public class MetaImageHeader extends ImageHeader
Compressed data is read as a ZIP archive, assumed to contain one entry. This feature is untested, so use with caution.
Modifier and Type | Class and Description |
---|---|
static class |
MetaImageHeader.AnatomicalOrientation
Supported anatomical orientations [L|R] [A|P] [I|S].
|
static class |
MetaImageHeader.DataType
Data type enum.
|
static class |
MetaImageHeader.ObjectType
Object type enum.
|
Modifier and Type | Field and Description |
---|---|
MetaImageHeader.AnatomicalOrientation |
anatomicalOrientation
AnatomicalOrientation field.
|
boolean |
binaryData
BinaryData, which is always true.
|
int |
channels
ElementNumberOfChannels, number of components.
|
boolean |
compressedData
CompressedData, if true, data is compressed with zlib.
|
int |
dataByteOffset
Offset of data in elementDataFile.
|
java.lang.String |
dataFile
data file.
|
MetaImageHeader.DataType |
dataType
ElementType, ie datatype.
|
int[] |
dimSize
Number of voxels in each dimension.
|
boolean |
intelByteOrder
BinaryDataByteOrderMSB = !
intelByteOrder . |
java.lang.String |
localDataFile
This variable contains the absolute path to the file containing the data (which may be the
same as the file containing the header).
|
int |
nDims
NDims, number of dimensions.
|
MetaImageHeader.ObjectType |
objectType
ObjectType, which for us is always Image.
|
double[] |
offset
Offset
|
double[] |
rotationCentre
CenterOfRotation
|
double[] |
spacing
Voxel dimensions.
|
RealMatrix |
transformation
TransformMatrix, a 3x3 rotation matrix.
|
Constructor and Description |
---|
MetaImageHeader()
Sets all values to their default.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
caminoDataTypeString()
Gets the Camino data type string
|
int |
components()
Analyze : nImages
Meta : channels NIFTI-1 : DIM5 |
int[] |
getDataDims() |
DataSource |
getImageDataSource()
Gets the image data source, scaling applied if applicable.
|
double[] |
getOrigin() |
double[] |
getVoxelDims()
Voxel dims may be negative for Analyze, use checkDims to get the absolute values.
|
RealMatrix |
getVoxelToPhysicalTransform()
Will use TransformMatrix + Offset, because it's not clear what coordinates CenterOfRotation uses
|
static MetaImageHeader |
readHeader(java.io.DataInput din)
Read the text header from an input stream.
|
static MetaImageHeader |
readHeader(java.lang.String file)
Read the text header from a file.
|
double[][][] |
readVolume(int index)
Reads a 3D Analyze volume and returns the result as double.
|
double[][][][] |
readVolumeData()
Reads a data array, assuming voxel-ordered data for multi-channel data.
|
void |
setHeaderValue(java.lang.String key,
java.lang.String value)
Parses header values from their String representation.
|
void |
writeHeader(java.io.DataOutput dout) |
void |
writeHeader(java.lang.String file)
Writes header to a file.
|
int |
xDataDim()
Analyze : width
MetaIO : DimSize[0] NIFTI-1 : XDIM |
double |
xVoxelDim()
Analyze : pixelwidth
(may be negative). |
int |
yDataDim()
Analyze : height
Meta : DimSize[1] NIFTI-1 : YDIM |
double |
yVoxelDim()
Analyze : pixelheight
(may be negative). |
int |
zDataDim()
Analyze : depth
Meta : DimSize[2] NIFTI-1 : ZDIM |
double |
zVoxelDim()
Analyze : pixeldepth
(may be negative). |
checkDims, getPhysicalToVoxelTransform, imageExists
public final MetaImageHeader.ObjectType objectType
public final int nDims
public final boolean binaryData
public boolean compressedData
public boolean intelByteOrder
intelByteOrder
.
Field named for consistency with AnalyzeHeader. The Meta specification also mentions
the seemingly redundant ElementByteOrderMSB. ITK examples contain either field, but
never both. Currently we read either but only write BinaryDataByteOrderMSB.public RealMatrix transformation
public double[] offset
public double[] rotationCentre
public MetaImageHeader.AnatomicalOrientation anatomicalOrientation
"Specify anatomic ordering of the axis. Use only [R|L] | [A|P] | [S|I] per axis. For example, if the three letter code for (column index, row index, slice index is) ILP, then the origin is at the superior, right, anterior corner of the volume, and therefore the axes run from superior to inferior, from right to left, from anterior to posterior."
Camino reads files in the order of left-right, posterior-anterior, inferior-superior. The origin of the image (voxel 0,0,0) is left, posterior, inferior. The orientation could therefore be described as LPI, but according to the above it's RAS. Because SNAP expects the codes to match the position of the origin, we'll default to LPI.
public double[] spacing
public int[] dimSize
public int channels
public MetaImageHeader.DataType dataType
public java.lang.String dataFile
public java.lang.String localDataFile
public int dataByteOffset
public static MetaImageHeader readHeader(java.lang.String file) throws java.io.IOException
java.io.IOException
public static MetaImageHeader readHeader(java.io.DataInput din) throws java.io.IOException
java.io.IOException
public void setHeaderValue(java.lang.String key, java.lang.String value)
public void writeHeader(java.lang.String file) throws java.io.IOException
java.io.IOException
public void writeHeader(java.io.DataOutput dout) throws java.io.IOException
java.io.IOException
public java.lang.String caminoDataTypeString()
public int xDataDim()
ImageHeader
xDataDim
in class ImageHeader
public int yDataDim()
ImageHeader
yDataDim
in class ImageHeader
public int zDataDim()
ImageHeader
zDataDim
in class ImageHeader
public int[] getDataDims()
getDataDims
in class ImageHeader
public double xVoxelDim()
ImageHeader
xVoxelDim
in class ImageHeader
public double yVoxelDim()
ImageHeader
yVoxelDim
in class ImageHeader
public double zVoxelDim()
ImageHeader
zVoxelDim
in class ImageHeader
public double[] getVoxelDims()
ImageHeader
getVoxelDims
in class ImageHeader
public int components()
ImageHeader
components
in class ImageHeader
public double[] getOrigin()
public DataSource getImageDataSource()
ImageHeader
getImageDataSource
in class ImageHeader
public double[][][][] readVolumeData()
readVolumeData
in class ImageHeader
public double[][][] readVolume(int index)
ImageHeader
readVolume
in class ImageHeader
index
- the volume to read, indexed from 0.public RealMatrix getVoxelToPhysicalTransform()
getVoxelToPhysicalTransform
in class ImageHeader