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

Show single subject data together with normative values #10

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

valosekj
Copy link
Member

@valosekj valosekj commented Aug 4, 2023

This PR adds a generate_figures_with_single_subject.py script to plot single-subject morphometric metrics together with normative values computed from the normative database (spine-generic dataset in PAM50 space).

I tested the script on both females and males.

dcm-zurich/sub-343299 - single compression at C4/C5; male; 0.5×0.5×3.6mm voxel size

Compression: image
Commands:
# Label T2w axial spinal cord segmentation using disc labels
sct_label_utils -i sub-343299_acq-axial_T2w_label-SC_mask-manual.nii.gz  -disc sub-343299_acq-axial_T2w_labels-manual.nii.gz -o sub-343299_acq-axial_T2w_label-SC_mask-manual_labeled.nii.gz

# Compute metrics
sct_process_segmentation -i sub-343299_acq-axial_T2w_label-SC_mask-manual.nii.gz -vertfile sub-343299_acq-axial_T2w_label-SC_mask-manual_labeled.nii.gz -perslice 1 -normalize-PAM50 1 -o sub-343299_metrics_PAM50.csv

# Generate figure
python generate_figures_with_single_subject.py -path-HC ${SCT_DIR}/data/PAM50_normalized_metrics -participant-file ${SCT_DIR}/data/PAM50_normalized_metrics/participants.tsv -csv-single-subject sub-343299_metrics_PAM50.csv -single-subject-sex M

image

dcm-zurich/sub-780875 - single compression at C5/C6; female; 0.5×0.5×3.6mm voxel size

Compression: image
Commands:
# Label T2w axial spinal cord segmentation using disc labels
sct_label_utils -i sub-780875_acq-axial_T2w_label-SC_mask-manual.nii.gz  -disc sub-780875_acq-axial_T2w_labels-manual.nii.gz -o sub-780875_acq-axial_T2w_label-SC_mask-manual_labeled.nii.gz

# Compute metrics
sct_process_segmentation -i sub-780875_acq-axial_T2w_label-SC_mask-manual.nii.gz -vertfile sub-780875_acq-axial_T2w_label-SC_mask-manual_labeled.nii.gz -perslice 1 -normalize-PAM50 1 -o sub-780875_metrics_PAM50.csv

# Generate figure
python generate_figures_with_single_subject.py -path-HC ${SCT_DIR}/data/PAM50_normalized_metrics -participant-file ${SCT_DIR}/data/PAM50_normalized_metrics/participants.tsv -csv-single-subject sub-780875_metrics_PAM50.csv -single-subject-sex F

image

data-multi-subject/sub-tokyoIngenia02 - compression at C6/C7; male; 0.8×0.8×0.8mm voxel size

Compression: image
Commands:
# Label T2w spinal cord segmentation using disc labels
sct_label_utils -i sub-tokyoIngenia02_T2w_seg-manual.nii.gz -disc sub-tokyoIngenia02_T2w_labels-disc-manual.nii.gz -o sub-tokyoIngenia02_T2w_seg-manual_labeled.nii.gz

# Compute metrics
sct_process_segmentation -i sub-tokyoIngenia02_T2w_seg-manual.nii.gz -vertfile sub-tokyoIngenia02_T2w_seg-manual_labeled.nii.gz -perslice 1 -normalize-PAM50 1 -o sub-tokyoIngenia02_metrics_PAM50.csv

# Generate figure
python generate_figures_with_single_subject.py -path-HC ${SCT_DIR}/data/PAM50_normalized_metrics -participant-file ${SCT_DIR}/data/PAM50_normalized_metrics/participants.tsv -csv-single-subject sub-tokyoIngenia02_metrics_PAM50.csv -single-subject-sex M

image


TODO:

  • also identify other types of compression ("impingement compression" vs "flat compression") and test the script
image

Figure ref: https://pubmed.ncbi.nlm.nih.gov/27509189/

@jcohenadad
Copy link
Member

I really really like this representation of an individual subject on the normative value. Nice work!

@valosekj
Copy link
Member Author

valosekj commented Aug 7, 2023

@jcohenadad, what do you think if I implemented the automatic generation of this figure into the sct_process_segmentation function?
If a user calls sct_process_segmentation -normalize-PAM50 1, sct_process_segmentation would output the figure along with a CSV file with metrics in PAM50 (the current output).
This feature could also be advertised in the manuscript.

@jcohenadad
Copy link
Member

@jcohenadad, what do you think if I implemented the automatic generation of this figure into the sct_process_segmentation function?

Sure, why not. We need to make sure the fig generation will work on a headless system (ie: using matplotlib OO module) in case people run it on a cluster via SSH. Also, figure naming and output location needs to be figured out. One possibility would be to output that figure via the QC's report. That way, if ppl don't want that figure they simply don't specify -qc, and having it in the QC will be convenient.

@valosekj
Copy link
Member Author

valosekj commented Aug 24, 2023

One possibility would be to output that figure via the QC's report. That way, if ppl don't want that figure they simply don't specify -qc, and having it in the QC will be convenient.

Good idea! I discussed the possibility of outputting the PNG figure into the hmtl QC report with @mguaypaq and @joshuacwnewton. The current QC code seems relatively rigid and supports only nii images. Fortunately, refactoring of the QC code currently done by Mathieu (spinalcordtoolbox/spinalcordtoolbox#4204) should offer an easy way of outputting the PNG figure into the hmtl QC report.

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 this pull request may close these issues.

2 participants