Skip to content

Commit 4c0a753

Browse files
committed
enh: remove interface already upstreamed (nipreps/sdcflows#56)
1 parent 42b4777 commit 4c0a753

File tree

1 file changed

+0
-64
lines changed

1 file changed

+0
-64
lines changed

niworkflows/interfaces/itk.py

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import os
55
from mimetypes import guess_type
66
from tempfile import TemporaryDirectory
7-
import numpy as np
8-
import nibabel as nb
97

108
from nipype import logging
119
from nipype.utils.filemanip import fname_presuffix
@@ -142,68 +140,6 @@ def _run_interface(self, runtime):
142140
return runtime
143141

144142

145-
class _FUGUEvsm2ANTSwarpInputSpec(BaseInterfaceInputSpec):
146-
in_file = File(exists=True, mandatory=True,
147-
desc='input displacements field map')
148-
pe_dir = traits.Enum('i', 'i-', 'j', 'j-', 'k', 'k-',
149-
desc='phase-encoding axis')
150-
151-
152-
class _FUGUEvsm2ANTSwarpOutputSpec(TraitedSpec):
153-
out_file = File(desc='the output warp field')
154-
155-
156-
class FUGUEvsm2ANTSwarp(SimpleInterface):
157-
"""Convert a voxel-shift-map to ants warp."""
158-
input_spec = _FUGUEvsm2ANTSwarpInputSpec
159-
output_spec = _FUGUEvsm2ANTSwarpOutputSpec
160-
161-
def _run_interface(self, runtime):
162-
163-
nii = nb.load(self.inputs.in_file)
164-
165-
phaseEncDim = {'i': 0, 'j': 1, 'k': 2}[self.inputs.pe_dir[0]]
166-
167-
if len(self.inputs.pe_dir) == 2:
168-
phaseEncSign = 1.0
169-
else:
170-
phaseEncSign = -1.0
171-
172-
# Fix header
173-
hdr = nii.header.copy()
174-
hdr.set_data_dtype(np.dtype('<f4'))
175-
hdr.set_intent('vector', (), '')
176-
177-
# Get data, convert to mm
178-
data = nii.get_fdata()
179-
180-
aff = np.diag([1.0, 1.0, -1.0])
181-
if np.linalg.det(aff) < 0 and phaseEncDim != 0:
182-
# Reverse direction since ITK is LPS
183-
aff *= -1.0
184-
185-
aff = aff.dot(nii.affine[:3, :3])
186-
187-
data *= phaseEncSign * nii.header.get_zooms()[phaseEncDim]
188-
189-
# Add missing dimensions
190-
zeros = np.zeros_like(data)
191-
field = [zeros, zeros]
192-
field.insert(phaseEncDim, data)
193-
field = np.stack(field, -1)
194-
# Add empty axis
195-
field = field[:, :, :, np.newaxis, :]
196-
197-
# Write out
198-
self._results['out_file'] = fname_presuffix(
199-
self.inputs.in_file, suffix='_antswarp', newpath=runtime.cwd)
200-
nb.Nifti1Image(
201-
field.astype(np.dtype('<f4')), nii.affine, hdr).to_filename(
202-
self._results['out_file'])
203-
204-
return runtime
205-
206-
207143
def _mat2itk(args):
208144
from nipype.interfaces.c3 import C3dAffineTool
209145
from nipype.utils.filemanip import fname_presuffix

0 commit comments

Comments
 (0)