Skip to content

Commit f09d854

Browse files
committed
Add 3dEdge3.
1 parent 6c4e1eb commit f09d854

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Seg, SkullStrip, TCorr1D, TCorrMap, TCorrelate,
1818
TShift, Volreg, Warp, QwarpPlusMinus)
1919
from .svm import (SVMTest, SVMTrain)
20-
from .utils import (AFNItoNIFTI, Autobox, BrickStat, Calc, Copy,
20+
from .utils import (AFNItoNIFTI, Autobox, BrickStat, Calc, Copy, Edge3,
2121
Eval, FWHMx,
2222
MaskTool, Merge, Notes, Refit, Resample, TCat, TStat, To3D,
2323
Unifize, ZCutUp, GCOR,)

nipype/interfaces/afni/utils.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,99 @@ class Copy(AFNICommand):
394394
output_spec = AFNICommandOutputSpec
395395

396396

397+
class Edge3InputSpec(AFNICommandInputSpec):
398+
in_file = File(
399+
desc='input file to 3dedge3',
400+
argstr='-input %s',
401+
position=0,
402+
mandatory=True,
403+
exists=True,
404+
copyfile=False)
405+
out_file = File(
406+
desc='output image file name',
407+
position=-1,
408+
argstr='-prefix %s')
409+
datum = traits.Enum(
410+
'byte','short','float',
411+
argstr='-datum %s',
412+
desc='specify data type for output. Valid types are \'byte\', '
413+
'\'short\' and \'float\'.')
414+
fscale = traits.Bool(
415+
desc='Force scaling of the output to the maximum integer range.',
416+
argstr='-fscale',
417+
xor=['gscale', 'nscale', 'scale_floats'])
418+
gscale = traits.Bool(
419+
desc='Same as \'-fscale\', but also forces each output sub-brick to '
420+
'to get the same scaling factor.',
421+
argstr='-gscale',
422+
xor=['fscale', 'nscale', 'scale_floats'])
423+
nscale = traits.Bool(
424+
desc='Don\'t do any scaling on output to byte or short datasets.',
425+
argstr='-nscale',
426+
xor=['fscale', 'gscale', 'scale_floats'])
427+
scale_floats = traits.Float(
428+
desc='Multiply input by VAL, but only if the input datum is '
429+
'float. This is needed when the input dataset '
430+
'has a small range, like 0 to 2.0 for instance. '
431+
'With such a range, very few edges are detected due to '
432+
'what I suspect to be truncation problems. '
433+
'Multiplying such a dataset by 10000 fixes the problem '
434+
'and the scaling is undone at the output.',
435+
argstr='-scale_floats %f',
436+
xor=['fscale', 'gscale', 'nscale'])
437+
verbose = traits.Bool(
438+
desc='Print out some information along the way.',
439+
argstr='-verbose')
440+
441+
442+
class Edge3(AFNICommand):
443+
"""Does 3D Edge detection using the library 3DEdge
444+
by Gregoire Malandain ([email protected]).
445+
446+
For complete details, see the `3dedge3 Documentation.
447+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dedge3.html>`_
448+
449+
references_ = [{'entry': BibTeX('@article{Deriche1987,'
450+
'author={R. Deriche},'
451+
'title={Optimal edge detection using recursive filtering},'
452+
'journal={International Journal of Computer Vision},'
453+
'volume={2},',
454+
'pages={167-187},'
455+
'year={1987},'
456+
'}'),
457+
'tags': ['method'],
458+
},
459+
{'entry': BibTeX('@article{MongaDericheMalandainCocquerez1991,'
460+
'author={O. Monga, R. Deriche, G. Malandain, J.P. Cocquerez},'
461+
'title={Recursive filtering and edge tracking: two primary tools for 3D edge detection},'
462+
'journal={Image and vision computing},'
463+
'volume={9},',
464+
'pages={203-214},'
465+
'year={1991},'
466+
'}'),
467+
'tags': ['method'],
468+
},
469+
]
470+
471+
Examples
472+
========
473+
474+
>>> from nipype.interfaces import afni
475+
>>> edge3 = afni.Edge3()
476+
>>> edge3.inputs.in_file = 'functional.nii'
477+
>>> edge3.inputs.out_file = 'edges.nii'
478+
>>> edge3.inputs.datum = 'byte'
479+
>>> edge3.cmdline # doctest: +ALLOW_UNICODE
480+
'3dedge3 -input functional.nii -datum byte -prefix edges.nii'
481+
>>> res = edge3.run() # doctest: +SKIP
482+
483+
"""
484+
485+
_cmd = '3dedge3'
486+
input_spec = Edge3InputSpec
487+
output_spec = AFNICommandOutputSpec
488+
489+
397490
class EvalInputSpec(AFNICommandInputSpec):
398491
in_file_a = File(
399492
desc='input file to 1deval',

0 commit comments

Comments
 (0)