Public Member Functions | Private Member Functions | Private Attributes | List of all members
vil_dicom_header_format Class Reference

A class to read and write the header part of a dicom file. More...

#include <vil_dicom_header.h>

Public Member Functions

 vil_dicom_header_format ()
 
 ~vil_dicom_header_format ()
 
bool isDicomFormat (vil_stream &)
 True if it is known DICOM format. More...
 
vil_dicom_header_info readHeader (vil_stream &fs)
 Read the dicom header into a header struct. More...
 
vil_dicom_header_info lastHeader (void)
 Method to return the last struct of header info set. More...
 
bool headerValid (void)
 Method to indicate if the header info held is valid or not. More...
 
vil_dicom_header_endian systemEndian (void)
 Return the current system endian. More...
 
vil_dicom_header_endian fileEndian (void)
 Return the endian of the header being read. More...
 
vil_dicom_header_image_type imageType (void)
 Return any encapsulated image type. More...
 

Private Member Functions

vil_dicom_header_type determineFileType (vil_stream &fs)
 Method to determine the file type. More...
 
void readHeaderElements (vil_stream &fs)
 Method to read the elements from the header. More...
 
void readIdentifyingElements (short element, int dblock_size, vil_stream &fs)
 Method to read the identifying group's details. More...
 
void readPatientElements (short element, int dblock_size, vil_stream &fs)
 Method to read the patient details. More...
 
void readAcquisitionElements (short element, int dblock_size, vil_stream &fs)
 Method to read the acquisition group's details. More...
 
void readRelationshipElements (short element, int dblock_size, vil_stream &fs)
 Method to read the relationship group's details. More...
 
void readImageElements (short element, int dblock_size, vil_stream &fs)
 Method to read the image group's details. More...
 
void readDelimiterElements (short element, int dblock_size, vil_stream &fs)
 Method to read the delimiter group's details. More...
 
void readProcedureElements (short element, int dblock_size, vil_stream &fs)
 Method to read the procedure group's details. More...
 
void readNSPhilipsElements (short element, int dblock_size, vil_stream &fs)
 Method to read the (non-standard, private) Philips group details. More...
 
bool convertValueRepresentation (unsigned int &dblock_size, vil_stream &ifs)
 Method to convert the Value Representation (VR) (if it exists). More...
 
bool pixelDataFound (short group, short element)
 Method to determine whether or not the actual pixel data has been reached. More...
 
void clearInfo (void)
 
vil_dicom_header_endian calculateEndian (void)
 Work out whether the current architecture is big or little endian. More...
 
vil_dicom_header_endian determineMetaInfo (vil_stream &fs)
 Initialise all the necessary meta-file stuff. More...
 
vxl_uint_16 shortSwap (vxl_uint_16 short_in)
 Method to byte swap an unsigned short int if necessary. More...
 
vxl_uint_32 intSwap (vxl_uint_32 int_in)
 Method to byte swap an unsigned int if necessary. More...
 
void charSwap (char *char_in, int val_size)
 Method to swap a number inside a char array. More...
 

Private Attributes

vil_dicom_header_info last_read_
 Holds the info from the last header read. More...
 
bool info_valid_
 TRUE if the header info is valid (i.e. has been read) otherwise FALSE. More...
 
vil_dicom_header_endian endian_
 A variable to hold the discovered architecture endian. More...
 
vil_dicom_header_endian file_endian_
 A variable to hold the current header file's endian. More...
 
vil_dicom_header_image_type image_type_
 A variable to hole the current encapsulate file type (if any). More...
 

Detailed Description

A class to read and write the header part of a dicom file.

This class reads and writes the header section of a dicom file, determining the type and storing the information in a dicom structure.

Definition at line 489 of file vil_dicom_header.h.

Constructor & Destructor Documentation

◆ vil_dicom_header_format()

vil_dicom_header_format::vil_dicom_header_format ( )

◆ ~vil_dicom_header_format()

vil_dicom_header_format::~vil_dicom_header_format ( )

Member Function Documentation

◆ calculateEndian()

vil_dicom_header_endian vil_dicom_header_format::calculateEndian ( void  )
private

Work out whether the current architecture is big or little endian.

Returns
The system endian value calculated
See also
systemEndian() and endian_()

◆ charSwap()

void vil_dicom_header_format::charSwap ( char *  char_in,
int  val_size 
)
private

Method to swap a number inside a char array.

Parameters
char_inThe char array to swap - on exit contains the result
val_sizeThe size of the var to swap

◆ clearInfo()

void vil_dicom_header_format::clearInfo ( void  )
private

◆ convertValueRepresentation()

bool vil_dicom_header_format::convertValueRepresentation ( unsigned int &  dblock_size,
vil_stream ifs 
)
private

Method to convert the Value Representation (VR) (if it exists).

Parameters
data_blockContains the VR or data block size (always holds the data block size on exit
fsThe file stream to read from
See also
readHeaderElements()

◆ determineFileType()

vil_dicom_header_type vil_dicom_header_format::determineFileType ( vil_stream fs)
private

Method to determine the file type.

Parameters
fsThe file stream for the image to test
Returns
The dicom file type or unknown

◆ determineMetaInfo()

vil_dicom_header_endian vil_dicom_header_format::determineMetaInfo ( vil_stream fs)
private

Initialise all the necessary meta-file stuff.

Returns
The endian of the file
See also
fileEndian(), file_endian_(), imageType(), and image_type_();

◆ fileEndian()

vil_dicom_header_endian vil_dicom_header_format::fileEndian ( void  )

Return the endian of the header being read.

Returns
The endian of the file currently being read.
See also
determineMetaInfo() and file_endian_()

◆ headerValid()

bool vil_dicom_header_format::headerValid ( void  )

Method to indicate if the header info held is valid or not.

Returns
TRUE if the header info is valid, otherwise false

◆ imageType()

vil_dicom_header_image_type vil_dicom_header_format::imageType ( void  )

Return any encapsulated image type.

Returns
The encapsulated image type of the file currently being read.

◆ intSwap()

vxl_uint_32 vil_dicom_header_format::intSwap ( vxl_uint_32  int_in)
private

Method to byte swap an unsigned int if necessary.

Parameters
int_inThe unsigned int to swap
Returns
The swapped unsigned int
See also
shortSwap() and charSwap()

◆ isDicomFormat()

bool vil_dicom_header_format::isDicomFormat ( vil_stream )

True if it is known DICOM format.

◆ lastHeader()

vil_dicom_header_info vil_dicom_header_format::lastHeader ( void  )

Method to return the last struct of header info set.

The class holds a dicom header info struct containing the info from the last dicom file read.

Returns
A dicom header struct containing the info gained from the last header read

◆ pixelDataFound()

bool vil_dicom_header_format::pixelDataFound ( short  group,
short  element 
)
private

Method to determine whether or not the actual pixel data has been reached.

Parameters
groupThe current group to test
elementThe element within that group
Returns
TRUE if it is the pixel data, otherwise false
See also
readHeaderElements()

◆ readAcquisitionElements()

void vil_dicom_header_format::readAcquisitionElements ( short  element,
int  dblock_size,
vil_stream fs 
)
private

Method to read the acquisition group's details.

Fills the acquisition details in the last_read_ structure from the file header

Parameters
elementThe element being read in the acquisition group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also
readHeaderElements(), readIdentifyingElements(), readPatientElements(), readRelationshipElements(), readImageElements(), readDelimiterElements() and last_read_()

◆ readDelimiterElements()

void vil_dicom_header_format::readDelimiterElements ( short  element,
int  dblock_size,
vil_stream fs 
)
private

Method to read the delimiter group's details.

Certain field in the delimiter group have no data block, and so should not be skipped. This method takes the appropriate action - to skip or not to skip

Parameters
elementThe element being read in the delimiter group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also
readHeaderElements(), readIdentifyingElements(), readPatientElements(), readAcquisitionElements(), readRelationshipElements(), readImageElements() and last_read_()

◆ readHeader()

vil_dicom_header_info vil_dicom_header_format::readHeader ( vil_stream fs)

Read the dicom header into a header struct.

Reads the header section of the dicom file and stores the result in a header struct, which it returns. When finished, the file stream should be pointing at the start of the image data

Parameters
fsThe file stream to read - on exit points to the start of the image data
Returns
A dicom header struct containing the info gained from the header
See also
lastHeader(), headerValid(), last_read_() and info_valid_()

◆ readHeaderElements()

void vil_dicom_header_format::readHeaderElements ( vil_stream fs)
private

Method to read the elements from the header.

This method fills the last_read_ header structure with the necessary fields

Parameters
fsThe file stream to read from
See also
readIdentifyingElements(), readPatientElements(), readAcquisitionElements(), readRelationshipElements(), readImageElements, readDelimiterElements(), readHeader() and last_read_()

◆ readIdentifyingElements()

void vil_dicom_header_format::readIdentifyingElements ( short  element,
int  dblock_size,
vil_stream fs 
)
private

Method to read the identifying group's details.

Fills the identifying details in the last_read_ structure from the file header

Parameters
elementThe element being read in the identifying group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also
readHeaderElements(), readPatientElements(), readAcquisitionElements(), readRelationshipElements(), readImageElements(), readDelimiterElements() and last_read_()

◆ readImageElements()

void vil_dicom_header_format::readImageElements ( short  element,
int  dblock_size,
vil_stream fs 
)
private

Method to read the image group's details.

Fills the image details in the last_read_ structure from the file header

Parameters
elementThe element being read in the image group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also
readHeaderElements(), readIdentifyingElements(), readPatientElements(), readAcquisitionElements(), readRelationshipElements(), readDelimiterElements() and last_read_()

◆ readNSPhilipsElements()

void vil_dicom_header_format::readNSPhilipsElements ( short  element,
int  dblock_size,
vil_stream fs 
)
private

Method to read the (non-standard, private) Philips group details.

Parameters
elementThe element being read in the image group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also
readHeaderElements(), readIdentifyingElements(), readPatientElements(), readAcquisitionElements(), readRelationshipElements(), readDelimiterElements() readProcedureElements(), readNSPhilipsElements() and last_read_()

◆ readPatientElements()

void vil_dicom_header_format::readPatientElements ( short  element,
int  dblock_size,
vil_stream fs 
)
private

Method to read the patient details.

Fills the patient details in the last_read_ structure from the file header

Parameters
elementThe element being read in the patient group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also
readHeaderElements(), readIdentifyingElements(), readAcquisitionElements(), readRelationshipElements(), readImageElements(), readDelimiterElements() and last_read_()

◆ readProcedureElements()

void vil_dicom_header_format::readProcedureElements ( short  element,
int  dblock_size,
vil_stream fs 
)
private

Method to read the procedure group's details.

Parameters
elementThe element being read in the image group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also
readHeaderElements(), readIdentifyingElements(), readPatientElements(), readAcquisitionElements(), readRelationshipElements(), readDelimiterElements() readProcedureElements() and last_read_()

◆ readRelationshipElements()

void vil_dicom_header_format::readRelationshipElements ( short  element,
int  dblock_size,
vil_stream fs 
)
private

Method to read the relationship group's details.

Fills the relationship details in the last_read_ structure from the file header

Parameters
elementThe element being read in the relationship group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also
readHeaderElements(), readIdentifyingElements(), readPatientElements(), readAcquisitionElements(), readImageElements(), readDelimiterElements() and last_read_()

◆ shortSwap()

vxl_uint_16 vil_dicom_header_format::shortSwap ( vxl_uint_16  short_in)
private

Method to byte swap an unsigned short int if necessary.

Parameters
short_inThe unsigned short to swap
Returns
The swapped unsigned short
See also
intSwap() and charSwap()

◆ systemEndian()

vil_dicom_header_endian vil_dicom_header_format::systemEndian ( void  )

Return the current system endian.

Returns
The system endian for the architecture running the application

Member Data Documentation

◆ endian_

vil_dicom_header_endian vil_dicom_header_format::endian_
private

A variable to hold the discovered architecture endian.

See also
calculateEndian() and systemEndian()

Definition at line 745 of file vil_dicom_header.h.

◆ file_endian_

vil_dicom_header_endian vil_dicom_header_format::file_endian_
private

A variable to hold the current header file's endian.

See also
determineMetaInfo() and fileEndian()

Definition at line 750 of file vil_dicom_header.h.

◆ image_type_

vil_dicom_header_image_type vil_dicom_header_format::image_type_
private

A variable to hole the current encapsulate file type (if any).

See also
determineMetaInfo() and imageType()

Definition at line 755 of file vil_dicom_header.h.

◆ info_valid_

bool vil_dicom_header_format::info_valid_
private

TRUE if the header info is valid (i.e. has been read) otherwise FALSE.

See also
readHeader(), lastHeader(), headerValid(), clearInfo() and last_read_()

Definition at line 740 of file vil_dicom_header.h.

◆ last_read_

vil_dicom_header_info vil_dicom_header_format::last_read_
private

Holds the info from the last header read.

See also
readHeader(), lastHeader(), headerValid(), clearInfo(), readHeaderElements() and info_valid_()

Definition at line 735 of file vil_dicom_header.h.


The documentation for this class was generated from the following file: