Skip to content
Jan Valosek edited this page Apr 21, 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

Manual labeling of spinal cord compression

This is an example on how to label spinal cord compressions in the axial image.

The workflow is the following:

  1. Loop across subjects listed in the <CONFIG_FILE> YML file.
  2. Open the axial and sagittal images in FSLeyes.
  3. Look at the clinical data provided with compression information.
  4. Locate the compression in the sagittal view.
  5. In the axial view, toggle to the maximum compressed slice arround the compression
  6. Click on alt+E to open edit mode. Select size 1 and click on the pencil.
  7. Place label at the center of the spinal cord of the axial image.
  8. Repeat steps 4 to 8 for the number of compressions.
  9. Save and quit.

Example command:

python manual_correction.py -path-in <INPUT_PATH>/data_processed -config <CONFIG_FILE> -path-out <OUTPUT_PATH> -viewer fsleyes -suffix-files-lesion _label-compression -load-other-contrast acq-sagittal_T2w

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