Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
        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)

        for tr in experiment.trainingset_traces:
            tr.setROI(
                [[2000., sampling_time * (len(voltage_trace) - 1) - 2000.]])
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)


############################################################################################################
# STEP 3B: FIT GIF WITH EXP BASIS FUNCTIONS TO DATA
############################################################################################################

# Create a new object GIF 
myGIF_exp = GIF(0.1)
Exemplo n.º 5
0
# 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()
myGIF.plotParameters()   


############################################################################################################
# STEP 3B: FIT gGIF MODEL TO DATA
"""
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()   


#################################################################################################
# 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
Exemplo n.º 7
0
# 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)

# 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