Skip to content

Commit 7a6d5bd

Browse files
committed
Merge branch 'enh/FSLb0calc' of https://github.com/oesteban/nipype into oesteban-enh/FSLb0calc
2 parents 4760977 + d1aafee commit 7a6d5bd

File tree

5 files changed

+179
-16
lines changed

5 files changed

+179
-16
lines changed

CHANGES

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Upcoming release 0.13
22
=====================
33

44
* ENH: Add a DVARS calculation interface (https://github.com/nipy/nipype/pull/1606)
5+
* ENH: New interface to b0calc of FSL-POSSUM (https://github.com/nipy/nipype/pull/1399)
56
* ENH: Convenient load/save of interface inputs (https://github.com/nipy/nipype/pull/1591)
67
* ENH: Add a Framewise Displacement calculation interface (https://github.com/nipy/nipype/pull/1604)
78
* FIX: Use builtins open and unicode literals for py3 compatibility (https://github.com/nipy/nipype/pull/1572)
@@ -124,14 +125,14 @@ Release 0.11.0 (September 15, 2015)
124125
* FIX: Bug crashed 'make api' (https://github.com/nipy/nipype/pull/1026)
125126
* ENH: Updated antsIntroduction to handle RA and RI registrations (https://github.com/nipy/nipype/pull/1009)
126127
* ENH: Updated N4BiasCorrection input spec to include weight image and spline order. Made
127-
argument formatting consistent. Cleaned ants.segmentation according to PEP8.
128-
(https://github.com/nipy/nipype/pull/990/files)
128+
argument formatting consistent. Cleaned ants.segmentation according to PEP8.
129+
(https://github.com/nipy/nipype/pull/990/files)
129130
* ENH: SPM12 Normalize interface (https://github.com/nipy/nipype/pull/986)
130131
* FIX: Utility interface test dir (https://github.com/nipy/nipype/pull/986)
131132
* FIX: IPython engine directory reset after crash (https://github.com/nipy/nipype/pull/987)
132133
* ENH: Resting state fMRI example with NiPy realignment and no SPM (https://github.com/nipy/nipype/pull/992)
133134
* FIX: Corrected Freesurfer SegStats _list_outputs to avoid error if summary_file is
134-
undefined (issue #994)(https://https://github.com/nipy/nipype/pull/996)
135+
undefined (issue #994)(https://https://github.com/nipy/nipype/pull/996)
135136
* FIX: OpenfMRI support and FSL 5.0.7 changes (https://github.com/nipy/nipype/pull/1006)
136137
* FIX: Output prefix in SPM Normalize with modulation (https://github.com/nipy/nipype/pull/1023)
137138
* ENH: Usability improvements in cluster environments (https://github.com/nipy/nipype/pull/1025)
@@ -213,11 +214,11 @@ Release 0.9.0 (December 20, 2013)
213214
* ENH: AFNI interfaces refactor, prefix, suffix are replaced by
214215
"flexible_%s_templates"
215216
* ENH: New SPM interfaces:
216-
- spm.ResliceToReference,
217-
- spm.DicomImport
217+
- spm.ResliceToReference,
218+
- spm.DicomImport
218219
* ENH: New AFNI interfaces:
219-
- afni.AFNItoNIFTI
220-
- afni.TCorr1D
220+
- afni.AFNItoNIFTI
221+
- afni.TCorr1D
221222
* ENH: Several new interfaces related to Camino were added:
222223
- camino.SFPICOCalibData
223224
- camino.Conmat
@@ -231,13 +232,13 @@ Release 0.9.0 (December 20, 2013)
231232
- mrtrix.FindShPeaks
232233
- mrtrix.Directions2Amplitude
233234
* ENH: New FSL interfaces:
234-
- fsl.PrepareFieldmap
235-
- fsl.TOPUP
236-
- fsl.ApplyTOPUP
237-
- fsl.Eddy
235+
- fsl.PrepareFieldmap
236+
- fsl.TOPUP
237+
- fsl.ApplyTOPUP
238+
- fsl.Eddy
238239
* ENH: New misc interfaces:
239-
- FuzzyOverlap,
240-
- P2PDistance
240+
- FuzzyOverlap,
241+
- P2PDistance
241242
* ENH: New workflows: nipype.workflows.dmri.fsl.epi.[fieldmap_correction&topup_correction]
242243
* ENH: Added simplified outputname generation for command line interfaces.
243244
* ENH: Allow ants use a single mask image
@@ -295,7 +296,7 @@ Release 0.7.0 (Dec 18, 2012)
295296
afni.AutoTcorrelate, DcmStack
296297
* ENH: New workflows: ants template building (both using 'ANTS' and the new 'antsRegistration')
297298
* ENH: New examples: how to use ANTS template building workflows (smri_ants_build_tmeplate),
298-
how to set SGE specific options (smri_ants_build_template_new)
299+
how to set SGE specific options (smri_ants_build_template_new)
299300
* ENH: added no_flatten option to Merge
300301
* ENH: added versioning option and checking to traits
301302
* ENH: added deprecation metadata to traits
@@ -357,9 +358,9 @@ Release 0.5 (Mar 10, 2012)
357358
* API: Canned workflows are now all under a different package structure
358359
* API: SpecifyModel event_info renamed to event_files
359360
* API: DataGrabber is always being rerun (unless overwrite is set to False on
360-
Node level)
361+
Node level)
361362
* API: "stop_on_first_rerun" does not stop for DataGrabber (unless overwrite is
362-
set to True on Node level)
363+
set to True on Node level)
363364
* API: Output prefix can be set for spm nodes (SliceTiming, Realign, Coregister,
364365
Normalize, Smooth)
365366

nipype/interfaces/fsl/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@
3030
from .maths import (ChangeDataType, Threshold, MeanImage, ApplyMask,
3131
IsotropicSmooth, TemporalFilter, DilateImage, ErodeImage,
3232
SpatialFilter, UnaryMaths, BinaryMaths, MultiImageMaths)
33+
34+
from .possum import B0Calc

nipype/interfaces/fsl/possum.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
4+
# vi: set ft=python sts=4 ts=4 sw=4 et:
5+
"""
6+
The possum module provides classes for interfacing with `POSSUM
7+
<http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/POSSUM>`_ command line tools.
8+
Please, check out the link for pertinent citations using POSSUM.
9+
10+
.. Note:: This was written to work with FSL version 5.0.6.
11+
12+
.. testsetup::
13+
# Change directory to provide relative paths for doctests
14+
import os
15+
filepath = os.path.dirname( os.path.realpath( __file__ ) )
16+
datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
17+
os.chdir(datadir)
18+
19+
"""
20+
21+
from .base import FSLCommand, FSLCommandInputSpec
22+
from ..base import TraitedSpec, File, traits
23+
24+
25+
class B0CalcInputSpec(FSLCommandInputSpec):
26+
in_file = File(exists=True, mandatory=True, argstr='-i %s', position=0,
27+
desc='filename of input image (usually a tissue/air segmentation)')
28+
out_file = File(argstr='-o %s', position=1, name_source=['in_file'],
29+
name_template='%s_b0field', output_name='out_file',
30+
desc='filename of B0 output volume')
31+
32+
x_grad = traits.Float(0.0, argstr='--gx=%0.4f',
33+
desc='Value for zeroth-order x-gradient field (per mm)')
34+
y_grad = traits.Float(0.0, argstr='--gy=%0.4f',
35+
desc='Value for zeroth-order y-gradient field (per mm)')
36+
z_grad = traits.Float(0.0, argstr='--gz=%0.4f',
37+
desc='Value for zeroth-order z-gradient field (per mm)')
38+
39+
x_b0 = traits.Float(0.0, argstr='--b0x=%0.2f', xor=['xyz_b0'],
40+
desc='Value for zeroth-order b0 field (x-component), in Tesla')
41+
y_b0 = traits.Float(0.0, argstr='--b0y=%0.2f', xor=['xyz_b0'],
42+
desc='Value for zeroth-order b0 field (y-component), in Tesla')
43+
z_b0 = traits.Float(1.0, argstr='--b0=%0.2f', xor=['xyz_b0'],
44+
desc='Value for zeroth-order b0 field (z-component), in Tesla')
45+
46+
xyz_b0 = traits.Tuple(
47+
traits.Float, traits.Float, traits.Float,
48+
argstr='--b0x=%0.2f --b0y=%0.2f --b0=%0.2f', xor=['x_b0', 'y_b0', 'z_b0'],
49+
desc='Zeroth-order B0 field in Tesla')
50+
51+
delta = traits.Float(-9.45e-6, argstr='-d %e',
52+
desc='Delta value (chi_tissue - chi_air)')
53+
chi_air = traits.Float(
54+
4.0e-7, argstr='--chi0=%e', desc='susceptibility of air')
55+
compute_xyz = traits.Bool(False, argstr='--xyz',
56+
desc='calculate and save all 3 field components (i.e. x,y,z)')
57+
extendboundary = traits.Float(1.0, argstr='--extendboundary=%0.2f',
58+
desc='Relative proportion to extend voxels at boundary')
59+
directconv = traits.Bool(False, argstr='--directconv',
60+
desc='use direct (image space) convolution, not FFT')
61+
62+
63+
class B0CalcOutputSpec(TraitedSpec):
64+
out_file = File(exists=True, desc='filename of B0 output volume')
65+
66+
67+
class B0Calc(FSLCommand):
68+
69+
"""
70+
B0 inhomogeneities occur at interfaces of materials with different magnetic susceptibilities,
71+
such as tissue-air interfaces. These differences lead to distortion in the local magnetic field,
72+
as Maxwell’s equations need to be satisfied. An example of B0 inhomogneity is the first volume
73+
of the 4D volume ```$FSLDIR/data/possum/b0_ppm.nii.gz```.
74+
75+
Examples
76+
--------
77+
78+
>>> from nipype.interfaces.fsl import B0Calc
79+
>>> b0calc = B0Calc()
80+
>>> b0calc.inputs.in_file = 'tissue+air_map.nii'
81+
>>> b0calc.inputs.z_b0 = 3.0
82+
>>> b0calc.cmdline # doctest: +IGNORE_UNICODE
83+
'b0calc -i tissue+air_map.nii -o tissue+air_map_b0field.nii.gz --b0=3.00'
84+
85+
"""
86+
87+
_cmd = 'b0calc'
88+
input_spec = B0CalcInputSpec
89+
output_spec = B0CalcOutputSpec
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from ....testing import assert_equal
3+
from ..possum import B0Calc
4+
5+
6+
def test_B0Calc_inputs():
7+
input_map = dict(args=dict(argstr='%s',
8+
),
9+
chi_air=dict(argstr='--chi0=%e',
10+
),
11+
compute_xyz=dict(argstr='--xyz',
12+
),
13+
delta=dict(argstr='-d %e',
14+
),
15+
directconv=dict(argstr='--directconv',
16+
),
17+
environ=dict(nohash=True,
18+
usedefault=True,
19+
),
20+
extendboundary=dict(argstr='--extendboundary=%0.2f',
21+
),
22+
ignore_exception=dict(nohash=True,
23+
usedefault=True,
24+
),
25+
in_file=dict(argstr='-i %s',
26+
mandatory=True,
27+
position=0,
28+
),
29+
out_file=dict(argstr='-o %s',
30+
name_source=['in_file'],
31+
name_template='%s_b0field',
32+
output_name='out_file',
33+
position=1,
34+
),
35+
output_type=dict(),
36+
terminal_output=dict(nohash=True,
37+
),
38+
x_b0=dict(argstr='--b0x=%0.2f',
39+
xor=['xyz_b0'],
40+
),
41+
x_grad=dict(argstr='--gx=%0.4f',
42+
),
43+
xyz_b0=dict(argstr='--b0x=%0.2f --b0y=%0.2f --b0=%0.2f',
44+
xor=['x_b0', 'y_b0', 'z_b0'],
45+
),
46+
y_b0=dict(argstr='--b0y=%0.2f',
47+
xor=['xyz_b0'],
48+
),
49+
y_grad=dict(argstr='--gy=%0.4f',
50+
),
51+
z_b0=dict(argstr='--b0=%0.2f',
52+
xor=['xyz_b0'],
53+
),
54+
z_grad=dict(argstr='--gz=%0.4f',
55+
),
56+
)
57+
inputs = B0Calc.input_spec()
58+
59+
for key, metadata in list(input_map.items()):
60+
for metakey, value in list(metadata.items()):
61+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
62+
63+
64+
def test_B0Calc_outputs():
65+
output_map = dict(out_file=dict(),
66+
)
67+
outputs = B0Calc.output_spec()
68+
69+
for key, metadata in list(output_map.items()):
70+
for metakey, value in list(metadata.items()):
71+
yield assert_equal, getattr(outputs.traits()[key], metakey), value

nipype/testing/data/tissue+air_map.nii

Whitespace-only changes.

0 commit comments

Comments
 (0)