Skip to content

Commit

Permalink
Merge pull request #214 from poldracklab/nearest-coreg
Browse files Browse the repository at this point in the history
[RTM] ENH: Use nearest for coreg visualization
  • Loading branch information
oesteban authored Dec 15, 2017
2 parents d7e0b3a + 530baf0 commit d8d13c3
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions niworkflows/interfaces/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,15 @@ class ApplyXFMRPT(FLIRTRPT, fsl.ApplyXFM):
if LooseVersion("0.0.0") < fs.Info.looseversion() < LooseVersion("6.0.0"):
class BBRegisterInputSpecRPT(nrc.ReportCapableInputSpec,
fs.preprocess.BBRegisterInputSpec):
pass
out_lta_file = traits.Either(traits.Bool, File, default=True, usedefault=True,
argstr="--lta %s", min_ver='5.2.0',
desc="write the transformation matrix in LTA format")
else:
class BBRegisterInputSpecRPT(nrc.ReportCapableInputSpec,
fs.preprocess.BBRegisterInputSpec6):
pass
out_lta_file = traits.Either(traits.Bool, File, default=True, usedefault=True,
argstr="--lta %s", min_ver='5.2.0',
desc="write the transformation matrix in LTA format")


class BBRegisterOutputSpecRPT(nrc.ReportCapableOutputSpec,
Expand All @@ -200,10 +204,21 @@ class BBRegisterRPT(nrc.RegistrationRC, fs.BBRegister):
output_spec = BBRegisterOutputSpecRPT

def _post_run_hook(self, runtime):
outputs = self.aggregate_outputs(runtime=runtime)
mri_dir = os.path.join(self.inputs.subjects_dir,
self.inputs.subject_id, 'mri')
self._fixed_image = os.path.join(mri_dir, 'brainmask.mgz')
self._moving_image = self.aggregate_outputs(runtime=runtime).registered_file
target_file = os.path.join(mri_dir, 'brainmask.mgz')

# Apply transform for simplicity
mri_vol2vol = fs.ApplyVolTransform(
source_file=self.inputs.source_file,
target_file=target_file,
lta_file=outputs.out_lta_file,
interp='nearest')
res = mri_vol2vol.run()

self._fixed_image = target_file
self._moving_image = res.outputs.transformed_file
self._contour = os.path.join(mri_dir, 'ribbon.mgz')
NIWORKFLOWS_LOG.info(
'Report - setting fixed (%s) and moving (%s) images',
Expand Down Expand Up @@ -240,7 +255,8 @@ def _post_run_hook(self, runtime):
mri_vol2vol = fs.ApplyVolTransform(
source_file=self.inputs.source_file,
target_file=target_file,
lta_file=outputs.out_lta_file)
lta_file=outputs.out_lta_file,
interp='nearest')
res = mri_vol2vol.run()

self._fixed_image = target_file
Expand Down

0 comments on commit d8d13c3

Please sign in to comment.