Skip to content

Instantly share code, notes, and snippets.

@neurosnap
Created June 30, 2014 13:29
Show Gist options
  • Save neurosnap/3a1824c31643367bbb0e to your computer and use it in GitHub Desktop.
Save neurosnap/3a1824c31643367bbb0e to your computer and use it in GitHub Desktop.
gdcmswig.py -- DataElement
class DataElement(_object):
"""
Class to represent a Data Element either Implicit or Explicit.
DATA ELEMENT: A unit of information as defined by a single entry in
the data dictionary. An encoded Information Object Definition ( IOD)
Attribute that is composed of, at a minimum, three fields: a Data
Element Tag, a Value Length, and a Value Field. For some specific
Transfer Syntaxes, a Data Element also contains a VR Field where the
Value Representation of that Data Element is specified explicitly.
Design: A DataElement in GDCM always store VL ( Value Length) on a 32
bits integer even when VL is 16 bits
A DataElement always store the VR even for Implicit TS, in which case
VR is defaulted to VR::INVALID
For Item start/end (See 0xfffe tags), Value is NULL
See: ExplicitDataElement ImplicitDataElement
C++ includes: gdcmDataElement.h
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, DataElement, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, DataElement, name)
__repr__ = _swig_repr
def GetTag(self, *args):
"""
Tag&
gdcm::DataElement::GetTag()
"""
return _gdcmswig.DataElement_GetTag(self, *args)
def SetTag(self, *args):
"""
void
gdcm::DataElement::SetTag(const Tag &t)
Set Tag Use with cautious (need to match Part 6)
"""
return _gdcmswig.DataElement_SetTag(self, *args)
def GetVL(self, *args):
"""
VL&
gdcm::DataElement::GetVL()
"""
return _gdcmswig.DataElement_GetVL(self, *args)
def SetVL(self, *args):
"""
void
gdcm::DataElement::SetVL(const VL &vl)
Set VL Use with cautious (need to match Part 6), advanced user only
See: SetByteValue
"""
return _gdcmswig.DataElement_SetVL(self, *args)
def SetVLToUndefined(self):
"""
void
gdcm::DataElement::SetVLToUndefined()
"""
return _gdcmswig.DataElement_SetVLToUndefined(self)
def GetVR(self):
"""
VR const&
gdcm::DataElement::GetVR() const
Get VR do not set VR::SQ on bytevalue data element
"""
return _gdcmswig.DataElement_GetVR(self)
def SetVR(self, *args):
"""
void
gdcm::DataElement::SetVR(VR const &vr)
Set VR Use with cautious (need to match Part 6), advanced user only vr
is a VR::VRALL (not a dual one such as OB_OW)
"""
return _gdcmswig.DataElement_SetVR(self, *args)
def GetValue(self, *args):
"""
Value&
gdcm::DataElement::GetValue()
"""
return _gdcmswig.DataElement_GetValue(self, *args)
def SetValue(self, *args):
"""
void
gdcm::DataElement::SetValue(Value const &vl)
WARNING: you need to set the ValueLengthField explicitely
"""
return _gdcmswig.DataElement_SetValue(self, *args)
def IsEmpty(self):
"""
bool
gdcm::DataElement::IsEmpty() const
Check if Data Element is empty.
"""
return _gdcmswig.DataElement_IsEmpty(self)
def Empty(self):
"""
void
gdcm::DataElement::Empty()
Make Data Element empty (no Value).
"""
return _gdcmswig.DataElement_Empty(self)
def Clear(self):
"""
void
gdcm::DataElement::Clear()
Clear Data Element (make Value empty and invalidate Tag & VR).
"""
return _gdcmswig.DataElement_Clear(self)
def SetByteValue(self, *args):
"""
void
gdcm::DataElement::SetByteValue(const char *array, VL length)
Set the byte value WARNING: user need to read DICOM standard for an
understanding of: even padding vs space padding By default even
padding is achieved using regardless of the of VR
"""
return _gdcmswig.DataElement_SetByteValue(self, *args)
def GetByteValue(self):
"""
const
ByteValue* gdcm::DataElement::GetByteValue() const
Return the Value of DataElement as a ByteValue (if possible) WARNING:
: You need to check for NULL return value
"""
return _gdcmswig.DataElement_GetByteValue(self)
def GetSequenceOfItems(self, *args):
"""SequenceOfItems* gdcm::DataElement::GetSequenceOfItems() """
return _gdcmswig.DataElement_GetSequenceOfItems(self, *args)
def GetValueAsSQ(self):
"""
SmartPointer<SequenceOfItems> gdcm::DataElement::GetValueAsSQ() const
Interpret the Value stored in the DataElement. This is more robust
(but also more expensive) to call this function rather than the
simpliest form: GetSequenceOfItems() It also return NULL when the
Value is NOT of type SequenceOfItems WARNING: in case
GetSequenceOfItems() succeed the function return this value, otherwise
it creates a new SequenceOfItems, you should handle that in your case,
for instance: SmartPointer<SequenceOfItems> sqi = de.GetValueAsSQ();
"""
return _gdcmswig.DataElement_GetValueAsSQ(self)
def GetSequenceOfFragments(self):
"""
const SequenceOfFragments* gdcm::DataElement::GetSequenceOfFragments()
const
Return the Value of DataElement as a Sequence Of Fragments (if
possible) WARNING: : You need to check for NULL return value
"""
return _gdcmswig.DataElement_GetSequenceOfFragments(self)
def IsUndefinedLength(self):
"""
bool
gdcm::DataElement::IsUndefinedLength() const
return if Value Length if of undefined length
"""
return _gdcmswig.DataElement_IsUndefinedLength(self)
def __init__(self, *args):
"""gdcm::DataElement::DataElement(const DataElement &_val) """
this = _gdcmswig.new_DataElement(*args)
try: self.this.append(this)
except: self.this = this
def __lt__(self, *args): return _gdcmswig.DataElement___lt__(self, *args)
def __eq__(self, *args): return _gdcmswig.DataElement___eq__(self, *args)
def __str__(self): return _gdcmswig.DataElement___str__(self)
__swig_destroy__ = _gdcmswig.delete_DataElement
__del__ = lambda self : None;
DataElement_swigregister = _gdcmswig.DataElement_swigregister
DataElement_swigregister(DataElement)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment