-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgii_to_hdf5.py
More file actions
27 lines (22 loc) · 872 Bytes
/
gii_to_hdf5.py
File metadata and controls
27 lines (22 loc) · 872 Bytes
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
from nibabel import gifti
import h5py
import numpy as np
subjects = []
with open('/scr/ilz1/nilearn_vol2surf_sink/subjects.txt') as f:
subjects = f.read().splitlines()
hemis = ['rh', 'lh']
smooths = ['fwhm0', 'fwhm6']
fname_template = '/scr/ilz1/nilearn_vol2surf_sink/%s/%s_%s_preprocessed_fsaverage5_%s.gii'
for smooth in smooths:
for sub in subjects:
for hemi in hemis:
print smooth, sub, hemi
fname=fname_template%(smooth, sub, hemi, smooth)
gii=gifti.giftiio.read(fname)
mat=np.zeros((gii.darrays[0].data.shape[0], len(gii.darrays)))
for arr in range(len(gii.darrays)):
mat[:,arr]=gii.darrays[arr].data
hname=fname[:-3]+'hdf5'
f = h5py.File(hname, 'w')
f.create_dataset('mat', data=mat)
f.close()