View Source
Class DICOMObject
The DICOM object is a container for DICOM elements. It contains methods for finding elements easily from within the
structure.
Inheritance
System.Object
DICOMObject
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace:EvilDICOM.Core
Assembly:EvilDICOM.dll
Syntax
Constructors
View Source
DICOMObject()
Constructor no parameters
Declaration
View Source
DICOMObject(IDICOMElement[])
Declaration
public DICOMObject(params IDICOMElement[] elements)
Parameters
Type |
Name |
Description |
IDICOMElement[] |
elements |
a param array of elements to be included in the object
|
View Source
DICOMObject(List<IDICOMElement>)
Declaration
public DICOMObject(List<IDICOMElement> elements)
Parameters
Type |
Name |
Description |
System.Collections.Generic.List<IDICOMElement> |
elements |
a list of elements to be included in the object
|
Properties
View Source
AllElements
The list of all DICOM elements at every level in the DICOM structure (includes sub-elements of sequences)
Declaration
public List<IDICOMElement> AllElements { get; }
Property Value
View Source
Elements
The list of first level DICOM elements inside this DICOM object
Declaration
public List<IDICOMElement> Elements { get; set; }
Property Value
View Source
SOPClass
Declaration
public SOPClass SOPClass { get; }
Property Value
Methods
View Source
Add(IDICOMElement)
Adds an element to the DICOM object
Declaration
public void Add(IDICOMElement el)
Parameters
Type |
Name |
Description |
IDICOMElement |
el |
a DICOM element to be added
|
View Source
AddRange(IEnumerable<IDICOMElement>)
Adds elements to the DICOM object
Declaration
public void AddRange(IEnumerable<IDICOMElement> els)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<IDICOMElement> |
els |
|
View Source
Clone()
Creates a clone of this DICOM object
Declaration
public DICOMObject Clone()
Returns
View Source
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
System.Object.Equals(System.Object)
View Source
FindAll(Tag)
Finds all DICOM elements that match a certain tag
Declaration
public List<IDICOMElement> FindAll(Tag tag)
Parameters
Type |
Name |
Description |
Tag |
tag |
the tag to find
|
Returns
Type |
Description |
System.Collections.Generic.List<IDICOMElement> |
a list of all elements that meet the search criteria
|
View Source
FindAll(Tag[])
Finds all DICOM elements that are embedded in the DICOM structure in some particular location. This location
is defined by descending tags from the outer most elements to the element. It is not necessary to include every
tag in the descending "treelike" structure. Branches can be skipped.
Declaration
public List<IDICOMElement> FindAll(Tag[] descendingTags)
Parameters
Type |
Name |
Description |
Tag[] |
descendingTags |
a tag array containing in order the tags from the outer most elements to the element being
searched for
|
Returns
Type |
Description |
System.Collections.Generic.List<IDICOMElement> |
a list of all elements that meet the search criteria
|
View Source
FindAll(VR)
Finds all DICOM elements that match a VR type
Declaration
public List<IDICOMElement> FindAll(VR vrToFind)
Parameters
Type |
Name |
Description |
VR |
vrToFind |
the VR type to find
|
Returns
Type |
Description |
System.Collections.Generic.List<IDICOMElement> |
a list of all elements that meet the search criteria
|
View Source
FindAll(String)
Finds all DICOM elements that match a certain tag
Declaration
public List<IDICOMElement> FindAll(string tag)
Parameters
Type |
Name |
Description |
System.String |
tag |
the tag to find
|
Returns
Type |
Description |
System.Collections.Generic.List<IDICOMElement> |
a list of all elements that meet the search criteria
|
View Source
FindAll(String[])
Finds all DICOM elements that are embedded in the DICOM structure in some particular location. This location
is defined by descending tags from the outer most elements to the element. It is not necessary to include every
tag in the descending "treelike" structure. Branches can be skipped.
Declaration
public List<IDICOMElement> FindAll(string[] descendingTags)
Parameters
Type |
Name |
Description |
System.String[] |
descendingTags |
a string array containing in order the tags from the outer most elements to the element
being searched for
|
Returns
Type |
Description |
System.Collections.Generic.List<IDICOMElement> |
a list of all elements that meet the search criteria
|
View Source
FindAll<T>()
Finds all DICOM elements that match an element type
Declaration
public List<T> FindAll<T>()
Returns
Type |
Description |
System.Collections.Generic.List<T> |
a list of all elements that are strongly typed
|
Type Parameters
Name |
Description |
T |
the DICOM element class that is being filtered and returned
|
View Source
FindFirst(Tag)
Finds the first element in the entire DICOM structure that has a certain tag
Declaration
public IDICOMElement FindFirst(Tag toFind)
Parameters
Type |
Name |
Description |
Tag |
toFind |
the tag to be searched
|
Returns
Type |
Description |
IDICOMElement |
one single DICOM element that is first occurence of the tag in the structure
|
View Source
FindFirst(String)
Finds the first element in the entire DICOM structure that has a certain tag
Declaration
public IDICOMElement FindFirst(string toFind)
Parameters
Type |
Name |
Description |
System.String |
toFind |
the tag to be searched
|
Returns
Type |
Description |
IDICOMElement |
one single DICOM element that is first occurence of the tag in the structure
|
View Source
GetBytes(DICOMIOSettings)
Declaration
public byte[] GetBytes(DICOMIOSettings settings = null)
Parameters
Returns
Type |
Description |
System.Byte[] |
|
View Source
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
System.Object.GetHashCode()
View Source
GetSelector()
Declaration
public DICOMSelector GetSelector()
Returns
View Source
GetUnknownTagAs<T>(Tag)
Returns elements of a certain tag that are of the unknown VR type (because they are not
in the DICOM dictionary) and reads them as the specified VR type
Declaration
public List<T> GetUnknownTagAs<T>(Tag toFind)
where T : IDICOMElement
Parameters
Type |
Name |
Description |
Tag |
toFind |
the tag of this element
|
Returns
Type |
Description |
System.Collections.Generic.List<T> |
the unknown elements strongly typed to T
|
Type Parameters
Name |
Description |
T |
the VR type to read as
|
View Source
GetUnknownTagAs<T>(String)
Returns elements of a certain tag that are of the unknown VR type (because they are not
in the DICOM dictionary) and reads them as the specified VR type
Declaration
public List<T> GetUnknownTagAs<T>(string toFind)
where T : IDICOMElement
Parameters
Type |
Name |
Description |
System.String |
toFind |
the tag of this element
|
Returns
Type |
Description |
System.Collections.Generic.List<T> |
the unknown elements strongly typed to T
|
Type Parameters
Name |
Description |
T |
the VR type to read as
|
View Source
Read(Byte[], TransferSyntax)
Reads a DICOM file from a byte array
Declaration
public static DICOMObject Read(byte[] file, TransferSyntax trySyntax = TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN)
Parameters
Type |
Name |
Description |
System.Byte[] |
file |
the bytes of the DICOM file
|
TransferSyntax |
trySyntax |
the transfer syntax to use in case there is no metadata explicitly included
|
Returns
View Source
Read(String, TransferSyntax)
Reads a DICOM file from a path
Declaration
public static DICOMObject Read(string filePath, TransferSyntax trySyntax = TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN)
Parameters
Type |
Name |
Description |
System.String |
filePath |
the path to the file
|
TransferSyntax |
trySyntax |
the transfer syntax to use in case there is no metadata explicitly included
|
Returns
Examples
var dcm = DICOMObject.Read("mydcm.dcm");
View Source
ReadAsync(String, TransferSyntax)
Reads a DICOM file from a path
Declaration
public static async Task<DICOMObject> ReadAsync(string filePath, TransferSyntax trySyntax = TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN)
Parameters
Type |
Name |
Description |
System.String |
filePath |
the path to the file
|
TransferSyntax |
trySyntax |
the transfer syntax to use in case there is no metadata explicitly included
|
Returns
Type |
Description |
System.Threading.Tasks.Task<DICOMObject> |
the DICOM Object
|
Examples
var dcm = DICOMObject.Read("mydcm.dcm");
View Source
Remove(Tag)
Removes the element with the tag from the DICOM object
Declaration
public void Remove(Tag tag)
Parameters
Type |
Name |
Description |
Tag |
tag |
the tag of the element to be removed
|
View Source
Remove(String)
Removes the element with the tag from the DICOM object
Declaration
public void Remove(string tag)
Parameters
Type |
Name |
Description |
System.String |
tag |
the tag string in the form of GGGGEEEE to be removed
|
View Source
RemoveRange(IEnumerable<Tag>)
Removes the element with the tag from the DICOM object
Declaration
public void RemoveRange(IEnumerable<Tag> tags)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<Tag> |
tags |
|
View Source
RemoveRange(IEnumerable<String>)
Removes the element with the tag from the DICOM object
Declaration
public void RemoveRange(IEnumerable<string> tags)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.String> |
tags |
|
View Source
Replace(AbstractElement<DICOMObject>)
Declaration
public bool Replace(AbstractElement<DICOMObject> element)
Parameters
Returns
Type |
Description |
System.Boolean |
|
View Source
Replace(AbstractElement<Tag>)
Declaration
public bool Replace(AbstractElement<Tag> element)
Parameters
Returns
Type |
Description |
System.Boolean |
|
View Source
Replace(AbstractElement<Byte>)
Declaration
public bool Replace(AbstractElement<byte> element)
Parameters
Returns
Type |
Description |
System.Boolean |
|
View Source
Replace(AbstractElement<Double>)
Declaration
public bool Replace(AbstractElement<double> element)
Parameters
Returns
Type |
Description |
System.Boolean |
|
View Source
Replace(AbstractElement<Int16>)
Declaration
public bool Replace(AbstractElement<short> element)
Parameters
Returns
Type |
Description |
System.Boolean |
|
View Source
Replace(AbstractElement<Int32>)
Declaration
public bool Replace(AbstractElement<int> element)
Parameters
Returns
Type |
Description |
System.Boolean |
|
View Source
Replace(AbstractElement<Nullable<DateTime>>)
Declaration
public bool Replace(AbstractElement<DateTime?> element)
Parameters
Type |
Name |
Description |
AbstractElement<System.Nullable<System.DateTime>> |
element |
|
Returns
Type |
Description |
System.Boolean |
|
View Source
Replace(AbstractElement<Single>)
Declaration
public bool Replace(AbstractElement<float> element)
Parameters
Returns
Type |
Description |
System.Boolean |
|
View Source
Replace(AbstractElement<String>)
Declaration
public bool Replace(AbstractElement<string> element)
Parameters
Returns
Type |
Description |
System.Boolean |
|
View Source
Replace(AbstractElement<UInt16>)
Declaration
public bool Replace(AbstractElement<ushort> element)
Parameters
Returns
Type |
Description |
System.Boolean |
|
View Source
Replace(AbstractElement<UInt32>)
Declaration
public bool Replace(AbstractElement<uint> element)
Parameters
Returns
Type |
Description |
System.Boolean |
|
View Source
Replace(IDICOMElement)
Replaces the underlying DICOM element with input DICOM element of the same tag
Declaration
public bool Replace(IDICOMElement el)
Parameters
Returns
Type |
Description |
System.Boolean |
whether or not the operation was successful
|
View Source
ReplaceOrAdd(AbstractElement<DICOMObject>)
Declaration
public void ReplaceOrAdd(AbstractElement<DICOMObject> element)
Parameters
View Source
ReplaceOrAdd(AbstractElement<Tag>)
Declaration
public void ReplaceOrAdd(AbstractElement<Tag> element)
Parameters
View Source
ReplaceOrAdd(AbstractElement<Byte>)
Declaration
public void ReplaceOrAdd(AbstractElement<byte> element)
Parameters
View Source
ReplaceOrAdd(AbstractElement<Double>)
Declaration
public void ReplaceOrAdd(AbstractElement<double> element)
Parameters
View Source
ReplaceOrAdd(AbstractElement<Int16>)
Declaration
public void ReplaceOrAdd(AbstractElement<short> element)
Parameters
View Source
ReplaceOrAdd(AbstractElement<Int32>)
Declaration
public void ReplaceOrAdd(AbstractElement<int> element)
Parameters
View Source
ReplaceOrAdd(AbstractElement<Nullable<DateTime>>)
Declaration
public void ReplaceOrAdd(AbstractElement<DateTime?> element)
Parameters
Type |
Name |
Description |
AbstractElement<System.Nullable<System.DateTime>> |
element |
|
View Source
ReplaceOrAdd(AbstractElement<Nullable<Double>>)
Declaration
public void ReplaceOrAdd(AbstractElement<double?> element)
Parameters
Type |
Name |
Description |
AbstractElement<System.Nullable<System.Double>> |
element |
|
View Source
ReplaceOrAdd(AbstractElement<Nullable<Single>>)
Declaration
public void ReplaceOrAdd(AbstractElement<float?> element)
Parameters
Type |
Name |
Description |
AbstractElement<System.Nullable<System.Single>> |
element |
|
View Source
ReplaceOrAdd(AbstractElement<Single>)
Declaration
public void ReplaceOrAdd(AbstractElement<float> element)
Parameters
View Source
ReplaceOrAdd(AbstractElement<String>)
Declaration
public void ReplaceOrAdd(AbstractElement<string> element)
Parameters
View Source
ReplaceOrAdd(AbstractElement<UInt16>)
Declaration
public void ReplaceOrAdd(AbstractElement<ushort> element)
Parameters
View Source
ReplaceOrAdd(AbstractElement<UInt32>)
Declaration
public void ReplaceOrAdd(AbstractElement<uint> element)
Parameters
View Source
ReplaceOrAdd<T>(AbstractElement<T>)
Replaces a current instance of the DICOM element in the DICOM object. If the object does not exist, this method
will add it to the object.
Declaration
public void ReplaceOrAdd<T>(AbstractElement<T> element)
Parameters
Type |
Name |
Description |
AbstractElement<T> |
element |
the instance of the element
|
Type Parameters
Name |
Description |
T |
the type of the data the element holds (eg. double[], int, DataTime, etc)
|
View Source
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.Object.ToString()
View Source
TryGetDataValue<T>(Tag, Object)
Searches for a specific element. If it is found, it returns the data from the element. Otherwise,
it will return a provided default value for the element.
Declaration
public DICOMData<T> TryGetDataValue<T>(Tag tagToFind, object defaultValueIfNull)
Parameters
Type |
Name |
Description |
Tag |
tagToFind |
the tag of the element containing the data
|
System.Object |
defaultValueIfNull |
the default value to return if the element is not found
|
Returns
Type Parameters
Name |
Description |
T |
the type of data to return
|
View Source
TrySetDataValue<T>(Tag, T)
Searches for a specific element (first instance). If it is found, it sets the data for this element and returns
true, otherwise returns false;
Declaration
public bool TrySetDataValue<T>(Tag tagToFind, T data)
Parameters
Type |
Name |
Description |
Tag |
tagToFind |
the tag of the element containing the data
|
T |
data |
the data to set in this element
|
Returns
Type |
Description |
System.Boolean |
a boolean indicating whether or not the operation was successful
|
Type Parameters
Name |
Description |
T |
the type of data to return
|
View Source
TrySetDataValue<T>(Tag, List<T>)
Searches for a specific element (first instance). If it is found, it sets the data for this element and returns
true, otherwise returns false;
Declaration
public bool TrySetDataValue<T>(Tag tagToFind, List<T> data)
Parameters
Type |
Name |
Description |
Tag |
tagToFind |
the tag of the element containing the data
|
System.Collections.Generic.List<T> |
data |
the data to set in this element
|
Returns
Type |
Description |
System.Boolean |
a boolean indicating whether or not the operation was successful
|
Type Parameters
Name |
Description |
T |
the type of data to return
|
View Source
Write(String, DICOMIOSettings)
Writes DICOM object to a file
Declaration
public void Write(string file, DICOMIOSettings settings = null)
Parameters
Type |
Name |
Description |
System.String |
file |
the path to write
|
DICOMIOSettings |
settings |
the DICOM settings to write (endianness, and indefinite sequences)
|
View Source
WriteAddMeta(String, DICOMIOSettings)
Same function as write, but adds required metadata for file (often missing in DICOM objects transferred over a network)
Declaration
public void WriteAddMeta(string file, DICOMIOSettings settings = null)
Parameters
Type |
Name |
Description |
System.String |
file |
the path to write
|
DICOMIOSettings |
settings |
the DICOM settings to write (endianness, and indefinite sequences)
|
Extension Methods