Skip to content

Commit 1c174df

Browse files
authored
Merge pull request #2185 from kesshijordan/dtitk
WIP: Dtitk
2 parents e125c95 + f60c149 commit 1c174df

21 files changed

+1829
-0
lines changed

nipype/interfaces/dtitk/__init__.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""The dtitk module provides classes for interfacing with the `Diffusion
2+
Tensor Imaging Toolkit (DTI-TK)
3+
<http://dti-tk.sourceforge.net/pmwiki/pmwiki.php>`_ command line tools.
4+
5+
Top-level namespace for dti-tk.
6+
"""
7+
8+
# from .base import ()
9+
from .registration import (RigidTask, AffineTask, DiffeoTask,
10+
ComposeXfmTask, diffeoSymTensor3DVolTask,
11+
affSymTensor3DVolTask, affScalarVolTask,
12+
diffeoScalarVolTask)
13+
from .utils import (TVAdjustOriginTask, TVAdjustVoxSpTask,
14+
SVAdjustVoxSpTask, TVResampleTask, SVResampleTask,
15+
TVtoolTask, BinThreshTask)

nipype/interfaces/dtitk/base.py

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# -*- coding: utf-8 -*-
2+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
3+
# vi: set ft=python sts=4 ts=4 sw=4 et:
4+
"""The dtitk module provides classes for interfacing with the `DTITK
5+
<http://dti-tk.sourceforge.net/pmwiki/pmwiki.php>`_ command line tools.
6+
7+
These are the base tools for working with DTITK.
8+
Preprocessing tools are found in dtitk/preprocess.py
9+
Registration tools are found in dtitk/registration.py
10+
11+
Currently these tools are supported:
12+
13+
* Rigid Tensor Registration
14+
* Affine Tensor Registration
15+
* Diffeomorphic Tensor Registration
16+
17+
Examples
18+
--------
19+
See the docstrings of the individual classes for examples.
20+
21+
"""
22+
from __future__ import print_function, division, unicode_literals, \
23+
absolute_import
24+
25+
import os
26+
27+
from ... import logging
28+
from ...utils.filemanip import fname_presuffix
29+
from ..base import CommandLine
30+
from nipype.interfaces.fsl.base import Info
31+
32+
LOGGER = logging.getLogger('interface')
33+
34+
35+
class CommandLineDtitk(CommandLine):
36+
37+
def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True,
38+
ext=None):
39+
"""Generate a filename based on the given parameters.
40+
41+
The filename will take the form: cwd/basename<suffix><ext>.
42+
If change_ext is True, it will use the extentions specified in
43+
<instance>intputs.output_type.
44+
45+
Parameters
46+
----------
47+
basename : str
48+
Filename to base the new filename on.
49+
cwd : str
50+
Path to prefix to the new filename. (default is os.getcwd())
51+
suffix : str
52+
Suffix to add to the `basename`. (defaults is '' )
53+
change_ext : bool
54+
Flag to change the filename extension to the FSL output type.
55+
(default True)
56+
57+
Returns
58+
-------
59+
fname : str
60+
New filename based on given parameters.
61+
62+
"""
63+
64+
if basename == '':
65+
msg = 'Unable to generate filename for command %s. ' % self.cmd
66+
msg += 'basename is not set!'
67+
raise ValueError(msg)
68+
if cwd is None:
69+
cwd = os.getcwd()
70+
if ext is None:
71+
ext = Info.output_type_to_ext(self.inputs.output_type)
72+
if change_ext:
73+
if suffix:
74+
suffix = ''.join((suffix, ext))
75+
else:
76+
suffix = ext
77+
if suffix is None:
78+
suffix = ''
79+
fname = fname_presuffix(basename, suffix=suffix,
80+
use_ext=False, newpath=cwd)
81+
return fname

0 commit comments

Comments
 (0)