opencortex utils Package

Utility functions for OpenCortex. See opencortex.core for the main module for user interaction with OpenCortex.

opencortex.utils Package

opencortex.utils.add_populations_in_cylindrical_layers(net, boundaryDict, popDict, radiusOfCylinder, storeSoma=True, cellBodiesOverlap=True, cellDiameterArray=None, numOfSides=None)

This method distributes the cells in cylindrical layers. The input arguments:

net - libNeuroML network object;

popDict - a dictionary whose keys are unique cell population ids; each key entry stores a tuple of five elements: population size, Layer tag, cell model id, compartmentalization, color;

layer tags (of type string) must make up the keys() of boundaryDict;

boundaryDict have layer pointers as keys; each entry stores the left and right bound of the layer in the list format , e.g. [L3_min, L3_max]

x_vector - a vector that stores the left and right bounds of the cortical column along x dimension

y_vector - a vector that stores the left and right bounds of the cortical column along y dimension

radiusOfCylinder - radius of cylindrical column in which cortical cells will be distributed.

storeSoma - specifies whether soma positions have to be stored in the output array (default is set to True);

cellBodiesOverlap - boolean value which defines whether cell somata can overlap; default is set to True;

cellDiameterArray - optional dictionary of cell model diameters required when cellBodiesOverlap is set to False;

numOfSides - optional argument which specifies the number of sides of regular polygon which is inscribed in the cylindrical column of a given radius; default value is None, thus cylindrical but not polygonal shape is built.

This method returns the dictionary; each key is a unique cell population id and the corresponding value is a dictionary which refers to libNeuroML population object (key ‘PopObj’) and cell position array (‘Positions’) which by default is None.

opencortex.utils.add_populations_in_rectangular_layers(net, boundaryDict, popDict, x_vector, z_vector, storeSoma=True, cellBodiesOverlap=True, cellDiameterArray=None)

This method distributes the cells in rectangular layers. The input arguments:

net - libNeuroML network object;

popDict - a dictionary whose keys are unique cell population ids; each key entry stores a tuple of five elements: population size, Layer tag, cell model id, compartmentalization, color;

layer tags (of type string) must make up the keys() of boundaryDict;

boundaryDict have layer pointers as keys; each entry stores the left and right bound of the layer in the list format , e.g. [L3_min, L3_max]

x_vector - a vector that stores the left and right bounds of the cortical column along x dimension

y_vector - a vector that stores the left and right bounds of the cortical column along y dimension

storeSoma - specifies whether soma positions have to be stored in the output array (default is set to True).

cellBodiesOverlap - boolean value which defines whether cell somata can overlap; default is set to True;

cellDiameterArray - optional dictionary of cell model diameters required when cellBodiesOverlap is set to False;

This method returns the dictionary; each key is a unique cell population id and the corresponding value is a dictionary which refers to libNeuroML population object (key ‘PopObj’) and cell position array (‘Positions’) which by default is None.

opencortex.utils.build_connectivity(net, pop_objects, path_to_cells, full_path_to_conn_summary, pre_segment_group_info=[], return_cached_dicts=True, synaptic_scaling_params=None, synaptic_delay_params=None, distance_dependence_params=None, ignore_synapses=[])

This method calls the appropriate build and utils methods to build connectivity of the NeuroML2 cortical network. Input arguments are as follows:

net- NeuroML2 network object;

pop_objects - dictionary of population parameters in the format returned by the utils method add_populations_in_rectangular_layers() or add_populations_in_cylindrical_layers();

path_to_cells - dir path to the folder where target NeuroML2 .cell.nml files are found;

full_path_to_conn_sumary - full path to the file which stores the connectivity summary, e.g. file named netConnList in the current working dir, then this string must be “netConnList”;

pre_segment_group_info - input argument of type ‘list’ which specifies presynaptic segment groups; made to supplement connectivity summary of type netConnList in the Thalamocortical project; default value is []; alternatively it might have one value of type’dict’ or several values of type ‘dict’; in the former case, dict should contain the fields ‘PreSegGroup’ and ‘ProjType’; in the latter case each dictionary should contain the fields ‘PrePop’, ‘PostPop’, ‘PreSegGroup’ and ‘ProjType’, which uniquely specifies one presynaptic segment group per pair of cell populations per type of projection.

return_cached_dicts - boolean-type argument which specifies whether build_connectivity returns the cached dictionary of cummulative distributions of segment lengths for all of the target segment groups. If return_cached_dicts is set to True the last output argument that is returned by build_connectivity is a cached target dictionary; the cached target dictionary is specifically built by the method check_cached_dicts inside utils;

synaptic_scaling_params - optional input argument, default value is None. Alternatively, it takes the format of

[{‘weight’:2.0,’synComp’:’all’}] or

[{‘weight’:2.5,’synComp’:’GABAA’,’synEndsWith’:[],’targetCellGroup’:[]},
{‘weight’:0.5,’synComp’:’Syn_Elect_DeepPyr_DeepPyr’,’synEndsWith’:[],’targetCellGroup’:[‘CG3D_L5’]} ]. Tailored for the NeuroML2 Thalamocortical project.

synaptic_delay_params - optional input argument, default value is None. Alternatively ,it takes the format similar to the synaptic_scaling_params:

[{‘delay’:0.05,’synComp’:’all’}] or

[{‘delay’:0.10,’synComp’:’GABAA’,’synEndsWith’:[],’targetCellGroup’:[]},
{‘delay’:0.05,’synComp’:’Syn_Elect_DeepPyr_DeepPyr’,’synEndsWith’:[],’targetCellGroup’:[‘CG3D_L5’]} ]. Tailored for the NeuroML2 Thalamocortical project.

distance_dependent_params - optional input argument, default value is None. Alternatively, it take the format of

[{‘PrePopID’:’Pop1’,’PostPopID’:’Pop2’,’DistDependConn’:’- 17.45 + 18.36 / (math.exp((r-267.)/39.) +1)’,’Type’:’Elect’}].

opencortex.utils.build_inputs(nml_doc, net, population_params, input_params, cached_dicts=None, path_to_cells=None, path_to_synapses=None)

a wrapper method that calls appropriate methods to build inputs to the NeuroML2 network. Input arguments:

nml_doc - a libNeuroML doc object;

net - a libNeuroML net object;

population_params - a dictionary that stores population parameters in the format returned by the method add_populations_in_layers;

input_params -a dictionary that specifies input parameters for any given cell model. The format can be checked by the method check_inputs. Dictionary values must

be of type ‘list’ and can thus define multiple input groups on any given cell type. Examples where lists contain only one input group but differ in other parameters:

Example 1: input_params={‘TCR’:[{‘InputType’:’GeneratePoissonTrains’,
‘InputName’:’TransPoiInputs’, ‘TrainType’:’transient’, ‘Synapse’:’Syn_AMPA_L6NT_TCR’, ‘AverageRateList’:[0.05], ‘DurationList’:[200.0], ‘DelayList’:[20.0], ‘FractionToTarget’:1.0, ‘LocationSpecific’:False, ‘TargetRegions’:[{‘XVector’:[2,12],’YVector’:[3,5],’ZVector’:[0,5]}], ‘TargetDict’:{‘dendrite_group’:1000 } }] }
Example 2: input_params={‘TCR’:[{‘InputType’:’PulseGenerators’,
‘InputName’:’PulseGenerator0’, ‘Noise’:False, ‘AmplitudeList’:[20.0,-20.0], ‘DurationList’:[100.0,50.0], ‘DelayList’:[50.0,200.0], ‘FractionToTarget’:1.0, ‘LocationSpecific’:False, ‘TargetDict’:{‘dendrite_group’:2 } }] }
Example 3: input_params={‘CG3D_L23PyrRS’:[{‘InputType’:’PulseGenerators’,
‘InputName’:’PulseGenerator0’, ‘Noise’:True, ‘SmallestAmplitudeList’:[5.0E-5], ‘LargestAmplitudeList’:[1.0E-4], ‘DurationList’:[20000.0], ‘DelayList’:[0.0], ‘TimeUnits’:’ms’, ‘AmplitudeUnits’:’uA’, ‘FractionToTarget’:1.0, ‘LocationSpecific’:False, ‘UniqueTargetSegmentID’:0, ‘UniqueFractionAlong’:0.5 }] } ;

cached_dicts - optional argument, default value is set to None; otherwise should be the input variable that stores the dictionary in the format returned by check_cached_dicts;

path_to_cells - dir where NeuroML2 cell files are found;

path_to_synapses - dir where NeuroML2 synapse files are found.

opencortex.utils.build_probability_based_connectivity(net, pop_params, probability_matrix, synapse_matrix, weight_matrix, delay_matrix, tags_on_populations, std_weight_matrix=None, std_delay_matrix=None)

‘Method which build network projections based on the probability matrix which specifies the probabilities between given populations. Input arguments:

net- NeuroML2 network object;

pop_params - dictionary of population parameters in the format returned by the utils method add_populations_in_rectangular_layers() or add_populations_in_cylindrical_layers();

probability_matrix - n by n array (list of lists or numpy array) which specifies the connection probabilities between the presynaptic and postsynaptic populations; the first index is for the target population (postsynaptic) and the second index is for the source population (presynaptic); can be 1 by 1 matrix , then probability is applied to all pairs of populations; probability values must be of type ‘float’;

synapse_matrix - n by n array (list of lists) which specifies the synapse components per projections; each element has be of the type ‘list’ because generically physical projection can contain multiple synaptic components;

weight_matrix - n by n array (list of lists or numpy array) which specifies the weight values for projections; each matrix element should be of type ‘float’ or if synaptic components per given projection differ in weights, then a corresponding matrix element must be a list containing ‘float’ values;

delay_matrix - n by n array (list of lists or numpy array) which specifies the delay values for projections; each matrix element should be of type ‘float’ or if synaptic components per given projection differ in delays, then a corresponding matrix elment must be a list containing ‘float’ values;

tags_on_populations - a list of n strings which tags the network populations; cannot have length larger than the number of populations; index of the population tag in tags_on_populations must correspond to the position of the matrix element in a standard way, e.g.

tags_on_populations= [ ‘pop1’, ‘pop2’ ], thus ‘pop1’ index is 0 and ‘pop2’ index is 1;

source population (presynaptic)

target population (postsynaptic) ‘pop1’ ‘pop2’

‘pop1’ (0,0) value in matrix (0,1) value in matrix

‘pop2’ (1,0) value in matrix (1,1) value in matrix . This applies to all matrices.

std_weight_matrix - optional matrix in the format weight_synapse which specifies the corresponding standard deviations of synaptic weights; default is set to None;

std_delay_matrix - optional matrix in the format delay_synapse which specifies the corresponding standard deviations of synaptic delays; default is set to None.

opencortex.utils.build_projection(net, proj_counter, proj_type, presynaptic_population, postsynaptic_population, synapse_list, targeting_mode, pre_seg_length_dict, post_seg_length_dict, num_of_conn_dict, distance_dependent_rule=None, pre_cell_positions=None, post_cell_positions=None, delays_dict=None, weights_dict=None)

This method calls the appropriate methods that construct chemical or electrical projections. The input arguments are as follows:

net - the network object created using libNeuroML ( neuroml.Network() );

proj_counter - stores the number of projections at any given moment;

proj_type - ‘Chem’ or ‘Elect’ depending on whether the projection is chemical or electrical.

presynaptic_population - object corresponding to the presynaptic population in the network;

postsynaptic_population - object corresponding to the postsynaptic population in the network;

synapse_list - the list of synapse ids that correspond to the individual receptor components on the physical synapse, e.g. the first element is the id of the AMPA synapse and the second element is the id of the NMDA synapse; these synapse components will be mapped onto the same location of the target segment;

targeting_mode - specifies the type of projection: divergent or convergent;

pre_seg_length_dict - a dictionary whose keys are the ids of presynaptic segment groups and the values are dictionaries in the format returned by make_target_dict();

post_seg_length_dict - a dictionary whose keys are the ids of target segment groups and the values are dictionaries in the format returned by make_target_dict();

num_of_conn_dict - a dictionary whose keys are the ids of target segment groups with the corresponding values of type ‘int’ specifying the number of connections per tarrget segment group per each cell.

distance_dependent_rule - optional string which defines the distance dependent rule of connectivity - soma to soma distance must be represented by the string character ‘r’;

pre_cell_positions- optional array specifying the cell positions for the presynaptic population; the format is an array of [ x coordinate, y coordinate, z coordinate];

post_cell_positions- optional array specifying the cell positions for the postsynaptic population; the format is an array of [ x coordinate, y coordinate, z coordinate];

delays_dict - optional dictionary that specifies the delays (in ms) for individual synapse components, e.g. {‘NMDA’:5.0} or {‘AMPA’:3.0,’NMDA’:5};

weights_dict - optional dictionary that specifies the weights for individual synapse components, e.g. {‘NMDA’:1} or {‘NMDA’:1,’AMPA’:2}.

opencortex.utils.check_cached_dicts(cell_component, cached_dicts, list_of_target_seg_groups, path_to_nml2=None)

This method checks whether information is missing on target segment groups and updates the output dictionary with new information for the target cell component.

opencortex.utils.check_delay_params(delay_params)
opencortex.utils.check_includes_in_cells(dir_to_cells, list_of_cell_ids, extra_channel_tags=None)
opencortex.utils.check_inputs(input_params, popDict, path_to_cells, path_to_synapses=None)
opencortex.utils.check_matrix_size_and_type(matrix_of_params, num_of_pop_tags, type_of_matrix)

Method to check whether the size and the type of the connection parameter matrix, corresponds to the number of tags provided for the list of populations.

opencortex.utils.check_pop_dict_and_layers(pop_dict, boundary_dict)
opencortex.utils.check_pre_segment_groups(pre_segment_group_info)
opencortex.utils.check_segment_group(segment_groups, target_segment_group)
opencortex.utils.check_synapse_location(synapse_id, pathToSynapses)
opencortex.utils.check_weight_params(weight_params)
opencortex.utils.get_segment_groups(cell_id, path_to_cells)
opencortex.utils.parse_delays(delays_params, post_pop, synapse_list)
opencortex.utils.parse_distance_dependence_params(distance_dependence_params, pre_pop, post_pop, proj_type)
opencortex.utils.parse_parameter_value(parameter_matrix, row_ind, col_ind, checks_passed=False)

Method to parse one of the connectivity parameters; by default assumes that checks are carried out by the method check_matrix_size_and_type().

opencortex.utils.parse_weights(weights_params, post_pop, synapse_list)
opencortex.utils.read_connectivity(pre_pop, post_pop, path_to_txt_file, ignore_synapses=[])

Method that reads the txt file in the format of netConnList found in: Thalamocortical/neuroConstruct/pythonScripts/netbuild.

opencortex.utils.replace_cell_types(net_file_name, path_to_net, new_net_id, cell_types_to_be_replaced, cell_types_replaced_by, dir_to_new_components, dir_to_old_components, reduced_to_single_compartment=True, validate_nml2=True, return_synapses=False, connection_segment_groups=None, input_segment_groups=None, synapse_file_tags=None)

This method substitutes the target cell types to a given NeuroML2 cortical network.