Skip to content
Paul Wright edited this page Apr 8, 2021 · 14 revisions

Patient Preprocessing

Overview

This is MATLAB code for various neuroimaging preprocessing operations (registration, reslicing, denoising, segmentation, etc.), which was originally intended for processing routine clinical data (hence the name).1 It takes as input nifti files (as .nii or .nii.gz) and produces copies of this data to which the requested preprocessing steps are applied. It additionally handles image data with paired label masks (e.g., a T1w MRI and a tumour mask (or multiple classes)), and makes sure that the resulting preprocessed data is consistent. These example use cases could be run as is, or be inspiration for more complicated preprocessing tasks. For more information, please refer to the detailed pipeline description.

Dependencies

The algorithm requires that the following package is on the MATLAB path:

Installation

Download and unpack the .zip file and add the location to your MATLAB path.

Usage

out = RunPreproc(paths,opt)

INPUT
paths - Can be given as:
           paths = im.ext, 
           paths = {im1.ext, ..., imN.ext}
           paths = {{im1.ext, ..., imN.ext}, 
                    {'', ..., labn.ext, ..., ''}}  
           
        where valid extensions are .nii and .nii.gz, and labn.ext should 
        be in the same index position as the image it was labelled on.
opt   - Preprocessing options

OUTPUT
out.pth.im    - Cell array of paths to preprocessed image(s)
out.pth.im2d  - Cell array of paths to 2D versions of preprocessed
                image(s) (if opt.do.write2d = true)
out.pth.lab   - Cell array of path to label image (if labels given)
out.pth.lab2d - Cell array of path to 2D version of label image (if 
                labels given and if opt.do.write2d = tru)
out.mat       - Orientation matrices to go back to native space 
                orientation as:
                  Mc = spm_get_space(P{c}); 
                  spm_get_space(f,M{c}*Mc);

Paths argument

Input can be a single image paths, a cell array of image paths, or two cell arrays of corresponding base image paths and label image paths.

Example:

paths = { ...
         {'/data/rawdata/sub-001/ses-001/anat/sub-001_ses-001_T1w.nii', ...
          '/data/rawdata/sub-001/ses-001/anat/sub-001_ses-001_T2w.nii', ...
          '/data/rawdata/sub-001/ses-001/anat/sub-001_ses-001_FLAIR.nii'}, ...
         {'/data/derivatives/lesions/sub-001/ses-001/anat/sub-001_ses-001_desc-T1w_label-lesion_mask.nii', ...
          '/data/derivatives/lesions/sub-001/ses-001/anat/sub-001_ses-001_desc-T2w_label-lesion_mask.nii', ...
          '/data/derivatives/lesions/sub-001/ses-001/anat/sub-001_ses-001_desc-FLAIR_label-lesion_mask.nii'} ...
         };

Note that the the base images in paths{1} and the label images in paths{2} have to be in same order. Later on, if you need to specify a reference image, you will use the index. So if you wanted the other images to be coregsitered to the FLAIR image you would specify reference 3.

Opt argument

Preprocessing options are entered as a MATLAB structure. Steps are selected in the opt.do field, and further options for each step are specified in their own fields. For example:

opt.do.coreg = true;
opt.coreg.ref = 3;

With the paths argument above, this will opt argument will enable coregistration and use the FLAIR image as the reference.

Here is a complete description of the options structure.

References

  1. Brudfors, M. (2020). Generative Models for Preprocessing of Hospital Brain Scans. Doctoral dissertation, UCL (University College London).

  2. Brudfors M, Balbastre Y, Nachev P, Ashburner J. MRI Super-Resolution Using Multi-channel Total Variation. In Annual Conference on Medical Image Understanding and Analysis 2018 Jul 9 (pp. 217-228). Springer, Cham.

License

This software is released under the GNU General Public License version 3 (GPL v3). As a result, you may copy, distribute and modify the software as long as you track changes/dates in source files. Any modifications to or software including (via compiler) GPL-licensed code must also be made available under the GPL along with build & install instructions.

TL;DR: GPL v3

Clone this wiki locally