Closed NathanMolinier closed 1 year ago
Should we create a check after the creation of the label to avoid this problem ?
Agree. I would add a simple condition checking if the label file is empty (for example, in the case of an MS patient with no visible lesion). If so, I would skip the QC.
UPDATE: implemented in https://github.com/spinalcordtoolbox/manual-correction/pull/61
The error raised by sct_qc
:
$ sct_qc -i sub-zh01_ses-01_acq-sag_T1w.nii.gz -s sub-zh01_ses-01_acq-sag_T1w_label-disc.nii.gz -p sct_label_utils -qc qc
--
Spinal Cord Toolbox (git-master-8b8f9bd98a0565d670faa515a6b24ecbc5a7d3a3)
sct_qc -i sub-zh01_ses-01_acq-sag_T1w.nii.gz -s sub-zh01_ses-01_acq-sag_T1w_label-disc.nii.gz -p sct_label_utils -qc qc
--
*** Generate Quality Control (QC) html report ***
Resample images to NonexNone mm
QcImage: layout with Sagittal slice
Traceback (most recent call last):
File "/Users/valosek/code/sct_latest/spinalcordtoolbox/scripts/sct_qc.py", line 105, in <module>
main(sys.argv[1:])
File "/Users/valosek/code/sct_latest/spinalcordtoolbox/scripts/sct_qc.py", line 90, in main
generate_qc(fname_in1=arguments.i,
File "/Users/valosek/code/sct_latest/spinalcordtoolbox/reports/qc.py", line 713, in generate_qc
QcImage(
File "/Users/valosek/code/sct_latest/spinalcordtoolbox/reports/qc.py", line 239, in layout
img, *mask = qcslice_layout(qcslice)
File "/Users/valosek/code/sct_latest/spinalcordtoolbox/reports/qc.py", line 665, in qcslice_layout
def qcslice_layout(x): return x.single()
File "/Users/valosek/code/sct_latest/spinalcordtoolbox/reports/slice.py", line 252, in single
index = self.get_center_spit()
File "/Users/valosek/code/sct_latest/spinalcordtoolbox/reports/slice.py", line 433, in get_center_spit
raise ValueError("Label/segmentation image is empty. Can't retrieve RL slice indices.")
ValueError: Label/segmentation image is empty. Can't retrieve RL slice indices.
Note that the error is raised due to the -p sct_label_utils
flag.
For the -p sct_deepseg_lesion
flag, empty QC can be created:
$ sct_qc -i sub-zh01_ses-01_acq-sag_T1w.nii.gz -s sub-zh01_ses-01_acq-sag_T1w_seg.nii.gz -d sub-zh01_ses-01_acq-sag_T1w_lesion.nii.gz -p sct_deepseg_lesion -plane axial -qc qc
--
Spinal Cord Toolbox (git-master-8b8f9bd98a0565d670faa515a6b24ecbc5a7d3a3)
sct_qc -i sub-zh01_ses-01_acq-sag_T1w.nii.gz -s sub-zh01_ses-01_acq-sag_T1w_seg.nii.gz -d sub-zh01_ses-01_acq-sag_T1w_lesion.nii.gz -p sct_deepseg_lesion -plane axial -qc qc
--
*** Generate Quality Control (QC) html report ***
Resample images to 0.6x0.6 mm
QcImage: layout with Axial slice
Compute center of mass at each slice
/Users/valosek/code/sct_latest/python/envs/venv_sct/lib/python3.8/site-packages/scipy/ndimage/_measurements.py:1534: RuntimeWarning: invalid value encountered in double_scalars
results = [sum(input * grids[dir].astype(float), labels, index) / normalizer
qc/sub-zh01/ses-01/anat/sct_deepseg_lesion/2023_08_22_155410.797321/background_img.png
Successfully generated the QC results in qc/_json/qc_2023_08_22_155410.797321.json
To see the results in a browser, type:
open qc/index.html
Okay, an empty label file is not supported by the following sct_qc -p
options:
sct_label_utils
sct_label_vertebrae
sct_detect_pmj
Implemented in https://github.com/spinalcordtoolbox/manual-correction/pull/61/commits/b481504d15a613881aca855ead9a86e751ac2227
Description
An error is raised by sct_qc when new created labels are empty. This behaviour is actually interesting in some cases:
However, keeping empty masks can be relevant for some specific tasks such as lesions segmentations.
Question
Should we create a check after the creation of the label to avoid this problem ?