Mapper for regression-based removal of polynomial trends.
Noteworthy features are the possibility for chunk-wise detrending, optional regressors, and the ability to use positional information about the samples from the dataset.
Any sample attribute from the to be mapped dataset can be used to define chunks that shall be detrended separately. The number of chunks is determined from the number of unique values of the attribute and all samples with the same value are considered to be in the same chunk.
It is possible to provide a list of additional sample attribute names that will be used as confound regressors during detrending. This, for example, allows to use fMRI motion correction parameters to be considered.
Finally, it is possible to use positional information about the dataset samples for the detrending. This is useful, for example, if the samples in the dataset are not equally spaced out over the acquisition time-window. In that case an actually linear trend in the data would be distorted and not properly removed. By setting the inspace argument to the name of a samples attribute that carries this information, the mapper will take this into account and shift the polynomials accordingly. If inspace is given, but the dataset doesn’t contain such an attribute evenly spaced coordinates are generated and this information is stored in the mapped dataset.
Notes
The mapper only support mapping of datasets, not plain data. Moreover, reverse mapping, or subsequent forward-mapping of partial datasets are currently not implemented.
Examples
>>> from mvpa2.datasets import dataset_wizard
>>> from mvpa2.mappers.detrend import PolyDetrendMapper
>>> samples = np.array([[1.0, 2, 3, 3, 2, 1],
... [-2.0, -4, -6, -6, -4, -2]]).T
>>> chunks = [0, 0, 0, 1, 1, 1]
>>> ds = dataset_wizard(samples, chunks=chunks)
>>> dm = PolyDetrendMapper(chunks_attr='chunks', polyord=1)
>>> # the mapper will be auto-trained upon first use
>>> mds = dm.forward(ds)
>>> # total removal all all (chunk-wise) linear trends
>>> np.sum(np.abs(mds)) < 0.00001
True
Available conditional attributes:
(Conditional attributes enabled by default suffixed with +)
Methods
forward(data) | Map data from input to output space. |
forward1(data) | Wrapper method to map single samples. |
generate(ds) | Yield processing results. |
get_postproc() | Returns the post-processing node or None. |
get_space() | Query the processing space name of this node. |
reset() | |
reverse(data) | Reverse-map data from output back into input space. |
reverse1(data) | Wrapper method to map single samples. |
set_postproc(node) | Assigns a post-processing node |
set_space(name) | Set the processing space name of this node. |
train(ds) | The default implementation calls _pretrain(), _train(), and finally _posttrain(). |
untrain() | Reverts changes in the state of this node caused by previous training |
Parameters : | space : str or None
polyord : int, optional
chunks_attr : None or str, optional
opt_regs : None or list(str), optional
enable_ca : None or list of str
disable_ca : None or list of str
auto_train : bool
force_train : bool
pass_attr : str, list of str|tuple, optional
postproc : Node instance, optional
descr : str
|
---|
Methods
forward(data) | Map data from input to output space. |
forward1(data) | Wrapper method to map single samples. |
generate(ds) | Yield processing results. |
get_postproc() | Returns the post-processing node or None. |
get_space() | Query the processing space name of this node. |
reset() | |
reverse(data) | Reverse-map data from output back into input space. |
reverse1(data) | Wrapper method to map single samples. |
set_postproc(node) | Assigns a post-processing node |
set_space(name) | Set the processing space name of this node. |
train(ds) | The default implementation calls _pretrain(), _train(), and finally _posttrain(). |
untrain() | Reverts changes in the state of this node caused by previous training |