Skip to content

FIX: DTITK Interface #2514

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

Merged
merged 58 commits into from
Apr 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
094c475
changes made by make, I think
Sep 11, 2017
f818961
Merge remote-tracking branch 'upstream/master'
Sep 11, 2017
0c28b39
fix: dtitk interface specs
satra Feb 23, 2018
b412659
Merge branch 'master' of https://github.com/nipy/nipype
kesshijordan Feb 27, 2018
6673083
Merge branch 'fix/specs' of https://github.com/satra/nipype into satr…
kesshijordan Feb 27, 2018
70d8d63
redo input for rigid registration such that default values are passed…
kesshijordan Feb 27, 2018
19f4904
fixed interface specs for Rigid and Affine
kesshijordan Feb 27, 2018
01d9666
incorporating changes to mandatory flag and specifying type of inputs
kesshijordan Mar 22, 2018
a913e6f
fixed TVAdjustVoxelspace; removed AdjustOrigin because it's redundant
kesshijordan Mar 22, 2018
1ef2ca6
TVResample fixed
kesshijordan Mar 22, 2018
50a9f1c
more modifications to get all interfaces working/standardized (not do…
kesshijordan Mar 23, 2018
6bb86e4
added cmdline to doctest, fixed ComposeXfm interface
kesshijordan Mar 25, 2018
197b793
Fixed TVtool
kesshijordan Mar 25, 2018
e670fe1
Incorporated recommendations from @effigies. Fixed TVResample interface
kesshijordan Mar 25, 2018
b1581ab
BinThresh fixed; xor added to TVAdjustVoxelSpace
kesshijordan Mar 25, 2018
db590d5
compressed sampling to tuple input, switched use of previously calcul…
kesshijordan Mar 25, 2018
f474554
affSymTensor3DVol interface fixed
kesshijordan Mar 26, 2018
32e4f02
Made use of affine not default per @effigies suggestion.
kesshijordan Mar 26, 2018
de50d4e
SVAdjustVoxelspace interface fixed
kesshijordan Mar 26, 2018
cb2b537
SVResample interface fixed
kesshijordan Mar 26, 2018
aeb2c55
removed old SVResample
kesshijordan Mar 26, 2018
5049458
minor wording
kesshijordan Mar 26, 2018
98e181a
affSymTensor3DVol interface fixed
kesshijordan Mar 26, 2018
f601c68
diffeoSymTensor3DVol fixed
kesshijordan Mar 26, 2018
49d0138
diffeoScalarVol interface fixed
kesshijordan Mar 26, 2018
78e155d
Merge branch 'master' of https://github.com/nipy/nipype into satra_fi…
kesshijordan Mar 26, 2018
605f3b5
From @effigies: prefatory lines no longer necessary. Tests are now ru…
kesshijordan Mar 26, 2018
ea6afb8
fix test bugs
kesshijordan Mar 27, 2018
2acb241
add tests
kesshijordan Mar 27, 2018
ddfd19d
added extra tests from other interfaces
kesshijordan Mar 27, 2018
37fb6f9
renamed interfaces; regenerated auto tests
kesshijordan Mar 28, 2018
1bc8a1c
renamed interfaces
kesshijordan Mar 28, 2018
2fea4fa
added new fake files for testing
kesshijordan Mar 28, 2018
1deaad8
Various modifications based on code review by @effigies
kesshijordan Mar 28, 2018
def5d6b
made interfaces more user friendly
kesshijordan Mar 28, 2018
5499794
fixed bug
kesshijordan Mar 29, 2018
0244983
this works
kesshijordan Mar 29, 2018
cfcb91d
fixed conversion int label to string
kesshijordan Mar 29, 2018
a10da5d
temp fix composexfm naming (still a problem)
kesshijordan Mar 29, 2018
0839823
fixed syntax, line continuation
kesshijordan Mar 30, 2018
1379dc6
fixed strings for tests
kesshijordan Mar 30, 2018
d40ba45
Merge branch 'master' of https://github.com/nipy/nipype into satra_fi…
kesshijordan Apr 3, 2018
4cedad9
merged master, ran make specs
kesshijordan Apr 3, 2018
155ae52
miscellaneous fixes from code review
kesshijordan Apr 3, 2018
e921ddf
added descriptions, few minor fixes
kesshijordan Apr 9, 2018
08babbc
removed automatic author label
kesshijordan Apr 9, 2018
f1fac40
temporary fix for composeXfm naming
kesshijordan Apr 10, 2018
cae974e
added mixin for backward compatability since interfaces were renamed
kesshijordan Apr 10, 2018
7c41d5d
fixed composeXfm naming; added tests for old interface names
kesshijordan Apr 10, 2018
5b2462c
minor fixes
kesshijordan Apr 10, 2018
a3c391c
task vs TASK
kesshijordan Apr 10, 2018
c644343
bug: copyfile=False caused execution input to be changed from the cor…
kesshijordan Apr 11, 2018
5df307c
tests for composexfm change
kesshijordan Apr 11, 2018
898db0c
made files save to node working directories
kesshijordan Apr 12, 2018
ca52d94
made check for ".aff not found" to raise error so that it doesn't fai…
kesshijordan Apr 12, 2018
6224080
changed description on initialize_xfm
kesshijordan Apr 12, 2018
769a0fc
added workflows for simple linear and nonlinear tensor registration
kesshijordan Apr 13, 2018
62e3456
added resliced ims to wf output, tweaked registration interface params
kesshijordan Apr 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
made interfaces more user friendly
  • Loading branch information
kesshijordan committed Mar 28, 2018
commit def5d6b8efa40087cb9357b9918f91b0fccc4d11
67 changes: 45 additions & 22 deletions nipype/interfaces/dtitk/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ class ComposeXfmInputSpec(CommandLineInputSpec):
argstr="-df %s", copyfile=False, mandatory=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is copyfile=False required here? I think name_source should handle changing directories fine, but you should check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this... @satra changed it in #2463. I can look into it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. It's not a big deal, either way.

in_aff = File(desc='affine transform file', exists=True,
argstr="-aff %s", mandatory=True)
out_file = traits.File(desc='output path',
argstr="-out %s", name_source="in_df",
name_template="%s_aff.df", keep_extension=True)
out_file = File(desc='output path',
argstr="-out %s", name_source="in_df",
name_template="%s_aff.df", keep_extension=True)


class ComposeXfmOutputSpec(TraitedSpec):
Expand Down Expand Up @@ -196,9 +196,9 @@ class ComposeXfm(CommandLineDtitk):
class affSymTensor3DVolInputSpec(CommandLineInputSpec):
in_file = File(desc='moving tensor volume', exists=True,
argstr="-in %s", mandatory=True)
out_file = traits.File(desc='output filename',
argstr="-out %s", name_source="in_file",
name_template="%s_affxfmd", keep_extension=True)
out_file = File(desc='output filename',
argstr="-out %s", name_source="in_file",
name_template="%s_affxfmd", keep_extension=True)
transform = File(exists=True, argstr="-trans %s",
xor=['target', 'translation', 'euler', 'deformation'],
desc='transform to apply: specify an input transformation\
Expand Down Expand Up @@ -254,16 +254,17 @@ class affSymTensor3DVol(CommandLineDtitk):
class affScalarVolInputSpec(CommandLineInputSpec):
in_file = File(desc='moving scalar volume', exists=True,
argstr="-in %s", mandatory=True)
out_file = traits.File(desc='output filename',
argstr="-out %s", name_source="in_file",
name_template="%s_affxfmd", keep_extension=True)
out_file = File(desc='output filename',
argstr="-out %s", name_source="in_file",
name_template="%s_affxfmd", keep_extension=True)
transform = File(exists=True, argstr="-trans %s",
xor=['target', 'translation', 'euler', 'deformation'],
desc='transform to apply: specify an input transformation\
file; parameters input will be ignored',)
interpolation = traits.Enum(0, 1, usedefault=True,
argstr="-interp %s",
desc='0=trilinear (def); 1=nearest neighbor')
interpolation = traits.Enum('trilinear', 'NN',
usedefault=True, argstr="-interp %s",
desc='trilinear or nearest neighbor\
interpolation')
target = File(exists=True, argstr="-target %s", xor=['transform'],
desc='output volume specification read from the target volume\
if specified')
Expand Down Expand Up @@ -301,13 +302,18 @@ class affScalarVol(CommandLineDtitk):
output_spec = affScalarVolOutputSpec
_cmd = 'affineScalarVolume'

def _format_arg(self, name, spec, value):
if name == 'interpolation':
value = {'trilinear': 0, 'NN': 1}[value]
super(affScalarVol, self)._format_arg(name, spec, value)


class diffeoSymTensor3DVolInputSpec(CommandLineInputSpec):
in_file = File(desc='moving tensor volume', exists=True,
argstr="-in %s", mandatory=True)
out_file = traits.File(desc='output filename',
argstr="-out %s", name_source="in_file",
name_template="%s_diffeoxfmd", keep_extension=True)
out_file = File(desc='output filename',
argstr="-out %s", name_source="in_file",
name_template="%s_diffeoxfmd", keep_extension=True)
transform = File(exists=True, argstr="-trans %s",
mandatory=True, desc='transform to apply')
df = traits.Str('FD', argstr="-df %s", usedefault=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description?

And if -df were omitted, it would act as if -df FD were passed? Are there no other options?

Copy link
Contributor Author

@kesshijordan kesshijordan Apr 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usage of deformationSymTensor3DVolume :
-in type: string(s) required: Y
-out type: string(s) required: Y
-trans type: string(s) required: Y
-df type: string(s) required: N default: FD
-interp type: string(s) required: N default: LEI EI or LEI
-reorient type: string(s) required: N default: PPD FS or PPD
-target type: string(s) required: N output volume specification read from the target volume if specified
-vsize type: double(s) required: N
-flip type: integer(s) required: N default: 0 0 0
-type type: integer(s) required: N default: 1 resampling type, 1 for backward (default) and 0 for forward

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the documentation. I think that is the case... "df" usually means "deformation field" in this package, but I'm not sure what FD stands for (I didn't find it in the documentation).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Okay, this makes sense. It sets the default, but because it's Str not Enum, it lets users who know more than we do set an alternative.

Expand All @@ -326,7 +332,8 @@ class diffeoSymTensor3DVolInputSpec(CommandLineInputSpec):
argstr="-vsize %g %g %g", xor=['target'])
flip = traits.Tuple((traits.Int(), traits.Int(), traits.Int()),
exists=True, argstr="-flip %d %d %d")
resampling_type = traits.Enum(1, 0, desc='1=backward(def), 0=forward',
resampling_type = traits.Enum('backward', 'forward',
desc='use backward or forward resampling',
exists=True, argstr="-type %d")


Expand Down Expand Up @@ -355,13 +362,18 @@ class diffeoSymTensor3DVol(CommandLineDtitk):
output_spec = diffeoSymTensor3DVolOutputSpec
_cmd = 'deformationSymTensor3DVolume'

def _format_arg(self, name, spec, value):
if name == 'resampling_type':
value = {'forward': 0, 'backward': 1}[value]
super(diffeoSymTensor3DVol, self)._format_arg(name, spec, value)


class diffeoScalarVolInputSpec(CommandLineInputSpec):
in_file = File(desc='moving scalar volume', exists=True,
argstr="-in %s", mandatory=True)
out_file = traits.File(desc='output filename',
argstr="-out %s", name_source="in_file",
name_template="%s_diffeoxfmd", keep_extension=True)
out_file = File(desc='output filename',
argstr="-out %s", name_source="in_file",
name_template="%s_diffeoxfmd", keep_extension=True)
transform = transform = File(exists=True, argstr="-trans %s",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transform = transform =

mandatory=True, desc='transform to apply')
target = File(exists=True, argstr="-target %s", xor=['voxel_size'],
Expand All @@ -372,10 +384,13 @@ class diffeoScalarVolInputSpec(CommandLineInputSpec):
argstr="-vsize %g %g %g", xor=['target'])
flip = traits.Tuple((traits.Int(), traits.Int(), traits.Int()),
exists=True, argstr="-flip %d %d %d")
resampling_type = traits.Enum(1, 0, desc='1=backward(def), 0=forward',
resampling_type = traits.Enum('backward', 'forward',
desc='use backward or forward resampling',
exists=True, argstr="-type %d")
interp = traits.Enum(0, 1, desc='0=trilinear(def), 1=nearest neighbor',
exists=True, argstr="-interp %d", usedefault=True)
interpolation = traits.Enum('trilinear', 'NN',
desc='trilinear, or nearest neighbor',
exists=True, argstr="-interp %d",
usedefault=True)


class diffeoScalarVolOutputSpec(TraitedSpec):
Expand All @@ -402,3 +417,11 @@ class diffeoScalarVol(CommandLineDtitk):
input_spec = diffeoScalarVolInputSpec
output_spec = diffeoScalarVolOutputSpec
_cmd = 'deformationScalarVolume'

def _format_arg(self, name, spec, value):
if name == 'resampling_type':
value = {'forward': 0, 'backward': 1}[value]
super(diffeoScalarVol, self)._format_arg(name, spec, value)
if name == 'interpolation':
value = {'trilinear': 0, 'NN': 1}[value]
super(diffeoScalarVol, self)._format_arg(name, spec, value)
39 changes: 19 additions & 20 deletions nipype/interfaces/dtitk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
class TVAdjustVoxSpInputSpec(CommandLineInputSpec):
in_file = File(desc="tensor volume to modify", exists=True,
mandatory=True, argstr="-in %s")
out_file = traits.File(genfile=True, desc='output path',
argstr="-out %s", name_source='in_file',
name_template='%s_avs', keep_extension=True)
target_file = traits.File(desc='target volume to match',
argstr="-target %s",
xor=['voxel_size', 'origin'])
out_file = File(genfile=True, desc='output path',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think genfile is an older mechanism than name_template, and no longer recommended. So we'd just drop genfile=True and keep this trait otherwise as is. @satra is this correct?

Copy link
Contributor Author

@kesshijordan kesshijordan Apr 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should genfile=True be used for TVtool? (in this case, we are building the filename from multiple inputs)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that one is fine to leave, since we're not modifying it to use name_template.

argstr="-out %s", name_source='in_file',
name_template='%s_avs', keep_extension=True)
target_file = File(desc='target volume to match',
argstr="-target %s",
xor=['voxel_size', 'origin'])
voxel_size = traits.Tuple((traits.Float(), traits.Float(), traits.Float()),
desc='xyz voxel size (superseded by target)',
argstr="-vsize %g %g %g", xor=['target_file'])
Expand Down Expand Up @@ -77,9 +77,9 @@ class TVAdjustVoxSp(CommandLineDtitk):
class SVAdjustVoxSpInputSpec(CommandLineInputSpec):
in_file = File(desc="scalar volume to modify", exists=True,
mandatory=True, argstr="-in %s")
out_file = traits.File(desc='output path', argstr="-out %s",
name_source="in_file", name_template='%s_avs',
keep_extension=True)
out_file = File(desc='output path', argstr="-out %s",
name_source="in_file", name_template='%s_avs',
keep_extension=True)
target_file = File(desc='target volume to match',
argstr="-target %s", xor=['voxel_size', 'origin'])
voxel_size = traits.Tuple((traits.Float(), traits.Float(), traits.Float()),
Expand Down Expand Up @@ -118,9 +118,9 @@ class SVAdjustVoxSp(CommandLineDtitk):
class TVResampleInputSpec(CommandLineInputSpec):
in_file = File(desc="tensor volume to resample", exists=True,
mandatory=True, argstr="-in %s")
out_file = traits.File(desc='output path',
name_source="in_file", name_template="%s_resampled",
keep_extension=True, argstr="-out %s")
out_file = File(desc='output path',
name_source="in_file", name_template="%s_resampled",
keep_extension=True, argstr="-out %s")
target_file = File(desc='specs read from the target volume',
argstr="-target %s",
xor=['array_size', 'voxel_size', 'origin'])
Expand Down Expand Up @@ -166,9 +166,9 @@ class TVResample(CommandLineDtitk):
class SVResampleInputSpec(CommandLineInputSpec):
in_file = File(desc="image to resample", exists=True,
mandatory=True, argstr="-in %s")
out_file = traits.File(desc='output path',
name_source="in_file", name_template="%s_resampled",
keep_extension=True, argstr="-out %s")
out_file = File(desc='output path',
name_source="in_file", name_template="%s_resampled",
keep_extension=True, argstr="-out %s")
target_file = File(desc='specs read from the target volume',
argstr="-target %s",
xor=['array_size', 'voxel_size', 'origin'])
Expand Down Expand Up @@ -215,8 +215,7 @@ class TVtoolInputSpec(CommandLineInputSpec):
'''NOTE: there are a lot more options here; not implementing all of them'''
in_flag = traits.Enum('fa', 'tr', 'ad', 'rd', 'pd', 'rgb', exists=True,
argstr="-%s", desc='')
out_file = traits.File(exists=True,
argstr="-out %s", genfile=True)
out_file = File(exists=True, argstr="-out %s", genfile=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exists=True will fail if the file doesn't already exist, which it probably won't.



class TVtoolOutputSpec(TraitedSpec):
Expand Down Expand Up @@ -263,9 +262,9 @@ def _gen_filename(self, name):
class BinThreshInputSpec(CommandLineInputSpec):
in_file = File(desc='Image to threshold/binarize', exists=True,
position=0, argstr="%s", mandatory=True)
out_file = traits.File(desc='', position=1, argstr="%s",
keep_extension=True, name_source='in_file',
name_template='%s_thrbin')
out_file = File(desc='', position=1, argstr="%s",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty description.

keep_extension=True, name_source='in_file',
name_template='%s_thrbin')
lower_bound = traits.Float(0.01, position=2, argstr="%g", mandatory=True)
upper_bound = traits.Float(100, position=3, argstr="%g", mandatory=True)
inside_value = traits.Float(1, position=4, argstr="%g", usedefault=True,
Expand Down