SPATIAL_RESAMPLING Module

The SPATIAL_RESAMPLING module resamples NIfTI images to a specified resolution, providing options for interpolation and voxel size. It uses the Convert3D (c3d) program from ITK-SNAP (http://www.itksnap.org) or SimpleITK for spatial transformations, depending on configuration.

Options

The SPATIAL_RESAMPLING module accepts the following options:

  • verbose: Enable verbose output for more detailed process information (default: False).

  • timer: Enable a timer to measure execution time (default: False).

  • inputFolder: Path to the folder containing input NIfTI files.

  • outputFolder: Path to save the resampled output files.

  • outputFolderSuffix: Adds a suffix to the inputFolder name to create an output folder.

  • with-segmentation: Specify if folders contain segmentation files.

  • all-data-with-segmentation: Specify if all folders contain segmentation files (default: True).

  • log: Path to a log file for saving detailed information about the resampling process.

  • new_log_file: Create a new log file; if a file with the same name exists, it will be overwritten.

  • skip: Path to a file listing subfolders to exclude from resampling.

  • include: Path to a file listing subfolders to include in resampling (all subfolders included by default).

  • multiprocessing: Specify the number of CPU cores to use for parallel processing.

  • image_interpolation: Interpolation method for images. Options: NearestNeighbor, Linear, Cubic, Sinc, Gaussian, B-Spline (default: Linear).

  • mask_interpolation: Interpolation method for masks/segmentation files. Options: NearestNeighbor, Linear, Cubic, Sinc, Gaussian, B-Spline (default: NearestNeighbor).

  • use_c3d: Use the c3d program for resampling instead of SimpleITK.

  • voxel_size: Specify the x, y, and z dimensions of the voxels in mm³. Only isotropic resampling is supported (default: 1).

  • suffix_name: Add a suffix to resampled image and segmentation files (default: “111”).

Example Usage

The following example demonstrates how to use the SPATIAL_RESAMPLING module to resample a folder of NIfTI files to 1mm³ isotropic voxel size:

SPATIAL_RESAMPLING:
{
    inputFolder: /path/to/NIFTI_folder
    outputFolderSuffix: 111
    voxel_size: 1  # 1mm³
    image_interpolation: Linear
    mask_interpolation: NearestNeighbor
    suffix_name: 111
    log: /path/to/logs/spatial_resampling.log
}

In this example:

  • inputFolder: Specifies the folder containing NIfTI files to be resampled.

  • outputFolderSuffix: Appends the suffix “111” to the name of inputFolder to create the output directory.

  • voxel_size: Sets the voxel size for resampling to 1mm³.

  • log: Saves a log file at the specified location, recording details of the resampling process.

NiftiSpatialResampling_multiprocessing.is_mask(nifti_file, verbose=False)[source]

Function to determine if a NIfTI file is a mask or an image based on the filename and the unique voxel intensities. The function first checks the filename for common keywords (e.g., ‘img’, ‘msk’). If verbose is True, it will print whether the file is identified as a mask or an image.

NiftiSpatialResampling_multiprocessing.main(argv)[source]
NiftiSpatialResampling_multiprocessing.process_patient(patient, outpath, size, interpolation, mask_interpolation, suffix, path_to_c3d, skip_files, include_files, verbose, log, NoSegmentation, AllSegmentation, use_c3d)[source]
NiftiSpatialResampling_multiprocessing.resample_image_sitk(input_path, output_path, size, interpolation_type, cast_type=None)[source]