def optimizetimescales(self, myExp): myExp.plotTrainingSet() myExp.plotTestSet() myGIF_rect = GIF(0.1) myGIF_rect.Tref = self.T_ref myGIF_rect.eta = Filter_Rect_LogSpaced() myGIF_rect.eta.setMetaParameters(length=500.0, binsize_lb=2.0, binsize_ub=100.0, slope=4.5) myGIF_rect.fitVoltageReset(myExp, myGIF_rect.Tref, do_plot=False) myGIF_rect.fitSubthresholdDynamics(myExp, DT_beforeSpike=self.DT_beforespike) myGIF_rect.eta.fitSumOfExponentials(3, [1.0, 0.5, 0.1], self.tau_gamma, ROI=None, dt=0.1) print "Optimal timescales: ", myGIF_rect.eta.tau0 self.tau_opt = [t for t in myGIF_rect.eta.tau0 if t < self.eta_tau_max] self.fitmodel(self, myExp)
def main(nombreGif): (folder1, folder2) = Directory.createDirectory() # read the gif images = GIF.readGif(nombreGif) # play with scanned images (motionPixels, pixeles) = detectMotion(images) # save files Directory.movedir(folder1) saveImage(motionPixels) Directory.creatGif() Directory.backDirectory() Directory.movedir(folder2) saveImage(pixeles) Directory.creatGif() Directory.backDirectory()
def fitmodel(self, myExp): myGIF = GIF(0.1) myGIF.Tref = self.T_ref myGIF.eta = Filter_Exps() myGIF.eta.setFilter_Timescales(self.tau_opt) myGIF.gamma = Filter_Exps() myGIF.gamma.setFilter_Timescales(self.tau_gamma) myGIF.fit(myExp, DT_beforeSpike=self.DT_beforespike) # Use the myGIF model to predict the spiking data of the test data set in myExp myPrediction = myExp.predictSpikes(myGIF, nb_rep=500) # Compute Md* with a temporal precision of +/- 4ms Md = myPrediction.computeMD_Kistler(4.0, 0.1) # Plot data vs model prediction myPrediction.plotRaster(delta=1000.0)
clamp_period=1.0) myAEC.p_expFitRange = [3.0, 150.0] myAEC.p_nbRep = 15 # Assign myAEC to experiment and compensate the voltage recordings experiment.setAEC(myAEC) experiment.performAEC() # Determine the refractory period ################################################################################################# # FIT STANDARD GIF ################################################################################################# # Create a new object GIF GIF_fit = GIF(sampling_time) # Define parameters GIF_fit.Tref = 6.0 GIF_fit.eta = Filter_Rect_LogSpaced() GIF_fit.eta.setMetaParameters(length=2000.0, binsize_lb=0.5, binsize_ub=500.0, slope=10.0) GIF_fit.gamma = Filter_Rect_LogSpaced() GIF_fit.gamma.setMetaParameters(length=2000.0, binsize_lb=2.0, binsize_ub=500.0, slope=5.0)
is_E_K_fixed = True GIF_K_fit.fit(experiment, DT_beforeSpike=5.0, is_E_K_fixed=is_E_K_fixed) # Plot the model parameters GIF_K_fit.plotParameters() # Save the model GIF_TYPE = 'GIF_K_' #GIF_K_fit.save(PATH_RESULTS + GIF_TYPE + CELL_NAME + SPECIFICATION + ADDITIONAL_SPECIFIER + '.pck') ################################################################################################# # FIT standard GIF ################################################################################################# # Create a new object GIF GIF_fit = GIF(sampling_time) # Define parameters GIF_fit.Tref = 6.0 GIF_fit.eta = Filter_Rect_LogSpaced() GIF_fit.eta.setMetaParameters(length=2000.0, binsize_lb=0.5, binsize_ub=500.0, slope=10.0) #5HT GIF_fit.eta.setMetaParameters(length=5000.0, binsize_lb=2.0, binsize_ub=1000.0, slope=4.5) GIF_fit.gamma = Filter_Rect_LogSpaced() GIF_fit.gamma.setMetaParameters(length=2000.0, binsize_lb=2.0, binsize_ub=500.0,
############################################################################################################ # STEP 2B: TO NOT PERFORM ACTIVE ELECTRODE COMPENSATION DO NOT RUN STEP 2A AND EXECUTE STEP 2B INSTEAD ############################################################################################################ """ myAEC_Dummy = AEC_Dummy() myExp.setAEC(myAEC_Dummy) myExp.performAEC() """ ############################################################################################################ # STEP 3A: FIT GIF WITH RECT BASIS FUNCTIONS TO DATA ############################################################################################################ # Create a new object GIF myGIF_rect = GIF(0.1) # Define parameters myGIF_rect.Tref = 4.0 # Define eta and gamma as a sum of rectangular functions (log-spaced) myGIF_rect.eta = Filter_Rect_LogSpaced() myGIF_rect.eta.setMetaParameters(length=5000.0, binsize_lb=2.0, binsize_ub=1000.0, slope=4.5) myGIF_rect.gamma = Filter_Rect_LogSpaced() myGIF_rect.gamma.setMetaParameters(length=5000.0, binsize_lb=5.0, binsize_ub=1000.0, slope=5.0) # Perform the fit myGIF_rect.fit(myExp, DT_beforeSpike=5.0)
# Define metaparametres myAEC.K_opt.setMetaParameters(length=150.0, binsize_lb=myExp.dt, binsize_ub=2.0, slope=30.0, clamp_period=1.0) myAEC.p_expFitRange = [3.0,150.0] myAEC.p_nbRep = 15 # Assign myAEC to myExp and compensate the voltage recordings myExp.setAEC(myAEC) myExp.performAEC() ############################################################################################################ # STEP 3A: FIT GIF MODEL TO DATA ############################################################################################################ # Create a new object GIF myGIF = GIF(0.1) # Define parameters myGIF.Tref = 4.0 myGIF.eta = Filter_Rect_LogSpaced() myGIF.eta.setMetaParameters(length=500.0, binsize_lb=2.0, binsize_ub=1000.0, slope=4.5) myGIF.gamma = Filter_Rect_LogSpaced() myGIF.gamma.setMetaParameters(length=500.0, binsize_lb=5.0, binsize_ub=1000.0, slope=5.0) # Perform the fit myGIF.fit(myExp, DT_beforeSpike=5.0) # Plot the model parameters myGIF.printParameters()
# STEP 2B: PLOT TRAINING SET TRACES INDIVIDUALLY ################################################################################################# # If you would like to see how the raw data looks like, you can uncomment this the following lines: """ for tr in experiment.trainingset_traces : tr.plot() """ ################################################################################################# # STEP 3A: FIT GIF MODEL (Pozzorini et al. 2015) ################################################################################################# # More details on how to fit a simple GIF model to data can be found here: Main_TestGIF.py GIF_fit = GIF(experiment.dt) GIF_fit.Tref = 4.0 GIF_fit.eta = Filter_Rect_LogSpaced() GIF_fit.eta.setMetaParameters(length=4000.0, binsize_lb=1.0, binsize_ub=1000.0, slope=7.0) GIF_fit.gamma = Filter_Rect_LogSpaced() GIF_fit.gamma.setMetaParameters(length=4000.0, binsize_lb=5.0, binsize_ub=1000.0, slope=7.0) GIF_fit.fit(experiment, DT_beforeSpike = 5.0) #GIF_fit.plotParameters() #################################################################################################
myExp.performAEC() # Plot AEC filters (Kopt and Ke) myAEC.plotKopt() myAEC.plotKe() # Plot training and test set myExp.plotTrainingSet() myExp.plotTestSet() ############################################################################################################ # STEP 3: FIT GIF MODEL TO DATA ############################################################################################################ # Create a new object GIF myGIF = GIF(0.1) # Define parameters myGIF.Tref = 4.0 myGIF.eta = Filter_Rect_LogSpaced() myGIF.eta.setMetaParameters(length=500.0, binsize_lb=2.0, binsize_ub=1000.0, slope=4.5) myGIF.gamma = Filter_Rect_LogSpaced() myGIF.gamma.setMetaParameters(length=500.0, binsize_lb=5.0, binsize_ub=1000.0, slope=5.0)
temp = GIF_Ca_fit.fit(experiment, DT_beforeSpike=5.0, is_E_Ca_fixed=is_E_Ca_fixed) # Plot the model parameters GIF_Ca_fit.plotParameters() # Save the model GIF_TYPE = 'GIF_Ca_' #GIF_Ca_fit.save(PATH_RESULTS + GIF_TYPE + CELL_NAME + SPECIFICATION + ADDITIONAL_SPECIFIER + '.pck') ################################################################################################# # FIT standard GIF ################################################################################################# # Create a new object GIF GIF_fit = GIF(sampling_time) # Define parameters GIF_fit.Tref = 6.0 GIF_fit.eta = Filter_Rect_LogSpaced() GIF_fit.eta.setMetaParameters(length=2000.0, binsize_lb=0.5, binsize_ub=500.0, slope=10.0) #5HT GIF_fit.eta.setMetaParameters(length=5000.0, binsize_lb=2.0, binsize_ub=1000.0, slope=4.5) GIF_fit.gamma = Filter_Rect_LogSpaced() GIF_fit.gamma.setMetaParameters(length=2000.0, binsize_lb=2.0, binsize_ub=500.0, slope=5.0) #5HT GIF_fit.gamma.setMetaParameters(length=5000.0, binsize_lb=5.0, binsize_ub=1000.0, slope=5.0) GIF_fit.fit(experiment, DT_beforeSpike=5.0) # Plot the model parameters
f.close() return h def identify(filename): h = read_headers(filename) if h == None: return None # This is the GIF header if h[:6] in ('GIF87a', 'GIF89a'): return ((ord(h[7])<<8 | ord(h[6])),(ord(h[9])<<8 | ord(h[8]))) return None if __name__ == "__main__": import sys import GIF if len(sys.argv) < 2: print 'Usage: %s files...\n' % sys.argv[0] sys.exit(0) for filename in sys.argv[1:]: info=GIF.identify(filename) if info != None: print "%s (size = %d,%d)" % (filename,info[0],info[1]) else: print "%s is not a GIF file" % filename