neuropoly / totalspineseg

Robust Instance Segmentation of Vertebrae, Intervertebral Discs, Spinal Cord, and Spinal Canal in MRI Images Using nnU-Net and Iterative Algorithm.
13 stars 0 forks source link

Totalspineseg outputs do not have the same resolution as the input #59

Closed simonqueric closed 3 weeks ago

simonqueric commented 1 month ago

The outputs of totalspineseg are volumes and segmentation mask with an isotropic resolution of 1 mm. It would be better if the final output matched the resolution of the input MRI volume.

yw7 commented 1 month ago

Hi @simonqueric ,

Thank you for your suggestion; it's indeed a good point to discuss.

We output volumes and segmentation masks at 1 mm isotropic resolution to preserve detail and avoid information loss, following the same strategy as SynthSeg. If you'd like the final output to match your input MRI's resolution, you can run:

totalspineseg_transform_seg2image -i path/to/input -s path/to/output/step2_output -o path/to/step2_output_in_input_space
NathanMolinier commented 1 month ago

Maybe we should output a directory with the segmentations in the original space indeed. I think it is an important feature to add (people want an output that corresponds to their original data).

I'm not sure resampling the segmentation to the original space can be considered as a loss of information. If the input resolution is lower (worse resolution) than 1mm iso it means that we were the one that created information in the first place, and if it was higher (better resolution) it means that we lost information during the first resampling to 1mm iso.

yw7 commented 1 month ago

I'm not sure resampling the segmentation to the original space can be considered as a loss of information. If the input resolution is lower (worse resolution) than 1mm iso it means that we were the one that created information in the first place, and if it was higher (better resolution) it means that we lost information during the first resampling to 1mm iso.

I do not agree, Please see the original SynthSeg paper at https://doi.org/10.1016/j.media.2023.102789

image

jcohenadad commented 1 month ago

@yw7 as Nathan mentioned (and as Simon experienced, and as our >300 users will also experience), we expect the segmentation to be in the same voxel space as the input image. I've been interacting with hundreds of SCT users over the past years and I know that that's what they expect.

As for the lack of precision, if users want better precision in their output, then they should use better precision in their input (ie: they upsample their images before feeding them into totalspineseg)

yw7 commented 1 month ago

Maybe we should output a directory with the segmentations in the original space indeed. I think it is an important feature to add (people want an output that corresponds to their original data).

I like this idea to add another folders in output with the results in the output space. @jcohenadad could this also be a solution that accepted by the users and will not enforce trampling before using the model? We should also discuss what output folder to resample back to the input resolution, or all of them? We have to do it after the labeling algorithm as it rely on the canonical 1mm iso.

NathanMolinier commented 1 month ago

For now, I believe that we can just resample the final output after the labeling. We can discuss about the other folders during a meeting.

yw7 commented 1 month ago

For now, I believe that we can just resample the final output after the labeling. We can discuss about the other folders during a meeting.

We can open a pr for that, also need to see how it will impact the output in all other output folders like levels. Also we should add --iso parameters for inference script to outpt in 1mm iso space.

NathanMolinier commented 1 month ago

need to see how it will impact the output in all other output folders like levels.

Regarding the efficiency of the labeling, I plan to do an extensive comparison and validate the method using my benchmark. I will try to do it as soon as possible to add the results to the paper.

jcohenadad commented 1 month ago

@jcohenadad could this also be a solution that accepted by the users and will not enforce trampling before using the model?

I find it quite confusing from the user perspective. I anticipate some users will want to do things with their input image and segmentation in the wrong voxel space, they will have errors, and we will be the ones spending time with them on the SCT forum to explain what went wrong. Again, we should keep it simple. Segmentation should be in the same voxel space as the input.

yw7 commented 3 weeks ago

We merged a fix that will resample all outputs back to the input image unless --iso argument specified. Thank you for this important update! @simonqueric @jcohenadad Note You might need to run this to apply the last changes after pulling the last version:

rm -rf $TOTALSPINESEG_DATA/nnUNet/{exports,results}
python3 -m pip install -e $TOTALSPINESEG --upgrade