def add_inputs_to_population(net, id, population, input_comp_id, all_cells=False, only_cells=None): if all_cells and only_cells is not None: opencortex.print_comment_v("Error! Method opencortex.build.%s() called with both arguments all_cells and only_cells set!"%sys._getframe().f_code.co_name) exit(-1) cell_ids = [] if all_cells: cell_ids = range(population.size) if only_cells is not None: if only_cells == []: return cell_ids = only_cells input_list = neuroml.InputList(id=id, component=input_comp_id, populations=population.id) count = 0 for cell_id in cell_ids: input = neuroml.Input(id=count, target="../%s/%i/%s"%(population.id, cell_id, population.component), destination="synapses") input_list.input.append(input) count+=1 if count>0: net.input_lists.append(input_list) return input_list
def generate_network(reference, network_seed=1234, temperature='32degC'): """ Generate a network which will contain populations, projections, etc. Arguments: `reference` the reference to use as the id for the network `network_seed` optional, will be used for random elements of the network, e.g. placement of cells in 3D `temperature` optional, will be specified in network and used in temperature dependent elements, e.g. ion channels with Q10. Default: 32degC """ del oc_build.all_included_files[:] oc_build.all_cells.clear() nml_doc = neuroml.NeuroMLDocument(id='%s' % reference) random.seed(network_seed) nml_doc.properties.append(neuroml.Property("Network seed", network_seed)) # Create network network = neuroml.Network(id='%s' % reference, type='networkWithTemperature', temperature=temperature) nml_doc.networks.append(network) opencortex.print_comment_v( "Created NeuroMLDocument containing a network with id: %s" % reference) return nml_doc, network
def add_targeted_electrical_projection(nml_doc, net, prefix, presynaptic_population, postsynaptic_population, targeting_mode, synapse_list, number_conns_per_cell, pre_segment_group, post_segment_group): ''' Adds (electrical, gap junction mediated) projection from `presynaptic_population` to `postsynaptic_population`, specifically limiting connections presynaptically to `pre_segment_group` and postsynaptically to `post_segment_group`. ''' if presynaptic_population.size == 0 or postsynaptic_population.size == 0: return None projections = [] pre_cell = oc_build.cell_ids_vs_nml_docs[ presynaptic_population.component].get_by_id( presynaptic_population.component) post_cell = oc_build.cell_ids_vs_nml_docs[ postsynaptic_population.component].get_by_id( postsynaptic_population.component) pre_segs = oc_build.extract_seg_ids(pre_cell, [pre_segment_group], "segGroups") post_segs = oc_build.extract_seg_ids(post_cell, [post_segment_group], "segGroups") pre_seg_target_dict = oc_build.make_target_dict(pre_cell, pre_segs) post_seg_target_dict = oc_build.make_target_dict(post_cell, post_segs) #print pre_seg_target_dict, post_seg_target_dict for synapse in synapse_list: proj_id = "%s_%s_%s" % (prefix, presynaptic_population.id, postsynaptic_population.id) if len(synapse_list) == 1 else \ "%s_%s_%s_%s" % (prefix, presynaptic_population.id, postsynaptic_population.id, synapse) opencortex.print_comment_v( "Adding projection: %s: %s (%s) -> %s (%s)" % (proj_id, pre_cell.id, pre_segs, post_cell.id, post_segs)) proj = neuroml.ElectricalProjection( id=proj_id, presynaptic_population=presynaptic_population.id, postsynaptic_population=postsynaptic_population.id) projections.append(proj) subset_dict = {} #{'dendrite_group':number_conns_per_cell} subset_dict[post_segment_group] = number_conns_per_cell oc_build._add_elect_projection(net, projections, presynaptic_population, postsynaptic_population, targeting_mode, synapse_list, pre_seg_target_dict, post_seg_target_dict, subset_dict) return projections
def generate_network(reference, seed=1234, temperature='32degC'): del all_included_files[:] all_cells.clear() nml_doc = neuroml.NeuroMLDocument(id='%s'%reference) random.seed(seed) nml_doc.properties.append(neuroml.Property("Python random seed",seed)) # Create network network = neuroml.Network(id='%s'%reference, type='networkWithTemperature', temperature=temperature) nml_doc.networks.append(network) opencortex.print_comment_v("Created NeuroMLDocument containing a network with id: %s"%reference) return nml_doc, network
def save_network(nml_doc, nml_file_name, validate=True, comment=True, format='xml'): info = "\n\nThis NeuroML 2 file was generated by OpenCortex v%s using: \n"%(opencortex.__version__) info += " libNeuroML v%s\n"%(neuroml.__version__) info += " pyNeuroML v%s\n\n "%(pyneuroml.__version__) if nml_doc.notes: nml_doc.notes += info else: nml_doc.notes = info if format == 'xml': writers.NeuroMLWriter.write(nml_doc, nml_file_name) elif format == 'hdf5': writers.NeuroMLHdf5Writer.write(nml_doc, nml_file_name) opencortex.print_comment_v("Saved NeuroML with id: %s to %s"%(nml_doc.id, nml_file_name)) if validate: from pyneuroml.pynml import validate_neuroml2 passed = validate_neuroml2(nml_file_name) if passed: opencortex.print_comment_v("Generated NeuroML file is valid") else: opencortex.print_comment_v("Generated NeuroML file is NOT valid!")
def save_network(nml_doc, nml_file_name, validate=True, format='xml', max_memory=None, target_dir='./', use_subfolder=True): """ Save the contents of the built NeuroML document, including the network to the file specified by `nml_file_name`, optionally specifying the `target_dir` """ oc_build._finalise_copy_to_dir_for_model(nml_doc, target_dir, use_subfolder=use_subfolder) info = "\n\nThis NeuroML 2 file was generated by OpenCortex v%s using: \n" % ( opencortex.__version__) info += " libNeuroML v%s\n" % (neuroml.__version__) info += " pyNeuroML v%s\n\n " % (pyneuroml.__version__) if nml_doc.notes: nml_doc.notes += info else: nml_doc.notes = info nml_full_file_name = target_dir + '/' + nml_file_name if format == 'xml': writers.NeuroMLWriter.write(nml_doc, nml_full_file_name) elif format == 'xml_hdf5': writers.NeuroMLHdf5Writer.write_xml_and_hdf5( nml_doc, nml_full_file_name, '%s.h5' % nml_full_file_name) elif format == 'hdf5': writers.NeuroMLHdf5Writer.write(nml_doc, nml_full_file_name) opencortex.print_comment_v("Saved NeuroML with id: %s to %s" % (nml_doc.id, nml_full_file_name)) if validate: from pyneuroml.pynml import validate_neuroml2 passed = validate_neuroml2(nml_full_file_name, max_memory=max_memory) if passed: opencortex.print_comment_v("Generated NeuroML file is valid") else: opencortex.print_comment_v("Generated NeuroML file is NOT valid!")
def add_targeted_inputs_to_population(net, id, population, input_comp_id, segment_group, number_per_cell=1, all_cells=False, only_cells=None): """ Add current input to the specified population. Attributes: `net` reference to the network object previously created `id` id of the <inputList> to be created `population` the <population> to be targeted `input_comp_id` id of the component to be used for the input (e.g. added with add_pulse_generator()) `segment_group` which segment group on the target cells to limit input locations to `number_per_cell` How many inputs to apply to each cell of the population. Default 1 `all_cells` whether to target all cells. Default False `only_cells` which specific cells to target. List of ids. Default None """ if all_cells and only_cells is not None: error = "Error! Method opencortex.build.%s() called with both arguments all_cells and only_cells set!" % sys._getframe( ).f_code.co_name opencortex.print_comment_v(error) raise Exception(error) cell_ids = [] target_cell = oc_build.cell_ids_vs_nml_docs[ population.component].get_by_id(population.component) target_segs = oc_build.extract_seg_ids(target_cell, [segment_group], "segGroups") seg_target_dict = oc_build.make_target_dict(target_cell, target_segs) subset_dict = {segment_group: number_per_cell} if all_cells: cell_ids = range(population.size) if only_cells is not None: if only_cells == []: return cell_ids = only_cells input_list = neuroml.InputList(id=id, component=input_comp_id, populations=population.id) count = 0 for cell_id in cell_ids: target_seg_array, target_fractions = oc_build.get_target_segments( seg_target_dict, subset_dict) for i in range(number_per_cell): input = neuroml.Input( id=count, target="../%s/%i/%s" % (population.id, cell_id, population.component), segment_id=target_seg_array[i], fraction_along=target_fractions[i], destination="synapses") input_list.input.append(input) count += 1 if count > 0: net.input_lists.append(input_list) return input_list
def add_inputs_to_population(net, id, population, input_comp_id, number_per_cell=1, all_cells=False, only_cells=None, segment_ids=[0], fraction_alongs=[0.5]): """ Add current input to the specified population. Attributes: `net` reference to the network object previously created `id` id of the <inputList> to be created `population` the <population> to be targeted `input_comp_id` id of the component to be used for the input (e.g. added with add_pulse_generator()) `number_per_cell` how many inputs to apply to each cell of the population. Default 1 `all_cells` Whether to target all cells. Default False `only_cells` Which specific cells to target. List of ids. Default None `segment_ids` List of segment ids to place inputs onto on each cell. Either list of 1 value or list of number_per_cell entries. Default [0] `fraction_alongs` List of fractions along the specified segments to place inputs onto on each cell. Either list of 1 value or list of number_per_cell entries. Default [0.5] """ if all_cells and only_cells is not None: error = "Error! Method opencortex.build.%s() called with both arguments all_cells and only_cells set!" % sys._getframe( ).f_code.co_name opencortex.print_comment_v(error) raise Exception(error) if len(segment_ids) != 1 or len(segment_ids) != number_per_cell: error = "Error! Attribute segment_ids in method opencortex.build.%s()"% sys._getframe().f_code.co_name+\ " should be a list of one integer (id of the segment all inputs to each cell go into) or a "+ \ "list of the same length as number_per_cell!" opencortex.print_comment_v(error) raise Exception(error) if len(fraction_alongs) != 1 or len(fraction_alongs) != number_per_cell: error = "Error! Attribute fraction_alongs in method opencortex.build.%s()"% sys._getframe().f_code.co_name+\ " should be a list of one float (fraction along the segment all inputs to each cell go into) or a "+ \ "list of the same length as number_per_cell!" opencortex.print_comment_v(error) raise Exception(error) cell_ids = [] if all_cells: cell_ids = range(population.size) if only_cells is not None: if only_cells == []: return cell_ids = only_cells input_list = neuroml.InputList(id=id, component=input_comp_id, populations=population.id) count = 0 for cell_id in cell_ids: for i in range(number_per_cell): segment_id = -1 if len(segment_ids) == 1: segment_id = segment_ids[0] else: segment_id = segment_ids[i] fraction_along = -1 if len(fraction_alongs) == 1: fraction_along = fraction_alongs[0] else: fraction_along = fraction_alongs[i] if fraction_along < 0 or fraction_along > 1: error = "Error! Attribute fraction_along should be >=0 and <=1" opencortex.print_comment_v(error) raise Exception(error) input = neuroml.Input( id=count, target="../%s/%i/%s" % (population.id, cell_id, population.component), segment_id=segment_id, fraction_along=fraction_along, destination="synapses") input_list.input.append(input) count += 1 if count > 0: net.input_lists.append(input_list) return input_list
def add_targeted_projection(net, prefix, presynaptic_population, postsynaptic_population, targeting_mode, synapse_list, number_conns_per_cell, pre_segment_group=None, post_segment_group=None, delays_dict=None, weights_dict=None): ''' Adds (chemical, event based) projection from `presynaptic_population` to `postsynaptic_population`, specifically limiting connections presynaptically to `pre_segment_group` and postsynaptically to `post_segment_group`. `net` reference to the network object previously created `prefix` prefix to use in the id of the projection `presynaptic_population` presynaptic population e.g. added via add_population_in_rectangular_region() `postsynaptic_population` postsynaptic population e.g. added via add_population_in_rectangular_region() `targeting_mode` a string that specifies the targeting mode: 'convergent' or 'divergent' `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 `number_conns_per_cell` number of connections to make on each cell in the postsynaptic population (when targeting_mode='convergent') or from each cell in the presynaptic population (when targeting_mode='divergent') `pre_segment_group` which segment_group to target connennections from on the presynaptic population, e.g. axon_group. This can be left out or set to None if the presynaptic component has no morphology `post_segment_group` which segment_group to target connennections from on the postsynaptic population, e.g. dendrite_group. This can be left out or set to None if the postsynaptic component has no morphology `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 (in ms) for individual synapse components, e.g. {'NMDA':1} or {'NMDA':1,'AMPA':2} ''' if presynaptic_population.size == 0 or postsynaptic_population.size == 0: return None projections = [] if presynaptic_population.component in oc_build.cell_ids_vs_nml_docs: pre_cell = oc_build.cell_ids_vs_nml_docs[ presynaptic_population.component].get_by_id( presynaptic_population.component) else: pre_cell = "Undetermined" if postsynaptic_population.component in oc_build.cell_ids_vs_nml_docs: post_cell = oc_build.cell_ids_vs_nml_docs[ postsynaptic_population.component].get_by_id( postsynaptic_population.component) else: post_cell = "Undetermined" if pre_segment_group: pre_segs = oc_build.extract_seg_ids(pre_cell, [pre_segment_group], "segGroups") pre_seg_target_dict = oc_build.make_target_dict(pre_cell, pre_segs) else: pre_segs = None pre_seg_target_dict = None if post_segment_group: post_segs = oc_build.extract_seg_ids(post_cell, [post_segment_group], "segGroups") post_seg_target_dict = oc_build.make_target_dict(post_cell, post_segs) else: post_segs = None post_seg_target_dict = None #print pre_seg_target_dict, post_seg_target_dict for synapse in synapse_list: proj_id = "%s_%s_%s" % (prefix, presynaptic_population.id, postsynaptic_population.id) if len(synapse_list) == 1 else \ "%s_%s_%s_%s" % (prefix, presynaptic_population.id, postsynaptic_population.id, synapse) opencortex.print_comment_v( "Adding projection: %s: %s#%s, %s (%s) -> %s#%s, %s (%s)" % (proj_id, presynaptic_population.id, presynaptic_population.size, pre_cell, pre_segs, postsynaptic_population.id, postsynaptic_population.size, post_cell, post_segs)) proj = neuroml.Projection( id=proj_id, presynaptic_population=presynaptic_population.id, postsynaptic_population=postsynaptic_population.id, synapse=synapse) projections.append(proj) subset_dict = {} #{'dendrite_group':number_conns_per_cell} subset_dict[post_segment_group] = number_conns_per_cell oc_build.add_targeted_projection_by_dicts( net, projections, presynaptic_population, postsynaptic_population, targeting_mode, synapse_list, pre_seg_target_dict, post_seg_target_dict, subset_dict, delays_dict, weights_dict) return projections
def RunColumnSimulation(net_id="TestRunColumn", nml2_source_dir="../../../neuroConstruct/generatedNeuroML2/", sim_config="TempSimConfig", scale_cortex=0.1, scale_thalamus=0.1, cell_bodies_overlap=True, cylindrical=True, default_synaptic_delay=0.05, gaba_scaling=1.0, l4ss_ampa_scaling=1.0, l5pyr_gap_scaling =1.0, in_nrt_tcr_nmda_scaling =1.0, pyr_ss_nmda_scaling=1.0, deep_bias_current=-1, include_gap_junctions=True, which_cell_types_to_include='all', dir_nml2="../../", backgroundL5Rate=30, # Hz backgroundL23Rate=30, # Hz duration=300, dt=0.025, max_memory='1000M', seed=1234, simulator=None, save_format='xml', num_of_cylinder_sides=None): popDictFull = {} ############## Full model ################################## popDictFull['CG3D_L23PyrRS'] = (1000, 'L23','L23PyrRS','multi', occ.L23_PRINCIPAL_CELL) popDictFull['CG3D_L23PyrFRB']= (50,'L23','L23PyrFRB_varInit','multi', occ.L23_PRINCIPAL_CELL_2) popDictFull['CG3D_SupBask'] = (90, 'L23','SupBasket','multi', occ.L23_INTERNEURON) # over both l23 & l4 popDictFull['CG3D_SupAxAx'] = (90, 'L23','SupAxAx','multi', occ.L23_INTERNEURON_2) # over both l23 & l4 popDictFull['CG3D_SupLTS']= (90,'L23','SupLTSInter','multi', occ.L4_INTERNEURON) # over both l23 & l4 popDictFull['CG3D_L4SpinStell']= (240,'L4','L4SpinyStellate','multi', occ.L4_PRINCIPAL_CELL) popDictFull['CG3D_L5TuftIB'] = (800, 'L5','L5TuftedPyrIB','multi', occ.L5_PRINCIPAL_CELL) popDictFull['CG3D_L5TuftRS']= (200,'L5','L5TuftedPyrRS','multi', occ.L5_PRINCIPAL_CELL_2) popDictFull['CG3D_L6NonTuftRS']= (500,'L6','L6NonTuftedPyrRS','multi', occ.L6_PRINCIPAL_CELL) popDictFull['CG3D_DeepAxAx']= (100,'L6','DeepAxAx','multi', occ.L5_INTERNEURON) # over both l5 & l6 popDictFull['CG3D_DeepBask']= (100,'L6','DeepBasket','multi', occ.L5_INTERNEURON_2) # over both l5 & l6 popDictFull['CG3D_DeepLTS']= (100,'L6','DeepLTSInter','multi', occ.L6_INTERNEURON) # over both l5 & l6 popDictFull['CG3D_nRT']= (100,'Thalamus','nRT','multi', occ.THALAMUS_1) popDictFull['CG3D_TCR']= (100,'Thalamus','TCR','multi', occ.THALAMUS_2) ############################################################### dir_to_cells=os.path.join(dir_nml2,"cells") dir_to_synapses=os.path.join(dir_nml2,"synapses") dir_to_gap_junctions=os.path.join(dir_nml2,"gapJunctions") popDict={} cell_model_list=[] cell_diameter_dict={} nml_doc, network = oc.generate_network(net_id,seed) for cell_population in popDictFull.keys(): include_cell_population=False cell_model=popDictFull[cell_population][2] if which_cell_types_to_include=='all' or cell_model in which_cell_types_to_include: popDict[cell_population]=() if popDictFull[cell_population][1] !='Thalamus': popDict[cell_population]=(int(round(scale_cortex*popDictFull[cell_population][0])), popDictFull[cell_population][1], popDictFull[cell_population][2], popDictFull[cell_population][3], popDictFull[cell_population][4]) cell_count=int(round(scale_cortex*popDictFull[cell_population][0])) else: popDict[cell_population]=(int(round(scale_thalamus*popDictFull[cell_population][0])), popDictFull[cell_population][1], popDictFull[cell_population][2], popDictFull[cell_population][3], popDictFull[cell_population][4]) cell_count=int(round(scale_thalamus*popDictFull[cell_population][0])) if cell_count !=0: include_cell_population=True if include_cell_population: cell_model_list.append(popDictFull[cell_population][2]) cell_diameter=oc_build.get_soma_diameter(popDictFull[cell_population][2],dir_to_cell=dir_to_cells) if popDictFull[cell_population][2] not in cell_diameter_dict.keys(): cell_diameter_dict[popDictFull[cell_population][2]]=cell_diameter cell_model_list_final=list(set(cell_model_list)) opencortex.print_comment_v("This is a final list of cell model ids: %s"%cell_model_list_final) copy_nml2_from_source=False for cell_model in cell_model_list_final: if not os.path.exists(os.path.join(dir_to_cells,"%s.cell.nml"%cell_model)): copy_nml2_from_source=True break if copy_nml2_from_source: oc_build.copy_nml2_source(dir_to_project_nml2=dir_nml2, primary_nml2_dir=nml2_source_dir, electrical_synapse_tags=['Elect'], chemical_synapse_tags=['.synapse.'], extra_channel_tags=['cad']) passed_includes_in_cells=oc_utils.check_includes_in_cells(dir_to_cells,cell_model_list_final,extra_channel_tags=['cad']) if not passed_includes_in_cells: opencortex.print_comment_v("Execution of RunColumn.py will terminate.") quit() for cell_model in cell_model_list_final: oc_build._add_cell_and_channels(nml_doc, os.path.join(dir_to_cells,"%s.cell.nml"%cell_model), cell_model, use_prototypes=False) t1=-0 t2=-250 t3=-250 t4=-200.0 t5=-300.0 t6=-300.0 t7=-200.0 t8=-200.0 boundaries={} boundaries['L1']=[0,t1] boundaries['L23']=[t1,t1+t2+t3] boundaries['L4']=[t1+t2+t3,t1+t2+t3+t4] boundaries['L5']=[t1+t2+t3+t4,t1+t2+t3+t4+t5] boundaries['L6']=[t1+t2+t3+t4+t5,t1+t2+t3+t4+t5+t6] boundaries['Thalamus']=[t1+t2+t3+t4+t5+t6+t7,t1+t2+t3+t4+t5+t6+t7+t8] xs = [0,500] zs = [0,500] passed_pops=oc_utils.check_pop_dict_and_layers(pop_dict=popDict,boundary_dict=boundaries) if passed_pops: opencortex.print_comment_v("Population parameters were specified correctly.") if cylindrical: pop_params=oc_utils.add_populations_in_cylindrical_layers(network,boundaries,popDict,radiusOfCylinder=250,cellBodiesOverlap=cell_bodies_overlap, cellDiameterArray=cell_diameter_dict,numOfSides=num_of_cylinder_sides) else: pop_params=oc_utils.add_populations_in_rectangular_layers(network,boundaries,popDict,xs,zs,cellBodiesOverlap=False,cellDiameterArray=cell_diameter_dict) else: opencortex.print_comment_v("Population parameters were specified incorrectly; execution of RunColumn.py will terminate.") quit() src_files = os.listdir("./") if 'netConnList' in src_files: full_path_to_connectivity='netConnList' else: full_path_to_connectivity="../../../neuroConstruct/pythonScripts/netbuild/netConnList" weight_params=[{'weight':gaba_scaling,'synComp':'GABAA','synEndsWith':[],'targetCellGroup':[]}, {'weight':l4ss_ampa_scaling,'synComp':'Syn_AMPA_L4SS_L4SS','synEndsWith':[],'targetCellGroup':[]}, {'weight':l5pyr_gap_scaling,'synComp':'Syn_Elect_DeepPyr_DeepPyr','synEndsWith':[],'targetCellGroup':['CG3D_L5']}, {'weight':in_nrt_tcr_nmda_scaling,'synComp':'NMDA','synEndsWith':["_IN","_DeepIN","_SupIN","_SupFS","_DeepFS","_SupLTS","_DeepLTS","_nRT","_TCR"], 'targetCellGroup':[]}, {'weight':pyr_ss_nmda_scaling,'synComp':'NMDA','synEndsWith':["_IN","_DeepIN","_SupIN","_SupFS","_DeepFS","_SupLTS","_DeepLTS","_nRT","_TCR"], 'targetCellGroup':[]}] delay_params=[{'delay':default_synaptic_delay,'synComp':'all'}] passed_weight_params=oc_utils.check_weight_params(weight_params) passed_delay_params=oc_utils.check_delay_params(delay_params) if passed_weight_params and passed_delay_params: opencortex.print_comment_v("Synaptic weight and delay parameters were specified correctly.") ignore_synapses = [] if not include_gap_junctions: ignore_synapses = ['Syn_Elect_SupPyr_SupPyr','Syn_Elect_CortIN_CortIN','Syn_Elect_L4SS_L4SS','Syn_Elect_DeepPyr_DeepPyr','Syn_Elect_nRT_nRT'] all_synapse_components,projArray,cached_segment_dicts=oc_utils.build_connectivity(net=network, pop_objects=pop_params, path_to_cells=dir_to_cells, full_path_to_conn_summary=full_path_to_connectivity, pre_segment_group_info=[{'PreSegGroup':"distal_axon",'ProjType':'Chem'}], synaptic_scaling_params=weight_params, synaptic_delay_params=delay_params, ignore_synapses=ignore_synapses) else: if not passed_weight_params: opencortex.print_comment_v("Synaptic weight parameters were specified incorrectly; execution of RunColumn.py will terminate.") if not passed_delay_params: opencortex.print_comment_v("Synaptic delay parameters were specified incorrectly; execution of RunColumn.py will terminate.") quit() ############ for testing only; will add original specifications later ############################################################## if sim_config=="Testing1": input_params={'CG3D_L23PyrRS':[{'InputType':'GeneratePoissonTrains', 'InputName':'Poi_CG3D_L23PyrRS', 'TrainType':'transient', 'Synapse':'Syn_AMPA_SupPyr_SupPyr', 'AverageRateList':[200.0,150.0], 'RateUnits':'Hz', 'TimeUnits':'ms', 'DurationList':[100.0,50.0], 'DelayList':[50.0,200.0], 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{'soma_group':1 } }] } ################################################################################################################################### if sim_config=="Testing2": input_params_final={'CG3D_L23PyrRS':[{'InputType':'PulseGenerators', 'InputName':"DepCurr_L23RS", 'Noise':True, 'SmallestAmplitudeList':[5.0E-5,1.0E-5], 'LargestAmplitudeList':[1.0E-4,2.0E-5], 'DurationList':[20000.0,20000.0], 'DelayList':[0.0,20000.0], 'TimeUnits':'ms', 'AmplitudeUnits':'uA', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{'dendrite_group':1} }] } if sim_config=="TempSimConfig": input_params ={'CG3D_L23PyrRS':[{'InputType':'PulseGenerators', 'InputName':"DepCurr_L23RS", '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, 'UniversalTargetSegmentID':0, 'UniversalFractionAlong':0.5}, {'InputType':'GeneratePoissonTrains', 'InputName':"BackgroundL23RS", 'TrainType':'persistent', 'Synapse':'Syn_AMPA_SupPyr_SupPyr', 'AverageRateList':[float(backgroundL23Rate)], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{'dendrite_group':100} }, {'InputType':'GeneratePoissonTrains', 'InputName':"EctopicStimL23RS", 'TrainType':'persistent', 'Synapse':'SynForEctStim', 'AverageRateList':[0.1], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':143, 'UniversalFractionAlong':0.5} ], 'CG3D_TCR':[{'InputType':'GeneratePoissonTrains', 'InputName':"EctopicStimTCR", 'TrainType':'persistent', 'Synapse':'SynForEctStim', 'AverageRateList':[1.0], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':269, 'UniversalFractionAlong':0.5}, {'InputType':'GeneratePoissonTrains', 'InputName':"Input_20", 'TrainType':'persistent', 'Synapse':'Syn_AMPA_L6NT_TCR', 'AverageRateList':[50.0], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{'dendrite_group':100} }], 'CG3D_L23PyrFRB':[{'InputType':'GeneratePoissonTrains', 'InputName':"EctopicStimL23FRB", 'TrainType':'persistent', 'Synapse':'SynForEctStim', 'AverageRateList':[0.1], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':143, 'UniversalFractionAlong':0.5}, {'InputType':'PulseGenerators', 'InputName':"DepCurr_L23FRB", 'Noise':True, 'SmallestAmplitudeList':[2.5E-4], 'LargestAmplitudeList':[3.5E-4], 'DurationList':[20000.0], 'DelayList':[0.0], 'TimeUnits':'ms', 'AmplitudeUnits':'uA', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':0, 'UniversalFractionAlong':0.5} ], 'CG3D_L6NonTuftRS':[{'InputType':'GeneratePoissonTrains', 'InputName':"EctopicStimL6NT", 'TrainType':'persistent', 'Synapse':'SynForEctStim', 'AverageRateList':[1.0], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':95, 'UniversalFractionAlong':0.5}, {'InputType':'PulseGenerators', 'InputName':"DepCurr_L6NT", '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, 'UniversalTargetSegmentID':0, 'UniversalFractionAlong':0.5} ], 'CG3D_L4SpinStell':[{'InputType':'PulseGenerators', 'InputName':"DepCurr_L4SS", '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, 'UniversalTargetSegmentID':0, 'UniversalFractionAlong':0.5}], 'CG3D_L5TuftIB':[{'InputType':'GeneratePoissonTrains', 'InputName':"BackgroundL5", 'TrainType':'persistent', 'Synapse':'Syn_AMPA_L5RS_L5Pyr', 'AverageRateList':[float(backgroundL5Rate)], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{'dendrite_group':100} }, {'InputType':'GeneratePoissonTrains', 'InputName':"EctopicStimL5IB", 'TrainType':'persistent', 'Synapse':'SynForEctStim', 'AverageRateList':[1.0], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':119, 'UniversalFractionAlong':0.5}, {'InputType':'PulseGenerators', 'InputName':"DepCurr_L5IB", '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, 'UniversalTargetSegmentID':0, 'UniversalFractionAlong':0.5} ], 'CG3D_L5TuftRS':[{'InputType':'GeneratePoissonTrains', 'InputName':"EctopicStimL5RS", 'TrainType':'persistent', 'Synapse':'SynForEctStim', 'AverageRateList':[1.0], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':119, 'UniversalFractionAlong':0.5}, {'InputType':'PulseGenerators', 'InputName':"DepCurr_L5RS", '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, 'UniversalTargetSegmentID':0, 'UniversalFractionAlong':0.5} ] } input_params_final={} for pop_id in pop_params.keys(): if pop_id in input_params.keys(): input_params_final[pop_id]=input_params[pop_id] if deep_bias_current >= 0: for cell_group in input_params_final.keys(): for input_group in range(0,len(input_params_final[cell_group])): check_type=input_params_final[cell_group][input_group]['InputType']=="PulseGenerators" check_group_1= cell_group=="CG3D_L5TuftIB" check_group_2=cell_group =="CG3D_L5TuftRS" check_group_3= cell_group =="CG3D_L6NonTuftRS" if check_type and (check_group_1 or check_group_2 or check_group_3): opencortex.print_comment_v("Changing offset current in 'PulseGenerators' for %s to %f"%(cell_group, deep_bias_current)) input_params_final[cell_group][input_group]['SmallestAmplitudeList']=[ (deep_bias_current-0.05)/1000 ] input_params_final[cell_group][input_group]['LargestAmplitudeList']=[ (deep_bias_current+0.05)/1000 ] input_list_array_final, input_synapse_list=oc_utils.build_inputs(nml_doc=nml_doc, net=network, population_params=pop_params, input_params=input_params_final, cached_dicts=cached_segment_dicts, path_to_cells=dir_to_cells, path_to_synapses=dir_to_synapses) #################################################################################################################################### for input_synapse in input_synapse_list: if input_synapse not in all_synapse_components: all_synapse_components.append(input_synapse) synapse_list=[] gap_junction_list=[] for syn_ind in range(0,len(all_synapse_components)): if 'Elect' not in all_synapse_components[syn_ind]: synapse_list.append(all_synapse_components[syn_ind]) all_synapse_components[syn_ind]=os.path.join(net_id,all_synapse_components[syn_ind]+".synapse.nml") else: gap_junction_list.append(all_synapse_components[syn_ind]) all_synapse_components[syn_ind]=os.path.join(net_id,all_synapse_components[syn_ind]+".nml") oc_build.add_synapses(nml_doc,dir_to_synapses,synapse_list,synapse_tag=True) oc_build.add_synapses(nml_doc,dir_to_gap_junctions,gap_junction_list,synapse_tag=False) nml_file_name = '%s.net.nml'%network.id validate=True if save_format=='hdf5': nml_file_name += '.h5' validate=False oc.save_network(nml_doc, nml_file_name, validate=validate,max_memory=max_memory, format=save_format) oc_build.remove_component_dirs(dir_to_project_nml2="%s"%network.id,list_of_cell_ids=cell_model_list_final,extra_channel_tags=['cad']) lems_file_name=oc.generate_lems_simulation(nml_doc, network, nml_file_name, duration =duration, dt =dt, include_extra_lems_files=all_synapse_components) if simulator != None: opencortex.print_comment_v("Starting simulation of %s.net.nml"%net_id) oc.simulate_network(lems_file_name=lems_file_name, simulator=simulator, max_memory=max_memory)
def RunPotjans2014(net_id='TestRunPotjans2014', neuron_params = {'cm' : 0.25, # nF 'i_offset' : 0.0, # nA 'tau_m' : 10.0, # ms 'tau_refrac': 2.0, # ms 'tau_syn_E' : 0.5, # ms 'tau_syn_I' : 0.5, # ms 'v_reset' : -65.0, # mV 'v_rest' : -65.0, # mV 'v_thresh' : -50.0, # mV 'v_init' : -58.0 # mV }, V0_mean = -58.0, V0_sd= 5.0, bg_rate=8.0, # spikes/s w_mean = 87.8e-3, # nA w_ext = 87.8e-3, # nA w_234 = 2 * 87.8e-3, # nA w_rel = 0.1, w_rel_234 = 0.05, d_mean = {'E': 1.5, 'I': 0.75}, d_sd = {'E': 0.75, 'I': 0.375}, K_ext = {'L23_E': 1600, 'L23_I': 1500, 'L4_E': 2100, 'L4_I': 1900, 'L5_E': 2000, 'L5_I': 1900, 'L6_E': 2900, 'L6_I': 2100}, full_mean_rates = {'L23_E': 0.971, 'L23_I': 2.868, 'L4_E': 4.746, 'L4_I': 5.396, 'L5_E': 8.142, 'L5_I': 9.078, 'L6_E' : 0.991, 'L6_I': 7.523}, thal_params = { # Number of neurons in thalamic population 'n_thal' : 902, # Connection probabilities 'C' : {'L23_E': 0, 'L23_I': 0, 'L4_E' : 0.0983, 'L4_I': 0.0619, 'L5_E' : 0, 'L5_I': 0, 'L6_E' : 0.0512, 'L6_I': 0.0196}, 'rate' : 120., # spikes/s; 'start' : 700., # ms 'duration' : 10. # ms; }, which_populations='all', which_pops_to_stimulate=[], scale_excitatory_cortex=0.01, scale_inhibitory_cortex=0.01, scale_thalamus=0.01, K_scaling=1.0, rel_inh_syn_w=-4.0, input_type='poisson', thalamic_input=False, build_connections=True, build_inputs=True, duration=300.0, dt=0.025, max_memory='4000M', seed=1234, simulator=None): ######################### Full-scale model ############################################################# popDictFull={} popDictFull['L23_E'] = (20683, 'L23','IF_curr_exp_L23_E','single') popDictFull['L23_I'] = (5834, 'L23','IF_curr_exp_L23_I','single') popDictFull['L4_E'] = (21915, 'L4','IF_curr_exp_L4_E','single') popDictFull['L4_I'] = (5479, 'L4','IF_curr_exp_L4_I','single') popDictFull['L5_E']= (4850,'L5','IF_curr_exp_L5_E','single') popDictFull['L5_I']= (1065,'L5','IF_curr_exp_L5_I','single') popDictFull['L6_E']= (14395,'L23','IF_curr_exp_L6_E','single') popDictFull['L6_I']= (2948,'L6','IF_curr_exp_L6_I','single') popDictFull['Thalamus']=(thal_params['n_thal'],'Thalamus','Thalamus_Input','single') pop_ids=['L23_E','L23_I','L4_E','L4_I', 'L5_E','L5_I', 'L6_E','L6_I'] n_layers = 4 n_pops_per_layer = 2 K_full = np.zeros([n_layers * n_pops_per_layer, n_layers * n_pops_per_layer]) ####################################################################################################### nml_doc, network = oc.generate_network(net_id,seed) popDict={} for cell_pop_id in popDictFull.keys(): if which_populations=='all' or cell_pop_id in which_populations: if 'Thalamus' not in cell_pop_id: popDict[cell_pop_id]=() if 'E' in cell_pop_id: popDict[cell_pop_id]=(int(round(scale_excitatory_cortex*popDictFull[cell_pop_id][0])), popDictFull[cell_pop_id][1], popDictFull[cell_pop_id][2], popDictFull[cell_pop_id][3]) if 'I' in cell_pop_id: popDict[cell_pop_id]=(int(round(scale_inhibitory_cortex*popDictFull[cell_pop_id][0])), popDictFull[cell_pop_id][1], popDictFull[cell_pop_id][2], popDictFull[cell_pop_id][3]) else: if thalamic_input: thal_tuple=(int(round(scale_thalamus*popDictFull[cell_pop_id][0])), popDictFull[cell_pop_id][1], popDictFull[cell_pop_id][2], popDictFull[cell_pop_id][3]) popDictFinal={} for cell_pop_id in popDict.keys(): if V0_mean != None and V0_sd != None: for cell_ind in range(0,popDict[cell_pop_id][0]): v0=random.gauss(V0_mean,V0_sd) new_pop_id=cell_pop_id+str(cell_ind) PyNN_cell=neuroml.IF_curr_exp(id=popDict[cell_pop_id][2]+str(cell_ind), cm=neuron_params['cm'], i_offset=neuron_params['i_offset'], tau_syn_E=neuron_params['tau_syn_E'], tau_syn_I=neuron_params['tau_syn_I'], v_init=v0, tau_m=neuron_params['tau_m'], tau_refrac=neuron_params['tau_refrac'], v_reset=neuron_params['v_reset'], v_rest=neuron_params['v_rest'], v_thresh=neuron_params['v_thresh']) nml_doc.IF_curr_exp.append(PyNN_cell) popDictFinal[new_pop_id]=(1,popDict[cell_pop_id][1],popDict[cell_pop_id][2]+str(cell_ind),popDict[cell_pop_id][3]) else: popDictFinal[cell_pop_id]=popDict[cell_pop_id] PyNN_cell=neuroml.IF_curr_exp(id=popDict[cell_pop_id][2], cm=neuron_params['cm'], i_offset=neuron_params['i_offset'], tau_syn_E=neuron_params['tau_syn_E'], tau_syn_I=neuron_params['tau_syn_I'], v_init=neuron_params['v_init'], tau_m=neuron_params['tau_m'], tau_refrac=neuron_params['tau_refrac'], v_reset=neuron_params['v_reset'], v_rest=neuron_params['v_rest'], v_thresh=neuron_params['v_thresh']) nml_doc.IF_curr_exp.append(PyNN_cell) t1=-100 t2=-150 t3=-150 t4=-300.0 t5=-300.0 t6=-300.0 t7=-200.0 t8=-200.0 boundaries={} boundaries['L1']=[0,t1] boundaries['L23']=[t1,t1+t2+t3] boundaries['L4']=[t1+t2+t3,t1+t2+t3+t4] boundaries['L5']=[t1+t2+t3+t4,t1+t2+t3+t4+t5] boundaries['L6']=[t1+t2+t3+t4+t5,t1+t2+t3+t4+t5+t6] boundaries['Thalamus']=[t1+t2+t3+t4+t5+t6+t7,t1+t2+t3+t4+t5+t6+t7+t8] xs = [0,1000] zs = [0,1000] passed_pops=oc_utils.check_pop_dict_and_layers(pop_dict=popDictFinal,boundary_dict=boundaries) if passed_pops: opencortex.print_comment_v("Population parameters were specified correctly.") #other options #pop_params=oc_utils.add_populations_in_cylindrical_layers(network,boundaries,popDictFinal,radiusOfCylinder=500,numOfSides=3) #pop_params=oc_utils.add_populations_in_cylindrical_layers(network,boundaries,popDictFinal,radiusOfCylinder=500) pop_params=oc_utils.add_populations_in_rectangular_layers(network,boundaries,popDictFinal,xs,zs) else: opencortex.print_comment_v("Population parameters were specified incorrectly; execution of RunPotjans2014.py will terminate.") quit() # Probabilities for >=1 connection between neurons in the given populations. # The first index is for the target population; the second for the source population # 2/3e 2/3i 4e 4i 5e 5i 6e 6i #pop_ids= ['L23_E','L23_I','L4_E','L4_I', 'L5_E','L5_I', 'L6_E','L6_I'] conn_probs = [[0.1009, 0.1689, 0.0437, 0.0818, 0.0323, 0., 0.0076, 0. ], [0.1346, 0.1371, 0.0316, 0.0515, 0.0755, 0., 0.0042, 0. ], [0.0077, 0.0059, 0.0497, 0.135, 0.0067, 0.0003, 0.0453, 0. ], [0.0691, 0.0029, 0.0794, 0.1597, 0.0033, 0., 0.1057, 0. ], [0.1004, 0.0622, 0.0505, 0.0057, 0.0831, 0.3726, 0.0204, 0. ], [0.0548, 0.0269, 0.0257, 0.0022, 0.06, 0.3158, 0.0086, 0. ], [0.0156, 0.0066, 0.0211, 0.0166, 0.0572, 0.0197, 0.0396, 0.2252], [0.0364, 0.001, 0.0034, 0.0005, 0.0277, 0.008, 0.0658, 0.1443]] conn_mean_w=[[w_mean, rel_inh_syn_w*w_mean, w_234 , rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean], [w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean], [w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean], [w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean], [w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean], [w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean], [w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean], [w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean, w_mean, rel_inh_syn_w*w_mean]] conn_std_w=[] for target_pop_index in range(0,len(pop_ids)): conn_std_w_per_target_pop=[] for source_pop_index in range(0,len(pop_ids)): w_val=conn_mean_w[target_pop_index][source_pop_index] if pop_ids[source_pop_index]=="L4_E" and pop_ids[target_pop_index]=="L23_E": w_sd=w_val*w_rel_234 else: w_sd=abs(w_val * w_rel) conn_std_w_per_target_pop.append(w_sd) conn_std_w.append(conn_std_w_per_target_pop) conn_mean_delay=[[d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I']], [d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I']], [d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I']], [d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I']], [d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I']], [d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I']], [d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I']], [d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I'], d_mean['E'], d_mean['I']]] conn_std_delay=[[d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I']], [d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I']], [d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I']], [d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I']], [d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I']], [d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I']], [d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I']], [d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I'], d_sd['E'], d_sd['I']]] syn=neuroml.ExpCurrSynapse(id='exp_curr_syn_all',tau_syn=0.5) nml_doc.exp_curr_synapses.append(syn) syn_id_matrix=[['exp_curr_syn_all']] # utils method build_probability_based_connectivity will assume that the same synapse model is shared by all projections; # however, it must be inside 'list' because generically each physical projection might contain multiple synaptic components. #### get in-degrees for all connections in the full scale model according to scaling.py in the original project for source_pop in pop_ids: for target_pop in pop_ids: n_target = popDictFull[target_pop][0] n_source = popDictFull[source_pop][0] K_full[pop_ids.index(target_pop)][pop_ids.index(source_pop)] = round(np.log(1. - conn_probs[pop_ids.index(target_pop)][pop_ids.index(source_pop)]) / np.log( (n_target * n_source - 1.) / (n_target * n_source))) / n_target input_params ={'L23_E':[{'InputType':'GenerateSpikeSourcePoisson', 'InputName':"EXT_L23_E", 'AverageRateList':[], 'DurationList':[], 'DelayList':[], 'WeightList':[], 'Synapse':'exp_curr_syn_all', 'RateUnits':'Hz', 'TimeUnits':'ms', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} }, {'InputType':'PulseGenerators', 'InputName':"Ext_L23_E", 'Noise':False, 'AmplitudeList':[], 'DurationList':[], 'DelayList':[], 'TimeUnits':'ms', 'AmplitudeUnits':'nA', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} }], 'L23_I':[{'InputType':'GenerateSpikeSourcePoisson', 'InputName':"EXT_L23_I", 'AverageRateList':[], 'DurationList':[], 'DelayList':[], 'WeightList':[], 'Synapse':'exp_curr_syn_all', 'RateUnits':'Hz', 'TimeUnits':'ms', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} }, {'InputType':'PulseGenerators', 'InputName':"Ext_L23_I", 'Noise':False, 'AmplitudeList':[], 'DurationList':[], 'DelayList':[], 'TimeUnits':'ms', 'AmplitudeUnits':'nA', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} }], 'L4_E':[ {'InputType':'GenerateSpikeSourcePoisson', 'InputName':"EXT_L4_E", 'AverageRateList':[], 'DurationList':[], 'DelayList':[], 'WeightList':[], 'Synapse':'exp_curr_syn_all', 'RateUnits':'Hz', 'TimeUnits':'ms', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} }, {'InputType':'PulseGenerators', 'InputName':"Ext_L4_E", 'Noise':False, 'AmplitudeList':[], 'DurationList':[], 'DelayList':[], 'TimeUnits':'ms', 'AmplitudeUnits':'nA', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} }], 'L4_I':[ {'InputType':'GenerateSpikeSourcePoisson', 'InputName':"EXT_L4_I", 'AverageRateList':[], 'DurationList':[], 'DelayList':[], 'WeightList':[], 'Synapse':'exp_curr_syn_all', 'RateUnits':'Hz', 'TimeUnits':'ms', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1}}, {'InputType':'PulseGenerators', 'InputName':"Ext_L4_I", 'Noise':False, 'AmplitudeList':[0.0], 'DurationList':[0.0], 'DelayList':[0.0], 'TimeUnits':'ms', 'AmplitudeUnits':'nA', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} } ], 'L5_E':[ {'InputType':'GenerateSpikeSourcePoisson', 'InputName':"EXT_L5_E", 'AverageRateList':[], 'DurationList':[], 'DelayList':[], 'WeightList':[], 'Synapse':'exp_curr_syn_all', 'RateUnits':'Hz', 'TimeUnits':'ms', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} }, {'InputType':'PulseGenerators', 'InputName':"Ext_L5_E", 'Noise':False, 'AmplitudeList':[], 'DurationList':[], 'DelayList':[], 'TimeUnits':'ms', 'AmplitudeUnits':'nA', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} } ], 'L5_I':[ {'InputType':'GenerateSpikeSourcePoisson', 'InputName':"EXT_L5_I", 'AverageRateList':[], 'DurationList':[], 'DelayList':[], 'WeightList':[], 'Synapse':'exp_curr_syn_all', 'RateUnits':'Hz', 'TimeUnits':'ms', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} }, {'InputType':'PulseGenerators', 'InputName':"Ext_L5_I", 'Noise':False, 'AmplitudeList':[], 'DurationList':[], 'DelayList':[], 'TimeUnits':'ms', 'AmplitudeUnits':'nA', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} } ], 'L6_E':[ {'InputType':'GenerateSpikeSourcePoisson', 'InputName':"EXT_L6_E", 'AverageRateList':[], 'DurationList':[], 'DelayList':[], 'WeightList':[], 'Synapse':'exp_curr_syn_all', 'RateUnits':'Hz', 'TimeUnits':'ms', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} }, {'InputType':'PulseGenerators', 'InputName':"Ext_L6_E", 'Noise':False, 'AmplitudeList':[], 'DurationList':[], 'DelayList':[], 'TimeUnits':'ms', 'AmplitudeUnits':'nA', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} } ], 'L6_I':[ {'InputType':'GenerateSpikeSourcePoisson', 'InputName':"EXT_L6_I", 'AverageRateList':[], 'DurationList':[], 'DelayList':[], 'WeightList':[], 'Synapse':'exp_curr_syn_all', 'RateUnits':'Hz', 'TimeUnits':'ms', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} }, {'InputType':'PulseGenerators', 'InputName':"Ext_L6_I", 'Noise':False, 'AmplitudeList':[], 'DurationList':[], 'DelayList':[], 'TimeUnits':'ms', 'AmplitudeUnits':'nA', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{None:1} } ] } DC_amp = {} for target_pop_index in range(0,len(pop_ids)): if input_type == "DC": DC_amp[pop_ids[target_pop_index]] = bg_rate *K_ext[pop_ids[target_pop_index]] * w_mean * neuron_params['tau_syn_E'] / 1000.0 else: DC_amp[pop_ids[target_pop_index]]= 0.0 if K_scaling != 1 : for target_pop_index in range(0,len(pop_ids)): input_coefficient = 0 for source_pop_index in range(0,len(pop_ids)): input_coefficient += conn_mean_w[target_pop_index][source_pop_index] * K_full[target_pop_index][source_pop_index] * full_mean_rates[pop_ids[source_pop_index]] conn_mean_w[target_pop_index][source_pop_index] = conn_mean_w[target_pop_index][source_pop_index] / np.sqrt(K_scaling) if input_type=="poisson": input_coefficient += w_ext*K_ext[pop_ids[target_pop_index]]*bg_rate K_ext[pop_ids[target_pop_index]] = K_ext[pop_ids[target_pop_index]]*K_scaling DC_amp[pop_ids[target_pop_index]] = 0.001 * neuron_params['tau_syn_E'] * \ (1. - np.sqrt(K_scaling)) * input_coefficient + DC_amp[pop_ids[target_pop_index]] w_ext = w_ext / np.sqrt(K_scaling) input_params_final={} for target_pop_tag in input_params.keys(): found_target_pop=False for pop_id in pop_params.keys(): if target_pop_tag in pop_id: found_target_pop=True break if found_target_pop and ( (target_pop_tag in which_pops_to_stimulate) or (which_pops_to_stimulate==[])): input_params_final[target_pop_tag]=[] for input_group_ind in range(0,len(input_params[target_pop_tag])): if (input_type=='DC' or K_scaling !=1) and input_params[target_pop_tag][input_group_ind]['InputType']=='PulseGenerators': input_params[target_pop_tag][input_group_ind]['AmplitudeList'].append(DC_amp[target_pop_tag]) input_params[target_pop_tag][input_group_ind]['DurationList'].append(duration) input_params[target_pop_tag][input_group_ind]['DelayList'].append(0.0) input_params_final[target_pop_tag].append(input_params[target_pop_tag][input_group_ind]) if input_type=='poisson' and input_params[target_pop_tag][input_group_ind]['InputType']=='GenerateSpikeSourcePoisson': input_params[target_pop_tag][input_group_ind]['AverageRateList'].append(bg_rate*K_ext[target_pop_tag]) input_params[target_pop_tag][input_group_ind]['WeightList'].append(w_ext) input_params[target_pop_tag][input_group_ind]['DurationList'].append(duration) input_params[target_pop_tag][input_group_ind]['DelayList'].append(0.0) input_params_final[target_pop_tag].append(input_params[target_pop_tag][input_group_ind]) if build_connections: proj_array=oc_utils.build_probability_based_connectivity(net=network, pop_params=pop_params, probability_matrix=conn_probs, synapse_matrix=syn_id_matrix, weight_matrix=conn_mean_w, delay_matrix=conn_mean_delay, tags_on_populations=pop_ids, std_weight_matrix=conn_std_w, std_delay_matrix=conn_std_delay) if build_inputs: input_list_array_final, input_synapse_list=oc_utils.build_inputs(nml_doc=nml_doc, net=network, population_params=pop_params, input_params=input_params_final, cached_dicts=None, path_to_cells=None, path_to_synapses=None) if thalamic_input: if thal_tuple[0] != 0: if duration > thal_params['start']: start_time="%f ms"%thal_params['start'] else: start_time="0 ms" oc.add_spike_source_poisson(nml_doc, id=thal_tuple[2], start=start_time, duration="%f ms"%thal_params['duration'], rate="%f Hz"%thal_params['rate']) thalamus_pop = neuroml.Population(id='Thalamus', component=thal_tuple[2], size=thal_tuple[0] ) network.populations.append(thalamus_pop) for target_pop in thal_params['C'].keys(): for pop_id in pop_params.keys(): if target_pop in pop_id: oc.add_probabilistic_projection_list(net=network, presynaptic_population=thalamus_pop, postsynaptic_population=pop_params[pop_id]['PopObj'], synapse_list=['exp_curr_syn_all'], connection_probability=thal_params['C'][target_pop], delay = d_mean['E'], weight = w_ext, presynaptic_population_list=False, std_delay=d_sd['E'], std_weight=w_ext*w_rel) else: print("Note: thalamic_input is set to True but population was scaled down to zero, thus thalamic input will not be added.") nml_file_name = '%s.net.nml'%network.id oc.save_network(nml_doc, nml_file_name, validate=True,max_memory=max_memory) lems_file_name=oc.generate_lems_simulation(nml_doc, network, nml_file_name, duration =duration, dt =dt, include_extra_lems_files=["PyNN.xml"], gen_plots_for_all_v = False, gen_plots_for_only_populations=pop_params.keys(), gen_saves_for_all_v = False, gen_saves_for_only_populations=pop_params.keys() ) if simulator != None: opencortex.print_comment_v("Starting simulation of %s.net.nml"%net_id) oc.simulate_network(lems_file_name=lems_file_name, simulator=simulator, max_memory=max_memory)
########################################################################################################################## ### This script was developed as part of GSoC 2016 project on Cortical Network Development ################### ## Author : Rokas Stanislovas ############################################# ########################################################################################################################## #### Converting https://github.com/NeuralEnsemble/PyNN/tree/master/examples/Potjans2014 to NeuroML2 using OpenCortex API## import opencortex import opencortex.build as oc import opencortex.utils as oc_utils import neuroml import random import numpy as np opencortex.print_comment_v("Using OpenCortex to convert Potjans2014 interface to NeuroML2") def RunPotjans2014(net_id='TestRunPotjans2014', neuron_params = {'cm' : 0.25, # nF 'i_offset' : 0.0, # nA 'tau_m' : 10.0, # ms 'tau_refrac': 2.0, # ms 'tau_syn_E' : 0.5, # ms 'tau_syn_I' : 0.5, # ms 'v_reset' : -65.0, # mV 'v_rest' : -65.0, # mV 'v_thresh' : -50.0, # mV 'v_init' : -58.0 # mV }, V0_mean = -58.0, V0_sd= 5.0, bg_rate=8.0, # spikes/s w_mean = 87.8e-3, # nA
{'Type':'Elect','PreCellType':"pyr_4_sym",'PreSegGroup':"soma_group",'PostCellType':"bask",'PostSegGroup':"dendrite_group"}, {'Type':'Elect','PreCellType':"bask",'PreSegGroup':"dendrite_group",'PostCellType':"bask",'PostSegGroup':"dendrite_group"}, {'Type':'Elect','PreCellType':"bask",'PreSegGroup':"dendrite_group",'PostCellType':"pyr_4_sym",'PostSegGroup':"dendrite_group"}], input_segment_groups=[{'PostCellType':"pyr_4_sym",'PostSegGroup':"dendrite_group"},{'PostCellType':"bask",'PostSegGroup':"dendrite_group"}], synapse_file_tags=['.synapse.','Syn','Elect']) nml_doc=pynml.read_neuroml2_file("TestRunColumnAllenInstitute.net.nml") network=nml_doc.networks[0] lems_file_name=oc_build.generate_lems_simulation(nml_doc, network, "TestRunColumnAllenInstitute.net.nml", duration =100, dt =0.020, include_extra_lems_files=include_these_synapses) opencortex.print_comment_v("Starting simulation of %s.net.nml"%"TestRunColumnAllenInstitute") oc_build.simulate_network(lems_file_name=lems_file_name, simulator="jNeuroML_NEURON", max_memory="4000M")
'PostCellType': "pyr_4_sym", 'PostSegGroup': "dendrite_group" }], input_segment_groups=[{ 'PostCellType': "pyr_4_sym", 'PostSegGroup': "dendrite_group" }, { 'PostCellType': "bask", 'PostSegGroup': "dendrite_group" }], synapse_file_tags=['.synapse.', 'Syn', 'Elect']) nml_doc = pynml.read_neuroml2_file("TestRunColumnAllenInstitute.net.nml") network = nml_doc.networks[0] lems_file_name = oc_build.generate_lems_simulation( nml_doc, network, "TestRunColumnAllenInstitute.net.nml", duration=100, dt=0.020, include_extra_lems_files=include_these_synapses) opencortex.print_comment_v("Starting simulation of %s.net.nml" % "TestRunColumnAllenInstitute") oc_build.simulate_network(lems_file_name=lems_file_name, simulator="jNeuroML_NEURON", max_memory="4000M")
def RunColumnSimulation(net_id="TestRunColumn", nml2_source_dir="../../../neuroConstruct/generatedNeuroML2/", sim_config="TempSimConfig", scale_cortex=0.1, scale_thalamus=0.1, cell_bodies_overlap=True, cylindrical=True, default_synaptic_delay=0.05, gaba_scaling=1.0, l4ss_ampa_scaling=1.0, l5pyr_gap_scaling =1.0, in_nrt_tcr_nmda_scaling =1.0, pyr_ss_nmda_scaling=1.0, deep_bias_current=-1, include_gap_junctions=True, which_cell_types_to_include='all', dir_nml2="../../", backgroundL5Rate=30, # Hz backgroundL23Rate=30, # Hz duration=300, dt=0.025, max_memory='1000M', seed=1234, simulator=None, num_of_cylinder_sides=None): popDictFull = {} ############## Full model ################################## popDictFull['CG3D_L23PyrRS'] = (1000, 'L23','L23PyrRS','multi', occ.L23_PRINCIPAL_CELL) popDictFull['CG3D_L23PyrFRB']= (50,'L23','L23PyrFRB_varInit','multi', occ.L23_PRINCIPAL_CELL_2) popDictFull['CG3D_SupBask'] = (90, 'L23','SupBasket','multi', occ.L23_INTERNEURON) # over both l23 & l4 popDictFull['CG3D_SupAxAx'] = (90, 'L23','SupAxAx','multi', occ.L23_INTERNEURON_2) # over both l23 & l4 popDictFull['CG3D_SupLTS']= (90,'L23','SupLTSInter','multi', occ.L4_INTERNEURON) # over both l23 & l4 popDictFull['CG3D_L4SpinStell']= (240,'L4','L4SpinyStellate','multi', occ.L4_PRINCIPAL_CELL) popDictFull['CG3D_L5TuftIB'] = (800, 'L5','L5TuftedPyrIB','multi', occ.L5_PRINCIPAL_CELL) popDictFull['CG3D_L5TuftRS']= (200,'L5','L5TuftedPyrRS','multi', occ.L5_PRINCIPAL_CELL_2) popDictFull['CG3D_L6NonTuftRS']= (500,'L6','L6NonTuftedPyrRS','multi', occ.L6_PRINCIPAL_CELL) popDictFull['CG3D_DeepAxAx']= (100,'L6','DeepAxAx','multi', occ.L5_INTERNEURON) # over both l5 & l6 popDictFull['CG3D_DeepBask']= (100,'L6','DeepBasket','multi', occ.L5_INTERNEURON_2) # over both l5 & l6 popDictFull['CG3D_DeepLTS']= (100,'L6','DeepLTSInter','multi', occ.L6_INTERNEURON) # over both l5 & l6 popDictFull['CG3D_nRT']= (100,'Thalamus','nRT','multi', occ.THALAMUS_1) popDictFull['CG3D_TCR']= (100,'Thalamus','TCR','multi', occ.THALAMUS_2) ############################################################### dir_to_cells=os.path.join(dir_nml2,"cells") dir_to_synapses=os.path.join(dir_nml2,"synapses") dir_to_gap_junctions=os.path.join(dir_nml2,"gapJunctions") popDict={} cell_model_list=[] cell_diameter_dict={} nml_doc, network = oc.generate_network(net_id,seed) for cell_population in popDictFull.keys(): include_cell_population=False cell_model=popDictFull[cell_population][2] if which_cell_types_to_include=='all' or cell_model in which_cell_types_to_include: popDict[cell_population]=() if popDictFull[cell_population][1] !='Thalamus': popDict[cell_population]=(int(round(scale_cortex*popDictFull[cell_population][0])), popDictFull[cell_population][1], popDictFull[cell_population][2], popDictFull[cell_population][3], popDictFull[cell_population][4]) cell_count=int(round(scale_cortex*popDictFull[cell_population][0])) else: popDict[cell_population]=(int(round(scale_thalamus*popDictFull[cell_population][0])), popDictFull[cell_population][1], popDictFull[cell_population][2], popDictFull[cell_population][3], popDictFull[cell_population][4]) cell_count=int(round(scale_thalamus*popDictFull[cell_population][0])) if cell_count !=0: include_cell_population=True if include_cell_population: cell_model_list.append(popDictFull[cell_population][2]) cell_diameter=oc_build.get_soma_diameter(popDictFull[cell_population][2],dir_to_cell=dir_to_cells) if popDictFull[cell_population][2] not in cell_diameter_dict.keys(): cell_diameter_dict[popDictFull[cell_population][2]]=cell_diameter cell_model_list_final=list(set(cell_model_list)) opencortex.print_comment_v("This is a final list of cell model ids: %s"%cell_model_list_final) copy_nml2_from_source=False for cell_model in cell_model_list_final: if not os.path.exists(os.path.join(dir_to_cells,"%s.cell.nml"%cell_model)): copy_nml2_from_source=True break if copy_nml2_from_source: oc_build.copy_nml2_source(dir_to_project_nml2=dir_nml2, primary_nml2_dir=nml2_source_dir, electrical_synapse_tags=['Elect'], chemical_synapse_tags=['.synapse.'], extra_channel_tags=['cad']) passed_includes_in_cells=oc_utils.check_includes_in_cells(dir_to_cells,cell_model_list_final,extra_channel_tags=['cad']) if not passed_includes_in_cells: opencortex.print_comment_v("Execution of RunColumn.py will terminate.") quit() for cell_model in cell_model_list_final: oc_build._add_cell_and_channels(nml_doc, os.path.join(dir_to_cells,"%s.cell.nml"%cell_model), cell_model, use_prototypes=False) t1=-0 t2=-250 t3=-250 t4=-200.0 t5=-300.0 t6=-300.0 t7=-200.0 t8=-200.0 boundaries={} boundaries['L1']=[0,t1] boundaries['L23']=[t1,t1+t2+t3] boundaries['L4']=[t1+t2+t3,t1+t2+t3+t4] boundaries['L5']=[t1+t2+t3+t4,t1+t2+t3+t4+t5] boundaries['L6']=[t1+t2+t3+t4+t5,t1+t2+t3+t4+t5+t6] boundaries['Thalamus']=[t1+t2+t3+t4+t5+t6+t7,t1+t2+t3+t4+t5+t6+t7+t8] xs = [0,500] zs = [0,500] passed_pops=oc_utils.check_pop_dict_and_layers(pop_dict=popDict,boundary_dict=boundaries) if passed_pops: opencortex.print_comment_v("Population parameters were specified correctly.") if cylindrical: pop_params=oc_utils.add_populations_in_cylindrical_layers(network,boundaries,popDict,radiusOfCylinder=250,cellBodiesOverlap=cell_bodies_overlap, cellDiameterArray=cell_diameter_dict,numOfSides=num_of_cylinder_sides) else: pop_params=oc_utils.add_populations_in_rectangular_layers(network,boundaries,popDict,xs,zs,cellBodiesOverlap=False,cellDiameterArray=cell_diameter_dict) else: opencortex.print_comment_v("Population parameters were specified incorrectly; execution of RunColumn.py will terminate.") quit() src_files = os.listdir("./") if 'netConnList' in src_files: full_path_to_connectivity='netConnList' else: full_path_to_connectivity="../../../neuroConstruct/pythonScripts/netbuild/netConnList" weight_params=[{'weight':gaba_scaling,'synComp':'GABAA','synEndsWith':[],'targetCellGroup':[]}, {'weight':l4ss_ampa_scaling,'synComp':'Syn_AMPA_L4SS_L4SS','synEndsWith':[],'targetCellGroup':[]}, {'weight':l5pyr_gap_scaling,'synComp':'Syn_Elect_DeepPyr_DeepPyr','synEndsWith':[],'targetCellGroup':['CG3D_L5']}, {'weight':in_nrt_tcr_nmda_scaling,'synComp':'NMDA','synEndsWith':["_IN","_DeepIN","_SupIN","_SupFS","_DeepFS","_SupLTS","_DeepLTS","_nRT","_TCR"], 'targetCellGroup':[]}, {'weight':pyr_ss_nmda_scaling,'synComp':'NMDA','synEndsWith':["_IN","_DeepIN","_SupIN","_SupFS","_DeepFS","_SupLTS","_DeepLTS","_nRT","_TCR"], 'targetCellGroup':[]}] delay_params=[{'delay':default_synaptic_delay,'synComp':'all'}] passed_weight_params=oc_utils.check_weight_params(weight_params) passed_delay_params=oc_utils.check_delay_params(delay_params) if passed_weight_params and passed_delay_params: opencortex.print_comment_v("Synaptic weight and delay parameters were specified correctly.") ignore_synapses = [] if not include_gap_junctions: ignore_synapses = ['Syn_Elect_SupPyr_SupPyr','Syn_Elect_CortIN_CortIN','Syn_Elect_L4SS_L4SS','Syn_Elect_DeepPyr_DeepPyr','Syn_Elect_nRT_nRT'] all_synapse_components,projArray,cached_segment_dicts=oc_utils.build_connectivity(net=network, pop_objects=pop_params, path_to_cells=dir_to_cells, full_path_to_conn_summary=full_path_to_connectivity, pre_segment_group_info=[{'PreSegGroup':"distal_axon",'ProjType':'Chem'}], synaptic_scaling_params=weight_params, synaptic_delay_params=delay_params, ignore_synapses=ignore_synapses) else: if not passed_weight_params: opencortex.print_comment_v("Synaptic weight parameters were specified incorrectly; execution of RunColumn.py will terminate.") if not passed_delay_params: opencortex.print_comment_v("Synaptic delay parameters were specified incorrectly; execution of RunColumn.py will terminate.") quit() ############ for testing only; will add original specifications later ############################################################## if sim_config=="Testing1": input_params={'CG3D_L23PyrRS':[{'InputType':'GeneratePoissonTrains', 'InputName':'Poi_CG3D_L23PyrRS', 'TrainType':'transient', 'Synapse':'Syn_AMPA_SupPyr_SupPyr', 'AverageRateList':[200.0,150.0], 'RateUnits':'Hz', 'TimeUnits':'ms', 'DurationList':[100.0,50.0], 'DelayList':[50.0,200.0], 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{'soma_group':1 } }] } ################################################################################################################################### if sim_config=="Testing2": input_params_final={'CG3D_L23PyrRS':[{'InputType':'PulseGenerators', 'InputName':"DepCurr_L23RS", 'Noise':True, 'SmallestAmplitudeList':[5.0E-5,1.0E-5], 'LargestAmplitudeList':[1.0E-4,2.0E-5], 'DurationList':[20000.0,20000.0], 'DelayList':[0.0,20000.0], 'TimeUnits':'ms', 'AmplitudeUnits':'uA', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{'dendrite_group':1} }] } if sim_config=="TempSimConfig": input_params ={'CG3D_L23PyrRS':[{'InputType':'PulseGenerators', 'InputName':"DepCurr_L23RS", '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, 'UniversalTargetSegmentID':0, 'UniversalFractionAlong':0.5}, {'InputType':'GeneratePoissonTrains', 'InputName':"BackgroundL23RS", 'TrainType':'persistent', 'Synapse':'Syn_AMPA_SupPyr_SupPyr', 'AverageRateList':[float(backgroundL23Rate)], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{'dendrite_group':100} }, {'InputType':'GeneratePoissonTrains', 'InputName':"EctopicStimL23RS", 'TrainType':'persistent', 'Synapse':'SynForEctStim', 'AverageRateList':[0.1], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':143, 'UniversalFractionAlong':0.5} ], 'CG3D_TCR':[{'InputType':'GeneratePoissonTrains', 'InputName':"EctopicStimTCR", 'TrainType':'persistent', 'Synapse':'SynForEctStim', 'AverageRateList':[1.0], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':269, 'UniversalFractionAlong':0.5}, {'InputType':'GeneratePoissonTrains', 'InputName':"Input_20", 'TrainType':'persistent', 'Synapse':'Syn_AMPA_L6NT_TCR', 'AverageRateList':[50.0], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{'dendrite_group':100} }], 'CG3D_L23PyrFRB':[{'InputType':'GeneratePoissonTrains', 'InputName':"EctopicStimL23FRB", 'TrainType':'persistent', 'Synapse':'SynForEctStim', 'AverageRateList':[0.1], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':143, 'UniversalFractionAlong':0.5}, {'InputType':'PulseGenerators', 'InputName':"DepCurr_L23FRB", 'Noise':True, 'SmallestAmplitudeList':[2.5E-4], 'LargestAmplitudeList':[3.5E-4], 'DurationList':[20000.0], 'DelayList':[0.0], 'TimeUnits':'ms', 'AmplitudeUnits':'uA', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':0, 'UniversalFractionAlong':0.5} ], 'CG3D_L6NonTuftRS':[{'InputType':'GeneratePoissonTrains', 'InputName':"EctopicStimL6NT", 'TrainType':'persistent', 'Synapse':'SynForEctStim', 'AverageRateList':[1.0], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':95, 'UniversalFractionAlong':0.5}, {'InputType':'PulseGenerators', 'InputName':"DepCurr_L6NT", '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, 'UniversalTargetSegmentID':0, 'UniversalFractionAlong':0.5} ], 'CG3D_L4SpinStell':[{'InputType':'PulseGenerators', 'InputName':"DepCurr_L4SS", '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, 'UniversalTargetSegmentID':0, 'UniversalFractionAlong':0.5}], 'CG3D_L5TuftIB':[{'InputType':'GeneratePoissonTrains', 'InputName':"BackgroundL5", 'TrainType':'persistent', 'Synapse':'Syn_AMPA_L5RS_L5Pyr', 'AverageRateList':[float(backgroundL5Rate)], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'TargetDict':{'dendrite_group':100} }, {'InputType':'GeneratePoissonTrains', 'InputName':"EctopicStimL5IB", 'TrainType':'persistent', 'Synapse':'SynForEctStim', 'AverageRateList':[1.0], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':119, 'UniversalFractionAlong':0.5}, {'InputType':'PulseGenerators', 'InputName':"DepCurr_L5IB", '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, 'UniversalTargetSegmentID':0, 'UniversalFractionAlong':0.5} ], 'CG3D_L5TuftRS':[{'InputType':'GeneratePoissonTrains', 'InputName':"EctopicStimL5RS", 'TrainType':'persistent', 'Synapse':'SynForEctStim', 'AverageRateList':[1.0], 'RateUnits':'Hz', 'FractionToTarget':1.0, 'LocationSpecific':False, 'UniversalTargetSegmentID':119, 'UniversalFractionAlong':0.5}, {'InputType':'PulseGenerators', 'InputName':"DepCurr_L5RS", '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, 'UniversalTargetSegmentID':0, 'UniversalFractionAlong':0.5} ] } input_params_final={} for pop_id in pop_params.keys(): if pop_id in input_params.keys(): input_params_final[pop_id]=input_params[pop_id] if deep_bias_current >= 0: for cell_group in input_params_final.keys(): for input_group in range(0,len(input_params_final[cell_group])): check_type=input_params_final[cell_group][input_group]['InputType']=="PulseGenerators" check_group_1= cell_group=="CG3D_L5TuftIB" check_group_2=cell_group =="CG3D_L5TuftRS" check_group_3= cell_group =="CG3D_L6NonTuftRS" if check_type and (check_group_1 or check_group_2 or check_group_3): opencortex.print_comment_v("Changing offset current in 'PulseGenerators' for %s to %f"%(cell_group, deep_bias_current)) input_params_final[cell_group][input_group]['SmallestAmplitudeList']=[ (deep_bias_current-0.05)/1000 ] input_params_final[cell_group][input_group]['LargestAmplitudeList']=[ (deep_bias_current+0.05)/1000 ] input_list_array_final, input_synapse_list=oc_utils.build_inputs(nml_doc=nml_doc, net=network, population_params=pop_params, input_params=input_params_final, cached_dicts=cached_segment_dicts, path_to_cells=dir_to_cells, path_to_synapses=dir_to_synapses) #################################################################################################################################### for input_synapse in input_synapse_list: if input_synapse not in all_synapse_components: all_synapse_components.append(input_synapse) synapse_list=[] gap_junction_list=[] for syn_ind in range(0,len(all_synapse_components)): if 'Elect' not in all_synapse_components[syn_ind]: synapse_list.append(all_synapse_components[syn_ind]) all_synapse_components[syn_ind]=os.path.join(net_id,all_synapse_components[syn_ind]+".synapse.nml") else: gap_junction_list.append(all_synapse_components[syn_ind]) all_synapse_components[syn_ind]=os.path.join(net_id,all_synapse_components[syn_ind]+".nml") oc_build.add_synapses(nml_doc,dir_to_synapses,synapse_list,synapse_tag=True) oc_build.add_synapses(nml_doc,dir_to_gap_junctions,gap_junction_list,synapse_tag=False) nml_file_name = '%s.net.nml'%network.id oc.save_network(nml_doc, nml_file_name, validate=True,max_memory=max_memory) oc_build.remove_component_dirs(dir_to_project_nml2="%s"%network.id,list_of_cell_ids=cell_model_list_final,extra_channel_tags=['cad']) lems_file_name=oc.generate_lems_simulation(nml_doc, network, nml_file_name, duration =duration, dt =dt, include_extra_lems_files=all_synapse_components) if simulator != None: opencortex.print_comment_v("Starting simulation of %s.net.nml"%net_id) oc.simulate_network(lems_file_name=lems_file_name, simulator=simulator, max_memory=max_memory)
def RunColumnSimulation( net_id="TestRunColumn", nml2_source_dir="../../../neuroConstruct/generatedNeuroML2/", sim_config="TempSimConfig", scale_cortex=0.1, scale_thalamus=0.1, cell_bodies_overlap=True, cylindrical=True, default_synaptic_delay=0.05, gaba_scaling=1.0, l4ss_ampa_scaling=1.0, l5pyr_gap_scaling=1.0, in_nrt_tcr_nmda_scaling=1.0, pyr_ss_nmda_scaling=1.0, deep_bias_current=-1, include_gap_junctions=True, which_models="all", dir_nml2="../../", duration=300, dt=0.025, max_memory="1000M", seed=1234, simulator=None, num_of_cylinder_sides=None, ): popDictFull = {} ############## Full model ################################## popDictFull["CG3D_L23PyrRS"] = (1000, "L23", "L23PyrRS", "multi") popDictFull["CG3D_SupBask"] = (90, "L23", "SupBasket", "multi") popDictFull["CG3D_SupAxAx"] = (90, "L23", "SupAxAx", "multi") popDictFull["CG3D_L5TuftIB"] = (800, "L5", "L5TuftedPyrIB", "multi") popDictFull["CG3D_L5TuftRS"] = (200, "L5", "L5TuftedPyrRS", "multi") popDictFull["CG3D_L4SpinStell"] = (240, "L4", "L4SpinyStellate", "multi") popDictFull["CG3D_L23PyrFRB"] = (50, "L23", "L23PyrFRB_varInit", "multi") popDictFull["CG3D_L6NonTuftRS"] = (500, "L6", "L6NonTuftedPyrRS", "multi") popDictFull["CG3D_DeepAxAx"] = (100, "L6", "DeepAxAx", "multi") popDictFull["CG3D_DeepBask"] = (100, "L6", "DeepBasket", "multi") popDictFull["CG3D_DeepLTS"] = (100, "L6", "DeepLTSInter", "multi") popDictFull["CG3D_SupLTS"] = (90, "L23", "SupLTSInter", "multi") popDictFull["CG3D_nRT"] = (100, "Thalamus", "nRT", "multi") popDictFull["CG3D_TCR"] = (100, "Thalamus", "TCR", "multi") ############################################################### dir_to_cells = os.path.join(dir_nml2, "cells") dir_to_synapses = os.path.join(dir_nml2, "synapses") dir_to_gap_junctions = os.path.join(dir_nml2, "gapJunctions") popDict = {} cell_model_list = [] cell_diameter_dict = {} nml_doc, network = oc.generate_network(net_id, seed) for cell_population in popDictFull.keys(): include_cell_population = False cell_model = popDictFull[cell_population][2] if which_models == "all" or cell_model in which_models: popDict[cell_population] = () if popDictFull[cell_population][1] != "Thalamus": popDict[cell_population] = ( int(round(scale_cortex * popDictFull[cell_population][0])), popDictFull[cell_population][1], popDictFull[cell_population][2], popDictFull[cell_population][3], ) cell_count = int(round(scale_cortex * popDictFull[cell_population][0])) else: popDict[cell_population] = ( int(round(scale_thalamus * popDictFull[cell_population][0])), popDictFull[cell_population][1], popDictFull[cell_population][2], popDictFull[cell_population][3], ) cell_count = int(round(scale_thalamus * popDictFull[cell_population][0])) if cell_count != 0: include_cell_population = True if include_cell_population: cell_model_list.append(popDictFull[cell_population][2]) cell_diameter = oc.get_soma_diameter(popDictFull[cell_population][2], dir_to_cell=dir_to_cells) if popDictFull[cell_population][2] not in cell_diameter_dict.keys(): cell_diameter_dict[popDictFull[cell_population][2]] = cell_diameter cell_model_list_final = list(set(cell_model_list)) opencortex.print_comment_v("This is a final list of cell model ids: %s" % cell_model_list_final) copy_nml2_from_source = False for cell_model in cell_model_list_final: if not os.path.exists(os.path.join(dir_to_cells, "%s.cell.nml" % cell_model)): copy_nml2_from_source = True break if copy_nml2_from_source: oc.copy_nml2_source( dir_to_project_nml2=dir_nml2, primary_nml2_dir=nml2_source_dir, electrical_synapse_tags=["Elect"], chemical_synapse_tags=[".synapse."], extra_channel_tags=["cad"], ) passed_includes_in_cells = oc_utils.check_includes_in_cells( dir_to_cells, cell_model_list_final, extra_channel_tags=["cad"] ) if not passed_includes_in_cells: opencortex.print_comment_v("Execution of RunColumn.py will terminate.") quit() for cell_model in cell_model_list_final: oc.add_cell_and_channels( nml_doc, os.path.join(dir_to_cells, "%s.cell.nml" % cell_model), cell_model, use_prototypes=False ) t1 = -0 t2 = -250 t3 = -250 t4 = -200.0 t5 = -300.0 t6 = -300.0 t7 = -200.0 t8 = -200.0 boundaries = {} boundaries["L1"] = [0, t1] boundaries["L23"] = [t1, t1 + t2 + t3] boundaries["L4"] = [t1 + t2 + t3, t1 + t2 + t3 + t4] boundaries["L5"] = [t1 + t2 + t3 + t4, t1 + t2 + t3 + t4 + t5] boundaries["L6"] = [t1 + t2 + t3 + t4 + t5, t1 + t2 + t3 + t4 + t5 + t6] boundaries["Thalamus"] = [t1 + t2 + t3 + t4 + t5 + t6 + t7, t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8] xs = [0, 500] zs = [0, 500] passed_pops = oc_utils.check_pop_dict_and_layers(pop_dict=popDict, boundary_dict=boundaries) if passed_pops: opencortex.print_comment_v("Population parameters were specified correctly.") if cylindrical: pop_params = oc_utils.add_populations_in_cylindrical_layers( network, boundaries, popDict, radiusOfCylinder=250, cellBodiesOverlap=cell_bodies_overlap, cellDiameterArray=cell_diameter_dict, numOfSides=num_of_cylinder_sides, ) else: pop_params = oc_utils.add_populations_in_rectangular_layers( network, boundaries, popDict, xs, zs, cellBodiesOverlap=False, cellDiameterArray=cell_diameter_dict ) else: opencortex.print_comment_v( "Population parameters were specified incorrectly; execution of RunColumn.py will terminate." ) quit() src_files = os.listdir("./") if "netConnList" in src_files: full_path_to_connectivity = "netConnList" else: full_path_to_connectivity = "../../../neuroConstruct/pythonScripts/netbuild/netConnList" weight_params = [ {"weight": gaba_scaling, "synComp": "GABAA", "synEndsWith": [], "targetCellGroup": []}, {"weight": l4ss_ampa_scaling, "synComp": "Syn_AMPA_L4SS_L4SS", "synEndsWith": [], "targetCellGroup": []}, { "weight": l5pyr_gap_scaling, "synComp": "Syn_Elect_DeepPyr_DeepPyr", "synEndsWith": [], "targetCellGroup": ["CG3D_L5"], }, { "weight": in_nrt_tcr_nmda_scaling, "synComp": "NMDA", "synEndsWith": ["_IN", "_DeepIN", "_SupIN", "_SupFS", "_DeepFS", "_SupLTS", "_DeepLTS", "_nRT", "_TCR"], "targetCellGroup": [], }, { "weight": pyr_ss_nmda_scaling, "synComp": "NMDA", "synEndsWith": ["_IN", "_DeepIN", "_SupIN", "_SupFS", "_DeepFS", "_SupLTS", "_DeepLTS", "_nRT", "_TCR"], "targetCellGroup": [], }, ] delay_params = [{"delay": default_synaptic_delay, "synComp": "all"}] passed_weight_params = oc_utils.check_weight_params(weight_params) passed_delay_params = oc_utils.check_delay_params(delay_params) if passed_weight_params and passed_delay_params: opencortex.print_comment_v("Synaptic weight and delay parameters were specified correctly.") ignore_synapses = [] if not include_gap_junctions: ignore_synapses = [ "Syn_Elect_SupPyr_SupPyr", "Syn_Elect_CortIN_CortIN", "Syn_Elect_L4SS_L4SS", "Syn_Elect_DeepPyr_DeepPyr", "Syn_Elect_nRT_nRT", ] all_synapse_components, projArray, cached_segment_dicts = oc_utils.build_connectivity( net=network, pop_objects=pop_params, path_to_cells=dir_to_cells, full_path_to_conn_summary=full_path_to_connectivity, pre_segment_group_info=[{"PreSegGroup": "distal_axon", "ProjType": "Chem"}], synaptic_scaling_params=weight_params, synaptic_delay_params=delay_params, ignore_synapses=ignore_synapses, ) else: if not passed_weight_params: opencortex.print_comment_v( "Synaptic weight parameters were specified incorrectly; execution of RunColumn.py will terminate." ) if not passed_delay_params: opencortex.print_comment_v( "Synaptic delay parameters were specified incorrectly; execution of RunColumn.py will terminate." ) quit() ############ for testing only; will add original specifications later ############################################################## if sim_config == "Testing1": input_params = { "CG3D_L23PyrRS": [ { "InputType": "GeneratePoissonTrains", "InputName": "Poi_CG3D_L23PyrRS", "TrainType": "transient", "Synapse": "Syn_AMPA_SupPyr_SupPyr", "AverageRateList": [200.0, 150.0], "RateUnits": "Hz", "TimeUnits": "ms", "DurationList": [100.0, 50.0], "DelayList": [50.0, 200.0], "FractionToTarget": 1.0, "LocationSpecific": False, "TargetDict": {"soma_group": 1}, } ] } ################################################################################################################################### if sim_config == "Testing2": input_params_final = { "CG3D_L23PyrRS": [ { "InputType": "PulseGenerators", "InputName": "DepCurr_L23RS", "Noise": True, "SmallestAmplitudeList": [5.0e-5, 1.0e-5], "LargestAmplitudeList": [1.0e-4, 2.0e-5], "DurationList": [20000.0, 20000.0], "DelayList": [0.0, 20000.0], "TimeUnits": "ms", "AmplitudeUnits": "uA", "FractionToTarget": 1.0, "LocationSpecific": False, "TargetDict": {"dendrite_group": 1}, } ] } if sim_config == "TempSimConfig": input_params = { "CG3D_L23PyrRS": [ { "InputType": "PulseGenerators", "InputName": "DepCurr_L23RS", "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, "UniversalTargetSegmentID": 0, "UniversalFractionAlong": 0.5, }, { "InputType": "GeneratePoissonTrains", "InputName": "BackgroundL23RS", "TrainType": "persistent", "Synapse": "Syn_AMPA_SupPyr_SupPyr", "AverageRateList": [30.0], "RateUnits": "Hz", "FractionToTarget": 1.0, "LocationSpecific": False, "TargetDict": {"dendrite_group": 100}, }, { "InputType": "GeneratePoissonTrains", "InputName": "EctopicStimL23RS", "TrainType": "persistent", "Synapse": "SynForEctStim", "AverageRateList": [0.1], "RateUnits": "Hz", "FractionToTarget": 1.0, "LocationSpecific": False, "UniversalTargetSegmentID": 143, "UniversalFractionAlong": 0.5, }, ], "CG3D_TCR": [ { "InputType": "GeneratePoissonTrains", "InputName": "EctopicStimTCR", "TrainType": "persistent", "Synapse": "SynForEctStim", "AverageRateList": [1.0], "RateUnits": "Hz", "FractionToTarget": 1.0, "LocationSpecific": False, "UniversalTargetSegmentID": 269, "UniversalFractionAlong": 0.5, }, { "InputType": "GeneratePoissonTrains", "InputName": "Input_20", "TrainType": "persistent", "Synapse": "Syn_AMPA_L6NT_TCR", "AverageRateList": [50.0], "RateUnits": "Hz", "FractionToTarget": 1.0, "LocationSpecific": False, "TargetDict": {"dendrite_group": 100}, }, ], "CG3D_L23PyrFRB": [ { "InputType": "GeneratePoissonTrains", "InputName": "EctopicStimL23FRB", "TrainType": "persistent", "Synapse": "SynForEctStim", "AverageRateList": [0.1], "RateUnits": "Hz", "FractionToTarget": 1.0, "LocationSpecific": False, "UniversalTargetSegmentID": 143, "UniversalFractionAlong": 0.5, }, { "InputType": "PulseGenerators", "InputName": "DepCurr_L23FRB", "Noise": True, "SmallestAmplitudeList": [2.5e-4], "LargestAmplitudeList": [3.5e-4], "DurationList": [20000.0], "DelayList": [0.0], "TimeUnits": "ms", "AmplitudeUnits": "uA", "FractionToTarget": 1.0, "LocationSpecific": False, "UniversalTargetSegmentID": 0, "UniversalFractionAlong": 0.5, }, ], "CG3D_L6NonTuftRS": [ { "InputType": "GeneratePoissonTrains", "InputName": "EctopicStimL6NT", "TrainType": "persistent", "Synapse": "SynForEctStim", "AverageRateList": [1.0], "RateUnits": "Hz", "FractionToTarget": 1.0, "LocationSpecific": False, "UniversalTargetSegmentID": 95, "UniversalFractionAlong": 0.5, }, { "InputType": "PulseGenerators", "InputName": "DepCurr_L6NT", "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, "UniversalTargetSegmentID": 0, "UniversalFractionAlong": 0.5, }, ], "CG3D_L4SpinStell": [ { "InputType": "PulseGenerators", "InputName": "DepCurr_L4SS", "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, "UniversalTargetSegmentID": 0, "UniversalFractionAlong": 0.5, } ], "CG3D_L5TuftIB": [ { "InputType": "GeneratePoissonTrains", "InputName": "BackgroundL5", "TrainType": "persistent", "Synapse": "Syn_AMPA_L5RS_L5Pyr", "AverageRateList": [30.0], "RateUnits": "Hz", "FractionToTarget": 1.0, "LocationSpecific": False, "TargetDict": {"dendrite_group": 100}, }, { "InputType": "GeneratePoissonTrains", "InputName": "EctopicStimL5IB", "TrainType": "persistent", "Synapse": "SynForEctStim", "AverageRateList": [1.0], "RateUnits": "Hz", "FractionToTarget": 1.0, "LocationSpecific": False, "UniversalTargetSegmentID": 119, "UniversalFractionAlong": 0.5, }, { "InputType": "PulseGenerators", "InputName": "DepCurr_L5IB", "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, "UniversalTargetSegmentID": 0, "UniversalFractionAlong": 0.5, }, ], "CG3D_L5TuftRS": [ { "InputType": "GeneratePoissonTrains", "InputName": "EctopicStimL5RS", "TrainType": "persistent", "Synapse": "SynForEctStim", "AverageRateList": [1.0], "RateUnits": "Hz", "FractionToTarget": 1.0, "LocationSpecific": False, "UniversalTargetSegmentID": 119, "UniversalFractionAlong": 0.5, }, { "InputType": "PulseGenerators", "InputName": "DepCurr_L5RS", "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, "UniversalTargetSegmentID": 0, "UniversalFractionAlong": 0.5, }, ], } input_params_final = {} for pop_id in pop_params.keys(): if pop_id in input_params.keys(): input_params_final[pop_id] = input_params[pop_id] if deep_bias_current >= 0: for cell_group in input_params_final.keys(): for input_group in range(0, len(input_params_final[cell_group])): check_type = input_params_final[cell_group][input_group]["InputType"] == "PulseGenerators" check_group_1 = cell_group == "CG3D_L5TuftIB" check_group_2 = cell_group == "CG3D_L5TuftRS" check_group_3 = cell_group == "CG3D_L6NonTuftRS" if check_type and (check_group_1 or check_group_2 or check_group_3): opencortex.print_comment_v( "Changing offset current in 'PulseGenerators' for %s to %f" % (cell_group, deep_bias_current) ) input_params_final[cell_group][input_group]["SmallestAmplitudeList"] = [ (deep_bias_current - 0.05) / 1000 ] input_params_final[cell_group][input_group]["LargestAmplitudeList"] = [ (deep_bias_current + 0.05) / 1000 ] input_list_array_final, input_synapse_list = oc_utils.build_inputs( nml_doc=nml_doc, net=network, population_params=pop_params, input_params=input_params_final, cached_dicts=cached_segment_dicts, path_to_cells=dir_to_cells, path_to_synapses=dir_to_synapses, ) #################################################################################################################################### for input_synapse in input_synapse_list: if input_synapse not in all_synapse_components: all_synapse_components.append(input_synapse) synapse_list = [] gap_junction_list = [] for syn_ind in range(0, len(all_synapse_components)): if "Elect" not in all_synapse_components[syn_ind]: synapse_list.append(all_synapse_components[syn_ind]) all_synapse_components[syn_ind] = os.path.join(net_id, all_synapse_components[syn_ind] + ".synapse.nml") else: gap_junction_list.append(all_synapse_components[syn_ind]) all_synapse_components[syn_ind] = os.path.join(net_id, all_synapse_components[syn_ind] + ".nml") oc.add_synapses(nml_doc, dir_to_synapses, synapse_list, synapse_tag=True) oc.add_synapses(nml_doc, dir_to_gap_junctions, gap_junction_list, synapse_tag=False) nml_file_name = "%s.net.nml" % network.id oc.save_network(nml_doc, nml_file_name, validate=True, max_memory=max_memory) oc.remove_component_dirs( dir_to_project_nml2="%s" % network.id, list_of_cell_ids=cell_model_list_final, extra_channel_tags=["cad"] ) lems_file_name = oc.generate_lems_simulation( nml_doc, network, nml_file_name, duration=duration, dt=dt, include_extra_lems_files=all_synapse_components ) if simulator != None: opencortex.print_comment_v("Starting simulation of %s.net.nml" % net_id) oc.simulate_network(lems_file_name=lems_file_name, simulator=simulator, max_memory=max_memory)
include_these_synapses=oc_utils.replace_cell_types(net_file_name="TestRunColumnSubstitution", path_to_net="./", new_net_id="TestRunColumnReduced", cell_types_to_be_replaced=["L23PyrRS","L23PyrFRB_varInit"], cell_types_replaced_by=["HH_464198958","HH_471141261"], dir_to_new_components="../../../../OpenCortex/NeuroML2/prototypes/AllenInstituteCellTypesDB_HH", dir_to_old_components="../../cells", reduced_to_single_compartment=True, validate_nml2=False, return_synapses=True, connection_segment_groups=None, input_segment_groups=None, synapse_file_tags=['.synapse.','Syn','Elect']) nml_doc=pynml.read_neuroml2_file("TestRunColumnReduced.net.nml") network=nml_doc.networks[0] lems_file_name=oc_build.generate_lems_simulation(nml_doc, network, "TestRunColumnReduced.net.nml", duration =100, dt =0.01, include_extra_lems_files=include_these_synapses) opencortex.print_comment_v("Starting simulation of %s.net.nml"%"TestRunColumnReduced") oc_build.simulate_network(lems_file_name=lems_file_name, simulator="jNeuroML_NEURON", max_memory="4000M")
cell_types_to_be_replaced=["L23PyrRS", "L23PyrFRB_varInit"], cell_types_replaced_by=["HH_464198958", "HH_471141261"], dir_to_new_components= "../../../../OpenCortex/NeuroML2/prototypes/AllenInstituteCellTypesDB_HH", dir_to_old_components="../../cells", reduced_to_single_compartment=True, validate_nml2=False, return_synapses=True, connection_segment_groups=None, input_segment_groups=None, synapse_file_tags=['.synapse.', 'Syn', 'Elect']) nml_doc = pynml.read_neuroml2_file("TestRunColumnReduced.net.nml") network = nml_doc.networks[0] lems_file_name = oc_build.generate_lems_simulation( nml_doc, network, "TestRunColumnReduced.net.nml", duration=100, dt=0.01, include_extra_lems_files=include_these_synapses) opencortex.print_comment_v("Starting simulation of %s.net.nml" % "TestRunColumnReduced") oc_build.simulate_network(lems_file_name=lems_file_name, simulator="jNeuroML_NEURON", max_memory="4000M")