ImFusion SDK 4.3
DicomWriter Class Reference

#include <ImFusion/Dicom/DicomWriter.h>

The DicomWriter class can store a SharedImageSet in a DICOM dataset. More...

+ Inheritance diagram for DicomWriter:

Detailed Description

The DicomWriter class can store a SharedImageSet in a DICOM dataset.

The writer creates DicomIODs and DcmDatasets that correspond to the SharedImageSet. For classical single frame DICOM files, an IOD and DcmDataset will be generated per 2D frame in the image. For enhanced multi-frame DICOM files, a single IOD and DcmDataset is generated.

The DicomWriter will automatically pick the most appropriate Dicom::IOD instance upon construction using the Dicom::IOD_Registry. The Dicom::IOD instance can also be changed later on using the resetIOD method.

Public Types

enum class  Compression {
  LittleEndianImplicit , LittleEndianExplicit , DeflatedLittleEndianExplicit , BigEndianExplicit ,
  JPEG , JPEG_lossless , JPEGLS_lossless , JPEGLS_lossy ,
  JPEG2000 , JPEG2000_lossless
}
 Enumeration of supported compression/storage types when writing DICOM.
 
enum class  Type { File , Folder , Auto }
 Type of DICOM storage to use. More...
 
using Url = Filesystem::Url
 
- Public Types inherited from ErrorRecorder
using ErrorCallback = std::function<void(const Error&)>
 Alias for a function to call for each error recorded.
 

Public Member Functions

 DicomWriter (SharedImageSet *imageSet, Type type=Type::Auto, Progress *progress=nullptr, std::shared_ptr< Dicom::IOD_Registry > registry=nullptr)
 Instantiates a new DicomWriter object with the given parameters.
 
SharedImageSetimageSet () const
 Returns the source image.
 
void createDatasets ()
 Creates the actual DcmDataset instances and fills them with tags according to the image.
 
const std::vector< Dicom::DatasetIodPair > & datasets () const
 List of DcmDatasets and corresponding IODs for each saved file.
 
std::shared_ptr< Dicom::IOD_RegistryiodRegistry () const
 Returns the registry used by this writer.
 
bool isMultiFile () const
 Returns true if the image will be split over multiple files.
 
bool save (const Url &uri)
 Saves the DICOM dataset to the given URI, which must have a scheme of either "file" or "pacs".
 
bool save (const std::string &path)
 Convenience method to save the DICOM dataset to the file system without explicitly constructing an URI.
 
void setCompression (DicomWriter::Compression compression)
 Sets the compression used when saving.
 
DicomWriter::Compression compression () const
 Returns the compression used when saving.
 
void setCompressionQuality (int quality)
 Sets the quality setting of lossy compressions.
 
int compressionQuality () const
 Returns the quality setting of lossy compressions.
 
void setFilenameFormat (const std::string &filenameFormat)
 Sets the output filename format.
 
std::string filenameFormat () const
 Returns the output filename format.
 
const std::stringcurrentWriterName () const
 Returns the current name of the writer used to generate the Dicom::IODs (see Dicom::IOD_Registry).
 
void configure (const Properties *p) override
 Configure filenameFormat, compression and compressionQuality.
 
void configuration (Properties *p) const override
 Retrieve the properties filenameFormat, compression and compressionQuality.
 
- Public Member Functions inherited from ErrorRecorder
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.
 
void registerError (Error::Code code, Error::Type type, const std::string &details, TagProxy tag=TagProxy()) const
 
- Public Member Functions inherited from Configurable
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
 
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
 
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 
 Configurable (const Configurable &rhs)
 
 Configurable (Configurable &&rhs) noexcept
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (Configurable &&) noexcept
 

Additional Inherited Members

- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 
- Protected Attributes inherited from Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 

Member Enumeration Documentation

◆ Type

enum class Type
strong

Type of DICOM storage to use.

Enumerator
File 

If possible, write all image data to a single file.

Folder 

Write each frame as separate DICOM file to a folder.

Auto 

Automatically determine storage type based on image content.

Constructor & Destructor Documentation

◆ DicomWriter()

DicomWriter ( SharedImageSet * imageSet,
Type type = Type::Auto,
Progress * progress = nullptr,
std::shared_ptr< Dicom::IOD_Registry > registry = nullptr )

Instantiates a new DicomWriter object with the given parameters.

Parameters
imageSetImage data to store in DICOM format.
typeDICOM storage type to use (defaults to Auto).
progressOptional progress object to use.

Member Function Documentation

◆ createDatasets()

void createDatasets ( )

Creates the actual DcmDataset instances and fills them with tags according to the image.

This might allocate a lot of memory depending of the size of the image. Calling this function again will replace the current dataset.

◆ datasets()

const std::vector< Dicom::DatasetIodPair > & datasets ( ) const

List of DcmDatasets and corresponding IODs for each saved file.

This list will be empty until createDatasets was called.

◆ save() [1/2]

bool save ( const Url & uri)

Saves the DICOM dataset to the given URI, which must have a scheme of either "file" or "pacs".

Automatically writes pixel data and applies compression. All intermediate directories of the given path are created automatically.

Note
If the URI is of scheme "file" and the DicomWriter is multi-file, a folder is expected, otherwise a file.

◆ save() [2/2]

bool save ( const std::string & path)

Convenience method to save the DICOM dataset to the file system without explicitly constructing an URI.

Just pass a normal file/folder path.

◆ setCompression()

void setCompression ( DicomWriter::Compression compression)

Sets the compression used when saving.

The default is LittleEndianImplicit (uncompressed). The compression will only be used during saving.

◆ setCompressionQuality()

void setCompressionQuality ( int quality)

Sets the quality setting of lossy compressions.

The quality goes from 1 to 100, with 1 being the lowest quality and highest compression and 100 being the highest quality and the lowest compression. Values will be clamped to 1 and 100. Has no effect on lossless or no compression.

◆ setFilenameFormat()

void setFilenameFormat ( const std::string & filenameFormat)

Sets the output filename format.

Syntax: prefix$0..0$suffix. E.g. dicom_$0000$.dcm will set m_maxdigits to 4 and the dicom files will be named dicom_0000.dcm, dicom_0001.dcm etc.

◆ configure()

void configure ( const Properties * p)
overridevirtual

Configure filenameFormat, compression and compressionQuality.

Reimplemented from Configurable.

◆ configuration()

void configuration ( Properties * p) const
overridevirtual

Retrieve the properties filenameFormat, compression and compressionQuality.

Reimplemented from Configurable.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close