io
io.bvectxt
io.dpy
io.gradients
io.image
io.peaks
io.pickles
io.streamline
io.trackvis
io.utils
io.vtk
Dpy
Dpy
Streamlines
InTemporaryDirectory
PeaksAndMetrics
Sphere
Dpy
Field
LazyTractogram
Streamlines
TckFile
Tractogram
TrkFile
partial
Nifti1Image
io
Dpy (fname[, mode, compression]) |
Methods |
load_pickle (fname) |
Load object from pickle file fname |
orientation_from_string (string_ornt) |
Returns an array representation of an ornt string |
orientation_to_string (ornt) |
Returns a string representation of a 3d ornt |
ornt_mapping (ornt1, ornt2) |
Calculates the mapping needing to get from orn1 to orn2 |
read_bvals_bvecs (fbvals, fbvecs) |
Read b-values and b-vectors from disk |
read_bvec_file (filename[, atol]) |
Read gradient table information from a pair of files with extentions .bvec and .bval. |
reorient_on_axis (input, current_ornt, new_ornt) |
|
reorient_vectors (input, current_ornt, new_ornt) |
Changes the orientation of a gradients or other vectors |
save_pickle (fname, dix) |
Save dix to fname as pickle |
io.bvectxt
orientation_from_string (string_ornt) |
Returns an array representation of an ornt string |
orientation_to_string (ornt) |
Returns a string representation of a 3d ornt |
ornt_mapping (ornt1, ornt2) |
Calculates the mapping needing to get from orn1 to orn2 |
read_bvec_file (filename[, atol]) |
Read gradient table information from a pair of files with extentions .bvec and .bval. |
reorient_on_axis (input, current_ornt, new_ornt) |
|
reorient_vectors (input, current_ornt, new_ornt) |
Changes the orientation of a gradients or other vectors |
splitext (p) |
Split the extension from a pathname. |
io.dpy
A class for handling large tractography datasets.
It is built using the h5py which in turn implement key features of the HDF5 (hierachical data format) API [R223c5a1ac171-1].
Dpy (fname[, mode, compression]) |
Methods |
Streamlines |
alias of nibabel.streamlines.array_sequence.ArraySequence |
io.gradients
InTemporaryDirectory ([suffix, prefix, dir]) |
Create, return, and change directory to a temporary directory |
read_bvals_bvecs (fbvals, fbvecs) |
Read b-values and b-vectors from disk |
splitext (p) |
Split the extension from a pathname. |
io.image
load_nifti (fname[, return_img, …]) |
|
save_nifti (fname, data, affine[, hdr]) |
|
save_qa_metric (fname, xopt, fopt) |
Save Quality Assurance metrics. |
io.peaks
PeaksAndMetrics |
|
||
Sphere ([x, y, z, theta, phi, xyz, faces, edges]) |
Points on the unit sphere. | ||
load_peaks (fname[, verbose]) |
Load a PeaksAndMetrics HDF5 file (PAM5) | ||
peaks_to_niftis (pam, fname_shm, fname_dirs, …) |
Save SH, directions, indices and values of peaks to Nifti. | ||
reshape_peaks_for_visualization (peaks) |
Reshape peaks for visualization. | ||
save_nifti (fname, data, affine[, hdr]) |
|||
save_peaks (fname, pam[, affine, verbose]) |
Save all important attributes of object PeaksAndMetrics in a PAM5 file (HDF5). |
io.pickles
Load and save pickles
load_pickle (fname) |
Load object from pickle file fname |
save_pickle (fname, dix) |
Save dix to fname as pickle |
io.streamline
Dpy (fname[, mode, compression]) |
Methods |
Field |
Header fields common to multiple streamline file formats. |
LazyTractogram ([streamlines, …]) |
Lazy container for streamlines and their data information. |
Streamlines |
alias of nibabel.streamlines.array_sequence.ArraySequence |
TckFile (tractogram[, header]) |
Convenience class to encapsulate TCK file format. |
Tractogram ([streamlines, …]) |
Container for streamlines and their data information. |
TrkFile (tractogram[, header]) |
Convenience class to encapsulate TRK file format. |
partial |
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords. |
aff2axcodes (aff[, labels, tol]) |
axis direction codes for affine aff |
detect_format (fileobj) |
Returns the StreamlinesFile object guessed from the file-like object. |
load_dpy (filename[, lazy_load]) |
Loads tractogram files (*.tck) |
load_tck (filename[, lazy_load]) |
Loads tractogram files (*.tck) |
load_tractogram (filename[, lazy_load]) |
Loads tractogram files (*.tck) |
load_trk (filename[, lazy_load]) |
Loads tractogram files (*.tck) |
save_tractogram (fname, streamlines, affine) |
Saves tractogram files (*.trk or *.tck or *.dpy) |
io.trackvis
save_trk (filename, points, vox_to_ras, shape) |
A temporary helper function for saving trk files. |
io.utils
Utility functions for file formats
Nifti1Image (dataobj, affine[, header, …]) |
Class for single file NIfTI1 format image |
decfa (img_orig[, scale]) |
Create a nifti-compliant directional-encoded color FA file. |
make5d (input) |
reshapes the input to have 5 dimensions, adds extra dimensions just before the last dimession |
nifti1_symmat (image_data, *args, **kwargs) |
Returns a Nifti1Image with a symmetric matrix intent |
io.vtk
load_polydata (file_name) |
Load a vtk polydata to a supported format file. |
optional_package (name[, trip_msg]) |
Return package-like thing and module setup for package name |
save_polydata (polydata, file_name[, binary, …]) |
Save a vtk polydata to a supported format file. |
setup_module () |
Dpy
dipy.io.
Dpy
(fname, mode='r', compression=0)Bases: object
Methods
read_track () |
read one track each time |
read_tracks () |
read the entire tractography |
read_tracksi (indices) |
read tracks with specific indices |
write_track (track) |
write on track each time |
write_tracks (tracks) |
write many tracks together |
close | |
version |
__init__
(fname, mode='r', compression=0)Advanced storage system for tractography based on HDF5
Parameters: |
|
---|
Examples
>>> import os
>>> from tempfile import mkstemp #temp file
>>> from dipy.io.dpy import Dpy
>>> def dpy_example():
... fd,fname = mkstemp()
... fname += '.dpy'#add correct extension
... dpw = Dpy(fname,'w')
... A=np.ones((5,3))
... B=2*A.copy()
... C=3*A.copy()
... dpw.write_track(A)
... dpw.write_track(B)
... dpw.write_track(C)
... dpw.close()
... dpr = Dpy(fname,'r')
... dpr.read_track()
... dpr.read_track()
... dpr.read_tracksi([0, 1, 2, 0, 0, 2])
... dpr.close()
... os.remove(fname) #delete file from disk
>>> dpy_example()
dipy.io.
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.io.
read_bvec_file
(filename, atol=0.001)Read gradient table information from a pair of files with extentions .bvec and .bval. The bval file should have one row of values representing the bvalues of each volume in the dwi data set. The bvec file should have three rows, where the rows are the x, y, and z components of the normalized gradient direction for each of the volumes.
Parameters: |
|
---|
dipy.io.
reorient_vectors
(input, current_ornt, new_ornt, axis=0)Changes the orientation of a gradients or other vectors
Moves vectors, storted along axis, from current_ornt to new_ornt. For example the vector [x, y, z] in “RAS” will be [-x, -y, z] in “LPS”.
R: Right A: Anterior S: Superior L: Left P: Posterior I: Inferior
Examples
>>> gtab = np.array([[1, 1, 1], [1, 2, 3]])
>>> reorient_vectors(gtab, 'ras', 'asr', axis=1)
array([[1, 1, 1],
[2, 3, 1]])
>>> reorient_vectors(gtab, 'ras', 'lps', axis=1)
array([[-1, -1, 1],
[-1, -2, 3]])
>>> bvec = gtab.T
>>> reorient_vectors(bvec, 'ras', 'lps', axis=0)
array([[-1, -1],
[-1, -2],
[ 1, 3]])
>>> reorient_vectors(bvec, 'ras', 'lsp')
array([[-1, -1],
[ 1, 3],
[-1, -2]])
dipy.io.
save_pickle
(fname, dix)Save dix to fname as pickle
Parameters: |
|
---|
See also
Examples
>>> import os
>>> from tempfile import mkstemp
>>> fd, fname = mkstemp() # make temporary file (opened, attached to fh)
>>> d={0:{'d':1}}
>>> save_pickle(fname, d)
>>> d2=load_pickle(fname)
We remove the temporary file we created for neatness
>>> os.close(fd) # the file is still open, we need to close the fh
>>> os.remove(fname)
dipy.io.bvectxt.
read_bvec_file
(filename, atol=0.001)Read gradient table information from a pair of files with extentions .bvec and .bval. The bval file should have one row of values representing the bvalues of each volume in the dwi data set. The bvec file should have three rows, where the rows are the x, y, and z components of the normalized gradient direction for each of the volumes.
Parameters: |
|
---|
dipy.io.bvectxt.
reorient_vectors
(input, current_ornt, new_ornt, axis=0)Changes the orientation of a gradients or other vectors
Moves vectors, storted along axis, from current_ornt to new_ornt. For example the vector [x, y, z] in “RAS” will be [-x, -y, z] in “LPS”.
R: Right A: Anterior S: Superior L: Left P: Posterior I: Inferior
Examples
>>> gtab = np.array([[1, 1, 1], [1, 2, 3]])
>>> reorient_vectors(gtab, 'ras', 'asr', axis=1)
array([[1, 1, 1],
[2, 3, 1]])
>>> reorient_vectors(gtab, 'ras', 'lps', axis=1)
array([[-1, -1, 1],
[-1, -2, 3]])
>>> bvec = gtab.T
>>> reorient_vectors(bvec, 'ras', 'lps', axis=0)
array([[-1, -1],
[-1, -2],
[ 1, 3]])
>>> reorient_vectors(bvec, 'ras', 'lsp')
array([[-1, -1],
[ 1, 3],
[-1, -2]])
Dpy
dipy.io.dpy.
Dpy
(fname, mode='r', compression=0)Bases: object
Methods
read_track () |
read one track each time |
read_tracks () |
read the entire tractography |
read_tracksi (indices) |
read tracks with specific indices |
write_track (track) |
write on track each time |
write_tracks (tracks) |
write many tracks together |
close | |
version |
__init__
(fname, mode='r', compression=0)Advanced storage system for tractography based on HDF5
Parameters: |
|
---|
Examples
>>> import os
>>> from tempfile import mkstemp #temp file
>>> from dipy.io.dpy import Dpy
>>> def dpy_example():
... fd,fname = mkstemp()
... fname += '.dpy'#add correct extension
... dpw = Dpy(fname,'w')
... A=np.ones((5,3))
... B=2*A.copy()
... C=3*A.copy()
... dpw.write_track(A)
... dpw.write_track(B)
... dpw.write_track(C)
... dpw.close()
... dpr = Dpy(fname,'r')
... dpr.read_track()
... dpr.read_track()
... dpr.read_tracksi([0, 1, 2, 0, 0, 2])
... dpr.close()
... os.remove(fname) #delete file from disk
>>> dpy_example()
InTemporaryDirectory
dipy.io.gradients.
InTemporaryDirectory
(suffix='', prefix='tmp', dir=None)Bases: nibabel.tmpdirs.TemporaryDirectory
Create, return, and change directory to a temporary directory
Examples
>>> import os
>>> my_cwd = os.getcwd()
>>> with InTemporaryDirectory() as tmpdir:
... _ = open('test.txt', 'wt').write('some text')
... assert os.path.isfile('test.txt')
... assert os.path.isfile(os.path.join(tmpdir, 'test.txt'))
>>> os.path.exists(tmpdir)
False
>>> os.getcwd() == my_cwd
True
Methods
cleanup |
dipy.io.gradients.
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).
PeaksAndMetrics
Sphere
dipy.io.peaks.
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)
Parameters: |
|
---|---|
Attributes: |
|
Methods
find_closest (xyz) |
Find the index of the vertex in the Sphere closest to the input vector |
subdivide ([n]) |
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
Parameters: |
|
---|
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/____
/\ / / \ / /____\/____ x c z
Parameters: |
|
---|---|
Returns: |
|
dipy.io.peaks.
save_peaks
(fname, pam, affine=None, verbose=False)Save all important attributes of object PeaksAndMetrics in a PAM5 file (HDF5).
Parameters: |
|
---|
dipy.io.pickles.
save_pickle
(fname, dix)Save dix to fname as pickle
Parameters: |
|
---|
See also
Examples
>>> import os
>>> from tempfile import mkstemp
>>> fd, fname = mkstemp() # make temporary file (opened, attached to fh)
>>> d={0:{'d':1}}
>>> save_pickle(fname, d)
>>> d2=load_pickle(fname)
We remove the temporary file we created for neatness
>>> os.close(fd) # the file is still open, we need to close the fh
>>> os.remove(fname)
Dpy
dipy.io.streamline.
Dpy
(fname, mode='r', compression=0)Bases: object
Methods
read_track () |
read one track each time |
read_tracks () |
read the entire tractography |
read_tracksi (indices) |
read tracks with specific indices |
write_track (track) |
write on track each time |
write_tracks (tracks) |
write many tracks together |
close | |
version |
__init__
(fname, mode='r', compression=0)Advanced storage system for tractography based on HDF5
Parameters: |
|
---|
Examples
>>> import os
>>> from tempfile import mkstemp #temp file
>>> from dipy.io.dpy import Dpy
>>> def dpy_example():
... fd,fname = mkstemp()
... fname += '.dpy'#add correct extension
... dpw = Dpy(fname,'w')
... A=np.ones((5,3))
... B=2*A.copy()
... C=3*A.copy()
... dpw.write_track(A)
... dpw.write_track(B)
... dpw.write_track(C)
... dpw.close()
... dpr = Dpy(fname,'r')
... dpr.read_track()
... dpr.read_track()
... dpr.read_tracksi([0, 1, 2, 0, 0, 2])
... dpr.close()
... os.remove(fname) #delete file from disk
>>> dpy_example()
Field
dipy.io.streamline.
Field
Bases: object
Header fields common to multiple streamline file formats.
In IPython, use nibabel.streamlines.Field?? to list them.
LazyTractogram
dipy.io.streamline.
LazyTractogram
(streamlines=None, data_per_streamline=None, data_per_point=None, affine_to_rasmm=None)Bases: nibabel.streamlines.tractogram.Tractogram
Lazy container for streamlines and their data information.
This container behaves lazily as it uses generator functions to manage streamlines and their data information. This container is thus memory friendly since it doesn’t require having all this data loaded in memory.
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.
Notes
LazyTractogram objects do not support indexing currently. LazyTractogram objects are suited for operations that can be linearized such as applying an affine transformation or converting streamlines from one file format to another.
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 to the streamlines. |
copy () |
Returns a copy of this LazyTractogram object. |
extend (other) |
Appends the data of another Tractogram . |
from_data_func (data_func) |
Creates an instance from a generator function. |
from_tractogram (tractogram) |
Creates a LazyTractogram object from a Tractogram object. |
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=True)Applies an affine transformation to the streamlines.
The transformation given by the affine matrix is applied after any other pending transformations to the streamline points.
Parameters: |
|
---|---|
Returns: |
|
copy
()Returns a copy of this LazyTractogram
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.
from_data_func
(data_func)Creates an instance from a generator function.
The generator function must yield TractogramItem
objects.
Parameters: |
|
---|---|
Returns: |
|
from_tractogram
(tractogram)Creates a LazyTractogram
object from a Tractogram
object.
Parameters: |
|
---|---|
Returns: |
|
to_world
(lazy=True)Brings the streamlines to world space (i.e. RAS+ and mm).
The transformation is applied after any other pending transformations to the streamline points.
Parameters: |
|
---|---|
Returns: |
|
TckFile
dipy.io.streamline.
TckFile
(tractogram, header=None)Bases: nibabel.streamlines.tractogram_file.TractogramFile
Convenience class to encapsulate TCK file format.
Notes
MRtrix (so its file format: TCK) considers streamlines coordinates to be in world space (RAS+ and mm space). MRtrix refers to that space as the “real” or “scanner” 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 TRK’s internal convention where it would have referred to a corner.
NiBabel’s streamlines internal representation follows the same convention as MRtrix.
References
[1] http://www.nitrc.org/pipermail/mrtrix-discussion/2014-January/000859.html [2] http://nipy.org/nibabel/coordinate_systems.html#voxel-coordinates-are-in-voxel-space
Attributes: |
|
---|
Methods
create_empty_header () |
Return an empty compliant TCK header as dict |
is_correct_format (fileobj) |
Check if the file is in TCK format. |
load (fileobj[, lazy_load]) |
Loads streamlines from a filename or file-like object. |
save (fileobj) |
Save tractogram to a filename or file-like object using TCK format. |
__init__
(tractogram, header=None)Parameters: |
|
---|
Notes
Streamlines of the tractogram are assumed to be in RAS+ and mm space. It is also assumed that when streamlines are mapped back to voxel space, 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 TRK’s internal convention where it would have referred to a corner.
is_correct_format
(fileobj)Check if the file is in TCK format.
Parameters: |
|
---|---|
Returns: |
|
load
(fileobj, lazy_load=False)Loads streamlines from a filename or file-like object.
Parameters: |
|
---|---|
Returns: |
|
Notes
Streamlines of the tractogram are assumed to be in RAS+ and mm space. It is also assumed that when streamlines are mapped back to voxel space, 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 TRK’s internal convention where it would have referred to a corner.
Tractogram
dipy.io.streamline.
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: |
|
TrkFile
dipy.io.streamline.
TrkFile
(tractogram, header=None)Bases: nibabel.streamlines.tractogram_file.TractogramFile
Convenience class to encapsulate TRK file format.
Notes
TrackVis (so its file format: TRK) considers the streamline coordinate (0,0,0) to be in the corner of the voxel whereas NiBabel’s streamlines internal representation (Voxel space) assumes (0,0,0) to be in the center of the voxel.
Thus, streamlines are shifted by half a voxel on load and are shifted back on save.
Attributes: |
|
---|
Methods
create_empty_header () |
Return an empty compliant TRK header as dict |
is_correct_format (fileobj) |
Check if the file is in TRK format. |
load (fileobj[, lazy_load]) |
Loads streamlines from a filename or file-like object. |
save (fileobj) |
Save tractogram to a filename or file-like object using TRK format. |
__init__
(tractogram, header=None)Parameters: |
|
---|
Notes
Streamlines of the tractogram are assumed to be in RAS+ and mm space where coordinate (0,0,0) refers to the center of the voxel.
is_correct_format
(fileobj)Check if the file is in TRK format.
Parameters: |
|
---|---|
Returns: |
|
load
(fileobj, lazy_load=False)Loads streamlines from a filename or file-like object.
Parameters: |
|
---|---|
Returns: |
|
Notes
Streamlines of the returned tractogram are assumed to be in RAS and mm space where coordinate (0,0,0) refers to the center of the voxel.
partial
dipy.io.streamline.
partial
Bases: object
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
Attributes: |
|
---|
Methods
__call__ ($self, /, *args, **kwargs) |
Call self as a function. |
dipy.io.streamline.
aff2axcodes
(aff, labels=None, tol=None)axis direction codes for affine aff
Parameters: |
|
---|---|
Returns: |
|
Examples
>>> aff = [[0,1,0,10],[-1,0,0,20],[0,0,1,30],[0,0,0,1]]
>>> aff2axcodes(aff, (('L','R'),('B','F'),('D','U')))
('B', 'R', 'U')
dipy.io.streamline.
detect_format
(fileobj)Returns the StreamlinesFile object guessed from the file-like object.
Parameters: |
|
---|---|
Returns: |
|
dipy.io.streamline.
load_dpy
(filename, lazy_load=False)Loads tractogram files (*.tck)
Parameters: |
|
---|---|
Returns: |
|
dipy.io.streamline.
load_tck
(filename, lazy_load=False)Loads tractogram files (*.tck)
Parameters: |
|
---|---|
Returns: |
|
dipy.io.streamline.
load_tractogram
(filename, lazy_load=False)Loads tractogram files (*.tck)
Parameters: |
|
---|---|
Returns: |
|
dipy.io.streamline.
load_trk
(filename, lazy_load=False)Loads tractogram files (*.tck)
Parameters: |
|
---|---|
Returns: |
|
dipy.io.streamline.
save_tractogram
(fname, streamlines, affine, vox_size=None, shape=None, header=None, reduce_memory_usage=False, tractogram_file=None)Saves tractogram files (*.trk or *.tck or *.dpy)
Parameters: |
|
---|
Nifti1Image
dipy.io.utils.
Nifti1Image
(dataobj, affine, header=None, extra=None, file_map=None)Bases: nibabel.nifti1.Nifti1Pair
Class for single file NIfTI1 format image
Attributes: |
|
---|
Methods
ImageArrayProxy |
alias of nibabel.arrayproxy.ArrayProxy |
ImageSlicer |
alias of nibabel.spatialimages.SpatialFirstSlicer |
as_reoriented (ornt) |
Apply an orientation change and return a new image |
filespec_to_file_map (filespec) |
Make file_map for this class from filename filespec |
filespec_to_files (filespec) |
filespec_to_files class method is deprecated. |
from_file_map (file_map[, mmap, keep_file_open]) |
class method to create image from mapping in file_map ` |
from_filename (filename[, mmap, keep_file_open]) |
class method to create image from filename filename |
from_files (file_map) |
from_files class method is deprecated. |
from_image (img) |
Class method to create new instance of own class from img |
get_affine () |
Get affine from image |
get_data ([caching]) |
Return image data from image with any necessary scaling applied |
get_fdata ([caching, dtype]) |
Return floating point image data with necessary scaling applied |
get_filename () |
Fetch the image filename |
get_header () |
Get header from image |
get_qform ([coded]) |
Return 4x4 affine matrix from qform parameters in header |
get_sform ([coded]) |
Return 4x4 affine matrix from sform parameters in header |
get_shape () |
Return shape for image |
header_class |
alias of Nifti1Header |
instance_to_filename (img, filename) |
Save img in our own format, to name implied by filename |
load (filename[, mmap, keep_file_open]) |
class method to create image from filename filename |
make_file_map ([mapping]) |
Class method to make files holder for this image type |
orthoview () |
Plot the image using OrthoSlicer3D |
path_maybe_image (filename[, sniff, sniff_max]) |
Return True if filename may be image matching this class |
set_filename (filename) |
Sets the files in the object from a given filename |
set_qform (affine[, code, strip_shears]) |
Set qform header values from 4x4 affine |
set_sform (affine[, code]) |
Set sform transform from 4x4 affine |
to_file_map ([file_map]) |
Write image to file_map or contained self.file_map |
to_filename (filename) |
Write image to files implied by filename string |
to_files ([file_map]) |
to_files method is deprecated. |
to_filespec (filename) |
to_filespec method is deprecated. |
uncache () |
Delete any cached read of data from proxied data |
update_header () |
Harmonize header with image data and affine |
get_data_dtype | |
set_data_dtype |
__init__
(dataobj, affine, header=None, extra=None, file_map=None)Initialize image
The image is a combination of (array-like, affine matrix, header), with optional metadata in extra, and filename / file-like objects contained in the file_map mapping.
Parameters: |
|
---|
Notes
If both a header and an affine are specified, and the affine does
not match the affine that is in the header, the affine will be used,
but the sform_code
and qform_code
fields in the header will be
re-initialised to their default values. This is performed on the basis
that, if you are changing the affine, you are likely to be changing the
space to which the affine is pointing. The set_sform()
and
set_qform()
methods can be used to update the codes after an image
has been created - see those methods, and the manual for more details.
dipy.io.utils.
decfa
(img_orig, scale=False)Create a nifti-compliant directional-encoded color FA file.
Parameters: |
|
---|---|
Returns: |
|
Notes
For a description of this format, see:
https://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields/nifti1fields_pages/datatype.html
dipy.io.vtk.
optional_package
(name, trip_msg=None)Return package-like thing and module setup for package name
Parameters: |
|
---|---|
Returns: |
|