Пример #1
0
    def __init__(self, dsmatrix, dset_metric, output_metric='spearman'):
        DatasetMeasure.__init__(self)

        self.dsmatrix = dsmatrix
        self.dset_metric = dset_metric
        self.output_metric = output_metric
        self.dset_dsm = []
Пример #2
0
    def __init__(self, queryengine, roi_ids=None, nproc=None, **kwargs):
        """
        Parameters
        ----------
        queryengine : QueryEngine
          Engine to use to discover the "neighborhood" of each feature.
          See :class:`~mvpa.misc.neighborhood.QueryEngine`.
        roi_ids : None or list of int
          List of feature ids (not coordinates) the shall serve as sphere
          centers. By default all features will be used.
        nproc : None or int
          How many processes to use for computation.  Requires `pprocess`
          external module.  If None -- all available cores will be used.
        **kwargs
          In addition this class supports all keyword arguments of its
          base-class :class:`~mvpa.measures.base.DatasetMeasure`.
      """
        DatasetMeasure.__init__(self, **(kwargs))

        if nproc > 1 and not externals.exists('pprocess'):
            raise RuntimeError("The 'pprocess' module is required for "
                               "multiprocess searchlights. Please either "
                               "install python-pprocess, or reduce `nproc` "
                               "to 1 (got nproc=%i)" % nproc)

        self._qe = queryengine
        if roi_ids is not None and not len(roi_ids):
            raise ValueError, \
                  "Cannot run searchlight on an empty list of roi_ids"
        self.__roi_ids = roi_ids
        self._nproc = nproc
Пример #3
0
    def __init__(self, datameasure, radius=1.0, center_ids=None, **kwargs):
        """
        :Parameters:
          datameasure: callable
            Any object that takes a :class:`~mvpa.datasets.base.Dataset`
            and returns some measure when called.
          radius: float
            All features within the radius around the center will be part
            of a sphere. Provided dataset should have a metric assigned
            (for NiftiDataset, voxel size is used to provide such a metric,
            hence radius should be specified in mm).
          center_ids: list(int)
            List of feature ids (not coordinates) the shall serve as sphere
            centers. By default all features will be used.
          **kwargs
            In additions this class supports all keyword arguments of its
            base-class :class:`~mvpa.measures.base.DatasetMeasure`.

        .. note::

          If `Searchlight` is used as `SensitivityAnalyzer` one has to make
          sure that the specified scalar `DatasetMeasure` returns large
          (absolute) values for high sensitivities and small (absolute) values
          for low sensitivities. Especially when using error functions usually
          low values imply high performance and therefore high sensitivity.
          This would in turn result in sensitivity maps that have low
          (absolute) values indicating high sensitivites and this conflicts
          with the intended behavior of a `SensitivityAnalyzer`.
        """
        DatasetMeasure.__init__(self, **(kwargs))

        self.__datameasure = datameasure
        self.__radius = radius
        self.__center_ids = center_ids
Пример #4
0
    def __init__(self,
                 transerror,
                 splitter=None,
                 combiner='mean',
                 expose_testdataset=False,
                 harvest_attribs=None,
                 copy_attribs='copy',
                 **kwargs):
        """
        :Parameters:
          transerror: TransferError instance
            Provides the classifier used for cross-validation.
          splitter: Splitter | None
            Used to split the dataset for cross-validation folds. By
            convention the first dataset in the tuple returned by the
            splitter is used to train the provided classifier. If the
            first element is 'None' no training is performed. The second
            dataset is used to generate predictions with the (trained)
            classifier. If `None` (default) an instance of
            :class:`~mvpa.datasets.splitters.NoneSplitter` is used.
          combiner: Functor | 'mean'
            Used to aggregate the error values of all cross-validation
            folds. If 'mean' (default) the grand mean of the transfer
            errors is computed.
          expose_testdataset: bool
           In the proper pipeline, classifier must not know anything
           about testing data, but in some cases it might lead only
           to marginal harm, thus migth wanted to be enabled (provide
           testdataset for RFE to determine stopping point).
          harvest_attribs: list of basestr
            What attributes of call to store and return within
            harvested state variable
          copy_attribs: None | basestr
            Force copying values of attributes on harvesting
          **kwargs:
            All additional arguments are passed to the
            :class:`~mvpa.measures.base.DatasetMeasure` base class.
        """
        DatasetMeasure.__init__(self, **kwargs)
        Harvestable.__init__(self, harvest_attribs, copy_attribs)

        if splitter is None:
            self.__splitter = NoneSplitter()
        else:
            self.__splitter = splitter

        if combiner == 'mean':
            self.__combiner = GrandMean
        else:
            self.__combiner = combiner

        self.__transerror = transerror
        self.__expose_testdataset = expose_testdataset
Пример #5
0
    def __init__(self,
                 transerror,
                 splitter=None,
                 expose_testdataset=False,
                 harvest_attribs=None,
                 copy_attribs='copy',
                 samples_idattr='origids',
                 **kwargs):
        """
        Parameters
        ----------
        transerror : TransferError instance
          Provides the classifier used for cross-validation.
        splitter : Splitter or None
          Used to split the dataset for cross-validation folds. By
          convention the first dataset in the tuple returned by the
          splitter is used to train the provided classifier. If the
          first element is 'None' no training is performed. The second
          dataset is used to generate predictions with the (trained)
          classifier. If `None` (default) an instance of
          :class:`~mvpa.datasets.splitters.NoneSplitter` is used.
        expose_testdataset : bool, optional
          In the proper pipeline, classifier must not know anything
          about testing data, but in some cases it might lead only
          to marginal harm, thus migth wanted to be enabled (provide
          testdataset for RFE to determine stopping point).
        harvest_attribs : list of str
          What attributes of call to store and return within
          harvested conditional attribute
        copy_attribs : None or str, optional
          Force copying values of attributes on harvesting
        samples_idattr : str, optional
          What samples attribute to use to identify and store samples_errors
          conditional attribute
        **kwargs
          All additional arguments are passed to the
          :class:`~mvpa.measures.base.DatasetMeasure` base class.
        """
        DatasetMeasure.__init__(self, **kwargs)
        Harvestable.__init__(self, harvest_attribs, copy_attribs)

        if splitter is None:
            self.__splitter = NoneSplitter()
        else:
            self.__splitter = splitter

        self.__transerror = transerror
        self.__expose_testdataset = expose_testdataset
        self.__samples_idattr = samples_idattr
Пример #6
0
    def __init__(self,
                 transerror,
                 splitter=None,
                 expose_testdataset=False,
                 harvest_attribs=None,
                 copy_attribs='copy',
                 samples_idattr='origids',
                 **kwargs):
        """
        Parameters
        ----------
        transerror : TransferError instance
          Provides the classifier used for cross-validation.
        splitter : Splitter or None
          Used to split the dataset for cross-validation folds. By
          convention the first dataset in the tuple returned by the
          splitter is used to train the provided classifier. If the
          first element is 'None' no training is performed. The second
          dataset is used to generate predictions with the (trained)
          classifier. If `None` (default) an instance of
          :class:`~mvpa.datasets.splitters.NoneSplitter` is used.
        expose_testdataset : bool, optional
          In the proper pipeline, classifier must not know anything
          about testing data, but in some cases it might lead only
          to marginal harm, thus migth wanted to be enabled (provide
          testdataset for RFE to determine stopping point).
        harvest_attribs : list of str
          What attributes of call to store and return within
          harvested conditional attribute
        copy_attribs : None or str, optional
          Force copying values of attributes on harvesting
        samples_idattr : str, optional
          What samples attribute to use to identify and store samples_errors
          conditional attribute
        **kwargs
          All additional arguments are passed to the
          :class:`~mvpa.measures.base.DatasetMeasure` base class.
        """
        DatasetMeasure.__init__(self, **kwargs)
        Harvestable.__init__(self, harvest_attribs, copy_attribs)

        if splitter is None:
            self.__splitter = NoneSplitter()
        else:
            self.__splitter = splitter

        self.__transerror = transerror
        self.__expose_testdataset = expose_testdataset
        self.__samples_idattr = samples_idattr