@@ -677,3 +677,86 @@ def _list_outputs(self):
677
677
outputs = self .output_spec ().get ()
678
678
outputs ['out_file' ] = op .abspath (self .inputs .out_file )
679
679
return outputs
680
+
681
+
682
+ class MRResizeInputSpec (MRTrix3BaseInputSpec ):
683
+ in_file = File (
684
+ exists = True ,
685
+ argstr = '%s' ,
686
+ position = - 2 ,
687
+ mandatory = True ,
688
+ desc = 'input DWI image'
689
+ )
690
+ image_size = traits .Tuple (
691
+ (traits .Int , traits .Int , traits .Int ),
692
+ argstr = '-size %d,%d,%d' ,
693
+ mandatory = True ,
694
+ desc = 'define the new image size for the output image. This should be '
695
+ 'specified as a comma-separated list.' ,
696
+ xor = ['voxel_size' , 'scale_factor' ],
697
+ )
698
+ voxel_size = traits .Tuple (
699
+ (traits .Float , traits .Float , traits .Float ),
700
+ argstr = '-voxel %d,%d,%d' ,
701
+ mandatory = True ,
702
+ desc = 'define the new voxel size for the output image. This can be '
703
+ 'specified either as a single value to be used for all '
704
+ 'dimensions, or as a comma-separated list of the size for each '
705
+ 'voxel dimension.' ,
706
+ xor = ['image_size' , 'scale_factor' ],
707
+ )
708
+ scale_factor = traits .Tuple (
709
+ (traits .Float , traits .Float , traits .Float ),
710
+ argstr = '-scale %d,%d,%d' ,
711
+ mandatory = True ,
712
+ desc = 'scale the image resolution by the supplied factor. This can be '
713
+ 'specified either as a single value to be used for all '
714
+ 'dimensions, or as a comma-separated list of scale factors for '
715
+ 'each dimension.' ,
716
+ xor = ['image_size' , 'voxel_size' ],
717
+ )
718
+ interp = traits .Enum (
719
+ 'cubic' ,
720
+ 'nearest' ,
721
+ 'linear' ,
722
+ 'sinc' ,
723
+ argstr = '-interp %s' ,
724
+ desc = 'set the interpolation method to use when resizing (choices: '
725
+ 'nearest, linear, cubic, sinc. Default: cubic).' ,
726
+ )
727
+ out_file = File (
728
+ argstr = '%s' ,
729
+ name_template = '%s_resized' ,
730
+ name_source = ['in_file' ],
731
+ keep_extension = True ,
732
+ position = - 1 ,
733
+ desc = 'the output resized DWI image' ,
734
+ )
735
+
736
+
737
+ class MRResizeOutputSpec (TraitedSpec ):
738
+ out_file = File (desc = 'the output resized DWI image' , exists = True )
739
+
740
+
741
+ class MRResize (MRTrix3Base ):
742
+ """
743
+ Resize an image by defining the new image resolution, voxel size or a
744
+ scale factor. If the image is 4D, then only the first 3 dimensions can be
745
+ resized. Also, if the image is down-sampled, the appropriate smoothing is
746
+ automatically applied using Gaussian smoothing.
747
+ For more information, see
748
+ <https://mrtrix.readthedocs.io/en/latest/reference/commands/mrresize.html>
749
+ Example
750
+ -------
751
+ >>> import nipype.interfaces.mrtrix3 as mrt
752
+ >>> resize = mrt.MRResize()
753
+ >>> resize.inputs.in_file = 'dwi.mif'
754
+ >>> resize.inputs.voxel_size = (1, 1, 1)
755
+ >>> resize.cmdline # doctest: +ELLIPSIS
756
+ 'mrresize -voxel 1,1,1 dwi.mif dwi_resized.mif'
757
+ >>> resize.run() # doctest: +SKIP
758
+ """
759
+
760
+ _cmd = 'mrresize'
761
+ input_spec = MRResizeInputSpec
762
+ output_spec = MRResizeOutputSpec
0 commit comments