qsiprep.interfaces.epi_fmap module

qsiprep.interfaces.epi_fmap.calculate_best_b0s(b0_list, radius=4)[source]
qsiprep.interfaces.epi_fmap.eddy_inputs_from_dwi_files(origin_file_list, eddy_prefix)[source]
qsiprep.interfaces.epi_fmap.get_best_b0_topup_inputs_from(dwi_file, bval_file, b0_threshold, cwd, bids_origin_files, epi_fmaps=None, max_per_spec=3, topup_requested=False, raw_image_sdc=True)[source]

Create a datain spec and a slspec from a concatenated dwi series.

Create inputs for TOPUP that come from data in dwi/ and epi fieldmaps in fmap/. The nii_file input may be the result of concatenating a number of scans with different distortions present. The original source of each volume in nii_file is listed in bids_origin_files.

The strategy is to select max_per_spec b=0 images from each distortion group. Here, distortion group uses the FSL definition of a phase encoding direction and total readout time, as specified in the datain file used by TOPUP (i.e. “0 -1 0 0.087”).

Parameters:
  • nii_file (str) – A 4D DWI Series

  • bval_file (str) – indices into nii_file that can be used by topup

  • topup_prefix (str) – file prefix for topup inputs

  • bids_origin_files (list) – A list with the original bids file of each image in nii_file. This is necessary because merging may have happened earlier in the pipeline

  • epi_fmaps – A list of images from the fmaps/ directory.

  • max_per_spec (int) – The maximum number of b=0 images to extract from a PE direction / image set

qsiprep.interfaces.epi_fmap.get_distortion_grouping(origin_file_list)[source]

Discover which distortion groups are present, then assign each volume to a group.

qsiprep.interfaces.epi_fmap.load_epi_dwi_fieldmaps(fmap_list, b0_threshold)[source]

Creates a 4D image of b=0s from a list of input images.

Parameters:

fmap_list: list

List of paths to epi fieldmap images

b0_threshold: int

Maximum b value for an image to be considered a b=0

Returns:

concatenated_images: spatial image

The b=0 volumes concatenated into a 4D image

b0_indices: list

List of the indices in the concatenated images that contain usable images

original_files: list

List of the original files where each b=0 image came from.

qsiprep.interfaces.epi_fmap.read_nifti_sidecar(json_file)[source]
qsiprep.interfaces.epi_fmap.relative_b0_index(b0_indices, original_files)[source]

Find the index of each b=0 image in its original imaging series

>>> b0_indices = [0, 7, 11, 15, 17, 30, 37, 41, 45]
>>> original_files = ["sub-1_dir-AP_dwi.nii.gz"] * 30 + ["sub-1_dir-PA_dwi.nii.gz"] * 30
>>> print(
... relative_b0_index(b0_indices,
...                   original_files))  
[0, 7, 11, 15, 17, 0, 7, 11, 15]

Or

>>> original_files = ["sub-1_dir-AP_run-1_dwi.nii.gz"] * 15 + [
...                   "sub-1_dir-AP_run-2_dwi.nii.gz"] * 15 + [
...                   "sub-1_dir-PA_dwi.nii.gz"] * 30
>>> print(relative_b0_index(b0_indices, original_files))
[0, 7, 11, 0, 2, 0, 7, 11, 15]
qsiprep.interfaces.epi_fmap.safe_get_3d_image(img_file, b0_index)[source]
qsiprep.interfaces.epi_fmap.split_into_b0s_and_origins(b0_threshold, original_files, img_file, cwd, b0_indices=None, bval_file=None, use_original_files=True)[source]