Skip to content
Jan Valosek edited this page Mar 6, 2023 · 33 revisions

Segmentation (SC/GM seg, MS/SCI lesions, etc.) corrections

Example command:

python manual_correction.py -path-in <INPUT_PATH>/data_processed -config <CONFIG_FILE> -path-out <OUTPUT_PATH>

The workflow is the following:

  • Loop across subjects listed in the <CONFIG_FILE> YML file.
  • Correct the segmentation mask using editing tools. Tip: Toggle the lesion overlay on/off to help validate the accuracy of the label.
  • Press Save button to save the manually corrected segmentation mask. Note: The manual_correction.py will automatically save manually-corrected segmentation masks under the derivatives/labels/ folder at the root of OUTPUT_PATH according to the BIDS convention.

Examples of <CONFIG_FILE> file:

Spinal cord segmentation corrections:

FILES_SEG:
  - sub-001_T1w.nii.gz
  - sub-002_T2w.nii.gz

Gray matter segmentation corrections:

FILES_GMSEG:
  - sub-001_T2star.nii.gz
  - sub-002_T2star.nii.gz

MS lesion corrections:

FILES_LESION:
  - sub-edm005_ses-M0_PSIR.nii.gz
  - sub-edm008_ses-M0_PSIR.nii.gz
  - sub-edm010_ses-M0_PSIR.nii.gz

Spinal cord segmentation corrections across all subjects using the wildcard *:

FILES_SEG:
  - sub-*_ses-M0_T2w.nii.gz

ℹ️ If your input images have been preprocessed (e.g., reoriented to RPI and resampled) and thus contain the suffix _RPI_r, YML file will have the following format. Also, you will have to use the -suffix-files-in _RPI_r flag.

FILES_SEG:
  - sub-*_ses-M0_T2w_RPI_r.nii.gz

ℹ️ Once all corrections are done, you can generate a QC report by adding the flag -qc-only to the command above. Note that SCT is required for generating QC report.

ℹ️ You can load an additional contrast using -load-other-contrast flag.

ℹ️ You can open an additional orthoview in FSLeyes using the --fsleyes-second-orthoview flag.

Video tutorials

Here is a video for correcting manual SC segmentation: Youtube manual

Here are several helpful videos reviewing how to correct manual MS lesion segmentations: 1, 2, 3, 4.

Vertebral labeling corrections

The workflow is the following:

  • Loop across subjects listed in the <CONFIG_FILE> YML file.
  • Correct the vertebral labeling based on the labeling convention.
  • Press Save and Quit button to save the manually corrected vertebral labeling. Note: The manual_correction.py will automatically save manually-corrected vertebral labeling under the derivatives/labels/ folder at the root of OUTPUT_PATH according to the BIDS convention.

Example command:

python manual_correction.py -path-in <INPUT_PATH>/data_processed -config <CONFIG_FILE> -path-out <OUTPUT_PATH>

Example of <CONFIG_FILE> file:

FILES_LABEL:
  - sub-001_T2w.nii.gz
  - sub-002_T2w.nii.gz

ℹ️ You can specify discs to label using -label-disc-list flag. For example, if you want to correct only the disc C2/C3, specify -label-disc-list 3.

Video tutorial

Here is a video for correcting vertebral labeling: Youtube manual

Adding corrected segmentations to git-annex

After you finish manual corrections, upload the manually-corrected segmentations to git-annex (see internal documentation).

You can use the copy_files_to_derivatives.py script provided within this repository to copy manually corrected labels (segmentations, disc labels, etc.) from your local derivatives/labels folder to the already existing git-annex BIDS dataset's derivatives/labels folder.

Clone this wiki locally