for i, x in enumerate(xs) ] return res fitres = leastsq(minimize, arg) return fitres # IF-curve filename = '/Users/jenskremkow/src/NeuroTools/examples/spike2/IF-Curve-example-data-provided-by-Florian-Rau-University-of-Freiburg-2008.smr' # load all channels in the file #all_channels = spike2.load(filename) # or only selected channels all_channels = spike2.load(filename, channels=[1, 2, 32]) # seperate the channels, just for better reading vm = all_channels[2] dc = all_channels[1] dc_onset_marker = all_channels[32] # cutout the dc and vm around a dc step, markers are in seconds, we need them in milliseonds dc_sequence = dc.slice_by_events(dc_onset_marker.times * 1000, t_min=500, t_max=1000) vm_sequence = vm.slice_by_events(dc_onset_marker.times * 1000, t_min=500, t_max=1000) xlim = [1000, 27000]
- loads content from a CED Son file which contains data from a IF-curve experiment - then the data is processed and a IF-Curve is plotted Performed at the NeuroTools demo session, INCF booth, SfN annual meeting 2008, Washington. DC. """ # IF-curve filename = 'IF-Curve-example-data-provided-by-Florian-Rau-University-of-Freiburg-2008.smr' # load all channels in the file #all_channels = spike2.load(filename) # or only selected channels all_channels = spike2.load(filename,channels=[1,2,32]) # seperate the channels, just for better reading vm = all_channels[2] dc = all_channels[1] dc_onset_marker = all_channels[32] pylab.close('all') # show original data # vm pylab.figure() pylab.plot(vm.time_axis(),vm.signal()) # currents pylab.figure() pylab.plot(dc.time_axis(),dc.signal()) # dc_onset_markers
import NeuroTools.spike2.spike2channels as spike2 import pylab, numpy from scipy.optimize import leastsq pylab.rcParams['text.usetex'] = True # helper function def fit_exp(xs,ys,arg): def minimize(arg): tau, offset, a = arg res = [a*numpy.exp(-x/tau)+offset - ys[i] for i,x in enumerate(xs)] return res fitres = leastsq(minimize,arg) return fitres filename = '/Users/jenskremkow/src/NeuroTools/examples/spike2/080814_cortex1_1cell001.smr' a = spike2.load(filename) current = a[1] vm = a[2] #marker = a[32] t_min = 200. t_max = 800. # since the markers dont really work marker = current.threshold_detection(threshold=-30.,sign='below') # current average current_average, time_axis = current.event_triggered_average(marker,average=True,t_min=t_min,t_max=t_max, with_time = True) I_base = current_average[0:t_min/current.dt].mean() I = current_average.min()-I_base # vm average vm_average= vm.event_triggered_average(marker,average=True,t_min=t_min,t_max=t_max) vm_base = vm_average[0:t_min/vm.dt].mean() # vm average for fit, I am just to lazy to slice the vm_avrage, so I recalculate it, starting with t_min 0.0 vm_average_for_fit, time_axis_for_fit = vm.event_triggered_average(marker,average=True,t_min=0.0,t_max=60., with_time=True) # fit