-
Notifications
You must be signed in to change notification settings - Fork 2
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
Analyze midsagittal lesion length and width #96
base: main
Are you sure you want to change the base?
Conversation
… compute the midsagittal lesion length and width.
… we use '-ofolder' for sct_analyze_lesion, then QC report fails.
…e previous commit
RESULTS FROM contrast-agnostic model (version: 2.4) Adding |
RESULTS FROM contrast-agnostic model (version: 2.4) When calling model_seg_sci/midsagittal_measures/01_compute_midsagittal_lesion_length_and_width.sh Lines 127 to 128 in 8d9b7b9
full error output+ sct_analyze_lesion -m sub-zh04_ses-02_acq-sag_T2w_lesion_seg.nii.gz -s sub-zh04_ses-02_acq-sag_T2w_sc_seg_contrast-agnostic.nii.gz -qc /home/GRAMES.POLYMTL.CA/p118175/results/sci-zurich_midsagittal_measures_2024-09-20/qc -qc-subject sub-zh04/ses-02
--
Spinal Cord Toolbox (git-master-197ef3494a1c73d8b8acb14fcd809f31e16b5265)
sct_analyze_lesion -m sub-zh04_ses-02_acq-sag_T2w_lesion_seg.nii.gz -s sub-zh04_ses-02_acq-sag_T2w_sc_seg_contrast-agnostic.nii.gz -qc /home/GRAMES.POLYMTL.CA/p118175/results/sci-zurich_midsagittal_measures_2024-09-20/qc -qc-subject sub-zh04/ses-02
--
Creating temporary folder (/tmp/sct_2024-09-20_12-02-42_analyze-lesion_fwwtdhau)
cp sub-zh04_ses-02_acq-sag_T2w_lesion_seg.nii.gz /tmp/sct_2024-09-20_12-02-42_analyze-lesion_fwwtdhau
cp sub-zh04_ses-02_acq-sag_T2w_sc_seg_contrast-agnostic.nii.gz /tmp/sct_2024-09-20_12-02-42_analyze-lesion_fwwtdhau
Orient input image(s) to RPI orientation...
^[[33mFile sub-zh04_ses-02_acq-sag_T2w_lesion_seg.nii.gz already exists. Will overwrite it.^[[0m
^[[33mFile sub-zh04_ses-02_acq-sag_T2w_sc_seg_contrast-agnostic.nii.gz already exists. Will overwrite it.^[[0m
Label connected regions of the masked image...
^[[33mImage header specifies datatype 'uint8', but array is of type 'int64'. Header metadata will be overwritten to use 'int64'.^[[0m
/home/GRAMES.POLYMTL.CA/p118175/code/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_analyze_lesion.py:394: RuntimeWarning: divide by zero encountered in scalar divide
axial_damage_ratio_dict[slice] = lesion_area / sc_area
Lesion count = 1
Midsagittal slice of the spinal cord: 10
Measures on lesion #1...
(S-I) length: 11926.41 mm
Max. equivalent diameter: 0.41 mm
Maximum axial damage ratio: inf
(S-I) length in the midsagittal slice: 8719.91 mm
(A-P) width in the midsagittal slice: 0.01 mm
Volume: 727.35 mm^3
Orient output image to initial orientation...
^[[33mFile sub-zh04_ses-02_acq-sag_T2w_lesion_seg_label.nii.gz already exists. Will overwrite it.^[[0m
Averaged measures across all lesions...
volume [mm3] = 727.35 +/- 0.0
length [mm] = 11926.41 +/- 0.0
max_equivalent_diameter [mm] = 0.41 +/- 0.0
max_axial_damage_ratio [] = inf +/- nan
Minimum tissue bridges across all lesions for the midsagittal slice (sagittal slice 10)...
WARNING: Lesion #1 does not exist in the midsagittal slice
Minimum dorsal bridge width [mm]: nan
Minimum ventral bridge width [mm]: nan
Total volume = 727.35 mm^3
Lesion count = 1
Save results files...
... measures saved in the files:
- ./sub-zh04_ses-02_acq-sag_T2w_lesion_seg_label.nii.gz
cp /tmp/sct_2024-09-20_12-02-42_analyze-lesion_fwwtdhau/sub-zh04_ses-02_acq-sag_T2w_lesion_seg_label.nii.gz ./sub-zh04_ses-02_acq-sag_T2w_lesion_seg_label.nii.gz
- ./sub-zh04_ses-02_acq-sag_T2w_lesion_seg_analysis.xls
cp /tmp/sct_2024-09-20_12-02-42_analyze-lesion_fwwtdhau/sub-zh04_ses-02_acq-sag_T2w_lesion_seg_analysis.xls ./sub-zh04_ses-02_acq-sag_T2w_lesion_seg_analysis.xls
- ./sub-zh04_ses-02_acq-sag_T2w_lesion_seg_analysis.pkl
cp /tmp/sct_2024-09-20_12-02-42_analyze-lesion_fwwtdhau/sub-zh04_ses-02_acq-sag_T2w_lesion_seg_analysis.pkl ./sub-zh04_ses-02_acq-sag_T2w_lesion_seg_analysis.pkl
*** Generating Quality Control (QC) html report ***
Traceback (most recent call last):
File "/home/GRAMES.POLYMTL.CA/p118175/code/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_analyze_lesion.py", line 1085, in <module>
main(sys.argv[1:])
File "/home/GRAMES.POLYMTL.CA/p118175/code/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_analyze_lesion.py", line 1048, in main
sct_analyze_lesion(
File "/home/GRAMES.POLYMTL.CA/p118175/code/spinalcordtoolbox/spinalcordtoolbox/reports/qc2.py", line 580, in sct_analyze_lesion
axes[idx_row, idx_col].set_xlim(np.min(np.where(im_label_data_cur)[1]) - 20,
File "/home/GRAMES.POLYMTL.CA/p118175/code/spinalcordtoolbox/python/envs/venv_sct/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 2953, in min
return _wrapreduction(a, np.minimum, 'min', axis, None, out,
File "/home/GRAMES.POLYMTL.CA/p118175/code/spinalcordtoolbox/python/envs/venv_sct/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 88, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: zero-size array to reduction operation minimum which has no identity The issue comes from L542 in |
… metal artifacts See comments in the following PR for context: #96
As the C-A model does not perform well on lumbar images with metal artifacts, I dropped it in 3a88281. The further analysis will continue with the SCIsegV2 model only. |
…ecause if SCIseg predictions no lesion, it finished with a QC error and GT masks are not analyzed at all
This PR adds a codebase to compare the midsagittal lesion length and width (recently added in spinalcordtoolbox/spinalcordtoolbox#4617) computed using different methods:
sct_analyze_lesion
from GT masks (located underderivatives/labels
)sct_analyze_lesion
from the lesion and SC masks obtained using SCIsegV2sct_analyze_lesion
from the lesion obtained using SCIsegV2 and SC obtained using the contrast-agnostic modelNote: The contrast-agnostic model is tried to see how it performs compared to the SCIsegV2 model. Comments below show some screenshots of SC seg obtained using the contrast-agnostic model.
At the same time, this PR aims to investigate an alternative method for getting the midsagittal slice (proposed in spinalcordtoolbox/spinalcordtoolbox#4631).
For details, visit this README.