Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

brainprep.utils.sbref_from_file

brainprep.utils.sbref_from_file(image_file)[source]

Infers the corresponding SBREFr file for a given BOLD NIfTI image file.

This function checks that the input file has a .nii.gz extension and attempts to locate a SBREF _sbref file with the same base name. None is returned if no SBREF file is found.

Parameters:
image_fileFile

The NIfTI image file for which to infer the SBREF file.

Returns:
sbref_fileFile | None

Path to the inferred SBREF file.

Raises:
ValueError

If the input file does not have a .nii.gz extension.

Examples

>>> from pathlib import Path
>>> from brainprep.utils import sbref_from_file
>>>
>>> image_file = Path("/tmp/sub-01_bold.nii.gz")
>>> sbref_file = Path("/tmp/sub-01_sbref.nii.gz")
>>> sbref_file.touch()
>>>
>>> sbref_from_file(image_file)
PosixPath('/tmp/sub-01_sbref.nii.gz')