ENHANCE-PET / MOOSE

MOOSE (Multi-organ objective segmentation) a data-centric AI solution that generates multilabel organ segmentations to facilitate systemic TB whole-person research.The pipeline is based on nn-UNet and has the capability to segment 120 unique tissue classes from a whole-body 18F-FDG PET/CT image.
https://enhance.pet
GNU General Public License v3.0
196 stars 28 forks source link

Feat: Bones segmentation #63

Closed afg-gatv closed 1 year ago

afg-gatv commented 1 year ago

First of all I would like to congratulate you for the amazing tool provided. I have been using v0.1 and now v2.0 and the improvements in usability and efficiency are very noticeable.

For my usage, I am mainly interested in the bone segmentation over CT images, specifically on spine segmentation. In previous version released v0.1, there is an output segmentation label for all bones (with internal labels) that was ideal for my purpose. Now in v2.0, there are two modes that work for bones which are "clin_ct_peripheral_bones", which does not include spine, and "clin_ct_vertebrae", that tries to segment every vertebrae separately. I tried the second model, the segmentations are very precised but several of the upper vertebae are not detected nor segmented, which is a major problem for my usage.

Is there any chance that you may include previous spine/bones segmentation model in v2.0?

Thanks a lot for your incredible work.

LalithShiyam commented 1 year ago

Hi @afg-gatv, many thanks for the kind words. Happy you like the new version. Also sorry about the split. We are currently trying to decide on an order and we are kind of in between due to logistical reasons. We promise that you will have things organized soon-ish. The good news is you can get all the goodies of moosev2 with the models of moosev1 if you have a Linux computer. Considering you used moosev1, I assume you have it. We have a particular version of moosev2 which runs both the models. So that you can bypass your current hiccup. Please create a new environment and follow the steps below.

[1] pip install moosez==2.2.8

[2] After the install, do the regular thing, but with one minute change in the model name:

For muscle and fat:

moosez -d <path_to_the_dir> -m clin_ct_fat_muscles_v1

This command will extract the fat and muscle for you using the old models

For bones:

moosez -d <path_to_the_dir> -m clin_ct_bones_v1

For organs

moosez -d <path_to_the_dir> -m clin_ct_organs_v2

This command will extract the usual organs using the latest models. Kindly Use the v1 bone models until we release a unified bone model in v2!

Hope it helps and happy to help you, Incase you have further issues! Happy moosing 🦌!

afg-gatv commented 1 year ago

Thanks a lot for the quick response and the bypass! It worked perfectly for Ubuntu 20.04.

I will use this implementation for now and will try to keep updated on your reseales!

LalithShiyam commented 1 year ago

Happy it worked out! Do hit us up, if you encounter further issues!

LalithShiyam commented 1 year ago

Hi @afg-gatv, we have an odd request; would it be possible to share the screenshot of the missed segments? So that we can see what really happened and fix it in the next version?

afg-gatv commented 1 year ago

For sure! Here you have a couple examples of 3D render outputs of the labels predicted, both of them seem to have issues within the same areas:

segmentation_1

segmentation_2

I hope this feedback help you as well.

LalithShiyam commented 1 year ago

Many thanks! @DariaFerrara @josefyu kindly have a look at this!

josefyu commented 1 year ago

Hello @afg-gatv , I am quite curious what the CT looks like, could you please help us with understanding this issue by providing the corresponding CT? My email is josef.yu@meduniwien.ac.at Thanks a lot

Keyn34 commented 1 year ago

@afg-gatv, we are training a new model and will let you know once it is done. Would you be able and interested to try it then to see if we could improve things? Thanks a ton in advance!

afg-gatv commented 1 year ago

Hello @josefyu , unfortunatelly I am not allowed to share the original CT images due to privacy restrictions of the project. I tried to replicate the problem with public data and the results were good enough. If it helps, I am working with patients that may have low density bones conditions, what could be affecting these results.

Replying also to @Keyn34 , anyways I would love to try your models and give you feedback with the images I am working with.

Feel free to reach me at afg.gatv@gmail.com

josefyu commented 1 year ago

@afg-gatv Thank you for the hint with the low density, this is greatly appreciated. :)

LalithShiyam commented 1 year ago

Hi @afg-gatv @mprires added the new model which we hope should do a better job. Would you be kind enough to try the latest version of moosez? All you need to do is pip install --upgrade moosez. We are not sure if it would do a great job, but we are hoping it generalizes well. We look forward to your response/evaluation!

We have attached our benchmark results, just for closure!

image

anaidasdfg commented 1 year ago

Hello @LalithShiyam!

I tried to run it as follows but keep having an error I cannot solve.

My data structure:

dataset/

S1/

CT.nii

S2/

CT.nii

I have just upgrade moosez in my conda moose-env (Python 3.9). I run the code by: moosez -d dataset -m clin_ct_vertebrae

And I have the error: [...] line 131 in postprocess predictec_image = file_utilities.get_files(output_dir. '.nii.gz')[0]' IndexError: list index out of range

In the data folder, the output folder is created and inside it there are 3 folders, "CT" one containing "CT_0000.nii.gz" file, which I think it may be the file loaded from the code.

Any idea of what is going wrong? Thank you

mprires commented 1 year ago

Hi @anaidasdfg do the other folders contain any files? If yes what are they named?

LalithShiyam commented 1 year ago

Hi @anaidasdfg, it's very hard to tell without the spit files. I think the prediction is not performed, from the top of my head, it can also be a python version error, as we need 3.9.2 (Requirement from the dask library which we use for chunking) or more... can you actually try it in python 3.9.2 or plus? Please clean up the folder and run it again in a 3.9.2 or + environment and let us know what happens...

Keyn34 commented 1 year ago

Hi @anaidasdfg, it seems like you summoned the three musketeers :)

I was not able to replicate your issue with a virtual environment running Python 3.10.12 and moosez version 2.2.35 I replicated the same folder structure as yours, with an S1 folder containing a CT.nii file. clin_ct_vertebrae model works fine for me.

I would love to take a look at it. Could you send us the data? Thanks!

anaidasdfg commented 1 year ago

Hi @mprires @LalithShiyam @Keyn34 , well noticed, my environment was 3.9. Now it is working properly with 3.10.

I am sorry to tell you that the new model is permorming similarly as the previous one, the segmentation of part of the vertebraes is missing.

image Screenshot from 2023-10-11 17-13-12

Thanks for your work again and for counting on me to validate it.

LalithShiyam commented 1 year ago

@anaidasdfg Haha, All good - we tried. How does the whole-vertebrae work with moosev1? is it the same? or it encompasses everything?

anaidasdfg commented 1 year ago

@LalithShiyam It actually works fine, it may not be so precise as moosev2 but it does not miss significative portions of the spine. For my purpuse it is enough :)

LalithShiyam commented 1 year ago

Fantastic, hit us up if you encounter further issues!