SoVRDicomFileReader Class Reference
[Readers]

VolumeViz DICOM file reader. More...

#include <VolumeViz/readers/SoVRDicomFileReader.h>

Inheritance diagram for SoVRDicomFileReader:
SoVolumeReader SoFieldContainer SoBase SoRefCounter SoTypedObject

List of all members.

Public Member Functions

virtual SoType getTypeId () const
 SoVRDicomFileReader ()
virtual int setFilename (const SbString &filename)
int setFilenamePattern (const SbString &pattern)
int setFilenameList (const SbStringList &filenameList)
SbBool setFilenameList (const SbString &format, const int startIndex=0, const int endIndex=INT_MAX, const int indexStep=1)
bool setFilenameListFromSeries (const SbString &base)
void loadInMemory ()
SbBool setDirectory (const SbString &folder)
virtual ReadError getDataChar (SbBox3f &size, SoDataSet::DataType &type, SbVec3i32 &dim)
virtual SbBool setOutputDataType (SbBool doChange, SoDataSet::DataType type)
virtual void getSubSlice (const SbBox2i32 &subSlice, int sliceNumber, void *data)
int getNumSignificantBits ()
virtual SoVolumeReader::ReaderType getReaderType ()
const SoVRDicomDatagetDicomData () const
const SiDicomDataSetgetDicomDataSet (const size_t sliceIdx) const
void loadSliceDicomData (int slice, SoVRDicomData &dicomData) const
virtual SbBool isThreadSafe () const
virtual void closeAllHandles ()
virtual void restoreAllHandles ()

Static Public Member Functions

static SoType getClassTypeId ()

Detailed Description

VolumeViz DICOM file reader.

Volume reader for the DICOM file format. VolumeViz automatically selects this reader if a filename is given and the file extension is ".dc3", ".dic", ".dcm", or ".dicom".

DICOM is a widely used format for storing medical image data (CT, MRI, etc), defined by the National Electrical Manufacturers Association (NEMA) (http://medical.nema.org).

SoVRDicomFileReader can load a volume from a single DICOM file or from a list of DICOM files (stack of images). Loading a volume from a single DICOM file is the same as loading any other format supported by VolumeViz (see setFilename(const SbString& filename)). Loading a volume from a list of DICOM files can be done by:

Unlike a raster stack, the position of each slice in a DICOM volume is determined by the location value in its file header and not by the order of the file name in the list. Also unlike a raster stack consisting of (for example) JPEG or PNG images, a DICOM file in the list may contain more than one slice of the volume. The reader handles this automatically. The first file in the list is considered the "reference" for the volume and all slices must be compatible with this one. Specifically this means that subsequent files must have the same width, height, data type and so on.

Note when using a list file: If the file extension is not ".dc3", ".dic" or ".dicom" VolumeViz will not automatically select the DICOM volume reader. You can either give the list file one of the DICOM file extensions or force VolumeViz to use the DICOM reader by explicitly creating an instance of SoVRDicomFileReader and calling the SoVolumeData method setReader().

The volume reader will automatically get the volume dimensions, data type, extent (voxel size/spacing) and number of significant bits from the DICOM file header. The reader will also apply the data adjustment (if any) specified by the RescaleSlope and RescaleIntercept tags in the DICOM file header, i.e.: actualValue = slope * storedValue + intercept. As part of this process the reader will automatically convert unsigned data to the corresponding signed data type if necessary (in other words if the rescale calculation produces negative values). The application can also explicitly specify the volume data type. This allows, for example, converting float data values to more compact integer values.
Note: The DICOM reader only uses the rescale slope and intercept values from the first file in the list. It does not currently handle the (less common) case where each file contains different rescale values.

Photometric Interpretation:

Volume extent:

The volume reader will compute the volume's width in X and height in Y from the volume dimensions and the voxel size. For example, if the volume dimension in X is 512 (voxels) and the voxel size in X is 0.408 mm, then the volume width is (approximately) 209 mm. The reader will compute the volume's depth in Z from the min and max slice locations specified in the file header(s). Note that for a DICOM data set, the volume 'position' is considered to be the center of the first voxel, however VolumeViz considers the volume extent (SoVolumeData::extent) to include all of the first and last voxels. Therefore the extent 'min' is alwaya the outside corner of the first voxel.

NOTE: By default, the reader does not consider the DICOM volume origin (Image Position Patient attribute) when setting the volume extent. The volume extent set by the reader is always centered at 0,0,0 in 3D world coordinates. There are two options to get the volume correctly positioned in 3D space:
  • Call the MedicalHelper method dicomAdjustVolume() after setting the files to be loaded. (Recommended)
  • Set the preference variable VOLUMEVIZ_CENTERED_DICOM to false (default is true).

Data Range:

Use an SoDataRange node to specify the actual (or desired) range of data values to be mapped. For example, a typical initial data range for DICOM data calibrated in Hounsfield units might be -1000 to 3000.

NOTE: By default, VolumeViz does not use the Window Center and Window Width values (if any) in the DICOM image file. Instead it maps the entire range of the voxel's data type (e.g. 0..65535 for unsigned short) into the colormap. There are two options to use the data range specified in the image file:

Coordinate Systems:

In a medical imaging application there are at least three related coordinate systems.

In other words, the default camera view is looking at the top of the head with the body "face down".

NOTE: By default Open Inventor does not display DICOM images with the usual orientation. A convenient way to get the standard DICOM view orientations is to use the MedicalHelper method orientView(). This method is useful for orienting the camera to view along one of the standard medical axes (Axial, Coronal or Sagittal).

When viewing a slice, also remember that the volume is always a 3D object to Open Inventor and you must also set the 'axis' field on the SoOrthoSlice node. See the dicomImageViewer example in the examples/source/Medical/Input directory.

DICOM Attributes

All DICOM attributes, including hierarchical data like Structured Reports, can be traversed and queried using SiDicomDataSet (see getDicomDataSet()). See the DicomSimpleViewer example in the examples/source/VolumeViz/examples directory.

SEE ALSO

SoVRDicomData, SiDicomDataSet

See related examples:

MedicalDicomReader, MedicalDTIViewer, MedicalFreeHandCutting


Constructor & Destructor Documentation

SoVRDicomFileReader::SoVRDicomFileReader (  ) 

Constructor.


Member Function Documentation

virtual void SoVRDicomFileReader::closeAllHandles (  )  [virtual]

Close all file handles currently opened by the reader.

See also:
restoreAllHandles

Reimplemented from SoVolumeReader.

static SoType SoVRDicomFileReader::getClassTypeId (  )  [static]

Returns the type identifier for this class.

Reimplemented from SoVolumeReader.

virtual ReadError SoVRDicomFileReader::getDataChar ( SbBox3f size,
SoDataSet::DataType type,
SbVec3i32 dim 
) [virtual]

Gets the characteristics (file header) of the data volume.

See SoVolumeData. size is the size of the actual volume. type is the type of the data. dim is the dimension of the data.

Implements SoVolumeReader.

const SoVRDicomData& SoVRDicomFileReader::getDicomData (  )  const

Returns an instance of SoVRDicomData for the first image of this volume.

Note that the first image of the volume does not necessarily correspond to first file of file list. Images are automatically sorted using the Image Postion Patient attribute.

This object can be queried for DICOM specific info, using for example the SoVRDicomData::getDicomInfo() method.

To conveniently access the DICOM attributes, see getDicomDataSet() method.

const SiDicomDataSet* SoVRDicomFileReader::getDicomDataSet ( const size_t  sliceIdx  )  const

Returns a DICOM data object for the specified slice containing all the DICOM attributes.

Parameters:
sliceIdx The index of the slice to extract the dataset from.
Returns:
A pointer to a new dataset object, that must be deleted by the application. Returns NULL if an error occured.
int SoVRDicomFileReader::getNumSignificantBits (  )  [virtual]

This method is optional.

It returns the number of significant bits of the volume data.

If it is not implemented, the default return value is 0, meaning the number of bits depends on the data type. See the last parameter of SoVolumeData::setVolumeData(). This method is called immediately after getDataChar().

Reimplemented from SoVolumeReader.

virtual SoVolumeReader::ReaderType SoVRDicomFileReader::getReaderType (  )  [inline, virtual]

Returns the reader type.

Reimplemented from SoVolumeReader.

virtual void SoVRDicomFileReader::getSubSlice ( const SbBox2i32 subSlice,
int  sliceNumber,
void *  data 
) [virtual]

New method required by VolumeViz 3.0 when using large volume support.

Must copy a rectangular part of an XY slice to the memory specified by data. Slices will not always be read sequentially.

Implements SoVolumeReader.

virtual SoType SoVRDicomFileReader::getTypeId (  )  const [virtual]

Returns the type identifier for this specific instance.

Reimplemented from SoVolumeReader.

virtual SbBool SoVRDicomFileReader::isThreadSafe (  )  const [virtual]

SoVRDicomFileReader is thread safe.

Reimplemented from SoVolumeReader.

void SoVRDicomFileReader::loadInMemory (  ) 

Load the DICOM data into contiguous memory if possible.

Once the data is loaded, no additional file I/O is necessary and data access calls to the reader, e.g. getSubSlice(), will be fast.

Example:

 SoVRDicomFileReader* volReader = new SoVRDicomFileReader();
 volReader->setFilename( VOLUME_FILENAME );
 volReader->loadInMemory();

 SoVolumeData* volData = new SoVolumeData();
 volData->setReader( *volReader );
 MedicalHelper::dicomAdjustVolume( volData );

Notes:

  • This is a blocking call (does not return until all data is loaded).
  • It is not currently possible to directly access the data in memory.
  • It is not currently possible to monitor the progress of the data loading.
  • It is not currently possible to test if the data loading succeeded.
  • Do NOT call this method before setting the data source (filename or directory).
  • Do NOT call this method with an invalid data filename or directory.
Since Open Inventor 10.3

void SoVRDicomFileReader::loadSliceDicomData ( int  slice,
SoVRDicomData dicomData 
) const

Loads the Dicom data of the given slice.

To conveniently access the DICOM attributes, see getDicomDataSet method.

virtual void SoVRDicomFileReader::restoreAllHandles (  )  [virtual]

Restore all file handles closed by closeAllHandles method.

See also:
closeAllHandles

Reimplemented from SoVolumeReader.

SbBool SoVRDicomFileReader::setDirectory ( const SbString folder  ) 

Specify a directory containing DICOM files to load.

Each file in this folder that has a supported extension (currently ".dc3", ".dic", ".dcm", or ".dicom") will be loaded. If the DICOM files have an unsupported extension, use the setFilenameList function instead.

All the DICOM files in the specified directory should be part of the same volume data set. If not, the results are undefined.

Parameters:
folder The folder from which to load files.
Returns:
true if successful.
Since Open Inventor 9.4.1

virtual int SoVRDicomFileReader::setFilename ( const SbString filename  )  [virtual]

Specify the name of a DICOM file or a file containing a list of DICOM files to load.

Using a list file is the same as loading a stack of images using the SoVRRasterStackReader except the list file should not contain any header. Each line in the list file may be a full path containing directory names or a simple file name. Simple file names are assumed to be in the same directory as the list file. The application can also specify a list of file paths using the setFilenameList() method. This is useful, for example, if the application user is allowed to select a list of files in a file selection dialog. All the specified files should be part of the same volume data set.

Returns 0 if successful.

Reimplemented from SoVolumeReader.

SbBool SoVRDicomFileReader::setFilenameList ( const SbString format,
const int  startIndex = 0,
const int  endIndex = INT_MAX,
const int  indexStep = 1 
)

Specify a list of DICOM files to load, using a sprintf-like format.

This will iterate from startIndex to endIndex (included) with increment of indexStep. For each step, this will add a file of name f, where f is format sprintf-ed with the current iteration index. All the specified files should be part of the same volume data set.

Parameters:
format The format of the file name, which must be an absolute file path.
e.g. "c:/testData/Brain.%04d.dcm", where "%04d" will be replaced by the current index, producing "c:/testData/Brain.0000.dcm" and so on.
startIndex The index of the first file to add
endIndex The index of the last file to add
indexStep the stride to use (e.g. 2 will skip one out of two files, by generating indices 0, 2, 4, ...)
Returns:
true if successful.
Since Open Inventor 9.4.1

int SoVRDicomFileReader::setFilenameList ( const SbStringList filenameList  ) 

Specify a list of DICOM files to load.

All the specified files should be part of the same volume data set. Returns 0 if successful.

Note: SbStringList is a list of pointers, not a list of objects, so the destructor for this class does not free the memory associated with the SbString objects. The application is responsible for deleting each object in the list.

Since Open Inventor 9.0

bool SoVRDicomFileReader::setFilenameListFromSeries ( const SbString base  ) 

Specify a DICOM file and load all image files in the same directory that are part of the same "series" based on the series UID (0x0020,0x000E).

Parameters:
base The path to a DICOM image file.
Returns:
true if successful.
int SoVRDicomFileReader::setFilenamePattern ( const SbString pattern  ) 

Specify a pattern of DICOM files to load.

Parameters:
pattern e.g. "data_directory/image_file*.dcm"
Returns:
0 if successful.
Since Open Inventor 9.8

virtual SbBool SoVRDicomFileReader::setOutputDataType ( SbBool  doChange,
SoDataSet::DataType  type 
) [virtual]

Requests that the input be converted (if necessary) to the specified data type.

This allows, for instance, conversion of float data to unsigned byte. By default no conversion is done. If doChange is FALSE no type conversion is done. Always returns TRUE.

Reimplemented from SoVolumeReader.


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

Open Inventor Toolkit reference manual, generated on 15 Mar 2023
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/