-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblind.py
More file actions
43 lines (31 loc) · 1.33 KB
/
blind.py
File metadata and controls
43 lines (31 loc) · 1.33 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
import os.path as op
import s3fs
import pandas as pd
import random
import shutil
s3 = s3fs.S3FileSystem()
with s3.open("openneuro.org/ds000030/participants.tsv") as f:
df = pd.read_csv(f, sep="\t")
subjects = [id for id in df["participant_id"]]
random.shuffle(subjects)
trk_dir = "/home/tmgomez/ds000030/trk"
html_dir = "/home/tmgomez/ds000030/clip_edges_True"
blinded_dir = "/home/tmgomez/ds000030/blinded"
unblinded = []
blinded = []
for subject_id in subjects:
trk_file1 = op.join(trk_dir, f'{subject_id}_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-SCPL_tractography.trk')
trk_file2 = op.join(trk_dir, f'{subject_id}_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-SCPR_tractography.trk')
if not op.exists(trk_file1) or not op.exists(trk_file2):
continue
blinded_id = "blinded-%0.3d" % len(blinded)
html_file = f"{subject_id}_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-viz_dwi.html"
blinded_file = f"{blinded_id}_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-viz_dwi.html"
unblinded.append(subject_id)
blinded.append(blinded_id)
shutil.copy(
op.join(html_dir, html_file),
op.join(blinded_dir, blinded_file)
)
df_out = pd.DataFrame({"subject_id": unblinded, "blinded": blinded})
df_out.to_csv("key.csv")