workflows
workflows.align
workflows.base
workflows.combined_workflow
workflows.denoise
workflows.docstring_parser
workflows.flow_runner
workflows.io
workflows.mask
workflows.multi_io
workflows.reconst
workflows.segment
workflows.stats
workflows.tracking
workflows.viz
workflows.workflow
AffineMap
AffineRegistration
AffineTransform3D
ApplyTransformFlow
CCMetric
DiffeomorphicMap
EMMetric
ImageRegistrationFlow
MutualInformationMetric
ResliceFlow
RigidTransform3D
SSDMetric
SlrWithQbxFlow
SymmetricDiffeomorphicRegistration
SynRegistrationFlow
TranslationTransform3D
Workflow
IntrospectiveArgumentParser
NumpyDocString
CombinedWorkflow
Workflow
NLMeansFlow
Workflow
NumpyDocString
Reader
IntrospectiveArgumentParser
IoInfoFlow
Workflow
MaskFlow
Workflow
IOIterator
ConstrainedSphericalDeconvModel
CsaOdfModel
DiffusionKurtosisModel
ReconstCSAFlow
ReconstCSDFlow
ReconstDkiFlow
ReconstDtiFlow
ReconstIvimFlow
ReconstMAPMRIFlow
TensorModel
Workflow
LabelsBundlesFlow
MedianOtsuFlow
RecoBundles
RecoBundlesFlow
Workflow
BundleAnalysisPopulationFlow
LinearMixedModelsFlow
SNRinCCFlow
TensorModel
Workflow
ClosestPeakDirectionGetter
CmcTissueClassifier
DeterministicMaximumDirectionGetter
LocalFiberTrackingPAMFlow
LocalTracking
PFTrackingPAMFlow
ParticleFilteringTracking
ProbabilisticDirectionGetter
ThresholdTissueClassifier
Tractogram
Workflow
HorizonFlow
Workflow
Workflow
workflows
workflows.align
AffineMap (affine[, domain_grid_shape, …]) |
Methods |
AffineRegistration ([metric, level_iters, …]) |
Methods |
AffineTransform3D |
Methods |
ApplyTransformFlow ([output_strategy, …]) |
Methods |
CCMetric (dim[, sigma_diff, radius]) |
Methods |
DiffeomorphicMap (dim, disp_shape[, …]) |
Methods |
EMMetric (dim[, smooth, inner_iter, …]) |
Methods |
ImageRegistrationFlow ([output_strategy, …]) |
The registration workflow is organized as a collection of different functions. |
MutualInformationMetric ([nbins, …]) |
Methods |
ResliceFlow ([output_strategy, mix_names, …]) |
Methods |
RigidTransform3D |
Methods |
SSDMetric (dim[, smooth, inner_iter, step_type]) |
Methods |
SlrWithQbxFlow ([output_strategy, mix_names, …]) |
Methods |
SymmetricDiffeomorphicRegistration (metric[, …]) |
Methods |
SynRegistrationFlow ([output_strategy, …]) |
Methods |
TranslationTransform3D |
Methods |
Workflow ([output_strategy, mix_names, …]) |
Methods |
check_dimensions (static, moving) |
Check the dimensions of the input images. |
load_nifti (fname[, return_img, …]) |
|
load_trk (filename[, lazy_load]) |
Loads tractogram files (*.tck) |
reslice (data, affine, zooms, new_zooms[, …]) |
Reslice data with new voxel resolution defined by new_zooms |
save_nifti (fname, data, affine[, hdr]) |
|
save_qa_metric (fname, xopt, fopt) |
Save Quality Assurance metrics. |
slr_with_qbx (static, moving[, x0, …]) |
Utility function for registering large tractograms. |
transform_centers_of_mass (static, …) |
Transformation to align the center of mass of the input images |
transform_streamlines (streamlines, mat[, …]) |
Apply affine transformation to streamlines |
workflows.base
IntrospectiveArgumentParser ([prog, usage, …]) |
|
||
NumpyDocString (docstring[, config]) |
|||
get_args_default (func) |
workflows.combined_workflow
CombinedWorkflow ([output_strategy, …]) |
Methods |
Workflow ([output_strategy, mix_names, …]) |
Methods |
iteritems (d, **kw) |
Return an iterator over the (key, value) pairs of a dictionary. |
workflows.denoise
NLMeansFlow ([output_strategy, mix_names, …]) |
Methods |
Workflow ([output_strategy, mix_names, …]) |
Methods |
estimate_sigma (arr[, …]) |
Standard deviation estimation from local patches |
load_nifti (fname[, return_img, …]) |
|
nlmeans (arr, sigma[, mask, patch_radius, …]) |
Non-local means for denoising 3D and 4D images |
save_nifti (fname, data, affine[, hdr]) |
workflows.docstring_parser
This was taken directly from the file docscrape.py of numpydoc package.
Copyright (C) 2008 Stefan van der Walt <stefan@mentat.za.net>, Pauli Virtanen <pav@iki.fi>
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS’’ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NumpyDocString (docstring[, config]) |
|
Reader (data) |
A line-based string reader. |
dedent_lines (lines) |
Deindent a list of lines maximally |
warn |
Issue a warning, or maybe ignore it or raise an exception. |
workflows.flow_runner
IntrospectiveArgumentParser ([prog, usage, …]) |
|
||
get_level (lvl) |
Transforms the loggin level passed on the commandline into a proper logging level name. | ||
iteritems (d, **kw) |
Return an iterator over the (key, value) pairs of a dictionary. | ||
run_flow (flow) |
Wraps the process of building an argparser that reflects the workflow that we want to run along with some generic parameters like logging, force and output strategies. |
workflows.io
IoInfoFlow ([output_strategy, mix_names, …]) |
Methods |
Workflow ([output_strategy, mix_names, …]) |
Methods |
load_nifti (fname[, return_img, …]) |
workflows.mask
MaskFlow ([output_strategy, mix_names, …]) |
Methods |
Workflow ([output_strategy, mix_names, …]) |
Methods |
load_nifti (fname[, return_img, …]) |
|
save_nifti (fname, data, affine[, hdr]) |
workflows.multi_io
IOIterator ([output_strategy, mix_names]) |
Create output filenames that work nicely with multiple input files from multiple directories (processing multiple subjects with one command) |
basename_without_extension (fname) |
|
common_start (sa, sb) |
Return the longest common substring from the beginning of sa and sb. |
concatenate_inputs (multi_inputs) |
Concatenate list of inputs |
connect_output_paths (inputs, out_dir, out_files) |
Generates a list of output files paths based on input files and output strategies. |
get_args_default (func) |
|
glob (pathname, *[, recursive]) |
Return a list of paths matching a pathname pattern. |
io_iterator (inputs, out_dir, fnames[, …]) |
Creates an IOIterator from the parameters. |
io_iterator_ (frame, fnc[, output_strategy, …]) |
Creates an IOIterator using introspection. |
slash_to_under (dir_str) |
workflows.reconst
ConstrainedSphericalDeconvModel (gtab, response) |
Methods |
CsaOdfModel (gtab, sh_order[, smooth, …]) |
Implementation of Constant Solid Angle reconstruction method. |
DiffusionKurtosisModel (gtab[, fit_method]) |
Class for the Diffusion Kurtosis Model |
ReconstCSAFlow ([output_strategy, mix_names, …]) |
Methods |
ReconstCSDFlow ([output_strategy, mix_names, …]) |
Methods |
ReconstDkiFlow ([output_strategy, mix_names, …]) |
Methods |
ReconstDtiFlow ([output_strategy, mix_names, …]) |
Methods |
ReconstIvimFlow ([output_strategy, …]) |
Methods |
ReconstMAPMRIFlow ([output_strategy, …]) |
Methods |
TensorModel (gtab[, fit_method, return_S0_hat]) |
Diffusion Tensor |
Workflow ([output_strategy, mix_names, …]) |
Methods |
IvimModel (gtab[, fit_method]) |
Selector function to switch between the 2-stage Levenberg-Marquardt based NLLS fitting method (also containing the linear fit): LM and the Variable Projections based fitting method: VarPro. |
auto_response (gtab, data[, roi_center, …]) |
Automatic estimation of response function using FA. |
axial_diffusivity (evals[, axis]) |
Axial Diffusivity (AD) of a diffusion tensor. |
color_fa (fa, evecs) |
Color fractional anisotropy of diffusion tensor |
fractional_anisotropy (evals[, axis]) |
Fractional anisotropy (FA) of a diffusion tensor. |
geodesic_anisotropy (evals[, axis]) |
Geodesic anisotropy (GA) of a diffusion tensor. |
get_mode (q_form) |
Mode (MO) of a diffusion tensor [1]. |
get_sphere ([name]) |
provide triangulated spheres |
gradient_table (bvals[, bvecs, big_delta, …]) |
A general function for creating diffusion MR gradients. |
literal_eval (node_or_string) |
Safely evaluate an expression node or a string containing a Python expression. |
load_nifti (fname[, return_img, …]) |
|
lower_triangular (tensor[, b0]) |
Returns the six lower triangular values of the tensor and a dummy variable if b0 is not None |
mean_diffusivity (evals[, axis]) |
Mean Diffusivity (MD) of a diffusion tensor. |
peaks_from_model (model, data, sphere, …[, …]) |
Fit the model to data and computes peaks and metrics |
peaks_to_niftis (pam, fname_shm, fname_dirs, …) |
Save SH, directions, indices and values of peaks to Nifti. |
radial_diffusivity (evals[, axis]) |
Radial Diffusivity (RD) of a diffusion tensor. |
read_bvals_bvecs (fbvals, fbvecs) |
Read b-values and b-vectors from disk |
save_nifti (fname, data, affine[, hdr]) |
|
save_peaks (fname, pam[, affine, verbose]) |
Save all important attributes of object PeaksAndMetrics in a PAM5 file (HDF5). |
split_dki_param (dki_params) |
Extract the diffusion tensor eigenvalues, the diffusion tensor eigenvector matrix, and the 15 independent elements of the kurtosis tensor from the model parameters estimated from the DKI model |
warn |
Issue a warning, or maybe ignore it or raise an exception. |
workflows.segment
LabelsBundlesFlow ([output_strategy, …]) |
Methods |
MedianOtsuFlow ([output_strategy, mix_names, …]) |
Methods |
RecoBundles (streamlines[, greater_than, …]) |
Methods |
RecoBundlesFlow ([output_strategy, …]) |
Methods |
Workflow ([output_strategy, mix_names, …]) |
Methods |
load_nifti (fname[, return_img, …]) |
|
load_trk (filename[, lazy_load]) |
Loads tractogram files (*.tck) |
median_otsu (input_volume[, median_radius, …]) |
Simple brain extraction tool method for images from DWI data. |
save_nifti (fname, data, affine[, hdr]) |
|
time () |
Return the current time in seconds since the Epoch. |
workflows.stats
BundleAnalysisPopulationFlow ([…]) |
Methods |
LinearMixedModelsFlow ([output_strategy, …]) |
Methods |
SNRinCCFlow ([output_strategy, mix_names, …]) |
Methods |
TensorModel (gtab[, fit_method, return_S0_hat]) |
Diffusion Tensor |
Workflow ([output_strategy, mix_names, …]) |
Methods |
binary_dilation (input[, structure, …]) |
Multi-dimensional binary dilation with the given structuring element. |
bounding_box (vol) |
Compute the bounding box of nonzero intensity voxels in the volume. |
bundle_analysis (model_bundle_folder, …[, …]) |
Applies statistical analysis on bundles and saves the results in a directory specified by out_dir . |
gradient_table (bvals[, bvecs, big_delta, …]) |
A general function for creating diffusion MR gradients. |
load_nifti (fname[, return_img, …]) |
|
median_otsu (input_volume[, median_radius, …]) |
Simple brain extraction tool method for images from DWI data. |
optional_package (name[, trip_msg]) |
Return package-like thing and module setup for package name |
read_bvals_bvecs (fbvals, fbvecs) |
Read b-values and b-vectors from disk |
save_nifti (fname, data, affine[, hdr]) |
|
segment_from_cfa (tensor_fit, roi, threshold) |
Segment the cfa inside roi using the values from threshold as bounds. |
simple_plot (file_name, title, x, y, xlabel, …) |
Saves the simple plot with given x and y values |
workflows.tracking
ClosestPeakDirectionGetter |
A direction getter that returns the closest odf peak to previous tracking direction. |
CmcTissueClassifier |
Continuous map criterion (CMC) stopping criteria from [1]. |
DeterministicMaximumDirectionGetter |
Return direction of a sphere with the highest probability mass function (pmf). |
LocalFiberTrackingPAMFlow ([output_strategy, …]) |
Methods |
LocalTracking (direction_getter, …[, …]) |
|
PFTrackingPAMFlow ([output_strategy, …]) |
Methods |
ParticleFilteringTracking (direction_getter, …) |
|
ProbabilisticDirectionGetter |
Randomly samples direction of a sphere based on probability mass function (pmf). |
ThresholdTissueClassifier |
# Declarations from tissue_classifier.pxd bellow cdef: double threshold, interp_out_double[1] double[:] interp_out_view = interp_out_view double[:, :, :] metric_map |
Tractogram ([streamlines, …]) |
Container for streamlines and their data information. |
Workflow ([output_strategy, mix_names, …]) |
Methods |
load_nifti (fname[, return_img, …]) |
|
load_peaks (fname[, verbose]) |
Load a PeaksAndMetrics HDF5 file (PAM5) |
save (tractogram, filename, **kwargs) |
Saves a tractogram to a file. |
workflows.viz
HorizonFlow ([output_strategy, mix_names, …]) |
Methods |
Workflow ([output_strategy, mix_names, …]) |
Methods |
horizon (tractograms, images, cluster, …[, …]) |
Highly interactive visualization - invert the Horizon! |
load_nifti (fname[, return_img, …]) |
|
load_tractogram (filename[, lazy_load]) |
Loads tractogram files (*.tck) |
pjoin (a, *p) |
Join two or more pathname components, inserting ‘/’ as needed. |
workflows.workflow
Workflow ([output_strategy, mix_names, …]) |
Methods |
io_iterator_ (frame, fnc[, output_strategy, …]) |
Creates an IOIterator using introspection. |
AffineMap
dipy.workflows.align.
AffineMap
(affine, domain_grid_shape=None, domain_grid2world=None, codomain_grid_shape=None, codomain_grid2world=None)Bases: object
Methods
get_affine () |
Returns the value of the transformation, not a reference! |
set_affine (affine) |
Sets the affine transform (operating in physical space) |
transform (image[, interp, image_grid2world, …]) |
Transforms the input image from co-domain to domain space |
transform_inverse (image[, interp, …]) |
Transforms the input image from domain to co-domain space |
__init__
(affine, domain_grid_shape=None, domain_grid2world=None, codomain_grid_shape=None, codomain_grid2world=None)AffineMap
Implements an affine transformation whose domain is given by domain_grid and domain_grid2world, and whose co-domain is given by codomain_grid and codomain_grid2world.
The actual transform is represented by the affine matrix, which operate in world coordinates. Therefore, to transform a moving image towards a static image, we first map each voxel (i,j,k) of the static image to world coordinates (x,y,z) by applying domain_grid2world. Then we apply the affine transform to (x,y,z) obtaining (x’, y’, z’) in moving image’s world coordinates. Finally, (x’, y’, z’) is mapped to voxel coordinates (i’, j’, k’) in the moving image by multiplying (x’, y’, z’) by the inverse of codomain_grid2world. The codomain_grid_shape is used analogously to transform the static image towards the moving image when calling transform_inverse.
If the domain/co-domain information is not provided (None) then the sampling information needs to be specified each time the transform or transform_inverse is called to transform images. Note that such sampling information is not necessary to transform points defined in physical space, such as stream lines.
Parameters: |
|
---|
get_affine
()Returns the value of the transformation, not a reference!
Returns: |
|
---|
set_affine
(affine)Sets the affine transform (operating in physical space)
Also sets self.affine_inv - the inverse of affine, or None if there is no inverse.
Parameters: |
|
---|
transform
(image, interp='linear', image_grid2world=None, sampling_grid_shape=None, sampling_grid2world=None, resample_only=False)Transforms the input image from co-domain to domain space
By default, the transformed image is sampled at a grid defined by self.domain_shape and self.domain_grid2world. If such information was not provided then sampling_grid_shape is mandatory.
Parameters: |
|
---|
transform_inverse
(image, interp='linear', image_grid2world=None, sampling_grid_shape=None, sampling_grid2world=None, resample_only=False)Transforms the input image from domain to co-domain space
By default, the transformed image is sampled at a grid defined by self.codomain_shape and self.codomain_grid2world. If such information was not provided then sampling_grid_shape is mandatory.
Parameters: |
|
---|
AffineRegistration
dipy.workflows.align.
AffineRegistration
(metric=None, level_iters=None, sigmas=None, factors=None, method='L-BFGS-B', ss_sigma_factor=None, options=None, verbosity=1)Bases: object
Methods
optimize (static, moving, transform, params0) |
Starts the optimization process |
__init__
(metric=None, level_iters=None, sigmas=None, factors=None, method='L-BFGS-B', ss_sigma_factor=None, options=None, verbosity=1)Initializes an instance of the AffineRegistration class
Parameters: |
|
---|
docstring_addendum
= 'verbosity: int (one of {0, 1, 2, 3}), optional\n Set the verbosity level of the algorithm:\n 0 : do not print anything\n 1 : print information about the current status of the algorithm\n 2 : print high level information of the components involved in\n the registration that can be used to detect a failing\n component.\n 3 : print as much information as possible to isolate the cause\n of a bug.\n Default: 1\n 'optimize
(static, moving, transform, params0, static_grid2world=None, moving_grid2world=None, starting_affine=None, ret_metric=False)Starts the optimization process
Parameters: |
|
---|---|
Returns: |
|
AffineTransform3D
dipy.workflows.align.
AffineTransform3D
Bases: dipy.align.transforms.Transform
Methods
get_identity_parameters |
Parameter values corresponding to the identity transform |
jacobian |
Jacobian function of this transform |
param_to_matrix |
Matrix representation of this transform with the given parameters |
get_dim | |
get_number_of_parameters |
ApplyTransformFlow
dipy.workflows.align.
ApplyTransformFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. | ||
get_short_name () |
Return A short name for the workflow used to subdivide. | ||
get_sub_runs () |
Return No sub runs since this is a simple workflow. | ||
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. | ||
run (static_image_files, moving_image_files, …) |
|
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
run
(static_image_files, moving_image_files, transform_map_file, transform_type='affine', out_dir='', out_file='transformed.nii.gz')Parameters: |
|
---|
CCMetric
dipy.workflows.align.
CCMetric
(dim, sigma_diff=2.0, radius=4)Bases: dipy.align.metrics.SimilarityMetric
Methods
compute_backward () |
Computes one step bringing the static image towards the moving. |
compute_forward () |
Computes one step bringing the moving image towards the static. |
free_iteration () |
Frees the resources allocated during initialization |
get_energy () |
Numerical value assigned by this metric to the current image pair |
initialize_iteration () |
Prepares the metric to compute one displacement field iteration. |
set_levels_above (levels) |
Informs the metric how many pyramid levels are above the current one |
set_levels_below (levels) |
Informs the metric how many pyramid levels are below the current one |
set_moving_image (moving_image, …) |
Sets the moving image being compared against the static one. |
set_static_image (static_image, …) |
Sets the static image being compared against the moving one. |
use_moving_image_dynamics (…) |
This is called by the optimizer just after setting the moving image |
use_static_image_dynamics (…) |
This is called by the optimizer just after setting the static image. |
__init__
(dim, sigma_diff=2.0, radius=4)Normalized Cross-Correlation Similarity metric.
Parameters: |
|
---|
compute_backward
()Computes one step bringing the static image towards the moving.
Computes the update displacement field to be used for registration of the static image towards the moving image
compute_forward
()Computes one step bringing the moving image towards the static.
Computes the update displacement field to be used for registration of the moving image towards the static image
get_energy
()Numerical value assigned by this metric to the current image pair
Returns the Cross Correlation (data term) energy computed at the largest iteration
initialize_iteration
()Prepares the metric to compute one displacement field iteration.
Pre-computes the cross-correlation factors for efficient computation of the gradient of the Cross Correlation w.r.t. the displacement field. It also pre-computes the image gradients in the physical space by re-orienting the gradients in the voxel space using the corresponding affine transformations.
DiffeomorphicMap
dipy.workflows.align.
DiffeomorphicMap
(dim, disp_shape, disp_grid2world=None, domain_shape=None, domain_grid2world=None, codomain_shape=None, codomain_grid2world=None, prealign=None)Bases: object
Methods
allocate () |
Creates a zero displacement field |
compute_inversion_error () |
Inversion error of the displacement fields |
expand_fields (expand_factors, new_shape) |
Expands the displacement fields from current shape to new_shape |
get_backward_field () |
Deformation field to transform an image in the backward direction |
get_forward_field () |
Deformation field to transform an image in the forward direction |
get_simplified_transform () |
Constructs a simplified version of this Diffeomorhic Map |
interpret_matrix (obj) |
Try to interpret obj as a matrix |
inverse () |
Inverse of this DiffeomorphicMap instance |
shallow_copy () |
Shallow copy of this DiffeomorphicMap instance |
transform (image[, interpolation, …]) |
Warps an image in the forward direction |
transform_inverse (image[, interpolation, …]) |
Warps an image in the backward direction |
warp_endomorphism (phi) |
Composition of this DiffeomorphicMap with a given endomorphism |
__init__
(dim, disp_shape, disp_grid2world=None, domain_shape=None, domain_grid2world=None, codomain_shape=None, codomain_grid2world=None, prealign=None)DiffeomorphicMap
Implements a diffeomorphic transformation on the physical space. The deformation fields encoding the direct and inverse transformations share the same domain discretization (both the discretization grid shape and voxel-to-space matrix). The input coordinates (physical coordinates) are first aligned using prealign, and then displaced using the corresponding vector field interpolated at the aligned coordinates.
Parameters: |
|
---|
allocate
()Creates a zero displacement field
Creates a zero displacement field (the identity transformation).
compute_inversion_error
()Inversion error of the displacement fields
Estimates the inversion error of the displacement fields by computing statistics of the residual vectors obtained after composing the forward and backward displacement fields.
Returns: |
|
---|
Notes
Since the forward and backward displacement fields have the same discretization, the final composition is given by
comp[i] = forward[ i + Dinv * backward[i]]
where Dinv is the space-to-grid transformation of the displacement fields
expand_fields
(expand_factors, new_shape)Expands the displacement fields from current shape to new_shape
Up-samples the discretization of the displacement fields to be of new_shape shape.
Parameters: |
|
---|
get_backward_field
()Deformation field to transform an image in the backward direction
Returns the deformation field that must be used to warp an image under this transformation in the backward direction (note the ‘is_inverse’ flag).
get_forward_field
()Deformation field to transform an image in the forward direction
Returns the deformation field that must be used to warp an image under this transformation in the forward direction (note the ‘is_inverse’ flag).
get_simplified_transform
()Constructs a simplified version of this Diffeomorhic Map
The simplified version incorporates the pre-align transform, as well as the domain and codomain affine transforms into the displacement field. The resulting transformation may be regarded as operating on the image spaces given by the domain and codomain discretization. As a result, self.prealign, self.disp_grid2world, self.domain_grid2world and self.codomain affine will be None (denoting Identity) in the resulting diffeomorphic map.
interpret_matrix
(obj)Try to interpret obj as a matrix
Some operations are performed faster if we know in advance if a matrix is the identity (so we can skip the actual matrix-vector multiplication). This function returns None if the given object is None or the ‘identity’ string. It returns the same object if it is a numpy array. It raises an exception otherwise.
Parameters: |
|
---|---|
Returns: |
|
inverse
()Inverse of this DiffeomorphicMap instance
Returns a diffeomorphic map object representing the inverse of this transformation. The internal arrays are not copied but just referenced.
Returns: |
|
---|
shallow_copy
()Shallow copy of this DiffeomorphicMap instance
Creates a shallow copy of this diffeomorphic map (the arrays are not copied but just referenced)
Returns: |
|
---|
transform
(image, interpolation='linear', image_world2grid=None, out_shape=None, out_grid2world=None)Warps an image in the forward direction
Transforms the input image under this transformation in the forward direction. It uses the “is_inverse” flag to switch between “forward” and “backward” (if is_inverse is False, then transform(…) warps the image forwards, else it warps the image backwards).
Parameters: |
|
---|---|
Returns: |
|
Notes
See _warp_forward and _warp_backward documentation for further information.
transform_inverse
(image, interpolation='linear', image_world2grid=None, out_shape=None, out_grid2world=None)Warps an image in the backward direction
Transforms the input image under this transformation in the backward direction. It uses the “is_inverse” flag to switch between “forward” and “backward” (if is_inverse is False, then transform_inverse(…) warps the image backwards, else it warps the image forwards)
Parameters: |
|
---|---|
Returns: |
|
Notes
See _warp_forward and _warp_backward documentation for further information.
warp_endomorphism
(phi)Composition of this DiffeomorphicMap with a given endomorphism
Creates a new DiffeomorphicMap C with the same properties as self and composes its displacement fields with phi’s corresponding fields. The resulting diffeomorphism is of the form C(x) = phi(self(x)) with inverse C^{-1}(y) = self^{-1}(phi^{-1}(y)). We assume that phi is an endomorphism with the same discretization and domain affine as self to ensure that the composition inherits self’s properties (we also assume that the pre-aligning matrix of phi is None or identity).
Parameters: |
|
---|---|
Returns: |
|
Notes
The problem with our current representation of a DiffeomorphicMap is that the set of Diffeomorphism that can be represented this way (a pre-aligning matrix followed by a non-linear endomorphism given as a displacement field) is not closed under the composition operation.
Supporting a general DiffeomorphicMap class, closed under composition, may be extremely costly computationally, and the kind of transformations we actually need for Avants’ mid-point algorithm (SyN) are much simpler.
EMMetric
dipy.workflows.align.
EMMetric
(dim, smooth=1.0, inner_iter=5, q_levels=256, double_gradient=True, step_type='gauss_newton')Bases: dipy.align.metrics.SimilarityMetric
Methods
compute_backward () |
Computes one step bringing the static image towards the moving. |
compute_demons_step ([forward_step]) |
Demons step for EM metric |
compute_forward () |
Computes one step bringing the reference image towards the static. |
compute_gauss_newton_step ([forward_step]) |
Computes the Gauss-Newton energy minimization step |
free_iteration () |
Frees the resources allocated during initialization |
get_energy () |
The numerical value assigned by this metric to the current image pair |
initialize_iteration () |
Prepares the metric to compute one displacement field iteration. |
set_levels_above (levels) |
Informs the metric how many pyramid levels are above the current one |
set_levels_below (levels) |
Informs the metric how many pyramid levels are below the current one |
set_moving_image (moving_image, …) |
Sets the moving image being compared against the static one. |
set_static_image (static_image, …) |
Sets the static image being compared against the moving one. |
use_moving_image_dynamics (…) |
This is called by the optimizer just after setting the moving image. |
use_static_image_dynamics (…) |
This is called by the optimizer just after setting the static image. |
__init__
(dim, smooth=1.0, inner_iter=5, q_levels=256, double_gradient=True, step_type='gauss_newton')Expectation-Maximization Metric
Similarity metric based on the Expectation-Maximization algorithm to handle multi-modal images. The transfer function is modeled as a set of hidden random variables that are estimated at each iteration of the algorithm.
Parameters: |
|
---|
compute_backward
()Computes one step bringing the static image towards the moving.
Computes the update displacement field to be used for registration of the static image towards the moving image
compute_demons_step
(forward_step=True)Demons step for EM metric
Parameters: |
|
---|---|
Returns: |
|
compute_forward
()Computes one step bringing the reference image towards the static.
Computes the forward update field to register the moving image towards the static image in a gradient-based optimization algorithm
compute_gauss_newton_step
(forward_step=True)Computes the Gauss-Newton energy minimization step
Computes the Newton step to minimize this energy, i.e., minimizes the linearized energy function with respect to the regularized displacement field (this step does not require post-smoothing, as opposed to the demons step, which does not include regularization). To accelerate convergence we use the multi-grid Gauss-Seidel algorithm proposed by Bruhn and Weickert et al [Bruhn05]
Parameters: |
|
---|---|
Returns: |
|
References
get_energy
()The numerical value assigned by this metric to the current image pair
Returns the EM (data term) energy computed at the largest iteration
initialize_iteration
()Prepares the metric to compute one displacement field iteration.
Pre-computes the transfer functions (hidden random variables) and variances of the estimators. Also pre-computes the gradient of both input images. Note that once the images are transformed to the opposite modality, the gradient of the transformed images can be used with the gradient of the corresponding modality in the same fashion as diff-demons does for mono-modality images. If the flag self.use_double_gradient is True these gradients are averaged.
use_moving_image_dynamics
(original_moving_image, transformation)This is called by the optimizer just after setting the moving image.
EMMetric takes advantage of the image dynamics by computing the current moving image mask from the original_moving_image mask (warped by nearest neighbor interpolation)
Parameters: |
|
---|
use_static_image_dynamics
(original_static_image, transformation)This is called by the optimizer just after setting the static image.
EMMetric takes advantage of the image dynamics by computing the current static image mask from the originalstaticImage mask (warped by nearest neighbor interpolation)
Parameters: |
|
---|
ImageRegistrationFlow
dipy.workflows.align.
ImageRegistrationFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
The registration workflow is organized as a collection of different functions. The user can intend to use only one type of registration (such as center of mass or rigid body registration only).
Alternatively, a registration can be done in a progressive manner. For example, using affine registration with progressive set to ‘True’ will involve center of mass, translation, rigid body and full affine registration. Whereas, when progressive is False the registration will include only center of mass and affine registration. The progressive registration will be slower but will improve the quality.
This can be controlled by using the progressive flag (True by default).
Methods
affine (static, static_grid2world, moving, …) |
Function for full affine registration. | ||
center_of_mass (static, static_grid2world, …) |
Function for the center of mass based image registration. | ||
get_io_iterator () |
Create an iterator for IO. | ||
get_short_name () |
Return A short name for the workflow used to subdivide. | ||
get_sub_runs () |
Return No sub runs since this is a simple workflow. | ||
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. | ||
perform_transformation (static, …) |
Function to apply the transformation. | ||
rigid (static, static_grid2world, moving, …) |
Function for rigid body based image registration. | ||
run (static_img_files, moving_img_files[, …]) |
|
||
translate (static, static_grid2world, moving, …) |
Function for translation based registration. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
affine
(static, static_grid2world, moving, moving_grid2world, affreg, params0, progressive)Function for full affine registration.
Parameters: |
|
---|
center_of_mass
(static, static_grid2world, moving, moving_grid2world)Function for the center of mass based image registration.
Parameters: |
|
---|
perform_transformation
(static, static_grid2world, moving, moving_grid2world, affreg, params0, transform, affine)Function to apply the transformation.
Parameters: |
|
---|
rigid
(static, static_grid2world, moving, moving_grid2world, affreg, params0, progressive)Function for rigid body based image registration.
Parameters: |
|
---|
run
(static_img_files, moving_img_files, transform='affine', nbins=32, sampling_prop=None, metric='mi', level_iters=[10000, 1000, 100], sigmas=[3.0, 1.0, 0.0], factors=[4, 2, 1], progressive=True, save_metric=False, out_dir='', out_moved='moved.nii.gz', out_affine='affine.txt', out_quality='quality_metric.txt')Parameters: |
|
---|
translate
(static, static_grid2world, moving, moving_grid2world, affreg, params0)Function for translation based registration.
Parameters: |
|
---|
MutualInformationMetric
dipy.workflows.align.
MutualInformationMetric
(nbins=32, sampling_proportion=None)Bases: object
Methods
distance (params) |
Numeric value of the negative Mutual Information |
distance_and_gradient (params) |
Numeric value of the metric and its gradient at given parameters |
gradient (params) |
Numeric value of the metric’s gradient at the given parameters |
setup (transform, static, moving[, …]) |
Prepares the metric to compute intensity densities and gradients |
__init__
(nbins=32, sampling_proportion=None)Initializes an instance of the Mutual Information metric
This class implements the methods required by Optimizer to drive the registration process.
Parameters: |
|
---|
Notes
Since we use linear interpolation, images are not, in general, differentiable at exact voxel coordinates, but they are differentiable between voxel coordinates. When using sparse sampling, selected voxels are slightly moved by adding a small random displacement within one voxel to prevent sampling points from being located exactly at voxel coordinates. When using dense sampling, this random displacement is not applied.
distance
(params)Numeric value of the negative Mutual Information
We need to change the sign so we can use standard minimization algorithms.
Parameters: |
|
---|---|
Returns: |
|
distance_and_gradient
(params)Numeric value of the metric and its gradient at given parameters
Parameters: |
|
---|---|
Returns: |
|
gradient
(params)Numeric value of the metric’s gradient at the given parameters
Parameters: |
|
---|---|
Returns: |
|
setup
(transform, static, moving, static_grid2world=None, moving_grid2world=None, starting_affine=None)Prepares the metric to compute intensity densities and gradients
The histograms will be setup to compute probability densities of intensities within the minimum and maximum values of static and moving
Parameters: |
|
---|
ResliceFlow
dipy.workflows.align.
ResliceFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (input_files, new_vox_size[, order, …]) |
Reslice data with new voxel resolution defined by new_vox_sz |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(input_files, new_vox_size, order=1, mode='constant', cval=0, num_processes=1, out_dir='', out_resliced='resliced.nii.gz')Reslice data with new voxel resolution defined by new_vox_sz
Parameters: |
|
---|
RigidTransform3D
dipy.workflows.align.
RigidTransform3D
Bases: dipy.align.transforms.Transform
Methods
get_identity_parameters |
Parameter values corresponding to the identity transform |
jacobian |
Jacobian function of this transform |
param_to_matrix |
Matrix representation of this transform with the given parameters |
get_dim | |
get_number_of_parameters |
__init__
()Rigid transform in 3D (rotation + translation) The parameter vector theta of length 6 is interpreted as follows: theta[0] : rotation about the x axis theta[1] : rotation about the y axis theta[2] : rotation about the z axis theta[3] : translation along the x axis theta[4] : translation along the y axis theta[5] : translation along the z axis
SSDMetric
dipy.workflows.align.
SSDMetric
(dim, smooth=4, inner_iter=10, step_type='demons')Bases: dipy.align.metrics.SimilarityMetric
Methods
compute_backward () |
Computes one step bringing the static image towards the moving. |
compute_demons_step ([forward_step]) |
Demons step for SSD metric |
compute_forward () |
Computes one step bringing the reference image towards the static. |
compute_gauss_newton_step ([forward_step]) |
Computes the Gauss-Newton energy minimization step |
free_iteration () |
Nothing to free for the SSD metric |
get_energy () |
The numerical value assigned by this metric to the current image pair |
initialize_iteration () |
Prepares the metric to compute one displacement field iteration. |
set_levels_above (levels) |
Informs the metric how many pyramid levels are above the current one |
set_levels_below (levels) |
Informs the metric how many pyramid levels are below the current one |
set_moving_image (moving_image, …) |
Sets the moving image being compared against the static one. |
set_static_image (static_image, …) |
Sets the static image being compared against the moving one. |
use_moving_image_dynamics (…) |
This is called by the optimizer just after setting the moving image |
use_static_image_dynamics (…) |
This is called by the optimizer just after setting the static image. |
__init__
(dim, smooth=4, inner_iter=10, step_type='demons')Sum of Squared Differences (SSD) Metric
Similarity metric for (mono-modal) nonlinear image registration defined by the sum of squared differences (SSD)
Parameters: |
|
---|
compute_backward
()Computes one step bringing the static image towards the moving.
Computes the update displacement field to be used for registration of the static image towards the moving image
compute_demons_step
(forward_step=True)Demons step for SSD metric
Computes the demons step proposed by Vercauteren et al.[Vercauteren09] for the SSD metric.
Parameters: |
|
---|---|
Returns: |
|
References
compute_forward
()Computes one step bringing the reference image towards the static.
Computes the update displacement field to be used for registration of the moving image towards the static image
compute_gauss_newton_step
(forward_step=True)Computes the Gauss-Newton energy minimization step
Minimizes the linearized energy function (Newton step) defined by the sum of squared differences of corresponding pixels of the input images with respect to the displacement field.
Parameters: |
|
---|---|
Returns: |
|
SlrWithQbxFlow
dipy.workflows.align.
SlrWithQbxFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (static_files, moving_files[, x0, …]) |
Streamline-based linear registration. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(static_files, moving_files, x0='affine', rm_small_clusters=50, qbx_thr=[40, 30, 20, 15], num_threads=None, greater_than=50, less_than=250, nb_pts=20, progressive=True, out_dir='', out_moved='moved.trk', out_affine='affine.txt', out_stat_centroids='static_centroids.trk', out_moving_centroids='moving_centroids.trk', out_moved_centroids='moved_centroids.trk')Streamline-based linear registration.
For efficiency we apply the registration on cluster centroids and remove small clusters.
Parameters: |
|
---|
Notes
The order of operations is the following. First short or long streamlines are removed. Second the tractogram or a random selection of the tractogram is clustered with QuickBundlesX. Then SLR [Garyfallidis15] is applied.
References
[Garyfallidis15] | (1, 2) Garyfallidis et al. “Robust and efficient linear |
registration of white-matter fascicles in the space of streamlines”, NeuroImage, 117, 124–140, 2015
[Garyfallidis14] | Garyfallidis et al., “Direct native-space fiber |
bundle alignment for group comparisons”, ISMRM, 2014.
[Garyfallidis17] | Garyfallidis et al. Recognition of white matter |
bundles using local and global streamline-based registration and clustering, Neuroimage, 2017.
SymmetricDiffeomorphicRegistration
dipy.workflows.align.
SymmetricDiffeomorphicRegistration
(metric, level_iters=None, step_length=0.25, ss_sigma_factor=0.2, opt_tol=1e-05, inv_iter=20, inv_tol=0.001, callback=None)Bases: dipy.align.imwarp.DiffeomorphicRegistration
Methods
get_map () |
Returns the resulting diffeomorphic map Returns the DiffeomorphicMap registering the moving image towards the static image. |
optimize (static, moving[, …]) |
Starts the optimization |
set_level_iters (level_iters) |
Sets the number of iterations at each pyramid level |
update (current_displacement, …) |
Composition of the current displacement field with the given field |
__init__
(metric, level_iters=None, step_length=0.25, ss_sigma_factor=0.2, opt_tol=1e-05, inv_iter=20, inv_tol=0.001, callback=None)Symmetric Diffeomorphic Registration (SyN) Algorithm
Performs the multi-resolution optimization algorithm for non-linear registration using a given similarity metric.
Parameters: |
|
---|
get_map
()Returns the resulting diffeomorphic map Returns the DiffeomorphicMap registering the moving image towards the static image.
optimize
(static, moving, static_grid2world=None, moving_grid2world=None, prealign=None)Starts the optimization
Parameters: |
|
---|---|
Returns: |
|
update
(current_displacement, new_displacement, disp_world2grid, time_scaling)Composition of the current displacement field with the given field
Interpolates new displacement at the locations defined by current_displacement. Equivalently, computes the composition C of the given displacement fields as C(x) = B(A(x)), where A is current_displacement and B is new_displacement. This function is intended to be used with deformation fields of the same sampling (e.g. to be called by a registration algorithm).
Parameters: |
|
---|---|
Returns: |
|
SynRegistrationFlow
dipy.workflows.align.
SynRegistrationFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. | ||
get_short_name () |
Return A short name for the workflow used to subdivide. | ||
get_sub_runs () |
Return No sub runs since this is a simple workflow. | ||
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. | ||
run (static_image_files, moving_image_files) |
|
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
run
(static_image_files, moving_image_files, prealign_file='', inv_static=False, level_iters=[10, 10, 5], metric='cc', mopt_sigma_diff=2.0, mopt_radius=4, mopt_smooth=0.0, mopt_inner_iter=0.0, mopt_q_levels=256, mopt_double_gradient=True, mopt_step_type='', step_length=0.25, ss_sigma_factor=0.2, opt_tol=1e-05, inv_iter=20, inv_tol=0.001, out_dir='', out_warped='warped_moved.nii.gz', out_inv_static='inc_static.nii.gz', out_field='displacement_field.nii.gz')Parameters: |
|
---|
TranslationTransform3D
dipy.workflows.align.
TranslationTransform3D
Bases: dipy.align.transforms.Transform
Methods
get_identity_parameters |
Parameter values corresponding to the identity transform |
jacobian |
Jacobian function of this transform |
param_to_matrix |
Matrix representation of this transform with the given parameters |
get_dim | |
get_number_of_parameters |
Workflow
dipy.workflows.align.
Workflow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: object
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (*args, **kwargs) |
Execute the workflow. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_io_iterator
()Create an iterator for IO.
Use a couple of inspection tricks to build an IOIterator using the previous frame (values of local variables and other contextuals) and the run method’s docstring.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
dipy.workflows.align.
check_dimensions
(static, moving)Check the dimensions of the input images.
Parameters: |
|
---|
dipy.workflows.align.
load_trk
(filename, lazy_load=False)Loads tractogram files (*.tck)
Parameters: |
|
---|---|
Returns: |
|
dipy.workflows.align.
reslice
(data, affine, zooms, new_zooms, order=1, mode='constant', cval=0, num_processes=1)Reslice data with new voxel resolution defined by new_zooms
Parameters: |
|
---|---|
Returns: |
|
Examples
>>> import nibabel as nib
>>> from dipy.align.reslice import reslice
>>> from dipy.data import get_fnames
>>> fimg = get_fnames('aniso_vox')
>>> img = nib.load(fimg)
>>> data = img.get_data()
>>> data.shape == (58, 58, 24)
True
>>> affine = img.affine
>>> zooms = img.header.get_zooms()[:3]
>>> zooms
(4.0, 4.0, 5.0)
>>> new_zooms = (3.,3.,3.)
>>> new_zooms
(3.0, 3.0, 3.0)
>>> data2, affine2 = reslice(data, affine, zooms, new_zooms)
>>> data2.shape == (77, 77, 40)
True
dipy.workflows.align.
slr_with_qbx
(static, moving, x0='affine', rm_small_clusters=50, maxiter=100, select_random=None, verbose=False, greater_than=50, less_than=250, qbx_thr=[40, 30, 20, 15], nb_pts=20, progressive=True, rng=None, num_threads=None)Utility function for registering large tractograms.
For efficiency we apply the registration on cluster centroids and remove small clusters.
Parameters: |
|
---|
Notes
The order of operations is the following. First short or long streamlines are removed. Second the tractogram or a random selection of the tractogram is clustered with QuickBundles. Then SLR [Garyfallidis15] is applied.
References
[Garyfallidis15] | (1, 2) Garyfallidis et al. “Robust and efficient linear |
registration of white-matter fascicles in the space of streamlines”, NeuroImage, 117, 124–140, 2015 .. [R890e584ccf15-Garyfallidis14] Garyfallidis et al., “Direct native-space fiber
bundle alignment for group comparisons”, ISMRM, 2014.
[Garyfallidis17] | Garyfallidis et al. Recognition of white matter |
bundles using local and global streamline-based registration and clustering, Neuroimage, 2017.
dipy.workflows.align.
transform_centers_of_mass
(static, static_grid2world, moving, moving_grid2world)Transformation to align the center of mass of the input images
Parameters: |
|
---|---|
Returns: |
|
dipy.workflows.align.
transform_streamlines
(streamlines, mat, in_place=False)Apply affine transformation to streamlines
Parameters: |
|
---|---|
Returns: |
|
IntrospectiveArgumentParser
dipy.workflows.base.
IntrospectiveArgumentParser
(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.RawTextHelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='resolve', add_help=True)Bases: argparse.ArgumentParser
Attributes: |
|
---|
Methods
add_argument (dest, …[, name, name]) |
|
add_sub_flow_args (sub_flows) |
Take an array of workflow objects and use introspection to extract the parameters, types and docstrings of their run method. |
add_subparsers (**kwargs) |
|
add_workflow (workflow) |
Take a workflow object and use introspection to extract the parameters, types and docstrings of its run method. |
error (message) |
Prints a usage message incorporating the message to stderr and exits. |
exit ([status, message]) |
|
format_usage () |
|
get_flow_args ([args, namespace]) |
Returns the parsed arguments as a dictionary that will be used as a workflow’s run method arguments. |
parse_args ([args, namespace]) |
|
print_usage ([file]) |
|
register (registry_name, value, object) |
|
set_defaults (**kwargs) |
add_argument_group | |
add_description | |
add_epilogue | |
add_mutually_exclusive_group | |
convert_arg_line_to_args | |
format_help | |
get_default | |
parse_known_args | |
print_help | |
show_argument | |
update_argument |
__init__
(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.RawTextHelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='resolve', add_help=True)Augmenting the argument parser to allow automatic creation of arguments from workflows
Parameters: |
|
---|
add_sub_flow_args
(sub_flows)Take an array of workflow objects and use introspection to extract the parameters, types and docstrings of their run method. Only the optional input parameters are extracted for these as they are treated as sub workflows.
Parameters: |
|
---|---|
Returns: |
|
add_workflow
(workflow)Take a workflow object and use introspection to extract the parameters, types and docstrings of its run method. Then add these parameters to the current arparser’s own params to parse. If the workflow is of type combined_workflow, the optional input parameters of its sub workflows will also be added.
Parameters: |
|
---|---|
Returns: |
|
NumpyDocString
dipy.workflows.base.
NumpyDocString
(docstring, config={})Bases: object
CombinedWorkflow
dipy.workflows.combined_workflow.
CombinedWorkflow
(output_strategy='append', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_optionals (flow, **kwargs) |
Returns the sub flow’s optional arguments merged with those passed as params in kwargs. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Returns a list of tuples (sub flow name, sub flow run method, sub flow short name) to be used in the sub flow parameters extraction. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (*args, **kwargs) |
Execute the workflow. |
run_sub_flow (flow, *args, **kwargs) |
Runs the sub flow with the optional parameters passed via the command line. |
set_sub_flows_optionals (opts) |
Sets the self._optionals variable with all sub flow arguments that were passed in the commandline. |
__init__
(output_strategy='append', mix_names=False, force=False, skip=False)Workflow that combines multiple workflows. The workflow combined together are referred as sub flows in this class.
get_optionals
(flow, **kwargs)Returns the sub flow’s optional arguments merged with those passed as params in kwargs.
get_sub_runs
()Returns a list of tuples (sub flow name, sub flow run method, sub flow short name) to be used in the sub flow parameters extraction.
Workflow
dipy.workflows.combined_workflow.
Workflow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: object
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (*args, **kwargs) |
Execute the workflow. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_io_iterator
()Create an iterator for IO.
Use a couple of inspection tricks to build an IOIterator using the previous frame (values of local variables and other contextuals) and the run method’s docstring.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
NLMeansFlow
dipy.workflows.denoise.
NLMeansFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (input_files[, sigma, out_dir, out_denoised]) |
Workflow wrapping the nlmeans denoising method. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(input_files, sigma=0, out_dir='', out_denoised='dwi_nlmeans.nii.gz')Workflow wrapping the nlmeans denoising method.
It applies nlmeans denoise on each file found by ‘globing’
input_files
and saves the results in a directory specified by
out_dir
.
Parameters: |
|
---|
Workflow
dipy.workflows.denoise.
Workflow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: object
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (*args, **kwargs) |
Execute the workflow. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_io_iterator
()Create an iterator for IO.
Use a couple of inspection tricks to build an IOIterator using the previous frame (values of local variables and other contextuals) and the run method’s docstring.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
dipy.workflows.denoise.
estimate_sigma
(arr, disable_background_masking=False, N=0)Standard deviation estimation from local patches
Parameters: |
|
---|---|
Returns: |
|
dipy.workflows.denoise.
nlmeans
(arr, sigma, mask=None, patch_radius=1, block_radius=5, rician=True, num_threads=None)Non-local means for denoising 3D and 4D images
Parameters: |
|
---|---|
Returns: |
|
References
[Descoteaux08] | Descoteaux, Maxim and Wiest-Daessle`, Nicolas and Prima, Sylvain and Barillot, Christian and Deriche, Rachid Impact of Rician Adapted Non-Local Means Filtering on HARDI, MICCAI 2008 |
NumpyDocString
dipy.workflows.docstring_parser.
NumpyDocString
(docstring, config={})Bases: object
Reader
dipy.workflows.docstring_parser.
Reader
(data)Bases: object
A line-based string reader.
Methods
eof | |
is_empty | |
peek | |
read | |
read_to_condition | |
read_to_next_empty_line | |
read_to_next_unindented_line | |
reset | |
seek_next_non_empty_line |
IntrospectiveArgumentParser
dipy.workflows.flow_runner.
IntrospectiveArgumentParser
(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.RawTextHelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='resolve', add_help=True)Bases: argparse.ArgumentParser
Attributes: |
|
---|
Methods
add_argument (dest, …[, name, name]) |
|
add_sub_flow_args (sub_flows) |
Take an array of workflow objects and use introspection to extract the parameters, types and docstrings of their run method. |
add_subparsers (**kwargs) |
|
add_workflow (workflow) |
Take a workflow object and use introspection to extract the parameters, types and docstrings of its run method. |
error (message) |
Prints a usage message incorporating the message to stderr and exits. |
exit ([status, message]) |
|
format_usage () |
|
get_flow_args ([args, namespace]) |
Returns the parsed arguments as a dictionary that will be used as a workflow’s run method arguments. |
parse_args ([args, namespace]) |
|
print_usage ([file]) |
|
register (registry_name, value, object) |
|
set_defaults (**kwargs) |
add_argument_group | |
add_description | |
add_epilogue | |
add_mutually_exclusive_group | |
convert_arg_line_to_args | |
format_help | |
get_default | |
parse_known_args | |
print_help | |
show_argument | |
update_argument |
__init__
(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.RawTextHelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='resolve', add_help=True)Augmenting the argument parser to allow automatic creation of arguments from workflows
Parameters: |
|
---|
add_sub_flow_args
(sub_flows)Take an array of workflow objects and use introspection to extract the parameters, types and docstrings of their run method. Only the optional input parameters are extracted for these as they are treated as sub workflows.
Parameters: |
|
---|---|
Returns: |
|
add_workflow
(workflow)Take a workflow object and use introspection to extract the parameters, types and docstrings of its run method. Then add these parameters to the current arparser’s own params to parse. If the workflow is of type combined_workflow, the optional input parameters of its sub workflows will also be added.
Parameters: |
|
---|---|
Returns: |
|
IoInfoFlow
dipy.workflows.io.
IoInfoFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (input_files[, b0_threshold, bvecs_tol, …]) |
Provides useful information about different files used in medical imaging. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(input_files, b0_threshold=50, bvecs_tol=0.01, bshell_thr=100)Provides useful information about different files used in medical imaging. Any number of input files can be provided. The program identifies the type of file by its extension.
Parameters: |
|
---|
Workflow
dipy.workflows.io.
Workflow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: object
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (*args, **kwargs) |
Execute the workflow. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_io_iterator
()Create an iterator for IO.
Use a couple of inspection tricks to build an IOIterator using the previous frame (values of local variables and other contextuals) and the run method’s docstring.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
MaskFlow
dipy.workflows.mask.
MaskFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (input_files, lb[, ub, out_dir, out_mask]) |
Workflow for creating a binary mask |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(input_files, lb, ub=inf, out_dir='', out_mask='mask.nii.gz')Workflow for creating a binary mask
Parameters: |
|
---|
Workflow
dipy.workflows.mask.
Workflow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: object
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (*args, **kwargs) |
Execute the workflow. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_io_iterator
()Create an iterator for IO.
Use a couple of inspection tricks to build an IOIterator using the previous frame (values of local variables and other contextuals) and the run method’s docstring.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
IOIterator
dipy.workflows.multi_io.
IOIterator
(output_strategy='absolute', mix_names=False)Bases: object
Create output filenames that work nicely with multiple input files from multiple directories (processing multiple subjects with one command)
Use information from input files, out_dir and out_fnames to generate correct outputs which can come from long lists of multiple or single inputs.
Methods
create_directories | |
create_outputs | |
file_existence_check | |
set_inputs | |
set_out_dir | |
set_out_fnames | |
set_output_keys |
dipy.workflows.multi_io.
connect_output_paths
(inputs, out_dir, out_files, output_strategy='absolute', mix_names=True)Generates a list of output files paths based on input files and output strategies.
Parameters: |
|
---|---|
Returns: |
|
dipy.workflows.multi_io.
glob
(pathname, *, recursive=False)Return a list of paths matching a pathname pattern.
The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by ‘*’ and ‘?’ patterns.
If recursive is true, the pattern ‘**’ will match any files and zero or more directories and subdirectories.
dipy.workflows.multi_io.
io_iterator
(inputs, out_dir, fnames, output_strategy='absolute', mix_names=False, out_keys=None)Creates an IOIterator from the parameters.
Parameters: |
|
---|
dipy.workflows.multi_io.
io_iterator_
(frame, fnc, output_strategy='absolute', mix_names=False)Creates an IOIterator using introspection.
Parameters: |
|
---|
ConstrainedSphericalDeconvModel
dipy.workflows.reconst.
ConstrainedSphericalDeconvModel
(gtab, response, reg_sphere=None, sh_order=8, lambda_=1, tau=0.1)Bases: dipy.reconst.shm.SphHarmModel
Methods
cache_clear () |
Clear the cache. |
cache_get (tag, key[, default]) |
Retrieve a value from the cache. |
cache_set (tag, key, value) |
Store a value in the cache. |
fit (data[, mask]) |
Fit method for every voxel in data |
predict (sh_coeff[, gtab, S0]) |
Compute a signal prediction given spherical harmonic coefficients for the provided GradientTable class instance. |
sampling_matrix (sphere) |
The matrix needed to sample ODFs from coefficients of the model. |
__init__
(gtab, response, reg_sphere=None, sh_order=8, lambda_=1, tau=0.1)Constrained Spherical Deconvolution (CSD) [1].
Spherical deconvolution computes a fiber orientation distribution (FOD), also called fiber ODF (fODF) [2], as opposed to a diffusion ODF as the QballModel or the CsaOdfModel. This results in a sharper angular profile with better angular resolution that is the best object to be used for later deterministic and probabilistic tractography [3].
A sharp fODF is obtained because a single fiber response function is injected as a priori knowledge. The response function is often data-driven and is thus provided as input to the ConstrainedSphericalDeconvModel. It will be used as deconvolution kernel, as described in [1].
Parameters: |
|
---|
References
[1] | (1, 2, 3, 4, 5, 6) Tournier, J.D., et al. NeuroImage 2007. Robust determination of the fibre orientation distribution in diffusion MRI: Non-negativity constrained super-resolved spherical deconvolution |
[2] | (1, 2) Descoteaux, M., et al. IEEE TMI 2009. Deterministic and Probabilistic Tractography Based on Complex Fibre Orientation Distributions |
[3] | (1, 2) C^ot’e, M-A., et al. Medical Image Analysis 2013. Tractometer: Towards validation of tractography pipelines |
[4] | Tournier, J.D, et al. Imaging Systems and Technology 2012. MRtrix: Diffusion Tractography in Crossing Fiber Regions |
predict
(sh_coeff, gtab=None, S0=1.0)Compute a signal prediction given spherical harmonic coefficients for the provided GradientTable class instance.
Parameters: |
|
---|---|
Returns: |
|
CsaOdfModel
dipy.workflows.reconst.
CsaOdfModel
(gtab, sh_order, smooth=0.006, min_signal=1.0, assume_normed=False)Bases: dipy.reconst.shm.QballBaseModel
Implementation of Constant Solid Angle reconstruction method.
References
[1] | Aganj, I., et al. 2009. ODF Reconstruction in Q-Ball Imaging With Solid Angle Consideration. |
Methods
cache_clear () |
Clear the cache. |
cache_get (tag, key[, default]) |
Retrieve a value from the cache. |
cache_set (tag, key, value) |
Store a value in the cache. |
fit (data[, mask]) |
Fits the model to diffusion data and returns the model fit |
sampling_matrix (sphere) |
The matrix needed to sample ODFs from coefficients of the model. |
DiffusionKurtosisModel
dipy.workflows.reconst.
DiffusionKurtosisModel
(gtab, fit_method='WLS', *args, **kwargs)Bases: dipy.reconst.base.ReconstModel
Class for the Diffusion Kurtosis Model
Methods
fit (data[, mask]) |
Fit method of the DKI model class |
predict (dki_params[, S0]) |
Predict a signal for this DKI model class instance given parameters. |
__init__
(gtab, fit_method='WLS', *args, **kwargs)Diffusion Kurtosis Tensor Model [1]
Parameters: |
|
---|
References
[1] | Tabesh, A., Jensen, J.H., Ardekani, B.A., Helpern, J.A., 2011. |
Estimation of tensors and tensor-derived measures in diffusional kurtosis imaging. Magn Reson Med. 65(3), 823-836
fit
(data, mask=None)Fit method of the DKI model class
Parameters: |
|
---|
predict
(dki_params, S0=1.0)Predict a signal for this DKI model class instance given parameters.
Parameters: |
|
---|
ReconstCSAFlow
dipy.workflows.reconst.
ReconstCSAFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (input_files, bvalues_files, …[, …]) |
Constant Solid Angle. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(input_files, bvalues_files, bvectors_files, mask_files, sh_order=6, odf_to_sh_order=8, b0_threshold=50.0, bvecs_tol=0.01, extract_pam_values=False, out_dir='', out_pam='peaks.pam5', out_shm='shm.nii.gz', out_peaks_dir='peaks_dirs.nii.gz', out_peaks_values='peaks_values.nii.gz', out_peaks_indices='peaks_indices.nii.gz', out_gfa='gfa.nii.gz')Constant Solid Angle.
Parameters: |
|
---|
References
[1] | Aganj, I., et al. 2009. ODF Reconstruction in Q-Ball Imaging with Solid Angle Consideration. |
ReconstCSDFlow
dipy.workflows.reconst.
ReconstCSDFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (input_files, bvalues_files, …[, …]) |
Constrained spherical deconvolution |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(input_files, bvalues_files, bvectors_files, mask_files, b0_threshold=50.0, bvecs_tol=0.01, roi_center=None, roi_radius=10, fa_thr=0.7, frf=None, extract_pam_values=False, sh_order=8, odf_to_sh_order=8, out_dir='', out_pam='peaks.pam5', out_shm='shm.nii.gz', out_peaks_dir='peaks_dirs.nii.gz', out_peaks_values='peaks_values.nii.gz', out_peaks_indices='peaks_indices.nii.gz', out_gfa='gfa.nii.gz')Constrained spherical deconvolution
Parameters: |
|
---|
References
[1] | Tournier, J.D., et al. NeuroImage 2007. Robust determination of the fibre orientation distribution in diffusion MRI: Non-negativity constrained super-resolved spherical deconvolution. |
ReconstDkiFlow
dipy.workflows.reconst.
ReconstDkiFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (input_files, bvalues_files, …[, …]) |
Workflow for Diffusion Kurtosis reconstruction and for computing DKI metrics. |
get_dki_model | |
get_fitted_tensor |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(input_files, bvalues_files, bvectors_files, mask_files, b0_threshold=50.0, save_metrics=[], out_dir='', out_dt_tensor='dti_tensors.nii.gz', out_fa='fa.nii.gz', out_ga='ga.nii.gz', out_rgb='rgb.nii.gz', out_md='md.nii.gz', out_ad='ad.nii.gz', out_rd='rd.nii.gz', out_mode='mode.nii.gz', out_evec='evecs.nii.gz', out_eval='evals.nii.gz', out_dk_tensor='dki_tensors.nii.gz', out_mk='mk.nii.gz', out_ak='ak.nii.gz', out_rk='rk.nii.gz')Workflow for Diffusion Kurtosis reconstruction and for computing
DKI metrics. Performs a DKI reconstruction on the files by ‘globing’
input_files
and saves the DKI metrics in a directory specified by
out_dir
.
Parameters: |
|
---|
References
[1] | Tabesh, A., Jensen, J.H., Ardekani, B.A., Helpern, J.A., 2011. Estimation of tensors and tensor-derived measures in diffusional kurtosis imaging. Magn Reson Med. 65(3), 823-836 |
[2] | Jensen, Jens H., Joseph A. Helpern, Anita Ramani, Hanzhang Lu, and Kyle Kaczynski. 2005. Diffusional Kurtosis Imaging: The Quantification of Non-Gaussian Water Diffusion by Means of Magnetic Resonance Imaging. MRM 53 (6):1432-40. |
ReconstDtiFlow
dipy.workflows.reconst.
ReconstDtiFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (input_files, bvalues_files, …[, …]) |
Workflow for tensor reconstruction and for computing DTI metrics. |
get_fitted_tensor | |
get_tensor_model |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(input_files, bvalues_files, bvectors_files, mask_files, b0_threshold=50, bvecs_tol=0.01, save_metrics=[], out_dir='', out_tensor='tensors.nii.gz', out_fa='fa.nii.gz', out_ga='ga.nii.gz', out_rgb='rgb.nii.gz', out_md='md.nii.gz', out_ad='ad.nii.gz', out_rd='rd.nii.gz', out_mode='mode.nii.gz', out_evec='evecs.nii.gz', out_eval='evals.nii.gz')Workflow for tensor reconstruction and for computing DTI metrics.
using Weighted Least-Squares.
Performs a tensor reconstruction on the files by ‘globing’
input_files
and saves the DTI metrics in a directory specified by
out_dir
.
Parameters: |
|
---|
References
[1] | Basser, P.J., Mattiello, J., LeBihan, D., 1994. Estimation of the effective self-diffusion tensor from the NMR spin echo. J Magn Reson B 103, 247-254. |
[2] | Basser, P., Pierpaoli, C., 1996. Microstructural and physiological features of tissues elucidated by quantitative diffusion-tensor MRI. Journal of Magnetic Resonance 111, 209-219. |
[3] | Lin-Ching C., Jones D.K., Pierpaoli, C. 2005. RESTORE: Robust estimation of tensors by outlier rejection. MRM 53: 1088-1095 |
[4] | hung, SW., Lu, Y., Henry, R.G., 2006. Comparison of bootstrap approaches for estimation of uncertainties of DTI parameters. NeuroImage 33, 531-541. |
ReconstIvimFlow
dipy.workflows.reconst.
ReconstIvimFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (input_files, bvalues_files, …[, …]) |
Workflow for Intra-voxel Incoherent Motion reconstruction and for computing IVIM metrics. |
get_fitted_ivim |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(input_files, bvalues_files, bvectors_files, mask_files, split_b_D=400, split_b_S0=200, b0_threshold=0, save_metrics=[], out_dir='', out_S0_predicted='S0_predicted.nii.gz', out_perfusion_fraction='perfusion_fraction.nii.gz', out_D_star='D_star.nii.gz', out_D='D.nii.gz')Workflow for Intra-voxel Incoherent Motion reconstruction and for
computing IVIM metrics. Performs a IVIM reconstruction on the files
by ‘globing’ input_files
and saves the IVIM metrics in a directory
specified by out_dir
.
Parameters: |
|
---|
References
[Stejskal65] | Stejskal, E. O.; Tanner, J. E. (1 January 1965). “Spin Diffusion Measurements: Spin Echoes in the Presence of a Time-Dependent Field Gradient”. The Journal of Chemical Physics 42 (1): 288. Bibcode: 1965JChPh..42..288S. doi:10.1063/1.1695690. |
[LeBihan84] | Le Bihan, Denis, et al. “Separation of diffusion and perfusion in intravoxel incoherent motion MR imaging.” Radiology 168.2 (1988): 497-505. |
ReconstMAPMRIFlow
dipy.workflows.reconst.
ReconstMAPMRIFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (data_files, bvals_files, bvecs_files, …) |
Workflow for fitting the MAPMRI model (with optional Laplacian regularization). |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(data_files, bvals_files, bvecs_files, small_delta, big_delta, b0_threshold=50.0, laplacian=True, positivity=True, bval_threshold=2000, save_metrics=[], laplacian_weighting=0.05, radial_order=6, out_dir='', out_rtop='rtop.nii.gz', out_lapnorm='lapnorm.nii.gz', out_msd='msd.nii.gz', out_qiv='qiv.nii.gz', out_rtap='rtap.nii.gz', out_rtpp='rtpp.nii.gz', out_ng='ng.nii.gz', out_perng='perng.nii.gz', out_parng='parng.nii.gz')Workflow for fitting the MAPMRI model (with optional Laplacian regularization). Generates rtop, lapnorm, msd, qiv, rtap, rtpp, non-gaussian (ng), parallel ng, perpendicular ng saved in a nifti format in input files provided by data_files and saves the nifti files to an output directory specified by out_dir.
In order for the MAPMRI workflow to work in the way intended either the laplacian or positivity or both must be set to True.
Parameters: |
|
---|
TensorModel
dipy.workflows.reconst.
TensorModel
(gtab, fit_method='WLS', return_S0_hat=False, *args, **kwargs)Bases: dipy.reconst.base.ReconstModel
Diffusion Tensor
Methods
fit (data[, mask]) |
Fit method of the DTI model class |
predict (dti_params[, S0]) |
Predict a signal for this TensorModel class instance given parameters. |
__init__
(gtab, fit_method='WLS', return_S0_hat=False, *args, **kwargs)A Diffusion Tensor Model [1], [2].
Parameters: |
|
---|
Notes
In order to increase speed of processing, tensor fitting is done simultaneously over many voxels. Many fit_methods use the ‘step’ parameter to set the number of voxels that will be fit at once in each iteration. This is the chunk size as a number of voxels. A larger step value should speed things up, but it will also take up more memory. It is advisable to keep an eye on memory consumption as this value is increased.
Example : In iter_fit_tensor()
we have a default step value of
1e4
References
[1] | (1, 2) Basser, P.J., Mattiello, J., LeBihan, D., 1994. Estimation of the effective self-diffusion tensor from the NMR spin echo. J Magn Reson B 103, 247-254. |
[2] | (1, 2) Basser, P., Pierpaoli, C., 1996. Microstructural and physiological features of tissues elucidated by quantitative diffusion-tensor MRI. Journal of Magnetic Resonance 111, 209-219. |
[3] | (1, 2) Lin-Ching C., Jones D.K., Pierpaoli, C. 2005. RESTORE: Robust estimation of tensors by outlier rejection. MRM 53: 1088-1095 |
fit
(data, mask=None)Fit method of the DTI model class
Parameters: |
|
---|
predict
(dti_params, S0=1.0)Predict a signal for this TensorModel class instance given parameters.
Parameters: |
|
---|
Workflow
dipy.workflows.reconst.
Workflow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: object
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (*args, **kwargs) |
Execute the workflow. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_io_iterator
()Create an iterator for IO.
Use a couple of inspection tricks to build an IOIterator using the previous frame (values of local variables and other contextuals) and the run method’s docstring.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
dipy.workflows.reconst.
IvimModel
(gtab, fit_method='LM', **kwargs)Selector function to switch between the 2-stage Levenberg-Marquardt based NLLS fitting method (also containing the linear fit): LM and the Variable Projections based fitting method: VarPro.
Parameters: |
|
---|
dipy.workflows.reconst.
auto_response
(gtab, data, roi_center=None, roi_radius=10, fa_thr=0.7, fa_callable=<function fa_superior>, return_number_of_voxels=False)Automatic estimation of response function using FA.
Parameters: |
|
---|---|
Returns: |
|
Notes
In CSD there is an important pre-processing step: the estimation of the fiber response function. In order to do this we look for voxels with very anisotropic configurations. For example we can use an ROI (20x20x20) at the center of the volume and store the signal values for the voxels with FA values higher than 0.7. Of course, if we haven’t precalculated FA we need to fit a Tensor model to the datasets. Which is what we do in this function.
For the response we also need to find the average S0 in the ROI. This is possible using gtab.b0s_mask() we can find all the S0 volumes (which correspond to b-values equal 0) in the dataset.
The response consists always of a prolate tensor created by averaging the highest and second highest eigenvalues in the ROI with FA higher than threshold. We also include the average S0s.
We also return the ratio which is used for the SDT models. If requested, the number of voxels used for estimating the response function is also returned, which can be used to judge the fidelity of the response function. As a rule of thumb, at least 300 voxels should be used to estimate a good response function (see [1]).
References
[1] | (1, 2) Tournier, J.D., et al. NeuroImage 2004. Direct estimation of the |
fiber orientation density function from diffusion-weighted MRI data using spherical deconvolution
dipy.workflows.reconst.
axial_diffusivity
(evals, axis=-1)Axial Diffusivity (AD) of a diffusion tensor. Also called parallel diffusivity.
Parameters: |
|
---|---|
Returns: |
|
Notes
AD is calculated with the following equation:
dipy.workflows.reconst.
color_fa
(fa, evecs)Color fractional anisotropy of diffusion tensor
Parameters: |
|
---|---|
Returns: |
|
ec{e})) imes fa
dipy.workflows.reconst.
fractional_anisotropy
(evals, axis=-1)Fractional anisotropy (FA) of a diffusion tensor.
Parameters: |
|
---|---|
Returns: |
|
Notes
FA is calculated using the following equation:
dipy.workflows.reconst.
geodesic_anisotropy
(evals, axis=-1)Geodesic anisotropy (GA) of a diffusion tensor.
Parameters: |
|
---|---|
Returns: |
|
Notes
GA is calculated using the following equation given in [1]:
Note that the notation, \(<D>\), is often used as the mean diffusivity (MD) of the diffusion tensor and can lead to confusions in the literature (see [1] versus [2] versus [3] for example). Reference [2] defines geodesic anisotropy (GA) with \(<D>\) as the MD in the denominator of the sum. This is wrong. The original paper [1] defines GA with \(<D> = det(D)^{1/3}\), as the isotropic part of the distance. This might be an explanation for the confusion. The isotropic part of the diffusion tensor in Euclidean space is the MD whereas the isotropic part of the tensor in log-Euclidean space is \(det(D)^{1/3}\). The Appendix of [1] and log-Euclidean derivations from [3] are clear on this. Hence, all that to say that \(<D> = det(D)^{1/3}\) here for the GA definition and not MD.
References
[1] | (1, 2, 3, 4, 5) P. G. Batchelor, M. Moakher, D. Atkinson, F. Calamante, A. Connelly, “A rigorous framework for diffusion tensor calculus”, Magnetic Resonance in Medicine, vol. 53, pp. 221-225, 2005. |
[2] | (1, 2, 3) M. M. Correia, V. F. Newcombe, G.B. Williams. “Contrast-to-noise ratios for indices of anisotropy obtained from diffusion MRI: a study with standard clinical b-values at 3T”. NeuroImage, vol. 57, pp. 1103-1115, 2011. |
[3] | (1, 2, 3) A. D. Lee, etal, P. M. Thompson. “Comparison of fractional and geodesic anisotropy in diffusion tensor images of 90 monozygotic and dizygotic twins”. 5th IEEE International Symposium on Biomedical Imaging (ISBI), pp. 943-946, May 2008. |
[4] | V. Arsigny, P. Fillard, X. Pennec, N. Ayache. “Log-Euclidean metrics for fast and simple calculus on diffusion tensors.” Magnetic Resonance in Medecine, vol 56, pp. 411-421, 2006. |
dipy.workflows.reconst.
get_mode
(q_form)Mode (MO) of a diffusion tensor [1].
Parameters: |
|
---|---|
Returns: |
|
Notes
Mode ranges between -1 (planar anisotropy) and +1 (linear anisotropy) with 0 representing orthotropy. Mode is calculated with the following equation (equation 9 in [1]):
Where \(\widetilde{A}\) is the deviatoric part of the tensor quadratic form.
References
[1] | (1, 2, 3, 4) Daniel B. Ennis and G. Kindlmann, “Orthogonal Tensor Invariants and the Analysis of Diffusion Tensor Magnetic Resonance Images”, Magnetic Resonance in Medicine, vol. 55, no. 1, pp. 136-146, 2006. |
dipy.workflows.reconst.
get_sphere
(name='symmetric362')provide triangulated spheres
Parameters: |
|
---|---|
Returns: |
|
Examples
>>> import numpy as np
>>> from dipy.data import get_sphere
>>> sphere = get_sphere('symmetric362')
>>> verts, faces = sphere.vertices, sphere.faces
>>> verts.shape == (362, 3)
True
>>> faces.shape == (720, 3)
True
>>> verts, faces = get_sphere('not a sphere name')
Traceback (most recent call last):
...
DataError: No sphere called "not a sphere name"
dipy.workflows.reconst.
gradient_table
(bvals, bvecs=None, big_delta=None, small_delta=None, b0_threshold=50, atol=0.01)A general function for creating diffusion MR gradients.
It reads, loads and prepares scanner parameters like the b-values and b-vectors so that they can be useful during the reconstruction process.
Parameters: |
|
---|---|
Returns: |
|
Notes
Examples
>>> from dipy.core.gradients import gradient_table
>>> bvals = 1500 * np.ones(7)
>>> bvals[0] = 0
>>> sq2 = np.sqrt(2) / 2
>>> bvecs = np.array([[0, 0, 0],
... [1, 0, 0],
... [0, 1, 0],
... [0, 0, 1],
... [sq2, sq2, 0],
... [sq2, 0, sq2],
... [0, sq2, sq2]])
>>> gt = gradient_table(bvals, bvecs)
>>> gt.bvecs.shape == bvecs.shape
True
>>> gt = gradient_table(bvals, bvecs.T)
>>> gt.bvecs.shape == bvecs.T.shape
False
dipy.workflows.reconst.
lower_triangular
(tensor, b0=None)Returns the six lower triangular values of the tensor and a dummy variable if b0 is not None
Parameters: |
|
---|---|
Returns: |
|
dipy.workflows.reconst.
mean_diffusivity
(evals, axis=-1)Mean Diffusivity (MD) of a diffusion tensor.
Parameters: |
|
---|---|
Returns: |
|
Notes
MD is calculated with the following equation:
dipy.workflows.reconst.
peaks_from_model
(model, data, sphere, relative_peak_threshold, min_separation_angle, mask=None, return_odf=False, return_sh=True, gfa_thr=0, normalize_peaks=False, sh_order=8, sh_basis_type=None, npeaks=5, B=None, invB=None, parallel=False, nbr_processes=None)Fit the model to data and computes peaks and metrics
Parameters: |
|
---|---|
Returns: |
|
References
[1] | (1, 2) Descoteaux, M., Angelino, E., Fitzgibbons, S. and Deriche, R. Regularized, Fast, and Robust Analytical Q-ball Imaging. Magn. Reson. Med. 2007;58:497-510. |
[2] | (1, 2) Tournier J.D., Calamante F. and Connelly A. Robust determination of the fibre orientation distribution in diffusion MRI: Non-negativity constrained super-resolved spherical deconvolution. NeuroImage. 2007;35(4):1459-1472. |
dipy.workflows.reconst.
radial_diffusivity
(evals, axis=-1)Radial Diffusivity (RD) of a diffusion tensor. Also called perpendicular diffusivity.
Parameters: |
|
---|---|
Returns: |
|
Notes
RD is calculated with the following equation:
dipy.workflows.reconst.
read_bvals_bvecs
(fbvals, fbvecs)Read b-values and b-vectors from disk
Parameters: |
|
---|---|
Returns: |
|
Notes
Files can be either ‘.bvals’/’.bvecs’ or ‘.txt’ or ‘.npy’ (containing arrays stored with the appropriate values).
dipy.workflows.reconst.
save_peaks
(fname, pam, affine=None, verbose=False)Save all important attributes of object PeaksAndMetrics in a PAM5 file (HDF5).
Parameters: |
|
---|
dipy.workflows.reconst.
split_dki_param
(dki_params)Extract the diffusion tensor eigenvalues, the diffusion tensor eigenvector matrix, and the 15 independent elements of the kurtosis tensor from the model parameters estimated from the DKI model
Parameters: |
|
---|---|
Returns: |
|
LabelsBundlesFlow
dipy.workflows.segment.
LabelsBundlesFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (streamline_files, labels_files[, …]) |
Extract bundles using existing indices (labels) |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(streamline_files, labels_files, out_dir='', out_bundle='recognized_orig.trk')Extract bundles using existing indices (labels)
Parameters: |
|
---|
References
[Garyfallidis17] | Garyfallidis et al. Recognition of white matter bundles using local and global streamline-based registration and clustering, Neuroimage, 2017. |
MedianOtsuFlow
dipy.workflows.segment.
MedianOtsuFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (input_files[, save_masked, …]) |
Workflow wrapping the median_otsu segmentation method. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(input_files, save_masked=False, median_radius=2, numpass=5, autocrop=False, vol_idx=None, dilate=None, out_dir='', out_mask='brain_mask.nii.gz', out_masked='dwi_masked.nii.gz')Workflow wrapping the median_otsu segmentation method.
Applies median_otsu segmentation on each file found by ‘globing’
input_files
and saves the results in a directory specified by
out_dir
.
Parameters: |
|
---|
RecoBundles
dipy.workflows.segment.
RecoBundles
(streamlines, greater_than=50, less_than=1000000, cluster_map=None, clust_thr=15, nb_pts=20, rng=None, verbose=True)Bases: object
Methods
evaluate_results (model_bundle, …) |
Comapare the similiarity between two given bundles, model bundle, and extracted bundle. |
recognize (model_bundle, model_clust_thr[, …]) |
Recognize the model_bundle in self.streamlines |
refine (model_bundle, pruned_streamlines, …) |
Refine and recognize the model_bundle in self.streamlines This method expects once pruned streamlines as input. |
__init__
(streamlines, greater_than=50, less_than=1000000, cluster_map=None, clust_thr=15, nb_pts=20, rng=None, verbose=True)Recognition of bundles
Extract bundles from a participants’ tractograms using model bundles segmented from a different subject or an atlas of bundles. See [Garyfallidis17] for the details.
Parameters: |
|
---|
Notes
Make sure that before creating this class that the streamlines and the model bundles are roughly in the same space. Also default thresholds are assumed in RAS 1mm^3 space. You may want to adjust those if your streamlines are not in world coordinates.
References
[Garyfallidis17] | (1, 2) Garyfallidis et al. Recognition of white matter bundles using local and global streamline-based registration and clustering, Neuroimage, 2017. |
evaluate_results
(model_bundle, pruned_streamlines, slr_select)Comapare the similiarity between two given bundles, model bundle, and extracted bundle.
Parameters: |
|
---|---|
Returns: |
|
recognize
(model_bundle, model_clust_thr, reduction_thr=10, reduction_distance='mdf', slr=True, slr_num_threads=None, slr_metric=None, slr_x0=None, slr_bounds=None, slr_select=(400, 600), slr_method='L-BFGS-B', pruning_thr=5, pruning_distance='mdf')Recognize the model_bundle in self.streamlines
Parameters: |
|
---|---|
Returns: |
|
References
[Garyfallidis17] | Garyfallidis et al. Recognition of white matter bundles using local and global streamline-based registration and clustering, Neuroimage, 2017. |
refine
(model_bundle, pruned_streamlines, model_clust_thr, reduction_thr=14, reduction_distance='mdf', slr=True, slr_metric=None, slr_x0=None, slr_bounds=None, slr_select=(400, 600), slr_method='L-BFGS-B', pruning_thr=6, pruning_distance='mdf')Refine and recognize the model_bundle in self.streamlines This method expects once pruned streamlines as input. It refines the first ouput of recobundle by applying second local slr (optional), and second pruning. This method is useful when we are dealing with noisy data or when we want to extract small tracks from tractograms.
Parameters: |
|
---|---|
Returns: |
|
References
[Garyfallidis17] | Garyfallidis et al. Recognition of white matter bundles using local and global streamline-based registration and clustering, Neuroimage, 2017. |
RecoBundlesFlow
dipy.workflows.segment.
RecoBundlesFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (streamline_files, model_bundle_files[, …]) |
Recognize bundles |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(streamline_files, model_bundle_files, greater_than=50, less_than=1000000, no_slr=False, clust_thr=15.0, reduction_thr=15.0, reduction_distance='mdf', model_clust_thr=2.5, pruning_thr=8.0, pruning_distance='mdf', slr_metric='symmetric', slr_transform='similarity', slr_matrix='small', refine=False, r_reduction_thr=12.0, r_pruning_thr=6.0, no_r_slr=False, out_dir='', out_recognized_transf='recognized.trk', out_recognized_labels='labels.npy')Recognize bundles
Parameters: |
|
---|
References
[Garyfallidis17] | Garyfallidis et al. Recognition of white matter bundles using local and global streamline-based registration and clustering, Neuroimage, 2017. |
Workflow
dipy.workflows.segment.
Workflow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: object
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (*args, **kwargs) |
Execute the workflow. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_io_iterator
()Create an iterator for IO.
Use a couple of inspection tricks to build an IOIterator using the previous frame (values of local variables and other contextuals) and the run method’s docstring.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
dipy.workflows.segment.
load_trk
(filename, lazy_load=False)Loads tractogram files (*.tck)
Parameters: |
|
---|---|
Returns: |
|
dipy.workflows.segment.
median_otsu
(input_volume, median_radius=4, numpass=4, autocrop=False, vol_idx=None, dilate=None)Simple brain extraction tool method for images from DWI data.
It uses a median filter smoothing of the input_volumes vol_idx and an automatic histogram Otsu thresholding technique, hence the name median_otsu.
This function is inspired from Mrtrix’s bet which has default values
median_radius=3
, numpass=2
. However, from tests on multiple 1.5T
and 3T data from GE, Philips, Siemens, the most robust choice is
median_radius=4
, numpass=4
.
Parameters: |
|
---|---|
Returns: |
|
Notes
Copyright (C) 2011, the scikit-image team All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of skimage nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS’’ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
BundleAnalysisPopulationFlow
dipy.workflows.stats.
BundleAnalysisPopulationFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (model_bundle_folder, subject_folder[, …]) |
Workflow of bundle analytics. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(model_bundle_folder, subject_folder, no_disks=100, out_dir='')Workflow of bundle analytics.
Applies statistical analysis on bundles of subjects and saves the
results in a directory specified by out_dir
.
Parameters: |
|
---|
References
[Chandio19] | Chandio, B.Q., S. Koudoro, D. Reagan, J. Harezlak, |
E. Garyfallidis, Bundle Analytics: a computational and statistical analyses framework for tractometric studies, Proceedings of: International Society of Magnetic Resonance in Medicine (ISMRM), Montreal, Canada, 2019.
LinearMixedModelsFlow
dipy.workflows.stats.
LinearMixedModelsFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (h5_files[, no_disks, out_dir]) |
Workflow of linear Mixed Models. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(h5_files, no_disks=100, out_dir='')Workflow of linear Mixed Models.
Applies linear Mixed Models on bundles of subjects and saves the
results in a directory specified by out_dir
.
Parameters: |
|
---|
SNRinCCFlow
dipy.workflows.stats.
SNRinCCFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (data_files, bvals_files, bvecs_files, …) |
Compute the signal-to-noise ratio in the corpus callosum. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(data_files, bvals_files, bvecs_files, mask_files, bbox_threshold=[0.6, 1, 0, 0.1, 0, 0.1], out_dir='', out_file='product.json', out_mask_cc='cc.nii.gz', out_mask_noise='mask_noise.nii.gz')Compute the signal-to-noise ratio in the corpus callosum.
Parameters: |
|
---|
TensorModel
dipy.workflows.stats.
TensorModel
(gtab, fit_method='WLS', return_S0_hat=False, *args, **kwargs)Bases: dipy.reconst.base.ReconstModel
Diffusion Tensor
Methods
fit (data[, mask]) |
Fit method of the DTI model class |
predict (dti_params[, S0]) |
Predict a signal for this TensorModel class instance given parameters. |
__init__
(gtab, fit_method='WLS', return_S0_hat=False, *args, **kwargs)A Diffusion Tensor Model [1], [2].
Parameters: |
|
---|
Notes
In order to increase speed of processing, tensor fitting is done simultaneously over many voxels. Many fit_methods use the ‘step’ parameter to set the number of voxels that will be fit at once in each iteration. This is the chunk size as a number of voxels. A larger step value should speed things up, but it will also take up more memory. It is advisable to keep an eye on memory consumption as this value is increased.
Example : In iter_fit_tensor()
we have a default step value of
1e4
References
[1] | (1, 2) Basser, P.J., Mattiello, J., LeBihan, D., 1994. Estimation of the effective self-diffusion tensor from the NMR spin echo. J Magn Reson B 103, 247-254. |
[2] | (1, 2) Basser, P., Pierpaoli, C., 1996. Microstructural and physiological features of tissues elucidated by quantitative diffusion-tensor MRI. Journal of Magnetic Resonance 111, 209-219. |
[3] | (1, 2) Lin-Ching C., Jones D.K., Pierpaoli, C. 2005. RESTORE: Robust estimation of tensors by outlier rejection. MRM 53: 1088-1095 |
fit
(data, mask=None)Fit method of the DTI model class
Parameters: |
|
---|
predict
(dti_params, S0=1.0)Predict a signal for this TensorModel class instance given parameters.
Parameters: |
|
---|
Workflow
dipy.workflows.stats.
Workflow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: object
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (*args, **kwargs) |
Execute the workflow. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_io_iterator
()Create an iterator for IO.
Use a couple of inspection tricks to build an IOIterator using the previous frame (values of local variables and other contextuals) and the run method’s docstring.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
dipy.workflows.stats.
binary_dilation
(input, structure=None, iterations=1, mask=None, output=None, border_value=0, origin=0, brute_force=False)Multi-dimensional binary dilation with the given structuring element.
Parameters: |
|
---|---|
Returns: |
|
See also
grey_dilation
, binary_erosion
, binary_closing
, binary_opening
, generate_binary_structure
Notes
Dilation [1] is a mathematical morphology operation [2] that uses a structuring element for expanding the shapes in an image. The binary dilation of an image by a structuring element is the locus of the points covered by the structuring element, when its center lies within the non-zero points of the image.
References
[1] | (1, 2) http://en.wikipedia.org/wiki/Dilation_%28morphology%29 |
[2] | (1, 2) http://en.wikipedia.org/wiki/Mathematical_morphology |
Examples
>>> from scipy import ndimage
>>> a = np.zeros((5, 5))
>>> a[2, 2] = 1
>>> a
array([[ 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0.],
[ 0., 0., 1., 0., 0.],
[ 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0.]])
>>> ndimage.binary_dilation(a)
array([[False, False, False, False, False],
[False, False, True, False, False],
[False, True, True, True, False],
[False, False, True, False, False],
[False, False, False, False, False]], dtype=bool)
>>> ndimage.binary_dilation(a).astype(a.dtype)
array([[ 0., 0., 0., 0., 0.],
[ 0., 0., 1., 0., 0.],
[ 0., 1., 1., 1., 0.],
[ 0., 0., 1., 0., 0.],
[ 0., 0., 0., 0., 0.]])
>>> # 3x3 structuring element with connectivity 1, used by default
>>> struct1 = ndimage.generate_binary_structure(2, 1)
>>> struct1
array([[False, True, False],
[ True, True, True],
[False, True, False]], dtype=bool)
>>> # 3x3 structuring element with connectivity 2
>>> struct2 = ndimage.generate_binary_structure(2, 2)
>>> struct2
array([[ True, True, True],
[ True, True, True],
[ True, True, True]], dtype=bool)
>>> ndimage.binary_dilation(a, structure=struct1).astype(a.dtype)
array([[ 0., 0., 0., 0., 0.],
[ 0., 0., 1., 0., 0.],
[ 0., 1., 1., 1., 0.],
[ 0., 0., 1., 0., 0.],
[ 0., 0., 0., 0., 0.]])
>>> ndimage.binary_dilation(a, structure=struct2).astype(a.dtype)
array([[ 0., 0., 0., 0., 0.],
[ 0., 1., 1., 1., 0.],
[ 0., 1., 1., 1., 0.],
[ 0., 1., 1., 1., 0.],
[ 0., 0., 0., 0., 0.]])
>>> ndimage.binary_dilation(a, structure=struct1,\
... iterations=2).astype(a.dtype)
array([[ 0., 0., 1., 0., 0.],
[ 0., 1., 1., 1., 0.],
[ 1., 1., 1., 1., 1.],
[ 0., 1., 1., 1., 0.],
[ 0., 0., 1., 0., 0.]])
dipy.workflows.stats.
bundle_analysis
(model_bundle_folder, bundle_folder, orig_bundle_folder, metric_folder, group, subject, no_disks=100, out_dir='')Applies statistical analysis on bundles and saves the results
in a directory specified by out_dir
.
Parameters: |
|
---|
References
[Chandio19] | Chandio, B.Q., S. Koudoro, D. Reagan, J. Harezlak, |
E. Garyfallidis, Bundle Analytics: a computational and statistical analyses framework for tractometric studies, Proceedings of: International Society of Magnetic Resonance in Medicine (ISMRM), Montreal, Canada, 2019.
dipy.workflows.stats.
gradient_table
(bvals, bvecs=None, big_delta=None, small_delta=None, b0_threshold=50, atol=0.01)A general function for creating diffusion MR gradients.
It reads, loads and prepares scanner parameters like the b-values and b-vectors so that they can be useful during the reconstruction process.
Parameters: |
|
---|---|
Returns: |
|
Notes
Examples
>>> from dipy.core.gradients import gradient_table
>>> bvals = 1500 * np.ones(7)
>>> bvals[0] = 0
>>> sq2 = np.sqrt(2) / 2
>>> bvecs = np.array([[0, 0, 0],
... [1, 0, 0],
... [0, 1, 0],
... [0, 0, 1],
... [sq2, sq2, 0],
... [sq2, 0, sq2],
... [0, sq2, sq2]])
>>> gt = gradient_table(bvals, bvecs)
>>> gt.bvecs.shape == bvecs.shape
True
>>> gt = gradient_table(bvals, bvecs.T)
>>> gt.bvecs.shape == bvecs.T.shape
False
dipy.workflows.stats.
median_otsu
(input_volume, median_radius=4, numpass=4, autocrop=False, vol_idx=None, dilate=None)Simple brain extraction tool method for images from DWI data.
It uses a median filter smoothing of the input_volumes vol_idx and an automatic histogram Otsu thresholding technique, hence the name median_otsu.
This function is inspired from Mrtrix’s bet which has default values
median_radius=3
, numpass=2
. However, from tests on multiple 1.5T
and 3T data from GE, Philips, Siemens, the most robust choice is
median_radius=4
, numpass=4
.
Parameters: |
|
---|---|
Returns: |
|
Notes
Copyright (C) 2011, the scikit-image team All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of skimage nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS’’ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dipy.workflows.stats.
optional_package
(name, trip_msg=None)Return package-like thing and module setup for package name
Parameters: |
|
---|---|
Returns: |
|
dipy.workflows.stats.
read_bvals_bvecs
(fbvals, fbvecs)Read b-values and b-vectors from disk
Parameters: |
|
---|---|
Returns: |
|
Notes
Files can be either ‘.bvals’/’.bvecs’ or ‘.txt’ or ‘.npy’ (containing arrays stored with the appropriate values).
dipy.workflows.stats.
segment_from_cfa
(tensor_fit, roi, threshold, return_cfa=False)Segment the cfa inside roi using the values from threshold as bounds.
Parameters: |
|
---|---|
Returns: |
|
dipy.workflows.stats.
simple_plot
(file_name, title, x, y, xlabel, ylabel)Saves the simple plot with given x and y values
Parameters: |
|
---|
ClosestPeakDirectionGetter
dipy.workflows.tracking.
ClosestPeakDirectionGetter
Bases: dipy.direction.closest_peak_direction_getter.PmfGenDirectionGetter
A direction getter that returns the closest odf peak to previous tracking direction.
Methods
from_pmf |
Constructor for making a DirectionGetter from an array of Pmfs |
from_shcoeff |
Probabilistic direction getter from a distribution of directions on the sphere |
initial_direction |
Returns best directions at seed location to start tracking. |
get_direction |
CmcTissueClassifier
dipy.workflows.tracking.
CmcTissueClassifier
Bases: dipy.tracking.local.tissue_classifier.ConstrainedTissueClassifier
Continuous map criterion (CMC) stopping criteria from [1]. This implements the use of partial volume fraction (PVE) maps to determine when the tracking stops.
References
[1] | (1, 2, 3) Girard, G., Whittingstall, K., Deriche, R., & Descoteaux, M. |
“Towards quantitative connectivity analysis: reducing tractography biases.” NeuroImage, 98, 266-278, 2014.
Methods
from_pve |
ConstrainedTissueClassifier from partial volume fraction (PVE) maps. |
check_point | |
get_exclude | |
get_include |
DeterministicMaximumDirectionGetter
dipy.workflows.tracking.
DeterministicMaximumDirectionGetter
Bases: dipy.direction.probabilistic_direction_getter.ProbabilisticDirectionGetter
Return direction of a sphere with the highest probability mass function (pmf).
Methods
from_pmf |
Constructor for making a DirectionGetter from an array of Pmfs |
from_shcoeff |
Probabilistic direction getter from a distribution of directions on the sphere |
initial_direction |
Returns best directions at seed location to start tracking. |
get_direction |
LocalFiberTrackingPAMFlow
dipy.workflows.tracking.
LocalFiberTrackingPAMFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (pam_files, stopping_files, seeding_files) |
Workflow for Local Fiber Tracking. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(pam_files, stopping_files, seeding_files, stopping_thr=0.2, seed_density=1, tracking_method='deterministic', pmf_threshold=0.1, max_angle=30.0, out_dir='', out_tractogram='tractogram.trk')Workflow for Local Fiber Tracking.
This workflow use a saved peaks and metrics (PAM) file as input.
Parameters: |
|
---|
References
Garyfallidis, University of Cambridge, PhD thesis 2012. Amirbekian, University of California San Francisco, PhD thesis 2017.
LocalTracking
dipy.workflows.tracking.
LocalTracking
(direction_getter, tissue_classifier, seeds, affine, step_size, max_cross=None, maxlen=500, fixedstep=True, return_all=True, random_seed=None)Bases: object
__init__
(direction_getter, tissue_classifier, seeds, affine, step_size, max_cross=None, maxlen=500, fixedstep=True, return_all=True, random_seed=None)Creates streamlines by using local fiber-tracking.
Parameters: |
|
---|
PFTrackingPAMFlow
dipy.workflows.tracking.
PFTrackingPAMFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (pam_files, wm_files, gm_files, …[, …]) |
Workflow for Particle Filtering Tracking. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(pam_files, wm_files, gm_files, csf_files, seeding_files, step_size=0.2, back_tracking_dist=2, front_tracking_dist=1, max_trial=20, particle_count=15, seed_density=1, pmf_threshold=0.1, max_angle=30.0, out_dir='', out_tractogram='tractogram.trk')Workflow for Particle Filtering Tracking.
This workflow use a saved peaks and metrics (PAM) file as input.
Parameters: |
|
---|
References
ParticleFilteringTracking
dipy.workflows.tracking.
ParticleFilteringTracking
(direction_getter, tissue_classifier, seeds, affine, step_size, max_cross=None, maxlen=500, pft_back_tracking_dist=2, pft_front_tracking_dist=1, pft_max_trial=20, particle_count=15, return_all=True, random_seed=None)Bases: dipy.tracking.local.localtracking.LocalTracking
__init__
(direction_getter, tissue_classifier, seeds, affine, step_size, max_cross=None, maxlen=500, pft_back_tracking_dist=2, pft_front_tracking_dist=1, pft_max_trial=20, particle_count=15, return_all=True, random_seed=None)A streamline generator using the particle filtering tractography method [1].
Parameters: |
|
---|
References
[1] | (1, 2) Girard, G., Whittingstall, K., Deriche, R., & Descoteaux, M. Towards quantitative connectivity analysis: reducing tractography biases. NeuroImage, 98, 266-278, 2014. |
ProbabilisticDirectionGetter
dipy.workflows.tracking.
ProbabilisticDirectionGetter
Bases: dipy.direction.closest_peak_direction_getter.PmfGenDirectionGetter
Randomly samples direction of a sphere based on probability mass function (pmf).
The main constructors for this class are current from_pmf and from_shcoeff.
The pmf gives the probability that each direction on the sphere should be
chosen as the next direction. To get the true pmf from the “raw pmf”
directions more than max_angle
degrees from the incoming direction are
set to 0 and the result is normalized.
Methods
from_pmf |
Constructor for making a DirectionGetter from an array of Pmfs |
from_shcoeff |
Probabilistic direction getter from a distribution of directions on the sphere |
initial_direction |
Returns best directions at seed location to start tracking. |
get_direction |
__init__
()Direction getter from a pmf generator.
Parameters: |
|
---|
See also
ThresholdTissueClassifier
dipy.workflows.tracking.
ThresholdTissueClassifier
Bases: dipy.tracking.local.tissue_classifier.TissueClassifier
# Declarations from tissue_classifier.pxd bellow cdef:
double threshold, interp_out_double[1] double[:] interp_out_view = interp_out_view double[:, :, :] metric_map
Methods
check_point |
Tractogram
dipy.workflows.tracking.
Tractogram
(streamlines=None, data_per_streamline=None, data_per_point=None, affine_to_rasmm=None)Bases: object
Container for streamlines and their data information.
Streamlines of a tractogram can be in any coordinate system of your choice as long as you provide the correct affine_to_rasmm matrix, at construction time. When applied to streamlines coordinates, that transformation matrix should bring the streamlines back to world space (RAS+ and mm space) [1]_.
Moreover, when streamlines are mapped back to voxel space [2]_, a streamline point located at an integer coordinate (i,j,k) is considered to be at the center of the corresponding voxel. This is in contrast with other conventions where it might have referred to a corner.
References
[1] http://nipy.org/nibabel/coordinate_systems.html#naming-reference-spaces [2] http://nipy.org/nibabel/coordinate_systems.html#voxel-coordinates-are-in-voxel-space
Attributes: |
|
---|
Methods
apply_affine (affine[, lazy]) |
Applies an affine transformation on the points of each streamline. |
copy () |
Returns a copy of this Tractogram object. |
extend (other) |
Appends the data of another Tractogram . |
to_world ([lazy]) |
Brings the streamlines to world space (i.e. |
__init__
(streamlines=None, data_per_streamline=None, data_per_point=None, affine_to_rasmm=None)Parameters: |
|
---|
apply_affine
(affine, lazy=False)Applies an affine transformation on the points of each streamline.
If lazy is not specified, this is performed in-place.
Parameters: |
|
---|---|
Returns: |
|
copy
()Returns a copy of this Tractogram
object.
extend
(other)Appends the data of another Tractogram
.
Data that will be appended includes the streamlines and the content of both dictionaries data_per_streamline and data_per_point.
Parameters: |
|
---|---|
Returns: |
|
Notes
The entries in both dictionaries self.data_per_streamline and self.data_per_point must match respectively those contained in the other tractogram.
to_world
(lazy=False)Brings the streamlines to world space (i.e. RAS+ and mm).
If lazy is not specified, this is performed in-place.
Parameters: |
|
---|---|
Returns: |
|
Workflow
dipy.workflows.tracking.
Workflow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: object
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (*args, **kwargs) |
Execute the workflow. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_io_iterator
()Create an iterator for IO.
Use a couple of inspection tricks to build an IOIterator using the previous frame (values of local variables and other contextuals) and the run method’s docstring.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
dipy.workflows.tracking.
save
(tractogram, filename, **kwargs)Saves a tractogram to a file.
Parameters: |
|
---|
HorizonFlow
dipy.workflows.viz.
HorizonFlow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: dipy.workflows.workflow.Workflow
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (input_files[, cluster, cluster_thr, …]) |
Highly interactive visualization - invert the Horizon! |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
run
(input_files, cluster=False, cluster_thr=15.0, random_colors=False, length_lt=1000, length_gt=0, clusters_lt=100000000, clusters_gt=0, native_coords=False, stealth=False, out_dir='', out_stealth_png='tmp.png')Highly interactive visualization - invert the Horizon!
Interact with any number of .trk, .tck or .dpy tractograms and anatomy files .nii or .nii.gz. Cluster streamlines on loading.
Parameters: |
|
---|
References
[Horizon_ISMRM19] | Garyfallidis E., M-A. Cote, B.Q. Chandio, S. Fadnavis, J. Guaje, R. Aggarwal, E. St-Onge, K.S. Juneja, S. Koudoro, D. Reagan, DIPY Horizon: fast, modular, unified and adaptive visualization, Proceedings of: International Society of Magnetic Resonance in Medicine (ISMRM), Montreal, Canada, 2019. |
Workflow
dipy.workflows.viz.
Workflow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: object
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (*args, **kwargs) |
Execute the workflow. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_io_iterator
()Create an iterator for IO.
Use a couple of inspection tricks to build an IOIterator using the previous frame (values of local variables and other contextuals) and the run method’s docstring.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
dipy.workflows.viz.
horizon
(tractograms, images, cluster, cluster_thr, random_colors, length_lt, length_gt, clusters_lt, clusters_gt, world_coords=True, interactive=True, out_png='tmp.png')Highly interactive visualization - invert the Horizon!
Parameters: |
|
---|
References
[Horizon_ISMRM19] | Garyfallidis E., M-A. Cote, B.Q. Chandio, S. Fadnavis, J. Guaje, R. Aggarwal, E. St-Onge, K.S. Juneja, S. Koudoro, D. Reagan, DIPY Horizon: fast, modular, unified and adaptive visualization, Proceedings of: International Society of Magnetic Resonance in Medicine (ISMRM), Montreal, Canada, 2019. |
dipy.workflows.viz.
load_tractogram
(filename, lazy_load=False)Loads tractogram files (*.tck)
Parameters: |
|
---|---|
Returns: |
|
Workflow
dipy.workflows.workflow.
Workflow
(output_strategy='absolute', mix_names=False, force=False, skip=False)Bases: object
Methods
get_io_iterator () |
Create an iterator for IO. |
get_short_name () |
Return A short name for the workflow used to subdivide. |
get_sub_runs () |
Return No sub runs since this is a simple workflow. |
manage_output_overwrite () |
Check if a file will be overwritten upon processing the inputs. |
run (*args, **kwargs) |
Execute the workflow. |
__init__
(output_strategy='absolute', mix_names=False, force=False, skip=False)Initialize the basic workflow object.
This object takes care of any workflow operation that is common to all the workflows. Every new workflow should extend this class.
get_io_iterator
()Create an iterator for IO.
Use a couple of inspection tricks to build an IOIterator using the previous frame (values of local variables and other contextuals) and the run method’s docstring.
get_short_name
()Return A short name for the workflow used to subdivide.
The short name is used by CombinedWorkflows and the argparser to subdivide the commandline parameters avoiding the trouble of having subworkflows parameters with the same name.
For example, a combined workflow with dti reconstruction and csd reconstruction might en up with the b0_threshold parameter. Using short names, we will have dti.b0_threshold and csd.b0_threshold available.
Returns class name by default but it is strongly advised to set it to something shorter and easier to write on commandline.
dipy.workflows.workflow.
io_iterator_
(frame, fnc, output_strategy='absolute', mix_names=False)Creates an IOIterator using introspection.
Parameters: |
|
---|