|
| 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 | +# @Author: oesteban - [email protected] |
| 7 | +# @Date: 2014-07-03 15:27:53 |
| 8 | +# @Last Modified by: oesteban |
| 9 | +# @Last Modified time: 2014-07-03 16:26:09 |
| 10 | +""" |
| 11 | +The possum module provides classes for interfacing with `POSSUM |
| 12 | +<http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/POSSUM>`_ command line tools. |
| 13 | +Please, check out the link for pertinent citations using POSSUM. |
| 14 | +
|
| 15 | +.. Note:: This was written to work with FSL version 5.0.6. |
| 16 | +
|
| 17 | + Change directory to provide relative paths for doctests |
| 18 | + >>> import os |
| 19 | + >>> filepath = os.path.dirname( os.path.realpath( __file__ ) ) |
| 20 | + >>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data')) |
| 21 | + >>> os.chdir(datadir) |
| 22 | +
|
| 23 | +""" |
| 24 | + |
| 25 | +import os |
| 26 | +import shutil |
| 27 | +import warnings |
| 28 | + |
| 29 | +from nipype.interfaces.fsl.base import FSLCommand, FSLCommandInputSpec, Info |
| 30 | +from nipype.interfaces.base import (TraitedSpec, isdefined, File, Directory, |
| 31 | + InputMultiPath, OutputMultiPath, traits) |
| 32 | +from nipype.utils.filemanip import fname_presuffix, split_filename, copyfile |
| 33 | + |
| 34 | + |
| 35 | +class B0CalcInputSpec(FSLCommandInputSpec): |
| 36 | + in_file = File(exists=True, mandatory=True, argstr='-i %s', position=0, |
| 37 | + desc='filename of input image (usually a tissue/air segmentation)') |
| 38 | + out_file = File(argstr='-o %s', position=1, name_source=['in_file'], |
| 39 | + name_template='%s_b0field', output_name='out_file', |
| 40 | + desc='filename of B0 output volume') |
| 41 | + |
| 42 | + |
| 43 | + x_grad = traits.Float(0.0, argstr='--gx=%0.4f', desc=('Value for zeroth-order x-gradient field ' |
| 44 | + '(per mm)')) |
| 45 | + y_grad = traits.Float(0.0, argstr='--gy=%0.4f', desc=('Value for zeroth-order y-gradient field ' |
| 46 | + '(per mm)')) |
| 47 | + z_grad = traits.Float(0.0, argstr='--gz=%0.4f', desc=('Value for zeroth-order z-gradient field ' |
| 48 | + '(per mm)')) |
| 49 | + |
| 50 | + x_b0 = traits.Float(0.0, argstr='--b0x=%0.2f', desc=('Value for zeroth-order b0 field ' |
| 51 | + '(x-component), in Tesla')) |
| 52 | + y_b0 = traits.Float(0.0, argstr='--b0y=%0.2f', desc=('Value for zeroth-order b0 field ' |
| 53 | + '(y-component), in Tesla')) |
| 54 | + z_b0 = traits.Float(1.0, argstr='--b0=%0.2f', desc=('Value for zeroth-order b0 field ' |
| 55 | + '(z-component), in Tesla')) |
| 56 | + |
| 57 | + delta = traits.Float(-9.45e-6, argstr='-d %e', desc='Delta value (chi_tissue - chi_air)') |
| 58 | + chi_air = traits.Float(4.0e-7, argstr='--chi0=%e', desc='susceptibility of air') |
| 59 | + compute_xyz = traits.Bool(False, argstr='--xyz', |
| 60 | + desc='calculate and save all 3 field components (i.e. x,y,z)') |
| 61 | + extendboundary = traits.Float(1.0, argstr='--extendboundary=%0.2f', desc=('Relative proportion to ' |
| 62 | + 'extend voxels at boundary')) |
| 63 | + directconv = traits.Bool(False, argstr='--directconv', |
| 64 | + desc='use direct (image space) convolution, not FFT') |
| 65 | + |
| 66 | + |
| 67 | +class B0CalcOutputSpec(TraitedSpec): |
| 68 | + out_file = File(exists=True, desc='filename of B0 output volume') |
| 69 | + |
| 70 | + |
| 71 | +class B0Calc(FSLCommand): |
| 72 | + """ |
| 73 | + B0 inhomogeneities occur at interfaces of materials with different magnetic susceptibilities, |
| 74 | + such as tissue-air interfaces. These differences lead to distortion in the local magnetic field, |
| 75 | + as Maxwell’s equations need to be satisfied. An example of B0 inhomogneity is the first volume |
| 76 | + of the 4D volume ```$FSLDIR/data/possum/b0_ppm.nii.gz```. |
| 77 | +
|
| 78 | + Examples :: |
| 79 | +
|
| 80 | + >>> from nipype.interfaces.fsl import B0Calc |
| 81 | + >>> b0calc = B0Calc() |
| 82 | + >>> b0calc.inputs.in_file = 'tissue+air_map.nii' |
| 83 | + >>> b0calc.inputs.z_b0 = 3.0 |
| 84 | + >>> b0calc.cmdline |
| 85 | + 'b0calc -i tissue+air_map.nii -o tissue+air_map_b0field.nii.gz --b0=3.00' |
| 86 | +
|
| 87 | + """ |
| 88 | + |
| 89 | + _cmd = 'b0calc' |
| 90 | + input_spec = B0CalcInputSpec |
| 91 | + output_spec = B0CalcOutputSpec |
| 92 | + |
| 93 | + |
0 commit comments