-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_fs.py
More file actions
32 lines (22 loc) · 1.13 KB
/
load_fs.py
File metadata and controls
32 lines (22 loc) · 1.13 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
def load_fs(subject):
import nibabel as nib
import numpy as np
dir1 = '/network/lustre/iss01/home/daniel.margulies/data/lsd'
data_all = []
for d in ['AP', 'PA']:
for s in [1,2]:
h = 'lh'
data_lh = nib.load('%s/derivatives/%s/func/%s_ses-02_task-rest_acq-%s_run-0%i.fsa5.%s.mgz' % (dir1,subject,subject,d,s,h)).get_data().squeeze()
lab_lh = nib.freesurfer.read_label('%s/freesurfer/fsaverage5/label/%s.cortex.label' % (dir1,h))
h = 'rh'
data_rh = nib.load('%s/derivatives/%s/func/%s_ses-02_task-rest_acq-%s_run-0%i.fsa5.%s.mgz' % (dir1,subject,subject,d,s,h)).get_data().squeeze()
lab_rh = nib.freesurfer.read_label('%s/freesurfer/fsaverage5/label/%s.cortex.label' % (dir1,h))
data = np.vstack((data_lh[lab_lh,:],data_rh[lab_rh,:]))
data = (data.T - np.nanmean(data, axis = 1)).T
data = (data.T / np.nanstd(data, axis = 1)).T
if len(data_all) == 0:
data_all = data.copy()
else:
data_all = np.hstack((data_all, data))
del data
return data_all