Skip to content

Commit e955987

Browse files
committed
[FIX] Fix IndexError no matching
If vertices aren't matched appropriately in civet_to_freesurfer then an IndexError was thrown. This uses a mask to (hopefully) avoid that possibility / issue.
1 parent 5685395 commit e955987

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

netneurotools/civet.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def civet_to_freesurfer(brainmap, surface='mid', version='v1',
117117
icbm = fetch_civet(density='41k' if n_vert == 40962 else '164k',
118118
version=version, data_dir=data_dir, verbose=0)[surface]
119119
fsavg = fetch_fsaverage(version=freesurfer, data_dir=data_dir, verbose=0)
120-
fsavg = fsavg['pial' if surface == 'mid' else 'white']
120+
fsavg = fsavg['pial' if surface == 'mid' else surface]
121121

122122
data = []
123123
for n, hemi in enumerate(('lh', 'rh')):
@@ -128,6 +128,9 @@ def civet_to_freesurfer(brainmap, surface='mid', version='v1',
128128
else:
129129
idx = mapping[sl]
130130

131-
data.append(brainmap[sl][idx])
131+
hdata = np.full(len(idx), np.nan)
132+
mask = idx != n_vert
133+
hdata[mask] = brainmap[sl][idx[mask]]
134+
data.append(hdata)
132135

133136
return np.hstack(data)

0 commit comments

Comments
 (0)