public class AnalyzeHeader extends ImageHeader
The class also stores the PICo seed point in the fields unused8, unused9 and unused10.
Modifier and Type | Field and Description |
---|---|
short |
bitpix |
short[] |
centre
Centre of the Talairach coordinate system
|
short |
datatype |
short |
depth |
java.lang.String |
description |
static short |
DT_ALL |
static short |
DT_BINARY |
static short |
DT_COMPLEX |
static short |
DT_DOUBLE |
static short |
DT_FLOAT |
static short |
DT_NONE |
static short |
DT_RGB |
static short |
DT_SIGNED_CHAR
8-bit signed char, equivalent to Java byte.
|
static short |
DT_SIGNED_INT |
static short |
DT_SIGNED_SHORT
16-bit signed integer (-32768-32767).
|
static short |
DT_UNKNOWN |
static short |
DT_UNSIGNED_CHAR
8-bit unsigned char (0-255) datatype.
|
static short |
DT_UNSIGNED_INT
32-bit unsigned int datatype.
|
static short |
DT_UNSIGNED_SHORT
16-bit unsigned short datatype.
|
int |
glmax |
int |
glmin |
short |
height |
boolean |
intelByteOrder |
short |
nImages |
short[] |
picoSeed
Seed point for PICo probability maps
|
float |
pixelDepth |
float |
pixelHeight |
float |
pixelWidth |
float |
scaleInter |
float |
scaleSlope |
float |
vox_offset |
short |
width |
Constructor and Description |
---|
AnalyzeHeader()
Creates an AnalyzeHeader object with all of its fields set to their
default value.
|
AnalyzeHeader(AnalyzeHeader ah)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
caminoDataTypeString() |
int |
components()
Analyze : nImages
Meta : channels NIFTI-1 : DIM5 |
static java.lang.String |
getArgs(AnalyzeHeader ah,
java.lang.String prog)
Get Camino program arguments for this header.
|
int[] |
getDataDims() |
static AnalyzeHeader |
getHeader(double[][][] data,
double[] voxelDims,
short datatype)
Creates an AnalyzeHeader object, with voxel and data dims taken from data.
|
static AnalyzeHeader |
getHeader(float[][][] data,
double[] voxelDims,
short datatype)
Creates an AnalyzeHeader object, with voxel and data dims taken from data.
|
static AnalyzeHeader |
getHeader(int[] dataDims,
double[] voxelDims,
short datatype)
Creates an AnalyzeHeader object, from specified dimensions.
|
java.lang.String |
getHeaderFile(java.lang.String file)
Gets the header file name for this object.
|
DataSource |
getImageDataSource()
Gets a data source from a Analyze header.
|
static java.lang.String |
getImageRoot(java.lang.String fileName)
Gets the image root, such that root.hdr and root.[img | img.gz] exist.
|
static java.lang.String |
getIMG_File(java.lang.String hdrFile) |
double[] |
getOrigin() |
double[] |
getVoxelDims()
Voxel dims may be negative for Analyze, use checkDims to get the absolute values.
|
RealMatrix |
getVoxelToPhysicalTransform()
Gets the transformation matrix R that provides a transformation from a = (i, j, k, 1) in
voxel space to b = (x, y, z, 1) in physical space.
|
static void |
main(java.lang.String[] args) |
float |
readFloat(java.io.DataInputStream input) |
static AnalyzeHeader |
readHeader(java.lang.String hdrFile)
Reads a header from the given file.
|
int |
readInt(java.io.DataInputStream input) |
short |
readShort(java.io.DataInputStream input) |
double[][][] |
readVolume(int index)
Reads a 3D Analyze volume and returns the result as double.
|
double[][][][] |
readVolumeData()
Reads a 4D Analyze volume and returns the result as double.
|
void |
setHeaderFile(java.lang.String file)
Sets the header file for this object.
|
java.lang.String |
toString() |
void |
writeHeader()
Writes header to the file.
|
static void |
writeImage(double[][][] data,
AnalyzeHeader ah,
java.lang.String file,
boolean gzip)
Writes file.hdr and file.img.
|
static void |
writeImage(float[][][] data,
AnalyzeHeader ah,
java.lang.String file,
boolean gzip)
Writes file.hdr and file.img.
|
static void |
writeImage(int[][][] data,
AnalyzeHeader ah,
java.lang.String file,
boolean gzip)
Writes file.hdr and file.img.
|
static void |
writeImage(int[][][] r,
int[][][] g,
int[][][] b,
AnalyzeHeader ah,
java.lang.String file,
boolean gzip)
Writes file.hdr and file.img.
|
static void |
writeImage(short[][][] data,
AnalyzeHeader ah,
java.lang.String file,
boolean gzip)
Writes file.hdr and file.img.
|
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 static final short DT_NONE
public static final short DT_UNKNOWN
public static final short DT_BINARY
public static final short DT_UNSIGNED_CHAR
public static final short DT_SIGNED_SHORT
public static final short DT_SIGNED_INT
public static final short DT_FLOAT
public static final short DT_COMPLEX
public static final short DT_DOUBLE
public static final short DT_RGB
public static final short DT_SIGNED_CHAR
public static final short DT_UNSIGNED_SHORT
public static final short DT_UNSIGNED_INT
public static final short DT_ALL
public short datatype
public short width
public short height
public short depth
public float vox_offset
public short nImages
public boolean intelByteOrder
public int glmin
public int glmax
public float pixelWidth
public float pixelHeight
public float pixelDepth
public float scaleSlope
public float scaleInter
public short bitpix
public java.lang.String description
public short[] centre
public short[] picoSeed
public AnalyzeHeader()
public AnalyzeHeader(AnalyzeHeader ah)
public static AnalyzeHeader readHeader(java.lang.String hdrFile) throws java.io.IOException
java.io.IOException
- if the header cannot be read.public void writeHeader() throws java.io.IOException
setHeaderFile
to set the file name of the header.java.io.IOException
public int readInt(java.io.DataInputStream input) throws java.io.IOException
java.io.IOException
public short readShort(java.io.DataInputStream input) throws java.io.IOException
java.io.IOException
public float readFloat(java.io.DataInputStream input) throws java.io.IOException
java.io.IOException
public static void main(java.lang.String[] args)
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String getArgs(AnalyzeHeader ah, java.lang.String prog)
prog
is the name of a
supported Camino program, the returned String is args for that program only,
without any surrounding context. Otherwise, a list of programs and args is returned.prog
- Use "all" to get general information. Other supported program names are
"shredder", "vcthreshselect", "pdview", "track". Anything else returns an empty String.public static AnalyzeHeader getHeader(int[] dataDims, double[] voxelDims, short datatype)
public static AnalyzeHeader getHeader(double[][][] data, double[] voxelDims, short datatype)
data
- the data dimensions are calculated from this array.voxelDims
- {x y z}
the voxel dimensions.datatype
- one of the Analyze data types.public static AnalyzeHeader getHeader(float[][][] data, double[] voxelDims, short datatype)
public static void writeImage(int[][][] r, int[][][] g, int[][][] b, AnalyzeHeader ah, java.lang.String file, boolean gzip) throws java.io.IOException
Note: unlike the other methods, this method always writes the header data type as RGB. It also does not scale (RGB values are already 8 bits per pixel).
r
- red values, should be between 0 and 255 (only the first 8 bits are written).g
- green values, should be between 0 and 255 (only the first 8 bits are written).b
- blue values, should be between 0 and 255 (only the first 8 bits are written).gzip
- if true, compress .img part of image.java.io.IOException
public static void writeImage(short[][][] data, AnalyzeHeader ah, java.lang.String file, boolean gzip) throws java.io.IOException
gzip
- if true, compress .img part of image.java.io.IOException
public static void writeImage(int[][][] data, AnalyzeHeader ah, java.lang.String file, boolean gzip) throws java.io.IOException
gzip
- if true, compress .img part of image.java.io.IOException
public static void writeImage(float[][][] data, AnalyzeHeader ah, java.lang.String file, boolean gzip) throws java.io.IOException
gzip
- if true, compress .img part of image.java.io.IOException
public static void writeImage(double[][][] data, AnalyzeHeader ah, java.lang.String file, boolean gzip) throws java.io.IOException
gzip
- if true, compress .img part of image.java.io.IOException
public void setHeaderFile(java.lang.String file)
public java.lang.String getHeaderFile(java.lang.String file)
public java.lang.String caminoDataTypeString()
ExternalDataSource
public static java.lang.String getIMG_File(java.lang.String hdrFile)
hdrFile
- the path to the header file, with or without the ".hdr".hdrFile
without the ".hdr" extension.
If neither root.img nor root.img.gz can be found, the method returns null
.public static java.lang.String getImageRoot(java.lang.String fileName)
If fileName exists and ends in [.hdr | .img | .img.gz], the method returns the file root, where
both root.hdr and root.[img | img.gz] exist and fileName is equal to root.[hdr | img | img.gz].
If fileName does not end in [.hdr | .img | .img.gz], the method returns fileName if fileName.hdr
and fileName.[img | img.gz] exist.
fileName
- path to a file, corresponding to an Analyze image.null
.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 double[] getOrigin()
public int components()
ImageHeader
components
in class ImageHeader
public DataSource getImageDataSource()
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()
The matrix is simply a scaling by pixdim and a translation, defined by centre.
getVoxelToPhysicalTransform
in class ImageHeader