digraph inheritance5815df6a85 { rankdir=LR; ratio=compress; fontsize=14; size="6.0, 8.0"; "Nifti1Pair" [shape=ellipse,URL="#nibabel.nifti1.Nifti1Pair",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "AnalyzeImage" -> "Nifti1Pair" [arrowsize=0.5,style="setlinewidth(0.5)"]; "AnalyzeImage" [shape=ellipse,URL="nibabel.analyze.AnalyzeImage.html#nibabel.analyze.AnalyzeImage",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; "SpatialImage" -> "AnalyzeImage" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SpatialImage" [shape=ellipse,URL="nibabel.spatialimages.SpatialImage.html#nibabel.spatialimages.SpatialImage",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; }
Initialize image
The image is a combination of (array, affine matrix, header), with optional metadata in extra, and filename / file-like objects contained in the file_map mapping.
Parameters : | data : object
affine : None or (4,4) array-like
header : None or mapping or header instance, optional
extra : None or mapping, optional
file_map : mapping, optional
|
---|
Return 4x4 affine matrix from qform parameters in header
Parameters : | coded : bool, optional
|
---|---|
Returns : | affine : None or (4,4) ndarray
code : int
|
See also
Return 4x4 affine matrix from sform parameters in header
Parameters : | coded : bool, optional
|
---|---|
Returns : | affine : None or (4,4) ndarray
code : int
|
See also
alias of Nifti1PairHeader
Set qform header values from 4x4 affine
Parameters : | hdr : nifti1 header affine : None or 4x4 array
code : None, string or integer
strip_shears : bool, optional
update_affine : bool, optional
|
---|
See also
Examples
>>> data = np.arange(24).reshape((2,3,4))
>>> aff = np.diag([2, 3, 4, 1])
>>> img = Nifti1Pair(data, aff)
>>> img.get_qform()
array([[ 2., 0., 0., 0.],
[ 0., 3., 0., 0.],
[ 0., 0., 4., 0.],
[ 0., 0., 0., 1.]])
>>> img.get_qform(coded=True)
(None, 0)
>>> aff2 = np.diag([3, 4, 5, 1])
>>> img.set_qform(aff2, 'talairach')
>>> qaff, code = img.get_qform(coded=True)
>>> np.all(qaff == aff2)
True
>>> int(code)
3
Set sform transform from 4x4 affine
Parameters : | hdr : nifti1 header affine : None or 4x4 array
code : None, string or integer
update_affine : bool, optional
|
---|
See also
Examples
>>> data = np.arange(24).reshape((2,3,4))
>>> aff = np.diag([2, 3, 4, 1])
>>> img = Nifti1Pair(data, aff)
>>> img.get_sform()
array([[ 2., 0., 0., 0.],
[ 0., 3., 0., 0.],
[ 0., 0., 4., 0.],
[ 0., 0., 0., 1.]])
>>> saff, code = img.get_sform(coded=True)
>>> saff
array([[ 2., 0., 0., 0.],
[ 0., 3., 0., 0.],
[ 0., 0., 4., 0.],
[ 0., 0., 0., 1.]])
>>> int(code)
2
>>> aff2 = np.diag([3, 4, 5, 1])
>>> img.set_sform(aff2, 'talairach')
>>> saff, code = img.get_sform(coded=True)
>>> np.all(saff == aff2)
True
>>> int(code)
3
Harmonize header with image data and affine
See AnalyzeImage.update_header for more examples
Examples
>>> data = np.zeros((2,3,4))
>>> affine = np.diag([1.0,2.0,3.0,1.0])
>>> img = Nifti1Image(data, affine)
>>> hdr = img.get_header()
>>> np.all(hdr.get_qform() == affine)
True
>>> np.all(hdr.get_sform() == affine)
True