-
Notifications
You must be signed in to change notification settings - Fork 1
/
Snakefile
303 lines (247 loc) · 12.8 KB
/
Snakefile
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
import os, glob
MODEL_DIR = 'code/striatal_model'
ANALYSIS_DIR = 'code/analysis'
DATA_PATH = 'data/'
THREADS = range(9)
EXPERIMENTS = [os.path.basename(f) for f in glob.glob('code/striatal_model/experiments/*')]
SLIDING_EXPERIMENTS = ["no_stim.yaml", "bilateral_D1.yaml", "bilateral_D2.yaml", "sequencesd1d2.yaml"]
SEQ_MULT_EXPERIMENTS = ["sequences.yaml", "sequencesd2.yaml", "sequencesd1d2.yaml"]
TRIALS = range(5)
SINGLE_TRIALS = range(1)
wildcard_constraints:
hemi="[a-z]+",
trial="[0-9]",
fn="^((?!-).)*",
rule all:
input:
"figs/competingActions.yaml/competing_traces_left.pdf",
"figs/competingActions.yaml/competing_traces_right.pdf",
"figs/competingActions.yaml/competing_traces.pdf",
"figs/competingActions.yaml/competing_corr_left.pdf",
"figs/competingActions.yaml/competing_corr_right.pdf",
"figs/competingActionsNoD2Conn.yaml/competing_traces_left.pdf",
"figs/competingActionsNoD2Conn.yaml/competing_traces_right.pdf",
"figs/competingActionsNoD2Conn.yaml/competing_traces.pdf",
"figs/competingActionsNoD2Conn.yaml/competing_corr_left.pdf",
"figs/competingActionsNoD2Conn.yaml/competing_corr_right.pdf",
'figs/competingActions.yaml/competing_corr_change_within_go_left_left.pdf',
'figs/competingActions.yaml/competing_corr_change_within_go_right_right.pdf',
'figs/competingActions.yaml/competing_corr_change_between_D1D1_left.pdf',
'figs/competingActions.yaml/competing_corr_change_between_D2D2_right.pdf',
expand('figs/{experiments}/corr_sliding_left.pdf', experiments=SLIDING_EXPERIMENTS),
expand('figs/{experiments}/corr_sliding_right.pdf', experiments=SLIDING_EXPERIMENTS),
expand("figs/{experiments}/new_corr_with_stim_left.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/new_corr_with_stim_right.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/new_corr_with_bckgrnd_left.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/new_corr_with_bckgrnd_right.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/corr_left.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/corr_right.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/trajectory.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/raster_plot_left_hemisphere.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/raster_plot_right_hemisphere.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/hist_left.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/hist_right.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/hist_left_3x3.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/hist_right_3x3.pdf", experiments=EXPERIMENTS),
expand("figs/{experiments}/changeAct.pdf", experiments=SEQ_MULT_EXPERIMENTS),
'figs/withGabaAntagonistDoughnut.yaml/gabaAntagonistEffectleft.pdf',
'figs/withGabaAntagonistDoughnut.yaml/gabaAntagonistEffectright.pdf',
rule clean:
shell:
"""
rm -r {}* {}*
""".format(DATA_PATH, "data_long/")
rule cleanFigs:
shell:
"""
echo Do you really have to delete \*all\* figures\? Think about it, it will take hours to run again.. \(y/N\);
read decision;
if [ "$decision" = "y" ]; then
find . -name '*.pdf' -type f -delete
else
echo \"Good decision!\"
fi
"""
rule plot_competing_change_CC:
input:
'data_long/competingActions.yaml/competing_corr_{hemi}.json',
'data_long/competingActionsNoD2Conn.yaml/competing_corr_{hemi}.json',
output:
'figs/{experiment}/competing_corr_change_within_go_left_{hemi}.pdf',
'figs/{experiment}/competing_corr_change_within_go_right_{hemi}.pdf',
'figs/{experiment}/competing_corr_change_between_D1D1_{hemi}.pdf',
'figs/{experiment}/competing_corr_change_between_D2D2_{hemi}.pdf',
run:
shell('ipython -c "%run code/analysis/plot_competing_correlations_change.py {input} {output}"')
rule plot_competing_traces:
input:
expand('data/{{experiment}}/{trial}/left_hemisphere.gdf', trial=SINGLE_TRIALS),
expand('data/{{experiment}}/{trial}/right_hemisphere.gdf', trial=SINGLE_TRIALS),
expand('data/{{experiment}}/{trial}/neuron_ids_left_hemisphere.json', trial=SINGLE_TRIALS),
expand('data/{{experiment}}/{trial}/neuron_ids_right_hemisphere.json', trial=SINGLE_TRIALS),
'code/striatal_model/experiments/{experiment}',
output:
'figs/{experiment}/competing_traces.pdf',
run:
shell('ipython -c "%run code/analysis/plot_competing_traces.py {input} {output}"')
rule plot_competing_CC:
input:
expand('data_long/{{experiment}}/{trial}/{{hemi}}_hemisphere.gdf', trial=TRIALS),
expand('data_long/{{experiment}}/{trial}/neuron_ids_{{hemi}}_hemisphere.json', trial=TRIALS),
'code/striatal_model/experiments/{experiment}',
output:
'figs/{experiment}/competing_traces_{hemi}.pdf',
'figs/{experiment}/competing_corr_{hemi}.pdf',
'data_long/{experiment}/competing_corr_{hemi}.json',
run:
shell('ipython -c "%run code/analysis/plot_competing_correlations.py {input} {wildcards.hemi} {output}"')
rule plot_sliding_CC:
input:
expand('data/{{experiment}}/{trial}/{{hemi}}_hemisphere.gdf', trial=TRIALS),
expand('data/{{experiment}}/{trial}/neuron_ids_{{hemi}}_hemisphere.json', trial=TRIALS),
'code/striatal_model/experiments/{experiment}',
output:
'figs/{experiment}/corr_sliding_{hemi}.pdf',
run:
shell('ipython -c "%run code/analysis/plot_sliding_correlations.py {input} {wildcards.hemi} {output}"')
rule plot_mean_act_CC:
input:
expand('data_long/{{experiment}}/{trial}/{{hemi}}_hemisphere.gdf', trial=SINGLE_TRIALS),
expand('data_long/{{experiment}}/{trial}/neuron_ids_{{hemi}}_hemisphere.json', trial=SINGLE_TRIALS),
'code/striatal_model/experiments/{experiment}',
output:
'figs/{experiment}/corr_mean_activity_{hemi}.pdf',
run:
shell('ipython -c "%run code/analysis/plot_mean_activity_correlations.py {input} {wildcards.hemi} {output}"')
rule plot_CC:
input:
expand('data_long/{{experiment}}/{trial}/{{hemi}}_hemisphere.gdf', trial=SINGLE_TRIALS),
expand('data_long/{{experiment}}/{trial}/neuron_ids_{{hemi}}_hemisphere.json', trial=SINGLE_TRIALS),
'code/striatal_model/experiments/{experiment}',
output:
'figs/{experiment}/corr_{hemi}.pdf',
run:
shell('ipython -c "%run code/analysis/plot_correlations.py {input} {wildcards.hemi} {output}"')
rule new_plot_CC_grid:
threads: 1
input:
expand('data_long/{{experiment}}/{trial}/{{hemi}}_hemisphere.gdf', trial=SINGLE_TRIALS),
expand('data_long/{{experiment}}/{trial}/neuron_ids_{{hemi}}_hemisphere.json', trial=SINGLE_TRIALS),
'code/striatal_model/experiments/{experiment}',
output:
'figs/{experiment}/new_corr_with_stim_{hemi}.pdf',
'figs/{experiment}/new_corr_with_bckgrnd_{hemi}.pdf',
run:
shell('ipython -c "%run code/analysis/plot_correlations_gridnew.py {input} {wildcards.hemi} {output}"')
rule plot_CC_grid:
input:
expand('data_long/{{experiment}}/{trial}/{{hemi}}_hemisphere.gdf', trial=SINGLE_TRIALS),
expand('data_long/{{experiment}}/{trial}/neuron_ids_{{hemi}}_hemisphere.json', trial=SINGLE_TRIALS),
'code/striatal_model/experiments/{experiment}',
output:
'figs/{experiment}/corr_with_stim_{hemi}.pdf',
'figs/{experiment}/corr_bw_stim_{hemi}.pdf',
'figs/{experiment}/corr_with_bckgrnd_{hemi}.pdf',
'figs/{experiment}/corr_bw_bckgrnd_{hemi}.pdf',
run:
shell('ipython -c "%run code/analysis/plot_correlations_grid.py {input} {wildcards.hemi} {output}"')
rule plot_trajectories:
input:
expand('data/{{experiment}}/{trial}/odom.bag', trial=SINGLE_TRIALS),
expand('data/{{experiment}}/{trial}/left_hemisphere.gdf', trial=SINGLE_TRIALS),
expand('data/{{experiment}}/{trial}/right_hemisphere.gdf', trial=SINGLE_TRIALS),
expand('data/{{experiment}}/{trial}/neuron_ids_left_hemisphere.json', trial=SINGLE_TRIALS),
expand('data/{{experiment}}/{trial}/neuron_ids_right_hemisphere.json', trial=SINGLE_TRIALS),
'code/striatal_model/experiments/{experiment}',
output:
'figs/{experiment}/trajectory.pdf',
run:
shell('ipython -c "%run code/analysis/trajectory_plotter.py {input} {output}"')
rule plot_activityChange:
input:
expand('data/{{experiment}}/{trial}/left_hemisphere.gdf', trial=TRIALS),
expand('data/{{experiment}}/{trial}/right_hemisphere.gdf', trial=TRIALS),
expand('data/{{experiment}}/{trial}/neuron_ids_left_hemisphere.json', trial=TRIALS),
expand('data/{{experiment}}/{trial}/neuron_ids_right_hemisphere.json', trial=TRIALS),
'code/striatal_model/experiments/{experiment}',
output:
'figs/{experiment}/changeAct.pdf',
run:
shell('ipython -c "%run code/analysis/plot_activity_change.py {input} {output}"')
rule plot_gaba_antagonist_effect:
input:
expand('data/withGabaAntagonistDoughnut.yaml/{trial}/{{hemi}}_hemisphere.gdf', trial=TRIALS),
expand('data/withoutGabaAntagonistDoughnut.yaml/{trial}/{{hemi}}_hemisphere.gdf', trial=TRIALS),
expand('data/withoutGabaAntagonistDoughnut.yaml/{trial}/neuron_ids_{{hemi}}_hemisphere.json', trial=TRIALS),
'code/striatal_model/experiments/withGabaAntagonistDoughnut.yaml',
'code/striatal_model/experiments/withoutGabaAntagonistDoughnut.yaml',
expand('data/withGabaAntagonistExp.yaml/{trial}/{{hemi}}_hemisphere.gdf', trial=TRIALS),
expand('data/withoutGabaAntagonistExp.yaml/{trial}/{{hemi}}_hemisphere.gdf', trial=TRIALS),
expand('data/withoutGabaAntagonistExp.yaml/{trial}/neuron_ids_{{hemi}}_hemisphere.json', trial=TRIALS),
'code/striatal_model/experiments/withGabaAntagonistExp.yaml',
'code/striatal_model/experiments/withoutGabaAntagonistExp.yaml',
output:
'figs/withGabaAntagonistDoughnut.yaml/gabaAntagonistEffect{hemi}.pdf',
run:
shell('ipython -c "%run code/analysis/plot_gaba_antagon_effect.py {input} {output}"')
rule concat_gdf:
input:
expand('{{fn}}-{threads}.gdf', threads=THREADS),
output:
'{fn}.gdf',
run:
shell('cat {wildcards.fn}-* > {wildcards.fn}.gdf')
rule plot_histogram:
input:
expand('data/{{experiment}}/{trial}/{{hemi}}_hemisphere.gdf', trial=SINGLE_TRIALS),
output:
'figs/{experiment}/hist_{hemi}.pdf',
run:
shell('ipython -c "%run code/analysis/plot_histogram.py {wildcards.experiment} {wildcards.hemi} {output}"')
rule plot_histogram3x3:
input:
expand('data/{{experiment}}/{trial}/{{hemi}}_hemisphere.gdf', trial=SINGLE_TRIALS),
output:
'figs/{experiment}/hist_{hemi}_3x3.pdf',
run:
shell('ipython -c "%run code/analysis/plot_histogram_3x3.py {wildcards.experiment} {wildcards.hemi} {output}"')
rule plot_raster:
input:
expand('data/{{experiment}}/{trial}/{{hemi}}_hemisphere.gdf', trial=SINGLE_TRIALS),
expand('data_long/{{experiment}}/{trial}/neuron_ids_{{hemi}}_hemisphere.json', trial=SINGLE_TRIALS),
output:
'figs/{experiment}/raster_plot_{hemi}_hemisphere.pdf',
run:
shell('python code/analysis/plot_raster.py {input} {output}')
rule run_experiment:
threads: 48
input:
'code/striatal_model/experiments/{experiment}',
output:
'data/{experiment}/{trial}/odom.bag',
expand('data/{{experiment}}/{{trial}}/left_hemisphere-{thread}.gdf', thread=THREADS),
expand('data/{{experiment}}/{{trial}}/right_hemisphere-{thread}.gdf', thread=THREADS),
'data/{experiment}/{trial}/neuron_ids_left_hemisphere.json',
'data/{experiment}/{trial}/neuron_ids_right_hemisphere.json',
params:
'prefix = {experiment}',
'scale = 1.',
'trial = {trial}',
run:
shell('cd {dir}; python launch_trial.py {params}', dir=MODEL_DIR)
rule run_experiment_long:
threads: 48
input:
'code/striatal_model/experiments/{experiment}',
output:
'data_long/{experiment}/{trial}/odom.bag',
expand('data_long/{{experiment}}/{{trial}}/left_hemisphere-{thread}.gdf', thread=THREADS),
expand('data_long/{{experiment}}/{{trial}}/right_hemisphere-{thread}.gdf', thread=THREADS),
'data_long/{experiment}/{trial}/neuron_ids_left_hemisphere.json',
'data_long/{experiment}/{trial}/neuron_ids_right_hemisphere.json',
params:
'prefix = {experiment}',
'scale = 10.',
'trial = {trial}',
run:
shell('cd {dir}; python launch_trial.py {params}', dir=MODEL_DIR)