This repo contains the code to reproduce the results presented in our ISBI25 article (accepted)
- In
notebooks: simple code to generate our data for submission. - In
report: the final test inference data presented in the article. - In
slurms: some simple SLURM scripts to run clinica's t1 linear pipeline. - In
src: the code used to run our experiments - In
test: unit test for important, handmade, part of the code. cli.py: Python file containing the CLI to run our experiments..env_example: template to create your own .env file.
Inside the src folder, you will find :
commands: each file contain procedure to execute commands fromcli.py.dataset: one folder per dataset with associated dataset and datamodule definition. You will also find the base class to define new datasets.motion: this contain almost unmodified code from "Quantifying MR head motion in the Rhineland Study–A robust method for population cohorts". It is used to estimate motion.network: architecture definitions and base classes to define new networkstraining: lightning modules containing the logic for each training setting (pretraining, transfer learning and training from scratch). Also contains base class containing common logic that you can extend for your own setting.transforms: two files containing data pipeline to generate data (synthetic data) and load data for training.utils: some common utilities
All weights (pretrain, transfer and scratch) are available on Zenodo.
You need at least two dataset :
- One with clean volumes for synthetic data generation and pretraining
- One with quality control scores for transfer learning and training from scratch
You can follow our datasets definitions for your own, outside of the code, it just requires a file with a data field corresponding to the path between the root of your data directory and the volumes. You also want to have identifiers and labels but those can be configured.
If you define a new dataset, you will certainly need to replace the lightning datamodules used in our commands files.
Before launching any commands, make sure that your quality control score correspond to the num_classes variable define in the lightning logic for your task (see training), you can even make your own LightningModule for this purpose.
Once everything is in place, you can run :
python cli.py pretrain --max_epochs <num_epochs> --learning_rate <lr> --batch_size <batch_size> python cli.py train --max_epochs <num_epochs> --learning_rate <lr> --batch_size <batch_size> python cli.py transfer --pretrain_path <path to your pretrained model checkpoint> --max_epochs <num_epochs> --learning_rate <lr> --batch_size <batch_size>For every commands, you can use --help to get more information and personalize further.
Now that you have trained your model, you want to test them against test data. Again, before running any commands, check that the dataset used in the code are yours.
python cli.py test pretrain -d <path to a root directory containing checkpoint(s)>python cli.py test scratch -d <path to a root directory containing checkpoint(s)> python cli.py test transfer -d <path to a root directory containing checkpoint(s)>You will find every results in the report folder.
If you have access to a SLURM cluster, you can use the launch group of commands to automatically launch one SLURM jobs per seed. For more information check the commands define in cli.py or use --help.
If you have questions, comments you can send them to my email address bricout.charles@outlook.com. Please use a tag like "[motiondetector]" in the object of your mail.
We do not accept direct contribution as this repository should always correspond to our ISBI article. I encourage you to make a fork and email me if you need any help !
Not submitted yet