ImFusion SDK 4.3
Sequence< T > Class Template Reference

#include <ImFusion/Dicom/DicomSequence.h>

Concrete sequence of items of type T, which must be derived from SequenceItem. More...

+ Inheritance diagram for Sequence< T >:

Detailed Description

template<typename T>
class ImFusion::Dicom::Sequence< T >

Concrete sequence of items of type T, which must be derived from SequenceItem.

A sequence is an Element by itself (i.e. it has a DICOM tag) but its value is usually meaningless. Instead, it provides a list of DcmItems that consist of one or multiple Elements again. These Elements are usually not directly accessed from the root DcmDataset (expect when searching recursively with searchIntoSubs). While in the root dataset each tag can only occur once, the same tag can occur in each item of the sequence, e.g. there can be multiple 'VOI LUT Descriptor' Elements. The template type defines which Elements make up a single item (all items must have those Elements).

When creating a sequence, the SequenceItems are initialized with the corresponding child DcmItem of the sequence.

Example for a imaginary Dicom file with following elements:

‍Rescale Intercept: 0.0 Modality Lut Sequence: 2 items

‍Rescale Intercept: 100.0 Rescale Intercept: 200.0

class Example: public Module
{
public:
Element<double> rescaleIntercept;
class LutItem: public SequenceItem
{
Element<double> rescaleIntercept;
LutItem(DcmItem& item, bool createSequence):
rescaleIntercept(*this, DCM_RescaleIntercept, 0, ElementBase::UserOption)
{}
}
Example(ModuleList& parent, Type type):
Module(parent, type),
rescaleIntercept(*this, DCM_RescaleIntercept, 0, ElementBase::UserOption),
lut(*this, DCM_ModalityLUTSequence, ElementBase::UserOption)
{}
}
Example e;
e.rescaleIntercept.value(); // -> 0.0
e.lut.item(0).rescaleIntercept.value(); // -> 100.0
e.lut.item(1).rescaleIntercept.value(); // -> 200.0
Abstract base class for DICOM Elements.
Definition DicomElement.h:74
Dicom Element with a concrete value type.
Definition VolumeReconstruction.h:20
Base class for Dicom Modules.
Definition DicomModule.h:111
Type
Conditionality of the module.
Definition DicomModule.h:115
Interface for classes that consist of modules.
Definition DicomModule.h:45
Concrete sequence of items of type T, which must be derived from SequenceItem.
Definition DicomSequence.h:118
T & item(int i)
Returns the sequence item at the given index.
Definition DicomSequence.h:253
Base class for sequence items.
Definition DicomSequence.h:27

Public Member Functions

 Sequence (ElementList &parent, DcmTag tag, ElementBase::Type type)
 Creates a new Sequence instance.
 
 Sequence (DcmItem &item, DcmTag tag, ElementBase::Type type)
 
void reload ()
 Reloads the list of items from the parent data set.
 
int count () const
 Returns the number of items in this sequence.
 
T & item (int i)
 Returns the sequence item at the given index.
 
const T & item (int i) const
 
T * insertItem ()
 Appends a new sequence item to the list.
 
void checkErrors (bool ignoreMandatory=false) const override
 Checks the sequence for errors.
 
bool isValid () const override
 Returns true if the element exists and is in a valid range.
 
- Public Member Functions inherited from SequenceBase
 SequenceBase (ElementList &parent, DcmTag tag, ElementBase::Type type)
 
 SequenceBase (DcmItem &item, DcmTag tag, ElementBase::Type type)
 
- Public Member Functions inherited from ElementBase
 ElementBase (ElementList &parent, DcmTag tag, Type type=Conditional, bool searchIntoSubs=false)
 
 ElementBase (DcmItem &item, DcmTag tag, Type type=Conditional, bool searchIntoSubs=false)
 
void setCondition (std::function< bool()> predicate)
 Sets a callback function that determines if a conditional element is mandatory.
 
virtual DcmTag tag () const
 DICOM tag wrapped by this Element.
 
virtual bool isMandatory () const
 Evaluates whether this element is mandatory (based on the specified type and optionally condition).
 
virtual bool exists () const
 Returns true if the elements exists in the dataset.
 
void remove ()
 Removes the element from the dataset.
 
std::string valueString () const
 Returns the value of the element as a string.
 
void setTargetSequence (DcmItem *sequence)
 Sets an optional sequence item where this elements will write its value.
 
- 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.
 
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
 

Protected Attributes

std::vector< std::unique_ptr< T > > m_items
 
- Protected Attributes inherited from ElementBase
DcmItem & m_dataset
 DICOM data set/base element to retrieve element data from.
 
DcmItem * m_targetSeq
 Optional sequence to write element data to; only used for setValue().
 
DcmTag m_tag
 DICOM tag the Element refers to.
 
Type m_type
 Conditionality of the Element.
 
bool m_searchIntoSubs
 Flag whether to search into sub sequences or not.
 
std::function< bool()> m_typeCondition
 Optional predicate function to evaluate conditionality.
 

Additional Inherited Members

- Public Types inherited from ElementBase
enum  Type { Mandatory , Conditional }
 Conditionality of an Element. More...
 
- Public Types inherited from ErrorRecorder
using ErrorCallback = std::function<void(const Error&)>
 Alias for a function to call for each error recorded.
 

Member Function Documentation

◆ item()

template<typename T>
T & item ( int i)

Returns the sequence item at the given index.

Throws an out-of-range exception if i is smaller than 0 and not smaller than count().

◆ insertItem()

template<typename T>
T * insertItem ( )

Appends a new sequence item to the list.

Returns the newly created item. Throws a value_error in case the item could not be created in the wrapped DICOM dataset.

◆ checkErrors()

template<typename T>
void checkErrors ( bool ignoreMandatory = false) const
overridevirtual

Checks the sequence for errors.

This assures that all mandatory and conditional elements are present and that all existing elements have a valid value. If ignoreMandatory is true, missing mandatory elements are not counted as errors (e.g. useful when the sequence itself is optional).

Implements SequenceBase.

◆ isValid()

template<typename T>
bool isValid ( ) const
overridevirtual

Returns true if the element exists and is in a valid range.

Implements ElementBase.


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