Adds utilities for the command-line interface

class designer.preprocessing.util.DWIFile(name)

Bases: object

Diffusion data file object, used for handling paths and extensions.

Helps interface different extensions, group .bval/.bvec seamlessly to the programmer. Offers interactive tools to try and locate a file if it can’t be found. Likely a bit overkill, but reduces uberscript coding.

Variables
  • path (str) – The path to the file

  • name (str) – The base name of the file

  • ext (list of str) – The valid extensions for this grouping of dwi data

  • acquisition (bool) – Indicates if a DWI acquisition or not, relevant for .bval/.bvec

  • json (struct) – The contents of the .json metadata if available

getBVAL()

Returns the .bval filename for this DWIFile

Returns

The full path to the .bval

Return type

str

getBVEC()

Returns the .bvec filename for this DWIFile

Returns

The full path to the .bvec

Return type

str

getFull()

Get the path and name combined for this dwifile

Returns

The full path and filename with extension

Return type

str

getJSON()

Returns the .json filename for this DWIFile

Returns

The full path to the .json file

Return type

str

getName()

Get the name without the path for this dwifile

Returns

Name of the file without extensions

Return type

str

getPath()

Get the path without the name for this dwifile

Returns

The path to this file

Return type

str

hasJSON()

Checks if this object has a .json file

Returns

True if has .json, False if not

Return type

bool

isAcquisition()

Check if this object is an acquisition

Returns

True if acquisition, False if not

Return type

bool

isPartialFourier()

Returns whether the volume is partial fourier encoded

Returns

True if encoding is partial fourier; False otherwise

Return type

bool

print(json=False)
class designer.preprocessing.util.DWIParser(path)

Bases: object

Parses a list of DWIs and concatenates them into a single 4D NifTi with appropriate BVEC, BVALS.

Variables
  • DWIlist (list of str) – Contains paths to all input series

  • DWInlist (list of str) – Contains path to file names without extension

  • DWIext (list of str) – Contains extension of input files

  • BVALlist (list of str) – Contains paths to all BVAL files

  • BVEClist (list of str) – Contains paths to all BVEC files

  • JSONlist (list of str) – Contains paths to all JSON files

  • nDWI (int) – Number of DWIs entered

  • echotime (list of int) – Echo time in miliseconds of each input DWI

  • vols (list of ints) – Number of volumes in each input DWI

cat(path, ext='.nii', verbose=False, force=False, resume=False)

Concatenates all input series when nDWI > 1 into a 4D NifTi along with a appropriate BVAL, BVEC and JSON files. Concatenation of series via MRTRIX3 requires every NifTi file to come with BVAL/BVEC to produce a .json with dw_scheme.

Parameters
  • path (str) – Directory where to store concatenated series

  • ext (str) – Extenstion to save concatenated file in. Refer to MRTRIX3’s mrconvert function for a list of possible extensions

  • force (bool, optional) – Force overwrite of output files if pre-existing (Default:False)

  • verbose (bool, optional) – Specify whether to print console output (Default: False)

  • resume (bool, optional) – Continue from an aborted or partial previous run of pydesigner (Default: False)

Return type

None; writes out file

getPath()

Returns directory where first file in DWI list is stored

Returns

directory of first DWI

Return type

str

designer.preprocessing.util.find_valid_ext(pathname)

Finds valid extensions for dwifile, helper function

Parameters

pathname (str) – The name to try and find extensions for

Returns

Array of valid file extensions for the basename

Return type

list of str

designer.preprocessing.util.json2fslgrad(path)

Creates FSL .bvec and .bval for series missing that information. Some datasets have their B0s separately that do not produce fsl gradients upon conversion to NifTi. This function creates those missing features for complete concatenation from .json file. Use with caution if and only if you know your input series is a DWI.

Parameters

path (str) – Path to NifTi file

Return type

None; writes out file