|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectNifti1Dataset
Nifti1Dataset is an API for reading/writing nifti-1 datasets.
The definitive nifti-1 specification is the nifti1.h file on the
NIfTI DFWG website
Notes:
Compression: files compressed with gzip are read using the Java
gunzip utility
Endian-ness: Java uses big-endian by default. nifti files determined to be little-endian as per the nifti spec (dim[0] field) will have the header and data swapped on read. (Not sure about write yet...)
Datatypes: the nifti-1 format supports a large number of datatypes. The current read methods typecast all data to doubles. This API will be extended to include methods to return image blobs of different datatypes.
Constructor Summary | |
Nifti1Dataset()
Constructor for creation of a new dataset. |
|
Nifti1Dataset(java.lang.String name)
Constructor for a dataset existing on disk. |
Method Summary | |
void |
addExtension(int code,
java.lang.String filename)
Add an extension stored in a file to a header |
short |
bytesPerVoxel(short dcode)
Return bytes per voxel for each nifti-1 datatype |
short |
checkHeader()
Check the header fields for valid settings |
void |
copyHeader(Nifti1Dataset A)
|
java.lang.String |
decodeDatatype(short dcode)
Decode the nifti datatype codes |
java.lang.String |
decodeIntent(short icode)
Decode the nifti intent codes |
java.lang.String |
decodeSliceOrder(short code)
Decode the nifti slice order codes |
java.lang.String |
decodeUnits(short code)
Decode the nifti unit codes |
java.lang.String |
decodeXform(short code)
Decode the nifti xform codes |
boolean |
exists()
Check if a valid dataset (header+data) exists. |
boolean |
existsDat()
Check if a valid dataset data file exists. |
boolean |
existsHdr()
Check if a valid dataset header file exists. |
short |
getBitpix()
Get the bitpix field |
java.lang.String |
getDataFilename()
Get the filename for the dataset data file |
short |
getDatatype()
Get the dataset datatype. |
int[][] |
getExtensionsList()
Get list of extensions and return it as nx2 array |
java.lang.String |
getHeaderFilename()
Get the filename for the dataset header file |
static void |
main(java.lang.String[] args)
main routine is used only for testing |
void |
printDoubleTmcrs(double[] d)
Print a voxel timecourse to standard out. |
void |
printHeader()
Print header information to standard out. |
byte[] |
readData()
Read all the data into one byte array. |
double[] |
readDoubleTmcrs(short x,
short y,
short z)
Read one 1D timecourse from a 4D dataset, ie all T values for a given XYZ location. |
double[][][] |
readDoubleVol(short ttt)
Read one 3D volume from disk and return it as 3D double array |
void |
readHeader()
Read header information into memory |
void |
removeExtension(int index)
Remove an extension from a header |
void |
setDataFilename(java.lang.String s)
Set the filename for the dataset data file |
void |
setDatatype(short code)
Set the dataset datatype. |
void |
setDims(short a,
short x,
short y,
short z,
short t,
short d5,
short d6,
short d7)
Set the dataset dimensions |
void |
setHeaderFilename(java.lang.String s)
Set the filename for the dataset header file |
void |
writeData(byte[] b)
Write a byte array of data to disk, starting at vox_offset, beginning of image data. |
void |
writeHeader()
Write header information to disk file |
void |
writeVol(double[][][] data,
short ttt)
Write one 3D double array to disk. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String ANZ_HDR_EXT
public static final java.lang.String ANZ_DAT_EXT
public static final java.lang.String NI1_EXT
public static final java.lang.String GZIP_EXT
public static final int ANZ_HDR_SIZE
public static final long NII_HDR_SIZE
public static final int EXT_KEY_SIZE
public static final java.lang.String NII_MAGIC_STRING
public static final java.lang.String ANZ_MAGIC_STRING
public static final short NIFTI_INTENT_NONE
public static final short NIFTI_INTENT_CORREL
public static final short NIFTI_INTENT_TTEST
public static final short NIFTI_INTENT_FTEST
public static final short NIFTI_INTENT_ZSCORE
public static final short NIFTI_INTENT_CHISQ
public static final short NIFTI_INTENT_BETA
public static final short NIFTI_INTENT_BINOM
public static final short NIFTI_INTENT_GAMMA
public static final short NIFTI_INTENT_POISSON
public static final short NIFTI_INTENT_NORMAL
public static final short NIFTI_INTENT_FTEST_NONC
public static final short NIFTI_INTENT_CHISQ_NONC
public static final short NIFTI_INTENT_LOGISTIC
public static final short NIFTI_INTENT_LAPLACE
public static final short NIFTI_INTENT_UNIFORM
public static final short NIFTI_INTENT_TTEST_NONC
public static final short NIFTI_INTENT_WEIBULL
public static final short NIFTI_INTENT_CHI
public static final short NIFTI_INTENT_INVGAUSS
public static final short NIFTI_INTENT_EXTVAL
public static final short NIFTI_INTENT_PVAL
public static final short NIFTI_INTENT_ESTIMATE
public static final short NIFTI_INTENT_LABEL
public static final short NIFTI_INTENT_NEURONAME
public static final short NIFTI_INTENT_GENMATRIX
public static final short NIFTI_INTENT_SYMMATRIX
public static final short NIFTI_INTENT_DISPVECT
public static final short NIFTI_INTENT_VECTOR
public static final short NIFTI_INTENT_POINTSET
public static final short NIFTI_INTENT_TRIANGLE
public static final short NIFTI_INTENT_QUATERNION
public static final short NIFTI_FIRST_STATCODE
public static final short NIFTI_LAST_STATCODE
public static final short DT_NONE
public static final short DT_BINARY
public static final short NIFTI_TYPE_UINT8
public static final short NIFTI_TYPE_INT16
public static final short NIFTI_TYPE_INT32
public static final short NIFTI_TYPE_FLOAT32
public static final short NIFTI_TYPE_COMPLEX64
public static final short NIFTI_TYPE_FLOAT64
public static final short NIFTI_TYPE_RGB24
public static final short DT_ALL
public static final short NIFTI_TYPE_INT8
public static final short NIFTI_TYPE_UINT16
public static final short NIFTI_TYPE_UINT32
public static final short NIFTI_TYPE_INT64
public static final short NIFTI_TYPE_UINT64
public static final short NIFTI_TYPE_FLOAT128
public static final short NIFTI_TYPE_COMPLEX128
public static final short NIFTI_TYPE_COMPLEX256
public static final short NIFTI_UNITS_UNKNOWN
public static final short NIFTI_UNITS_METER
public static final short NIFTI_UNITS_MM
public static final short NIFTI_UNITS_MICRON
public static final short NIFTI_UNITS_SEC
public static final short NIFTI_UNITS_MSEC
public static final short NIFTI_UNITS_USEC
public static final short NIFTI_UNITS_HZ
public static final short NIFTI_UNITS_PPM
public static final short NIFTI_SLICE_SEQ_INC
public static final short NIFTI_SLICE_SEQ_DEC
public static final short NIFTI_SLICE_ALT_INC
public static final short NIFTI_SLICE_ALT_DEC
public static final short NIFTI_XFORM_UNKNOWN
public static final short NIFTI_XFORM_SCANNER_ANAT
public static final short NIFTI_XFORM_ALIGNED_ANAT
public static final short NIFTI_XFORM_TALAIRACH
public static final short NIFTI_XFORM_MNI_152
public boolean ds_is_nii
public boolean big_endian
public short XDIM
public short YDIM
public short ZDIM
public short TDIM
public short DIM5
public short DIM6
public short DIM7
public short freq_dim
public short phase_dim
public short slice_dim
public short xyz_unit_code
public short t_unit_code
public short qfac
public int sizeof_hdr
public java.lang.StringBuffer data_type_string
public java.lang.StringBuffer db_name
public int extents
public short session_error
public java.lang.StringBuffer regular
public java.lang.StringBuffer dim_info
public float[] intent
public short intent_code
public short slice_start
public float[] pixdim
public float vox_offset
public float scl_slope
public float scl_inter
public short slice_end
public byte slice_code
public byte xyzt_units
public float cal_max
public float cal_min
public float slice_duration
public float toffset
public int glmax
public int glmin
public java.lang.StringBuffer descrip
public java.lang.StringBuffer aux_file
public short qform_code
public short sform_code
public float[] quatern
public float[] qoffset
public float[] srow_x
public float[] srow_y
public float[] srow_z
public java.lang.StringBuffer intent_name
public java.lang.StringBuffer magic
public byte[] extension
Constructor Detail |
public Nifti1Dataset(java.lang.String name)
name
- - name of the nifti-1 dataset. The name can have
the .hdr, .img, or .nii extension, optionally followed by a .gz
compression suffix. Or, the name can be specified with no
extensions or suffixes, in which case the program will look in
this order for files with these extensions: .hdr<.gz> .img<.gz>
.nii<.gz>public Nifti1Dataset()
Method Detail |
public void readHeader() throws java.io.IOException, java.io.FileNotFoundException
java.io.IOException
java.io.FileNotFoundException
public void copyHeader(Nifti1Dataset A)
public int[][] getExtensionsList()
public void removeExtension(int index)
index
- number of the extension to remove (0 based)public void addExtension(int code, java.lang.String filename) throws java.io.IOException
code
- -- code identifying the extensionfilename
- -- filename containing the extension. The entire
file will be added as an extension
java.io.IOException
public void writeHeader() throws java.io.IOException, java.io.FileNotFoundException
java.io.IOException
java.io.FileNotFoundException
public void printHeader()
public void printDoubleTmcrs(double[] d)
d
- 1D double array of timecourse values, length TDIMpublic boolean exists()
public boolean existsHdr()
public boolean existsDat()
public void setHeaderFilename(java.lang.String s)
s
- filename for the dataset header filepublic java.lang.String getHeaderFilename()
public void setDataFilename(java.lang.String s)
s
- filename for the dataset data filepublic java.lang.String getDataFilename()
public void setDims(short a, short x, short y, short z, short t, short d5, short d6, short d7)
public void setDatatype(short code)
code
- nifti-1 datatype codepublic short getDatatype()
public short getBitpix()
public java.lang.String decodeIntent(short icode)
icode
- nifti intent code
public java.lang.String decodeDatatype(short dcode)
dcode
- nifti datatype code
public short bytesPerVoxel(short dcode)
dcode
- nifti datatype code
public java.lang.String decodeSliceOrder(short code)
code
- nifti slice order code
public java.lang.String decodeXform(short code)
code
- nifti xform code
public java.lang.String decodeUnits(short code)
code
- nifti units code
public short checkHeader()
public double[][][] readDoubleVol(short ttt) throws java.io.IOException
ttt
- T dimension of vol to read (0 based index)
java.io.IOException
public void writeVol(double[][][] data, short ttt) throws java.io.IOException
data
- 3D array of array data
Array indices are [Z][Y][X], assuming an xyzt ordering of dimensions.
ie indices are data[dim[3]][dim[2]][dim[1]]ttt
- T dimension of vol to write (0 based index)
java.io.IOException
public byte[] readData() throws java.io.IOException
java.io.IOException
public void writeData(byte[] b) throws java.io.IOException
b
- byte array of image data
java.io.IOException
public double[] readDoubleTmcrs(short x, short y, short z) throws java.io.IOException
x
- X dimension of vol to read (0 based index)y
- Y dimension of vol to read (0 based index)z
- Z dimension of vol to read (0 based index)
java.io.IOException
public static void main(java.lang.String[] args)
args
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |