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

Display vertebral levels when provided with -perslice 1 #4004

Merged
merged 9 commits into from Jan 24, 2023

Conversation

sandrinebedard
Copy link
Member

@sandrinebedard sandrinebedard commented Jan 19, 2023

Checklist

GitHub

PR contents

Description

This PR adresses #3113. In sct_process_segmentation when specifying -vertfile and -perslice 1, it now specifies the vertebral levels (when they are provided).

Linked issues

Fixes #3113 (and also its duplication #3976)

Copy link
Member

@joshuacwnewton joshuacwnewton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking on this task, and opening up a PR so quickly! ♥️

I found this PR a little difficult to review, though. So, I have some PR ettiquette-related requests for the future, if possible?

  • Could you add extended descriptions to your commits, when applicable?

    They're really helpful for explaining the reasons for each change. Without explanations, a reviewer either has to has to guess the motivations for each commit, or they have to take the time ask for explanations as part of their review. This slows down the review process, and makes a PR harder to review.

    (Obviously sometimes the changes are pretty self-explanatory? But in this case, the motivations for each commit weren't clear to me.)

  • Could you break down commits into smaller changes?

    (I had some trouble understanding 0c21b16, since it has multiple changes that are seemingly unrelated.)

Thank you again!

spinalcordtoolbox/scripts/sct_process_segmentation.py Outdated Show resolved Hide resolved
spinalcordtoolbox/scripts/sct_process_segmentation.py Outdated Show resolved Hide resolved
spinalcordtoolbox/aggregate_slicewise.py Outdated Show resolved Hide resolved
spinalcordtoolbox/aggregate_slicewise.py Show resolved Hide resolved
spinalcordtoolbox/aggregate_slicewise.py Show resolved Hide resolved
spinalcordtoolbox/aggregate_slicewise.py Show resolved Hide resolved
Without this, currently the default value of `argumnets.vert`
is `None`.

By adding this line, it makes it so that the default value of
`arguments.vert` will be an empty list (`[]`).
This allows users to specify `-vert` by itself, assuming they've run
`sct_warp_template` and generated the level file in the working directory.
Instead of manually setting `vert` to `[]` and `vertfile` to `None`,
we can just rely on their default values.
@joshuacwnewton
Copy link
Member

joshuacwnewton commented Jan 23, 2023

I've made some changes to implement the suggestions from the earlier review.

To test these changes, I followed the instructions from the Registration to Template tutorial to register the sct_example_data/t2/t2.nii.gz image to the PAM50 template. Then, I tried computing -perslice metrics on the segmentation, with and without the default ./label/template/PAM50 file specified by the default -vertfile value.

Before running sct_warp_template (vertfile is missing, warning is thrown, no vertlevel info in csv)
(sb/3113-display-vert-level) joshua@tadpole:~/repos/spinalcordtoolbox/data/sct_example_data/t2$ sct_process_segmentation -i t2_seg.nii.gz -z 30:35 -perslice 1 -o csa_perslice.csv

--
Spinal Cord Toolbox (git-sb/3113-display-vert-level-9dd71dc98a637e5aa2175e8149631e43e40265da)

sct_process_segmentation -i t2_seg.nii.gz -z 30:35 -perslice 1 -o csa_perslice.csv
--

Vertebral level file ./label/template/PAM50_levels.nii.gz does not exist. Vert level information will not be displayed. To use vertebral level information, you may need to run `sct_warp_template` to generate the appropriate level file in your working directory.
Compute shape analysis: 100%|##############| 240/240 [00:01<00:00, 194.14iter/s]

Done! To view results, type:
xdg-open /home/joshua/repos/spinalcordtoolbox/data/sct_example_data/t2/csa_perslice.csv

image

After running sct_warp_template (vertfile is present, no warning, vertlevel info is in csv)
(sb/3113-display-vert-level) joshua@tadpole:~/repos/spinalcordtoolbox/data/sct_example_data/t2$ sct_process_segmentation -i t2_seg.nii.gz -z 30:35 -perslice 1 -o csa_perslice.csv

--
Spinal Cord Toolbox (git-sb/3113-display-vert-level-9dd71dc98a637e5aa2175e8149631e43e40265da)

sct_process_segmentation -i t2_seg.nii.gz -z 30:35 -perslice 1 -o csa_perslice.csv
--

Compute shape analysis: 100%|##############| 240/240 [00:01<00:00, 125.36iter/s]

Done! To view results, type:
xdg-open /home/joshua/repos/spinalcordtoolbox/data/sct_example_data/t2/csa_perslice.csv

image

Without this check, `aggregate_per_slice_or_level` will try to generate
vertebral level information on a nonexistent file.
@sandrinebedard
Copy link
Member Author

@joshuacwnewton I've tested it out and works fine on my side!

Copy link
Member

@joshuacwnewton joshuacwnewton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I think we can merge. :)

@sandrinebedard sandrinebedard merged commit 2d09af3 into master Jan 24, 2023
@joshuacwnewton joshuacwnewton deleted the sb/3113-display-vert-level branch February 6, 2023 18:39
valosekj added a commit to sct-pipeline/dcm-metric-normalization that referenced this pull request Feb 15, 2023
@joshuacwnewton joshuacwnewton added this to the 6.0 milestone Jul 13, 2023
@joshuacwnewton joshuacwnewton added the feature category: new functionality label Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature category: new functionality sct_process_segmentation context:
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display vertebral level when using -perslice 1 option
2 participants