Skip to content

Commit 9c2a9b0

Browse files
committed
Merge pull request #1 from nipy/master
pulled updates from the main repo
2 parents ab7ce7d + a2f9c51 commit 9c2a9b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+12670
-113
lines changed

CHANGES

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
Next Release
22
============
33

4-
* ENH: New FSL interface: EpiReg
5-
* ENH: New Freesurfer interface: Tkregister2 (for conversion of fsl style matrices to freesurfer format)
6-
* ENH: New FSL interfaces: WarpPoints, WarpPointsToStd.
7-
* ENH: New Freesurfer interface: MRIPretess
8-
* ENH: New miscelaneous interface: AddCSVRow
4+
* ENH: New dipy interfaces: Denoise, Resample
5+
* ENH: New Freesurfer interfaces: Tkregister2 (for conversion of fsl style matrices to freesurfer format),
6+
MRIPretess
7+
* ENH: New FSL interfaces: WarpPoints, WarpPointsToStd, EpiReg, ProbTrackX2, WarpUtils, ConvertWarp
8+
* ENH: New miscelaneous interfaces: AddCSVRow, NormalizeProbabilityMapSet, AddNoise
9+
* ENH: New AFNI interfaces: Eval, Means, SVMTest, SVMTrain
910
* ENH: FUGUE interface has been refactored to use the name_template system, 3 examples
1011
added to doctests, some bugs solved.
11-
* ENH: Added new interfaces (fsl.utils.WarpUtils, ConvertWarp) to fnirtfileutils and convertwarp
1212
* API: Interfaces to external packages are no longer available in the top-level
1313
``nipype`` namespace, and must be imported directly (e.g.
1414
``from nipype.interfaces import fsl``).
15-
* ENH: New FSL interface: ProbTrackX2
16-
* ENH: New misc algorithm: NormalizeProbabilityMapSet
1715
* ENH: Support for elastix via a set of new interfaces: Registration, ApplyWarp,
1816
AnalyzeWarp, PointsWarp, and EditTransform
19-
* ENH: New ANTs interface: ApplyTransformsToPoints
17+
* ENH: New ANTs interface: ApplyTransformsToPoints, LaplacianThickness
18+
* ENH: New Diffusion Toolkit interface: TrackMerge
19+
* ENH: New MRtrix interface: FilterTracks
2020
* ENH: New metrics group in algorithms. Now Distance, Overlap, and FuzzyOverlap
2121
are found in nipype.algorithms.metrics instead of misc
2222
* ENH: New interface in algorithms.metrics: ErrorMap (a voxel-wise diff map).
2323
* ENH: New FreeSurfer workflow: create_skullstripped_recon_flow()
24+
* ENH: Deep revision of workflows for correction of dMRI artifacts. New dmri_preprocessing
25+
example.
2426
* ENH: New data grabbing interface that works over SSH connections, SSHDataGrabber
2527
* ENH: New color mode for write_graph
2628
* ENH: You can now force MapNodes to be run serially
27-
* ENH: New ANTs interface: LaplacianThickness
2829
* FIX: MRTrix tracking algorithms were ignoring mask parameters.
2930
* FIX: FNIRT registration pathway and associated OpenFMRI example script
3031
* FIX: spm12b compatibility for Model estimate

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ umbrella of NiPy, is a Python project that provides a uniform interface
3838
to existing neuroimaging software and facilitates interaction between
3939
these packages within a single workflow. Nipype provides an environment
4040
that encourages interactive exploration of algorithms from different
41-
packages (e.g., SPM, FSL, FreeSurfer, AFNI, Slicer), eases the
41+
packages (e.g., SPM, FSL, FreeSurfer, AFNI, Slicer, ANTS), eases the
4242
design of workflows within and between packages, and reduces the
4343
learning curve necessary to use different packages. Nipype is creating a
4444
collaborative platform for neuroimaging software development in a

doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
to existing neuroimaging software and facilitates interaction between
1515
these packages within a single workflow. Nipype provides an environment
1616
that encourages interactive exploration of algorithms from different
17-
packages (e.g., SPM_, FSL_, FreeSurfer_, Camino_, MRtrix_, MNE_, AFNI_,
17+
packages (e.g., ANTS_, SPM_, FSL_, FreeSurfer_, Camino_, MRtrix_, MNE_, AFNI_,
1818
Slicer_), eases the design of workflows within and between packages, and
1919
reduces the learning curve necessary to use different packages. Nipype is
2020
creating a collaborative platform for neuroimaging software development

doc/links_names.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
.. _matlab: http://www.mathworks.com
8787
.. _spm: http://www.fil.ion.ucl.ac.uk/spm
8888
.. _eeglab: http://sccn.ucsd.edu/eeglab
89+
.. _ANTS: http://stnava.github.io/ANTs/
8990
.. _AFNI: http://afni.nimh.nih.gov/afni
9091
.. _FSL: http://www.fmrib.ox.ac.uk/fsl
9192
.. _FreeSurfer: http://surfer.nmr.mgh.harvard.edu

examples/dmri_preprocessing.py

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
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+
5+
"""
6+
===================
7+
dMRI: Preprocessing
8+
===================
9+
10+
Introduction
11+
============
12+
13+
This script, dmri_preprocessing.py, demonstrates how to prepare dMRI data
14+
for tractography and connectivity analysis with nipype.
15+
16+
We perform this analysis using the FSL course data, which can be acquired from
17+
here: http://www.fmrib.ox.ac.uk/fslcourse/fsl_course_data2.tar.gz
18+
19+
Can be executed in command line using ``python dmri_preprocessing.py``
20+
21+
22+
Import necessary modules from nipype.
23+
"""
24+
25+
import os # system functions
26+
import nipype.interfaces.io as nio # Data i/o
27+
import nipype.interfaces.utility as niu # utility
28+
import nipype.algorithms.misc as misc
29+
30+
import nipype.pipeline.engine as pe # pypeline engine
31+
32+
from nipype.interfaces import fsl
33+
from nipype.interfaces import ants
34+
35+
36+
"""
37+
Load specific nipype's workflows for preprocessing of dMRI data:
38+
:class:`nipype.workflows.dmri.preprocess.epi.all_peb_pipeline`,
39+
as data include a *b0* volume with reverse encoding direction
40+
(*P>>>A*, or *y*), in contrast with the general acquisition encoding
41+
that is *A>>>P* or *-y* (in RAS systems).
42+
"""
43+
44+
from nipype.workflows.dmri.fsl.artifacts import all_fsl_pipeline, remove_bias
45+
46+
"""
47+
Map field names into individual subject runs
48+
"""
49+
50+
info = dict(dwi=[['subject_id', 'dwidata']],
51+
bvecs=[['subject_id', 'bvecs']],
52+
bvals=[['subject_id', 'bvals']],
53+
dwi_rev=[['subject_id', 'nodif_PA']])
54+
55+
infosource = pe.Node(interface=niu.IdentityInterface(fields=['subject_id']),
56+
name="infosource")
57+
58+
# Set the subject 1 identifier in subject_list,
59+
# we choose the preproc dataset as it contains uncorrected files.
60+
subject_list = ['subj1_preproc']
61+
62+
63+
"""Here we set up iteration over all the subjects. The following line
64+
is a particular example of the flexibility of the system. The
65+
``datasource`` attribute ``iterables`` tells the pipeline engine that
66+
it should repeat the analysis on each of the items in the
67+
``subject_list``. In the current example, the entire first level
68+
preprocessing and estimation will be repeated for each subject
69+
contained in subject_list.
70+
"""
71+
72+
infosource.iterables = ('subject_id', subject_list)
73+
74+
75+
"""
76+
Now we create a :class:`nipype.interfaces.io.DataGrabber` object and
77+
fill in the information from above about the layout of our data. The
78+
:class:`~nipype.pipeline.engine.Node` module wraps the interface object
79+
and provides additional housekeeping and pipeline specific
80+
functionality.
81+
"""
82+
83+
datasource = pe.Node(nio.DataGrabber(infields=['subject_id'],
84+
outfields=info.keys()), name='datasource')
85+
86+
datasource.inputs.template = "%s/%s"
87+
88+
# This needs to point to the fdt folder you can find after extracting
89+
# http://www.fmrib.ox.ac.uk/fslcourse/fsl_course_data2.tar.gz
90+
datasource.inputs.base_directory = os.path.abspath('fdt1')
91+
datasource.inputs.field_template = dict(dwi='%s/%s.nii.gz',
92+
dwi_rev='%s/%s.nii.gz')
93+
datasource.inputs.template_args = info
94+
datasource.inputs.sort_filelist = True
95+
96+
97+
"""
98+
An inputnode is used to pass the data obtained by the data grabber to the
99+
actual processing functions
100+
"""
101+
102+
inputnode = pe.Node(niu.IdentityInterface(fields=["dwi", "bvecs", "bvals",
103+
"dwi_rev"]), name="inputnode")
104+
105+
106+
"""
107+
108+
Setup for dMRI preprocessing
109+
============================
110+
111+
In this section we initialize the appropriate workflow for preprocessing of
112+
diffusion images.
113+
114+
Artifacts correction
115+
--------------------
116+
117+
We will use the combination of ``topup`` and ``eddy`` as suggested by FSL.
118+
119+
In order to configure the susceptibility distortion correction (SDC), we first
120+
write the specific parameters of our echo-planar imaging (EPI) images.
121+
122+
Particularly, we look into the ``acqparams.txt`` file of the selected subject
123+
to gather the encoding direction, acceleration factor (in parallel sequences
124+
it is > 1), and readout time or echospacing.
125+
126+
"""
127+
128+
epi_AP = {'echospacing': 66.5e-3, 'enc_dir': 'y-'}
129+
epi_PA = {'echospacing': 66.5e-3, 'enc_dir': 'y'}
130+
prep = all_fsl_pipeline(epi_params=epi_AP, altepi_params=epi_PA)
131+
132+
133+
"""
134+
135+
Bias field correction
136+
---------------------
137+
138+
Finally, we set up a node to correct for a single multiplicative bias field
139+
from computed on the *b0* image, as suggested in [Jeurissen2014]_.
140+
141+
"""
142+
143+
bias = remove_bias()
144+
145+
146+
"""
147+
Connect nodes in workflow
148+
=========================
149+
150+
We create a higher level workflow to connect the nodes. Please excuse the
151+
author for writing the arguments of the ``connect`` function in a not-standard
152+
style with readability aims.
153+
"""
154+
155+
wf = pe.Workflow(name="dMRI_Preprocessing")
156+
wf.base_dir = os.path.abspath('preprocessing_dmri_tutorial')
157+
wf.connect([
158+
(infosource, datasource, [('subject_id', 'subject_id')])
159+
,(datasource, prep, [('dwi', 'inputnode.in_file'),
160+
('dwi_rev', 'inputnode.alt_file'),
161+
('bvals', 'inputnode.in_bval'),
162+
('bvecs', 'inputnode.in_bvec')])
163+
,(prep, bias, [('outputnode.out_file', 'inputnode.in_file'),
164+
('outputnode.out_mask', 'inputnode.in_mask')])
165+
,(datasource, bias, [('bvals', 'inputnode.in_bval')])
166+
])
167+
168+
169+
"""
170+
Run the workflow as command line executable
171+
"""
172+
173+
if __name__ == '__main__':
174+
wf.run()
175+
wf.write_graph()

0 commit comments

Comments
 (0)