niworkflows.interfaces.patches module

Temporary patches.

class niworkflows.interfaces.patches.RobustACompCor(*args, **kwargs)[source]

Bases: ACompCor

Runs aCompCor several times if it suddenly fails with https://github.com/nipreps/fmriprep/issues/776

Mandatory Inputs:

realigned_file (a pathlike object or string representing an existing file) – Already realigned brain image (4D).

Optional Inputs:
  • components_file (a string) – Filename to store physiological components. (Nipype default value: components_file.txt)

  • failure_mode (‘error’ or ‘NaN’) – When no components are found or convergence fails, raise an error or silently return columns of NaNs. (Nipype default value: error)

  • header_prefix (a string) – The desired header for the output tsv file (one column). If undefined, will default to “CompCor”.

  • high_pass_cutoff (a float) – Cutoff (in seconds) for “cosine” pre-filter. (Nipype default value: 128)

  • ignore_initial_volumes (an integer >= 0) – Number of volumes at start of series to ignore. (Nipype default value: 0)

  • mask_files (a list of items which are a pathlike object or string representing an existing file) – One or more mask files that determines ROI (3D). When more that one file is provided merge_method or merge_index must be provided.

  • mask_index (an integer >= 0) – Position of mask in mask_files to use - first is the default. Mutually exclusive with inputs: merge_method. Requires inputs: mask_files.

  • mask_names (a list of items which are a string) – Names for provided masks (for printing into metadata). If provided, it must be as long as the final mask list (after any merge and indexing operations).

  • merge_method (‘union’ or ‘intersect’ or ‘none’) – Merge method if multiple masks are present - union uses voxels included in at least one input mask, intersect uses only voxels present in all input masks, none performs CompCor on each mask individually. Mutually exclusive with inputs: mask_index. Requires inputs: mask_files.

  • num_components (an integer >= 1 or ‘all’) – Number of components to return from the decomposition. If num_components is all, then all components will be retained. Mutually exclusive with inputs: variance_threshold.

  • pre_filter (‘polynomial’ or ‘cosine’ or False) – Detrend time series prior to component extraction. (Nipype default value: polynomial)

  • regress_poly_degree (an integer >= 1) – The degree polynomial to use. (Nipype default value: 1)

  • repetition_time (a float) – Repetition time (TR) of series - derived from image header if unspecified.

  • save_metadata (a boolean or a pathlike object or string representing a file) – Save component metadata as text file. (Nipype default value: False)

  • save_pre_filter (a boolean or a pathlike object or string representing a file) – Save pre-filter basis as text file. (Nipype default value: False)

  • use_regress_poly (a boolean) – Use polynomial regression pre-component extraction.

  • variance_threshold (0.0 < a floating point number < 1.0) – Select the number of components to be returned automatically based on their ability to explain variance in the dataset. variance_threshold is a fractional value between 0 and 1; the number of components retained will be equal to the minimum number of components necessary to explain the provided fraction of variance in the masked time series. Mutually exclusive with inputs: num_components.

Outputs:
  • components_file (a pathlike object or string representing an existing file) – Text file containing the noise components.

  • metadata_file (a pathlike object or string representing a file) – Text file containing component metadata.

  • pre_filter_file (a pathlike object or string representing a file) – Text file containing high-pass filter basis.

class niworkflows.interfaces.patches.RobustTCompCor(*args, **kwargs)[source]

Bases: TCompCor

Runs tCompCor several times if it suddenly fails with https://github.com/nipreps/fmriprep/issues/940

Mandatory Inputs:

realigned_file (a pathlike object or string representing an existing file) – Already realigned brain image (4D).

Optional Inputs:
  • components_file (a string) – Filename to store physiological components. (Nipype default value: components_file.txt)

  • failure_mode (‘error’ or ‘NaN’) – When no components are found or convergence fails, raise an error or silently return columns of NaNs. (Nipype default value: error)

  • header_prefix (a string) – The desired header for the output tsv file (one column). If undefined, will default to “CompCor”.

  • high_pass_cutoff (a float) – Cutoff (in seconds) for “cosine” pre-filter. (Nipype default value: 128)

  • ignore_initial_volumes (an integer >= 0) – Number of volumes at start of series to ignore. (Nipype default value: 0)

  • mask_files (a list of items which are a pathlike object or string representing an existing file) – One or more mask files that determines ROI (3D). When more that one file is provided merge_method or merge_index must be provided.

  • mask_index (an integer >= 0) – Position of mask in mask_files to use - first is the default. Mutually exclusive with inputs: merge_method. Requires inputs: mask_files.

  • mask_names (a list of items which are a string) – Names for provided masks (for printing into metadata). If provided, it must be as long as the final mask list (after any merge and indexing operations).

  • merge_method (‘union’ or ‘intersect’ or ‘none’) – Merge method if multiple masks are present - union uses voxels included in at least one input mask, intersect uses only voxels present in all input masks, none performs CompCor on each mask individually. Mutually exclusive with inputs: mask_index. Requires inputs: mask_files.

  • num_components (an integer >= 1 or ‘all’) – Number of components to return from the decomposition. If num_components is all, then all components will be retained. Mutually exclusive with inputs: variance_threshold.

  • percentile_threshold (0.0 < a floating point number < 1.0) – The percentile used to select highest-variance voxels, represented by a number between 0 and 1, exclusive. By default, this value is set to .02. That is, the 2% of voxels with the highest variance are used. (Nipype default value: 0.02)

  • pre_filter (‘polynomial’ or ‘cosine’ or False) – Detrend time series prior to component extraction. (Nipype default value: polynomial)

  • regress_poly_degree (an integer >= 1) – The degree polynomial to use. (Nipype default value: 1)

  • repetition_time (a float) – Repetition time (TR) of series - derived from image header if unspecified.

  • save_metadata (a boolean or a pathlike object or string representing a file) – Save component metadata as text file. (Nipype default value: False)

  • save_pre_filter (a boolean or a pathlike object or string representing a file) – Save pre-filter basis as text file. (Nipype default value: False)

  • use_regress_poly (a boolean) – Use polynomial regression pre-component extraction.

  • variance_threshold (0.0 < a floating point number < 1.0) – Select the number of components to be returned automatically based on their ability to explain variance in the dataset. variance_threshold is a fractional value between 0 and 1; the number of components retained will be equal to the minimum number of components necessary to explain the provided fraction of variance in the masked time series. Mutually exclusive with inputs: num_components.

Outputs:
  • components_file (a pathlike object or string representing an existing file) – Text file containing the noise components.

  • high_variance_masks (a list of items which are a pathlike object or string representing an existing file) – Voxels exceeding the variance threshold.

  • metadata_file (a pathlike object or string representing a file) – Text file containing component metadata.

  • pre_filter_file (a pathlike object or string representing a file) – Text file containing high-pass filter basis.