roiextract.pipeline.ExtractionPipeline#

class roiextract.pipeline.ExtractionPipeline(steps)#

This class represents a pipeline for extracting ROI time courses. The pipeline should consist of one or more linear transformation steps.

Parameters:
stepslist of PipelineStep

The list of pipeline steps (instances of PipelineStep or its subclasses) that define the transformations to be applied to the data. The steps are applied in the order they appear in the provided list.

Attributes:
preparedbool

Indicates whether the pipeline has been fit to the data.

Methods

fit(data, src, labels[, subject, subjects_dir])

Fit the pipeline to the provided data.

fit_transform(data, src, labels[, subject, ...])

Fit the pipeline to the provided data and then apply the transformation.

get_filters()

Get the list of spatial filters that represent the final data transformation for each considered ROI.

get_names()

Returns the names for rows of the resulting weight matrix.

get_weights()

The weight matrix corresponding to the linear transformation defined by the entire pipeline.

transform(data)

Transform the provided data using the fitted pipeline.

fit(data, src, labels, subject=None, subjects_dir=None, **kwargs)#

Fit the pipeline to the provided data. This method should be called before calling transform().

Parameters:
dataRaw

The raw data to fit the pipeline on.

srcSourceSpaces

The definition of the considered source space for inverse modeling.

labelslist of Label

The list of ROIs for which time courses should be extracted.

subjectstr, optional

The subject for which the pipeline is being fit. Currently, this argument is only used by centroid-based aggregation to compute the center of mass of the ROIs.

subjects_dirstr, optional

The directory containing the subjects’ MRI data. Currently, this argument is only used by centroid-based aggregation to compute the center of mass of the ROIs.

**kwargs

Additional keyword arguments that may be required for fitting the pipeline.

Returns:
selfExtractionPipeline

The fitted pipeline.

Notes

Each step in the pipeline receives only a subset of the provided arguments, depending on the specific requirements of the step. Custom steps can request specific arguments by overriding the PipelineStep._request_args() method.

fit_transform(data, src, labels, subject=None, subjects_dir=None, **kwargs)#

Fit the pipeline to the provided data and then apply the transformation. For the parameters and return values, see fit() and transform(), respectively.

get_filters()#

Get the list of spatial filters that represent the final data transformation for each considered ROI. The filters are generated using the values of get_weights() and get_names() methods of the pipeline, as well as get_params() method of each step.

Returns:
filterslist of SpatialFilter

The resulting list of spatial filters.

get_names()#

Returns the names for rows of the resulting weight matrix. The names are taken from the last step in the pipeline.

Returns:
row_nameslist of str | None

Names for rows of the weight matrix that corresponds to the entire pipeline, or None if the names are not available.

get_weights()#

The weight matrix corresponding to the linear transformation defined by the entire pipeline. It is obtained by multiplying the weight matrices of the individual steps in the pipeline.

Returns:
weightsarray

The weight matrix corresponding to the linear transformation defined by the entire pipeline.

transform(data)#

Transform the provided data using the fitted pipeline. For built-in steps, the transformation either executes the corresponding function in MNE-Python directly or matches it as closely as possible.

Parameters:
dataRaw

The raw data to transform.

Returns:
transformed_data

The transformed data obtained by applying the pipeline to the input data.