-
Notifications
You must be signed in to change notification settings - Fork 532
ENH: Adds interfaces for MRtrix utils shconv and sh2amp #3280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
1f3d251
a9a8904
ac7490c
974ca38
ccd25c6
f245ba4
c81259b
ab96460
cd4bbc6
35a762f
7e670ff
8671983
308436d
f4eefeb
70e3bcf
a6e440d
5266a7c
c5d7ffe
fd8cc40
76ccb77
af8e01f
f698f4b
5e5ffbf
e096c19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
MRConvert, | ||
MRResize, | ||
DWIExtract, | ||
SHConv, | ||
SH2Amp | ||
) | ||
from .preprocess import ( | ||
ResponseSD, | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -765,3 +765,132 @@ class MRResize(MRTrix3Base): | |||||
_cmd = "mrresize" | ||||||
input_spec = MRResizeInputSpec | ||||||
output_spec = MRResizeOutputSpec | ||||||
|
||||||
|
||||||
class SHConvInputSpec(CommandLineInputSpec): | ||||||
|
||||||
tclose marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
in_file = File( | ||||||
exists=True, | ||||||
argstr="%s", | ||||||
mandatory=True, | ||||||
position=-3, | ||||||
desc="input ODF image", | ||||||
) | ||||||
|
||||||
tclose marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# General options | ||||||
response = File( | ||||||
exists=True, | ||||||
mandatory=True, | ||||||
argstr="%s", | ||||||
position=-2, | ||||||
desc=("The response function"), | ||||||
) | ||||||
|
||||||
tclose marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
out_file = File( | ||||||
"sh.mif", | ||||||
tclose marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
argstr="%s", | ||||||
mandatory=True, | ||||||
tclose marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
position=-1, | ||||||
usedefault=True, | ||||||
desc="the output spherical harmonics", | ||||||
) | ||||||
|
||||||
|
||||||
class SHConvOutputSpec(TraitedSpec): | ||||||
out_file = File(exists=True, | ||||||
desc="the output convoluted spherical harmonics file") | ||||||
|
||||||
|
||||||
class SHConv(CommandLine): | ||||||
""" | ||||||
Convolve spherical harmonics with a tissue response function. Useful for | ||||||
checking residuals of ODF estimates. | ||||||
|
||||||
|
||||||
Example | ||||||
------- | ||||||
|
||||||
>>> import nipype.interfaces.mrtrix3 as mrt | ||||||
>>> sh = mrt.SHConv() | ||||||
>>> sh.inputs.in_file = 'odf.mif' | ||||||
>>> sh.inputs.response = 'response.txt' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These files should exist in https://github.com/nipy/nipype/tree/master/nipype/testing/data. If there isn't already one with a name that works for this tool, feel free to create an empty file with that name. |
||||||
>>> sh.cmdline # doctest: +ELLIPSIS | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No
Suggested change
|
||||||
'shconv odf.mif response.txt sh.mif' | ||||||
>>> sh.run() # doctest: +SKIP | ||||||
""" | ||||||
|
||||||
_cmd = "shconv" | ||||||
input_spec = SHConvInputSpec | ||||||
output_spec = SHConvOutputSpec | ||||||
|
||||||
def _list_outputs(self): | ||||||
outputs = self.output_spec().get() | ||||||
outputs["out_file"] = op.abspath(self.inputs.out_file) | ||||||
return outputs | ||||||
|
||||||
|
||||||
|
||||||
class SH2AmpInputSpec(CommandLineInputSpec): | ||||||
in_file = File( | ||||||
exists=True, | ||||||
argstr="%s", | ||||||
mandatory=True, | ||||||
position=-3, | ||||||
desc="input ODF image", | ||||||
) | ||||||
|
||||||
tclose marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# General options | ||||||
directions = File( | ||||||
exists=True, | ||||||
mandatory=True, | ||||||
argstr="%s", | ||||||
position=-2, | ||||||
desc=("The gradient directions along which to sample the spherical " | ||||||
"harmonics MRtrix format"), | ||||||
) | ||||||
|
||||||
tclose marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
out_file = File( | ||||||
"amp.mif", | ||||||
tclose marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
argstr="%s", | ||||||
mandatory=True, | ||||||
tclose marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
position=-1, | ||||||
usedefault=True, | ||||||
desc="the output spherical harmonics", | ||||||
) | ||||||
|
||||||
tclose marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
nonnegative = traits.Bool( | ||||||
argstr='-nonnegative', | ||||||
desc="cap all negative amplitudes to zero") | ||||||
|
||||||
|
||||||
class SH2AmpOutputSpec(TraitedSpec): | ||||||
out_file = File(exists=True, | ||||||
desc="the output convoluted spherical harmonics file") | ||||||
|
||||||
|
||||||
class SH2Amp(CommandLine): | ||||||
""" | ||||||
Sample spherical harmonics on a set of gradient orientations. Useful for | ||||||
checking residuals of ODF estimates. | ||||||
|
||||||
|
||||||
Example | ||||||
------- | ||||||
|
||||||
>>> import nipype.interfaces.mrtrix3 as mrt | ||||||
>>> sh = mrt.SH2Amp() | ||||||
>>> sh.inputs.in_file = 'sh.mif' | ||||||
>>> sh.inputs.directions = 'grads.txt' | ||||||
effigies marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
>>> sh.cmdline # doctest: +ELLIPSIS | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
'sh2amp sh.mif grads.txt amp.mif' | ||||||
tclose marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
>>> sh.run() # doctest: +SKIP | ||||||
""" | ||||||
|
||||||
_cmd = "sh2amp" | ||||||
input_spec = SH2AmpInputSpec | ||||||
output_spec = SH2AmpOutputSpec | ||||||
|
||||||
def _list_outputs(self): | ||||||
outputs = self.output_spec().get() | ||||||
outputs["out_file"] = op.abspath(self.inputs.out_file) | ||||||
return outputs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that you're being consistent with the rest of this function. If you feel the urge, you can fix up the others, but I think we should do this the standard way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On this interface, I remembered that 'predicted_signal' is only a valid option when using the 'msmt_csd' algorithm. Is there a way to specify this in the input spec?