-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript_process_batch.py
More file actions
76 lines (65 loc) · 2.89 KB
/
script_process_batch.py
File metadata and controls
76 lines (65 loc) · 2.89 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""Scripts to run oscillation mapping pipeline in batches."""
import glob
import importlib
import logging
import os
import pdb
from absl import app, flags
from main import oscillation_mapping_readin, oscillation_mapping_reconstruction
FLAGS = flags.FLAGS
flags.DEFINE_string("cohort", "healthy", "cohort folder name in config folder")
CONFIG_PATH = "config/"
def main(argv):
"""Run the oscillation imaging pipeline in multiple subjects.
Import the config file and run the oscillation imaging pipeline on all
subjects specified in by the cohort flag.
"""
if FLAGS.cohort == "healthy":
subjects = glob.glob(os.path.join(CONFIG_PATH, "healthy", "*py"))
elif FLAGS.cohort == "cteph":
subjects = glob.glob(os.path.join(CONFIG_PATH, "cteph", "*py"))
elif FLAGS.cohort == "ild":
subjects = glob.glob(os.path.join(CONFIG_PATH, "ild", "*py"))
elif FLAGS.cohort == "tyvaso":
subjects = glob.glob(os.path.join(CONFIG_PATH, "tyvaso", "*py"))
elif FLAGS.cohort == "jupiter":
subjects = glob.glob(os.path.join(CONFIG_PATH, "jupiter", "*py"))
elif FLAGS.cohort == "all":
subjects = glob.glob(os.path.join(CONFIG_PATH, "healthy", "*py"))
subjects += glob.glob(os.path.join(CONFIG_PATH, "cteph", "*py"))
subjects += glob.glob(os.path.join(CONFIG_PATH, "ild", "*py"))
subjects += glob.glob(os.path.join(CONFIG_PATH, "tyvaso", "*py"))
elif "-" in FLAGS.cohort:
cohorts = FLAGS.cohort.split("-")
subjects = []
for cohort in cohorts:
if cohort == "healthy":
subjects += glob.glob(os.path.join(CONFIG_PATH, "healthy", "*py"))
elif cohort == "cteph":
subjects += glob.glob(os.path.join(CONFIG_PATH, "cteph", "*py"))
elif cohort == "ild":
subjects += glob.glob(os.path.join(CONFIG_PATH, "ild", "*py"))
elif cohort == "tyvaso":
subjects += glob.glob(os.path.join(CONFIG_PATH, "tyvaso", "*py"))
else:
raise ValueError("Invalid cohort name")
else:
raise ValueError("Invalid cohort name")
for subject in subjects:
config_obj = importlib.import_module(
name=subject[:-3].replace("/", "."), package=None
)
config = config_obj.get_config()
logging.info("Processing subject: %s", config.subject_id)
if FLAGS.force_recon:
oscillation_mapping_reconstruction(config)
elif FLAGS.force_readin:
oscillation_mapping_readin(config)
elif config.processes.oscillation_mapping_reconstruction:
oscillation_mapping_reconstruction(config)
elif config.processes.oscillation_mapping_readin:
oscillation_mapping_readin(config)
else:
pass
if __name__ == "__main__":
app.run(main)