示例#1
0
    def __init__(self,
                 model,
                 data,
                 grids,
                 bounds,
                 Ns,
                 tr_length,
                 voxel_index=(1, 2, 3),
                 auto_fit=True,
                 verbose=0):

        PopulationFit.__init__(self, model, data, grids, bounds, Ns, tr_length,
                               voxel_index, auto_fit, verbose)

        if self.auto_fit:

            self.start = time.clock()
            try:
                self.ballpark
                self.estimate
                self.OLS
                self.finish = time.clock()

                if self.verbose:
                    print(self.msg)

            except:
                self.finish = time.clock()
                if self.verbose:
                    print(self.errmsg)
示例#2
0
    def __init__(self,
                 model,
                 data,
                 grids,
                 bounds,
                 voxel_index=(1, 2, 3),
                 Ns=None,
                 auto_fit=True,
                 verbose=0):

        PopulationFit.__init__(self, model, data, grids, bounds, voxel_index,
                               Ns, auto_fit, verbose)
示例#3
0
 def __init__(self, model, data, grids, bounds, Ns, tr_length,
              voxel_index=(1,2,3), auto_fit=True, verbose=0):
     
     
     PopulationFit.__init__(self, model, data, grids, bounds, Ns, tr_length, voxel_index, auto_fit, verbose)
     
     if self.auto_fit:
         
         self.start = time.clock()
         try:
             self.ballpark;
             self.estimate;
             self.OLS;
             self.finish = time.clock()
             
             if self.verbose:
                 print(self.msg)
                 
         except:
             self.finish = time.clock()
             if self.verbose:
                 print(self.errmsg)
示例#4
0
文件: dog.py 项目: arokem/popeye
 def __init__(self, model, data, grids, bounds,
              voxel_index=(1,2,3), Ns=None, auto_fit=True, verbose=0):
     
     r"""
     A class containing tools for fitting the Difference of Gaussians pRF model.
     
     The `DifferenceOfGaussiansFit` class houses all the fitting tool that 
     are associated with estimating a pRF model. The `GaussianFit` takes a 
     `DifferenceOfGaussiansModel` instance  `model` and a time-series `data`. 
     In addition, extent and sampling-rate of a  brute-force grid-search is set 
     with `grids` and `Ns`.  Use `bounds` to set limits on the search space for 
     each parameter.  
     
     Paramaters
     ----------
     
             
     model : `DifferenceOfGaussiansModel` class instance
         An object representing the CSS model. 
     
     data : ndarray
         An array containing the measured BOLD signal of a single voxel.
     
     grids : tuple
         A tuple indicating the search space for the brute-force grid-search.
         The tuple contains pairs of upper and lower bounds for exploring a
         given dimension.  For example `grids=((-10,10),(0,5),)` will
         search the first dimension from -10 to 10 and the second from 0 to 5.
         These values cannot be `None`. 
         
         For more information, see `scipy.optimize.brute`.
     
     bounds : tuple
         A tuple containing the upper and lower bounds for each parameter
         in `parameters`.  If a parameter is not bounded, simply use
         `None`.  For example, `fit_bounds=((0,None),(-10,10),)` would 
         bound the first parameter to be any positive number while the
         second parameter would be bounded between -10 and 10.
     
     Ns : int
         Number of samples per stimulus dimension to sample during the ballpark search.
         
         For more information, see `scipy.optimize.brute`.
     
     voxel_index : tuple
         A tuple containing the index of the voxel being modeled. The 
         fitting procedure does not require a voxel index, but 
         collating the results across many voxels will does require voxel
         indices. With voxel indices, the brain volume can be reconstructed 
         using the newly computed model estimates.
     
     auto_fit : bool
         A flag for automatically running the fitting procedures once the 
         `GaussianFit` object is instantiated.
     
     verbose : int
         0 = silent
         1 = print the final solution of an error-minimization
         2 = print each error-minimization step
     
     """
     
     PopulationFit.__init__(self, model, data, grids, bounds, 
                            voxel_index, Ns, auto_fit, verbose)
示例#5
0
 def __init__(self, model, data, grids, bounds,
              voxel_index=(1,2,3), Ns=None, auto_fit=True, verbose=0):
     
     r"""
     A class containing tools for fitting the 1D Gaussian pRF model.
     
     The `AuditoryFit` class houses all the fitting tool that are associated with 
     estimatinga pRF model.  The `PopulationFit` takes a `AuditoryModel` instance 
     `model` and a time-series `data`.  In addition, extent and sampling-rate of a 
     brute-force grid-search is set with `grids` and `Ns`.  Use `bounds` to set 
     limits on the search space for each parameter.  
     
     Paramaters
     ----------
     
             
     model : `AuditoryModel` class instance
         An object representing the 1D Gaussian model.
     
     data : ndarray
         An array containing the measured BOLD signal of a single voxel.
     
     grids : tuple
         A tuple indicating the search space for the brute-force grid-search.
         The tuple contains pairs of upper and lower bounds for exploring a
         given dimension.  For example `grids=((-10,10),(0,5),)` will
         search the first dimension from -10 to 10 and the second from 0 to 5.
         These values cannot be `None`. 
         
         For more information, see `scipy.optimize.brute`.
     
     bounds : tuple
         A tuple containing the upper and lower bounds for each parameter
         in `parameters`.  If a parameter is not bounded, simply use
         `None`.  For example, `fit_bounds=((0,None),(-10,10),)` would 
         bound the first parameter to be any positive number while the
         second parameter would be bounded between -10 and 10.
     
     Ns : int
         Number of samples per stimulus dimension to sample during the ballpark search.
         
         For more information, see `scipy.optimize.brute`.
     
     voxel_index : tuple
         A tuple containing the index of the voxel being modeled. The 
         fitting procedure does not require a voxel index, but 
         collating the results across many voxels will does require voxel
         indices. With voxel indices, the brain volume can be reconstructed 
         using the newly computed model estimates.
     
     auto_fit : bool
         A flag for automatically running the fitting procedures once the 
         `GaussianFit` object is instantiated.
     
     verbose : int
         0 = silent
         1 = print the final solution of an error-minimization
         2 = print each error-minimization step
     
     """
     
     # invoke the base class
     PopulationFit.__init__(self, model, data, grids, bounds, 
                            voxel_index, Ns, auto_fit, verbose)
示例#6
0
    def __init__(self, model, data, grids, bounds, voxel_index=(1, 2, 3), Ns=None, auto_fit=True, verbose=0):

        PopulationFit.__init__(self, model, data, grids, bounds, voxel_index, Ns, auto_fit, verbose)
示例#7
0
文件: og.py 项目: mekman/popeye
    def __init__(self, model, data, search_bounds, fit_bounds, tr_length,
                 voxel_index=(1,2,3), auto_fit=True, verbose=True, uncorrected_rval=0.0):
        
        
        """
        A Gaussian population receptive field model [1]_.

        Paramaters
        ----------
        
        data : ndarray
            An array containing the measured BOLD signal.
        
        model : `GaussianModel` class instance containing the representation
            of the visual stimulus.
        
        search_bounds : tuple
            A tuple indicating the search space for the brute-force grid-search.
            The tuple contains pairs of upper and lower bounds for exploring a
            given dimension.  For example `fit_bounds=((-10,10),(0,5),)` will
            search the first dimension from -10 to 10 and the second from 0 to 5.
            These values cannot be None. 
            
            For more information, see `scipy.optimize.brute`.
        
        fit_bounds : tuple
            A tuple containing the upper and lower bounds for each parameter
            in `parameters`.  If a parameter is not bounded, simply use
            `None`.  For example, `fit_bounds=((0,None),(-10,10),)` would 
            bound the first parameter to be any positive number while the
            second parameter would be bounded between -10 and 10.
        
        tr_length : float
            The length of the repetition time in seconds.
        
        voxel_index : tuple
            A tuple containing the index of the voxel being modeled. The 
            fitting procedure does not require a voxel index, but 
            collating the results across many voxels will does require voxel
            indices. With voxel indices, the brain volume can be reconstructed 
            using the newly computed model estimates.
        
        auto-fit : bool
            A flag for automatically running the fitting procedures once the 
            `GaussianFit` object is instantiated.
        
        verbose : bool
            A flag for printing some summary information about the model estiamte
            after the fitting procedures have completed.
        
        References
        ----------
        
        .. [1] Dumoulin SO, Wandell BA. (2008) Population receptive field 
        estimates in human visual cortex. NeuroImage 39:647-660

        """
        
        PopulationFit.__init__(self, model, data)
        
        self.search_bounds = search_bounds
        self.fit_bounds = fit_bounds
        self.tr_length = tr_length
        self.voxel_index = voxel_index
        self.auto_fit = auto_fit
        self.verbose = verbose
        self.uncorrected_rval = uncorrected_rval
        
        if self.auto_fit:
            
            
            tic = time.clock()
            self.ballpark_estimate;
            
            if self.coarse_fit_stats[2] > self.uncorrected_rval:
            
                self.estimate;
                self.fit_stats;
                self.rss;
                toc = time.clock()
                
                msg = ("VOXEL=(%.03d,%.03d,%.03d)   TIME=%.03d   RVAL=%.02f" 
                        %(self.voxel_index[0],
                          self.voxel_index[1],
                          self.voxel_index[2],
                          toc-tic,
                          self.fit_stats[2]))
            
                
            else:
                toc = time.clock()
                
                msg = ("VOXEL=(%.03d,%.03d,%.03d)   TIME=%.03d   COARSE_RVAL=%.02f" 
                        %(self.voxel_index[0],
                          self.voxel_index[1],
                          self.voxel_index[2],
                          toc-tic,
                          self.coarse_fit_stats[2]))
            
            if self.verbose:
                print(msg)              
示例#8
0
文件: dog.py 项目: mekman/popeye
 def __init__(self, og_fit, fit_bounds, auto_fit=True, verbose=True, uncorrected_rval=0.0):
     
     
     """
     A Gaussian population receptive field model [1]_.
     
     Paramaters
     ----------
     
     og_fit : `GaussianFit` class instance
         A `GaussianFit` object.  This object does not have to be fitted already,
         as the fit will be performed inside the `DifferenceOfGaussiansFit` in any 
         case.  The `GaussianFit` is used as a seed for the `DifferenceOfGaussiansFit`
         search.
     
     fit_bounds : tuple
         A tuple containing the upper and lower bounds for each parameter
         in `parameters`.  If a parameter is not bounded, simply use
         `None`.  For example, `fit_bounds=((0,None),(-10,10),)` would 
         bound the first parameter to be any positive number while the
         second parameter would be bounded between -10 and 10.
         
     auto-fit : bool
         A flag for automatically running the fitting procedures once the 
         `GaussianFit` object is instantiated.
     
     verbose : bool
         A flag for printing some summary information about the model estiamte
         after the fitting procedures have completed.
     
     References
     ----------
     
     .. [1] Dumoulin SO, Wandell BA. (2008) Population receptive field 
     estimates in human visual cortex. NeuroImage 39:647-660
     
     """
     
     PopulationFit.__init__(self, og_fit.model, og_fit.data)
     
     self.og_fit = og_fit
     self.fit_bounds = fit_bounds
     self.tr_length = self.og_fit.tr_length
     self.voxel_index = self.og_fit.voxel_index
     self.auto_fit = auto_fit
     self.verbose = verbose
     self.uncorrected_rval = uncorrected_rval
     
     if self.auto_fit:
         
         tic = time.clock()
         self.og_fit.estimate
         
         if self.og_fit.fit_stats[2] > self.uncorrected_rval:
          
             self.estimate;
             self.fit_stats;
             toc = time.clock()
         
             msg = ("VOXEL=(%.03d,%.03d,%.03d)   TIME=%.03d   OG-RVAL=%.02f    DoG-RVAL=%.02f"
                     %(self.voxel_index[0],
                       self.voxel_index[1],
                       self.voxel_index[2],
                       toc-tic,
                       self.og_fit.fit_stats[2],
                       self.fit_stats[2]))
         
         else:
             toc = time.clock()
             msg = ("VOXEL=(%.03d,%.03d,%.03d)   TIME=%.03d   OG-RVAL=%.02f"
                     %(self.voxel_index[0],
                       self.voxel_index[1],
                       self.voxel_index[2],
                       toc-tic,
                       self.og_fit.fit_stats[2]))
         
         if self.verbose:
             print(msg)