Skip to content
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

Help with training on segmenter.py #1

Open
js-kki opened this issue Sep 29, 2024 · 6 comments
Open

Help with training on segmenter.py #1

js-kki opened this issue Sep 29, 2024 · 6 comments

Comments

@js-kki
Copy link

js-kki commented Sep 29, 2024

Hello, I have run into trouble when attempting to use segmenter.py. I have axial volumes, (25x128x128), and attempted to use the pre-trained models in MU-Net-R to run segmenter.py on these scans. The outputs, when loaded in, contained zeroes except for ones at the bound indices. When attempting to add the --train flag, I wasn't sure how to incorporate all of my .nii files to train the model on, or if there were any validation samples around, and am unsure whether I need to modify anything regarding the folds/foldfiles. I feel as though I'm doing something wrong on the command line, but I'm unsure how to proceed. Any tips would be fantastic! I created a private repo with two axial .nii datasets if necessary.

@Hierakonpolis
Copy link
Owner

Hierakonpolis commented Sep 30, 2024

Could you please paste the command you are using and the directory tree of your dataset (e.g. tree command in bash) I would need a bit more information to understand what is missing for you to train the network.

@js-kki
Copy link
Author

js-kki commented Oct 3, 2024

Here are the scans that I was using: https://github.com/js-kki/KKI-MUNet/tree/main/scans

Here is the output of an attempt of running segmenter.py on one of the trained models: https://github.com/js-kki/KKI-MUNet/tree/main/segmentation_attempt1

Here are a few train commands I have tried to submit:
python3 segmenter.py --savefolder ./trained_models/ --train ./ multislice_image.nii test_1

python3 segmenter.py --savefolder ./trained_models/ --train --mask multislice_image_Mask.nii.gz, multislice_imageRE0972 --folds 2 ./ multislice_imageWM9986.nii EBmodVal_0

python3 segmenter.py --savefolder ./trained_models/ --train --mask multislice_image_Mask.nii.gz --folds 2 ./ multislice_imageWM9986.nii, multislice_imageRE0972 test_1

@Hierakonpolis
Copy link
Owner

So, files should be organized in different folders, so inside your root folder you would have something like:

dataset_root
--1
----scan.nii
----label1.nii.gz
----label2.nii.gz
----brain_mask.nii.gz
--2
----scan.nii
----label1.nii.gz
----label2.nii.gz
----brain_mask.nii.gz

Then you would train it with something like:

python3 segmenter.py /path/to/dataset_root scan.nii my_model --train --savefolder /path/to/my_trained_models --mask brain_mask.nii.gz --labels label1.nii.gz label2.nii.gz

If you are still experiencing issues please copy and paste any error messages you might be receiving and the actual folder structure in which your data is organized.

@js-kki
Copy link
Author

js-kki commented Oct 4, 2024

So, files should be organized in different folders, so inside your root folder you would have something like:

dataset_root
--1
----scan.nii
----label1.nii.gz
----label2.nii.gz
----brain_mask.nii.gz
--2
----scan.nii
----label1.nii.gz
----label2.nii.gz
----brain_mask.nii.gz

Then you would train it with something like:

python3 segmenter.py /path/to/dataset_root scan.nii my_model --train --savefolder /path/to/my_trained_models --mask brain_mask.nii.gz --labels label1.nii.gz label2.nii.gz

All I have is the scans, no mask or labels. The attempt of running segmenter without these is in the folder titled "segmentation_attempt1", and the output mask is unusable. Is it possible to run this without the mask/labels, or is it possible to extrapolate the mask and labels from your trained runs?

@Hierakonpolis
Copy link
Owner

Well, this is a supervised learning algorithm and you would need to retrain if for your dataset, so I'm afraid that without some labeled data this won't work. I do not have a set of weights for a model general enough to work on any given MRI dataset.

Something you could consider doing is to prepare manual labels for a small number of samples, e.g. 5, use that to label a larger dataset, refine manually, and repeat on more data. Whether this is worth it depends on your use case.

@js-kki
Copy link
Author

js-kki commented Oct 9, 2024

Thank you for the advice, I'll be sure to get back to you if I have further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants