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

Adding a new method to ivadomed, intervertebral disc labeling #766

Open
rezazad68 opened this issue Apr 23, 2021 · 11 comments
Open

Adding a new method to ivadomed, intervertebral disc labeling #766

rezazad68 opened this issue Apr 23, 2021 · 11 comments

Comments

@rezazad68
Copy link
Collaborator

Hi,

Would appreciate your comments and guidance regarding the process for adding a new method to the ivadomed library. I am following the below steps:

1- Add model to the model.py
2- Add loss function to losses.py
3- Add metric to metrics.py
3- For training and evaluation, the main.py should revise?
4- weight files should be stored in which address?
Any further comments are welcome. Thanks in advance.

@andreanne-lemay
Copy link
Member

andreanne-lemay commented Apr 23, 2021

1-Sounds good!
2- and 3.1-: What type of loss and metric are you using? We might have something already implemented.
3.2- Since Lucas already implemented a model for vertebral labeling, I don't think you will need to modify the main (except if your model has special needs that we don't cover yet). Same for the loader. In what format is your GT (binary images or coordinates)? Currently, the loader only supports binary images that match the dimensions of the input image.
4- During the development phase, we usually keep the weights saved locally. Once you have your final model, the weights can be saved in the ivadomed organization under a specific repository created for your model. We usually create one repo per model (e.g., spinal cord segmentation model). During the training of your model, the folder containing the model and the config file will automatically be created and stored in the output path you specified in the config file: "path_output"/"model_name"

@charleygros
Copy link
Member

I agree with @andreanne-lemay !
The best way would probably be to start a pull request with your code and we'd be happy to guide you from there :-) Feel free to tag us wherever you have questions

@rezazad68
Copy link
Collaborator Author

The pose estimation method similar to the Countception approach uses the 2D images (mid slices) to train and evaluate the model. Thus, the config file uses the "T1w_mid". Since the ivadomed needs to be used by the end-user, I was wondering to know should I create a bash file to generate those samples (the user can easily run by address) or somehow include them in ivadomed?

@andreanne-lemay
Copy link
Member

Ideally, we want one command to run the whole process (preprocessing, loading, training) and want to avoid multiple manual steps. This being said, I am not sure to understand what preprocessing step you are referring to. Lucas wrote this python script to prepare the dataset for vertebral labeling "ivadomed/scripts/prepare_dataset_vertebral_labeling.py". Are you referring to this? If so, you can start by simply reusing / adapting this script to the needs of your model.

@rezazad68
Copy link
Collaborator Author

Yes, I am referring to Lucas's script. This script needs to be run separately before running the ivadomed command, that is my point. If it is fine I can go in the same direction.

@andreanne-lemay
Copy link
Member

Yes, this sounds like a good starting point!

@jcohenadad
Copy link
Member

@rezazad68 indeed, this "preparation script" will ultimately be incorporated by the calling function, e.g., SCT's code. So you don't need to worry about incorporating these preprocessing steps into ivadomed. As long as you document the steps to generate a model, this is all fine.

@rezazad68
Copy link
Collaborator Author

The ivadomed 2.7.4 source code doesn't have a resize transform, is there any specific reason for it?

@andreanne-lemay
Copy link
Member

There is a resample transformation that allows resizing the image (https://github.com/ivadomed/ivadomed/blob/master/ivadomed/transforms.py#L211).

@rezazad68
Copy link
Collaborator Author

Hi,
The training part is finished now. Now ivadomed uses the pose estimation technique to detect intervertebral disc labeling. Other parts will be done soon ...

image

Two generated gif files for the validation set.

sub-hamburg05__rec-mid_T1w__0
sub-oxfordFmrib10__rec-mid_T1w__0

@jcohenadad
Copy link
Member

Amazing! @rezazad68 could you please open a PR so we can comment on your changes.

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