![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Dicom/DicomLoader.h>
The DicomLoader class loads images from DICOM files. More...
The DicomLoader class loads images from DICOM files.
A DicomLoader instance can be created from a single file or multiple files. Images with the same series instance UID are combined to volumes if possible. Each image is represented by a Dicom::IOD that structures all image related dicom tags. When loading multiple images, be aware that all images are loaded into the main memory at once. Therefore, it can be more efficient to load individual series with separate DicomLoader objects. A single series can be loaded by setting a series UID filter. However, this still needs to load all files first.
Example:
Paths passed to the constructor can be either local paths or URLs. Only the schemes "file:" and "pacs:" are supported. All others are handled as "file:". Paths to folders will be ignored.
If all frames in a series have the same SeriesInstanceUID, ImageType and SOP class, they are loaded as a single SharedImageSet. Otherwise a single series might be split into multiple SharedImageSets. A DICOM file that contains a NumberOfFrames value larger than 1, is always loaded as an individual SharedImageSet.
The DicomLoader uses Dicom::IOD_Registry to generate the Dicom::IOD instance(s) used for loading the image data. It also runs any enabled Extension that are part of the Dicom::IOD_Registry.
Example:
Classes | |
struct | RawBuffer |
Public Types | |
using | SharedImageSetDescriptor = std::vector<ImageDescriptor> |
![]() | |
using | ErrorCallback = std::function<void(const Error&)> |
Alias for a function to call for each error recorded. | |
Public Member Functions | |
DicomLoader (const std::string &path, Progress *progress=nullptr, Dicom::SharedDatasetCache cache=nullptr, std::shared_ptr< Dicom::IOD_Registry > registry=nullptr) | |
Creates a DicomLoader instance from a single file. | |
DicomLoader (const std::vector< std::string > &paths, Progress *progress=nullptr, Dicom::SharedDatasetCache cache=nullptr, std::shared_ptr< Dicom::IOD_Registry > registry=nullptr) | |
Creates a DicomLoader instance from multiple files. | |
DicomLoader (const std::vector< std::shared_ptr< DcmDataset > > &datasets, Progress *progress=nullptr, const std::vector< std::string > &paths=std::vector< std::string >(), std::shared_ptr< Dicom::IOD_Registry > registry=nullptr) | |
Creates a DicomLoader instance from existing DcmDatasets. | |
DicomLoader (std::shared_ptr< DcmDataset > dataset, Progress *progress=nullptr, std::shared_ptr< Dicom::IOD_Registry > registry={}) | |
Creates a DicomLoader instance from an existing DcmDataset. | |
DicomLoader (const std::vector< RawBuffer > &buffers, Progress *progress=nullptr, const std::vector< std::string > &paths=std::vector< std::string >(), std::shared_ptr< Dicom::IOD_Registry > registry=nullptr) | |
Creates a DicomLoader instance from buffers of DcmDatasets. | |
std::vector< std::unique_ptr< SharedImageSet > > | loadImages () |
Loads all images of all series. | |
std::vector< std::pair< std::unique_ptr< ImFusion::SharedImageSet >, OwningDataList > > | loadImagesWithAdditionalData () |
Loads all images of all series plus additional data (such as segmentations). | |
std::vector< SharedImageSetDescriptor > | loadDescriptors () |
Similar to loadImages but does not load any pixel data but only the ImageDescriptors. | |
void | setSeriesUidFilter (const std::string &filter) |
Only loads series that contain the given series UID. | |
void | setSplitVolumes (bool enable) |
Sets the flag whether loaded data should be split up for best support in the ImFusionSuite. | |
bool | splitsVolumes () const |
Returns the flag weather loaded data is prepared for best support in the ImFusionSuite. | |
void | setReconstructVolumes (bool enable) |
Sets the flag whether loaded data should be reconstructed to volumes if possible. | |
bool | reconstructionVolumes () const |
Returns whether loaded data will be reconstructed to volumes if possible. | |
void | setIgnoreDuplicateFrames (bool enable) |
Sets the flag whether frames that are consider duplicates of other frames are ignored. | |
bool | ignoreDuplicateFrames () const |
Returns whether duplicated frames are ignored. | |
const std::vector< Dicom::DatasetIodPair > & | datasets () const |
List of DcmDatasets and corresponding IODs for each loaded file. | |
![]() | |
virtual void * | registerErrorHandler (ErrorCallback handler) |
Registers a new handler callback function. | |
virtual void | unregisterErrorHandler (void *handler) |
Removes a previously registered handler again. | |
void * | forwardErrors (const ErrorRecorder *otherRecorder) |
Convenient function to forward all errors registered to this recorder to another recorder. | |
virtual void | registerError (const Error &error) const |
Sends the given error to all error handler callbacks. | |
void | registerError (Error::Code code, Error::Type type, const std::string &details, TagProxy tag=TagProxy()) const |
Static Public Member Functions | |
static std::multimap< std::string, std::vector< Dicom::IOD * > > | groupSeries (const std::vector< Dicom::DatasetIodPair > &datasets, const Dicom::ErrorRecorder &recorder) |
Groups datasets by series instance UID. | |
static std::vector< std::vector< Dicom::IOD * > > | splitDuplicatedFrames (const std::vector< Dicom::IOD * > &series, const Dicom::ErrorRecorder &recorder) |
Splits duplicated IODs from the list of series into separate lists. | |
DicomLoader | ( | const std::vector< std::shared_ptr< DcmDataset > > & | datasets, |
Progress * | progress = nullptr, | ||
const std::vector< std::string > & | paths = std::vector< std::string >(), | ||
std::shared_ptr< Dicom::IOD_Registry > | registry = nullptr ) |
Creates a DicomLoader instance from existing DcmDatasets.
If paths has the same size as datasets, they will be used as DicomIOD::pathInfo.
DicomLoader | ( | const std::vector< RawBuffer > & | buffers, |
Progress * | progress = nullptr, | ||
const std::vector< std::string > & | paths = std::vector< std::string >(), | ||
std::shared_ptr< Dicom::IOD_Registry > | registry = nullptr ) |
Creates a DicomLoader instance from buffers of DcmDatasets.
The buffers are assumed to be directly retrieved from DICOM files. The loader does not take ownership and the buffers can be safely deleted after the constructor is executed. If paths has the same size as datasets, they will be used as DicomIOD::pathInfo.
std::vector< std::unique_ptr< SharedImageSet > > loadImages | ( | ) |
Loads all images of all series.
Usually one image corresponds to one series but there are exceptions such as series that contain both 2D and 3D data or Ultrasound Series.
std::vector< SharedImageSetDescriptor > loadDescriptors | ( | ) |
Similar to loadImages but does not load any pixel data but only the ImageDescriptors.
So a SharedImage is represented by a ImageDescriptor and a SharedImageSet (i.e. a list of SharedImage) therefore by a list of ImageDescriptors.
void setSplitVolumes | ( | bool | enable | ) |
Sets the flag whether loaded data should be split up for best support in the ImFusionSuite.
If enabled, splits SharedImageSets that contain both 2D and 3D images into a single 2D image set. This usually happens when a volume could not be reconstructed correctly e.g. due to missing slices. Enabled by default.
void setReconstructVolumes | ( | bool | enable | ) |
Sets the flag whether loaded data should be reconstructed to volumes if possible.
Disabling this will load all series as image sets. Enabled by default.
void setIgnoreDuplicateFrames | ( | bool | enable | ) |
Sets the flag whether frames that are consider duplicates of other frames are ignored.
Frames are considered the equal if they have the same SOP Instance UID, patient ID and position/orientation. This can happen if a dataset was copied and a folder containing both copies is loaded. When this option is disabled, duplicated frames will be loaded as separate images. E.g. if a folder contains every file twice, one image will be loaded is this option is enabled, but two images when this option is disabled. Enabled by default.
|
static |
Groups datasets by series instance UID.
All IODs in one list will be of the same class. In case a series would end up with mixed IODs, it will be split according to their class types. Therefore, a single series instance UID can consist of multiple grouped dataset (hence the std::multimap).
|
static |
Splits duplicated IODs from the list of series into separate lists.
If no duplicated IODs have been detected, the returned list will only have one element. If a IOD has duplicates, the first found duplicate will be placed into the second list, the second found duplicate in the third list and so on. The order of IODs is retained. IODs are considered duplicates if certain tag values contain identical values (e.g. SOP Instance UID or Patient ID among others).