![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Dicom/DicomWriter.h>
The DicomWriter class can store a SharedImageSet in a DICOM dataset. More...
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 |
![]() | |
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. | |
SharedImageSet * | imageSet () 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_Registry > | iodRegistry () 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::string & | currentWriterName () 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. | |
![]() | |
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 |
![]() | |
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 | |
Configurable & | operator= (const Configurable &) |
Configurable & | operator= (Configurable &&) noexcept |
Additional Inherited Members | |
![]() | |
Signal | signalParametersChanged |
Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted. | |
![]() | |
std::vector< Param > | m_params |
List of all registered Parameter and SubProperty instances. | |
|
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. |
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.
imageSet | Image data to store in DICOM format. |
type | DICOM storage type to use (defaults to Auto). |
progress | Optional progress object to use. |
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.
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.
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.
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.
void setCompression | ( | DicomWriter::Compression | compression | ) |
Sets the compression used when saving.
The default is LittleEndianImplicit (uncompressed). The compression will only be used during saving.
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.
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.
|
overridevirtual |
Configure filenameFormat, compression and compressionQuality.
Reimplemented from Configurable.
|
overridevirtual |
Retrieve the properties filenameFormat, compression and compressionQuality.
Reimplemented from Configurable.