sct-pipeline / normative-metrics

Processing scripts for computation of qMRI metrics
MIT License
1 stars 0 forks source link

Allow extraction of any ROI/label using extract_normative_metrics.sh #6

Closed valosekj closed 3 years ago

valosekj commented 4 years ago

I am dealing with thought, if not extend extract_normative_metrics.sh script to allow extraction of qMRI metrics from arbitrary ROI/label based on PAM50 atlas. So far, the script allows extraction only following ROI: https://github.com/sct-pipeline/normative-metrics/blob/50b99e50810f0e22b9e43370cbd76e9d6b17dda2/scripts/extract_normative_metrics.sh#L36-L43

Requested ROIs/labels could be define inside yaml file and passed to the script as a input. User could choose from ROIs/labels based on PAM50 atlas:

List of labels in /usr/local/lib/sct_v4.3/data/PAM50/atlas/info_label.txt:
--------------------------------------------------------------------------------------
# White matter atlas. Generated on: 01-Sep-2016
#
# Keyword=IndivLabels (Please DO NOT change this line)
# ID, name, file
0, WM left fasciculus gracilis, PAM50_atlas_00.nii.gz
1, WM right fasciculus gracilis, PAM50_atlas_01.nii.gz
2, WM left fasciculus cuneatus, PAM50_atlas_02.nii.gz
3, WM right fasciculus cuneatus, PAM50_atlas_03.nii.gz
4, WM left lateral corticospinal tract, PAM50_atlas_04.nii.gz
5, WM right lateral corticospinal tract, PAM50_atlas_05.nii.gz
6, WM left ventral spinocerebellar tract, PAM50_atlas_06.nii.gz
7, WM right ventral spinocerebellar tract, PAM50_atlas_07.nii.gz
8, WM left rubrospinal tract, PAM50_atlas_08.nii.gz
9, WM right rubrospinal tract, PAM50_atlas_09.nii.gz
10, WM left lateral reticulospinal tract, PAM50_atlas_10.nii.gz
11, WM right lateral reticulospinal tract, PAM50_atlas_11.nii.gz
12, WM left spinal lemniscus (spinothalamic and spinoreticular tracts), PAM50_atlas_12.nii.gz
13, WM right spinal lemniscus (spinothalamic and spinoreticular tracts), PAM50_atlas_13.nii.gz
14, WM left spino-olivary tract, PAM50_atlas_14.nii.gz
15, WM right spino-olivary tract, PAM50_atlas_15.nii.gz
16, WM left ventrolateral reticulospinal tract, PAM50_atlas_16.nii.gz
17, WM right ventrolateral reticulospinal tract, PAM50_atlas_17.nii.gz
18, WM left lateral vestibulospinal tract, PAM50_atlas_18.nii.gz
19, WM right lateral vestibulospinal tract, PAM50_atlas_19.nii.gz
20, WM left ventral reticulospinal tract, PAM50_atlas_20.nii.gz
21, WM right ventral reticulospinal tract, PAM50_atlas_21.nii.gz
22, WM left ventral corticospinal tract, PAM50_atlas_22.nii.gz
23, WM right ventral corticospinal tract, PAM50_atlas_23.nii.gz
24, WM left tectospinal tract, PAM50_atlas_24.nii.gz
25, WM right tectospinal tract, PAM50_atlas_25.nii.gz
26, WM left medial reticulospinal tract, PAM50_atlas_26.nii.gz
27, WM right medial reticulospinal tract, PAM50_atlas_27.nii.gz
28, WM left medial longitudinal fasciculus, PAM50_atlas_28.nii.gz
29, WM right medial longitudinal fasciculus, PAM50_atlas_29.nii.gz
30, GM left ventral horn, PAM50_atlas_30.nii.gz
31, GM right ventral horn, PAM50_atlas_31.nii.gz
32, GM left intermediate zone, PAM50_atlas_32.nii.gz
33, GM right intermediate zone, PAM50_atlas_33.nii.gz
34, GM left dorsal horn, PAM50_atlas_34.nii.gz
35, GM right dorsal horn, PAM50_atlas_35.nii.gz
36, CSF contour, PAM50_atlas_36.nii.gz

# Combined labels
# Keyword=CombinedLabels (Please DO NOT change this line)
# ID, name, IDgroup
50, spinal cord, 0:35
51, white matter, 0:29
52, gray matter, 30:35
53, dorsal columns, 0:3
54, lateral funiculi, 4:13
55, ventral funiculi, 14:29
jcohenadad commented 4 years ago

Sounds like a good idea @valosekj

valosekj commented 4 years ago

👍 thanks, because no effective yaml parser exists in bash, I will rewrite the script into python.

valosekj commented 4 years ago

I have started to think about python implementation of extract_normative_metrics.sh and I realized that I call/run this script using sct_run_batch.py script to allow parallel run across whole multi-subject dataset. I am now not sure, if the sct_run_batch.py allows to run also python scripts. Because, in its help, only shell script is documented:

https://github.com/neuropoly/spinalcordtoolbox/blob/a52f725fc440edae1d1cbd687ca8c0443a25a6bc/scripts/sct_run_batch.py#L143-L144

jcohenadad commented 4 years ago

you could do something like this:

my_shell_script.sh ```bash #!/bin/bash python my_python_function.py ```
sct_run_batch -script my_shell_script.sh