Skip to content

Commit 593db53

Browse files
author
Alexander Schaefer
committed
added dilation file Rfor fMRI
1 parent d323b92 commit 593db53

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

nipype/interfaces/cmtk/parcellation.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,31 @@ def create_roi(subject_id, subjects_dir, fs_dir, parcellation_name):
184184
nb.save(img, out_roi)
185185

186186
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 ]")
187212

188213

189214
def create_wm_mask(subject_id, subjects_dir, fs_dir, parcellation_name):

0 commit comments

Comments
 (0)