-
Notifications
You must be signed in to change notification settings - Fork 1
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
Consider cropping around the spinal cord #37
Comments
I'm just adding that the SC segmentation does not work perfectly for PSIR/STIR images (i.e., contrasts with lesion masks). This should hopefully not be a problem as the SC segmentation will only be used for cropping. Here is a comment in which I investigated different settings for SC seg. Alternatively, we can bring T2w seg to PSIR/STIR, as done here. |
Just pushed the modifications on branch
Now when calling |
Cool progress, @plbenveniste! A few notes:
Note: All my notes are just for brainstorming; I am not discarding any ideas. |
Currently the cropping approach is exploratory. So we don't need a 'clean' pipeline with proper QC, manual correction, etc. Obviously, you want to make sure that the segmentation is "good enough", ie: works in >90% of your images (otherwise you could not conclude about the efficiency of cropping for model training). In order to assess this, you need QC. So that could be added in your function call: If segmentation does not work well (because of the anisotropic and sagittal orientation), then you might need to:
|
About using That being said, it might be OK to keep the seg/crop and upgraded version of nnunet conversion script as is (ie: with the crop option)-- however it needs to be documented. |
New script for segmentation of the spinal cord on an entire dataset: seg_dataset.py. Currently performing QC on the segmentations. |
However, there is still one problem: PSIR images tend to have bad segmentations with the lower slices of the volume having no segmentations. |
Cool trick! In the past, I used |
Interesting, I just tried terminal output$ cd ~/extrassd1/janvalosek/data/canproco/sub-edm143/ses-M0/anat
$ sct_propseg -i sub-edm143_ses-M0_PSIR.nii.gz -c t1 -o sub-edm143_ses-M0_PSIR_seg.nii.gz
--
Spinal Cord Toolbox (git-master-0204cfebce8a005dbb8d14768270135ea32839bc)
sct_propseg -i sub-edm143_ses-M0_PSIR.nii.gz -c t1
--
Image header specifies datatype 'int16', but array is of type 'float64'. Header metadata will be overwritten to use 'float64'.
Creating temporary folder (/tmp/sct_2023-07-21_14-32-50_propseg_vw16rmuy)
Image header specifies datatype 'int16', but array is of type 'float64'. Header metadata will be overwritten to use 'float64'.
Creating temporary folder (/tmp/sct_2023-07-21_14-32-50_optic-detect-centerline_sy406lrg)
Remove temporary files...
rm -rf /tmp/sct_2023-07-21_14-32-50_optic-detect-centerline_sy406lrg
Creating temporary folder (/tmp/sct_2023-07-21_14-32-52_propseg-centerline-optic_wuvdypvo)
/home/GRAMES.POLYMTL.CA/p118175/code/spinalcordtoolbox/bin/isct_propseg -t t1 -o /tmp/sct_2023-07-21_14-32-50_propseg_vw16rmuy -verbose -i /mnt/extrassd1/janvalosek/data/canproco/sub-edm143/ses-M0/anat/sub-edm143_ses-M0_PSIR.nii.gz -init-centerline /tmp/sct_2023-07-21_14-32-52_propseg-centerline-optic_wuvdypvo/centerline_optic.nii.gz -centerline-binary # in /mnt/extrassd1/janvalosek/data/canproco/sub-edm143/ses-M0/anat
mv /tmp/sct_2023-07-21_14-32-50_propseg_vw16rmuy/sub-edm143_ses-M0_PSIR_seg.nii.gz ./sub-edm143_ses-M0_PSIR_seg.nii.gz
mv /tmp/sct_2023-07-21_14-32-50_propseg_vw16rmuy/sub-edm143_ses-M0_PSIR_centerline.nii.gz ./sub-edm143_ses-M0_PSIR_centerline.nii.gz
Check consistency of segmentation...
Creating temporary folder (/tmp/sct_2023-07-21_14-33-21_propseg-check-segmentation_dqmgdz8e)
/tmp/sct_2023-07-21_14-33-21_propseg-check-segmentation_dqmgdz8e/tmp.segmentation.nii.gz
/tmp/sct_2023-07-21_14-33-21_propseg-check-segmentation_dqmgdz8e/tmp.centerline.nii.gz
Get data dimensions...
/tmp/sct_2023-07-21_14-33-21_propseg-check-segmentation_dqmgdz8e/tmp.segmentation_RPI_c.nii.gz
rm -rf /tmp/sct_2023-07-21_14-33-21_propseg-check-segmentation_dqmgdz8e
Copy header input --> output(s) to make sure qform is the same.
Image header specifies datatype 'float64', but array is of type 'uint8'. Header metadata will be overwritten to use 'uint8'.
Image header specifies datatype 'float64', but array is of type 'uint8'. Header metadata will be overwritten to use 'uint8'.
Done! To view results, type:
fsleyes sub-edm143_ses-M0_PSIR.nii.gz -cm greyscale sub-edm143_ses-M0_PSIR_seg.nii.gz -cm red -a 100.0 & |
I found the problem: |
Okay, $ sct_propseg -i sub-edm143_ses-M0_PSIR.nii.gz -c t1 -o $PWD/test/sub-edm143_ses-M0_PSIR_seg.nii.gz Could you please open an issue about this under SCT repo? |
Segmentation and cropping done. List of images to change
I noticed that some images were exactly the same between M0 and M12. Maybe that's an issue to look at ? None exhaustive list
The images which had a poor segmentation/cropping were replaced by their original nifti file.
|
Good catch! Can you please open a separate issue about that under this repo? We will have to contact the sites and figure out what happed. |
Do you mean that the Dice improved by 0.55 or that it has reached 0.55 with the cropped data? If the latter, what what the previous Dice score? |
Current best dice score is 0.55. Dice score was around 0.49 before cropping the images. |
Nota Bene: It seems that the segmentations include more segmentations when performed with On the left with Because we favor Recall over precision, we will run inference with |
very interesting observation. Tagging @naga-karthik @rohanbanerjee @tzebre |
Cropping around the spinal cord for training and inference could help with:
There are at least two approaches for cropping:
Related to #29
The text was updated successfully, but these errors were encountered: