Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error raised by sct_qc when dealing with empty masks #60

Closed
NathanMolinier opened this issue Aug 21, 2023 · 3 comments · Fixed by #61
Closed

Error raised by sct_qc when dealing with empty masks #60

NathanMolinier opened this issue Aug 21, 2023 · 3 comments · Fixed by #61
Assignees

Comments

@NathanMolinier
Copy link
Contributor

Description

An error is raised by sct_qc when new created labels are empty. This behaviour is actually interesting in some cases:

  • to not keep empty labels
  • to be aware of complex subjects

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 ?

@valosekj
Copy link
Member

valosekj commented Aug 21, 2023

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 #61

@valosekj
Copy link
Member

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

@valosekj
Copy link
Member

valosekj commented Sep 14, 2023

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 b481504

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants