SLIMMER
Public Member Functions | Protected Member Functions
SimpleVoxIO Class Reference

Voxel Input/Output Class. More...

#include <SimpleVoxIO.h>

Inheritance diagram for SimpleVoxIO:
ReadDataType SimpleTField< T, TS > SimpleTField< float > SimpleTField< T > SimpleTField< T2 > Stack< T, TTransformType >

List of all members.

Public Member Functions

 SimpleVoxIO ()
 Flag Indicating Scanner Coordinates Known From File.
virtual ~SimpleVoxIO ()
 Destructor.
void SetReadSwap (int val)
 Set Read ByteSwap Flag (to Change from File to Machine Order)
void SetWriteSwap (int val)
 Set Write ByteSwap Flag (to Change from Machine to File Order)
FILE * SimpleReadHeader (BasicHeader &im1, char *name, int &offset)
 Read Image Header and Return File Pointer to Data Start.
FILE * SimpleWriteHeader (BasicHeader &im1, char *name, int Itype=IT_SHORT, double scale=1.0)
 Write a Header and Return a File Pointer to File to Write Voxel Data To.

Protected Member Functions

FILE * WriteGIPLHEAD (BasicHeader &im1, char *name, int Itype=IT_SHORT, double scale=1.0, double offset=0.0)
 Write a GIPL file Header.
bool SimpleWriteTiming (FILE *fp, BasicHeader &im1)
 Read Extra Slice Timing From the End of a GIPL File.
FILE * WriteMidasHEAD (BasicHeader &im1, char *name, int Itype=IT_SHORT, double scale=1.0, double offset=0.0)
 Write a MIDAS Format Header.
unsigned long int WriteDataBlock (FILE *fp, double *data, unsigned long int tot, float scale)
 Write a Block of Doubles.
unsigned long int WriteDataBlock (FILE *fp, float *data, unsigned long int tot, float scale)
 Write a Block of Floats.
unsigned long int WriteDataBlock (FILE *fp, int *data, unsigned long int tot, float scale)
 Write a Block of ints.
unsigned long int WriteDataBlock (FILE *fp, short *data, const unsigned long int tot, const float scale)
 Write a Block of shorts.
unsigned long int WriteDataBlock (FILE *fp, char *data, const unsigned long int tot, const float scale)
 Write a block of chars.
template<unsigned int LEN>
unsigned long int WriteDataBlock (FILE *fp, SimpleTVec< short, LEN > *data, const unsigned long int tot, double scale)
 Write a Fixed length vector of shorts.
unsigned long int WriteDataBlock (FILE *fp, SimpleVTVec< short, unsigned int > *data, const unsigned long int tot, double scale)
 Write a Variable length vector of shorts.
template<unsigned int LEN>
unsigned long int WriteDataBlock (FILE *fp, SimpleTVec< unsigned short, LEN > *data, const unsigned long int tot, double scale)
 Write a Fixed length vector of unsigned shorts.
template<unsigned int LEN>
unsigned long int WriteDataBlock (FILE *fp, SimpleVTVec< unsigned short > *data, const unsigned long int tot, double scale)
 Write a Variable length vector of unsigned shorts.
template<unsigned int LEN>
unsigned long int WriteDataBlock (FILE *fp, SimpleTVec< int, LEN > *data, const unsigned long int tot, double scale)
 Write a Fixed length vector of ints.
unsigned long int WriteDataBlock (FILE *fp, SimpleVTVec< int > *data, unsigned long int tot, double scale)
 Write a Variable length vector of ints.
template<unsigned int LEN>
unsigned long int WriteDataBlock (FILE *fp, SimpleTVec< unsigned int, LEN > *data, const unsigned long int tot, double scale)
 Write a Fixed length vector of unsigned ints.
unsigned long int WriteDataBlock (FILE *fp, SimpleVTVec< unsigned int > *data, unsigned long int tot, double scale)
 Write a Variable length vector of unsigned ints.
template<unsigned int LEN>
unsigned long int WriteDataBlock (FILE *fp, SimpleTVec< float, LEN > *data, const unsigned long int tot, double scale)
 Write a Fixed length vector of floats.
unsigned long int WriteDataBlock (FILE *fp, SimpleVTVec< float > *data, unsigned long int tot, double scale)
 Write a Variable length vector of floats.
template<unsigned int LEN, unsigned int LEN2>
unsigned long int WriteDataBlockVV (FILE *fp, SimpleTVec< SimpleTVec< float, LEN >, LEN2 > *data, const unsigned long int tot, const double scale)
 Write a Fixed length vector of fixed length vectors of floats.
template<unsigned int LEN, unsigned int LEN2>
unsigned long int WriteDataBlock (FILE *fp, SimpleTMat< float, LEN, LEN2 > *data, unsigned long int tot, double scale)
 Write a Fixed size matrix of floats.
unsigned long int WriteDataBlock (FILE *fp, SimpleVTMat< float > *data, unsigned long int tot, double scale)
 Write a Variable size matrix of floats.
unsigned long int WriteDataBlock (FILE *fp, SimpleVTMat< short > *data, unsigned long int tot, double scale)
 Write a Variable size matrix of short.
FILE * ReadGIPLHEAD (BasicHeader &im1, char *name, int &offset)
 Read a GIPL File Header.
bool SimpleReadTiming (FILE *fp, BasicHeader &im1, unsigned long int datasize=0)
 Read Slice Timing Info from Extended GIPL File.
float MIDASFloatRead (int argc, char **argv, const char *tag, float def)
 Read Floating Point Number from Midas header.
void MIDASStringRead (int argc, char **argv, const char *tag, char *out)
 Read String from Midas header.
FILE * ReadMidasHEAD (BasicHeader &mh, char *name)
 Read an Midas Header From a File and Return Pointer to Data File to Read Voxels From.
FILE * ReadMayoHEAD (BasicHeader &mh, char *name, int &offset)
 Read Mayo/Analyze Header Data and Return Pointer to Voxel Data.
FILE * ReadNiftiHEAD (BasicHeader &mh, char *name, int &offset)
 Read NIFTI data header Format and return file pointer to Voxel Data File.
int FindHDFTag (char *name, int &length, int TagVal, int DDBstart=4)
 Find a Tag in a HDF Header.
FILE * ReadHDFHEAD (BasicHeader &mh, char *name, int &offset)
 Read HDF Header Info and return File Pointer to start of Voxel Data.
FILE * ReadOLDBSplineHEAD (BasicHeader &mh, char *name)
 Read Old BSpline Data Format.
int FixNans (const float *data, const unsigned int tot, float fixval=0)
 Check and Fix NANS and Overflows etc.
unsigned long int ReadDataBlock (FILE *fp, float *data, unsigned long int tot, double scale, int dftype, int offset=0, int fixNANS=(1==1))
 Read Block of Float Data.
int ReadDataBlock (FILE *fp, int *data, unsigned int tot, double scale, int dftype, int offset=0, int fixNANS=(1==1))
 Read Block of Int 32 Data.
int ReadDataBlock (FILE *fp, short *data, unsigned int tot, double scale, int dftype, int offset=0, int fixNANS=(1==1))
 Read Block of Short Data.
int ReadDataBlock (FILE *fp, char *data, unsigned int tot, double scale, int dftype, int offset=0, int fixNANS=(1==1))
 Read Block of Char Data.
template<typename T , unsigned int LEN>
int ReadDataBlock (FILE *fp, SimpleTVec< T, LEN, unsigned int > *data, unsigned long int totVec, float scale, int dftype, int offset=0)
 Read Vector Data.
template<typename T >
int ReadDataBlock (FILE *fp, SimpleVTVec< T, unsigned int > *data, unsigned long int totVec, float scale, int dftype, int offset=0)
 Read Block of Variable Sized Vectors of type T.
template<typename T , unsigned int LEN1, unsigned int LEN2>
int ReadDataBlock (FILE *fp, SimpleTMat< T, LEN1, LEN2 > *data, unsigned long int totMat, float scale, int dftype, int offset=0)
 Read Block of Fixed Sized Matrices of type T.
template<typename T >
int ReadDataBlock (FILE *fp, SimpleVTMat< T, unsigned int > *data, unsigned long int totMat, float scale, int dftype, int offset=0)
 Read Block of Variable Sized Matrices of type T.
template<typename T >
void ReadOrient (T *_dataV, BasicHeader &hd)
 Reorient Data to Standardize After Loading.
template<typename T >
void ReadOrient (T *_dataV, int nx, int ny, int nz, int nt)
 Apply Reorientation to Standardize Voxel Order After Reading.
template<typename T >
void RawReflectX (T *_dataV, int nx, int ny, int nz, int nt)
 Reflect Volume Data Along X Axis.
template<typename T >
void RawReflectY (T *_dataV, int nx, int ny, int nz, int nt)
 Reflect Volume Data Along Y Axis.
template<typename T >
void RawReflectZ (T *_dataV, int nx, int ny, int nz, int nt)
 Reflect Volume Data Along Z Axis.
template<typename T >
void RawSwapXY (T *_dataV, BasicHeader &hd)
 Swap X and Y Axes of Volume Data.
template<typename T >
void RawSwapXZ (T *_dataV, BasicHeader &hd)
 Swap X and Z Axes of Volume Data.

Detailed Description

Voxel Input/Output Class.

Basic Voxel File IO Functions to and from 3D medical image formats
Handles Byte Swapping to Machine Order (See ReadDataType.h)

Currently Loads:
GIPL (.gipl),
Mayo Analyze (.hdr/img)
MIDAS (.mdh/.vol)
NIFTI (.nii,.ni1)
HDF (.hdf) (16 bit and 8 bit unsigned integers only)
Older BSPline Data formats (.grd)

Currently Saves: GIPL and Midas formats

Handles Conversion from File Data type (float/int/short/char) to memory type

Decompresses unix compressed .Z files into memory (using ReadData.h)

Reads Vectors and matrices as 4D gipl/analyze/midas data

Id:
SimpleVoxIO.h,v 1.46 2012/01/30 20:40:53 mads Exp

Constructor & Destructor Documentation

SimpleVoxIO::SimpleVoxIO ( ) [inline]

Flag Indicating Scanner Coordinates Known From File.

Default Constructor


Member Function Documentation

template<typename T , unsigned int LEN>
int SimpleVoxIO::ReadDataBlock ( FILE *  fp,
SimpleTVec< T, LEN, unsigned int > *  data,
unsigned long int  totVec,
float  scale,
int  dftype,
int  offset = 0 
) [inline, protected]

Read Vector Data.

Assumes Vector elements are stored in sequential volumetric frames Reads and Packs into individual vector components Only short,float and ASCII File element types supported so far! Read Vector Data Into Raw Array of Vectors Accepts Base Class Vector to work with Variable and Fixed Length vector Types

BUT: Assumes Vectors are all same length in field! AND: Vectors are Same Length as Memory Type! Read Block of Fixed Sized Vectors of type T

template<typename T , unsigned int LEN1, unsigned int LEN2>
int SimpleVoxIO::ReadDataBlock ( FILE *  fp,
SimpleTMat< T, LEN1, LEN2 > *  data,
unsigned long int  totMat,
float  scale,
int  dftype,
int  offset = 0 
) [inline, protected]

Read Block of Fixed Sized Matrices of type T.

Accepts Base Class Matrix to work with Variable and Fixed Length matrices

BUT: Assumes Matrices are all same shape in field! AND: Matrices in memory are same size as on Disk!

 All Classes Functions Variables Typedefs