AllenInstitute / bmtk

Brain Modeling Toolkit
https://alleninstitute.github.io/bmtk/
BSD 3-Clause "New" or "Revised" License
275 stars 89 forks source link

Assigning Individual cell model configuration file to each node of a population #371

Open Jballbe opened 6 months ago

Jballbe commented 6 months ago

Hi,

I am trying to create a network using PointNet, in which each node in a given population would have individual dynamics_params. Therefore, in the add_node call, I give a list of model ( current_pop_dict['model_list']) which contains one model json config file for each cell (e.g. : the list will be of length 100 if N=100)


            net.add_nodes(N=current_pop_dict['N'],  # Create a population of 80 neurons
                          positions = position_obj._all_positions[0],

                          pop_name=current_pop_dict['pop_name'],
                          layer = current_pop_dict['pop_name'].split('_')[1],

                          ei= current_pop_dict['ei'],  # optional parameters
                          model_type='point_process',  # Tells the simulator to use point-based neurons
                          model_template='nest:glif_lif_asc_psc',  # tells the simulator to use NEST iaf_psc_alpha models
                          dynamics_params=current_pop_dict['model_list'] # File containing iaf_psc_alpha mdoel parameters
                         )
            net.build()
            net.save_nodes(output_dir=network_dir)

But when I call

configure = pointnet.Config.from_json(config_file)
    configure.build_env()

    network = pointnet.PointNetwork.from_config(configure)
    sim = pointnet.PointSimulator.from_config(configure, network)
    sim.run()

I get the error:

File ~/anaconda3/envs/wBMTKAllenSDKNEST/lib/python3.11/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File ~/My_Work/BMTK/Test_folder/run_pointnet_Test.py:14
    main('/Users/julienballbe/My_Work/BMTK/Test_folder/Test_config_file.json')

  File ~/My_Work/BMTK/Test_folder/run_pointnet_Test.py:9 in main
    sim = pointnet.PointSimulator.from_config(configure, network)

  File ~/anaconda3/envs/wBMTKAllenSDKNEST/lib/python3.11/site-packages/bmtk/simulator/pointnet/pointsimulator.py:278 in from_config
    graph.build_nodes()

  File ~/anaconda3/envs/wBMTKAllenSDKNEST/lib/python3.11/site-packages/bmtk/simulator/pointnet/pointnetwork.py:152 in build_nodes
    node.build()

  File ~/anaconda3/envs/wBMTKAllenSDKNEST/lib/python3.11/site-packages/bmtk/simulator/pointnet/sonata_adaptors.py:65 in build
    self._nest_objs = nest.Create(self.nest_model, self.n_nodes, self.nest_params)

  File ~/anaconda3/envs/wBMTKAllenSDKNEST/lib/python3.11/site-packages/bmtk/simulator/pointnet/sonata_adaptors.py:58 in nest_params
    return self._nt_table[self._nt_id]['dynamics_params']

KeyError: 'dynamics_params'

Indeed, it turns out that the nodes_type.csv file doesn't contain a column "dynamics_params", even though when I look in the node.h5 file, each node from a given population is correctly assigned an individual cell model configuration file.

Is there a way to do so? Or should I conclude that for each "node_type_id" there must be a unique model configuration file?

I hope I am clear,

Thank you for any help you can give me,

Best, Julien