Closed valosekj closed 1 month ago
TODO: compare
sct_deepseg_sc
andcontrast-agnostic
on more subjects
Okay, tested. The contrast-agnostic
seg is shifted at the superior part of the FOV for almost all subjects. --> switching to sct_deepseg_sc
in https://github.com/valosekj/dcm-brno/commit/6787d062202dc0e9043ee35f4bdfc782b65ee2ac
I also tried contrast-agnostic v2.3, based on the recommendation from @naga-karthik:
If possible, if you could try using the v2.3 model instead? The rationale is that between models v2.3 and v2.4, I added the canproco dataset and I remember that canproco had a lot of shifted segmentations in the GT.
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 edge
padding option when running inference from the model v2.4/v2.3 downloaded from the contrast-agnostic repository (i.e. not using SCT for inference)
Basically from the command you posted above, the change would be:
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/ --pad-mode edge
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!
Hey Naga! Thanks for the tip! I tried --pad-mode edge
, but the predictions are pretty much the same (the shift is still there).
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 contrast-agnostic
segmenations, but I notice that some slices are very slightly undersegmented. I am not sure if that's expected with DWI images because the cord/csf boundary is not that clear.
When you tried sct_deepseg_sc
, was it convincingly better than the contrast-agnostic
model?
but I notice that some slices are very slightly undersegmented
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 contrast-agnostic
training. @naga-karthik, what do you think?
When you tried sct_deepseg_sc, was it convincingly better than the contrast-agnostic model?
Here is sct_deepseg_sc
on the same subjects. Notice that sct_deepseg_sc
undersegments even more and struggles with capturing the compressed cord. I would say that the fixed contrast-agnostic
model is now consistently better!
Indeed! sct_deepseg_sc
is worse than contrast-agnostic
for these subjects!
I will perform manual correction of these segmentaions. Then we could use them for another iteration of the contrast-agnostic training. @naga-karthik, what do you think?
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 https://github.com/valosekj/dcm-brno/issues/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
![Kapture 2024-07-18 at 14 57 00](https://github.com/user-attachments/assets/e1a42322-a327-439c-951b-6dee049c5d58)TODO: compare
sct_deepseg_sc
andcontrast-agnostic
on more subjects