def subcellular_input_map(cellName, networkParamName, synapseFilename, outputFilename, cellType=None, tBegin=None, tEnd=None): ''' visualization of subcellular input distributions: -per cell type and time window possible -output: per cell type landmark files, list of distances ''' neuronParameters = scp.build_parameters(cellName) networkParameters = scp.build_parameters(networkParamName) scp.load_NMODL_parameters(neuronParameters) scp.load_NMODL_parameters(networkParameters) cellParam = neuronParameters.neuron print 'Loading cell morphology...' parser = scp.CellParser(cellParam.filename) parser.spatialgraph_to_cell() cell = parser.cell synLocations = [] synDistances = [] if tBegin is None and tEnd is None: evokedNW = scp.NetworkMapper(cell, networkParameters.network) evokedNW._assign_anatomical_synapses() synTypes = cell.synapses.keys() for synType in synTypes: preCellType, preColumn = synType.split('_') if cellType is not None and preCellType != cellType: continue print 'Computing synapse distances for cell type %s' % synType synDistances.extend(sca.compute_syn_distances(cell, synType)) for syn in cell.synapses[synType]: secID = syn.secID ptID = syn.ptID x = syn.x synLoc3D = cell.sections[secID].pts[ptID] synLocations.append(synLoc3D) else: synInfo = scp.read_synapse_activation_file(synapseFilename) synTypes = synInfo.keys() for synType in synTypes: preCellType, preColumn = synType.split('_') if cellType is not None and preCellType != cellType: continue print 'Loading synapse distances and activation times for cell type %s' % synType for syn in synInfo[synType]: synID, secID, ptID, synTimes, somaDist = syn activeSyn = False for t in synTimes: if tBegin <= t <= tEnd: activeSyn = True break if not activeSyn: continue synLoc3D = cell.sections[secID].pts[ptID] synLocations.append(synLoc3D) synDistances.append(somaDist) scp.write_landmark_file(outputFilename, synLocations) write_synapse_distances(outputFilename, synDistances)
def create_network_parameter(templateParamName, cellNumberFileName, synFileName, conFileName, outFileName): print '*************' print 'creating network parameter file from template %s' % templateParamName print '*************' templateParam = scp.build_parameters(templateParamName) cellTypeColumnNumbers = load_cell_number_file(cellNumberFileName) nwParam = scp.NTParameterSet({ 'info': templateParam.info, 'NMODL_mechanisms': templateParam.NMODL_mechanisms }) # nwParam.info = templateParam.info # nwParam.NMODL_mechanisms = templateParam.NMODL_mechanisms nwParam.network = {} for cellType in cellTypeColumnNumbers.keys(): cellTypeParameters = templateParam.network[cellType] for column in cellTypeColumnNumbers[cellType].keys(): numberOfCells = cellTypeColumnNumbers[cellType][column] if numberOfCells == 0: continue cellTypeName = cellType + '_' + column nwParam.network[cellTypeName] = cellTypeParameters.tree_copy() nwParam.network[cellTypeName].cellNr = numberOfCells nwParam.network[ cellTypeName].synapses.distributionFile = synFileName nwParam.network[cellTypeName].synapses.connectionFile = conFileName nwParam.save(outFileName)
def synapse_distances_2D(pname): parameters = scp.build_parameters(pname) cellParam = parameters.network.post preParam = parameters.network.pre parser = scp.CellParser(cellParam.filename) parser.spatialgraph_to_cell() cell = parser.cell for preType in preParam.keys(): synapseFName = preParam[preType].synapses.realization synDist = scp.read_synapse_realization(synapseFName) mapper = scp.SynapseMapper(cell, synDist) mapper.map_synapse_realization() for synType in cell.synapses.keys(): dist = compute_syn_distances_2Dprojected(cell, synType) name = parameters.info.outputname name += '_' name += synType name += '_syn_distances_2Dprojected.csv' with open(name, 'w') as distFile: header = 'Distance to soma (micron)\n' distFile.write(header) for d in dist: distFile.write(str(d) + '\n')
def remove_population(folderName, contains, suffix, population): fnames = [] get_files_in_directory(folderName, fnames, contains, suffix) for tmpName in fnames: print '*************' print 'Removing population %s from file %s' % (population, tmpName) print '*************' nwParamCluster = scp.build_parameters(tmpName) nwParamCluster.network.pop(population) insertIndex = tmpName.find('_UpState') insertIndex += 8 clusterOutFileName = tmpName[:insertIndex] clusterOutFileName += '_' clusterOutFileName += population clusterOutFileName += '_inact' clusterOutFileName += tmpName[insertIndex:] nwParamCluster.save(clusterOutFileName)
def create_network_parameter(templateParamName, cellNumberFileName, synFileName, conFileName, whisker, outFileName): print '*************' print 'creating network parameter file from template %s' % templateParamName print '*************' templateParam = scp.build_parameters(templateParamName) cellTypeColumnNumbers = load_cell_number_file(cellNumberFileName) nwParam = scp.NTParameterSet({ 'info': templateParam.info, 'NMODL_mechanisms': templateParam.NMODL_mechanisms }) nwParam.network = {} for cellType in templateParam.network.keys(): cellTypeParameters = templateParam.network[cellType] for column in cellTypeColumnNumbers[cellType].keys(): numberOfCells = cellTypeColumnNumbers[cellType][column] if numberOfCells == 0: continue cellTypeName = cellType + '_' + column nwParam.network[cellTypeName] = cellTypeParameters.tree_copy() PSTH = whisker_evoked_PSTH(column, whisker, cellType) if PSTH is not None: interval = nwParam.network[cellTypeName].pop('interval') nwParam.network[cellTypeName].celltype = { 'spiketrain': { 'interval': interval } } nwParam.network[cellTypeName].celltype['pointcell'] = PSTH nwParam.network[cellTypeName].celltype['pointcell'][ 'offset'] = deflectionOffset nwParam.network[cellTypeName].cellNr = numberOfCells nwParam.network[ cellTypeName].synapses.distributionFile = synFileName nwParam.network[cellTypeName].synapses.connectionFile = conFileName nwParam.save(outFileName)
L6ctEvokedName = evokedPrefix + 'L6ct_3x3_PSTH_UpState.param' VPMEvokedName = evokedPrefix + 'VPM_3x3_PSTH.param' L1EvokedName = evokedPrefix + 'L1_3x3_PSTH_UpState.param' L23TransEvokedName = evokedPrefix + 'L23Trans_PSTH_active_timing_normalized_PW_1.0_SuW_0.5.param' L45PeakEvokedName = evokedPrefix + 'L45Peak_PSTH_active_timing_normalized_PW_1.0_SuW_0.5.param' L45SymEvokedName = evokedPrefix + 'L45Sym_PSTH_active_timing_normalized_PW_1.0_SuW_0.5.param' L56TransEvokedName = evokedPrefix + 'L56Trans_PSTH_active_timing_normalized_PW_1.0_SuW_0.5.param' SymLocal1EvokedName = evokedPrefix + 'SymLocal1_PSTH_active_timing_normalized_PW_1.0_SuW_0.5.param' SymLocal2EvokedName = evokedPrefix + 'SymLocal2_PSTH_active_timing_normalized_PW_1.0_SuW_0.5.param' SymLocal3EvokedName = evokedPrefix + 'SymLocal3_PSTH_active_timing_normalized_PW_1.0_SuW_0.5.param' SymLocal4EvokedName = evokedPrefix + 'SymLocal4_PSTH_active_timing_normalized_PW_1.0_SuW_0.5.param' SymLocal5EvokedName = evokedPrefix + 'SymLocal5_PSTH_active_timing_normalized_PW_1.0_SuW_0.5.param' SymLocal6EvokedName = evokedPrefix + 'SymLocal6_PSTH_active_timing_normalized_PW_1.0_SuW_0.5.param' L2EvokedParam = scp.build_parameters(L2EvokedName) L34EvokedParam = scp.build_parameters(L34EvokedName) L4pyEvokedParam = scp.build_parameters(L4pyEvokedName) L4spEvokedParam = scp.build_parameters(L4spEvokedName) L4ssEvokedParam = scp.build_parameters(L4ssEvokedName) L5stEvokedParam = scp.build_parameters(L5stEvokedName) L5ttEvokedParam = scp.build_parameters(L5ttEvokedName) L6ccEvokedParam = scp.build_parameters(L6ccEvokedName) L6ccinvEvokedParam = scp.build_parameters(L6ccinvEvokedName) L6ctEvokedParam = scp.build_parameters(L6ctEvokedName) VPMEvokedParam = scp.build_parameters(VPMEvokedName) L1EvokedParam = scp.build_parameters(L1EvokedName) L23TransEvokedParam = scp.build_parameters(L23TransEvokedName) L45PeakEvokedParam = scp.build_parameters(L45PeakEvokedName) L45SymEvokedParam = scp.build_parameters(L45SymEvokedName) L56TransEvokedParam = scp.build_parameters(L56TransEvokedName)
def create_network_parameter(templateParamName, cellNumberFileName, synFileName, conFileName, whisker, outFileName): print '*************' print 'creating network parameter file from template %s' % templateParamName print '*************' templateParam = scp.build_parameters(templateParamName) cellTypeColumnNumbers = load_cell_number_file(cellNumberFileName) nwParam = scp.NTParameterSet({ 'info': templateParam.info, 'NMODL_mechanisms': templateParam.NMODL_mechanisms }) # nwParam.info = templateParam.info # nwParam.NMODL_mechanisms = templateParam.NMODL_mechanisms nwParam.network = {} if clusterParameters: clusterBasePath = '/gpfs01/bethge/home/regger' nwParamCluster = scp.NTParameterSet({'info': templateParam.info}) nwParamCluster.NMODL_mechanisms = templateParam.NMODL_mechanisms.tree_copy( ) nwParamCluster.network = {} synFileNameIndex = synFileName.find('L5tt') synFileNameCluster = clusterBasePath + '/data/' + synFileName[ synFileNameIndex:] conFileNameCluster = synFileNameCluster[:-4] + '.con' for mech in nwParamCluster.NMODL_mechanisms: mechPath = nwParamCluster.NMODL_mechanisms[mech] if '/nas1/Data_regger' in mechPath: mechPathIndex = mechPath.find('L5tt') newMechPath = clusterBasePath + '/data/' + mechPath[ mechPathIndex:] if '/home/regger' in mechPath: newMechPath = clusterBasePath + mechPath[12:] nwParamCluster.NMODL_mechanisms[mech] = newMechPath # for cellType in cellTypeColumnNumbers.keys(): for cellType in templateParam.network.keys(): cellTypeParameters = templateParam.network[cellType] for column in cellTypeColumnNumbers[cellType].keys(): numberOfCells = cellTypeColumnNumbers[cellType][column] if numberOfCells == 0: continue cellTypeName = cellType + '_' + column nwParam.network[cellTypeName] = cellTypeParameters.tree_copy() if clusterParameters: nwParamCluster.network[ cellTypeName] = cellTypeParameters.tree_copy() PSTH = whisker_evoked_PSTH(column, whisker, cellType) if PSTH is not None: interval = nwParam.network[cellTypeName].pop('interval') nwParam.network[cellTypeName].celltype = { 'spiketrain': { 'interval': interval } } nwParam.network[cellTypeName].celltype['pointcell'] = PSTH nwParam.network[cellTypeName].celltype['pointcell'][ 'offset'] = deflectionOffset if clusterParameters: interval = nwParamCluster.network[cellTypeName].pop( 'interval') nwParamCluster.network[cellTypeName].celltype = { 'spiketrain': { 'interval': interval } } nwParamCluster.network[cellTypeName].celltype[ 'pointcell'] = PSTH nwParamCluster.network[cellTypeName].celltype['pointcell'][ 'offset'] = deflectionOffset nwParam.network[cellTypeName].cellNr = numberOfCells nwParam.network[ cellTypeName].synapses.distributionFile = synFileName nwParam.network[cellTypeName].synapses.connectionFile = conFileName if clusterParameters: nwParamCluster.network[cellTypeName].cellNr = numberOfCells nwParamCluster.network[ cellTypeName].synapses.distributionFile = synFileNameCluster nwParamCluster.network[ cellTypeName].synapses.connectionFile = conFileNameCluster nwParam.save(outFileName) clusterOutFileName = outFileName[:-6] + '_cluster.param' if clusterParameters: nwParamCluster.save(clusterOutFileName)
def assign_3D_soma_locations(cellName, networkParamName, somaDistributionName, VPMFolderName, connectedSomataName): ''' randomly assign 3D locations of corresponding cell type/column Assumes there are >= somata than connected somata!!! (i.e. best to use soma distribution from corresponding NeuroNet output) ''' neuronParameters = scp.build_parameters(cellName) networkParameters = scp.build_parameters(networkParamName) scp.load_NMODL_parameters(neuronParameters) scp.load_NMODL_parameters(networkParameters) cellParam = neuronParameters.neuron somaDistribution = load_soma_distribution(somaDistributionName) somaDistribution['VPM'] = load_soma_distribution_VPM(VPMFolderName) # connectedSomata = load_connected_somata(connectedSomataName) # # for cellType in connectedSomata.keys(): # somaLocations3D = [] # for column in connectedSomata[cellType].keys(): # numberOfConnectedCells = len(connectedSomata[cellType][column]) # numberOfTotalCells = len(somaDistribution[cellType][column]) # somaLocationIDs = np.random.permutation(numberOfTotalCells) # for i in range(numberOfConnectedCells): # ID = somaLocationIDs[i] # loc = somaDistribution[cellType][column][ID] # somaLocations3D.append(loc) # cellTypeName = connectedSomataName[:-4] # cellTypeName += '_' # cellTypeName += cellType # scp.write_landmark_file(cellTypeName, somaLocations3D) print 'Loading cell morphology...' parser = scp.CellParser(cellParam.filename) parser.spatialgraph_to_cell() cell = parser.cell evokedNW = scp.NetworkMapper(cell, networkParameters.network) evokedNW._assign_anatomical_synapses() evokedNW._create_presyn_cells() evokedNW._map_complete_anatomical_realization() somaLocationsPerCellType3D = {} somaLocationsPerSynType3D = {} for synType in evokedNW.cells.keys(): cellType, column = synType.split('_') numberOfConnectedCells = len(evokedNW.cells[synType]) numberOfTotalCells = len(somaDistribution[cellType][column]) somaLocationIDs = np.random.permutation(numberOfTotalCells) for i in range(numberOfConnectedCells): ID = somaLocationIDs[i] loc = somaDistribution[cellType][column][ID] try: somaLocationsPerCellType3D[cellType].append(loc) except KeyError: somaLocationsPerCellType3D[cellType] = [loc] try: somaLocationsPerSynType3D[synType].append(loc) except KeyError: somaLocationsPerSynType3D[synType] = [loc] for cellType in somaLocationsPerCellType3D.keys(): cellTypeName = connectedSomataName[:-4] cellTypeName += '_' cellTypeName += cellType scp.write_landmark_file(cellTypeName, somaLocationsPerCellType3D[cellType]) write_cell_location_realization(somaLocationsPerSynType3D, connectedSomataName)
def evoked_activity(simName, cellName, evokedINHParamName, evokedGenericParamName, evokedSynDistributionFile, evokedInhSynDistributionFile, nrOfSynapses, synapseTiming): ''' pre-stimulus ongoing activity and evoked activity ''' neuronParameters = scp.build_parameters(cellName) evokedUpNWParameters = scp.build_parameters(evokedINHParamName) evokedUpGenericParameters = scp.build_parameters(evokedGenericParamName) scp.load_NMODL_parameters(neuronParameters) scp.load_NMODL_parameters(evokedUpNWParameters) scp.load_NMODL_parameters(evokedUpGenericParameters) cellParam = neuronParameters.neuron paramEvokedUp = evokedUpNWParameters.network paramEvokedUpGeneric = evokedUpGenericParameters.network cell = scp.create_cell(cellParam) evokedSynDistribution = np.loadtxt(evokedSynDistributionFile, skiprows=1, unpack=True, delimiter=',') cellPointsLUT = cell_points_by_distance_LUT(cell, evokedSynDistribution, 'EXC') evokedInhSynDistribution = np.loadtxt(evokedInhSynDistributionFile, skiprows=1, unpack=True, delimiter=',') cellPointsLUT_INH = cell_points_by_distance_LUT(cell, evokedInhSynDistribution, 'INH') offset = synapseTiming[0] mode = synapseTiming[1] median = synapseTiming[2] mu = np.log(median) sigma = np.sqrt(mu - np.log(mode)) synTimingLognormal = (offset, mu, sigma) uniqueID = str(os.getpid()) dirName = 'results/' dirName += simName if not simName.endswith('/'): dirName += '/' dirName += time.strftime('%Y%m%d-%H%M') dirName += '_' dirName += uniqueID if not os.path.exists(dirName): os.makedirs(dirName) vTraces = [] tTraces = [] recordingSiteFiles = neuronParameters.sim.recordingSites recSiteManagers = [] for recFile in recordingSiteFiles: recSiteManagers.append(sca.RecordingSiteManager(recFile, cell)) if 'PW' in simName: nrOfInhSynapses = 375 # Avg PW deflection elif 'SW' in simName: nrOfInhSynapses = 209 # Avg SW deflection elif 'E2' in simName: nrOfInhSynapses = 255 # Avg E2 deflection nSweeps = 200 tOffset = 100.0 # avoid numerical transients tStim = 245.0 tStop = 270.0 neuronParameters.sim.tStop = tStop dt = neuronParameters.sim.dt offsetBin = int(tOffset / dt + 0.5) nRun = 0 while nRun < nSweeps: synParametersEvoked = paramEvokedUp startTime = time.time() evokedNW = scp.NetworkMapper(cell, synParametersEvoked, neuronParameters.sim) evokedNW.create_saved_network2() place_synapses_by_distance(evokedSynDistribution, cell, cellPointsLUT, nrOfSynapses, 'Generic') activate_distance_dependent_synapses(cell, tStim, synTimingLognormal, 'Generic', paramEvokedUpGeneric) place_synapses_by_distance(evokedInhSynDistribution, cell, cellPointsLUT_INH, nrOfInhSynapses, 'GenericINH') activate_distance_dependent_synapses(cell, tStim, None, 'GenericINH', paramEvokedUpGeneric) stopTime = time.time() setupdt = stopTime - startTime print 'Network setup time: %.2f s' % setupdt synTypes = cell.synapses.keys() synTypes.sort() print 'Testing evoked response properties run %d of %d' % (nRun + 1, nSweeps) tVec = h.Vector() tVec.record(h._ref_t) startTime = time.time() scp.init_neuron_run(neuronParameters.sim, vardt=False) stopTime = time.time() simdt = stopTime - startTime print 'NEURON runtime: %.2f s' % simdt vmSoma = np.array(cell.soma.recVList[0]) t = np.array(tVec) vTraces.append(np.array(vmSoma[offsetBin:])), tTraces.append( np.array(t[offsetBin:])) for RSManager in recSiteManagers: RSManager.update_recordings() print 'writing simulation results' fname = 'simulation' fname += '_run%04d' % nRun synName = dirName + '/' + fname + '_synapses.csv' print 'computing active synapse properties' sca.compute_synapse_distances_times(synName, cell, t, synTypes) nRun += 1 cell.re_init_cell() cell.synapses.pop('Generic') cell.synapses.pop('GenericINH') evokedNW.re_init_network() print '-------------------------------' vTraces = np.array(vTraces) dendTraces = [] scp.write_all_traces(dirName + '/' + uniqueID + '_vm_all_traces.csv', t[offsetBin:], vTraces) for RSManager in recSiteManagers: for recSite in RSManager.recordingSites: tmpTraces = [] for vTrace in recSite.vRecordings: tmpTraces.append(vTrace[offsetBin:]) recSiteName = dirName + '/' + uniqueID + '_' + recSite.label + '_vm_dend_traces.csv' scp.write_all_traces(recSiteName, t[offsetBin:], tmpTraces) dendTraces.append(tmpTraces) dendTraces = np.array(dendTraces) print 'writing simulation parameter files' neuronParameters.save(dirName + '/' + uniqueID + '_neuron_model.param') evokedUpNWParameters.save(dirName + '/' + uniqueID + '_network_model.param')
def evoked_activity(simName, cellName, evokedUpParamName): ''' pre-stimulus ongoing activity and evoked activity ''' neuronParameters = scp.build_parameters(cellName) evokedUpNWParameters = scp.build_parameters(evokedUpParamName) scp.load_NMODL_parameters(neuronParameters) scp.load_NMODL_parameters(evokedUpNWParameters) cellParam = neuronParameters.neuron paramEvokedUp = evokedUpNWParameters.network cell = scp.create_cell(cellParam) uniqueID = str(os.getpid()) dirName = 'results/' dirName += simName if not simName.endswith('/'): dirName += '/' dirName += time.strftime('%Y%m%d-%H%M') dirName += '_' dirName += uniqueID if not os.path.exists(dirName): os.makedirs(dirName) vTraces = [] tTraces = [] recordingSiteFiles = neuronParameters.sim.recordingSites recSiteManagers = [] for recFile in recordingSiteFiles: recSiteManagers.append(sca.RecordingSiteManager(recFile, cell)) nSweeps = 200 tOffset = 100.0 # avoid numerical transients tStim = 245.0 tStop = 270.0 neuronParameters.sim.tStop = tStop dt = neuronParameters.sim.dt offsetBin = int(tOffset / dt + 0.5) nRun = 0 while nRun < nSweeps: synParametersEvoked = paramEvokedUp startTime = time.time() evokedNW = scp.NetworkMapper(cell, synParametersEvoked, neuronParameters.sim) evokedNW.create_saved_network2() stopTime = time.time() setupdt = stopTime - startTime print 'Network setup time: %.2f s' % setupdt synTypes = cell.synapses.keys() synTypes.sort() print 'Testing evoked response properties run %d of %d' % (nRun + 1, nSweeps) tVec = h.Vector() tVec.record(h._ref_t) startTime = time.time() scp.init_neuron_run(neuronParameters.sim, vardt=False) stopTime = time.time() simdt = stopTime - startTime print 'NEURON runtime: %.2f s' % simdt vmSoma = np.array(cell.soma.recVList[0]) t = np.array(tVec) vTraces.append(np.array(vmSoma[offsetBin:])), tTraces.append( np.array(t[offsetBin:])) for RSManager in recSiteManagers: RSManager.update_recordings() print 'writing simulation results' fname = 'simulation' fname += '_run%04d' % nRun synName = dirName + '/' + fname + '_synapses.csv' print 'computing active synapse properties' sca.compute_synapse_distances_times(synName, cell, t, synTypes) preSynCellsName = dirName + '/' + fname + '_presynaptic_cells.csv' scp.write_presynaptic_spike_times(preSynCellsName, evokedNW.cells) nRun += 1 cell.re_init_cell() evokedNW.re_init_network() print '-------------------------------' vTraces = np.array(vTraces) scp.write_all_traces(dirName + '/' + uniqueID + '_vm_all_traces.csv', t[offsetBin:], vTraces) for RSManager in recSiteManagers: for recSite in RSManager.recordingSites: tmpTraces = [] for vTrace in recSite.vRecordings: tmpTraces.append(vTrace[offsetBin:]) recSiteName = dirName + '/' + uniqueID + '_' + recSite.label + '_vm_dend_traces.csv' scp.write_all_traces(recSiteName, t[offsetBin:], tmpTraces) print 'writing simulation parameter files' neuronParameters.save(dirName + '/' + uniqueID + '_neuron_model.param') evokedUpNWParameters.save(dirName + '/' + uniqueID + '_network_model.param')
def single_neuron_embedding_to_catmaid(cellName, networkParamName, somaDistributionName, connectedNeuronsName, outputName): ''' randomly assign 3D locations of corresponding cell type/column Assumes there are >= somata than connected somata!!! (i.e. best to use soma distribution from corresponding NeuroNet output) ''' neuronParameters = scp.build_parameters(cellName) networkParameters = scp.build_parameters(networkParamName) scp.load_NMODL_parameters(neuronParameters) scp.load_NMODL_parameters(networkParameters) cellParam = neuronParameters.neuron somaDistribution = load_cell_location_realization(somaDistributionName) synapseConnectivity = load_connected_neuron_per_synapse( connectedNeuronsName) print 'Loading cell morphology...' parser = scp.CellParser(cellParam.filename) parser.spatialgraph_to_cell() cell = parser.cell evokedNW = scp.NetworkMapper(cell, networkParameters.network) evokedNW._assign_anatomical_synapses() evokedNW._create_presyn_cells() evokedNW._map_complete_anatomical_realization() # create continuous morphology IDs ('DUMMYIDXXXXX') IDCounter = 0 cellTypeColumns = somaDistribution.keys() for cellTypeColumn in cellTypeColumns: cellType = cellTypeColumn.split('_')[0] column = cellTypeColumn.split('_')[1] if len(somaDistribution[cellTypeColumn]) != len( evokedNW.cells[cellTypeColumn]): errstr = 'Number of cells in Network not equal to number of somata' raise RuntimeError(errstr) for i in range(len(somaDistribution[cellTypeColumn])): somaLoc = somaDistribution[cellTypeColumn][i] pointCell = evokedNW.cells[cellTypeColumn][i] morphologyID = 'DUMMYID%05d' % IDCounter pointCell.cellTypeStr = cellType pointCell.columnStr = column pointCell.morphologyID = morphologyID pointCell.somaLoc3D = somaLoc IDCounter += 1 for i in range(len(synapseConnectivity[cellTypeColumn])): syn = cell.synapses[cellTypeColumn][i] preCellID = synapseConnectivity[cellTypeColumn][i] preCell = evokedNW.cells[cellTypeColumn][preCellID] syn.preCell = preCell create_catmaid_connection(cell, syn) # write cell file in JSON format morphologyName = outputName morphologyName += '_morphologies.json' write_catmaid_morphology_file(morphologyName, evokedNW.cells) # write synapse file in CortexInSilico/Catmaid format synapseName = outputName synapseName += '_synapses.csv' write_catmaid_synapse_file(synapseName, cell.synapses)