Class Nifti1Dataset

java.lang.Object
  extended byNifti1Dataset

public class Nifti1Dataset
extends java.lang.Object

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.

Todo List

History of changes to Nifti1Dataset


Field Summary
static java.lang.String ANZ_DAT_EXT
           
static java.lang.String ANZ_HDR_EXT
           
static int ANZ_HDR_SIZE
           
static java.lang.String ANZ_MAGIC_STRING
           
 java.lang.StringBuffer aux_file
           
 boolean big_endian
           
 float cal_max
           
 float cal_min
           
 java.lang.StringBuffer data_type_string
           
 java.lang.StringBuffer db_name
           
 java.lang.StringBuffer descrip
           
 java.lang.StringBuffer dim_info
           
 short DIM5
           
 short DIM6
           
 short DIM7
           
 boolean ds_is_nii
           
static short DT_ALL
           
static short DT_BINARY
           
static short DT_NONE
           
static int EXT_KEY_SIZE
           
 byte[] extension
           
 int extents
           
 short freq_dim
           
 int glmax
           
 int glmin
           
static java.lang.String GZIP_EXT
           
 float[] intent
           
 short intent_code
           
 java.lang.StringBuffer intent_name
           
 java.lang.StringBuffer magic
           
static java.lang.String NI1_EXT
           
static short NIFTI_FIRST_STATCODE
           
static short NIFTI_INTENT_BETA
           
static short NIFTI_INTENT_BINOM
           
static short NIFTI_INTENT_CHI
           
static short NIFTI_INTENT_CHISQ
           
static short NIFTI_INTENT_CHISQ_NONC
           
static short NIFTI_INTENT_CORREL
           
static short NIFTI_INTENT_DISPVECT
           
static short NIFTI_INTENT_ESTIMATE
           
static short NIFTI_INTENT_EXTVAL
           
static short NIFTI_INTENT_FTEST
           
static short NIFTI_INTENT_FTEST_NONC
           
static short NIFTI_INTENT_GAMMA
           
static short NIFTI_INTENT_GENMATRIX
           
static short NIFTI_INTENT_INVGAUSS
           
static short NIFTI_INTENT_LABEL
           
static short NIFTI_INTENT_LAPLACE
           
static short NIFTI_INTENT_LOGISTIC
           
static short NIFTI_INTENT_NEURONAME
           
static short NIFTI_INTENT_NONE
           
static short NIFTI_INTENT_NORMAL
           
static short NIFTI_INTENT_POINTSET
           
static short NIFTI_INTENT_POISSON
           
static short NIFTI_INTENT_PVAL
           
static short NIFTI_INTENT_QUATERNION
           
static short NIFTI_INTENT_SYMMATRIX
           
static short NIFTI_INTENT_TRIANGLE
           
static short NIFTI_INTENT_TTEST
           
static short NIFTI_INTENT_TTEST_NONC
           
static short NIFTI_INTENT_UNIFORM
           
static short NIFTI_INTENT_VECTOR
           
static short NIFTI_INTENT_WEIBULL
           
static short NIFTI_INTENT_ZSCORE
           
static short NIFTI_LAST_STATCODE
           
static short NIFTI_SLICE_ALT_DEC
           
static short NIFTI_SLICE_ALT_INC
           
static short NIFTI_SLICE_SEQ_DEC
           
static short NIFTI_SLICE_SEQ_INC
           
static short NIFTI_TYPE_COMPLEX128
           
static short NIFTI_TYPE_COMPLEX256
           
static short NIFTI_TYPE_COMPLEX64
           
static short NIFTI_TYPE_FLOAT128
           
static short NIFTI_TYPE_FLOAT32
           
static short NIFTI_TYPE_FLOAT64
           
static short NIFTI_TYPE_INT16
           
static short NIFTI_TYPE_INT32
           
static short NIFTI_TYPE_INT64
           
static short NIFTI_TYPE_INT8
           
static short NIFTI_TYPE_RGB24
           
static short NIFTI_TYPE_UINT16
           
static short NIFTI_TYPE_UINT32
           
static short NIFTI_TYPE_UINT64
           
static short NIFTI_TYPE_UINT8
           
static short NIFTI_UNITS_HZ
           
static short NIFTI_UNITS_METER
           
static short NIFTI_UNITS_MICRON
           
static short NIFTI_UNITS_MM
           
static short NIFTI_UNITS_MSEC
           
static short NIFTI_UNITS_PPM
           
static short NIFTI_UNITS_SEC
           
static short NIFTI_UNITS_UNKNOWN
           
static short NIFTI_UNITS_USEC
           
static short NIFTI_XFORM_ALIGNED_ANAT
           
static short NIFTI_XFORM_MNI_152
           
static short NIFTI_XFORM_SCANNER_ANAT
           
static short NIFTI_XFORM_TALAIRACH
           
static short NIFTI_XFORM_UNKNOWN
           
static long NII_HDR_SIZE
           
static java.lang.String NII_MAGIC_STRING
           
 short phase_dim
           
 float[] pixdim
           
 short qfac
           
 short qform_code
           
 float[] qoffset
           
 float[] quatern
           
 java.lang.StringBuffer regular
           
 float scl_inter
           
 float scl_slope
           
 short session_error
           
 short sform_code
           
 int sizeof_hdr
           
 byte slice_code
           
 short slice_dim
           
 float slice_duration
           
 short slice_end
           
 short slice_start
           
 float[] srow_x
           
 float[] srow_y
           
 float[] srow_z
           
 short t_unit_code
           
 short TDIM
           
 float toffset
           
 float vox_offset
           
 short XDIM
           
 short xyz_unit_code
           
 byte xyzt_units
           
 short YDIM
           
 short ZDIM
           
 
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

ANZ_HDR_EXT

public static final java.lang.String ANZ_HDR_EXT
See Also:
Constant Field Values

ANZ_DAT_EXT

public static final java.lang.String ANZ_DAT_EXT
See Also:
Constant Field Values

NI1_EXT

public static final java.lang.String NI1_EXT
See Also:
Constant Field Values

GZIP_EXT

public static final java.lang.String GZIP_EXT
See Also:
Constant Field Values

ANZ_HDR_SIZE

public static final int ANZ_HDR_SIZE
See Also:
Constant Field Values

NII_HDR_SIZE

public static final long NII_HDR_SIZE
See Also:
Constant Field Values

EXT_KEY_SIZE

public static final int EXT_KEY_SIZE
See Also:
Constant Field Values

NII_MAGIC_STRING

public static final java.lang.String NII_MAGIC_STRING
See Also:
Constant Field Values

ANZ_MAGIC_STRING

public static final java.lang.String ANZ_MAGIC_STRING
See Also:
Constant Field Values

NIFTI_INTENT_NONE

public static final short NIFTI_INTENT_NONE
See Also:
Constant Field Values

NIFTI_INTENT_CORREL

public static final short NIFTI_INTENT_CORREL
See Also:
Constant Field Values

NIFTI_INTENT_TTEST

public static final short NIFTI_INTENT_TTEST
See Also:
Constant Field Values

NIFTI_INTENT_FTEST

public static final short NIFTI_INTENT_FTEST
See Also:
Constant Field Values

NIFTI_INTENT_ZSCORE

public static final short NIFTI_INTENT_ZSCORE
See Also:
Constant Field Values

NIFTI_INTENT_CHISQ

public static final short NIFTI_INTENT_CHISQ
See Also:
Constant Field Values

NIFTI_INTENT_BETA

public static final short NIFTI_INTENT_BETA
See Also:
Constant Field Values

NIFTI_INTENT_BINOM

public static final short NIFTI_INTENT_BINOM
See Also:
Constant Field Values

NIFTI_INTENT_GAMMA

public static final short NIFTI_INTENT_GAMMA
See Also:
Constant Field Values

NIFTI_INTENT_POISSON

public static final short NIFTI_INTENT_POISSON
See Also:
Constant Field Values

NIFTI_INTENT_NORMAL

public static final short NIFTI_INTENT_NORMAL
See Also:
Constant Field Values

NIFTI_INTENT_FTEST_NONC

public static final short NIFTI_INTENT_FTEST_NONC
See Also:
Constant Field Values

NIFTI_INTENT_CHISQ_NONC

public static final short NIFTI_INTENT_CHISQ_NONC
See Also:
Constant Field Values

NIFTI_INTENT_LOGISTIC

public static final short NIFTI_INTENT_LOGISTIC
See Also:
Constant Field Values

NIFTI_INTENT_LAPLACE

public static final short NIFTI_INTENT_LAPLACE
See Also:
Constant Field Values

NIFTI_INTENT_UNIFORM

public static final short NIFTI_INTENT_UNIFORM
See Also:
Constant Field Values

NIFTI_INTENT_TTEST_NONC

public static final short NIFTI_INTENT_TTEST_NONC
See Also:
Constant Field Values

NIFTI_INTENT_WEIBULL

public static final short NIFTI_INTENT_WEIBULL
See Also:
Constant Field Values

NIFTI_INTENT_CHI

public static final short NIFTI_INTENT_CHI
See Also:
Constant Field Values

NIFTI_INTENT_INVGAUSS

public static final short NIFTI_INTENT_INVGAUSS
See Also:
Constant Field Values

NIFTI_INTENT_EXTVAL

public static final short NIFTI_INTENT_EXTVAL
See Also:
Constant Field Values

NIFTI_INTENT_PVAL

public static final short NIFTI_INTENT_PVAL
See Also:
Constant Field Values

NIFTI_INTENT_ESTIMATE

public static final short NIFTI_INTENT_ESTIMATE
See Also:
Constant Field Values

NIFTI_INTENT_LABEL

public static final short NIFTI_INTENT_LABEL
See Also:
Constant Field Values

NIFTI_INTENT_NEURONAME

public static final short NIFTI_INTENT_NEURONAME
See Also:
Constant Field Values

NIFTI_INTENT_GENMATRIX

public static final short NIFTI_INTENT_GENMATRIX
See Also:
Constant Field Values

NIFTI_INTENT_SYMMATRIX

public static final short NIFTI_INTENT_SYMMATRIX
See Also:
Constant Field Values

NIFTI_INTENT_DISPVECT

public static final short NIFTI_INTENT_DISPVECT
See Also:
Constant Field Values

NIFTI_INTENT_VECTOR

public static final short NIFTI_INTENT_VECTOR
See Also:
Constant Field Values

NIFTI_INTENT_POINTSET

public static final short NIFTI_INTENT_POINTSET
See Also:
Constant Field Values

NIFTI_INTENT_TRIANGLE

public static final short NIFTI_INTENT_TRIANGLE
See Also:
Constant Field Values

NIFTI_INTENT_QUATERNION

public static final short NIFTI_INTENT_QUATERNION
See Also:
Constant Field Values

NIFTI_FIRST_STATCODE

public static final short NIFTI_FIRST_STATCODE
See Also:
Constant Field Values

NIFTI_LAST_STATCODE

public static final short NIFTI_LAST_STATCODE
See Also:
Constant Field Values

DT_NONE

public static final short DT_NONE
See Also:
Constant Field Values

DT_BINARY

public static final short DT_BINARY
See Also:
Constant Field Values

NIFTI_TYPE_UINT8

public static final short NIFTI_TYPE_UINT8
See Also:
Constant Field Values

NIFTI_TYPE_INT16

public static final short NIFTI_TYPE_INT16
See Also:
Constant Field Values

NIFTI_TYPE_INT32

public static final short NIFTI_TYPE_INT32
See Also:
Constant Field Values

NIFTI_TYPE_FLOAT32

public static final short NIFTI_TYPE_FLOAT32
See Also:
Constant Field Values

NIFTI_TYPE_COMPLEX64

public static final short NIFTI_TYPE_COMPLEX64
See Also:
Constant Field Values

NIFTI_TYPE_FLOAT64

public static final short NIFTI_TYPE_FLOAT64
See Also:
Constant Field Values

NIFTI_TYPE_RGB24

public static final short NIFTI_TYPE_RGB24
See Also:
Constant Field Values

DT_ALL

public static final short DT_ALL
See Also:
Constant Field Values

NIFTI_TYPE_INT8

public static final short NIFTI_TYPE_INT8
See Also:
Constant Field Values

NIFTI_TYPE_UINT16

public static final short NIFTI_TYPE_UINT16
See Also:
Constant Field Values

NIFTI_TYPE_UINT32

public static final short NIFTI_TYPE_UINT32
See Also:
Constant Field Values

NIFTI_TYPE_INT64

public static final short NIFTI_TYPE_INT64
See Also:
Constant Field Values

NIFTI_TYPE_UINT64

public static final short NIFTI_TYPE_UINT64
See Also:
Constant Field Values

NIFTI_TYPE_FLOAT128

public static final short NIFTI_TYPE_FLOAT128
See Also:
Constant Field Values

NIFTI_TYPE_COMPLEX128

public static final short NIFTI_TYPE_COMPLEX128
See Also:
Constant Field Values

NIFTI_TYPE_COMPLEX256

public static final short NIFTI_TYPE_COMPLEX256
See Also:
Constant Field Values

NIFTI_UNITS_UNKNOWN

public static final short NIFTI_UNITS_UNKNOWN
See Also:
Constant Field Values

NIFTI_UNITS_METER

public static final short NIFTI_UNITS_METER
See Also:
Constant Field Values

NIFTI_UNITS_MM

public static final short NIFTI_UNITS_MM
See Also:
Constant Field Values

NIFTI_UNITS_MICRON

public static final short NIFTI_UNITS_MICRON
See Also:
Constant Field Values

NIFTI_UNITS_SEC

public static final short NIFTI_UNITS_SEC
See Also:
Constant Field Values

NIFTI_UNITS_MSEC

public static final short NIFTI_UNITS_MSEC
See Also:
Constant Field Values

NIFTI_UNITS_USEC

public static final short NIFTI_UNITS_USEC
See Also:
Constant Field Values

NIFTI_UNITS_HZ

public static final short NIFTI_UNITS_HZ
See Also:
Constant Field Values

NIFTI_UNITS_PPM

public static final short NIFTI_UNITS_PPM
See Also:
Constant Field Values

NIFTI_SLICE_SEQ_INC

public static final short NIFTI_SLICE_SEQ_INC
See Also:
Constant Field Values

NIFTI_SLICE_SEQ_DEC

public static final short NIFTI_SLICE_SEQ_DEC
See Also:
Constant Field Values

NIFTI_SLICE_ALT_INC

public static final short NIFTI_SLICE_ALT_INC
See Also:
Constant Field Values

NIFTI_SLICE_ALT_DEC

public static final short NIFTI_SLICE_ALT_DEC
See Also:
Constant Field Values

NIFTI_XFORM_UNKNOWN

public static final short NIFTI_XFORM_UNKNOWN
See Also:
Constant Field Values

NIFTI_XFORM_SCANNER_ANAT

public static final short NIFTI_XFORM_SCANNER_ANAT
See Also:
Constant Field Values

NIFTI_XFORM_ALIGNED_ANAT

public static final short NIFTI_XFORM_ALIGNED_ANAT
See Also:
Constant Field Values

NIFTI_XFORM_TALAIRACH

public static final short NIFTI_XFORM_TALAIRACH
See Also:
Constant Field Values

NIFTI_XFORM_MNI_152

public static final short NIFTI_XFORM_MNI_152
See Also:
Constant Field Values

ds_is_nii

public boolean ds_is_nii

big_endian

public boolean big_endian

XDIM

public short XDIM

YDIM

public short YDIM

ZDIM

public short ZDIM

TDIM

public short TDIM

DIM5

public short DIM5

DIM6

public short DIM6

DIM7

public short DIM7

freq_dim

public short freq_dim

phase_dim

public short phase_dim

slice_dim

public short slice_dim

xyz_unit_code

public short xyz_unit_code

t_unit_code

public short t_unit_code

qfac

public short qfac

sizeof_hdr

public int sizeof_hdr

data_type_string

public java.lang.StringBuffer data_type_string

db_name

public java.lang.StringBuffer db_name

extents

public int extents

session_error

public short session_error

regular

public java.lang.StringBuffer regular

dim_info

public java.lang.StringBuffer dim_info

intent

public float[] intent

intent_code

public short intent_code

slice_start

public short slice_start

pixdim

public float[] pixdim

vox_offset

public float vox_offset

scl_slope

public float scl_slope

scl_inter

public float scl_inter

slice_end

public short slice_end

slice_code

public byte slice_code

xyzt_units

public byte xyzt_units

cal_max

public float cal_max

cal_min

public float cal_min

slice_duration

public float slice_duration

toffset

public float toffset

glmax

public int glmax

glmin

public int glmin

descrip

public java.lang.StringBuffer descrip

aux_file

public java.lang.StringBuffer aux_file

qform_code

public short qform_code

sform_code

public short sform_code

quatern

public float[] quatern

qoffset

public float[] qoffset

srow_x

public float[] srow_x

srow_y

public float[] srow_y

srow_z

public float[] srow_z

intent_name

public java.lang.StringBuffer intent_name

magic

public java.lang.StringBuffer magic

extension

public byte[] extension
Constructor Detail

Nifti1Dataset

public Nifti1Dataset(java.lang.String name)
Constructor for a dataset existing on disk.

Parameters:
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>

Nifti1Dataset

public Nifti1Dataset()
Constructor for creation of a new dataset. Default values are set, programmer must set or reset all fields appropriate for the new dataset.

Method Detail

readHeader

public void readHeader()
                throws java.io.IOException,
                       java.io.FileNotFoundException
Read header information into memory

Throws:
java.io.IOException
java.io.FileNotFoundException

copyHeader

public void copyHeader(Nifti1Dataset A)

getExtensionsList

public int[][] getExtensionsList()
Get list of extensions and return it as nx2 array

Returns:
nx2 array where n = # of extensions, array elem 0 is the size in bytes of that extension and array elem 1 is the extension code.

removeExtension

public void removeExtension(int index)
Remove an extension from a header

Parameters:
index - number of the extension to remove (0 based)

addExtension

public void addExtension(int code,
                         java.lang.String filename)
                  throws java.io.IOException
Add an extension stored in a file to a header

Parameters:
code - -- code identifying the extension
filename - -- filename containing the extension. The entire file will be added as an extension
Throws:
java.io.IOException

writeHeader

public void writeHeader()
                 throws java.io.IOException,
                        java.io.FileNotFoundException
Write header information to disk file

Throws:
java.io.IOException
java.io.FileNotFoundException

printHeader

public void printHeader()
Print header information to standard out.


printDoubleTmcrs

public void printDoubleTmcrs(double[] d)
Print a voxel timecourse to standard out.

Parameters:
d - 1D double array of timecourse values, length TDIM

exists

public boolean exists()
Check if a valid dataset (header+data) exists. Note that some operations (e.g. header editing) do not actually require that a data file exist. Use existsHdr() existsDat() in those cases. Gzipped files with .gz extension are permitted.

Returns:
true if header and data file exist, else false

existsHdr

public boolean existsHdr()
Check if a valid dataset header file exists.

Returns:
true if header file exist, else false

existsDat

public boolean existsDat()
Check if a valid dataset data file exists.

Returns:
true if data file exist, else false

setHeaderFilename

public void setHeaderFilename(java.lang.String s)
Set the filename for the dataset header file

Parameters:
s - filename for the dataset header file

getHeaderFilename

public java.lang.String getHeaderFilename()
Get the filename for the dataset header file

Returns:
String with the disk filename for the dataset header file

setDataFilename

public void setDataFilename(java.lang.String s)
Set the filename for the dataset data file

Parameters:
s - filename for the dataset data file

getDataFilename

public java.lang.String getDataFilename()
Get the filename for the dataset data file

Returns:
filename for the dataset data file

setDims

public void setDims(short a,
                    short x,
                    short y,
                    short z,
                    short t,
                    short d5,
                    short d6,
                    short d7)
Set the dataset dimensions


setDatatype

public void setDatatype(short code)
Set the dataset datatype. (bitpix will also be set accordingly.)

Parameters:
code - nifti-1 datatype code

getDatatype

public short getDatatype()
Get the dataset datatype.

Returns:
datatype code (note: it is not guaranteed to be a valid code, what is there is what you get...)

getBitpix

public short getBitpix()
Get the bitpix field

Returns:
bitpix: number of bits per pixel

decodeIntent

public java.lang.String decodeIntent(short icode)
Decode the nifti intent codes

Parameters:
icode - nifti intent code
Returns:
a terse string describing the intent

decodeDatatype

public java.lang.String decodeDatatype(short dcode)
Decode the nifti datatype codes

Parameters:
dcode - nifti datatype code
Returns:
a terse string describing the datatype

bytesPerVoxel

public short bytesPerVoxel(short dcode)
Return bytes per voxel for each nifti-1 datatype

Parameters:
dcode - nifti datatype code
Returns:
a short with number of bytes per voxel, 0 for unknown, -1 for 1 bit

decodeSliceOrder

public java.lang.String decodeSliceOrder(short code)
Decode the nifti slice order codes

Parameters:
code - nifti slice order code
Returns:
a terse string describing the slice order

decodeXform

public java.lang.String decodeXform(short code)
Decode the nifti xform codes

Parameters:
code - nifti xform code
Returns:
a terse string describing the coord. system

decodeUnits

public java.lang.String decodeUnits(short code)
Decode the nifti unit codes

Parameters:
code - nifti units code
Returns:
a terse string describing the unit

checkHeader

public short checkHeader()
Check the header fields for valid settings

Returns:
0 if all checks are passed else, error code

readDoubleVol

public double[][][] readDoubleVol(short ttt)
                           throws java.io.IOException
Read one 3D volume from disk and return it as 3D double array

Parameters:
ttt - T dimension of vol to read (0 based index)
Returns:
3D double array, scale and offset have been applied. Array indices are [Z][Y][X], assuming an xyzt ordering of dimensions. ie indices are data[dim[3]][dim[2]][dim[1]]
Throws:
java.io.IOException

writeVol

public void writeVol(double[][][] data,
                     short ttt)
              throws java.io.IOException
Write one 3D double array to disk. Data is written in datatype of this Nifti1Dataset instance. Data is "un-scaled" as per scale/offset fields of this Nifti1Dataset instance, before being written to disk.

Parameters:
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)
Throws:
java.io.IOException

readData

public byte[] readData()
                throws java.io.IOException
Read all the data into one byte array. Note that since the data is handled as bytes, NO byte swapping has been performed. Applications converting from the byte array to int/float datatypes will need to swap bytes if necessary. return byte array with all image data

Throws:
java.io.IOException

writeData

public void writeData(byte[] b)
               throws java.io.IOException
Write a byte array of data to disk, starting at vox_offset, beginning of image data. It is assumed that usually the entire data array will be written with this call. Note that since the data is handled as bytes, NO byte swapping will be performed. Applications needing byteswapping must swap the bytes correctly in the input array b.

Parameters:
b - byte array of image data
Throws:
java.io.IOException

readDoubleTmcrs

public double[] readDoubleTmcrs(short x,
                                short y,
                                short z)
                         throws java.io.IOException
Read one 1D timecourse from a 4D dataset, ie all T values for a given XYZ location. Scaling is applied.

Parameters:
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)
Returns:
1D double array
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
main routine is used only for testing

Parameters:
args -