def read_muscle_data(): conns = [] neurons = [] muscles = [] filename = "%sCElegansNeuronTables.xls"%spreadsheet_location rb = open_workbook(filename) print_("Opened Excel file: "+ filename) sheet = rb.sheet_by_index(1) for row in range(1,sheet.nrows): pre = str(sheet.cell(row,0).value) post = str(sheet.cell(row,1).value) syntype = 'Send' num = int(sheet.cell(row,2).value) synclass = sheet.cell(row,3).value.replace(',', 'plus').replace(' ', '_') conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) if pre not in neurons: neurons.append(pre) if post not in muscles: muscles.append(post) return neurons, muscles, conns
def setup(parameter_set, generate=False, duration=None, dt=0.05, target_directory='examples', data_reader="SpreadsheetDataReader", param_overrides={}, config_param_overrides={}, verbose=True): reference = "c302_%s_IClamp" % parameter_set c302.print_("Setting up %s" % reference) exec('from parameters_%s import ParameterisedModel' % parameter_set, globals()) params = ParameterisedModel() stim_amplitudes = ["1pA", "2pA", "3pA", "4pA", "5pA", "6pA"] if duration == None: duration = (len(stim_amplitudes)) * 1000 my_cells = ["ADAL", "PVCL"] muscles_to_include = ['MDR01'] cells = my_cells cells_total = my_cells + muscles_to_include nml_doc = None if generate: c302.print_("Generating %s" % reference) nml_doc = c302.generate(reference, params, cells=cells, cells_to_stimulate=[], muscles_to_include=muscles_to_include, duration=duration, dt=dt, target_directory=target_directory, param_overrides=param_overrides, verbose=verbose, data_reader=data_reader) for i in range(len(stim_amplitudes)): start = "%sms" % (i * 1000 + 100) for c in cells_total: c302.add_new_input(nml_doc, c, start, "800ms", stim_amplitudes[i], params) nml_file = target_directory + '/' + reference + '.net.nml' writers.NeuroMLWriter.write( nml_doc, nml_file) # Write over network file written above... print("(Re)written network file to: " + nml_file) return cells, cells_total, params, muscles_to_include, nml_doc
def run_c302(config, parameter_set, prefix, duration, dt, simulator, save=False, show_plot_already=True, data_reader="SpreadsheetDataReader", verbose=False, plot_ca=True, param_overrides={}): print( "********************\n\n Going to generate c302_%s_%s and run for %s on %s\n\n********************" % (parameter_set, config, duration, simulator)) exec('from c302_%s import setup' % config) cells, cells_to_stimulate, params, muscles = setup( parameter_set, data_reader=data_reader, generate=True, duration=duration, dt=dt, target_directory='examples', verbose=verbose, param_overrides=param_overrides) os.chdir('examples') lems_file = 'LEMS_c302_%s_%s.xml' % (parameter_set, config) if simulator == 'jNeuroML': results = pynml.run_lems_with_jneuroml(lems_file, nogui=True, load_saved_data=True, verbose=verbose) elif simulator == 'jNeuroML_NEURON': results = pynml.run_lems_with_jneuroml_neuron(lems_file, nogui=True, load_saved_data=True, verbose=verbose) c302.print_("Finished simulation of %s and have reloaded results" % lems_file) c302_utils.plot_c302_results(results, config, parameter_set, directory=save_fig_dir, save=save, show_plot_already=show_plot_already, data_reader=data_reader, plot_ca=plot_ca) os.chdir('..') return cells, cells_to_stimulate, params, muscles
def read_data(self, include_nonconnected_cells=False): print_("Initialising OpenWormReader") cell_names, pre, post, conns = self._read_connections('neuron') if include_nonconnected_cells: return cell_names, conns else: return pre + post, conns
def setup(parameter_set, generate=False, duration=2500, dt=0.05, target_directory='examples', data_reader="SpreadsheetDataReader", param_overrides={}, config_param_overrides={}, verbose=True): exec('from parameters_%s import ParameterisedModel' % parameter_set, globals()) params = ParameterisedModel() cells = ["RMGR", "ASHR", "ASKR", "AWBR", "IL2R", "RMHR", "URXR"] cells_to_stimulate = [] reference = "c302_%s_Social" % parameter_set nml_doc = None if generate: nml_doc = c302.generate(reference, params, cells=cells, cells_to_stimulate=cells_to_stimulate, duration=duration, dt=dt, target_directory=target_directory, param_overrides=param_overrides, verbose=verbose, data_reader=data_reader) stim_amplitude = "5pA" c302.add_new_input(nml_doc, "RMGR", "100ms", "200ms", stim_amplitude, params) c302.add_new_input(nml_doc, "ASHR", "400ms", "200ms", stim_amplitude, params) c302.add_new_input(nml_doc, "ASKR", "700ms", "200ms", stim_amplitude, params) c302.add_new_input(nml_doc, "AWBR", "1000ms", "200ms", stim_amplitude, params) c302.add_new_input(nml_doc, "IL2R", "1300ms", "200ms", stim_amplitude, params) c302.add_new_input(nml_doc, "RMHR", "1600ms", "200ms", stim_amplitude, params) c302.add_new_input(nml_doc, "URXR", "1900ms", "200ms", stim_amplitude, params) nml_file = target_directory + '/' + reference + '.net.nml' writers.NeuroMLWriter.write( nml_doc, nml_file) # Write over network file written above... c302.print_("(Re)written network file to: " + nml_file) return cells, cells_to_stimulate, params, [], nml_doc
def setup(parameter_set, generate=False, duration=1000, dt=0.05, target_directory='examples', data_reader="SpreadsheetDataReader", param_overrides={}, verbose=True): exec('from c302.parameters_%s import ParameterisedModel'%parameter_set, globals()) params = ParameterisedModel() my_cells = ['RIAL', 'SMDDL','SMDVL'] muscles_to_include = [] cells = my_cells cells_total = my_cells + muscles_to_include reference = "c302_%s_RIA"%parameter_set nml_doc = None if generate: nml_doc = c302.generate(reference, params, cells=cells, cells_to_stimulate=muscles_to_include, muscles_to_include = muscles_to_include, duration=duration, dt=dt, target_directory=target_directory, param_overrides=param_overrides, verbose=verbose, data_reader=data_reader) start1 = '100ms' dur1 = '100ms' stim_amplitude1 = '4pA' start2 = '400ms' dur2 = '100ms' stim_amplitude2 = '4pA' c302.add_new_input(nml_doc, 'SMDDL', start1, dur1, stim_amplitude1, params) c302.add_new_input(nml_doc, 'SMDVL', start2, dur2, stim_amplitude2, params) nml_file = target_directory+'/'+reference+'.net.nml' writers.NeuroMLWriter.write(nml_doc, nml_file) # Write over network file written above... c302.print_("(Re)written network file to: "+nml_file) return cells, cells_total, params, muscles_to_include, nml_doc
def read_data(include_nonconnected_cells=False, neuron_connect=False): # reading the NeuronConnect.xls file if neuron_connect = True if neuron_connect: conns = [] cells = [] filename = "%sNeuronConnectFormatted.xlsx"%spreadsheet_location rb = open_workbook(filename) print_("Opened Excel file: " + filename) for row in range(1,rb.sheet_by_index(0).nrows): pre = str(rb.sheet_by_index(0).cell(row,0).value) post = str(rb.sheet_by_index(0).cell(row,1).value) syntype = rb.sheet_by_index(0).cell(row,2).value num = int(rb.sheet_by_index(0).cell(row,3).value) synclass = 'Generic_GJ' if 'EJ' in syntype else 'Chemical_Synapse' conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) if pre not in cells: cells.append(pre) if post not in cells: cells.append(post) return cells, conns else: conns = [] cells = [] filename = "%sCElegansNeuronTables.xls"%spreadsheet_location rb = open_workbook(filename) print_("Opened Excel file: " + filename) known_nonconnected_cells = ['CANL', 'CANR', 'VC6'] for row in range(1,rb.sheet_by_index(0).nrows): pre = str(rb.sheet_by_index(0).cell(row,0).value) post = str(rb.sheet_by_index(0).cell(row,1).value) syntype = rb.sheet_by_index(0).cell(row,2).value num = int(rb.sheet_by_index(0).cell(row,3).value) synclass = rb.sheet_by_index(0).cell(row,4).value conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) if pre not in cells: cells.append(pre) if post not in cells: cells.append(post) if include_nonconnected_cells: for c in known_nonconnected_cells: cells.append(c) return cells, conns
def _show_conn_matrix(data, t, all_info_pre, all_info_post, type, save_figure_to=False): if data.shape[0] > 0 and data.shape[1] > 0 and np.amax(data) > 0: ##norm = matplotlib.colors.LogNorm(vmin=1, vmax=np.amax(data)) maxn = int(np.amax(data)) else: ##norm = None maxn = 0 c302.print_("Plotting data of size %s, max %s: %s" % (str(data.shape), maxn, t)) if maxn == 0: c302.print_("No connections!!") return fig, ax = plt.subplots() title = '%s: %s' % (type, t) plt.title(title) fig.canvas.set_window_title(title) import matplotlib cm = matplotlib.cm.get_cmap('gist_stern_r') im = plt.imshow(data, cmap=cm, interpolation='nearest', norm=None) ax = plt.gca() # Gridlines based on minor ticks if data.shape[0] < 40: ax.grid(which='minor', color='grey', linestyle='-', linewidth=.3) xt = np.arange(data.shape[1]) + 0 ax.set_xticks(xt) ax.set_xticks(xt[:-1] + 0.5, minor=True) ax.set_yticks(np.arange(data.shape[0]) + 0) ax.set_yticks(np.arange(data.shape[0]) + 0.5, minor=True) ax.set_yticklabels([all_info_pre[k][4] for k in all_info_pre]) ax.set_xticklabels([all_info_post[k][4] for k in all_info_post]) ax.set_ylabel('presynaptic') tick_size = 10 if data.shape[0] < 20 else (8 if data.shape[0] < 40 else 6) ax.tick_params(axis='y', labelsize=tick_size) ax.set_xlabel('postsynaptic') ax.tick_params(axis='x', labelsize=tick_size) fig.autofmt_xdate() #heatmap = ax.pcolor(data, cmap='gist_stern') cbar = plt.colorbar(im, ticks=range(maxn + 1)) cbar.set_ticklabels(range(maxn + 1)) if save_figure_to: c302.print_("Saving connectivity figure to: %s" % save_figure_to) plt.savefig(save_figure_to, bbox_inches='tight') else: c302.print_("Not saving figure")
def plots(a_n, info, cells, dt): #import cProfile, pstats, StringIO #pr = cProfile.Profile() #pr.enable() #import time #start = time.time() c302.print_('Generating plots for: %s' % info) fig, ax = plt.subplots() #fig = plt.figure() #ax = fig.gca() downscale = 10 #print a_n.shape a_n_ = a_n[:, ::downscale] #c302.print_(a_n_.shape) plot0 = ax.pcolormesh(a_n_) ax.set_yticks(np.arange(a_n_.shape[0]) + 0.5, minor=False) ax.set_yticklabels(cells) ax.tick_params(axis='y', labelsize=6) #plt.setp(ax.get_yticklabels(), rotation=45) fig.colorbar(plot0) fig.canvas.set_window_title(info) plt.title(info) plt.xlabel('Time (ms)') fig.canvas.draw() labels = [] #issue is with unicode for label in ax.get_xticklabels(): if (len(label.get_text()) > 0): labels.append( float(str((label.get_text()))) * dt * downscale * 1000) # except: # print "Error value on forming axis values, value: ", label.get_text(), ", length: ",len(label.get_text()) #labels = [float(label.get_text())*dt*downscale*1000 for item in ax.get_xticklabels()] ax.set_xticklabels(labels) #print labels #print plt.xlim() plt.xlim(0, a_n_.shape[1])
def show(self): """ Plot the result of the simulation once it's been intialized """ from matplotlib import pyplot as plt if self.already_run: for ref in self.volts.keys(): plt.plot(self.t, self.volts[ref], label=ref) plt.title("Simulation voltage vs time") plt.legend() plt.xlabel("Time [ms]") plt.ylabel("Voltage [mV]") else: c302.print_("""First you have to `go()` the simulation.""") plt.show()
def readMuscleDataFromSpreadsheet(): """ Returns: neurons (:obj:`list` of :obj:`str`): List of motor neurons. Each neuron has at least one connection with a post-synaptic muscle cell. muscles (:obj:`list` of :obj:`str`): List of muscle cells. conns (:obj:`list` of :obj:`ConnectionInfo`): List of neuron-muscle connections. """ neurons = [] muscles = [] conns = [] with open(filename, 'r') as f: reader = csv.DictReader(f) print_("Opened file: " + filename) for row in reader: pre, post, num, syntype, synclass = parse_row(row) if (not is_neuron(pre) and not is_body_wall_muscle(pre) ) or not is_body_wall_muscle(post): # Don't add connections unless pre=neuron and post=body_wall_muscle continue if is_neuron(pre): pre = remove_leading_index_zero(pre) else: pre = get_old_muscle_name(pre) post = get_old_muscle_name(post) conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) #print ConnectionInfo(pre, post, num, syntype, synclass) if is_neuron(pre) and pre not in neurons: neurons.append(pre) elif is_body_wall_muscle(pre) and pre not in muscles: muscles.append(pre) if post not in muscles: muscles.append(post) return neurons, muscles, conns
def readDataFromSpreadsheet(include_nonconnected_cells=False): """ Args: include_nonconnected_cells (bool): Also append neurons without known connections to other neurons to the 'cells' list. True if they should get appended, False otherwise. Returns: cells (:obj:`list` of :obj:`str`): List of neurons conns (:obj:`list` of :obj:`ConnectionInfo`): List of connections from neuron to neuron """ conns = [] cells = [] with open(filename, 'r') as f: reader = csv.DictReader(f) print_("Opened file: " + filename) known_nonconnected_cells = ['CANL', 'CANR'] for row in reader: pre, post, num, syntype, synclass = parse_row(row) if not is_neuron(pre) or not is_neuron(post): continue # pre or post is not a neuron pre = remove_leading_index_zero(pre) post = remove_leading_index_zero(post) conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) #print ConnectionInfo(pre, post, num, syntype, synclass) if pre not in cells: cells.append(pre) if post not in cells: cells.append(post) if include_nonconnected_cells: for c in known_nonconnected_cells: if c not in cells: cells.append(c) return cells, conns
def read_data(include_nonconnected_cells=False): print_("Initialising OpenWormReader") P.connect() net = P.Worm().get_neuron_network() all_connections = net.synapses() print_("Finished initialising OpenWormReader") conns = [] cells = [] cell_names = get_cells_in_model(net) for s in all_connections: pre = str(s.pre_cell().name()) post = str(s.post_cell().name()) if isinstance(s.post_cell(), P.Neuron) and pre in cell_names and post in cell_names: syntype = str(s.syntype()) syntype = syntype[0].upper() + syntype[1:] num = int(s.number()) synclass = str(s.synclass()) ci = ConnectionInfo(pre, post, num, syntype, synclass) conns.append(ci) if pre not in cells: cells.append(pre) if post not in cells: cells.append(post) print_("Total cells %i (%i with connections)" % (len(cell_names), len(cells))) print_("Total connections found %i " % len(conns)) P.disconnect() if include_nonconnected_cells: return cell_names, conns else: return cells, conns
def read_data(include_nonconnected_cells=False): print_("Initialising OpenWormReader") with pyopenworm_connect() as conn: ctx = Context(ident="http://openworm.org/data", conf=conn.conf).stored #Extract the network object from the worm object. net = ctx(Worm)().neuron_network() all_connections = net.synapses() conns = [] cells = [] cell_names = get_cells_in_model(net) for s in all_connections: pre = str(s.pre_cell().name()) post = str(s.post_cell().name()) if isinstance(s.post_cell(), Neuron) and pre in cell_names and post in cell_names: syntype = str(s.syntype()) syntype = syntype[0].upper() + syntype[1:] num = int(s.number()) synclass = str(s.synclass()) ci = ConnectionInfo(pre, post, num, syntype, synclass) conns.append(ci) if pre not in cells: cells.append(pre) if post not in cells: cells.append(post) print_("Total cells %i (%i with connections)" % (len(cell_names), len(cells))) print_("Total connections found %i " % len(conns)) if include_nonconnected_cells: return cell_names, conns else: return cells, conns
def generate_conn_matrix(nml_doc, save_fig_dir=None, verbose=False): net = nml_doc.networks[0] cc_exc_conns = {} cc_inh_conns = {} all_cells = [] for cp in net.continuous_projections: if not cp.presynaptic_population in cc_exc_conns.keys(): cc_exc_conns[cp.presynaptic_population] = {} if not cp.presynaptic_population in cc_inh_conns.keys(): cc_inh_conns[cp.presynaptic_population] = {} if not cp.presynaptic_population in all_cells: all_cells.append(cp.presynaptic_population) if not cp.postsynaptic_population in all_cells: all_cells.append(cp.postsynaptic_population) for c in cp.continuous_connection_instance_ws: if 'inh' in c.post_component: cc_inh_conns[cp.presynaptic_population][ cp.postsynaptic_population] = float(c.weight) else: cc_exc_conns[cp.presynaptic_population][ cp.postsynaptic_population] = float(c.weight) gj_conns = {} for ep in net.electrical_projections: if not ep.presynaptic_population in gj_conns.keys(): gj_conns[ep.presynaptic_population] = {} if not ep.presynaptic_population in all_cells: all_cells.append(ep.presynaptic_population) if not ep.postsynaptic_population in all_cells: all_cells.append(ep.postsynaptic_population) for e in ep.electrical_connection_instance_ws: gj_conns[ep.presynaptic_population][ ep.postsynaptic_population] = float(e.weight) all_cells = sorted(all_cells) all_neuron_info, all_muscle_info = c302._get_cell_info(all_cells) all_neurons = [] all_muscles = [] for c in all_cells: if c302.is_muscle(c): all_muscles.append(c) else: all_neurons.append(c) data_exc_n = np.zeros((len(all_neurons), len(all_neurons))) data_exc_m = np.zeros((len(all_neurons), len(all_muscles))) data_inh_n = np.zeros((len(all_neurons), len(all_neurons))) data_inh_m = np.zeros((len(all_neurons), len(all_muscles))) for pre in cc_exc_conns.keys(): for post in cc_exc_conns[pre].keys(): c302.print_( "Exc Conn %s -> %s: %s" % (pre, post, cc_exc_conns[pre][post]), verbose) if post in all_neurons: data_exc_n[all_neurons.index(pre), all_neurons.index(post)] = cc_exc_conns[pre][post] else: data_exc_m[all_neurons.index(pre), all_muscles.index(post)] = cc_exc_conns[pre][post] if pre in all_muscles: raise Exception("Unexpected...") for pre in cc_inh_conns.keys(): for post in cc_inh_conns[pre].keys(): c302.print_( "Inh Conn %s -> %s: %s" % (pre, post, cc_inh_conns[pre][post]), verbose) if post in all_neurons: data_inh_n[all_neurons.index(pre), all_neurons.index(post)] = cc_inh_conns[pre][post] else: data_inh_m[all_neurons.index(pre), all_muscles.index(post)] = cc_inh_conns[pre][post] if pre in all_muscles: raise Exception("Unexpected...") _show_conn_matrix(data_exc_n, 'Excitatory (non GABA) conns to neurons', all_neuron_info, all_neuron_info, net.id, save_figure_to='%s/%s_exc_to_neurons.png' % (save_fig_dir, net.id) if save_fig_dir else None) _show_conn_matrix(data_exc_m, 'Excitatory (non GABA) conns to muscles', all_neuron_info, all_muscle_info, net.id, save_figure_to='%s/%s_exc_to_muscles.png' % (save_fig_dir, net.id) if save_fig_dir else None) _show_conn_matrix(data_inh_n, 'Inhibitory (GABA) conns to neurons', all_neuron_info, all_neuron_info, net.id, save_figure_to='%s/%s_inh_to_neurons.png' % (save_fig_dir, net.id) if save_fig_dir else None) _show_conn_matrix(data_inh_m, 'Inhibitory (GABA) conns to muscles', all_neuron_info, all_muscle_info, net.id, save_figure_to='%s/%s_inh_to_muscles.png' % (save_fig_dir, net.id) if save_fig_dir else None) data_n = np.zeros((len(all_neurons), len(all_neurons))) data_n_m = np.zeros((len(all_neurons), len(all_muscles))) data_m_m = np.zeros((len(all_muscles), len(all_muscles))) neuron_muscle = False muscle_muscle = False for pre in gj_conns.keys(): for post in gj_conns[pre].keys(): c302.print_( "Elect Conn %s -> %s: %s" % (pre, post, gj_conns[pre][post]), verbose) if pre in all_neurons and post in all_neurons: data_n[all_neurons.index(pre), all_neurons.index(post)] = gj_conns[pre][post] elif pre in all_neurons and post in all_muscles or pre in all_muscles and post in all_neurons: if pre in all_neurons: data_n_m[all_neurons.index(pre), all_muscles.index(post)] = gj_conns[pre][post] else: data_n_m[all_muscles.index(pre), all_neurons.index(post)] = gj_conns[pre][post] neuron_muscle = True elif pre in all_muscles and post in all_muscles: muscle_muscle = True data_m_m[all_muscles.index(pre), all_muscles.index(post)] = gj_conns[pre][post] else: raise Exception("Unexpected...") _show_conn_matrix(data_n, 'Electrical (gap junction) conns to neurons', all_neuron_info, all_neuron_info, net.id, save_figure_to='%s/%s_elec_neurons_neurons.png' % (save_fig_dir, net.id) if save_fig_dir else None) if neuron_muscle: _show_conn_matrix( data_n_m, 'Electrical (gap junction) conns between neurons and muscles', all_neuron_info, all_muscle_info, net.id, save_figure_to='%s/%s_elec_neurons_muscles.png' % (save_fig_dir, net.id) if save_fig_dir else None) if muscle_muscle: _show_conn_matrix(data_m_m, 'Electrical (gap junction) conns between muscles', all_muscle_info, all_muscle_info, net.id, save_figure_to='%s/%s_elec_muscles_muscles.png' % (save_fig_dir, net.id) if save_fig_dir else None)
def setup(parameter_set, generate=False, duration=2000, dt=0.05, target_directory='examples', data_reader="UpdatedSpreadsheetDataReader2", param_overrides={}, verbose=True, config_param_overrides={}): exec('from parameters_%s import ParameterisedModel' % parameter_set, globals()) params = ParameterisedModel() params.set_bioparameter("unphysiological_offset_current", "0pA", "Testing TapWithdrawal", "0") params.set_bioparameter("unphysiological_offset_current_del", "0 ms", "Testing TapWithdrawal", "0") params.set_bioparameter("unphysiological_offset_current_dur", "2000 ms", "Testing TapWithdrawal", "0") VA_motors = ["VA%s" % c for c in range_incl(1, 12)] VB_motors = ["VB%s" % c for c in range_incl(1, 11)] DA_motors = ["DA%s" % c for c in range_incl(1, 9)] DB_motors = ["DB%s" % c for c in range_incl(1, 7)] DD_motors = ["DD%s" % c for c in range_incl(1, 6)] VD_motors = ["VD%s" % c for c in range_incl(1, 13)] AS_motors = ["AS%s" % c for c in range_incl(1, 11)] cells = list(['AVBL', 'AVBR'] + DB_motors + VD_motors + VB_motors + DD_motors) muscles_to_include = True cells_to_stimulate = [] cells_to_plot = list(cells) reference = "c302_%s_FW" % parameter_set conns_to_include = [] conns_to_exclude = [ 'VB2-VB4_GJ', 'VB4-VB2_GJ', ] conn_polarity_override = { r'^DB\d+-DD\d+$': 'inh', r'^VB\d+-VD\d+$': 'inh', } conn_number_override = { '^.+-.+$': 1, } input_list = [] '''dur = '250ms' amp = '3pA' for muscle_num in range(24): mdlx = 'MDL0%s' % (muscle_num + 1) mdrx = 'MDR0%s' % (muscle_num + 1) #mvlx = 'MVL0%s' % (muscle_num + 1) #mvrx = 'MVR0%s' % (muscle_num + 1) if muscle_num >= 9: mdlx = 'MDL%s' % (muscle_num + 1) mdrx = 'MDR%s' % (muscle_num + 1) #mvlx = 'MVL%s' % (muscle_num + 1) #mvrx = 'MVR%s' % (muscle_num + 1) startd = '%sms' % (muscle_num * 10) #startv = '%sms' % ((stim_num * 800 + 400) + muscle_num * 30) input_list.append((mdlx, startd, dur, amp)) input_list.append((mdrx, startd, dur, amp))''' input_list.append(('MVR10', '0ms', '150ms', '1pA')) input_list.append(('MVR11', '0ms', '150ms', '2pA')) input_list.append(('MVR12', '0ms', '150ms', '3pA')) input_list.append(('MVR13', '0ms', '150ms', '3pA')) input_list.append(('MVR14', '0ms', '150ms', '2pA')) input_list.append(('MVR15', '0ms', '150ms', '1pA')) input_list.append(('MVL10', '0ms', '150ms', '1pA')) input_list.append(('MVL11', '0ms', '150ms', '2pA')) input_list.append(('MVL12', '0ms', '150ms', '3pA')) input_list.append(('MVL13', '0ms', '150ms', '3pA')) input_list.append(('MVL14', '0ms', '150ms', '2pA')) input_list.append(('MVL15', '0ms', '150ms', '1pA')) input_list.append(('MDL21', '0ms', '250ms', '3pA')) input_list.append(('MDL22', '0ms', '250ms', '3pA')) input_list.append(('MDR21', '0ms', '250ms', '3pA')) input_list.append(('MDR22', '0ms', '250ms', '3pA')) amp = '4pA' dur = '250ms' for stim_num in range(15): for muscle_num in range(7): mdlx = 'MDL0%s' % (muscle_num + 1) mdrx = 'MDR0%s' % (muscle_num + 1) mvlx = 'MVL0%s' % (muscle_num + 1) mvrx = 'MVR0%s' % (muscle_num + 1) if muscle_num >= 9: mdlx = 'MDL%s' % (muscle_num + 1) mdrx = 'MDR%s' % (muscle_num + 1) mvlx = 'MVL%s' % (muscle_num + 1) mvrx = 'MVR%s' % (muscle_num + 1) startd = '%sms' % (stim_num * 800 + muscle_num * 30) startv = '%sms' % ((stim_num * 800 + 400) + muscle_num * 30) input_list.append((mdlx, startd, dur, amp)) input_list.append((mdrx, startd, dur, amp)) if muscle_num != 6: input_list.append((mvlx, startv, dur, amp)) input_list.append((mvrx, startv, dur, amp)) d_v_delay = 400 start = 190 motor_dur = '250ms' input_list.append(('AVBL', '0ms', '1e9ms', '15pA')) input_list.append(('AVBR', '0ms', '1e9ms', '15pA')) input_list.append(('DB1', '%sms' % (start), motor_dur, '3pA')) input_list.append(('VB1', '%sms' % (start + d_v_delay), motor_dur, '3pA')) i = start + 2 * d_v_delay j = start + 3 * d_v_delay for pulse_num in range(1, 15): input_list.append(('DB1', '%sms' % i, motor_dur, '3pA')) input_list.append(('VB1', '%sms' % j, motor_dur, '3pA')) i += d_v_delay * 2 j += d_v_delay * 2 #input_list = [] #input_list.append(('AVBL', '0ms', '1900ms', '15pA')) #input_list.append(('AVBR', '0ms', '1900ms', '15pA')) config_param_overrides['input'] = input_list param_overrides = { 'mirrored_elec_conn_params': { r'^AVB._to_DB\d+\_GJ$_elec_syn_gbase': '0.001 nS', r'^AVB._to_VB\d+\_GJ$_elec_syn_gbase': '0.001 nS', r'^DB\d+_to_DB\d+\_GJ$_elec_syn_gbase': '0.001 nS', #'^DB\d+_to_DB\d+\_GJ$_elec_syn_p_gbase': '0.08 nS', #'^DB\d+_to_DB\d+\_GJ$_elec_syn_sigma': '0.2 per_mV', #'^DB\d+_to_DB\d+\_GJ$_elec_syn_mu': '-20 mV', r'^VB\d+_to_VB\d+\_GJ$_elec_syn_gbase': '0.001 nS', #'^VB\d+_to_VB\d+\_GJ$_elec_syn_p_gbase': '0.1 nS', #'^VB\d+_to_VB\d+\_GJ$_elec_syn_sigma': '0.3 per_mV', #'^VB\d+_to_VB\d+\_GJ$_elec_syn_mu': '-30 mV', #'VB2_to_VB4_elec_syn_gbase': '0 nS', r'^DB\d+_to_VB\d+\_GJ$_elec_syn_gbase': '0 nS', r'^DB\d+_to_DD\d+\_GJ$_elec_syn_gbase': '0 nS', r'^VB\d+_to_VD\d+\_GJ$_elec_syn_gbase': '0 nS', #'^VD\d+_to_DD\d+\_GJ$_elec_syn_gbase': '0 nS', 'DD1_to_MVL08_elec_syn_gbase': '0 nS', 'VD2_to_MDL09_elec_syn_gbase': '0 nS', }, r'^VB\d+_to_VB\d+$_exc_syn_conductance': '18 nS', r'^VB\d+_to_VB\d+$_exc_syn_ar': '0.19 per_s', r'^VB\d+_to_VB\d+$_exc_syn_ad': '73 per_s', r'^VB\d+_to_VB\d+$_exc_syn_beta': '2.81 per_mV', r'^VB\d+_to_VB\d+$_exc_syn_vth': '-22 mV', r'^VB\d+_to_VB\d+$_exc_syn_erev': '10 mV', r'^DB\d+_to_DB\d+$_exc_syn_conductance': '20 nS', r'^DB\d+_to_DB\d+$_exc_syn_ar': '0.08 per_s', r'^DB\d+_to_DB\d+$_exc_syn_ad': '18 per_s', r'^DB\d+_to_DB\d+$_exc_syn_beta': '0.21 per_mV', r'^DB\d+_to_DB\d+$_exc_syn_vth': '-10 mV', r'^DB\d+_to_DB\d+$_exc_syn_erev': '10 mV', 'initial_memb_pot': '-50 mV', 'AVBR_to_DB4_exc_syn_conductance': '0 nS', #'VB4_to_VB5_exc_syn_conductance': '0 nS', 'AVBL_to_VB2_exc_syn_conductance': '0 nS', 'AVBR_to_VD3_exc_syn_conductance': '0 nS', #'^DB\d+_to_DD\d+$_exc_syn_conductance': '0 nS', #'^DD\d+_to_DB\d+$_inh_syn_conductance': '0 nS', #'^VB\d+_to_VD\d+$_exc_syn_conductance': '0 nS', #'^VD\d+_to_VB\d+$_inh_syn_conductance': '0 nS', 'DD1_to_VB2_inh_syn_conductance': '0 nS', 'neuron_to_muscle_exc_syn_conductance': '0.5 nS', r'^DB\d+_to_MDL\d+$_exc_syn_conductance': '0.4 nS', r'^DB\d+_to_MDR\d+$_exc_syn_conductance': '0.4 nS', r'^VB\d+_to_MVL\d+$_exc_syn_conductance': '0.6 nS', r'^VB\d+_to_MVR\d+$_exc_syn_conductance': '0.6 nS', 'neuron_to_muscle_exc_syn_vth': '37 mV', 'neuron_to_muscle_inh_syn_conductance': '0.6 nS', 'neuron_to_neuron_inh_syn_conductance': '0.2 nS', #'DB2_to_MDL11_exc_syn_conductance': '1 nS', 'AVBR_to_MVL16_exc_syn_conductance': '0 nS', 'ca_conc_decay_time_muscle': '60.8 ms', 'ca_conc_rho_muscle': '0.002338919 mol_per_m_per_A_per_s', } nml_doc = None if generate: nml_doc = c302.generate(reference, params, cells=cells, cells_to_plot=cells_to_plot, cells_to_stimulate=cells_to_stimulate, conns_to_include=conns_to_include, conns_to_exclude=conns_to_exclude, conn_polarity_override=conn_polarity_override, conn_number_override=conn_number_override, muscles_to_include=muscles_to_include, duration=duration, dt=dt, target_directory=target_directory, data_reader=data_reader, param_overrides=param_overrides, verbose=verbose) #if config_param_overrides.has_key('input'): # input_list = config_param_overrides['input'] for stim_input in input_list: cell, start, dur, current = stim_input c302.add_new_input(nml_doc, cell, start, dur, current, params) nml_file = target_directory + '/' + reference + '.net.nml' writers.NeuroMLWriter.write( nml_doc, nml_file) # Write over network file written above... c302.print_("(Re)written network file to: " + nml_file) return cells, cells_to_stimulate, params, muscles_to_include, nml_doc
def setup( parameter_set, generate=False, duration=10000, # Change here the duration of the simulation in ms dt=0.05, # Time step target_directory='examples', data_reader="UpdatedSpreadsheetDataReader2", param_overrides={}, verbose=True, config_param_overrides={}): # Import this from the defined parameters. exec('from parameters_%s import ParameterisedModel' % parameter_set, globals()) params = ParameterisedModel() #******************************************* # 1. DEFINE THE ELEMENTS TO SIMULATE #******************************************* cells = [] # Neurons to include in the simulation (e.g. cells = ['AVBL', 'DB1']) muscles_to_include = [] # Muscles to include in the simulation (e.g. muscles_to_include = ['MDL07'], muscles = True for all the muscles) cells_to_stimulate = [] # Neurons to stimulate # This is used to stimulate the neurons and muscles, I use a different method to stimulate however. cells_to_plot = cells # Neurons to include in the plot (e.g. cells_to_plot = ['DB1']) # If you do not want to plot all the neurons defined, change cells by the only neurons you want plotted. reference = "c302_%s_tutorial" % parameter_set # Reference for the subsequent generated NeuroML files # (Make sure this corresponds with the script name: c302_NAME.py --> reference = "c302_%s_NAME" % parameter_set) #******************************************* # 2. DEFINE THE NETWORK CONNECTIONS #******************************************* conns_to_include = [] # Only connections to include # By default, c302 takes all the connections from the connectome. # If you only want some specific connections, specify them here. conns_to_exclude = [ 'DB1-DB2', # Exclude the chemical synapse from DB1 to DB2 'DB1-DB2_GJ', # Exclude the gap junction from DB1 to DB2 'DB2-DB1_GJ', # Note that gap junctions need to be excluded in both ways r'^AVB.-DB\d+$', # Regular expression to exclude AVBR and AVBL synapses to DB1, DB2... DB7 ] # Connections to exclude or 'ablate' # I included some examples of connections to be excluded. # Search on how to use Regular Expressions in python. conn_polarity_override = { r'^VB\d+-VB\d+$': 'inh', #Change any VB# to VB# synapse to inhibitory r'^DD\d+-DD\d+$': 'exc', #Change any DD# to DD# synapse to excitatory } # Change the polarity of chemical synapses # c302 takes as inhibitory those synapses coming from GABAergic neurons. conn_number_override = { '^.+-.+$': 1, } # Changed the number of synapses between neurons all to 1. #******************************************* # 3. ADD INPUTS TO NEURONS AND MUSCLES #******************************************* # (This is where I define the inputs, instead of using cells_to_stimulate) input_list = [] # Step current input sine_input_list = [] # Sinusoidal input ramp_input_list = [] # Ramp inputs are still under development input_list.append((neuron, start, duration, amplitude)) # Add a step input to a neuron, at a given time, with a duration and intensity. # This can also be used to stimulate muscles! # (e.g. input_list.append(('AVBL', '0ms', '4000ms', '15pA'))) sine_input_list.append((neuron, start, duration, peak_amplitude, period)) # Add a step input to a neuron, at a given time, with a duration and intensity. # This can also be used to stimulate muscles! # (e.g. sine_input_list.append(('DB1', '0ms', '5000ms', '1.5pA', '800ms')) ) config_param_overrides['input'] = input_list #******************************************* # 4. OVERRIDE CERTAIN PARAMETERS #******************************************* param_overrides = { # Symmetrical Gap junctions 'mirrored_elec_conn_params': { #r'^AVB._to_AVB._GJ$_elec_syn_gbase': '0.001 nS', }, # Change the initial membrane potential 'initial_memb_pot': '-50 mV', # Here, any parameters found in the Parameters_#.py can be changed and specified for this specific simulation. } nml_doc = None # Create the NeuroML file of the network using c302 functions. if generate: nml_doc = c302.generate(reference, params, cells=cells, cells_to_plot=cells_to_plot, cells_to_stimulate=cells_to_stimulate, conns_to_include=conns_to_include, conns_to_exclude=conns_to_exclude, conn_polarity_override=conn_polarity_override, conn_number_override=conn_number_override, muscles_to_include=muscles_to_include, duration=duration, dt=dt, target_directory=target_directory, data_reader=data_reader, param_overrides=param_overrides, verbose=verbose) for stim_input in input_list: cell, start, dur, current = stim_input c302.add_new_input(nml_doc, cell, start, dur, current, params) for sine_stim_input in sine_input_list: cell, delay, dur, amp, period = sine_stim_input c302.add_new_sinusoidal_input(nml_doc, cell, delay, dur, amp, period, params) for ramp_stim_input in ramp_input_list: cell, delay, dur, start_amp, finish_amp, base_amp = ramp_stim_input c302.add_new_ramp_input(nml_doc, cell, delay, dur, start_amp, finish_amp, base_amp, params) nml_file = target_directory + '/' + reference + '.net.nml' writers.NeuroMLWriter.write( nml_doc, nml_file) # Write over network file written above... c302.print_("(Re)written network file to: " + nml_file) return cells, cells_to_stimulate, params, muscles_to_include, nml_doc
def main(): cells, conns = read_data(include_nonconnected_cells=True) assert(len(cells) == 302) print_("Lengths are equal if include_nonconnected_cells=True") print_("Found %s cells: %s...\n"%(len(cells),cells)) print_("Found %s connections..."%(len(conns))) for c in conns[:5]: print_(" %s"%c) print_(" ...\n") neurons, muscles, conns = read_muscle_data() print_("Found %i neurons connected to muscles: %s\n"%(len(neurons), sorted(neurons))) print_("Found %i muscles connected to neurons: %s\n"%(len(muscles), sorted(muscles))) print_("Found %i connections between neurons and muscles, e.g. %s\n"%(len(conns), conns[0]))
def setup(parameter_set, generate=False, duration=400, dt=0.05, target_directory='examples', data_reader="UpdatedSpreadsheetDataReader", param_overrides={}, config_param_overrides={}, verbose=True): exec('from parameters_%s import ParameterisedModel'%parameter_set, globals()) params = ParameterisedModel() params.set_bioparameter("unphysiological_offset_current", "0pA", "Testing TapWithdrawal", "0") params.set_bioparameter("unphysiological_offset_current_del", "0 ms", "Testing TapWithdrawal", "0") params.set_bioparameter("unphysiological_offset_current_dur", "2000 ms", "Testing TapWithdrawal", "0") VA_motors = ["VA%s" % c for c in range_incl(1, 12)] VB_motors = ["VB%s" % c for c in range_incl(1, 11)] DA_motors = ["DA%s" % c for c in range_incl(1, 9)] DB_motors = ["DB%s" % c for c in range_incl(1, 7)] DD_motors = ["DD%s" % c for c in range_incl(1, 6)] VD_motors = ["VD%s" % c for c in range_incl(1, 13)] AS_motors = ["AS%s" % c for c in range_incl(1, 11)] AS_motors = [] TW_cells = ['AVAL', 'AVAR', 'AVBL', 'AVBR', 'PVCL', 'PVCR', 'AVDL', 'AVDR', 'DVA', 'PVDL', 'PVDR', 'PLML', 'PLMR', 'AVM', 'ALML', 'ALMR'] TW_sensory = ["PLML", "PLMR", "AVM", "ALML", "ALMR"] all_motors = list(VA_motors + VB_motors + DA_motors + DB_motors + DD_motors + VD_motors + AS_motors) #all_motors = [] #neurons = ['AVAL', 'AVAR', 'AVBL', 'AVBR', 'PVCL', 'PVCR', 'AVDL', 'AVDR', 'DVA', 'PVDL', 'PVDR', 'PLML', 'PLMR', 'AVM', 'ALML', 'ALMR'] muscles_to_include = False #muscles_to_include = True # ALL muscles #muscles_to_include = ['MVL01', 'MVL10'] cells = list(TW_cells + all_motors) cells_to_plot = list(cells) #cells_to_plot = ["VB5", "VA4"] cells += [ # 'AS1', 'AS10', 'AS11', 'AS2', 'AS3', 'AS4', 'AS5', 'AS6', 'AS7', 'AS8', 'AS9', # 'AVFL', 'AVFR', 'AVKR', 'AVL', # 'CEPVL', 'CEPVR', # # # 'DVB', # 'HSNL', 'HSNR', # 'IL1DL', 'IL1DR', 'IL1L', 'IL1R', 'IL1VL', 'IL1VR', # 'PDA', 'PDB', # 'PVNL', 'PVNR', # 'RID', 'RIML', 'RIMR', 'RIVL', 'RIVR', # 'RMDDL', 'RMDDR', 'RMDL', 'RMDR', 'RMDVL', 'RMDVR', 'RMED', 'RMEL', 'RMER', 'RMEV', 'RMFL', 'RMGL', 'RMGR', # 'RMHL', 'RMHR', # 'SMBDL', 'SMBDR', 'SMBVL', 'SMBVR', 'SMDDL', 'SMDDR', 'SMDVL', 'SMDVR', # 'URADL', 'URADR', 'URAVL', 'URAVR', # 'VC1', 'VC2', 'VC3', 'VC4', 'VC5', 'VC6', ] # cells = None #cells_to_stimulate = ['PLML', 'PLMR', 'AVM'] cells_to_stimulate = [] #cells_to_plot = ['AVAL', 'AVAR', 'AVBL', 'AVBR', 'PLML', 'PLMR', 'AVM', 'ALML', 'ALMR', 'PVDL', 'PVDR', 'AVDL', 'AVDR'] #cells_to_plot = ['PLML', 'AVM', 'AVBL', 'AVAL'] #cells_to_plot = cells #cells_to_plot += motors reference = "c302_%s_TapWithdrawal" % parameter_set conn_polarity_override = { 'ALML-ALML':'inh', 'ALML-PVCL':'inh', 'ALML-PVCR':'inh', 'ALML-AVDR':'inh', ## 'ALMR-PVCR':'inh', 'AVM-PVCL':'inh', 'AVM-PVCR':'inh', 'AVM-AVBL':'inh', 'AVM-AVBR':'inh', 'AVM-AVDL':'inh', ## 'AVM-AVDR':'inh', ## 'PVDL-PVDR':'inh', 'PVDL-PVCL':'exc', 'PVDL-PVCR':'exc', 'PVDL-AVAL':'inh', 'PVDL-AVAR':'inh', 'PVDL-AVDL':'inh', 'PVDL-AVDR':'inh', 'PVDR-PVDL':'inh', 'PVDR-DVA':'exc', 'PVDR-PVCL':'exc', 'PVDR-PVCR':'exc', 'PVDR-AVAL':'inh', 'PVDR-AVAR':'inh', 'PVDR-AVDL':'inh', 'DVA-PVCL':'inh',# 'DVA-PVCR':'inh',# 'DVA-AVAL':'inh', 'DVA-AVAR':'inh', 'DVA-AVBL':'inh',# 'DVA-AVBR':'inh',# 'DVA-AVDR':'inh', 'PVCL-DVA':'exc', 'PVCL-PVCL':'inh', 'PVCL-PVCR':'inh', 'PVCL-AVAL':'inh', 'PVCL-AVAR':'inh', 'PVCL-AVBL':'exc', 'PVCL-AVBR':'exc', 'PVCL-AVDL':'inh', 'PVCL-AVDR':'inh', 'PVCR-PVDL':'inh', 'PVCR-PVDR':'inh', 'PVCR-DVA':'exc', 'PVCR-PVCL':'inh', 'PVCR-AVAL':'inh', 'PVCR-AVAR':'inh', 'PVCR-AVBL':'exc', 'PVCR-AVBR':'exc', 'PVCR-AVDL':'inh', 'PVCR-AVDR':'inh', 'AVAL-PVCL':'inh', 'AVAL-PVCR':'inh', 'AVAL-AVAR':'inh', 'AVAL-AVBL':'inh', 'AVAL-AVDL':'inh', 'AVAL-AVDR':'inh', 'AVAR-PVCL':'inh', 'AVAR-PVCR':'inh', 'AVAR-AVAL':'inh', 'AVAR-AVBL':'inh', 'AVAR-AVBR':'inh', 'AVAR-AVDL':'inh', 'AVAR-AVDR':'inh', 'AVBL-DVA':'inh', 'AVBL-PVCR':'inh', 'AVBL-AVAL':'inh', 'AVBL-AVAR':'inh', 'AVBL-AVBR':'inh', 'AVBL-AVDR':'inh', 'AVBR-AVAL':'inh', 'AVBR-AVAR':'inh', 'AVBR-AVBL':'inh', 'AVBR-AVDL':'inh', 'AVDL-PVCL':'inh', 'AVDL-AVAL':'exc', 'AVDL-AVAR':'exc', 'AVDL-AVDR':'exc', 'AVDR-PVCR':'inh', 'AVDR-AVAL':'exc', 'AVDR-AVAR':'exc', 'AVDR-AVBL':'inh', 'AVDR-AVDL':'exc', 'DA9-DVA':'inh', 'DVA-DA2':'inh', 'PVCL-DA5':'inh', 'PVCL-DA8':'inh', 'PVCR-DA2':'inh', 'PVCR-DA4':'inh', 'PVCR-DA5':'inh', 'PVCR-DA7':'inh', 'AVBL-DA5':'inh', 'AVBL-DA7':'inh', 'AVBR-DA3':'inh', 'AVBR-DA4':'inh', 'AVBR-DA7':'inh', 'AVDL-DA1':'inh', 'AVDL-DA2':'inh', 'AVDL-DA3':'inh', 'AVDL-DA4':'inh', 'AVDL-DA5':'inh', 'AVDL-DA8':'inh', 'AVDR-DA1':'inh', 'AVDR-DA2':'inh', 'AVDR-DA3':'inh', 'AVDR-DA4':'inh', 'AVDR-DA5':'inh', 'AVDR-DA8':'inh', 'DB1-DA1':'inh', 'DB1-DA2':'inh', 'DB2-DA2':'inh', 'DB2-DA3':'inh', 'DB2-DA4':'inh', 'DB3-DA4':'inh', 'DB3-DA5':'inh', 'DB4-DA5':'inh', 'DB5-DA6':'inh', 'DB5-DA7':'inh', 'DB5-DA8':'inh', 'DB6-DA8':'inh', 'DB6-DA9':'inh', 'DB7-DA9':'inh', 'AVAR-DB2':'inh', 'AVAR-DB3':'inh', 'AVAL-DB7':'inh', 'DA1-DB1':'inh', 'DA2-DA3':'inh', 'DA2-DB1':'inh', 'DA3-DB3':'inh', 'DA4-DB2':'inh', 'DA5-DB4':'inh', 'DA6-DB5':'inh', 'DA7-DB6':'inh', 'DA8-DB7':'inh', 'DA9-DB7':'inh', 'DVA-VA2':'inh', 'DVA-VA6':'inh', 'DVA-VA8':'inh', 'DVA-VA12':'inh', 'PVCL-VA11':'inh', 'PVDR-VA9':'inh', 'PVDR-VA12':'inh', 'AVBL-VA2':'inh', 'AVBL-VA10':'inh', 'AVBR-VA3':'inh', 'AVBR-VA4':'inh', 'AVDL-VA3':'inh', 'AVDL-VA5':'inh', 'AVDL-VA10':'inh', 'AVDL-VA12':'inh', 'AVDR-VA2':'inh', 'AVDR-VA3':'inh', 'AVDR-VA5':'inh', 'AVDR-VA11':'inh', 'VB1-VA1':'inh', 'VB1-VA2':'inh', 'VB1-VA3':'inh', 'VB1-VA4':'inh', 'VB2-VA2':'inh', 'VB2-VA3':'inh', 'VB3-VA4':'inh', 'VB3-VA5':'inh', 'VB4-VA4':'inh', 'VB4-VA5':'inh', 'VB5-VA6':'inh', 'VB6-VA7':'inh', 'VB6-VA8':'inh', 'VB7-VA9':'inh', 'VB7-VA10':'inh', 'VB8-VA11':'inh', 'VB9-VA11':'inh', 'VB10-VA11':'inh', 'VB11-VA12':'inh', 'VB11-PVCR':'inh', 'VB4-VB5':'inh', 'VA2-VB1':'inh', 'VA2-VB2':'inh', 'VA3-VB2':'inh', 'VA3-VB3':'inh', 'VA4-AVDL':'inh', 'VA4-VB3':'inh', 'VA4-VB4':'inh', 'VA5-VB4':'inh', 'VA6-VB4':'inh', 'VA6-VB5':'inh', 'VA7-VB6':'inh', 'VA8-VB6':'inh', 'VA9-VB7':'inh', 'VA9-VB8':'inh', 'VA10-VB8':'inh', 'VA10-VB9':'inh', 'VA11-VB10':'inh', 'VA12-PVCL':'inh', 'VA12-PVCR':'inh', 'VA12-DB7':'inh', 'VA12-VB11':'inh', 'AVM-VB3':'inh', #'VB4-VB5':'exc', #'DD1-DA2':'inh', #'DD1-VB2':'inh', #'DD2-DA3':'inh', #'DD3-DA5':'inh', } conn_number_override = { #'PVCL-AVDL':7*0.1, #'PVCL-AVDR':11*0.1, #'PVCR-AVDL':16*0.1, #'PVCR-AVDR':6*0.1, #'PVCR-AVDR_GJ':2 * 0.01, #'AVDR-PVCR_GJ':2 * 0.01, 'PVCL-AVAL_GJ':5 * 0.01, 'AVAL-PVCL_GJ':5 * 0.01, 'PVCL-AVAR_GJ':10 * 0.01, 'AVAR-PVCL_GJ':10 * 0.01, 'PVCR-AVAL_GJ':15 * 0.01, 'AVAL-PVCR_GJ':15 * 0.01, 'PVCR-AVAR_GJ':22 * 0.01, 'AVAR-PVCR_GJ':22 * 0.01, 'PVCL-PLML_GJ':4 * 0.01, ## 'PVCR-PLMR_GJ':8 * 0.01, ## #'AVDL-AVM_GJ':8 * 0.01, #'ALML-AVM_GJ':1 * 0.01, #'ALMR-AVM_GJ':1 * 0.01, #'AVDR-ALMR_GJ':1 * 0.01, # 'AVDL-AVAL':37*0.1, # 'AVDL-AVAR':37*0.1, # 'AVDR-AVAL':41*0.1, # 'AVDR-AVAR':52*0.1, # 'AVDL-AVAL_GJ':7*0.1, # 'AVAL-AVDL_GJ':7*0.1, # 'AVDL-AVAR_GJ':2*0.1, # 'AVAR-AVDL_GJ':2*0.1, # 'AVDR-AVAL_GJ':9*0.1, # 'AVAL-AVDR_GJ':9*0.1, # 'AVDR-AVAR_GJ':15*0.1, # 'AVAR-AVDR_GJ':15*0.1, # 'ALMR-AVDR_GJ':2*5, # 'AVDR-ALMR_GJ':2*5, 'AVAR-AVBL_GJ':3*0.01, 'AVBL-AVAR_GJ':3*0.01, # 'AVAR-AVAL_GJ':18*2, # 'AVAL-AVAR_GJ':18*2, 'PVDL-AVAR_GJ':4 * 0.01, 'AVAR-PVDL_GJ':4 * 0.01, 'PVDR-AVAL_GJ':6 * 0.01, 'AVAL-PVDR_GJ':6 * 0.01, 'AVBL-VA11_GJ':1 * 0.01, 'VA11-AVBL_GJ':1 * 0.01, 'AVBR-VA11_GJ':3 * 0.01, 'VA11-AVBR_GJ':3 * 0.01, 'PVCR-VA11_GJ':3 * 0.01, 'VA11-PVCR_GJ':3 * 0.01, 'DVA-VA11_GJ':1 * 0.01, 'VA11-DVA_GJ':1 * 0.01, 'PVCL-VA12_GJ':18 * 0.01, 'VA12-PVCL_GJ':18 * 0.01, 'PVCR-VA12_GJ':8 * 0.01, 'VA12-PVCR_GJ':8 * 0.01, 'AVAL-VB11_GJ':2 * 0.01, 'VB11-AVAL_GJ':2 * 0.01, 'PVCL-DA4_GJ':1 * 0.01, 'DA4-PVCL_GJ':1 * 0.01, 'PVCL-DA7_GJ':1 * 0.01, 'DA7-PVCL_GJ':1 * 0.01, 'PVCR-DA7_GJ':3 * 0.01, 'DA7-PVCR_GJ':3 * 0.01, 'PVCL-DA8_GJ':17 * 0.01, 'DA8-PVCL_GJ':17 * 0.01, 'PVCR-DA8_GJ':1 * 0.01, 'DA8-PVCR_GJ':1 * 0.01, 'DVA-DA9_GJ':3 * 0.01, 'DA9-DVA_GJ':3 * 0.01, 'PVCR-DA9_GJ':3 * 0.01, 'DA9-PVCR_GJ':3 * 0.01, 'DB7-VA10_GJ':1 * 0.01, 'VA10-DB7_GJ':1 * 0.01, 'VA4-VB3_GJ':1 * 0.01, 'VB3-VA4_GJ':1 * 0.01, 'VA11-VB10_GJ':3 * 0.01, 'VB10-VA11_GJ':3 * 0.01, 'VA12-VB11_GJ':7 * 0.01, 'VB11-VA12_GJ':7 * 0.01, 'VB11-DA9_GJ':7 * 0.01, 'DA9-VB11_GJ':7 * 0.01, } nml_doc = None if generate: nml_doc = c302.generate(reference, params, cells=cells, cells_to_plot=cells_to_plot, cells_to_stimulate=cells_to_stimulate, conn_polarity_override=conn_polarity_override, conn_number_override=conn_number_override, muscles_to_include=muscles_to_include, duration=duration, dt=dt, target_directory=target_directory, data_reader=data_reader, param_overrides=param_overrides, verbose=verbose) stim_amplitude = "6pA" # stim_amplitude = "5.135697186048022pA" for vb in VB_motors: c302.add_new_sinusoidal_input(nml_doc, cell=vb, delay="0ms", duration="1000ms", amplitude="3pA", period="150ms", params=params) for db in DB_motors: c302.add_new_sinusoidal_input(nml_doc, cell=db, delay="0ms", duration="1000ms", amplitude="3pA", period="150ms", params=params) #c302.add_new_input(nml_doc, "AVM", "10ms", "700ms", stim_amplitude, params) #c302.add_new_input(nml_doc, "ALML", "10ms", "700ms", stim_amplitude, params) #c302.add_new_input(nml_doc, "ALMR", "10ms", "700ms", stim_amplitude, params) #c302.add_new_input(nml_doc, "PLML", "10ms", "700ms", stim_amplitude, params) #c302.add_new_input(nml_doc, "PLMR", "10ms", "700ms", stim_amplitude, params) nml_file = target_directory + '/' + reference + '.net.nml' writers.NeuroMLWriter.write(nml_doc, nml_file) # Write over network file written above... c302.print_("(Re)written network file to: " + nml_file) return cells, cells_to_stimulate, params, muscles_to_include, nml_doc
def setup(parameter_set, generate=False, duration=500, dt=0.05, target_directory='examples', data_reader="SpreadsheetDataReader", param_overrides={}, config_param_overrides={}, verbose=True): exec('from parameters_%s import ParameterisedModel' % parameter_set, globals()) params = ParameterisedModel() stim_amplitudes = ["1pA", "5pA"] duration = (len(stim_amplitudes)) * 1800 params.set_bioparameter("unphysiological_offset_current_del", "50 ms", "Testing IClamp", "0") exc_pre = "URYDL" exc_post = "SMDDR" inh_pre = "VD12" inh_post = "VB11" gap_1 = "AIZL" gap_2 = "ASHL" moto_pre = "AS2" muscle_post = "MDL07" cells = [exc_pre, exc_post, inh_pre, inh_post, moto_pre] cells_to_stimulate_extra = [exc_pre, inh_pre, moto_pre] muscles_to_include = [muscle_post] if parameter_set != 'A': cells.append(gap_1) cells.append(gap_2) cells_to_stimulate_extra.append(gap_1) reference = "c302_%s_Syns" % parameter_set nml_doc = None if generate: nml_doc = c302.generate(reference, params, cells=cells, cells_to_stimulate=[], muscles_to_include=muscles_to_include, duration=duration, dt=dt, target_directory=target_directory, param_overrides=param_overrides, verbose=verbose, data_reader=data_reader) for i in range(len(stim_amplitudes)): start = "%sms" % (i * 1400 + 500) for c in cells_to_stimulate_extra: c302.add_new_input(nml_doc, c, start, "800ms", stim_amplitudes[i], params) nml_file = target_directory + '/' + reference + '.net.nml' writers.NeuroMLWriter.write( nml_doc, nml_file) # Write over network file written above... c302.print_("(Re)written network file to: " + nml_file) return cells, cells_to_stimulate_extra, params, [], nml_doc
def setup(parameter_set, generate=False, duration=6000, dt=0.05, target_directory='examples', data_reader="UpdatedSpreadsheetDataReader2", param_overrides={}, verbose=True, config_param_overrides={}): exec ('from parameters_%s import ParameterisedModel' % parameter_set, globals()) params = ParameterisedModel() #''' VA_motors = ["VA%s" % c for c in range_incl(1, 12)] VB_motors = ["VB%s" % c for c in range_incl(1, 11)] DA_motors = ["DA%s" % c for c in range_incl(1, 9)] DB_motors = ["DB%s" % c for c in range_incl(1, 7)] DD_motors = ["DD%s" % c for c in range_incl(1, 6)] VD_motors = ["VD%s" % c for c in range_incl(1, 13)] AS_motors = ["AS%s" % c for c in range_incl(1, 11)] #''' motors = list(VA_motors + VB_motors + AS_motors + DA_motors + DB_motors + VD_motors + DD_motors) inters = ['AVBL', 'AVBR', 'AVAL', 'AVAR'] cells = list(motors + inters) muscles_to_include = [] cells_to_stimulate = [] cells_to_plot = cells reference = "c302_%s_BW" % parameter_set conns_to_include = [ ] conns_to_exclude = [ 'VB2-VB4_GJ', 'VB4-VB2_GJ', ######################################### # Remove unwanted interneuron connections ######################################### # Disconnect the AVA and AVB interneurons r'^AVB.-AVA.$', r'^AVA.-AVB.$', r'^AVB.-AVA._GJ$', r'^AVA.-AVB._GJ$', # Disconnect chemical stimulation from AVA and AVB r'^AVB.-.A\d+$', r'^AVB.-.B\d+$', r'^AVB.-.D\d+$', r'^AVB.-AS\d+$', r'^AVA.-.A\d+$', r'^AVA.-.B\d+$', r'^AVA.-.D\d+$', r'^AVA.-AS\d+$', # Disconnect AVA and AVB gap junctions not pressent. r'^AVB.-.A\d+_GJ$', r'^AVB.-AS\d+_GJ$', r'^AVB.-.D\d+_GJ$', r'^AVA.-.B\d+_GJ$', r'^AVA.-AS\d+_GJ$', r'^AVA.-.D\d+_GJ$', # Disconnect feedback GJ into AVA and AVB. r'^..\d+-AV.._GJ$', ######################################################### # Remove connections not present in Haspel and O'Donovan ######################################################### #''' r'^AS\d+-.B\d+$', r'^AS\d+-VA\d+$', r'^AS\d+-DD\d+$', r'^AS\d+-..\d+_GJ$', r'^..\d+-AS\d+_GJ$', r'^DA\d+-AS\d+$', r'^DA\d+-DD\d+$', r'^DA\d+-VB\d+$', r'^DA\d+-VA\d+$', r'^DA\d+-AS\d+$', r'^DA\d+-.B\d+_GJ$', r'^DA\d+-.D\d+_GJ$', r'^.B\d+-DA\d+_GJ$', r'^.D\d+-DA\d+_GJ$', r'^DB\d+-.A\d+$', r'^DB\d+-VB\d+$', r'^DB\d+-.A\d+_GJ$', r'^DB\d+-.D\d+_GJ$', r'^DB\d+-VB\d+_GJ$', r'^.A\d+-DB\d+_GJ$', r'^.D\d+-DB\d+_GJ$', r'^VB\d+-DB\d+_GJ$', r'^DD\d+-..\d+$', r'^DD\d+-VD\d+_GJ$', r'^DD\d+-.B\d+_GJ$', r'^DD\d+-.A\d+_GJ$', r'^VD\d+-DD\d+_GJ$', r'^.B\d+-DD\d+_GJ$', r'^.A\d+-DD\d+_GJ$', r'^VD\d+-D.\d+$', r'^VD\d+-AS\d+$', r'^VD\d+-VB\d+_GJ$', r'^VB\d+-VD\d+_GJ$', r'^VB\d+-DB\d+$', r'^VB\d+-.A\d+$', r'^VB\d+-AS\d+$', r'^VB\d+-VD\d+$', r'^VB\d+-VA\d+_GJ$', r'^VA\d+-VB\d+_GJ$', r'^VA\d+-.B\d+$', r'^VA\d+-DA\d+$', r'^VA\d+-AS\d+$', ############################################### # Remove connections going forward in DA and VA ############################################### #Forward connections in DA-VA 'DA3-DA4', 'DA2-DA3', 'VA2-VA3', 'VA3-VA4', 'VA5-VA6', 'DA9-VA12', 'VA12-DA8', 'VA12-DA9', 'VA1-DA2', #''' ] conn_polarity_override = { #Inhibitory in Olivares r'^AS\d+-VD\d+$': 'inh', r'^DB\d+-AS\d+$': 'inh', r'^DB\d+-VD\d+$': 'inh', r'^VD\d+-VA\d+$': 'inh', r'^VA\d+-VD\d+$': 'inh', #Excitatory in Olivares r'^VD\d+-VB\d+$': 'exc', #Inhibitory in LUNG #r'^DB\d+-DD\d+$': 'inh', #r'^VB\d+-VD\d+$': 'inh', #Inhibitory for DD r'^DA\d+-DD\d+$': 'inh', r'^AS\d+-DD\d+$': 'inh', r'^DB\d+-VD\d+$': 'inh', } conn_polarity_override = { #### NEW CIRCUIT #### r'^VA\d+-VD\d+$': 'inh', r'^DA\d+-DD\d+$': 'inh', r'^AS\d+-DD\d+$': 'inh', r'^DB\d+-DD\d+$': 'inh', r'^AS\d+-VD\d+$': 'inh', #VD-DD and VD-VB are already inhibitory } conn_number_override = { '^.+-.+$': 1, } #********* # INPUTS #********* input_list = [] sine_input_list = [] ramp_input_list = [] #************************* # Interneuron STIMULATION #************************* #''' input_list.append(('AVAL', '0ms', '4000ms', '15pA')) input_list.append(('AVAR', '0ms', '4000ms', '15pA')) #''' #************************* # DB1 and VB1 STIMULATION #************************* # Sinusoidal Input #''' #sine_input_list.append(('DB1', '0ms', '15000ms', '1.5pA', '800ms')) #AMP: 2pA seems to overstimulate #sine_input_list.append(('VB1', '0ms', '15000ms', '1.5pA', '800ms')) sine_input_list.append(('DA9', '0ms', '15000ms', '1.5pA', '800ms')) sine_input_list.append(('VA12', '0ms', '15000ms', '-1.5pA', '800ms')) config_param_overrides['input'] = input_list param_overrides = { 'mirrored_elec_conn_params': { #Connections to DB1 and VB1 have a HIGHER conductance r'^AVB._to_.B1_GJ$_elec_syn_gbase': '0.005 nS', #Connections to rest of DB and VB have a LOWER conductance r'^AVB._to_.B[2-9]\_GJ$_elec_syn_gbase': '0.001 nS', r'^AVB._to_.B[1-9][0-9]\_GJ$_elec_syn_gbase': '0.001 nS', #Connections to DA9 and VA12 have a HIGHER conductance r'^AVA._to_DA9_GJ$_elec_syn_gbase': '0.005 nS', r'^AVA._to_VA12_GJ$_elec_syn_gbase': '0.005 nS', #Connections to rest of DA and VA have LOWER conductance r'^AVA._to_DA[1-8]\_GJ$_elec_syn_gbase': '0.001 nS', r'^AVA._to_VA[1-9][0-1]?\_GJ$_elec_syn_gbase': '0.001 nS', r'^.B\d+_to_.B\d+\_GJ$_elec_syn_gbase': '0.001 nS', r'^.A\d+_to_.A\d+\_GJ$_elec_syn_gbase': '0.001 nS', r'^.D\d+_to_.D\d+\_GJ$_elec_syn_gbase': '0.001 nS', r'^AS\d+_to_AS\d+\_GJ$_elec_syn_gbase': '0.001 nS', r'^VA\d+_to_DA\d+\_GJ$_elec_syn_gbase': '0.001 nS', r'^VA\d+_to_VD\d+\_GJ$_elec_syn_gbase': '0.001 nS', }, 'initial_memb_pot': '-50 mV', ##### Adjustments ###### r'^DA\d+_to_DB\d+$_exc_syn_conductance': '0.2 nS', r'^DB\d+_to_VD\d+$_exc_syn_conductance': '0.2 nS', #********************************* # Connections between units (chemical) #********************************* #r'^VD\d+_to_VB\d+$_inh_syn_conductance': '0.2 nS', #r'^DA\d+_to_VD\d+$_exc_syn_conductance': '0.2 nS', #Connect synaptically VB1 to VB2 and so on r'^VB\d+_to_VB\d+$_exc_syn_conductance': '30 nS', r'^VB\d+_to_VB\d+$_exc_syn_ar': '0.19 per_s', r'^VB\d+_to_VB\d+$_exc_syn_ad': '73 per_s', r'^VB\d+_to_VB\d+$_exc_syn_beta': '2.81 per_mV', r'^VB\d+_to_VB\d+$_exc_syn_vth': '-22 mV', r'^VB\d+_to_VB\d+$_exc_syn_erev': '10 mV', #Connect synaptically DB1 to DB2 and so on r'^DB\d+_to_DB\d+$_exc_syn_conductance': '30 nS', r'^DB\d+_to_DB\d+$_exc_syn_ar': '0.08 per_s', r'^DB\d+_to_DB\d+$_exc_syn_ad': '18 per_s', r'^DB\d+_to_DB\d+$_exc_syn_beta': '0.21 per_mV', r'^DB\d+_to_DB\d+$_exc_syn_vth': '-10 mV', r'^DB\d+_to_DB\d+$_exc_syn_erev': '10 mV', #''' #Connect synaptically VA1 to VA2 and so on r'^VA\d+_to_VA\d+$_exc_syn_conductance': '30 nS', r'^VA\d+_to_VA\d+$_exc_syn_ar': '0.19 per_s', r'^VA\d+_to_VA\d+$_exc_syn_ad': '73 per_s', r'^VA\d+_to_VA\d+$_exc_syn_beta': '2.81 per_mV', r'^VA\d+_to_VA\d+$_exc_syn_vth': '-22 mV', r'^VA\d+_to_VA\d+$_exc_syn_erev': '10 mV', #Connect synaptically DB1 to DB2 and so on r'^DA\d+_to_DA\d+$_exc_syn_conductance': '30 nS', r'^DA\d+_to_DA\d+$_exc_syn_ar': '0.08 per_s', r'^DA\d+_to_DA\d+$_exc_syn_ad': '18 per_s', r'^DA\d+_to_DA\d+$_exc_syn_beta': '0.21 per_mV', r'^DA\d+_to_DA\d+$_exc_syn_vth': '-10 mV', r'^DA\d+_to_DA\d+$_exc_syn_erev': '10 mV', #''' 'AVBR_to_MVL16_exc_syn_conductance': '0 nS', 'ca_conc_decay_time_muscle': '60.8 ms', 'ca_conc_rho_muscle': '0.002338919 mol_per_m_per_A_per_s', } nml_doc = None if generate: nml_doc = c302.generate(reference, params, cells=cells, cells_to_plot=cells_to_plot, cells_to_stimulate=cells_to_stimulate, conns_to_include=conns_to_include, conns_to_exclude=conns_to_exclude, conn_polarity_override=conn_polarity_override, conn_number_override=conn_number_override, muscles_to_include=muscles_to_include, duration=duration, dt=dt, target_directory=target_directory, data_reader=data_reader, param_overrides=param_overrides, verbose=verbose) #if config_param_overrides.has_key('input'): # input_list = config_param_overrides['input'] for stim_input in input_list: cell, start, dur, current = stim_input c302.add_new_input(nml_doc, cell, start, dur, current, params) for sine_stim_input in sine_input_list: cell, delay, dur, amp, period = sine_stim_input c302.add_new_sinusoidal_input(nml_doc, cell, delay, dur, amp, period, params) for ramp_stim_input in ramp_input_list: cell, delay, dur, start_amp, finish_amp, base_amp = ramp_stim_input c302.add_new_ramp_input(nml_doc, cell, delay, dur, start_amp, finish_amp, base_amp, params) #c302.add_new_input(nml_doc, cell='VB1', delay="1200ms", duration="1000ms", amplitude="1pA", params=params) #c302.add_new_input(nml_doc, cell='VB1', delay="0ms", duration="2000ms", amplitude="1.5pA", params=params) nml_file = target_directory + '/' + reference + '.net.nml' writers.NeuroMLWriter.write(nml_doc, nml_file) # Write over network file written above... c302.print_("(Re)written network file to: " + nml_file) return cells, cells_to_stimulate, params, muscles_to_include, nml_doc
def plot_c302_results(lems_results, config, parameter_set, directory='./', save=True, show_plot_already=True, data_reader="SpreadsheetDataReader", plot_ca=True): params = {'legend.fontsize': 8, 'font.size': 10} plt.rcParams.update(params) if not directory.endswith('/'): directory += '/' save_fig_path = directory+'%s' #c302.print_("Reloaded data: %s"%lems_results.keys()) cells = [] muscles = [] times = [t*1000 for t in lems_results['t']] for cm in lems_results.keys(): if not cm=='t' and cm.endswith('/v'): if c302.is_muscle(cm): muscles.append(cm.split('/')[0]) else: cells.append(cm.split('/')[0]) cells.sort(key=natsort) cells.reverse() c302.print_("All cells: %s"%cells) dt = lems_results['t'][1] ################################################ ## Plot voltages cells if len(cells) > 0: c302.print_("Plotting neuron voltages") template = '{0}/0/GenericNeuronCell/{1}' if parameter_set.startswith('A') or parameter_set.startswith('B'): template = '{0}/0/generic_neuron_iaf_cell/{1}' if parameter_set.startswith('D'): template = '{0}/0/{0}/{1}' xvals = [] yvals = [] labels = [] for cell in cells: v = lems_results[template.format(cell,'v')] xvals.append(times) labels.append(cell) if cell==cells[0]: volts_n = np.array([[vv*1000 for vv in v]]) else: volts_n = np.append(volts_n,[[vv*1000 for vv in v]],axis=0) yvals.append(volts_n[-1]) info = 'Membrane potentials of %i neuron(s) (%s %s)'%(len(cells),config,parameter_set) #tasks.append((volts_n, info, cells, dt)) plots(volts_n, info, cells, dt) if save: f = save_fig_path%('neurons_%s_%s.png'%(parameter_set,config)) c302.print_("Saving figure to: %s"%os.path.abspath(f)) plt.savefig(f,bbox_inches='tight') generate_traces_plot(config, parameter_set, xvals, yvals, info, labels, save=save, save_fig_path=save_fig_path, voltage=True, muscles=False) ################################################ ## Plot voltages muscles muscles.sort(key=natsort) muscles.reverse() xvals = [] yvals = [] labels = [] if len(muscles)>0: c302.print_("Plotting muscle voltages") template_m = '{0}/0/GenericMuscleCell/{1}' if parameter_set.startswith('A') or parameter_set.startswith('B'): template_m = '{0}/0/generic_muscle_iaf_cell/{1}' for muscle in muscles: mv = lems_results[template_m.format(muscle,'v')] xvals.append(times) labels.append(muscle) if muscle==muscles[0]: mvolts_n = np.array([[vv*1000 for vv in mv]]) else: mvolts_n = np.append(mvolts_n,[[vv*1000 for vv in mv]],axis=0) yvals.append(mvolts_n[-1]) info = 'Membrane potentials of %i muscle(s) (%s %s)'%(len(muscles),config,parameter_set) plots(mvolts_n, info, muscles, dt) if save: f = save_fig_path%('muscles_%s_%s.png'%(parameter_set,config)) c302.print_("Saving figure to: %s"%os.path.abspath(f)) plt.savefig(f,bbox_inches='tight') generate_traces_plot(config, parameter_set, xvals, yvals, info, labels, save=save, save_fig_path=save_fig_path, voltage=True, muscles=True) ################################################ ## Plot activity/[Ca2+] in cells if plot_ca and parameter_set!='A' and len(cells) > 0: c302.print_("Plotting neuron activities ([Ca2+])") variable = 'activity' description = 'Activity' if parameter_set.startswith('C') or parameter_set.startswith('D'): variable = 'caConc' description = '[Ca2+]' xvals = [] yvals = [] labels = [] info = '%s of %i neurons (%s %s)'%(description, len(cells),config,parameter_set) for cell in cells: a = lems_results[template.format(cell,variable)] xvals.append(times) yvals.append(a) labels.append(cell) if cell==cells[0]: activities_n = np.array([a]) else: activities_n = np.append(activities_n,[a],axis=0) plots(activities_n, info, cells, dt) if save: f = save_fig_path%('neuron_activity_%s_%s.png'%(parameter_set,config)) c302.print_("Saving figure to: %s"%os.path.abspath(f)) plt.savefig(f,bbox_inches='tight') generate_traces_plot(config, parameter_set, xvals, yvals, info, labels, save=save, save_fig_path=save_fig_path, voltage=False, muscles=False) ################################################ ## Plot activity/[Ca2+] in muscles if plot_ca and parameter_set!='A' and len(muscles)>0: c302.print_("Plotting muscle activities ([Ca2+])") variable = 'activity' description = 'Activity' if parameter_set.startswith('C') or parameter_set.startswith('D'): variable = 'caConc' description = '[Ca2+]' xvals = [] yvals = [] labels = [] info = '%s of %i muscles (%s %s)'%(description, len(muscles),config,parameter_set) for m in muscles: a = lems_results[template_m.format(m,variable)] xvals.append(times) yvals.append(a) labels.append(m) if m==muscles[0]: activities_n = np.array([a]) else: activities_n = np.append(activities_n,[a],axis=0) plots(activities_n, info, muscles, dt) if save: f = save_fig_path%('muscle_activity_%s_%s.png'%(parameter_set,config)) c302.print_("Saving figure to: %s"%os.path.abspath(f)) plt.savefig(f,bbox_inches='tight') generate_traces_plot(config, parameter_set, xvals, yvals, info, labels, save=save, save_fig_path=save_fig_path, voltage=False, muscles=True) if show_plot_already: try: plt.show() except KeyboardInterrupt: print "Interrupt received, stopping..." else: plt.close("all")
print_("Total cells %i (%i with connections)" % (len(cell_names), len(cells))) print_("Total connections found %i " % len(conns)) if include_nonconnected_cells: return cell_names, conns else: return cells, conns if __name__ == "__main__": cells, conns = read_data(include_nonconnected_cells=True) print_("%i cells found using OpenWormReader: %s..." % (len(cells), sorted(cells)[0:3])) print_("Found %s connections using OpenWormReader: %s..." % (len(conns), conns[0])) conn_map_OWR = {} for c in conns: conn_map_OWR[c.short()] = c from UpdatedSpreadsheetDataReader import read_data as read_data_usr #from SpreadsheetDataReader import read_data as read_data_usr cells2, conns2 = read_data_usr(include_nonconnected_cells=True) print_("%i cells found using UpdatedSpreadsheetDataReader: %s..." % (len(cells2), sorted(cells2)[0:3]))
def go(self): """ Start the simulation once it's been intialized """ nml_doc = c302.generate(self.reference, self.params, cells=self.cells, cells_to_stimulate=self.cells_to_stimulate, muscles_to_include=self.muscles_to_include, duration=self.sim_time, dt=self.dt, verbose=False, target_directory=self.generate_dir) self.lems_file = "LEMS_%s.xml" % (self.reference) c302.print_("Running a simulation of %s ms with timestep %s ms: %s" % (self.sim_time, self.dt, self.lems_file)) self.already_run = True start = time.time() if self.simulator == 'jNeuroML': self.results = pynml.run_lems_with_jneuroml( self.lems_file, nogui=True, load_saved_data=True, plot=False, exec_in_dir=self.generate_dir, verbose=False) elif self.simulator == 'jNeuroML_NEURON': self.results = pynml.run_lems_with_jneuroml_neuron( self.lems_file, nogui=True, load_saved_data=True, plot=False, exec_in_dir=self.generate_dir, verbose=False) else: c302.print_('Unsupported simulator: %s' % self.simulator) exit() secs = time.time() - start c302.print_("Ran simulation in %s in %f seconds (%f mins)\n\n" % (self.simulator, secs, secs / 60.0)) self.t = [t * 1000 for t in self.results['t']] res_template_n = '%s/0/generic_neuron_iaf_cell/v' if self.params.level.startswith('C') or self.params.level.startswith( 'D'): res_template_n = '%s/0/GenericNeuronCell/v' res_template_m = '%s/0/GenericMuscleCell/v' self.volts = {} if self.cells is None: self.cells = [] for pop in nml_doc.networks[0].populations: self.cells.append(pop.id) for cell in self.cells: self.volts[res_template_n % cell] = [ v * 1000 for v in self.results[res_template_n % cell] ] if self.muscles_to_include: for cell in self.muscles_to_include: self.volts[res_template_m % cell] = [ v * 1000 for v in self.results[res_template_m % cell] ]
def _read_connections(self, termination=None): if not self.cached: with Bundle('openworm/owmeta-data', version=6) as bnd: ctx = bnd(Context)(ident="http://openworm.org/data").stored # Extract the network object from the worm object. net = ctx(Worm).query().neuron_network() syn = net.synapse.expr pre = syn.pre_cell post = syn.post_cell (pre | post).rdf_type(multiple=True) (pre | post).name() pre() post() syn.syntype() syn.synclass() syn.number() self.connlist = syn.to_objects() self.cell_names = self.get_cells_in_model(net) self.cached = True if termination == 'neuron': term_type = set([Neuron.rdf_type]) elif termination == 'muscle': term_type = set([BodyWallMuscle.rdf_type]) else: term_type = set([Neuron.rdf_type, BodyWallMuscle.rdf_type]) conns = [] pre_cell_names = set() post_cell_names = set() for conn in self.connlist: if (Neuron.rdf_type in conn.pre_cell.rdf_type and term_type & set(conn.post_cell.rdf_type)): num = conn.number syntype = conn.syntype or '' synclass = conn.synclass or '' pre_name = conn.pre_cell.name post_name = conn.post_cell.name if BodyWallMuscle.rdf_type in conn.post_cell.rdf_type: post_name = format_muscle_name(post_name) if not synclass: # Hack/guess if syntype and syntype.lower() == "gapjunction": synclass = "Generic_GJ" else: if pre_name.startswith("DD") or pre_name.startswith("VD"): synclass = "GABA" synclass = "Acetylcholine" conns.append(ConnectionInfo(pre_name, post_name, num, syntype, synclass)) pre_cell_names.add(pre_name) post_cell_names.add(post_name) print_("Total cells %i (%i with connections)" % ( len(self.cell_names | pre_cell_names | post_cell_names), len(pre_cell_names | post_cell_names))) print_("Total connections found %i " % len(conns)) return list(self.cell_names), pre_cell_names, post_cell_names, conns
def setup(parameter_set, generate=False, duration=2000, dt=0.05, target_directory='examples', data_reader="SpreadsheetDataReader", param_overrides={}, verbose=True, config_param_overrides={}): exec('from c302.parameters_%s import ParameterisedModel' % parameter_set, globals()) params = ParameterisedModel() params.set_bioparameter("unphysiological_offset_current", "0pA", "Testing TapWithdrawal", "0") params.set_bioparameter("unphysiological_offset_current_del", "0 ms", "Testing TapWithdrawal", "0") params.set_bioparameter("unphysiological_offset_current_dur", "2000 ms", "Testing TapWithdrawal", "0") VA_motors = ["VA%s" % c for c in range_incl(1, 12)] VB_motors = ["VB%s" % c for c in range_incl(1, 11)] DA_motors = ["DA%s" % c for c in range_incl(1, 9)] DB_motors = ["DB%s" % c for c in range_incl(1, 7)] DD_motors = ["DD%s" % c for c in range_incl(1, 6)] VD_motors = ["VD%s" % c for c in range_incl(1, 13)] AS_motors = ["AS%s" % c for c in range_incl(1, 11)] cells = [] muscles_to_include = True if config_param_overrides.has_key('muscles_to_include'): muscles_to_include = config_param_overrides['muscles_to_include'] cells_to_stimulate = [] cells_to_plot = list(cells) reference = "c302_%s_MuscleTest" % parameter_set conns_to_include = [] if config_param_overrides.has_key('conns_to_include'): conns_to_include = config_param_overrides['conns_to_include'] conns_to_exclude = ['^.+-.+$'] if config_param_overrides.has_key('conns_to_exclude'): conns_to_exclude = config_param_overrides['conns_to_exclude'] conn_polarity_override = {} if config_param_overrides.has_key('conn_polarity_override'): conn_polarity_override.update( config_param_overrides['conn_polarity_override']) conn_number_override = {} if config_param_overrides.has_key('conn_number_override'): conn_number_override.update( config_param_overrides['conn_number_override']) param_overrides = { 'ca_conc_decay_time_muscle': '60 ms', 'ca_conc_rho_muscle': '0.002138919 mol_per_m_per_A_per_s', } end = '%sms' % (int(duration) - 100) input_list = [] #input_list.append(('MDL02', '0ms', '250ms', '3pA')) #input_list.append(('MDL03', '0ms', '250ms', '3pA')) #input_list.append(('MDR02', '0ms', '250ms', '3pA')) #input_list.append(('MDR03', '0ms', '250ms', '3pA')) input_list.append(('MVR10', '0ms', '250ms', '1pA')) input_list.append(('MVR11', '0ms', '250ms', '2pA')) input_list.append(('MVR12', '0ms', '250ms', '3pA')) input_list.append(('MVR13', '0ms', '250ms', '3pA')) input_list.append(('MVR14', '0ms', '250ms', '2pA')) input_list.append(('MVR15', '0ms', '250ms', '1pA')) input_list.append(('MVL10', '0ms', '250ms', '1pA')) input_list.append(('MVL11', '0ms', '250ms', '2pA')) input_list.append(('MVL12', '0ms', '250ms', '3pA')) input_list.append(('MVL13', '0ms', '250ms', '3pA')) input_list.append(('MVL14', '0ms', '250ms', '2pA')) input_list.append(('MVL15', '0ms', '250ms', '1pA')) input_list.append(('MDL21', '0ms', '250ms', '3pA')) input_list.append(('MDL22', '0ms', '250ms', '3pA')) input_list.append(('MDR21', '0ms', '250ms', '3pA')) input_list.append(('MDR22', '0ms', '250ms', '3pA')) for stim_num in range(5): for muscle_num in range(24): mdlx = 'MDL0%s' % (muscle_num + 1) mdrx = 'MDR0%s' % (muscle_num + 1) mvlx = 'MVL0%s' % (muscle_num + 1) mvrx = 'MVR0%s' % (muscle_num + 1) if muscle_num >= 9: mdlx = 'MDL%s' % (muscle_num + 1) mdrx = 'MDR%s' % (muscle_num + 1) mvlx = 'MVL%s' % (muscle_num + 1) if muscle_num != 23: mvrx = 'MVR%s' % (muscle_num + 1) startd = '%sms' % (stim_num * 1000 + muscle_num * 50) startv = '%sms' % ((stim_num * 1000 + 500) + muscle_num * 50) dur = '250ms' amp = '3pA' input_list.append((mdlx, startd, dur, amp)) input_list.append((mdrx, startd, dur, amp)) input_list.append((mvlx, startv, dur, amp)) input_list.append((mvrx, startv, dur, amp)) nml_doc = None if generate: nml_doc = c302.generate(reference, params, cells=cells, cells_to_plot=cells_to_plot, cells_to_stimulate=cells_to_stimulate, conns_to_include=conns_to_include, conns_to_exclude=conns_to_exclude, conn_polarity_override=conn_polarity_override, conn_number_override=conn_number_override, muscles_to_include=muscles_to_include, duration=duration, dt=dt, target_directory=target_directory, data_reader=data_reader, param_overrides=param_overrides, verbose=verbose) if 'input' in config_param_overrides: input_list = config_param_overrides['input'] for stim_input in input_list: cell, start, dur, current = stim_input c302.add_new_input(nml_doc, cell, start, dur, current, params) nml_file = target_directory + '/' + reference + '.net.nml' writers.NeuroMLWriter.write( nml_doc, nml_file) # Write over network file written above... c302.print_("(Re)written network file to: " + nml_file) return cells, cells_to_stimulate, params, muscles_to_include, nml_doc
def run_c302(config, parameter_set, prefix, duration, dt, simulator, save=False, show_plot_already=True, data_reader="SpreadsheetDataReader", verbose=False, plot_ca=True, plot_connectivity=False, param_overrides={}, config_param_overrides={}, config_package="", target_directory='examples', save_fig_to=None): if save_fig_to: global save_fig_dir save_fig_dir = save_fig_to print("********************\n\n Going to generate c302_%s_%s and run for %sms (dt: %sms) on %s\n\n********************"%(parameter_set,config,duration, dt, simulator)) if config_package: exec ('from %s.c302_%s import setup' % (config_package, config), globals()) else: exec ('from c302_%s import setup' % config, globals()) try: os.makedirs(target_directory) except OSError as e: if e.errno != errno.EEXIST: raise cells, cells_to_stimulate, params, muscles, nml_doc = setup(parameter_set, data_reader=data_reader, generate=True, duration = duration, dt = dt, target_directory=target_directory, verbose=verbose, param_overrides=param_overrides, config_param_overrides=config_param_overrides) orig_dir = os.getcwd() os.chdir(target_directory) try: os.makedirs(save_fig_dir) except OSError as e: if e.errno != errno.EEXIST: raise lems_file = 'LEMS_c302_%s_%s.xml'%(parameter_set,config) if simulator == 'jNeuroML': results = pynml.run_lems_with_jneuroml(lems_file, nogui=True, load_saved_data=True, verbose=verbose) elif simulator == 'jNeuroML_NEURON': results = pynml.run_lems_with_jneuroml_neuron(lems_file, nogui=True, load_saved_data=True, verbose=verbose) c302.print_("Finished simulation of %s and have reloaded results"%lems_file) c302_utils.plot_c302_results(results, config, parameter_set, directory=save_image_full_dir, save=save, show_plot_already=show_plot_already, data_reader=data_reader, plot_ca=plot_ca) if plot_connectivity: c302_utils.generate_conn_matrix(nml_doc, save_fig_dir=save_image_full_dir) os.chdir(orig_dir) return cells, cells_to_stimulate, params, muscles
def setup(parameter_set, generate=False, duration=1000, dt=0.05, target_directory='examples', data_reader="SpreadsheetDataReader", param_overrides={}, config_param_overrides={}, verbose=True): exec('from parameters_%s import ParameterisedModel' % parameter_set, globals()) params = ParameterisedModel() params.set_bioparameter("unphysiological_offset_current", "0pA", "Disabling offset current", "0") #params.set_bioparameter("exc_syn_conductance", ".20 nS", "BlindGuess", "0.1") params.set_bioparameter("chem_exc_syn_decay", "5 ms", "BlindGuess", "0.1") #params.set_bioparameter("inh_syn_conductance", ".35 nS", "BlindGuess", "0.1") params.set_bioparameter("chem_inh_syn_decay", "200 ms", "BlindGuess", "0.1") #params.set_bioparameter("elec_syn_gbase", "0.001 nS", "BlindGuess", "0.1") # Any neurons connected to muscles cells = [ 'AS1', 'AS10', 'AS11', 'AS2', 'AS3', 'AS4', 'AS5', 'AS6', 'AS7', 'AS8', 'AS9', 'AVFL', 'AVFR', 'AVKR', 'AVL', 'CEPVL', 'CEPVR', 'DA1', 'DA2', 'DA3', 'DA4', 'DA5', 'DA6', 'DA7', 'DA8', 'DA9', 'DB1', 'DB2', 'DB3', 'DB4', 'DB5', 'DB6', 'DB7', 'DD1', 'DD2', 'DD3', 'DD4', 'DD5', 'DD6', 'DVB', 'HSNL', 'HSNR', 'IL1DL', 'IL1DR', 'IL1L', 'IL1R', 'IL1VL', 'IL1VR', 'PDA', 'PDB', 'PVNL', 'PVNR', 'RID', 'RIML', 'RIMR', 'RIVL', 'RIVR', 'RMDDL', 'RMDDR', 'RMDL', 'RMDR', 'RMDVL', 'RMDVR', 'RMED', 'RMEL', 'RMER', 'RMEV', 'RMFL', 'RMGL', 'RMGR', 'RMHL', 'RMHR', 'SMBDL', 'SMBDR', 'SMBVL', 'SMBVR', 'SMDDL', 'SMDDR', 'SMDVL', 'SMDVR', 'URADL', 'URADR', 'URAVL', 'URAVR', 'VA1', 'VA10', 'VA11', 'VA12', 'VA2', 'VA3', 'VA4', 'VA5', 'VA6', 'VA7', 'VA8', 'VA9', 'VB1', 'VB10', 'VB11', 'VB2', 'VB3', 'VB4', 'VB5', 'VB6', 'VB7', 'VB8', 'VB9', 'VC1', 'VC2', 'VC3', 'VC4', 'VC5', 'VC6', 'VD1', 'VD10', 'VD11', 'VD12', 'VD13', 'VD2', 'VD3', 'VD4', 'VD5', 'VD6', 'VD7', 'VD8', 'VD9' ] cells += ['AVAL', 'AVAR', 'AVBL', 'AVBR', 'AVDL', 'AVDR', 'PVCL', 'PVCR'] #cells=None # implies all cells... ## Some random set of neurons #probability = 0.1 cells_to_stimulate = [] ''' for cell in cells: #if random.random()<probability: # cells_to_stimulate.append(cell) if cell.startswith("xxVB") or cell.startswith("DB"): cells_to_stimulate.append(cell)''' #cells_to_stimulate = ['DB1', 'VB1'] #cells_to_stimulate = ['PVCL', 'AVBL'] #cells_to_stimulate.extend(['DB1', 'VB1']) #cells_to_stimulate = ['PVCL','PVCR'] #cells_to_stimulate = ['PLML','PLMR'] cells_to_stimulate = ['AVBL', 'AVBR'] # Plot some directly stimulated & some not stimulated #cells_to_plot = ['AS1', 'AS10', 'AVFL', 'DA1','DB1','DB4','DB7','IL1DL','RID', 'RIML','SMBDL', 'SMBDR', 'VB1', 'VB5', 'VB10','VC1', 'VC2'] cells_to_plot = [ 'AVBL', 'AVBR', 'PVCL', 'PVCR', 'DB1', 'DB2', 'VB1', 'VB2', 'DD1', 'DD2', 'VD1', 'VD2' ] reference = "c302_%s_MusclesSine" % parameter_set muscles_to_include = True #includes all muscles in plots nml_doc = None if generate: nml_doc = c302.generate(reference, params, cells=cells, cells_to_plot=cells_to_plot, cells_to_stimulate=cells_to_stimulate, muscles_to_include=muscles_to_include, duration=duration, dt=dt, target_directory=target_directory, param_overrides=param_overrides, verbose=verbose, data_reader=data_reader) # Import from libNeuroML from neuroml import SineGenerator, InputList, Input import neuroml.writers as writers # Create the sine wave current generator & add to NeuroML document sw_input = SineGenerator(id='NewSineWaveInput', delay='100ms', phase='0', duration='800ms', amplitude='4.5pA', period='200ms') nml_doc.sine_generators.append(sw_input) # Which cell to stimulate cell = 'AVBL' # create an InputList and add one Input to that cell input_list = InputList(id="Input_%s_%s" % (cell, sw_input.id), component=sw_input.id, populations='%s' % cell) input_list.input.append( Input(id=0, target="../%s/0/GenericNeuronCell" % cell, destination="synapses")) nml_doc.networks[0].input_lists.append(input_list) # Write over network file created already... nml_file = target_directory + '/' + reference + '.net.nml' writers.NeuroMLWriter.write(nml_doc, nml_file) c302.print_("(Re)written network file to: " + nml_file) return cells, cells_to_stimulate, params, muscles_to_include, nml_doc
def plots(a_n, info, cells, dt): c302.print_('Generating plots for: %s'%info) heightened = False matrix_height_in = None if len(cells) > 24: matrix_height_in = 10 heightened = True if len(cells) > 100: matrix_height_in = 20 if heightened: #fontsize_pt = plt.rcParams['ytick.labelsize'] #dpi = 72.27 # comput the matrix height in points and inches ##matrix_height_pt = fontsize_pt * a_n.shape[0] ##matrix_height_in = float(matrix_height_pt) / dpi #matrix_height_in = 10 # compute the required figure height top_margin = 0.04 # in percentage of the figure height bottom_margin = 0.04 # in percentage of the figure height figure_height = matrix_height_in / (1 - top_margin - bottom_margin) fig, ax = plt.subplots( figsize=(6, figure_height), gridspec_kw=dict(top=1 - top_margin, bottom=bottom_margin)) else: fig, ax = plt.subplots() #fig = plt.figure() #ax = fig.gca() downscale = 10 a_n_ = a_n[:,::downscale] plot0 = ax.pcolormesh(a_n_) ax.set_yticks(np.arange(a_n_.shape[0]) + 0.5, minor=False) ax.set_yticklabels(cells) ax.tick_params(axis='y', labelsize=6) #plt.setp(ax.get_yticklabels(), rotation=45) fig.colorbar(plot0) fig.canvas.set_window_title(info) plt.title(info) plt.xlabel('Time (ms)') fig.canvas.draw() labels = [] #issue is with unicode for label in ax.get_xticklabels(): if(len(label.get_text()) >0): labels.append(float( str((label.get_text())) )*dt*downscale*1000) # except: # print "Error value on forming axis values, value: ", label.get_text(), ", length: ",len(label.get_text()) #labels = [float(label.get_text())*dt*downscale*1000 for item in ax.get_xticklabels()] ax.set_xticklabels(labels) #print labels #print plt.xlim() plt.xlim(0,a_n_.shape[1])
def main(): cells, conns = readDataFromSpreadsheet() print_("%i cells in spreadsheet: %s..." % (len(cells), sorted(cells)[0:3])) from os import listdir cell_names = [ f[:-9] for f in listdir('%s/CElegans/morphologies/' % spreadsheet_location) if f.endswith('.java.xml') ] cell_names.remove('MDL08') # muscle s_c = sorted(cell_names) print_("%i cell morphologies found: %s..." % (len(cell_names), s_c[0:3])) for c in cells: cell_names.remove(c) print_("Difference: %s" % cell_names) cells2, conns2 = readDataFromSpreadsheet(include_nonconnected_cells=True) assert (len(cells2) == 302) print_("Lengths are equal if include_nonconnected_cells=True") print_("Found %s connections: %s..." % (len(conns2), conns2[0])) neurons, muscles, conns = readMuscleDataFromSpreadsheet() print_("Found %i neurons connected to muscles: %s\n" % (len(neurons), sorted(neurons))) print_("Found %i muscles connected to neurons: %s\n" % (len(muscles), sorted(muscles))) print_("Found %i connections between neurons and muscles, e.g. %s" % (len(conns), conns[0]))
def run_c302(config, parameter_set, prefix, duration, dt, simulator, save=False, show_plot_already=True, data_reader="SpreadsheetDataReader", verbose=False, plot_ca=True, plot_connectivity=False, param_overrides={}, config_param_overrides={}, config_package="", target_directory='examples', save_fig_to=None): if save_fig_to: global save_fig_dir save_fig_dir = save_fig_to c302.print_("********************\n\n Going to generate c302_%s_%s and run for %sms (dt: %sms) on %s\n\n********************"%(parameter_set,config,duration, dt, simulator)) if config_package: exec ('from %s.c302_%s import setup' % (config_package, config), globals()) else: exec ('from c302_%s import setup' % config, globals()) try: os.makedirs(target_directory) except OSError as e: if e.errno != errno.EEXIST: raise cells, cells_to_stimulate, params, muscles, nml_doc = setup(parameter_set, data_reader=data_reader, generate=True, duration = duration, dt = dt, target_directory=target_directory, verbose=verbose, param_overrides=param_overrides, config_param_overrides=config_param_overrides) orig_dir = os.getcwd() os.chdir(target_directory) try: os.makedirs(save_fig_dir) except OSError as e: if e.errno != errno.EEXIST: raise lems_file = 'LEMS_c302_%s_%s.xml'%(parameter_set,config) if simulator == 'jNeuroML': results = pynml.run_lems_with_jneuroml(lems_file, nogui=True, load_saved_data=True, verbose=verbose) elif simulator == 'jNeuroML_NEURON': results = pynml.run_lems_with_jneuroml_neuron(lems_file, nogui=True, load_saved_data=True, verbose=verbose) c302.print_("Finished simulation of %s and have reloaded results"%lems_file) c302_utils.plot_c302_results(results, config, parameter_set, directory=save_image_full_dir, save=save, show_plot_already=show_plot_already, data_reader=data_reader, plot_ca=plot_ca) if plot_connectivity: c302_utils.generate_conn_matrix(nml_doc, save_fig_dir=save_image_full_dir) os.chdir(orig_dir) return cells, cells_to_stimulate, params, muscles
def go(self): """ Start the simulation once it's been intialized """ nml_doc = c302.generate(self.reference, self.params, cells=self.cells, cells_to_stimulate=self.cells_to_stimulate, muscles_to_include = self.muscles_to_include, duration=self.sim_time, dt=self.dt, verbose=False, target_directory = self.generate_dir) self.lems_file ="LEMS_%s.xml"%(self.reference) c302.print_("Running a simulation of %s ms with timestep %s ms: %s"%(self.sim_time, self.dt, self.lems_file)) self.already_run = True start = time.time() if self.simulator == 'jNeuroML': self.results = pynml.run_lems_with_jneuroml(self.lems_file, nogui=True, load_saved_data=True, plot=False, exec_in_dir = self.generate_dir, verbose=False) elif self.simulator == 'jNeuroML_NEURON': self.results = pynml.run_lems_with_jneuroml_neuron(self.lems_file, nogui=True, load_saved_data=True, plot=False, exec_in_dir = self.generate_dir, verbose=False) else: c302.print_('Unsupported simulator: %s'%self.simulator) exit() secs = time.time()-start c302.print_("Ran simulation in %s in %f seconds (%f mins)\n\n"%(self.simulator, secs, secs/60.0)) self.t = [t*1000 for t in self.results['t']] res_template_n = '%s/0/generic_neuron_iaf_cell/v' if self.params.level.startswith('C') or self.params.level.startswith('D'): res_template_n = '%s/0/GenericNeuronCell/v' res_template_m = '%s/0/GenericMuscleCell/v' self.volts = {} if self.cells is None: self.cells = [] for pop in nml_doc.networks[0].populations: self.cells.append(pop.id) for cell in self.cells: self.volts[res_template_n%cell] = [v*1000 for v in self.results[res_template_n%cell]] if self.muscles_to_include: for cell in self.muscles_to_include: self.volts[res_template_m%cell] = [v*1000 for v in self.results[res_template_m%cell]]