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
180 stars 28 forks source link

Let users know if environment variables are not loaded #42

Closed chris-clem closed 1 year ago

chris-clem commented 1 year ago

Is your feature request related to a problem? Please describe. If the environment variables are not loaded, MOOSE fails silently like so:

✔ Converted DICOM images in /home/user/Data/... to NIFTI
- Only CT data found in folder /home/user/Data/..., MOOSE will construct noncerebral tissue atlas (n=37) based on CT 
- Initiating CT segmentation protocols
- CT image to be segmented: /home/user/Data/...._0000\.nii\.gz                            
✔ Segmented abdominal organs from /home/user/Data/..._0000.nii.gz                                     
Traceback (most recent call last):                                                                                                                                                                                 
    File "/usr/local/bin/moose", line 131, in <module>
        ct_atlas = ie.segment_ct(ct_file[0], out_dir)                                                                                                                                                             
    File "/home/user/Code/MOOSE/src/inferenceEngine.py", line 78, in segment_ct                                                                                                                                        
        out_label = fop.get_files(out_dir, pathlib.Path(nifti_img).stem + '*')[0]                
IndexError: list index out of range

Describe the solution you'd like It would be nice to let the user know that the problem is that the nnUNet_raw_data_base, nnUNet_preprocessed, etc. env variables are not set.

LalithShiyam commented 1 year ago

Hi @chris-clem, great idea! On it. Would you be willing to test the patch, once it is done?

chris-clem commented 1 year ago

Nice! Sure, I can test it

chris-clem commented 1 year ago

Related to this: I don't know if adding the env variables to .bashrc is the best place to do it. Some users might use zsh and others might use nnUnet seperately.

I added a env_vars.sh file in the MOOSE repo dir that I source.

LalithShiyam commented 1 year ago

@chris-clem I have pushed a patch, can you do a git pull and check if the update helps with the request you have made? I am working on my potato laptop, which doesn't have MOOSE installed, so I cannot test it on my own. Many thanks for your suggestions and help - much appreciated!

LalithShiyam commented 1 year ago

@chris-clem : regarding the env_vars.sh, I like this solution. How do we do this? do you wanna make a PR request? or you want me to do this? I am fine with either :D!

chris-clem commented 1 year ago

I am running MOOSE on a large dataset at the moment. Will do it when the run is finsihed. Probably on Monday or Tuesday.

I will have a look at the env_var PR. Should not be too complicated.

LalithShiyam commented 1 year ago

Passt! I will await your PR 🎉, any help with managing the environment variables is highly appreciated 🙌🏽

LalithShiyam commented 1 year ago

Hi @chris-clem, I tested the patch, it seems to work on my end. Also I have released a new version. Closing this for now :D, keep me posted in case if it doesn't work in your end!