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

-initz flag and label value correction #2641

Merged
merged 6 commits into from
Mar 24, 2020

Conversation

PaulBautin
Copy link
Member

@PaulBautin PaulBautin commented Mar 22, 2020

In the current implementation (b5d01bd), when specifying -initz, the value corresponds to the upper vertebral level whereas it should be the lower levels. E.g., Label 4 is interpreted as C4/C5 disc, whereas it should correspond to the C3/C4 disc.

The bug occurred when user used -initz flag but not when automatically finding c2c3 disc. This is because automatic c2c3 used the precedent label value convention (label value 2).

I've updated sct_label_vertebrae to use the new label value convention (label value 3).

However I've left vertebral_detection (core.py) use the precedent convention and shiftted it's init_disc value by one (should it be done in sct_label_vertebrae?). This could have for consequence to crash other programs still using the precedent convention.

DONE:
-No change in the usage
-modification in core.py: label value is shifted by one
-flag -initz takes correct label value
-C2_C3 automatic detection now takes label value 3
-Could the modification in core.py crash other scripts?

Fixes #2608

@@ -315,9 +315,6 @@ def main(args=None):
im_label.save(fname_labelz)
elif fname_initlabel:
import sct_label_utils
# subtract "1" to label value because due to legacy, in this code the disc C2-C3 has value "2", whereas in the
# recent version of SCT it is defined as "3". Therefore, when asking the user to define a label, we point to the
# new definition of labels (i.e., C2-C3 = 3).
sct_label_utils.main(['-i', fname_initlabel, '-add', '-1', '-o', fname_labelz])
Copy link
Member

Choose a reason for hiding this comment

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

to be consistent, if you remove the explanation you also need to remove the code that actually does the "minus one"

Copy link
Member Author

Choose a reason for hiding this comment

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

-I've changed sct_label_utils for Image(fname_initlabel).save(fname_labelz). It seems to work fine.
-Responding to second comment. vertebral_detection in core.py uses the precedent convention. Should I shift label value in core.py and see what happens or shift label value in sct_label_vertebrae

Copy link
Member

Choose a reason for hiding this comment

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

-I've changed sct_label_utils for Image(fname_initlabel).save(fname_labelz). It seems to work fine.

I don't see your change. Which commit are you referring to? But regardless, my point was that you should not do this "minus one" operation anymore (for the same reason you removed the comment)

Copy link
Member

Choose a reason for hiding this comment

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

-Responding to second comment. vertebral_detection in core.py uses the precedent convention. Should I shift label value in core.py and see what happens or shift label value in sct_label_vertebrae

I don't know which "second comment." you are referring to (there is only one comment in this thread). If you are referring to another post in this PR, a good habit within Github is to add a hyperlink to the post you are referring to.

@jcohenadad
Copy link
Member

Could the modification in core.py crash other scripts?

good question-- i guess we (incl. you) need to find out :-)

Copy link
Member

@jcohenadad jcohenadad left a comment

Choose a reason for hiding this comment

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

I've tried running 913c04a and noticed that the labeling below the specified z value is now wrong (see image below: C4 should be followed by C5, not C6):

Screen Shot 2020-03-23 at 4 24 57 PM

To reproduce:

sct_download_data -d sct_testing_data
cd sct_testing_data/t2
sct_propseg -i t2.nii.gz -c t2 -qc qc
sct_label_vertebrae -i t2.nii.gz -s t2_seg.nii.gz -c t2 -initz 34,4 -qc qc

Paul added 2 commits March 23, 2020 17:22
…fered in sct_label_vertebrae just before vertebral_detection

-the shift in option -initlabel has been supressed
Correction fname_labelz initialisation

Co-Authored-By: Julien Cohen-Adad <jcohen@polymtl.ca>
@jcohenadad
Copy link
Member

I've tested the following options and the script works as expected (i.e. no bug introduced by this PR):

 -initz <list of: int>
 -initcenter <int>
 -initlabel <file>

@jcohenadad jcohenadad merged commit 266bfc8 into spinalcordtoolbox:master Mar 24, 2020
@jcohenadad jcohenadad added bug category: fixes an error in the code sct_label_vertebrae context: labels Mar 24, 2020
@jcohenadad jcohenadad added this to the 4.2.3 milestone Mar 24, 2020
Copy link
Member Author

@PaulBautin PaulBautin left a comment

Choose a reason for hiding this comment

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

Program fails when using "initlabel" on "sct_label_vertebrae".
When "fname_labelz" takes "fname_initlabel" path, "isct_antsAppllyTransforms" does not find "labelz.nii.gz" anymore.

See error:
log-error-sct_label_vertebrae.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug category: fixes an error in the code sct_label_vertebrae context:
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Label value specified by -initz flag is shifted by one value
2 participants