-
Notifications
You must be signed in to change notification settings - Fork 0
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
DWI mean SC seg #19
Comments
Okay, tested. The |
Resolved in 6787d06 |
I also tried contrast-agnostic v2.3, based on the recommendation from @naga-karthik:
Link to the data used. conda activate monai
~/code/contrast-agnostic-softseg-spinalcord
# v2.3
python monai/run_inference_single_image.py --path-img /Users/valosek/Downloads/sub-1860B6472B/dwi/sub-1860B6472B_ses-1860B_acq-ZOOMit_dir-AP_dwi_crop_crop_moco_dwi_mean.nii.gz --path-out /Users/valosek/Downloads/sub-1860B6472B/dwi/contrast_agnostic_v2.3 --chkp-path /Users/valosek/Downloads/model_soft_bin_20240410-1136
# v2.4
python monai/run_inference_single_image.py --path-img /Users/valosek/Downloads/sub-1860B6472B/dwi/sub-1860B6472B_ses-1860B_acq-ZOOMit_dir-AP_dwi_crop_crop_moco_dwi_mean.nii.gz --path-out /Users/valosek/Downloads/sub-1860B6472B/dwi/contrast_agnostic_v2.4 --chkp-path /Users/valosek/Downloads/nnunet_seed=50_ndata=7_ncont=9_pad=zero_nf=32_opt=adam_lr=0.001_AdapW_bs=2_20240425-170840/ The shift in the top slices is presented for all versions (v2.3, v2.3, SCT): |
Hey Jan! Before I start debugging this issue a bit deeper could you try the Basically from the command you posted above, the change would be:
Instead of zero padding this option does edge padding and in my internal experiments I have seen that this works slightly better for the top/bottom slices. Let me know how it goes! |
## Description Currently, test-time preprocessing transforms for the monai models (which, at the moment, is only the contrast-agnostic model), used zero-padding during cropping and padding as in [these lines](https://github.com/spinalcordtoolbox/spinalcordtoolbox/blob/master/spinalcordtoolbox/deepseg/monai.py#L176-L177). However, @valosekj observed that zero-padding DWI images from the `dcm-brno` dataset resulted in [shifted predictions](valosekj/dcm-brno#19 (comment)). Interestingly, the shifts were only observed in the initial and final slices, suggesting that this might be sub-optimal padding issue. I experimented with different padding options as test-time [here](sct-pipeline/contrast-agnostic-softseg-spinalcord#113 (comment)) and found that `edge`-padding fixed the issue with shifted predictions. Hence, this PR updates the default padding (which is zero padding) to `edge` padding. This change should not break anything as `edge` padding is at least as good as the zero-padding (so it is not risky to make it the default). Morever, I noticed that nnUNet has also started to (subtly) make `edge` padding the default, supporting the changes in this PR. --------- Co-authored-by: Joshua Newton <[email protected]>
Testing the contrast-agnostic model v2.4 after fixing the edge padding as part of SCT v6.4 on DWI mean images. I would say that the segmentations look relatively reasonable now! (of course, some minor manual corrections, especially at the compression levels, would be appropriate) @naga-karthik, @sandrinebedard, @jcohenadad, what do you think? |
It seems that there are no major issues with the When you tried |
Yes, you're right! I have the same feeling. I will perform manual correction of these segmentaions. Then we could use them for another iteration of the
Here is |
Indeed!
Agreed, good plan! |
Currently, I use the contrast-agnostic model to segment mean DWI image:
https://github.com/valosekj/dcm-brno/blob/main/02_processing_scripts/02_process_data.sh#L347-L348
This SC seg is consequently used to bring the template to DWI space:
https://github.com/valosekj/dcm-brno/blob/main/02_processing_scripts/02_process_data.sh#L353-L359
However, when debugging #18, I noticed that the contrast-agnostic segmentation is slightly shifted. So I tried
sct_deepseg_sc
and found out that it might actually provide a better segmentation:gif
TODO: compare
sct_deepseg_sc
andcontrast-agnostic
on more subjectsThe text was updated successfully, but these errors were encountered: