funROI.first_level

Nilearn

funROI.first_level.nilearn.run_first_level(task: str, subjects: List[str] | None = None, space: str | None = None, data_filter: List[Tuple[str, str]] | None = [], contrasts: List[Tuple[str, Dict[str, float]]] | None = [], orthogs: List[str] | None = ['all-but-one', 'odd-even'], **kwargs)[source]

Run first-level analysis for a list of subjects.

Parameters:
  • task (str) – The task label.

  • subjects (Optional[List[str]]) – List of subject labels. If None, all subjects are included.

  • space (Optional[str]) – The space name of the data. If None, the data is assumed to be in the native space.

  • data_filter (Optional[List[Tuple[str, str]]]) – Additional data filter, e.g. the resolution associated with the space. See Nilearn get_bids_files documentation for more information.

  • contrasts (Optional[List[Tuple[str, Dict[str, float]]]) – List of contrast definitions. Each contrast is a tuple of the contrast name and the contrast expression. The contrast expression is defined by a dictionary of regressor names and their weights.

  • orthogs (Optional[List[str]]) – List of orthogonalization strategies. For each group, contrast images are also generated for corresponding run labels. Supported strategies are ‘all-but-one’ and ‘odd-even’. Default is both.

  • kwargs (Dict) – Additional keyword arguments for the first-level analysis. See Nilearn first_level_from_bids documentation for more information.

SPM

funROI.first_level.spm.migrate_first_level_from_spm(spm_dir: str | Path, subject: str, task: str)[source]

Migrate first-level contrasts from SPM to BIDS, to be used with later stages of the pipeline.

Warning

Since contrast computation is quite model-specific, it is assumed that all needed contrasts are already computed in SPM. E.g., contrasts for each run, all-but-one, odd, and even runs, etc. These contrasts are assumed to be named in the following way in SPM:

  • Contrast by run: SESSION<session_number>_<contrast_name>

  • All-but-one contrast: ORTH_TO_SESSION<session_number>_<contrast_name>

  • Odd-run contrast: ODD_<contrast_name>

  • Even-run contrast: EVEN_<contrast_name>

Parameters:
  • spm_dir (Union[str, Path]) – Path to the SPM directory. The directory should contain ‘SPM.mat’.

  • subject (str) – Subject label.

  • task (str) – Task label.

Raises:

FileNotFoundError – If ‘SPM.mat’ is not found in the SPM directory.