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

sct_get_centerline: Use the new viewer #2035

Merged
merged 18 commits into from
Oct 9, 2018

Conversation

charleygros
Copy link
Member

sct_get_centerline currently uses sct_viewer.ClickViewerPropseg() instead of the new spinalcordtoolbox.gui.* viewer.

This Pull Request aims at integrating the new viewer into sct_get_centerline.

To test it, please run:

cd example_data/t2
sct_get_centerline -i t2.nii.gz -method viewer
sct_image -i t2.nii.gz -setorient SAL -o t2SAL.nii.gz
sct_get_centerline -i t2SAL.nii.gz -method viewer

This code was in sct_deepseg_sc --> I moved it in sct_get_centerline --> that s why both sct_deepseg_sc and sct_deepseg_lesion now called functions from sct_get_centerline.

To test it, please run:

cd example_data/t2
sct_deepseg_sc -i t2.nii.gz -c t2 -centerline viewer

This PR fixes the issue #1837.

@charleygros charleygros self-assigned this Oct 5, 2018
@jcohenadad jcohenadad changed the title sct_get_centerline -method viewer: use the new viewer sct_get_centerline: use the new viewer Oct 5, 2018
@jcohenadad jcohenadad added enhancement category: improves performance/results of an existing feature sct_get_centerline context: labels Oct 5, 2018
@jcohenadad jcohenadad added this to the v3.2.5 milestone Oct 5, 2018
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.

there is a weird bug (i think related to the centerline smoothing). To reproduce:

cd sct_example_data/t1/
sct_get_centerline -i t1.nii.gz -method viewer

results (tested on ba40d2f):
screen shot 2018-10-05 at 16 59 23

@charleygros
Copy link
Member Author

charleygros commented Oct 6, 2018

@jcohenadad : Thank you. I reproduced the bug, and I think it comes from this line:
https://github.com/neuropoly/spinalcordtoolbox/blob/master/scripts/sct_straighten_spinalcord.py#L159

I will investigate in this way.

UPDATE: In the commit 983a719, I reduced the nurbs_pts_number in the smoothing. It seems to fix it.

@jcohenadad
Copy link
Member

i still find issues if the number of points is too low (switches to hanning, but we don't know because verbose is set to False). For this PR, i would suggest to only introduce the new viewer, without perturbating too much the behaviour (which requires extensive testing on larger set of images). So i would suggest the following modifs:

  • set verbose to "verbose" (instead of 0) when calling smooth_centerline
  • set nurbs_pts_number=3000 (as was the case before)
  • use the same number of points & gap as before (was calculated based on max number of slices)
  • if not too much trouble, replace _from_viewerLabels_to_centerline by the already-existing sct_process_segmentation.extract_centerline (which does the same thing)

happy to help :-)

@charleygros
Copy link
Member Author

@jcohenadad: Thank you for your help.
The last commits do:

  • replace _from_viewerLabels_to_centerline by the already-existing sct_process_segmentation.extract_centerline
  • set verbose to "verbose" (instead of 0) when calling smooth_centerline in sct_process_segmentation.extract_centerline
  • use the same number of points & gap as before (calculated based on max number of slices)

I tested it on the example_data with the default param (gap=10) and it seems to work well.
Please let me know your thoughts



def viewer_centerline(image_input_reoriented, interslice_gap, verbose):
def _call_viewer_centerline(fname_in, interslice_gap=10):
Copy link
Member

Choose a reason for hiding this comment

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

i find it a bit too dense now, how about setting a compromise with interslice_gap=20?

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 agree!

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.

great contribution! I just made a minor comment about the default value for interslice_gap. Otherwise looks OK!

@charleygros
Copy link
Member Author

@jcohenadad: By increasing the default gap to 20.0mm, I observed 'not smooth centerline' again.
In the last commits, I proposed to increase the number of points used by the nurbs (3000 to 8000) --> looks much better. However it takes more time.

Another approach would be to leave gap=20 and nurbs_pts_number=3000 but to send a message to the user if: https://github.com/neuropoly/spinalcordtoolbox/blob/master/scripts/sct_straighten_spinalcord.py#L160
--> asking the user to decrease the gap used by the viewer.

@jcohenadad
Copy link
Member

@charleygros let's go with your latest commit. We definitely don't want to have an approach where a message is sent, asking the user to make a decision (99.99% of our users don't read the terminal output).

@charleygros charleygros merged commit a627117 into master Oct 9, 2018
@jcohenadad jcohenadad changed the title sct_get_centerline: use the new viewer sct_get_centerline: Use the new viewer Oct 16, 2018
@gmotzespina gmotzespina deleted the cg_sctGetCenterline_newViewer branch August 9, 2019 14:12
jcohenadad pushed a commit that referenced this pull request Dec 18, 2019
sct_get_centerline: use the new viewer

Former-commit-id: a627117
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement category: improves performance/results of an existing feature sct_get_centerline context:
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants