-
Notifications
You must be signed in to change notification settings - Fork 0
/
move_completed_subjects.py
68 lines (59 loc) · 2.23 KB
/
move_completed_subjects.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
"""
Small script that moves the final results of the subjects
For safekeeping and backup reasons.
"""
import click
import shutil
import os
import pandas as pd
import numpy as np
@click.command(
help="Move the results folder to create a backup on the desired folder ."
)
@click.option("--pip_csv", type=click.STRING, help="csv with the completed pipeline")
@click.option(
"--out_dir",
type=click.STRING,
help="Directory where we will store the results. Each subject would have a subdirectory",
)
@click.argument("ind_dir")
def move_completed_subjects(ind_dir, pip_csv, out_dir):
df_pipeline = pd.read_csv(pip_csv)
for row in df_pipeline.itertuples():
subID = row.id
type_dir = row.CENTER
if type_dir != "LONDON":
continue
# if type_dir != "CLINIC": continue
subj_dir_id = f"{ind_dir}/{type_dir}_Post/{subID}"
# store only subjects that have been processed
if row.toTVB:
out_dir_subj = f"{out_dir}/{type_dir}_{subID}"
# create subject if it does not exist
if not os.path.exists(f"{out_dir_subj}/results/"):
os.makedirs(f"{out_dir_subj}/results/")
# copy connectivity.zip, weights, tracts, z_matrix and zr_matrix
shutil.copy2(
f"{subj_dir_id}/results/Connectivity.zip", f"{out_dir_subj}/results/"
)
shutil.copy2(
f"{subj_dir_id}/results/{subID}_SC_distances.txt",
f"{out_dir_subj}/results/{type_dir}_{subID}_SC_distances.txt",
)
shutil.copy2(
f"{subj_dir_id}/results/{subID}_SC_weights.txt",
f"{out_dir_subj}/results/{type_dir}_{subID}_SC_weights.txt",
)
shutil.copy2(
f"{subj_dir_id}/fmri_proc_dti/r_matrix.csv", f"{out_dir_subj}/results/"
)
shutil.copy2(
f"{subj_dir_id}/fmri_proc_dti/zr_matrix.csv", f"{out_dir_subj}/results/"
)
shutil.copy2(
f"{subj_dir_id}/fmri_proc_dti/corrlabel_ts.txt",
f"{out_dir_subj}/results/",
)
if __name__ == "__main__":
# those parameters have to be entered from outside
move_completed_subjects()