-
Notifications
You must be signed in to change notification settings - Fork 0
/
NRpRF_center_size.pro
77 lines (63 loc) · 2.81 KB
/
NRpRF_center_size.pro
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
71
72
73
74
75
76
pro NRpRF_center_size
;+
; :Author: Wouter Schellekens
;
; Non-rigid pRF center & size calculation
;-
;Declare variables
rdir='/Fridge/users/wouter/NRPRF/'
fsdir='/Fridge/users/wouter/fs/avg_wbm/'
surfdir=fsdir+'surf/caret/'
subs=['V6649','V6682','V6683','V6743','V6744','V7774','V7860','V7882']
nsub=n_elements(subs)
nconds=18.
condities = ['toes', 'ankle', 'knee', 'abdomen', 'shoulder', 'elbow','wrist', 'littleF', 'ringF', 'middleF', 'indexF', 'thumb', 'forehead', 'eye', 'nose', 'lips', 'jaw', 'tongue']
nscans=856.
gcenter=10.
;Load pRF fits
for i=0,nsub-1 do begin
subdir=rdir+subs[i]+'/FSL/'
zfitz=loadmgh(subdir+'difpos/'+subs[i]+'-zfitz-lh.mgh')
nrnodes=n_elements(zfitz[*,0])
;Set values beyond 1 s.d. to zero
zfitz2=reform(zfitz[*,2:2+nconds-1])
hwhm=sqrt(2*alog(2))
fwhm=2*hwhm
zfitz3=zfitz2
low=fwhm
zfitz3-=low
zfitz3[where(zfitz2 lt gcenter-hwhm)]=0
zfitz3/=(gcenter-low)
;Threshold non-significant vertices
mask=intarr(nrnodes)
mask[where(zfitz[*,-1] gt 0)]=1
fpar=nconds+2
fthr=f_fdr(reform(zfitz[*,-1]),[fpar-1,nscans-fpar-1])
m2=mask
m2[where(reform(zfitz[*,-1]) lt fthr)]=0
;Calculate pRF center
centerpos=fltarr(nrnodes)
for ii=0L,nrnodes-1 do if m2[ii] eq 1 then begin
if n_elements(where(zfitz2[ii,*] eq max(zfitz2[ii,*]),/null)) eq 1 then begin
centerpos[ii]=where(zfitz2[ii,*] eq max(zfitz2[ii,*]))
endif else begin
centerpos[ii]=round(mean(where(zfitz2[ii,*] eq max(zfitz2[ii,*]))))
endelse
endif
;Calculate pRF size
zfitz4=zfitz2/gcenter
sigmapos=fltarr(nrnodes)
for ii=0L,nrnodes-1 do if m2[ii] eq 1 then sigmapos[ii] = total(zfitz4[ii,where(zfitz3[ii,*] gt 0)])*hwhm
;Set non-significant vertices to NaN
centerpos[where(m2 eq 0)]=!values.f_nan
sigmapos[where(m2 eq 0)]=!values.f_nan
zfitz3[where(m2 eq 0),*]=!values.f_nan
;Save it to Freesurfer format and project to average cortical surface
savemgh,centerpos,subdir+'difpos/'+subs[i]+'-centerpos-lh.mgh'
spawn,'mri_surf2surf --srcsubject '+subs[i]+' --srcsurfval '+subdir+'difpos/'+subs[i]+'-centerpos-lh.mgh --trgsubject avg_wbm --trgsurfval '+subdir+'difpos/'+subs[i]+'-centerpos-lh-avg_wbm.mgh --hemi lh'
savemgh,sigmapos,subdir+'difpos/'+subs[i]+'-sigmapos-lh.mgh'
spawn,'mri_surf2surf --srcsubject '+subs[i]+' --srcsurfval '+subdir+'difpos/'+subs[i]+'-sigmapos-lh.mgh --trgsubject avg_wbm --trgsurfval '+subdir+'difpos/'+subs[i]+'-sigmapos-lh-avg_wbm.mgh --hemi lh'
savemgh,zfitz3,subdir+'difpos/'+subs[i]+'-dxi-lh.mgh'
spawn,'mri_surf2surf --srcsubject '+subs[i]+' --srcsurfval '+subdir+'difpos/'+subs[i]+'-dxi-lh.mgh --trgsubject avg_wbm --trgsurfval '+subdir+'difpos/'+subs[i]+'-dxi-lh-avg_wbm.mgh --hemi lh'
endfor
end