roiextract.pipeline.SVDAggregation#

class roiextract.pipeline.SVDAggregation(n_components=1)#

SVD-based aggregation of reconstructed source time courses within the ROI. The time courses that correspond to the first n_components singular vectors are selected as the representative time courses of the ROI.

Parameters:
n_componentsint, default=1

The number of SVD components to retain for each ROI.

Methods

copy()

Create a copy of the pipeline step.

fit(data, src, labels)

Fit the SVD aggregation step to the provided data, source space, and labels.

fit_transform(data, src, labels)

Fit and apply the SVD aggregation to the provided data, source space, and labels.

get_names(names)

Get the names of the rows of the weight matrix, which correspond to the extracted time courses for each label and SVD component.

get_params()

Get the parameters of the SVD aggregation step as a dictionary.

get_weights()

Get the weight matrix corresponding to the resulting SVD aggregation transformation.

transform(data)

Apply the fitted SVD aggregation to the provided data.

copy()#

Create a copy of the pipeline step.

Returns:
copyPipelineStep

A copy of the pipeline step.

fit(data, src, labels)#

Fit the SVD aggregation step to the provided data, source space, and labels.

Parameters:
dataSourceEstimate

The source estimate containing the reconstructed source time courses.

srcSourceSpaces

The definition of the considered source space for inverse modeling.

labelsLabel | list of Label

The label or list of labels defining the ROIs for which time courses should be extracted.

Returns:
selfSVDAggregation

The fitted aggregation step.

fit_transform(data, src, labels)#

Fit and apply the SVD aggregation to the provided data, source space, and labels.

Parameters:
dataSourceEstimate

The source estimate containing the reconstructed source time courses.

srcSourceSpaces

The definition of the considered source space for inverse modeling.

labelsLabel | list of Label

The label or list of labels defining the ROIs for which time courses should be extracted.

Returns:
label_tcarray, shape (n_labels * n_components, n_times)

The extracted time courses for each label and SVD component.

get_names(names)#

Get the names of the rows of the weight matrix, which correspond to the extracted time courses for each label and SVD component.

Parameters:
nameslist of str | None

This parameter is not used in the implementation, label names and component indices are always used to define row names.

Returns:
nameslist of str

The names of the rows of the weight matrix. If more than one SVD component per ROI is extracted, the names are formatted as "<ROI_name> (SVD<component_index>)".

get_params()#

Get the parameters of the SVD aggregation step as a dictionary.

Returns:
paramsdict

The parameters of the aggregation step, including the number of SVD components to retain for each ROI.

get_weights()#

Get the weight matrix corresponding to the resulting SVD aggregation transformation.

Returns:
weightsarray

The weight matrix that contains the SVD-based weights for each ROI and component.

transform(data)#

Apply the fitted SVD aggregation to the provided data. Unlike other built-in aggregation methods, this method does not use MNE-Python’s mne.extract_label_time_course() function, since it only allows extracting the first SVD component. Instead, the method applies the fitted weight matrix to the data to obtain the SVD-based time courses.

In case of one SVD component per ROI, the result should match the output of mne.extract_label_time_course() with mode="pca_flip" up to a sign flip and scaling factor.

Parameters:
dataSourceEstimate

The source estimate containing the reconstructed source time courses.

Returns:
label_tcarray, shape (n_labels * n_components, n_times)

The extracted time courses for each label and SVD component. For label i, the time courses of corresponding SVD components are located at rows i * n_components to (i + 1) * n_components - 1.