data
data.fetcher
DataError
GradientTable
HemiSphere
Sphere
FetcherError
tqdm
data
Read test or example data.
|
Diffusion gradient information |
|
Points on the unit sphere. |
|
Points on the unit sphere. |
|
Return arr as native byteordered array |
|
Returns the directory component of a pathname |
Download atlas tractogram from the hcp842 dataset with 80 bundles |
|
Download map of FA within two bundles in oneof the hcp dataset subjects |
|
Download 2 subjects from the SNAIL dataset with their bundles |
|
|
Fetch ‘HCP-like’ data, collected at multiple b-values. |
Download CFIN multi b-value diffusion data |
|
Downloads the gold standard for streamlines io testing. |
|
Download a 2-shell software phantom dataset |
|
Download IVIM dataset |
|
fetch the MNI 2009a T1 and T2, and 2009c T1 and T1 mask files Notes —– The templates were downloaded from the MNI (McGill University) website in July 2015. |
|
Download b=0 datasets from multiple MR systems (GE, Philips, Siemens) and different magnetic fields (1.5T and 3T) |
|
Download a 3shell HARDI dataset with 192 gradient direction |
|
Download a HARDI dataset with 160 gradient directions |
|
Download reduced freesurfer aparc image from stanford web site |
|
Download t1 and b0 volumes from the same session |
|
Download a DSI dataset with 203 gradient directions |
|
Download tractogram of one of the hcp dataset subjects |
|
Download images to be used for tissue classification |
|
|
|
|
Make a callable, similar to maptlotlib.pyplot.get_cmap. |
|
Provide full paths to example or test datasets. |
|
provide some simulated voxel data |
|
provide skeletons generated from Local Skeleton Clustering (LSC) |
|
provide triangulated spheres |
|
|
|
|
|
A general function for creating diffusion MR gradients. |
|
Load file given filename, guessing at file type |
|
Load data and other information from a nifti file. |
|
|
Spherical functions represented by spherical harmonic coefficients and evaluated on a discrete sphere. |
|
|
Join two or more pathname components, inserting ‘/’ as needed. |
|
Read images and streamlines from 2 subjects of the SNAIL dataset. |
|
Read CENIR multi b-value data. |
Load CFIN multi b-value DWI data. |
|
Load CFIN T1-weighted data. |
|
Load ISBI 2013 2-shell synthetic dataset. |
|
Load IVIM dataset. |
|
|
Read the MNI template from disk. |
Load GE 3T b0 image form the scil b0 dataset. |
|
Load Sherbrooke 3-shell HARDI dataset. |
|
Load Stanford HARDI dataset. |
|
Read stanford hardi data and label map. |
|
Load t1 and b0 volumes from the same session. |
|
Load Taiwan NTU dataset. |
|
|
Load images to be used for tissue classification |
|
Given a representation of a set of streamlines as a large array and an offsets array return the streamlines as a list of shorter arrays. |
data.fetcher
alias of |
|
|
Computes the md5 of filename and check if it matches with the supplied string md5 |
|
copy data from file-like object fsrc to file-like object fdst |
|
|
Download atlas tractogram from the hcp842 dataset with 80 bundles |
|
Download map of FA within two bundles in oneof the hcp dataset subjects |
|
Download 2 subjects from the SNAIL dataset with their bundles |
|
|
Fetch ‘HCP-like’ data, collected at multiple b-values. |
Download CFIN multi b-value diffusion data |
|
|
Downloads files to folder and checks their md5 checksums |
Download 5 bundles in various file formats and their reference |
|
Surface for testing and examples |
|
Downloads the gold standard for streamlines io testing. |
|
Download a 2-shell software phantom dataset |
|
Download IVIM dataset |
|
fetch the MNI 2009a T1 and T2, and 2009c T1 and T1 mask files Notes —– The templates were downloaded from the MNI (McGill University) website in July 2015. |
|
Downloads test-retest qt-dMRI acquisitions of two C57Bl6 mice. |
|
Download b=0 datasets from multiple MR systems (GE, Philips, Siemens) and different magnetic fields (1.5T and 3T) |
|
Download a 3shell HARDI dataset with 192 gradient direction |
|
Download a HARDI dataset with 160 gradient directions |
|
Download reduced freesurfer aparc image from stanford web site |
|
Download t1 and b0 volumes from the same session |
|
Download a DSI dataset with 203 gradient directions |
|
Download tractogram of one of the hcp dataset subjects |
|
Download images to be used for tissue classification |
|
|
|
|
|
|
Provide full paths to example or test datasets. |
|
|
|
|
|
A general function for creating diffusion MR gradients. |
A general function for creating diffusion MR gradients. |
|
|
Load data and other information from a nifti file. |
|
Load only the data array from a nifti file. |
Returns a md5 hash object; optionally initialized with a string |
|
|
Join two or more pathname components, inserting ‘/’ as needed. |
|
Read images and streamlines from 2 subjects of the SNAIL dataset. |
|
Read b-values and b-vectors from disk. |
|
Read CENIR multi b-value data. |
Load CFIN multi b-value DWI data. |
|
Load CFIN T1-weighted data. |
|
Load ISBI 2013 2-shell synthetic dataset. |
|
Load IVIM dataset. |
|
|
Read the MNI template from disk. |
Load test-retest qt-dMRI acquisitions of two C57Bl6 mice. |
|
Load GE 3T b0 image form the scil b0 dataset. |
|
Load Sherbrooke 3-shell HARDI dataset. |
|
Load Siemens 1.5T b0 image from the scil b0 dataset. |
|
Load Stanford HARDI dataset. |
|
Read stanford hardi data and label map. |
|
Load t1 and b0 volumes from the same session. |
|
Load Taiwan NTU dataset. |
|
|
Load images to be used for tissue classification |
|
Open the URL url, which can be either a string or a Request object. |
DataError
dipy.data.
DataError
Bases: Exception
Methods
|
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self. |
GradientTable
dipy.data.
GradientTable
(gradients, big_delta=None, small_delta=None, b0_threshold=50, btens=None)Bases: object
Diffusion gradient information
Diffusion gradients. The direction of each of these vectors corresponds to the b-vector, and the length corresponds to the b-value.
Gradients with b-value less than or equal to b0_threshold are considered as b0s i.e. without diffusion weighting.
See also
Notes
The GradientTable object is immutable. Do NOT assign attributes. If you have your gradient table in a bval & bvec format, we recommend using the factory function gradient_table
diffusion gradients
The b-value, or magnitude, of each gradient direction.
The q-value for each gradient direction. Needs big and small delta.
The direction, represented as a unit vector, of each gradient.
Boolean array indicating which gradients have no diffusion weighting, ie b-value is close to 0.
Gradients with b-value less than or equal to b0_threshold are considered to not have diffusion weighting.
The b-tensor of each gradient direction.
Methods
b0s_mask |
|
bvals |
|
bvecs |
|
gradient_strength |
|
qvals |
|
tau |
HemiSphere
dipy.data.
HemiSphere
(x=None, y=None, z=None, theta=None, phi=None, xyz=None, faces=None, edges=None, tol=1e-05)Bases: dipy.core.sphere.Sphere
Points on the unit sphere.
A HemiSphere is similar to a Sphere but it takes antipodal symmetry into account. Antipodal symmetry means that point v on a HemiSphere is the same as the point -v. Duplicate points are discarded when constructing a HemiSphere (including antipodal duplicates). edges and faces are remapped to the remaining points as closely as possible.
The HemiSphere can be constructed using one of three conventions:
HemiSphere(x, y, z)
HemiSphere(xyz=xyz)
HemiSphere(theta=theta, phi=phi)
Vertices as x-y-z coordinates.
Vertices as spherical coordinates. Theta and phi are the inclination and azimuth angles respectively.
Vertices as x-y-z coordinates.
Indices into vertices that form triangular faces. If unspecified, the faces are computed using a Delaunay triangulation.
Edges between vertices. If unspecified, the edges are derived from the faces.
Angle in degrees. Vertices that are less than tol degrees apart are treated as duplicates.
See also
Methods
|
Find the index of the vertex in the Sphere closest to the input vector, taking into account antipodal symmetry |
|
Create instance from a Sphere |
|
Create a full Sphere from a HemiSphere |
|
Create a more subdivided HemiSphere |
edges |
|
faces |
|
vertices |
__init__
(x=None, y=None, z=None, theta=None, phi=None, xyz=None, faces=None, edges=None, tol=1e-05)Create a HemiSphere from points
Sphere
dipy.data.
Sphere
(x=None, y=None, z=None, theta=None, phi=None, xyz=None, faces=None, edges=None)Bases: object
Points on the unit sphere.
The sphere can be constructed using one of three conventions:
Sphere(x, y, z)
Sphere(xyz=xyz)
Sphere(theta=theta, phi=phi)
Vertices as x-y-z coordinates.
Vertices as spherical coordinates. Theta and phi are the inclination and azimuth angles respectively.
Vertices as x-y-z coordinates.
Indices into vertices that form triangular faces. If unspecified, the faces are computed using a Delaunay triangulation.
Edges between vertices. If unspecified, the edges are derived from the faces.
Methods
|
Find the index of the vertex in the Sphere closest to the input vector |
|
Subdivides each face of the sphere into four new faces. |
edges |
|
faces |
|
vertices |
__init__
(x=None, y=None, z=None, theta=None, phi=None, xyz=None, faces=None, edges=None)Initialize self. See help(type(self)) for accurate signature.
find_closest
(xyz)Find the index of the vertex in the Sphere closest to the input vector
A unit vector
The index into the Sphere.vertices array that gives the closest vertex (in angle).
subdivide
(n=1)Subdivides each face of the sphere into four new faces.
New vertices are created at a, b, and c. Then each face [x, y, z] is divided into faces [x, a, c], [y, a, b], [z, b, c], and [a, b, c].
y
/\
/ \
a/____\b
/\ /\
/ \ / \
/____\/____\
x c z
The number of subdivisions to preform.
The subdivided sphere.
dipy.data.
as_native_array
(arr)Return arr as native byteordered array
If arr is already native byte ordered, return unchanged. If it is opposite endian, then make a native byte ordered copy and return that
If arr was native order, this is just arr. Otherwise it’s a new
array such that np.all(native_arr == arr)
, with native byte
ordering.
dipy.data.
fetch_cenir_multib
(with_raw=False)Fetch ‘HCP-like’ data, collected at multiple b-values.
Whether to fetch the raw data. Per default, this is False, which means that only eddy-current/motion corrected data is fetched
Notes
Details of the acquisition and processing, and additional meta-data are available through UW researchworks:
https://digital.lib.washington.edu/researchworks/handle/1773/33311
dipy.data.
fetch_mni_template
()fetch the MNI 2009a T1 and T2, and 2009c T1 and T1 mask files Notes —– The templates were downloaded from the MNI (McGill University) website in July 2015.
The following publications should be referenced when using these templates:
VS Fonov, AC Evans, K Botteron, CR Almli, RC McKinstry, DL Collins and BDCG, Unbiased average age-appropriate atlases for pediatric studies, NeuroImage, 54:1053-8119, DOI: 10.1016/j.neuroimage.2010.07.033
VS Fonov, AC Evans, RC McKinstry, CR Almli and DL Collins, Unbiased nonlinear average age-appropriate brain templates from birth to adulthood, NeuroImage, 47:S102 Organization for Human Brain Mapping 2009 Annual Meeting, DOI: https://doi.org/10.1016/S1053-8119(09)70884-5
License for the MNI templates:
Copyright (C) 1993-2004, Louis Collins McConnell Brain Imaging Centre, Montreal Neurological Institute, McGill University. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies. The authors and McGill University make no representations about the suitability of this software for any purpose. It is provided “as is” without express or implied warranty. The authors are not responsible for any data loss, equipment damage, property loss, or injury to subjects or patients resulting from the use or misuse of this software package.
dipy.data.
get_fnames
(name='small_64D')Provide full paths to example or test datasets.
the filename/s of which dataset to return, one of: - ‘small_64D’ small region of interest nifti,bvecs,bvals 64 directions - ‘small_101D’ small region of interest nifti, bvecs, bvals
101 directions
‘aniso_vox’ volume with anisotropic voxel size as Nifti
‘fornix’ 300 tracks in Trackvis format (from Pittsburgh Brain Competition)
‘gqi_vectors’ the scanner wave vectors needed for a GQI acquisitions of 101 directions tested on Siemens 3T Trio
‘small_25’ small ROI (10x8x2) DTI data (b value 2000, 25 directions)
‘test_piesno’ slice of N=8, K=14 diffusion data
‘reg_c’ small 2D image used for validating registration
‘reg_o’ small 2D image used for validation registration
‘cb_2’ two vectorized cingulum bundles
filenames for dataset
Examples
>>> import numpy as np
>>> from dipy.io.image import load_nifti
>>> from dipy.data import get_fnames
>>> fimg, fbvals, fbvecs = get_fnames('small_101D')
>>> bvals=np.loadtxt(fbvals)
>>> bvecs=np.loadtxt(fbvecs).T
>>> data, affine = load_nifti(fimg)
>>> data.shape == (6, 10, 10, 102)
True
>>> bvals.shape == (102,)
True
>>> bvecs.shape == (102, 3)
True
dipy.data.
get_sim_voxels
(name='fib1')provide some simulated voxel data
‘fib0’, ‘fib1’ or ‘fib2’
where every row is a simulated voxel with different orientation
Notes
These sim voxels were provided by M.M. Correia using Rician noise.
Examples
>>> from dipy.data import get_sim_voxels
>>> sv=get_sim_voxels('fib1')
>>> sv['data'].shape == (100, 102)
True
>>> sv['fibres']
'1'
>>> sv['gradients'].shape == (102, 3)
True
>>> sv['bvals'].shape == (102,)
True
>>> sv['snr']
'60'
>>> sv2=get_sim_voxels('fib2')
>>> sv2['fibres']
'2'
>>> sv2['snr']
'80'
dipy.data.
get_skeleton
(name='C1')provide skeletons generated from Local Skeleton Clustering (LSC)
Examples
>>> from dipy.data import get_skeleton
>>> C=get_skeleton('C1')
>>> len(C.keys())
117
>>> for c in C: break
>>> sorted(C[c].keys())
['N', 'hidden', 'indices', 'most']
dipy.data.
get_sphere
(name='symmetric362')provide triangulated spheres
which sphere - one of: * ‘symmetric362’ * ‘symmetric642’ * ‘symmetric724’ * ‘repulsion724’ * ‘repulsion100’ * ‘repulsion200’
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.data.
gradient_table
(bvals, bvecs=None, big_delta=None, small_delta=None, b0_threshold=50, atol=0.01, btens=None)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.
an array of shape (N,) or (1, N) or (N, 1) with the b-values.
a path for the file which contains an array like the above (1).
an array of shape (N, 4) or (4, N). Then this parameter is considered to be a b-table which contains both bvals and bvecs. In this case the next parameter is skipped.
a path for the file which contains an array like the one at (3).
an array of shape (N, 3) or (3, N) with the b-vectors.
a path for the file which contains an array like the previous.
acquisition pulse separation time in seconds (default None)
acquisition pulse duration time in seconds (default None)
All b-values with values less than or equal to bo_threshold are considered as b0s i.e. without diffusion weighting.
All b-vectors need to be unit vectors up to a tolerance.
a string specifying the shape of the encoding tensor for all volumes in data. Options: ‘LTE’, ‘PTE’, ‘STE’, ‘CTE’ corresponding to linear, planar, spherical, and “cigar-shaped” tensor encoding. Tensors are rotated so that linear and cigar tensors are aligned with the corresponding gradient direction and the planar tensor’s normal is aligned with the corresponding gradient direction. Magnitude is scaled to match the b-value.
an array of strings of shape (N,), (N, 1), or (1, N) specifying encoding tensor shape for each volume separately. N corresponds to the number volumes in data. Options for elements in array: ‘LTE’, ‘PTE’, ‘STE’, ‘CTE’ corresponding to linear, planar, spherical, and “cigar-shaped” tensor encoding. Tensors are rotated so that linear and cigar tensors are aligned with the corresponding gradient direction and the planar tensor’s normal is aligned with the corresponding gradient direction. Magnitude is scaled to match the b-value.
an array of shape (N,3,3) specifying the b-tensor of each volume exactly. N corresponds to the number volumes in data. No rotation or scaling is performed.
A GradientTable with all the gradient information.
Notes
Often b0s (b-values which correspond to images without diffusion weighting) have 0 values however in some cases the scanner cannot provide b0s of an exact 0 value and it gives a bit higher values e.g. 6 or 12. This is the purpose of the b0_threshold in the __init__.
We assume that the minimum number of b-values is 7.
B-vectors should be unit vectors.
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.data.
load_nifti
(fname, return_img=False, return_voxsize=False, return_coords=False, as_ndarray=True)Load data and other information from a nifti file.
Full path to a nifti file.
Whether to return the nibabel nifti img object. Default: False
Whether to return the nifti header zooms. Default: False
Whether to return the nifti header aff2axcodes. Default: False
convert nibabel ArrayProxy to a numpy.ndarray. If you want to save memory and delay this casting, just turn this option to False (default: True)
See also
load_nifti_data
dipy.data.
mrtrix_spherical_functions
()Spherical functions represented by spherical harmonic coefficients and evaluated on a discrete sphere.
Functions represented by the coefficients associated with the mxtrix spherical harmonic basis of order 8.
Functions evaluated on sphere.
The discrete sphere, points on the surface of a unit sphere, used to evaluate the functions.
Notes
These coefficients were obtained by using the dwi2SH command of mrtrix.
dipy.data.
read_bundles_2_subjects
(subj_id='subj_1', metrics=['fa'], bundles=['af.left', 'cst.right', 'cc_1'])Read images and streamlines from 2 subjects of the SNAIL dataset.
Either subj_1
or subj_2
.
Either [‘fa’] or [‘t1’] or [‘fa’, ‘t1’]
E.g., [‘af.left’, ‘cst.right’, ‘cc_1’]. See all the available bundles
in the exp_bundles_maps/bundles_2_subjects
directory of your
$HOME/.dipy
folder.
Dictionary with data of the metrics and the bundles as keys.
Notes
If you are using these datasets please cite the following publications.
References
Renauld, E., M. Descoteaux, M. Bernier, E. Garyfallidis,
K. Whittingstall, “Morphology of thalamus, LGN and optic radiation do not influence EEG alpha waves”, Plos One (under submission), 2015.
Garyfallidis, E., O. Ocegueda, D. Wassermann,
M. Descoteaux. Robust and efficient linear registration of fascicles in the space of streamlines , Neuroimage, 117:124-140, 2015.
dipy.data.
read_cenir_multib
(bvals=None)Read CENIR multi b-value data.
The b-values to read from file (200, 400, 1000, 2000, 3000).
Notes
Details of the acquisition and processing, and additional meta-data are available through UW researchworks:
https://digital.lib.washington.edu/researchworks/handle/1773/33311
dipy.data.
read_mni_template
(version='a', contrast='T2')Read the MNI template from disk.
There are two MNI templates 2009a and 2009c, so options available are: “a” and “c”.
Which of the contrast templates to read. For version “a” two contrasts are available: “T1” and “T2”. Similarly for version “c” there are two options, “T1” and “mask”. You can input contrast as a string or a list
order they were requested in the input.
Notes
The templates were downloaded from the MNI (McGill University) website in July 2015.
The following publications should be referenced when using these templates:
VS Fonov, AC Evans, K Botteron, CR Almli, RC McKinstry, DL Collins and BDCG, Unbiased average age-appropriate atlases for pediatric studies, NeuroImage, 54:1053-8119, DOI: 10.1016/j.neuroimage.2010.07.033
VS Fonov, AC Evans, RC McKinstry, CR Almli and DL Collins, Unbiased nonlinear average age-appropriate brain templates from birth to adulthood, NeuroImage, 47:S102 Organization for Human Brain Mapping 2009 Annual Meeting, DOI: https://doi.org/10.1016/S1053-8119(09)70884-5
License for the MNI templates:
Copyright (C) 1993-2004, Louis Collins McConnell Brain Imaging Centre, Montreal Neurological Institute, McGill University. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies. The authors and McGill University make no representations about the suitability of this software for any purpose. It is provided “as is” without express or implied warranty. The authors are not responsible for any data loss, equipment damage, property loss, or injury to subjects or patients resulting from the use or misuse of this software package.
Examples
>>> # Get only the T1 file for version c:
>>> T1 = read_mni_template("c", contrast = "T1")
>>> # Get both files in this order for version a:
>>> T1, T2 = read_mni_template(contrast = ["T1", "T2"])
FetcherError
dipy.data.fetcher.
FetcherError
Bases: Exception
Methods
|
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self. |
dipy.data.fetcher.
fetch_cenir_multib
(with_raw=False)Fetch ‘HCP-like’ data, collected at multiple b-values.
Whether to fetch the raw data. Per default, this is False, which means that only eddy-current/motion corrected data is fetched
Notes
Details of the acquisition and processing, and additional meta-data are available through UW researchworks:
https://digital.lib.washington.edu/researchworks/handle/1773/33311
dipy.data.fetcher.
fetch_data
(files, folder, data_size=None)Downloads files to folder and checks their md5 checksums
For each file in files the value should be (url, md5). The file will be downloaded from url if the file does not already exist or if the file exists but the md5 checksum does not match.
The directory where to save the file, the directory will be created if it does not already exist.
A string describing the size of the data (e.g. “91 MB”) to be logged to the screen. Default does not produce any information about data size.
Raises if the md5 checksum of the file does not match the expected value. The downloaded file is not deleted when this error is raised.
dipy.data.fetcher.
fetch_mni_template
()fetch the MNI 2009a T1 and T2, and 2009c T1 and T1 mask files Notes —– The templates were downloaded from the MNI (McGill University) website in July 2015.
The following publications should be referenced when using these templates:
VS Fonov, AC Evans, K Botteron, CR Almli, RC McKinstry, DL Collins and BDCG, Unbiased average age-appropriate atlases for pediatric studies, NeuroImage, 54:1053-8119, DOI: 10.1016/j.neuroimage.2010.07.033
VS Fonov, AC Evans, RC McKinstry, CR Almli and DL Collins, Unbiased nonlinear average age-appropriate brain templates from birth to adulthood, NeuroImage, 47:S102 Organization for Human Brain Mapping 2009 Annual Meeting, DOI: https://doi.org/10.1016/S1053-8119(09)70884-5
License for the MNI templates:
Copyright (C) 1993-2004, Louis Collins McConnell Brain Imaging Centre, Montreal Neurological Institute, McGill University. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies. The authors and McGill University make no representations about the suitability of this software for any purpose. It is provided “as is” without express or implied warranty. The authors are not responsible for any data loss, equipment damage, property loss, or injury to subjects or patients resulting from the use or misuse of this software package.
dipy.data.fetcher.
get_fnames
(name='small_64D')Provide full paths to example or test datasets.
the filename/s of which dataset to return, one of: - ‘small_64D’ small region of interest nifti,bvecs,bvals 64 directions - ‘small_101D’ small region of interest nifti, bvecs, bvals
101 directions
‘aniso_vox’ volume with anisotropic voxel size as Nifti
‘fornix’ 300 tracks in Trackvis format (from Pittsburgh Brain Competition)
‘gqi_vectors’ the scanner wave vectors needed for a GQI acquisitions of 101 directions tested on Siemens 3T Trio
‘small_25’ small ROI (10x8x2) DTI data (b value 2000, 25 directions)
‘test_piesno’ slice of N=8, K=14 diffusion data
‘reg_c’ small 2D image used for validating registration
‘reg_o’ small 2D image used for validation registration
‘cb_2’ two vectorized cingulum bundles
filenames for dataset
Examples
>>> import numpy as np
>>> from dipy.io.image import load_nifti
>>> from dipy.data import get_fnames
>>> fimg, fbvals, fbvecs = get_fnames('small_101D')
>>> bvals=np.loadtxt(fbvals)
>>> bvecs=np.loadtxt(fbvecs).T
>>> data, affine = load_nifti(fimg)
>>> data.shape == (6, 10, 10, 102)
True
>>> bvals.shape == (102,)
True
>>> bvecs.shape == (102, 3)
True
dipy.data.fetcher.
gradient_table
(bvals, bvecs=None, big_delta=None, small_delta=None, b0_threshold=50, atol=0.01, btens=None)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.
an array of shape (N,) or (1, N) or (N, 1) with the b-values.
a path for the file which contains an array like the above (1).
an array of shape (N, 4) or (4, N). Then this parameter is considered to be a b-table which contains both bvals and bvecs. In this case the next parameter is skipped.
a path for the file which contains an array like the one at (3).
an array of shape (N, 3) or (3, N) with the b-vectors.
a path for the file which contains an array like the previous.
acquisition pulse separation time in seconds (default None)
acquisition pulse duration time in seconds (default None)
All b-values with values less than or equal to bo_threshold are considered as b0s i.e. without diffusion weighting.
All b-vectors need to be unit vectors up to a tolerance.
a string specifying the shape of the encoding tensor for all volumes in data. Options: ‘LTE’, ‘PTE’, ‘STE’, ‘CTE’ corresponding to linear, planar, spherical, and “cigar-shaped” tensor encoding. Tensors are rotated so that linear and cigar tensors are aligned with the corresponding gradient direction and the planar tensor’s normal is aligned with the corresponding gradient direction. Magnitude is scaled to match the b-value.
an array of strings of shape (N,), (N, 1), or (1, N) specifying encoding tensor shape for each volume separately. N corresponds to the number volumes in data. Options for elements in array: ‘LTE’, ‘PTE’, ‘STE’, ‘CTE’ corresponding to linear, planar, spherical, and “cigar-shaped” tensor encoding. Tensors are rotated so that linear and cigar tensors are aligned with the corresponding gradient direction and the planar tensor’s normal is aligned with the corresponding gradient direction. Magnitude is scaled to match the b-value.
an array of shape (N,3,3) specifying the b-tensor of each volume exactly. N corresponds to the number volumes in data. No rotation or scaling is performed.
A GradientTable with all the gradient information.
Notes
Often b0s (b-values which correspond to images without diffusion weighting) have 0 values however in some cases the scanner cannot provide b0s of an exact 0 value and it gives a bit higher values e.g. 6 or 12. This is the purpose of the b0_threshold in the __init__.
We assume that the minimum number of b-values is 7.
B-vectors should be unit vectors.
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.data.fetcher.
gradient_table_from_gradient_strength_bvecs
(gradient_strength, bvecs, big_delta, small_delta, 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.
gradient strength given in T/mm
an array of shape (N, 3) or (3, N) with the b-vectors.
a path for the file which contains an array like the previous.
acquisition pulse separation time in seconds
acquisition pulse duration time in seconds
All b-values with values less than or equal to bo_threshold are considered as b0s i.e. without diffusion weighting.
All b-vectors need to be unit vectors up to a tolerance.
A GradientTable with all the gradient information.
Notes
Often b0s (b-values which correspond to images without diffusion weighting) have 0 values however in some cases the scanner cannot provide b0s of an exact 0 value and it gives a bit higher values e.g. 6 or 12. This is the purpose of the b0_threshold in the __init__.
We assume that the minimum number of b-values is 7.
B-vectors should be unit vectors.
Examples
>>> from dipy.core.gradients import (
... gradient_table_from_gradient_strength_bvecs)
>>> gradient_strength = .03e-3 * np.ones(7) # clinical strength at 30 mT/m
>>> big_delta = .03 # pulse separation of 30ms
>>> small_delta = 0.01 # pulse duration of 10ms
>>> gradient_strength[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_from_gradient_strength_bvecs(
... gradient_strength, bvecs, big_delta, small_delta)
dipy.data.fetcher.
load_nifti
(fname, return_img=False, return_voxsize=False, return_coords=False, as_ndarray=True)Load data and other information from a nifti file.
Full path to a nifti file.
Whether to return the nibabel nifti img object. Default: False
Whether to return the nifti header zooms. Default: False
Whether to return the nifti header aff2axcodes. Default: False
convert nibabel ArrayProxy to a numpy.ndarray. If you want to save memory and delay this casting, just turn this option to False (default: True)
See also
dipy.data.fetcher.
load_nifti_data
(fname, as_ndarray=True)Load only the data array from a nifti file.
Full path to the file.
convert nibabel ArrayProxy to a numpy.ndarray. If you want to save memory and delay this casting, just turn this option to False (default: True)
See also
dipy.data.fetcher.
read_bundles_2_subjects
(subj_id='subj_1', metrics=['fa'], bundles=['af.left', 'cst.right', 'cc_1'])Read images and streamlines from 2 subjects of the SNAIL dataset.
Either subj_1
or subj_2
.
Either [‘fa’] or [‘t1’] or [‘fa’, ‘t1’]
E.g., [‘af.left’, ‘cst.right’, ‘cc_1’]. See all the available bundles
in the exp_bundles_maps/bundles_2_subjects
directory of your
$HOME/.dipy
folder.
Dictionary with data of the metrics and the bundles as keys.
Notes
If you are using these datasets please cite the following publications.
References
Renauld, E., M. Descoteaux, M. Bernier, E. Garyfallidis,
K. Whittingstall, “Morphology of thalamus, LGN and optic radiation do not influence EEG alpha waves”, Plos One (under submission), 2015.
Garyfallidis, E., O. Ocegueda, D. Wassermann,
M. Descoteaux. Robust and efficient linear registration of fascicles in the space of streamlines , Neuroimage, 117:124-140, 2015.
dipy.data.fetcher.
read_bvals_bvecs
(fbvals, fbvecs)Read b-values and b-vectors from disk.
Full path to file with b-values. None to not read bvals.
Full path of file with b-vectors. None to not read bvecs.
Notes
Files can be either ‘.bvals’/’.bvecs’ or ‘.txt’ or ‘.npy’ (containing arrays stored with the appropriate values).
dipy.data.fetcher.
read_cenir_multib
(bvals=None)Read CENIR multi b-value data.
The b-values to read from file (200, 400, 1000, 2000, 3000).
Notes
Details of the acquisition and processing, and additional meta-data are available through UW researchworks:
https://digital.lib.washington.edu/researchworks/handle/1773/33311
dipy.data.fetcher.
read_mni_template
(version='a', contrast='T2')Read the MNI template from disk.
There are two MNI templates 2009a and 2009c, so options available are: “a” and “c”.
Which of the contrast templates to read. For version “a” two contrasts are available: “T1” and “T2”. Similarly for version “c” there are two options, “T1” and “mask”. You can input contrast as a string or a list
order they were requested in the input.
Notes
The templates were downloaded from the MNI (McGill University) website in July 2015.
The following publications should be referenced when using these templates:
VS Fonov, AC Evans, K Botteron, CR Almli, RC McKinstry, DL Collins and BDCG, Unbiased average age-appropriate atlases for pediatric studies, NeuroImage, 54:1053-8119, DOI: 10.1016/j.neuroimage.2010.07.033
VS Fonov, AC Evans, RC McKinstry, CR Almli and DL Collins, Unbiased nonlinear average age-appropriate brain templates from birth to adulthood, NeuroImage, 47:S102 Organization for Human Brain Mapping 2009 Annual Meeting, DOI: https://doi.org/10.1016/S1053-8119(09)70884-5
License for the MNI templates:
Copyright (C) 1993-2004, Louis Collins McConnell Brain Imaging Centre, Montreal Neurological Institute, McGill University. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies. The authors and McGill University make no representations about the suitability of this software for any purpose. It is provided “as is” without express or implied warranty. The authors are not responsible for any data loss, equipment damage, property loss, or injury to subjects or patients resulting from the use or misuse of this software package.
Examples
>>> # Get only the T1 file for version c:
>>> T1 = read_mni_template("c", contrast = "T1")
>>> # Get both files in this order for version a:
>>> T1, T2 = read_mni_template(contrast = ["T1", "T2"])
dipy.data.fetcher.
read_qtdMRI_test_retest_2subjects
()Load test-retest qt-dMRI acquisitions of two C57Bl6 mice. These datasets were used to study test-retest reproducibility of time-dependent q-space indices (q:math:` au`-indices) in the corpus callosum of two mice [1]. The data itself and its details are publicly available and can be cited at [2].
The test-retest diffusion MRI spin echo sequences were acquired from two C57Bl6 wild-type mice on an 11.7 Tesla Bruker scanner. The test and retest acquisition were taken 48 hours from each other. The (processed) data consists of 80x160x5 voxels of size 110x110x500μm. Each data set consists of 515 Diffusion-Weighted Images (DWIs) spread over 35 acquisition shells. The shells are spread over 7 gradient strength shells with a maximum gradient strength of 491 mT/m, 5 pulse separation shells between [10.8 - 20.0]ms, and a pulse length of 5ms. We manually created a brain mask and corrected the data from eddy currents and motion artifacts using FSL’s eddy. A region of interest was then drawn in the middle slice in the corpus callosum, where the tissue is reasonably coherent.
contains the dwi datasets ordered as (subject1_test, subject1_retest, subject2_test, subject2_retest)
contains the corpus callosum masks ordered in the same order as data.
contains the qt-dMRI gradient tables of the data sets.
References
Fick, Rutger HJ, et al. “Non-Parametric GraphNet-Regularized Representation of dMRI in Space and Time”, Medical Image Analysis, 2017.
Wassermann, Demian, et al., “Test-Retest qt-dMRI datasets for `Non-Parametric GraphNet-Regularized Representation of dMRI in Space and Time’”. doi:10.5281/zenodo.996889, 2017.
dipy.data.fetcher.
urlopen
(url, data=None, timeout=<object object>, *, cafile=None, capath=None, cadefault=False, context=None)Open the URL url, which can be either a string or a Request object.
data must be an object specifying additional data to be sent to the server, or None if no such data is needed. See Request for details.
urllib.request module uses HTTP/1.1 and includes a “Connection:close” header in its HTTP requests.
The optional timeout parameter specifies a timeout in seconds for blocking operations like the connection attempt (if not specified, the global default timeout setting will be used). This only works for HTTP, HTTPS and FTP connections.
If context is specified, it must be a ssl.SSLContext instance describing the various SSL options. See HTTPSConnection for more details.
The optional cafile and capath parameters specify a set of trusted CA certificates for HTTPS requests. cafile should point to a single file containing a bundle of CA certificates, whereas capath should point to a directory of hashed certificate files. More information can be found in ssl.SSLContext.load_verify_locations().
The cadefault parameter is ignored.
This function always returns an object which can work as a context manager and has methods such as
geturl() - return the URL of the resource retrieved, commonly used to determine if a redirect was followed
info() - return the meta-information of the page, such as headers, in the form of an email.message_from_string() instance (see Quick Reference to HTTP Headers)
getcode() - return the HTTP status code of the response. Raises URLError on errors.
For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse object slightly modified. In addition to the three new methods above, the msg attribute contains the same information as the reason attribute — the reason phrase returned by the server — instead of the response headers as it is specified in the documentation for HTTPResponse.
For FTP, file, and data URLs and requests explicitly handled by legacy URLopener and FancyURLopener classes, this function returns a urllib.response.addinfourl object.
Note that None may be returned if no handler handles the request (though the default installed global OpenerDirector uses UnknownHandler to ensure this never happens).
In addition, if proxy settings are detected (for example, when a *_proxy environment variable like http_proxy is set), ProxyHandler is default installed and makes sure the requests are handled through the proxy.