-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_blocked_flicker.py
executable file
·98 lines (82 loc) · 2.24 KB
/
run_blocked_flicker.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python3
"""
Run a blocked flickering checkerboard stimulus.
"""
import argparse
import subprocess
import os.path as op
def cli_parser():
"""
Parse command line arguments to generate a call to my LOVE flickering checkerboard experiment.
"""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"--on_blocksize",
type=float,
help="Duration of the ON block",
required=True,
)
parser.add_argument(
"--off_blocksize",
type=float,
help="Duration of the OFF block",
required=True,
)
parser.add_argument(
"--luminance", type=float, help="Maximum luminance for stimulus", default=0.8
)
parser.add_argument(
"--flicker", type=int, help="The flicker frequency in Hz", default=12
)
parser.add_argument("--tr", type=float, help="The TR in seconds", required=True)
parser.add_argument(
"--n_volumes", type=int, help="The number of repetitions", required=True
)
parser.add_argument(
"--offset",
type=int,
help="Offset in seconds to start experiment after 1st trigger",
default=14,
required=True
)
parser.add_argument(
"--sub_id",
type=str,
help="The subject ID. USE SAME AS IN SCANNER REGISTRATION.",
required=True
)
parser.add_argument(
"--run_id",
type=str,
help="The run ID. Use same name as the task in the protocol.",
required=True
)
parser.add_argument(
"--scalednoise",
type=int,
help="Whether to use scaled noise instead of a flickering checkerboard",
default=0
)
return parser
def run():
"""
Run love flicker with proper parameters.
"""
parser = cli_parser()
args = parser.parse_args()
cmd = [
"love",
op.join(op.dirname(__file__), "blocked-flicker"),
args.sub_id,
args.run_id,
str(args.on_blocksize),
str(args.off_blocksize),
str(args.luminance),
str(args.offset),
str(args.tr * args.n_volumes + 3),
str(args.flicker),
str(args.scalednoise)
]
subprocess.call(cmd)
if __name__ == "__main__":
run()