3
3
# @Author: oesteban
4
4
# @Date: 2014-09-01 10:33:35
5
5
# @Last Modified by: oesteban
6
- # @Last Modified time: 2014-09-01 11:27:55
6
+ # @Last Modified time: 2014-09-02 01:12:14
7
7
from nipype .interfaces .base import (traits , TraitedSpec , BaseInterface ,
8
8
File , isdefined )
9
9
from nipype .utils .filemanip import split_filename
29
29
class ResampleInputSpec (TraitedSpec ):
30
30
in_file = File (exists = True , mandatory = True ,
31
31
desc = 'The input 4D diffusion-weighted image file' )
32
- vox_size = traits .Tuple (traits .Float , traits .Float , traits .Float , desc = ('specify the new '
33
- 'voxel zooms. If no vox_size is set, then isotropic regridding will '
34
- 'be performed, with spacing equal to the smallest current zoom.' ))
35
- interp = traits .Int (1 , mandatory = True , usedefault = True , desc = ('order of the interpolator'
36
- '(0 = nearest, 1 = linear, etc.' ))
32
+ vox_size = traits .Tuple (traits .Float , traits .Float , traits .Float ,
33
+ desc = ('specify the new voxel zooms. If no vox_size'
34
+ ' is set, then isotropic regridding will '
35
+ 'be performed, with spacing equal to the '
36
+ 'smallest current zoom.' ))
37
+ interp = traits .Int (1 , mandatory = True , usedefault = True , desc = ('order of '
38
+ 'the interpolator (0 = nearest, 1 = linear, etc.' ))
37
39
38
40
39
41
class ResampleOutputSpec (TraitedSpec ):
@@ -43,7 +45,8 @@ class ResampleOutputSpec(TraitedSpec):
43
45
class Resample (BaseInterface ):
44
46
"""
45
47
An interface to reslicing diffusion datasets.
46
- See http://nipy.org/dipy/examples_built/reslice_datasets.html#example-reslice-datasets.
48
+ See
49
+ http://nipy.org/dipy/examples_built/reslice_datasets.html#example-reslice-datasets.
47
50
48
51
Example
49
52
-------
@@ -87,7 +90,8 @@ class DenoiseInputSpec(TraitedSpec):
87
90
in_file = File (exists = True , mandatory = True ,
88
91
desc = 'The input 4D diffusion-weighted image file' )
89
92
in_mask = File (exists = True , desc = 'brain mask' )
90
- noise_model = traits .Enum ('rician' , 'gaussian' , mandatory = True , usedefault = True ,
93
+ noise_model = traits .Enum ('rician' , 'gaussian' , mandatory = True ,
94
+ usedefault = True ,
91
95
desc = ('noise distribution model' ))
92
96
93
97
@@ -98,13 +102,15 @@ class DenoiseOutputSpec(TraitedSpec):
98
102
class Denoise (BaseInterface ):
99
103
"""
100
104
An interface to denoising diffusion datasets [Coupe2008]_.
101
- See http://nipy.org/dipy/examples_built/denoise_nlmeans.html#example-denoise-nlmeans.
105
+ See
106
+ http://nipy.org/dipy/examples_built/denoise_nlmeans.html#example-denoise-nlmeans.
102
107
103
- .. [Coupe2008] P. Coupe, P. Yger, S. Prima, P. Hellier, C. Kervrann, C. Barillot,
104
- `An Optimized Blockwise Non Local Means Denoising Filter for 3D Magnetic Resonance Images
108
+ .. [Coupe2008] Coupe P et al., `An Optimized Blockwise Non Local Means
109
+ Denoising Filter for 3D Magnetic Resonance Images
105
110
<http://dx.doi.org/10.1109%2FTMI.2007.906087>`_,
106
111
IEEE Transactions on Medical Imaging, 27(4):425-441, 2008.
107
112
113
+
108
114
Example
109
115
-------
110
116
@@ -124,7 +130,7 @@ def _run_interface(self, runtime):
124
130
mask = nb .load (self .inputs .in_mask ).get_data ()
125
131
126
132
nlmeans_proxy (self .inputs .in_file , in_mask = mask ,
127
- rician = (self .inputs .noise_model == 'rician' ),
133
+ rician = (self .inputs .noise_model == 'rician' ),
128
134
out_file = out_file )
129
135
iflogger .info ('Denoised image saved as {i}' .format (i = out_file ))
130
136
return runtime
@@ -141,6 +147,7 @@ def _gen_outfilename(self):
141
147
fext = fext2 + fext
142
148
return op .abspath ('%s_denoise%s' % (fname , fext ))
143
149
150
+
144
151
def resample_proxy (in_file , order = 3 , new_zooms = None , out_file = None ):
145
152
"""
146
153
Performs regridding of an image to set isotropic voxel sizes using dipy.
@@ -205,4 +212,3 @@ def nlmeans_proxy(in_file, in_mask=None, rician=True, out_file=None):
205
212
nb .Nifti1Image (den .astype (hdr .get_data_dtype ()), aff ,
206
213
hdr ).to_filename (out_file )
207
214
return out_file
208
-
0 commit comments