Class Dataset

Class Dataset

Namespace: Aspose.Medical.Dicom
Assembly: Aspose.Medical.dll (25.11.0)

Encapsulates DICOM Dataset.

public class Dataset : IEnumerable<ielement>, IEnumerable

Inheritance

object Dataset

Derived

MetaInformation

Implements

IEnumerable<ielement> , IEnumerable

Inherited Members

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Constructors

Dataset()

Initialize a new instance of the Aspose.Medical.Dicom.Dataset.

public Dataset()

Dataset(TransferSyntax)

Initialize a new instance of the Aspose.Medical.Dicom.Dataset with the given syntax .

Internal transfer syntax representation of the dataset
public Dataset(TransferSyntax syntax)

Parameters

syntax TransferSyntax

Dataset(IEnumerable<ielement>)

Initialize a new instance of the Aspose.Medical.Dicom.Dataset and copies the given elements into newly created dataset.

public Dataset(IEnumerable<ielement> elements)

Parameters

elements IEnumerable < IElement &gt;

Elements to be copied.

Exceptions

MedicalApiException

The provided data are invalid.

DicomValidationException

An element can’t be cloned.

Dataset(Encoding[])

Initialize a new instance of the Aspose.Medical.Dicom.Dataset with the given fallback System.Text.Encodings.

public Dataset(Encoding[] fallbackEncodings)

Parameters

fallbackEncodings Encoding []

Fallback encodings.

Methods

Add(IElement)

Adds the given element to the dataset if the element with the Aspose.Medical.Dicom.Elements.IElement.Tag is not presented in the dataset or updates element value with the same tag.

public void Add(IElement element)

Parameters

element IElement

A DICOM element to be added.

Exceptions

MedicalApiException

The element with the given tag already exists int this Dataset.

AddOrUpdate(IElement)

Adds the given element to the dataset if the element with the Aspose.Medical.Dicom.Elements.IElement.Tag is not presented in the dataset or updates element value with the same tag.

public void AddOrUpdate(IElement element)

Parameters

element IElement

A DICOM element to be added / updated.

AddOrUpdate<t>(Tag, T)

Adds single DICOM element to the dataset if the element with the tag is not presented in the dataset or updates element value with the same tag.

public void AddOrUpdate<t>(Tag tag, T value)

Parameters

tag Tag

DICOM tag of the added item.

value T

Value of the added item.

Type Parameters

T

Type of added values.

Exceptions

DicomValidationException

The provided data are invalid.

MedicalApiException

Unable to identify value representation for the given tag.

AddOrUpdate<t>(Tag, T[]?)

Adds single DICOM element to the dataset if the element with the tag is not presented in the dataset or updates element value with the same tag.

public void AddOrUpdate<t>(Tag tag, T[]? values)

Parameters

tag Tag

DICOM tag of the added item.

values T[]?

Values of the added item.

Type Parameters

T

Type of added values.

Exceptions

DicomValidationException

The provided data are invalid.

MedicalApiException

Unable to identify value representation for the given tag.

AddOrUpdate<t>(Tag, Span<t>)

Adds single DICOM element to the dataset if the element with the tag is not presented in the dataset or updates element value with the same tag.

public void AddOrUpdate<t>(Tag tag, Span<t> values)

Parameters

tag Tag

DICOM tag of the added item.

values Span <t>

Values of the added item.

Type Parameters

T

Type of added values.

Exceptions

DicomValidationException

The provided data are invalid.

MedicalApiException

Unable to identify value representation for the given tag.

AddOrUpdate<t>(Tag, ValueRepresentation, Span<t>)

Adds single DICOM element to the dataset if the element with the tag is not presented in the dataset or updates element value with the same tag.

public void AddOrUpdate<t>(Tag tag, ValueRepresentation vr, Span<t> values)

Parameters

tag Tag

DICOM tag of the added item.

vr ValueRepresentation

Value representation of an element to be added or updated.

values Span <t>

Values of the added item.

Type Parameters

T

Type of added values.

Exceptions

DicomValidationException

The provided data are invalid.

MedicalApiException

The specified vr is not compatible with the given tag.

AddOrUpdateRange(IEnumerable<ielement>)

Adds the given elements to the dataset. If an element with the Aspose.Medical.Dicom.Elements.IElement.Tag is not presented in the dataset, then adds the element; otherwise, updates element’s value with the same tag.

public void AddOrUpdateRange(IEnumerable<ielement> elements)

Parameters

elements IEnumerable < IElement &gt;

DICOM data elements to be added.

Contains(Tag)

Determines whether the DICOM dataset contains an element with the specified tag.

public bool Contains(Tag tag)

Parameters

tag Tag

DICOM tag to test.

Returns

bool

true if a DICOM element with the given tag already exists; otherwise, false.

EnumerateGroup(ushort)

Enumerates DICOM elements for the given group.

public IEnumerable<ielement> EnumerateGroup(ushort group)

Parameters

group ushort

Requested group.

Returns

IEnumerable < IElement &gt;

The System.Collections.Generic.IEnumerable`1 of Aspose.Medical.Dicom.Elements.IElement for specified group.

FindValues<t>(Tag)

Returns the element values of the specified tag if the element exists in the dataset; otherwise, empty set.

public Span<t> FindValues<t>(Tag tag)

Parameters

tag Tag

The requested DICOM tag.

Returns

Span <t>

The T element values corresponding to tag.

Type Parameters

T

Type of the return value (collections aren’t allowed).

Get<t>(Tag)

Returns the T of the specified tag or default if the tag is not in the dataset.

public T Get<t>(Tag tag) where T : class, IElement

Parameters

tag Tag

A requested DICOM tag.

Returns

T

The T of the given tag or default if the tag is not in the dataset.

Type Parameters

T

Exceptions

MedicalApiException

The requested tag is missing in this Dataset.

GetEnumerator()

public IEnumerator<ielement> GetEnumerator()

Returns

IEnumerator < IElement &gt;

GetOrDefault(Tag)

Returns the Aspose.Medical.Dicom.Elements.IElement of the specified tag or default if the tag is not in the dataset.

public IElement? GetOrDefault(Tag tag)

Parameters

tag Tag

A requested DICOM tag.

Returns

IElement ?

The Aspose.Medical.Dicom.Elements.IElement of the given tag or default if the tag is not in the dataset.

GetOrDefault<t>(Tag)

Returns the T of the specified tag or default if the tag is not in the dataset.

public T? GetOrDefault<t>(Tag tag) where T : class, IElement

Parameters

tag Tag

A requested DICOM tag.

Returns

T?

The T of the given tag or default if the tag is not in the dataset.

Type Parameters

T

GetPrivateTag(Tag)

Converts a dictionary tag to a valid private tag for this dataset.

public Tag GetPrivateTag(Tag tag)

Parameters

tag Tag

DICOM dictionary tag.

Returns

Tag

The Aspose.Medical.Dicom.Tags.Tag.

Remarks

Note: this method will create Private Creator tag if needed.

GetSingleValue<t>(Tag)

Gets the element value of the specified tag, whose Value Multiplicity has to be 1.

public T GetSingleValue<t>(Tag tag)

Parameters

tag Tag

The requested DICOM tag.

Returns

T

Element value corresponding to tag.

Type Parameters

T

Type of the return value (collections aren’t allowed).

Exceptions

MedicalApiException

The dataset does not contain tag, is empty or is multivalued.

GetSingleValueOrDefault<t>(Tag, T?)

Gets the element value of the specified tag, whose Value Multiplicity has to be 1 or the provided defaultValue if the element value does not exist.

public T? GetSingleValueOrDefault<t>(Tag tag, T? defaultValue)

Parameters

tag Tag

The requested DICOM tag.

defaultValue T?

Value that is returned if the requested element value does not exist.

Returns

T?

Type Parameters

T

Type of the return value. This cannot be an array type.

Exceptions

MedicalApiException

The tag is multivalued.

GetValue<t>(Tag, int)

Gets the index-th element value of the specified tag.

public T GetValue<t>(Tag tag, int index)

Parameters

tag Tag

The requested DICOM tag.

index int

The element index.

Returns

T

The T element value corresponding to tag.

Type Parameters

T

Type of the return value (collections aren’t allowed).

Exceptions

MedicalApiException

The dataset does not contain tag, or the specified index is out of range or element’s value can’t be converted to the specified type.

GetValue<t>(Tag, Index)

Gets the index-th element value of the specified tag.

public T GetValue<t>(Tag tag, Index index)

Parameters

tag Tag

The requested DICOM tag.

index Index

The element index.

Returns

T

The T element value corresponding to tag.

Type Parameters

T

Type of the return value (collections aren’t allowed).

Exceptions

MedicalApiException

The dataset does not contain tag, or the specified index is out of range or element’s value can’t be converted to the specified type.

GetValueOrDefault<t>(Tag, int, T)

Gets the index-th element value of the specified tag or the defaultValue if the requested value is not contained in the dataset.

public T GetValueOrDefault<t>(Tag tag, int index, T defaultValue)

Parameters

tag Tag

The requested DICOM tag.

index int

The element index.

defaultValue T

The value that is returned if the requested element value does not exist.

Returns

T

Type Parameters

T

Type of the return value (collections aren’t allowed).

GetValueOrDefault<t>(Tag, Index, T)

Gets the index-th element value of the specified tag or the defaultValue if the requested value is not contained in the dataset.

public T GetValueOrDefault<t>(Tag tag, Index index, T defaultValue)

Parameters

tag Tag

The requested DICOM tag.

index Index

The element index.

defaultValue T

The value that is returned if the requested element value does not exist.

Returns

T

Type Parameters

T

Type of the return value (collections aren’t allowed).

GetValues<t>(Tag)

Gets the element values of the specified tag.

public Span<t> GetValues<t>(Tag tag)

Parameters

tag Tag

The requested DICOM tag.

Returns

Span <t>

The T element values corresponding to tag.

Type Parameters

T

Type of the return value (collections aren’t allowed).

Exceptions

MedicalApiException

The dataset does not contain tag or element’s value can’t be converted to the specified type.

GetValues<t>(Tag, Range)

Gets the element values of the specified tag.

public Span<t> GetValues<t>(Tag tag, Range range)

Parameters

tag Tag

The requested DICOM tag.

range Range

The range of the element values to retrieve.

Returns

Span <t>

The T element values corresponding to tag.

Type Parameters

T

Type of the return value (collections aren’t allowed).

Exceptions

MedicalApiException

The dataset does not contain tag or element’s value can’t be converted to the specified type.

Remove(Tag)

Removes element for given tag.

public void Remove(Tag tag)

Parameters

tag Tag

DICOM tag to remove.

Remove(params Tag[])

Removes elements for given tags.

public void Remove(params Tag[] tags)

Parameters

tags Tag []

DICOM tags to remove.

Remove(Func<ielement, bool="">)

Removes all the elements that match the conditions defined by the specified predicate.

public void Remove(Func<ielement, bool=""> predicate)

Parameters

predicate Func < IElement , bool &gt;

The delegate that defines the conditions of the elements to remove.

Transcode(TransferSyntax)

Transcodes this Aspose.Medical.Dicom.Dataset to the given syntax.

public Dataset Transcode(TransferSyntax syntax)

Parameters

syntax TransferSyntax

The destination transfer syntax this dataset will be transcoded to.

Returns

Dataset

The transcoded Aspose.Medical.Dicom.Dataset.

Exceptions

MedicalApiException

Transcoding to the given syntax is not supported.

TryGetSingleValue<t>(Tag, out T?)

Gets the element value of the specified tag, whose value multiplicity has to be 1.

public bool TryGetSingleValue<t>(Tag tag, out T? value)

Parameters

tag Tag

The requested DICOM tag.

value T?

When this method returns, contains the value associated with the tag, if the tag is found; otherwise, contains the default value for the type of the value parameter.

Returns

bool

true if the element value could be extracted; otherwise false.

Type Parameters

T

Type of the return value. This cannot be an array type.

Exceptions

MedicalApiException

The tag is multivalued.

TryGetValue<t>(Tag, int, out T?)

Gets the index-th element value of the specified tag.

public bool TryGetValue<t>(Tag tag, int index, out T? value)

Parameters

tag Tag

Requested DICOM tag.

index int

Item index (for multi-valued elements).

value T?

When this method returns, contains the value associated with the tag, if the tag is found; otherwise, contains the default value for the type of the value parameter.

Returns

bool

true if the element value could be extracted; otherwise false.

Type Parameters

T

Type of the return value. This cannot be an array type.

TryGetValue<t>(Tag, Index, out T?)

Gets the index-th element value of the specified tag.

public bool TryGetValue<t>(Tag tag, Index index, out T? value)

Parameters

tag Tag

Requested DICOM tag.

index Index

Item index (for multi-valued elements).

value T?

When this method returns, contains the value associated with the tag, if the tag is found; otherwise, contains the default value for the type of the value parameter.

Returns

bool

true if the element value could be extracted; otherwise false.

Type Parameters

T

Type of the return value. This cannot be an array type. </t></t></t></ielement,></ielement,></t></t></t></t></t></t></t></t></t></t></t></t></t></t></ielement></t></t></t></t></t></t></t></t></ielement></ielement>