-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmove_arrayslices_hcp.py
70 lines (46 loc) · 1.32 KB
/
move_arrayslices_hcp.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 8 14:07:14 2019
@author: jeffreydurieux
# need to move array slices on aws
"""
import os
import pandas as pd
from shutil import copyfile
os.chdir('/Users/jeffreydurieux/Desktop/test/')
data = pd.read_csv('gan_dl_BehavioralData.csv')
list(data)
df = data[['Subject','age_category']]
os.chdir('/Users/jeffreydurieux/Desktop/test/array_slices/')
files = os.listdir()
# remove strings from list
files.remove('age0')
files.remove('age1')
files.remove('age2')
files.remove('age3')
Sid = []
for i in range(1112):
Sid.append(files[i][:6])
# type cast Sid to int
Sid = list(map(int, Sid))
idx = df.Subject.isin(Sid)
# subset of data: data to work with
df = df[idx]
for ii in range(1112):
data = df.iloc[ii]
filenum = str(int(data['Subject']))
age_cat = data['age_category']
file = filenum + '_slice_100.npy'
if age_cat == 0:
print('age cat is 0')
copyfile(src = file , dst = "age0/"+file)
if age_cat == 1:
print('age cat is 1')
copyfile(src = file , dst = "age1/"+file)
if age_cat == 2:
print('age cat is 2')
copyfile(src = file , dst = "age2/"+file)
if age_cat == 3:
print('age cat is 3')
copyfile(src = file , dst = "age3/"+file)