Skip to content

Commit 04b1529

Browse files
committed
Merge pull request #598 from alexschaefer83/master
Fix for Dilation
2 parents e6bc85e + 4d6f4c3 commit 04b1529

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

nipype/interfaces/cmtk/parcellation.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def create_wm_mask(subject_id, subjects_dir, fs_dir, parcellation_name):
444444
nb.save(img, wm_out)
445445

446446

447-
def crop_and_move_datasets(subject_id, subjects_dir, fs_dir, parcellation_name, out_roi_file):
447+
def crop_and_move_datasets(subject_id, subjects_dir, fs_dir, parcellation_name, out_roi_file,dilation):
448448
fs_dir = op.join(subjects_dir, subject_id)
449449
cmp_config = cmp.configuration.PipelineConfiguration()
450450
cmp_config.parcellation_scheme = "Lausanne2008"
@@ -468,7 +468,8 @@ def crop_and_move_datasets(subject_id, subjects_dir, fs_dir, parcellation_name,
468468

469469
ds.append((op.join(op.curdir, 'ROI_%s.nii.gz' % parcellation_name),
470470
op.join(op.curdir, 'ROI_HR_th.nii.gz')))
471-
ds.append((op.join(op.curdir, 'ROIv_%s.nii.gz' %
471+
if(dilation==True):
472+
ds.append((op.join(op.curdir, 'ROIv_%s.nii.gz' %
472473
parcellation_name), op.join(op.curdir, 'ROIv_HR_th.nii.gz')))
473474
orig = op.join(fs_dir, 'mri', 'orig', '001.mgz')
474475
for d in ds:
@@ -531,7 +532,7 @@ class ParcellateInputSpec(BaseInterfaceInputSpec):
531532
class ParcellateOutputSpec(TraitedSpec):
532533
roi_file = File(
533534
exists=True, desc='Region of Interest file for connectivity mapping')
534-
roiv_file = File(exists=True, desc='Region of Interest file for fMRI connectivity mapping')
535+
roiv_file = File(desc='Region of Interest file for fMRI connectivity mapping')
535536
white_matter_mask_file = File(exists=True, desc='White matter mask file')
536537
cc_unknown_file = File(
537538
desc='Image file with regions labelled as unknown cortical structures',
@@ -545,8 +546,7 @@ class ParcellateOutputSpec(TraitedSpec):
545546
desc='ROI image resliced to the dimensions of the original structural image',
546547
exists=True)
547548
dilated_roi_file_in_structural_space = File(
548-
desc='dilated ROI image resliced to the dimensions of the original structural image',
549-
exists=True)
549+
desc='dilated ROI image resliced to the dimensions of the original structural image')
550550

551551

552552
class Parcellate(BaseInterface):
@@ -583,7 +583,7 @@ def _run_interface(self, runtime):
583583
create_annot_label(self.inputs.subject_id, self.inputs.subjects_dir, self.inputs.freesurfer_dir, self.inputs.parcellation_name)
584584
create_roi(self.inputs.subject_id, self.inputs.subjects_dir, self.inputs.freesurfer_dir, self.inputs.parcellation_name, self.inputs.dilation)
585585
create_wm_mask(self.inputs.subject_id, self.inputs.subjects_dir, self.inputs.freesurfer_dir, self.inputs.parcellation_name)
586-
crop_and_move_datasets(self.inputs.subject_id, self.inputs.subjects_dir, self.inputs.freesurfer_dir, self.inputs.parcellation_name, self.inputs.out_roi_file)
586+
crop_and_move_datasets(self.inputs.subject_id, self.inputs.subjects_dir, self.inputs.freesurfer_dir, self.inputs.parcellation_name, self.inputs.out_roi_file,self.inputs.dilation)
587587
return runtime
588588

589589
def _list_outputs(self):
@@ -593,16 +593,18 @@ def _list_outputs(self):
593593
else:
594594
outputs['roi_file'] = op.abspath(
595595
self._gen_outfilename('nii.gz', 'ROI'))
596-
outputs['roiv_file'] = op.abspath(self._gen_outfilename(
596+
if(self.inputs.dilation==True):
597+
outputs['roiv_file'] = op.abspath(self._gen_outfilename(
597598
'nii.gz', 'ROIv'))
598599
outputs['white_matter_mask_file'] = op.abspath('fsmask_1mm.nii.gz')
599600
outputs['cc_unknown_file'] = op.abspath('cc_unknown.nii.gz')
600601
outputs['ribbon_file'] = op.abspath('ribbon.nii.gz')
601602
outputs['aseg_file'] = op.abspath('aseg.nii.gz')
602603
outputs['roi_file_in_structural_space'] = op.abspath(
603604
'ROI_HR_th.nii.gz')
604-
outputs['dilated_roi_file_in_structural_space'] = op.abspath(
605-
'ROI_HR_th.nii.gz')
605+
if(self.inputs.dilation==True):
606+
outputs['dilated_roi_file_in_structural_space'] = op.abspath(
607+
'ROIv_HR_th.nii.gz')
606608
return outputs
607609

608610
def _gen_outfilename(self, ext, prefix='ROI'):

0 commit comments

Comments
 (0)