Skip to content

Commit

Permalink
fix: resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
satra committed Feb 10, 2015
2 parents 86a9249 + 60e6b55 commit b7964c4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Next release
============

* FIX: remove unused mandatory flag from spm normalize (https://github.com/nipy/nipype/pull/1048)
* ENH: Update ANTSCorticalThickness interface (https://github.com/nipy/nipype/pull/1013)
* FIX: Edge case with sparsemodels and PEP8 cleanup (https://github.com/nipy/nipype/pull/1046)
* ENH: New io interfaces for JSON files reading/writing (https://github.com/nipy/nipype/pull/1020)
* ENH: Enhanced openfmri script to support freesurfer linkage (https://github.com/nipy/nipype/pull/1037)
Expand Down
63 changes: 29 additions & 34 deletions nipype/interfaces/ants/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,17 @@ class antsCorticalThicknessoutputSpec(TraitedSpec):
BrainExtractionMask = File(exists=True, desc='brain extraction mask')
BrainSegmentation = File(exists=True, desc='brain segmentaion image')
BrainSegmentationN4 = File(exists=True, desc='N4 corrected image')
BrainSegmentationPosteriorsCSF = File(exists=True, desc='CSF posterior probability image')
BrainSegmentationPosteriorsGM = File(exists=True, desc='GM posterior probability image')
BrainSegmentationPosteriorsWM = File(exists=True, desc='WM posterior probability image')
BrainSegmentationPosteriorsDGM = File(exists=True, desc='DGM posterior probability image')
BrainSegmentationPosteriors = OutputMultiPath(File(exists=True),
desc='Posterior probability images')
CorticalThickness = File(exists=True, desc='cortical thickness file')
TemplateToSubject1GenericAffine = File(exists=True, desc='Template to subject affine')
TemplateToSubject0Warp = File(exists=True, desc='Template to subject warp')
SubjectToTemplate1Warp = File(exists=True, desc='Template to subject inverse warp')
SubjectToTemplate0GenericAffine = File(exists=True, desc='Template to subject inverse affine')
TemplateToSubjectLogJacobian = File(exists=True, desc='Template to subject log jacobian')
SubjectToTemplateLogJacobian = File(exists=True, desc='Template to subject log jacobian')
CorticalThicknessNormedToTemplate = File(exists=True,
desc='Normalized cortical thickness')
BrainVolumes = File(exists=True, desc='Brain volumes as text')


class antsCorticalThickness(ANTSCommand):
Expand All @@ -472,7 +473,7 @@ class antsCorticalThickness(ANTSCommand):
>>> corticalthickness.inputs.segmentation_priors = ['BrainSegmentationPrior01.nii.gz', 'BrainSegmentationPrior02.nii.gz', 'BrainSegmentationPrior03.nii.gz', 'BrainSegmentationPrior04.nii.gz']
>>> corticalthickness.inputs.t1_registration_template = 'brain_study_template.nii.gz'
>>> corticalthickness.cmdline
'antsCorticalThickness.sh -a T1.nii.gz -m ProbabilityMaskOfStudyTemplate.nii.gz -e study_template.nii.gz -d 3 -s nii.gz -o antsCT_ -p BrainSegmentationPrior%02d.nii.gz -t brain_study_template.nii.gz'
'antsCorticalThickness.sh -a T1.nii.gz -m ProbabilityMaskOfStudyTemplate.nii.gz -e study_template.nii.gz -d 3 -s nii.gz -o antsCT_ -p nipype_priors/BrainSegmentationPrior%02d.nii.gz -t brain_study_template.nii.gz'
"""

input_spec = antsCorticalThicknessInputSpec
Expand All @@ -496,25 +497,20 @@ def _format_arg(self, opt, spec, val):
retval = '-t %s' % val
return retval
if opt == 'segmentation_priors':
priors_directory, _, ext = split_filename(self.inputs.segmentation_priors[0])
if priors_directory is not '':
retval = "-p %s/BrainSegmentationPrior%%02d" % priors_directory
else:
retval = "-p BrainSegmentationPrior%02d"
retval += ext
_, _, ext = split_filename(self.inputs.segmentation_priors[0])
retval = "-p nipype_priors/BrainSegmentationPrior%02d" + ext
return retval
return super(ANTSCommand, self)._format_arg(opt, spec, val)

def _run_interface(self, runtime, correct_return_codes=[0]):
priors_directory = os.path.join(os.getcwd(), "priors")
priors_directory = os.path.join(os.getcwd(), "nipype_priors")
if not os.path.exists(priors_directory):
os.makedirs(priors_directory)
_, _, ext = split_filename(self.inputs.segmentation_priors[0])
for i, f in enumerate(self.inputs.segmentation_priors):
target = os.path.join(priors_directory, 'BrainSegmentationPrior%02d' % (i + 1) + ext)
if not (os.path.exists(target) and os.path.realpath(target) == os.path.abspath(f)):
copyfile(os.path.abspath(f), os.path.join(priors_directory,
'BrainSegmentationPrior%02d' % (i + 1) + ext))
copyfile(os.path.abspath(f), target)
runtime = super(antsCorticalThickness, self)._run_interface(runtime)
return runtime

Expand All @@ -532,43 +528,42 @@ def _list_outputs(self):
self.inputs.out_prefix +
'BrainSegmentation0N4.' +
self.inputs.image_suffix)
outputs['BrainSegmentationPosteriorsCSF'] = os.path.join(os.getcwd(),
self.inputs.out_prefix +
'BrainSegmentationPosteriors01.' +
self.inputs.image_suffix)
outputs['BrainSegmentationPosteriorsGM'] = os.path.join(os.getcwd(),
self.inputs.out_prefix +
'BrainSegmentationPosteriors02.' +
self.inputs.image_suffix)
outputs['BrainSegmentationPosteriorsWM'] = os.path.join(os.getcwd(),
self.inputs.out_prefix +
'BrainSegmentationPosteriors03.' +
self.inputs.image_suffix)
outputs['BrainSegmentationPosteriorsDGM'] = os.path.join(os.getcwd(),
self.inputs.out_prefix +
'BrainSegmentationPosteriors04.' +
self.inputs.image_suffix)
posteriors = []
for i in range(len(self.inputs.segmentation_priors)):
posteriors.append(os.path.join(os.getcwd(),
self.inputs.out_prefix +
'BrainSegmentationPosteriors%02d.' % (i + 1) +
self.inputs.image_suffix))
outputs['BrainSegmentationPosteriors'] = posteriors
outputs['CorticalThickness'] = os.path.join(os.getcwd(),
self.inputs.out_prefix +
'CorticalThickness.' +
self.inputs.image_suffix)
outputs['TemplateToSubject1GenericAffine'] = os.path.join(os.getcwd(),
self.inputs.out_prefix +
'TemplateToSubject1GenericAffine.mat')
outputs['TemplateToSubject0Warp'] = os.path.join(os.getcwd(),
self.inputs.out_prefix +
'TemplateToSubject0Warp.' +
self.inputs.image_suffix)
outputs['SubjectToTemplate1Warp'] = os.path.join(os.getcwd(),
self.inputs.out_prefix +
'SubjectToTemplate1Warp' +
'SubjectToTemplate1Warp.' +
self.inputs.image_suffix)
outputs['SubjectToTemplate0GenericAffine'] = os.path.join(os.getcwd(),
self.inputs.out_prefix +
'SubjectToTemplate0GenericAffine.mat')
outputs['TemplateToSubjectLogJacobian'] = os.path.join(os.getcwd(),
outputs['SubjectToTemplateLogJacobian'] = os.path.join(os.getcwd(),
self.inputs.out_prefix +
'subjectToTemplateLogJacobian.' +
'SubjectToTemplateLogJacobian.' +
self.inputs.image_suffix)
outputs['CorticalThicknessNormedToTemplate'] = os.path.join(os.getcwd(),
self.inputs.out_prefix +
'CorticalThickness.' +
self.inputs.image_suffix)
outputs['BrainVolumes'] = os.path.join(os.getcwd(),
self.inputs.out_prefix +
'brainvols.csv')
return outputs

class JointFusionInputSpec(ANTSCommandInputSpec):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,15 @@ def test_antsCorticalThickness_outputs():
output_map = dict(BrainExtractionMask=dict(),
BrainSegmentation=dict(),
BrainSegmentationN4=dict(),
BrainSegmentationPosteriorsCSF=dict(),
BrainSegmentationPosteriorsDGM=dict(),
BrainSegmentationPosteriorsGM=dict(),
BrainSegmentationPosteriorsWM=dict(),
BrainSegmentationPosteriors=dict(),
BrainVolumes=dict(),
CorticalThickness=dict(),
CorticalThicknessNormedToTemplate=dict(),
SubjectToTemplate0GenericAffine=dict(),
SubjectToTemplate1Warp=dict(),
SubjectToTemplateLogJacobian=dict(),
TemplateToSubject0Warp=dict(),
TemplateToSubject1GenericAffine=dict(),
TemplateToSubjectLogJacobian=dict(),
)
outputs = antsCorticalThickness.output_spec()

Expand Down

0 comments on commit b7964c4

Please sign in to comment.