pySPFM provides three main estimators that follow the scikit-learn API:
SparseDeconvolution: The core estimator for sparse hemodynamic deconvolution.
Supports both univariate (voxel-wise) and multivariate (joint spatial) solving modes.
LowRankPlusSparse: Decomposes fMRI data into low-rank (structured noise/drift)
and sparse (neural activity) components using robust PCA combined with sparse deconvolution.
StabilitySelection: Provides robust estimation through stability selection,
solving the problem across multiple subsampled datasets and computing area-under-curve (AUC)
stability scores.
Sparse hemodynamic deconvolution using LARS or FISTA.
This estimator implements Sparse Paradigm Free Mapping (SPFM) for
deconvolution of fMRI data. It estimates activity-inducing signals
(spike model) or innovation signals (block model) from BOLD timeseries.
The estimator supports two solving modes:
Univariate mode (group=0.0, default):
Each voxel is solved independently using pure L1 (LASSO) regularization.
This is efficient and suitable when spatial structure is not important.
Multivariate mode (group>0.0):
All voxels are solved jointly using L2,1 mixed-norm regularization,
which encourages spatial grouping of activity across voxels at the
same timepoint. This leverages spatial structure in 4D fMRI data.
Requires a FISTA-compatible criterion (‘mad’, ‘factor’, etc.).
Parameters:
tr (float) – Repetition time (TR) of the fMRI acquisition in seconds.
te (list of float, default=None) – Echo times in milliseconds for multi-echo data. If None or [0],
assumes single-echo data.
hrf_model (str, default=’spm’) – HRF model to use. Options are ‘spm’, ‘glover’, or a path to a custom
HRF file (.1D or .txt).
block_model (bool, default=False) – If True, estimate innovation signals (block model).
If False, estimate activity-inducing signals (spike model).
criterion (str, default=’bic’) – Criterion for lambda selection:
‘bic’, ‘aic’: Information criteria (LARS solver, univariate only).
X (array-like of shape (n_timepoints, n_voxels) or (n_timepoints * n_echoes, n_voxels)) – The fMRI timeseries data. For multi-echo data, timepoints from
different echoes should be concatenated along the first axis.
y (None) – Not used, present for API consistency.
Returns:
self (object) – Fitted estimator.
Raises:
ValueError – If group>0 is used with a LARS criterion (‘bic’, ‘aic’),
since multivariate mode requires FISTA.
Return the explained variance ratio of the deconvolution.
The score is computed as \(R^2 = 1 - SS_{res} / SS_{tot}\),
where \(SS_{res}\) is the residual sum of squares and
\(SS_{tot}\) is the total sum of squares.
Parameters:
X (array-like of shape (n_timepoints, n_voxels)) – Test samples (fMRI timeseries).
y (None) – Not used, present for API consistency.
Returns:
score (float) – Explained variance ratio averaged across voxels.
The method works on simple estimators as well as on nested objects.
The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
This estimator implements the Sparse and Low-Rank Paradigm Free Mapping
(SPLORA) algorithm, which separates fMRI data into low-rank (global/
structured) and sparse (transient neuronal) components.
Parameters:
tr (float) – Repetition time (TR) of the fMRI acquisition in seconds.
te (list of float, default=None) – Echo times in seconds for multi-echo data. If None or [0], assumes
single-echo data.
hrf_model (str, default=’spm’) – HRF model to use. Options are ‘spm’, ‘glover’, or a path to a custom
HRF file (.1D or .txt).
block_model (bool, default=False) – If True, estimate innovation signals (block model).
If False, estimate activity-inducing signals (spike model).
Return the explained variance ratio of the deconvolution.
The score is computed as \(R^2 = 1 - SS_{res} / SS_{tot}\),
where \(SS_{res}\) is the residual sum of squares and
\(SS_{tot}\) is the total sum of squares.
Parameters:
X (array-like of shape (n_timepoints, n_voxels)) – Test samples (fMRI timeseries).
y (None) – Not used, present for API consistency.
Returns:
score (float) – Explained variance ratio averaged across voxels.
The method works on simple estimators as well as on nested objects.
The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
Stability selection for robust sparse deconvolution.
This estimator uses stability selection to identify robust features
in the sparse deconvolution problem. It runs multiple deconvolutions
on subsampled data and returns the selection frequency (AUC) for each
timepoint.
Parameters:
tr (float) – Repetition time (TR) of the fMRI acquisition in seconds.
te (list of float, default=None) – Echo times in seconds for multi-echo data.
hrf_model (str, default=’spm’) – HRF model to use.
Return the explained variance ratio of the deconvolution.
The score is computed as \(R^2 = 1 - SS_{res} / SS_{tot}\),
where \(SS_{res}\) is the residual sum of squares and
\(SS_{tot}\) is the total sum of squares.
Parameters:
X (array-like of shape (n_timepoints, n_voxels)) – Test samples (fMRI timeseries).
y (None) – Not used, present for API consistency.
Returns:
score (float) – Explained variance ratio averaged across voxels.
The method works on simple estimators as well as on nested objects.
The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.