public class SoVRDicomFileReader extends SoVolumeReader
DICOM is a widely used format for storing medical image data (CT, MRI, etc), defined by the National Electrical Manufacturers Association (NEMA) (
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()). Loading a volume from a list of DICOM files can be done by:
setFilenamePattern()
.
setFilenameListFromSeries()
.
setDirectory()
.
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:
SoDataRange
and SoTransferFunction
nodes. The application will normally use the DICOM Window Center and Window Width values to set the SoDataRange
. For SoTransferFunction
the application can use the predefined light to dark color map INTENSITY_REVERSED for displaying single images.
SoDataRange
and SoTransferFunction
nodes. The application will normally use the DICOM Window Center and Window Width values to set the SoDataRange
. For SoTransferFunction
the application can use the predefined dark to light color map INTENSITY for displaying single images.
SoDataRange
and SoTransferFunction
have no effect on an RGBA volume.
SoDataRange
and SoTransferFunction
have no effect on an RGBA volume.
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:
Use an 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:
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 DICOM Attributes
All DICOM attributes, including hierarchical data like Structured Reports, can be traversed and queried using
See also:
Data Range:
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.
Coordinate Systems:
SoVRDicomData
object (see getDicomData()
) or an SiDicomDataSet
object (see getDicomDataSet()
).
Also called XYZ coordinates. This is the Cartesian coordinate system in which rendering objects (volumes, geometry), cameras, lights, etc. are positioned. In Open Inventor this is a right-handed coordinate system (same as OpenGL). The default camera creates a view look down the Z axis, i.e. +Z is toward the user, +X is to the right and +Y is up.
Also called "IJK" coordinates. Each voxel's position in the volume can be described by an IJK coordinate. In VolumeViz this is also a right-handed coordinate system, corresponding to the positive XYZ axes, i.e. in the default camera's view K is toward the user, I is to the right and J is up. You can convert between IJK and XYZ coordinates based on the volume dimensions and extent or use the conversion methods provided in the SoVolumeData
class, e.g. voxelToXYZ().
SoOrthoSlice
node. See the dicomImageViewer example in the examples/source/Medical/Input directory.
SiDicomDataSet
(see getDicomDataSet()
). See the DicomSimpleViewer example in the examples/source/VolumeViz/examples directory.
SoVolumeReader.Axis, SoVolumeReader.CoordinateTypes, SoVolumeReader.CopyPolicies, SoVolumeReader.DataInfo, SoVolumeReader.ReadErrors, SoVolumeReader.ReaderTypes, SoVolumeReader.SubVolumeInfo
Inventor.ConstructorCommand
AM, AVS, COORDINATES_RECTILINEAR, COORDINATES_UNIFORM, COPY, DICOM, GENERIC, LDM, MEMORY, NO_COPY, NO_READER, RASTERSTACK, RD_FILE_FORMAT_NOT_VALID_ERROR, RD_FILE_NOT_FOUND_ERROR, RD_INVALID_DATA_ERROR, RD_NO_ERROR, RD_UNKNOWN_ERROR, RD_UNSUPPORTED_DATA_TYPE_ERROR, SEGY, TIFF, VOL, VOX, X, Y, Z
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoVRDicomFileReader()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
SoVRDicomData |
getDicomData()
Returns an instance of
SoVRDicomData for the first image of this volume. |
SiDicomDataSet |
getDicomDataSet(long sliceIdx)
Returns a DICOM data object for the specified slice containing all the DICOM attributes.
|
boolean |
setDirectory(java.lang.String folder)
Specify a directory containing DICOM files to load.
|
boolean |
setFilenameList(java.lang.String format)
Calls setFilenameList(format, (int)0, Integer.MAX_VALUE, (int)1).
|
boolean |
setFilenameList(java.lang.String format,
int startIndex)
Calls setFilenameList(format, startIndex, Integer.MAX_VALUE, (int)1).
|
boolean |
setFilenameList(java.lang.String format,
int startIndex,
int endIndex)
Calls setFilenameList(format, startIndex, endIndex, (int)1).
|
boolean |
setFilenameList(java.lang.String format,
int startIndex,
int endIndex,
int indexStep)
Specify a list of DICOM files to load, using a sprintf-like format.
|
boolean |
setFilenameListFromSeries(java.lang.String 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).
|
int |
setFilenamePattern(java.lang.String pattern)
Specify a pattern of DICOM files to load.
|
closeAllHandles, getAppropriateReader, getBorderFlag, getConfiguredWriter, getCoordinateType, getCurrentTimeStep, getDataChar, getDirectCoordSys, getDirectCoordSysAutoDetection, getDoubleMinMax, getFilename, getIntMinMax, getMinMax, getNumSignificantBits, getNumSubsampledTiles, getNumTimeSteps, getNumVoxels, getOriginalFilename, getReaderType, getShortTileSize, getSizeToAllocate, getSubSlice, getSubVolumeInfo, getTileMinMax, getTileSize, isDataConverted, isIgnoredFile, isRGBA, isThreadSafe, readTile, readTile, restoreAllHandles, setCurrentTimeStep, setDirectCoordSysAutoDetection, setDirectCoorSys, setFilename, setInputDataRange, setOutputDataType, setRectilinearCoordinates, setRGBA
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
dispose, getEXTERNPROTO, getName, getPROTO, isDisposable, isSynchronizable, setName, setSynchronizable, touch
getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
public boolean setFilenameList(java.lang.String format)
public boolean setFilenameList(java.lang.String format, int startIndex)
public boolean setFilenameList(java.lang.String format, int startIndex, int endIndex)
public int setFilenamePattern(java.lang.String pattern)
pattern
- e.g. "data_directory/image_file*.dcm"
public boolean setDirectory(java.lang.String folder)
All the DICOM files in the specified directory should be part of the same volume data set. If not, the results are undefined.
folder
- The folder from which to load files.
public SoVRDicomData getDicomData()
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 the getDicomDataSet()
method.
public boolean setFilenameListFromSeries(java.lang.String base)
base
- The path to a DICOM image file.
public SiDicomDataSet getDicomDataSet(long sliceIdx)
sliceIdx
- The index of the slice to extract the dataset from.
public boolean setFilenameList(java.lang.String format, int startIndex, int endIndex, int indexStep)
format
- The format of the file name, which must be an absolute file path. 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, ...)
Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com