CLI Reference

The following section outlines the CLI of shimming-toolbox.

shimmingtoolbox.cli.check_env.check_dcm2niix_installation()int

Checks that dcm2niix is installed.

This function calls which dcm2niix and checks the exit code to verify that dcm2niix is installed.

Returns

Exit code. 0 on success, nonzero on failure.

Return type

int

shimmingtoolbox.cli.check_env.check_prelude_installation()int

Checks that prelude is installed.

This function calls which prelude and checks the exit code to verify that prelude is installed.

Returns

Exit code. 0 on success, nonzero on failure.

Return type

int

shimmingtoolbox.cli.check_env.get_dcm2niix_version()str

Gets the dcm2niix installation version.

This function calls dcm2niix --version and captures the output to obtain the installation version.

Returns

Version of the dcm2niix installation.

Return type

str

shimmingtoolbox.cli.check_env.get_env_info()str

Gets information about the environment.

This function gets information about the operating system, the host machine hardware, Python version & implementation, and Python location.

Returns

A multiline string containing environment info.

Return type

str

shimmingtoolbox.cli.check_env.get_pkg_info()str

Gets package version.

This function gets the version of shimming-toolbox.

Returns

The version number of the shimming-toolbox installation.

Return type

str

shimmingtoolbox.cli.check_env.get_prelude_version()str

Gets the prelude installation version.

This function calls prelude --help and parses the output to obtain the installation version.

Returns

Version of the prelude installation.

Return type

str

shimmingtoolbox.cli.check_env.print_line(string)

print without carriage return

mask

Create a mask based on a specified shape (box, rectangle, SpinalCord Toolbox mask) or based on the thresholding of an input image. Callable with the prefix ‘st’ in front of ‘mask’. (Example: ‘st_mask -h’).

mask [OPTIONS] COMMAND [ARGS]...

box

Create a box mask from the input file. The nifti file is converted to a numpy array. If this array is in 3D dimensions, then a binary mask is created from this array in the form of a box with lengths defined in ‘size’. This box is centered according to the 3 dimensions indicated in ‘center’. The mask is stored by default under the name ‘mask.nii.gz’ in the output folder.Return the filename for the output mask.

mask box [OPTIONS]

Options

-input <fname_input>

Required (str): Input path of the nifti file to mask. This nifti file must have 3D. Supported extensions are .nii or .nii.gz.

-output <output>

(str): Name of output mask. Supported extensions are .nii or .nii.gz. (default: (os.curdir, ‘mask.nii.gz’))

-size <size>

Required (int): Length of the side of the box along first, second and third dimension (in pixels). (nargs=3)

-center <center>

(int): Center of the box along first, second and third dimension (in pixels). If no center is provided (None), the middle is used. (nargs=3) (default: None, None, None)

rect

Create a rectangle mask from the input file. The nifti file is converted to a numpy array. If this array is in 2 dimensions, then a binary mask is created from this array in the form of a rectangle of lengths defined in ‘size’. This rectangle is centered according to the 2 dimensions indicated in ‘center’. If this array is in 3 dimensions, a binary mask is created in the shape of rectangle for each slice of the 3rd dimension of the array, in the same way as for a 2D array. The masks of all these slices are grouped in an array to form a binary mask in 3 dimensions. The mask is stored by default under the name ‘mask.nii.gz’ in the output folder.Return an output nifti file with square mask.

mask rect [OPTIONS]

Options

-input <fname_input>

Required (str): Input path of the nifti file to mask. This nifti file must have 2D or 3D. Supported extensions are .nii or .nii.gz.

-output <output>

(str): Name of output mask. Supported extensions are .nii or .nii.gz. (default: (os.curdir, ‘mask.nii.gz’))

-size <size>

Required (int): Length of the side of the box along first and second dimension (in pixels). (nargs=2)

-center <center>

(int): Center of the box along first and second dimension (in pixels). If no center is provided (None), the middle is used. (nargs=2) (default: None, None)

threshold

Create a threshold mask from the input file. The nifti file is converted into a numpy array. A binary mask is created from the thresholding of the array. The mask is stored by default under the name ‘mask.nii.gz’ in the output folder. Return an output nifti file with threshold mask.

mask threshold [OPTIONS]

Options

-input <fname_input>

Required (str): Input path of the nifti file to mask. Supported extensions are .nii or .nii.gz.

-output <output>

(str): Name of output mask. Supported extensions are .nii or .nii.gz. (default: (os.curdir, ‘mask.nii.gz’))

-thr <thr>

(int): Value to threshold the data: voxels will be set to zero if their value is equal or less than this threshold. (default: 30)