The dog templates are created by using the Template framework.
- Data from VirginiaTech by Dr. Richard Shinn.
- The dataset has 5 subjects.
- T1w and T2w contrast images for all the subjects. The data is stored at:
data.neuro.polymtl.ca:datasets/template_dog_virginiatech
The raw dog data was first organised into the BIDS dataset format, which was then followed by the first pipline: Data Pre-processing
. The segmentation masks/centerlines and disc labels were obtained for each subject in the dataset. These derivatives were then provided to the preprocess_normalize.py
pipeline which generated more derivatives such as the straightened spinal cord, template space etc. Finally, these derivatives were provided as input to the second pipeline Template Creation
. The script generate_template.py
ran for the requested number of iterations and generated the final template.
Reproduce the T2w template
git clone https://github.com/spinalcordtoolbox/template-dog
cd template-dog
[If you are an external user, please open an issue regarding data access and we will get back to you.]
git clone git@data.neuro.polymtl.ca:datasets/template_dog_virginiatech
cd template_dog_virginiatech
git checkout b4be9769cb0474c14c38261777f97e52081dde4c
git annex get .
cd ..
git clone https://github.com/neuropoly/template
cd template
Spinal Cord Toolbox
, Scoop
installations have not been mentioned here, please go through the template repository for the setup.
Once the template
repository is setup, you are ready to the preprocessing pipeline in order to get the different derivatives such as straightened_spinalcord
and template space
which will be used for generating the templates in the next steps.
mv ./configuration_T1w.json .
mv ./configuration_T2w.json .
python preprocess_normalize.py configuration_T1w.json
python preprocess_normalize.py configuration_T2w.json
The above step should have generated all the required derivatives.
Login into the Digital Research Alliance of Canada (the Alliance) High-Performance Computer (HCP)
5.1. cd scratch
5.2. mkdir template-dog
5.3. cd template-dog
5.4. git clone https://github.com/neuropoly/template
Copy derivatives from the template_dog_virginiatech dataset to scratch. You can either use SCP or simply drag and drop.
5.5. cd template
5.6. Make changes to the subjects.csv path in the generate_template.py script. It is expected that to find the subjects.csv file inside derivatives/template
5.7. Make chnages to the path names in the subjects.csv
Alternatively, you also have the option to run the template generation pipeline on your local machine (note; This takes significantly more time that DRAC)
python generate_template.py
Please follow the dependency instructions to setup dependencies on DRAC from the template repository (Steps 2)
6.1. Create a template_pipeline.sh file
6.2. Copy paste the following into the above created file
#!/bin/bash
python -m scoop -vvv generate_template.py
6.3. sbatch --time=24:00:00 --mem-per-cpu 4000 template_pipeline.sh
r20240702
, use all the 5 subjects and change the template generation parameters in generate_template.py
with the below values:
'symmetric': True,
'protocol': [{'iter': 3, 'level': 8},
{'iter': 3, 'level': 4},
{'iter': 3, 'level': 2},
{'iter': 3, 'level': 1},
{'iter': 3, 'level': 0.5}],
'refine': True
Inside the template folder, you are expected to find a model_n_all
folder in which the tem,plate iterations are saved. After the pipeline has finished running, the .mnc
file needs to be converted to .nii
format in order to get the final template. The pipeline would give outputs with the name: avg.XXX.mnc, where XXX
is the nth iteration. To convert it to the .nii
format, run the following command:
mnc2nii PATH_TO/avg.XXX.mnc PATH_TO/template_XXX.nii
We picked sub-HarshmanDobby
as an example.
[with internal data access] Required data is at the data.neuro.polymtl.ca:datasets/template_dog_virginiatech
repository under the rb/update_HB
branch
[with no internal data access] Please download the below data, with only sub-HarshmanDobby and its derivatives (contains no sensitive information) reg_to_temp_bids.zip
- Protocol to segment the spinal cord of the sub-HarshmanDobby
Command used : sct_deepseg_sc -i sub-HarshmanDobby_T2w.nii.gz -c t2 -o sub-HarshmanDobby_T2w_label-SC_seg_initial.nii.gz
Manual correction was done by Rohan Banerjee on the output from sct_deepseg_sc and the final segmentation file was renamed.
Renaming: sub-HarshmanDobby_T2w_label-SC_seg_initial.nii.gz --> sub-HarshmanDobby_T2w_label-SC_seg.nii.gz
- Protocol to get the disc labels (manual labeling)
sct_label_utils -i sub-HarshmanDobby_T2w.nii.gz -create-viewer 1:24 -o sub-HarshmanDobby_T2w_labels-disc.nii.gz
The following steps were done for the registration to the template:
sct_register_to_template -i sub-HarshmanDobby_T2w.nii.gz -s sub-HarshmanDobby_T2w_label-SC_seg.nii.gz -ldisc sub-HarshmanDobby_T2w_labels-disc.nii.gz -t <PATH_TO_TEMPLATE_PARENT_FOLDER> -c t2 -s-template-id 2 -param step=1,type=seg,algo=centermassrot:step=2,type=im,algo=syn,metric=CC,iter=3 -ofolder HB_to_temp -qc qc_HB_to_temp
QC report qc_HB_to_temp.zip