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)
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) for tr in experiment.trainingset_traces: tr.setROI( [[2000., sampling_time * (len(voltage_trace) - 1) - 2000.]]) (var_explained_dV, var_explained_V_GIF_train) = GIF_fit.fit(experiment, DT_beforeSpike=5.0) GIF_fit.save(path_results + cell_name + '_GIF_ModelParams' + '.pck') ################################################################################################### # EVALUATE MODEL PERFORMANCES ON THE TEST SET DATA ################################################################################################### # predict spike times in test set prediction = experiment.predictSpikes(GIF_fit, nb_rep=500) # Compute epsilon_V epsilon_V = 0. local_counter = 0. for tr in experiment.testset_traces: SSE = 0. VAR = 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 GIF_fit.plotParameters() ''' ################################################################################################# # STEP 3B: FIT iGIF_NP (Mensi et al. 2016 with current-based spike-triggered adaptation) ################################################################################################# # Note that in the iGIF_NP model introduced in Mensi et al. 2016, the adaptation current is # conductance-based (i.e., eta is a spike-triggered conductance). # Define metaparameters used during the fit theta_inf_nbbins = 10 # Number of rect functions used to define the nonlinear coupling between # membrane potential and firing threshold (note that the positioning of # the rect function
# 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) ############################################################################################################ # STEP 3B: FIT GIF WITH EXP BASIS FUNCTIONS TO DATA ############################################################################################################ # Create a new object GIF myGIF_exp = GIF(0.1) # Define parameters myGIF_exp.Tref = 4.0 # Define the timescales in eta (ie, the spike-triggered current). # In this particular example 6 different exponentials are used with timescales ranging from 1 to 500 ms
############################################################################################################ # 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() myGIF.plotParameters() ############################################################################################################ # STEP 3B: FIT gGIF MODEL TO DATA ############################################################################################################ mygGIF = gGIF(0.1) # Set absolute refractory period mygGIF.Tref = myGIF.Tref
# 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() ################################################################################################# # STEP 3B: FIT iGIF_NP (Mensi et al. 2016 with current-based spike-triggered adaptation) ################################################################################################# # Note that in the iGIF_NP model introduced in Mensi et al. 2016, the adaptation current is # conductance-based (i.e., eta is a spike-triggered conductance). # Define metaparameters used during the fit theta_inf_nbbins = 8 # Number of rect functions used to define the nonlinear coupling between # membrane potential and firing threshold (note that the positioning of the rect function
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) # Define the ROI of the training set to be used for the fit (in this example we will use only the first 100 s) myExp.trainingset_traces[0].setROI([[0, 100000.0]]) # To visualize the training set and the ROI call again myExp.plotTrainingSet() # Perform the fit myGIF.fit(myExp, DT_beforeSpike=5.0) # Plot the model parameters myGIF.printParameters() myGIF.plotParameters() ## Save the model #myGIF.save('./myGIF.pck') ############################################################################################################ # STEP 3A (OPTIONAL): PLAY A BIT WITH THE FITTED MODEL ############################################################################################################ ## Reload the model #myGIF = GIF.load('./myGIF.pck') #