for i_amp, amp in enumerate(amp_spread): dis = distance[0] loop = 0 spiked = True # artificially set to True, to engage the loop, but anyway tested for distance = 0 print("debug01 loop {} rank {} amp {} distance {}".format( loop, RANK, amp, dis)) while spiked and loop < len(distance): # displacement, amp, loop, PROBLEM dis = distance[loop] print("debug001 loop {} rank {} amp {} distance {}".format( loop, RANK, amp, dis)) source_amps = np.multiply(polarity, amp) ExtPot = utils.ImposedPotentialField( source_amps, positions[0], positions[1] + displacement_source, positions[2] + dura_height, sigma) # LFPy.cell.neuron.init() cell = LFPy.TemplateCell( morphology=morphologyfile, templatefile=posixpth(os.path.join( NRN, 'template.hoc')), templatename=templatename, templateargs=1 if add_synapses else 0, tstop=tstop, dt=dt, extracellular=True, nsegs_method=None) # set view as in most other examples cell.set_rotation(x=np.pi / 2)
n_stim_amp = -stim_amp / 4 source_geometry = np.array( [-stim_amp / 4, -stim_amp / 4, -stim_amp / 4, -stim_amp / 4, stim_amp]) source_zs = np.ones(len(source_xs)) * cortical_surface_height # Stimulation Parameters: max_current = -100000. # mA current_resolution = 100 # amp_range = np.exp(np.linspace(1, np.log(max_current), current_resolution)) amp_range = np.linspace(1, max_current, current_resolution) amp = amp_range[0] for loop in range(current_resolution): # loop for various geometries source_amps = source_geometry * amp_range[loop] ExtPot = utils.ImposedPotentialField(source_amps, source_xs, source_ys, source_zs, sigma) plot_field_length = 500 v_field_ext_xz = np.zeros((100, 100)) xf = np.linspace(-plot_field_length, plot_field_length, 100) zf = np.linspace(-plot_field_length, cortical_surface_height, 100) for xidx, x in enumerate(xf): for zidx, z in enumerate(zf): v_field_ext_xz[xidx, zidx] = ExtPot.ext_field(x, 0, z) vmin = -1000 vmax = 1000 logthresh = 0 fig = plt.figure(figsize=[18, 7]) fig.suptitle('CURRENT = {0} mA'.format((amp_range[loop]) / 1000.)) fig.subplots_adjust(wspace=.6)
# source_geometry = np.array([-stim_amp, 0, stim_amp, 0, 0]) # dipole # source_geometry = np.array([-stim_amp / 4, -stim_amp / 4, -stim_amp / 4, -stim_amp / 4, stim_amp]) # source_geometry = np.array([stim_amp, stim_amp, stim_amp, stim_amp, -stim_amp]) # source_geometry = np.array([-1, -1, 1, 1, 1, 1, -1, -1]) name_shape_ecog = 'twosquare' polarity, n_elec, positions = utils.create_array_shape(name_shape_ecog, 25) amp = (200. * 10**3) / n_elec # uA voltage = 5000 cortical_surface_height = 20 source_amps = np.multiply(polarity, amp) ExtPot = utils.ImposedPotentialField(source_amps, positions[0], positions[1], positions[2] + cortical_surface_height, sigma) x_extent = 500 z_extent = 1000 y_extent = 500 space_resolution = 500 depth_check = -350 # v_field_ext_xz = np.zeros((space_resolution, space_resolution)) # v_field_ext_xy2 = np.zeros((space_resolution, space_resolution)) # xf = np.linspace(-x_extent, x_extent, space_resolution) # zf = np.linspace(-x_extent * 2, cortical_surface_height, space_resolution) # for xidx, x in enumerate(xf): # for zidx, z in enumerate(zf): # v_field_ext_xz[xidx, zidx] = ExtPot.ext_field(x, 0, z) # # v_field_ext_xz[xidx, zidx] = ExtPot.ext_field(0, x, z)
# v_clr = lambda z: plt.cm.jet(1.0 * (z - np.min(zs)) / (np.max(zs) - np.min(zs))) # v_clr = lambda z: plt.cm.jet(1.0 * (z - np.min(cell.zend)) / (np.max(np.abs(cell.zmid) - np.min(np.abs(cell.zmid))))) # WHILE/FOR click = 0 # is_spike = np.zeros(n_cells) is_spike = False for depth in distance: while amp < max_current and not is_spike: amp = amp_range[click] source_amps = np.multiply(polarity, amp) ExtPot = utils.ImposedPotentialField(source_amps, positions[0], positions[1], positions[2] + dura_height, sigma) # source_amps = source_geometry * amp # ExtPot = utils.ImposedPotentialField(source_amps, source_xs, source_ys, source_zs, sigma) # Find external potential field at all cell positions as a function of time # v_field_ext_stick = np.zeros((len(zs), n_tsteps)) # v_field_ext_stick = ext_field(zs).reshape(len(zs), 1) * pulse.reshape(1, n_tsteps) # v_field_ext_stick = v_cell_ext[v_idxs] # Insert external potential at cell if cell_id == 1: cell = LFPy.Cell(**cell_parameters) cell.set_rotation(x=np.pi / 2.) else: