@@ -184,6 +184,31 @@ def create_roi(subject_id, subjects_dir, fs_dir, parcellation_name):
184
184
nb .save (img , out_roi )
185
185
186
186
iflogger .info ("[ DONE ]" )
187
+ # dilate cortical regions
188
+ iflogger .info ("Dilating cortical regions..." )
189
+ dilatestart = time ()
190
+ # loop throughout all the voxels belonging to the aseg GM volume
191
+ for j in range (xx .size ):
192
+ if newrois [xx [j ],yy [j ],zz [j ]] == 0 :
193
+ local = extract (rois , shape , position = (xx [j ],yy [j ],zz [j ]), fill = 0 )
194
+ mask = local .copy ()
195
+ mask [np .nonzero (local > 0 )] = 1
196
+ thisdist = np .multiply (dist ,mask )
197
+ thisdist [np .nonzero (thisdist == 0 )] = np .amax (thisdist )
198
+ value = np .int_ (local [np .nonzero (thisdist == np .amin (thisdist ))])
199
+ if value .size > 1 :
200
+ counts = np .bincount (value )
201
+ value = np .argmax (counts )
202
+ newrois [xx [j ],yy [j ],zz [j ]] = value
203
+ iflogger .info ("Cortical ROIs dilation took %s seconds to process." % (time ()- dilatestart ))
204
+
205
+ # store volume eg in ROIv_scale33.nii.gz
206
+ out_roi = op .join (fs_dir , 'label' , 'ROIv_%s.nii.gz' % parkey )
207
+ iflogger .info ("Save output image to %s" % out_roi )
208
+ img = ni .Nifti1Image (newrois , aseg .get_affine (), hdr2 )
209
+ ni .save (img , out_roi )
210
+
211
+ iflogger .info ("[ DONE ]" )
187
212
188
213
189
214
def create_wm_mask (subject_id , subjects_dir , fs_dir , parcellation_name ):
0 commit comments