-
Notifications
You must be signed in to change notification settings - Fork 0
/
batch_tract_subcort_conn.py
executable file
·54 lines (36 loc) · 1.45 KB
/
batch_tract_subcort_conn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/python
import os
import sys
import glob
import argparse
from aparc12 import get_aparc12_cort_rois
from scai_utils import *
tractSegDir = "/users/cais/STUT/analysis/tractseg_aparc12/"
L2_DIR = "/users/cais/STUT/analysis/tract_subcort_conn"
allROIs = get_aparc12_cort_rois(lobe="all", bSpeech=False)
allROIs.sort()
if __name__ == "__main__":
ap = argparse.ArgumentParser(description="Batch run of tractography- and aparc12-based subcorticla-cortical connectivity analysis, by calling tract_seg.py and tract_subcort_conn.py")
ap.add_argument("scSeed", \
help="Subcortical seed (e.g., lh.Thalamus-Proper)")
if len(sys.argv) == 1:
ap.print_help()
sys.exit(0)
args = ap.parse_args()
check_dir(tractSegDir)
ds = glob.glob(os.path.join(tractSegDir, "S??"))
ds.sort()
sIDs = []
for (i0, t_fn) in enumerate(ds):
(t_path, t_sID) = os.path.split(t_fn)
sIDs.append(t_sID)
# === Check the existence of the subcortical seed mask file === %
scMask = os.path.join(L2_DIR, "%s_ccStop" % args.scSeed, \
"mask", "merged_mask_min_bin.nii.gz")
check_file(scMask)
for roi in allROIs:
for sID in sIDs:
saydo("tract_seg.py %s %s roiconn --roi %s --ccStop" % \
(sID, args.scSeed, roi))
saydo("tract_subcort_conn.py %s --ccstop --roi %s --mask %s" % \
(args.scSeed, roi, scMask))