Skip to content

Commit a9a8904

Browse files
committed
added SHConv and SH2Amp interfaces to mrtrix utils
1 parent 1f3d251 commit a9a8904

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

nipype/interfaces/mrtrix3/utils.py

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,3 +765,129 @@ class MRResize(MRTrix3Base):
765765
_cmd = "mrresize"
766766
input_spec = MRResizeInputSpec
767767
output_spec = MRResizeOutputSpec
768+
769+
770+
class SHConvInputSpec(TraitedSpec):
771+
in_file = File(
772+
exists=True,
773+
argstr="%s",
774+
mandatory=True,
775+
position=-3,
776+
desc="input ODF image",
777+
)
778+
779+
# General options
780+
response = File(
781+
exists=True,
782+
mandatory=True,
783+
argstr="%s",
784+
position=-2,
785+
desc=("The response function"),
786+
)
787+
788+
out_file = File(
789+
"sh.mif",
790+
argstr="%s",
791+
mandatory=True,
792+
position=-1,
793+
usedefault=True,
794+
desc="the output spherical harmonics",
795+
)
796+
797+
798+
class SHConvOutputSpec(TraitedSpec):
799+
out_file = File(exists=True,
800+
desc="the output convoluted spherical harmonics file")
801+
802+
803+
class SHConv(CommandLine):
804+
"""
805+
Convert diffusion-weighted images to tensor images
806+
807+
808+
Example
809+
-------
810+
811+
>>> import nipype.interfaces.mrtrix3 as mrt
812+
>>> tsr = mrt.SHConv()
813+
>>> tsr.inputs.in_file = 'odf.mif'
814+
>>> tsr.inputs.response = 'response.txt'
815+
>>> tsr.inputs.grad_fsl = ('bvecs', 'bvals')
816+
>>> tsr.cmdline # doctest: +ELLIPSIS
817+
'dwi2tensor -fslgrad bvecs bvals -mask mask.nii.gz dwi.mif dti.mif'
818+
>>> tsr.run() # doctest: +SKIP
819+
"""
820+
821+
_cmd = "shconv"
822+
input_spec = SHConvInputSpec
823+
output_spec = SHConvOutputSpec
824+
825+
def _list_outputs(self):
826+
outputs = self.output_spec().get()
827+
outputs["out_file"] = op.abspath(self.inputs.out_file)
828+
return outputs
829+
830+
831+
832+
class SH2AmpInputSpec(MRTrix3BaseInputSpec):
833+
in_file = File(
834+
exists=True,
835+
argstr="%s",
836+
mandatory=True,
837+
position=-3,
838+
desc="input ODF image",
839+
)
840+
841+
# General options
842+
directions = File(
843+
exists=True,
844+
mandatory=True,
845+
argstr="%s",
846+
position=-2,
847+
desc=("The directions along which to sample the function"),
848+
)
849+
850+
out_file = File(
851+
"amp.mif",
852+
argstr="%s",
853+
mandatory=True,
854+
position=-1,
855+
usedefault=True,
856+
desc="the output spherical harmonics",
857+
)
858+
859+
nonnegative = traits.Bool(
860+
argstr='-nonnegative',
861+
desc="cap all negative amplitudes to zero")
862+
863+
864+
class SH2AmpOutputSpec(TraitedSpec):
865+
out_file = File(exists=True,
866+
desc="the output convoluted spherical harmonics file")
867+
868+
869+
class SH2Amp(MRTrix3Base):
870+
"""
871+
Convert diffusion-weighted images to tensor images
872+
873+
874+
Example
875+
-------
876+
877+
>>> import nipype.interfaces.mrtrix3 as mrt
878+
>>> sha = mrt.SH2Amp()
879+
>>> sha.inputs.in_file = 'odf.mif'
880+
>>> sha.inputs.response = 'response.txt'
881+
>>> sha.cmdline # doctest: +ELLIPSIS
882+
'dwi2tensor -fslgrad bvecs bvals -mask mask.nii.gz dwi.mif dti.mif'
883+
>>> sha.run() # doctest: +SKIP
884+
"""
885+
886+
_cmd = "sh2amp"
887+
input_spec = SH2AmpInputSpec
888+
output_spec = SH2AmpOutputSpec
889+
890+
def _list_outputs(self):
891+
outputs = self.output_spec().get()
892+
outputs["out_file"] = op.abspath(self.inputs.out_file)
893+
return outputs

0 commit comments

Comments
 (0)