Skip to content

Commit 0843742

Browse files
committed
RF: Replace InvertT1w with Rescale(invert=True)
1 parent a783c38 commit 0843742

File tree

3 files changed

+3
-38
lines changed

3 files changed

+3
-38
lines changed

fmriprep/interfaces/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
ReadSidecarJSON, DerivativesDataSink, BIDSDataGrabber, BIDSFreeSurferDir, BIDSInfo
66
)
77
from .images import (
8-
IntraModalMerge, InvertT1w, ValidateImage, TemplateDimensions, Conform
8+
IntraModalMerge, ValidateImage, TemplateDimensions, Conform
99
)
1010
from .freesurfer import (
1111
StructuralReference, MakeMidthickness, FSInjectBrainExtracted,

fmriprep/interfaces/images.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -427,41 +427,6 @@ def _run_interface(self, runtime):
427427
return runtime
428428

429429

430-
class InvertT1wInputSpec(BaseInterfaceInputSpec):
431-
in_file = File(exists=True, mandatory=True,
432-
desc='Skull-stripped T1w structural image')
433-
ref_file = File(exists=True, mandatory=True,
434-
desc='Skull-stripped reference image')
435-
436-
437-
class InvertT1wOutputSpec(TraitedSpec):
438-
out_file = File(exists=True, desc='Inverted T1w structural image')
439-
440-
441-
class InvertT1w(SimpleInterface):
442-
input_spec = InvertT1wInputSpec
443-
output_spec = InvertT1wOutputSpec
444-
445-
def _run_interface(self, runtime):
446-
t1_img = nli.load_img(self.inputs.in_file)
447-
t1_data = t1_img.get_data()
448-
epi_data = nli.load_img(self.inputs.ref_file).get_data()
449-
450-
# We assume the image is already masked
451-
mask = t1_data > 0
452-
453-
t1_min, t1_max = np.unique(t1_data)[[1, -1]]
454-
epi_min, epi_max = np.unique(epi_data)[[1, -1]]
455-
scale_factor = (epi_max - epi_min) / (t1_max - t1_min)
456-
457-
inv_data = mask * ((t1_max - t1_data) * scale_factor + epi_min)
458-
459-
out_file = fname_presuffix(self.inputs.in_file, suffix='_inv', newpath=runtime.cwd)
460-
nli.new_img_like(t1_img, inv_data, copy_header=True).to_filename(out_file)
461-
self._results['out_file'] = out_file
462-
return runtime
463-
464-
465430
class DemeanImageInputSpec(BaseInterfaceInputSpec):
466431
in_file = File(exists=True, mandatory=True,
467432
desc='image to be demeaned')

fmriprep/workflows/fieldmap/syn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
from nipype import logging
2929
from nipype.pipeline import engine as pe
3030
from nipype.interfaces import fsl, utility as niu
31+
from nipype.interfaces.image import Rescale
3132
from niworkflows.interfaces.fixes import (FixHeaderApplyTransforms as ApplyTransforms,
3233
FixHeaderRegistration as Registration)
33-
from ...interfaces import InvertT1w
3434
from ..bold.util import init_skullstrip_bold_wf
3535

3636
DEFAULT_MEMORY_MIN_GB = 0.01
@@ -110,7 +110,7 @@ def init_syn_sdc_wf(omp_nthreads, bold_pe=None,
110110
affine_transform = pkgr.resource_filename('fmriprep', 'data/affine.json')
111111
syn_transform = pkgr.resource_filename('fmriprep', 'data/susceptibility_syn.json')
112112

113-
invert_t1w = pe.Node(InvertT1w(), name='invert_t1w',
113+
invert_t1w = pe.Node(Rescale(invert=True), name='invert_t1w',
114114
mem_gb=0.3)
115115

116116
ref_2_t1 = pe.Node(Registration(from_file=affine_transform),

0 commit comments

Comments
 (0)