Package mvpa :: Package datasets :: Module miscfx_sp
[hide private]
[frames] | no frames]

Module miscfx_sp

source code

Misc function performing operations on datasets which are based on scipy
Functions [hide private]
 
legendre_(n, x) source code
 
detrend(dataset, perchunk=False, model='linear', polyord=None, opt_reg=None)
Given a dataset, detrend the data inplace either entirely or per each chunk
source code
 
__detrend_regress(dataset, perchunk=True, polyord=None, opt_reg=None)
Given a dataset, perform a detrend inplace, regressing out polynomial terms as well as optional regressors, such as motion parameters.
source code
Variables [hide private]
  np = N

Imports: externals, N, isSequenceType, Dataset, datasetmethod, getBreakPoints, signal, lstsq, legendre


Function Details [hide private]

detrend(dataset, perchunk=False, model='linear', polyord=None, opt_reg=None)

source code 
Given a dataset, detrend the data inplace either entirely or per each chunk
Parameters:
  • dataset (Dataset) - dataset to operate on
  • perchunk (bool) - either to operate on whole dataset at once or on each chunk separately
  • model - Type of detrending model to run. If 'linear' or 'constant', scipy.signal.detrend is used to perform a linear or demeaning detrend. Polynomial detrending is activated when 'regress' is used or when polyord or opt_reg are specified.
  • polyord (int or list) - Order of the Legendre polynomial to remove from the data. This will remove every polynomial up to and including the provided value. For example, 3 will remove 0th, 1st, 2nd, and 3rd order polynomials from the data. N.B.: The 0th polynomial is the baseline shift, the 1st is the linear trend. If you specify a single int and perchunk is True, then this value is used for each chunk. You can also specify a different polyord value for each chunk by providing a list or ndarray of polyord values the length of the number of chunks.
  • opt_reg (ndarray) - Optional ndarray of additional information to regress out from the dataset. One example would be to regress out motion parameters. As with the data, time is on the first axis.
Decorators:
  • @datasetmethod

__detrend_regress(dataset, perchunk=True, polyord=None, opt_reg=None)

source code 
Given a dataset, perform a detrend inplace, regressing out polynomial terms as well as optional regressors, such as motion parameters.
Parameters:
  • dataset (Dataset) - Dataset to operate on
  • perchunk (bool) - Either to operate on whole dataset at once or on each chunk separately. If perchunk is True, all the samples within a chunk should be contiguous and the chunks should be sorted in order from low to high.
  • polyord (int) - Order of the Legendre polynomial to remove from the data. This will remove every polynomial up to and including the provided value. For example, 3 will remove 0th, 1st, 2nd, and 3rd order polynomials from the data. N.B.: The 0th polynomial is the baseline shift, the 1st is the linear trend. If you specify a single int and perchunk is True, then this value is used for each chunk. You can also specify a different polyord value for each chunk by providing a list or ndarray of polyord values the length of the number of chunks.
  • opt_reg (ndarray) - Optional ndarray of additional information to regress out from the dataset. One example would be to regress out motion parameters. As with the data, time is on the first axis.