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.utils.bvecbval_from_file

brainprep.utils.utils.bvecbval_from_file(image_file)[source]

Infers the corresponding .bvec and .bval files for a given dMRI NIfTI image file.

This function checks that the input file has a .nii.gz extension and attempts to locate gradient information .bvec and .bval files with the same base name. None is returned if no gradient information is found.

Parameters:
image_fileFile

The NIfTI image file for which to infer the JSON sidecar.

Returns:
bvec_fileFile

Path to the inferred bvec file.

bvval_fileFile

Path to the inferred bvel file.

Raises:
ValueError

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

Examples

>>> from pathlib import Path
>>> from brainprep.utils import bvecbval_from_file
>>>
>>> image_file = Path("/tmp/sub-01_dwi.nii.gz")
>>> bvec_file = Path("/tmp/sub-01_dwi.bvec")
>>> bvec_file.touch()
>>> bval_file = Path("/tmp/sub-01_dwi.bval")
>>> bval_file.touch()
>>>
>>> bvecbval_from_file(image_file)
(PosixPath('/tmp/sub-01_dwi.bvec'), PosixPath('/tmp/sub-01_dwi.bval'))