Skip to content

Commit

Permalink
Merge branch 'main' into um/model_image_readme
Browse files Browse the repository at this point in the history
  • Loading branch information
uzaymacar committed Jan 16, 2022
2 parents 812ca89 + c35bde1 commit dd6aefe
Showing 1 changed file with 62 additions and 9 deletions.
71 changes: 62 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This repository contains two models, one for spinal cord (SC) segmentation and o
## Dependencies

- [SCT](https://spinalcordtoolbox.com/) commit: 7fd2ea718751dd858840c3823c0830a910d9777c
- [ivadomed](https://ivadomed.org) commit: XXX
- [ivadomed](https://ivadomed.org) commit: git-master-93ba03df76d229d8a190c694f757da6c00efa545

## Clone this repository

Expand All @@ -20,25 +20,78 @@ git clone https://github.com/ivadomed/model_seg_ms_mp2rage.git

## Get the data

- data.neuro.polymtl.ca:basel-mp2rage
- Commit: 88c506eb9855d6a0cb29a2e95c3283b8fd0a8099
- [email protected]:datasets/basel-mp2rage
- Commit: 93110d8ebb65398dcc6e4528bf548eb7828332f1

### Example calls to get the data

~~~
git clone [email protected]:datasets/basel-mp2rage
cd basel-mp2rage
git annex get .
cd ..
~~~

## Prepare the data

The data need to be preprocessed before training. The preprocessing command is:

~~~
sct_run_batch -script <PATH_TO_REPOSITORY>/preprocessing/preprocess_data.sh -path-data <PATH_TO_DATA>/basel-mp2rage/ -path-output <PATH_OUTPUT> -jobs <JOBS>
sct_run_batch -script <PATH_TO_REPOSITORY>/preprocessing/preprocess_data.sh -path-data <PATH_TO_DATA>/basel-mp2rage/ -path-output basel-mp2rage-preprocessed -jobs <JOBS>
~~~

This command will create a `data_processed_scseg` folder for the SC segmentation task and a
`data_processed_lesionseg` folder for the lesion segmentation task inside the `<PATH_OUTPUT>`
`data_processed_lesionseg` folder for the lesion segmentation task inside the `basel-mp2rage-preprocessed`
you specified. Each of these two folders contain only the required files for their respective task.

After running the preprocessing, you can also run the quality-control (QC) script:
```
python preprocessing/qc_preprocess.py -s <PATH_OUTPUT>
python preprocessing/qc_preprocess.py -s basel-mp2rage-preprocessed
```
which i) logs resolutions and sizes for each subject image (both raw and cropped) for data exploration,
ii) performs basic shape checks for spinal cord (SC) cropped images and ground-truths (GTs), and
most importantly iii) checks if the dilated SC mask leaves out any lesions from the GT of each rater.

## Training

Spinal cord segmentation training was carried out with
```
ivadomed --train -c config/seg_sc.json
```

Lesion segmentation training was carried out with
```
ivadomed --train -c config/seg_lesion.json
```

## Get trained models

```
cp -r ~/duke/temp/uzay/saved_models_basel/seg_sc_output .
cp -r ~/duke/temp/uzay/saved_models_basel/seg_lesion_output .
```

## Performance evaluation

To test a spinal cord segmentation model run
```
ivadomed --test -c config/seg_sc.json
```

To test a lesion segmentation model independently on the two rater's annotations
```
ivadomed --test -c config/test_on_rater1.json
ivadomed --test -c config/test_on_rater2.json
```

## Segment a dataset

To run inference with spinal cord segmentation model on a dataset run
```
ivadomed --segment -c config/seg_sc.json --path-data <PATH_DATA>
```

To run inference with lesion segmentation model on a dataset run
```
ivadomed --segment -c config/seg_lesion.json --path-data <PATH_DATA>
```
which i) logs resolutions and sizes for each SC-cropped subject image for data exploration,
ii) performs basic shape checks for SC-cropped images and ground-truths (GTs), and most importantly
iii) checks if the dilated spinal-cord (SC) mask leaves out any lesions from the GT of each rater.

0 comments on commit dd6aefe

Please sign in to comment.