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_deepseg_sc, sct_deepseg_lesion: Allow to input image with one axial slice #2012

Merged
merged 10 commits into from
Sep 4, 2018

Conversation

charleygros
Copy link
Member

@charleygros charleygros commented Aug 27, 2018

Goal: Allow to input image with only one axial slice.

Issue: isct_spine_detect requires nz>1.

Solution: If nz==1, then ask the user to use -centerline cnn instead of -centerline svm (default).

To test:

cd sct_example_data/t2s
sct_crop_image -i t2s.nii.gz -dim 2 -start 2 -end 2 -o t2s_Z010.nii.gz
sct_deepseg_sc -i t2s_Z010.nii.gz -c t2s

Raises an error message:

Your image contains only one axial slice, please re-run the function using -centerline cnn.

Then,

sct_deepseg_sc -i t2s_Z010.nii.gz -c t2s -centerline cnn

Same for sct_deepseg_lesion.

Note that I have remove some duplicated code: The centerline detection is now done by a function in sct_deepseg_sc named find_centerline, which is called by sct_deepseg_lesion.

@charleygros charleygros self-assigned this Aug 27, 2018
@jcohenadad jcohenadad changed the title sct_deepseg_sc/lesion - Allow to input image with one axial slice sct_deepseg_sc, sct_deepseg_lesion: Allow to input image with one axial slice Aug 27, 2018
@@ -410,6 +416,68 @@ def heatmap2optic(fname_heatmap, lambda_value, fname_out, z_max, algo='dpdt'):
ctr_nii.save()


def find_centerline(algo, image_fname, path_sct, contrast_type, brain_bool, folder_output, remove_temp_files):

if algo == 'svm' and Image(image_fname).dim[2] > 1: # isct_spine_detect requires nz > 1
Copy link
Member

Choose a reason for hiding this comment

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

why not checking beforehand if the image is 2D, and if it is, duplicate the slice to create a 3D volume, then run the centerline detection, then crop back to 2D on the output centerline.
This will prevent from having an error with the default parameters if 2D image is input.

Copy link
Member Author

Choose a reason for hiding this comment

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

Excellent idea, thank you.
It is ready to be reviewed (commit #5d2f492).

@jcohenadad jcohenadad added this to the v3.2.5 milestone Sep 3, 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.

successfully tested on 3D and 2D data using default params 👍
I've run into a few bugs (#2015, #2016) which don't seem to be related to this PR, so we can merge this PR and address those issues in other PRs.

@charleygros charleygros merged commit c878a7b into master Sep 4, 2018
@gmotzespina gmotzespina deleted the cg_deepseg_oneslice branch August 9, 2019 14:12
jcohenadad pushed a commit that referenced this pull request Dec 18, 2019
sct_deepseg_sc, sct_deepseg_lesion: Allow to input image with one axial slice

Former-commit-id: c878a7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants