Table of Contents

Class DicomFile

Namespace
FellowOakDicom
Assembly
fo-dicom.core.dll

Representation of one DICOM file.

public class DicomFile
Inheritance
DicomFile
Derived
Inherited Members
Extension Methods

Constructors

DicomFile()

public DicomFile()

DicomFile(DicomDataset)

Constructs a DicomFile instance. Dataset and FileMetaInfo are initialized from values contained in parameter dataset

public DicomFile(DicomDataset dataset)

Parameters

dataset DicomDataset

Values with that the DicomFile is initialized

Properties

Dataset

Gets the DICOM dataset of the file.

public DicomDataset Dataset { get; protected set; }

Property Value

DicomDataset

File

Gets the file reference of the DICOM file.

public IFileReference File { get; protected set; }

Property Value

IFileReference

FileMetaInfo

Gets the DICOM file meta information of the file.

public DicomFileMetaInformation FileMetaInfo { get; protected set; }

Property Value

DicomFileMetaInformation

Format

Gets the DICOM file format.

public DicomFileFormat Format { get; protected set; }

Property Value

DicomFileFormat

IsPartial

Gets whether the parsing of the file ended prematurely.

public bool IsPartial { get; protected set; }

Property Value

bool

Methods

HandleOpenError(DicomFile, DicomReaderResult)

Throw if reading the file resulted in an error.

protected static void HandleOpenError(DicomFile dicomFile, DicomReaderResult result)

Parameters

dicomFile DicomFile
result DicomReaderResult

Exceptions

DicomFileException

If the file could not be read properly.

HasValidHeader(string)

Test if file has a valid preamble and DICOM 3.0 header.

public static bool HasValidHeader(string path)

Parameters

path string

Path to file

Returns

bool

True if valid DICOM 3.0 file header is detected.

OnSave()

Method to call before performing the actual saving.

protected virtual void OnSave()

Open(Stream, FileReadOption, int)

Read a DICOM file from stream.

public static DicomFile Open(Stream stream, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)

Parameters

stream Stream

Stream to read.

readOption FileReadOption

The option how to deal with large DICOM tags like pixel data.

largeObjectSize int

Custom limit of what are large values and what are not. If 0 is passed, then the default of 64k is used.

Returns

DicomFile

Read DicomFile.

Open(Stream, Encoding, Func<ParseState, bool>, FileReadOption, int)

Read a DICOM file from stream.

public static DicomFile Open(Stream stream, Encoding fallbackEncoding, Func<ParseState, bool> stop = null, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)

Parameters

stream Stream

Stream to read.

fallbackEncoding Encoding

Encoding to use if encoding cannot be obtained from DICOM file.

stop Func<ParseState, bool>

Stop criterion in dataset.

readOption FileReadOption

The option how to deal with large DICOM tag like pixel data

largeObjectSize int

Custom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.

Returns

DicomFile

Read DicomFile.

Open(string, FileReadOption, int)

Reads the specified filename and returns a DicomFile object. Note that the values for large DICOM elements (e.g. PixelData) are read in "on demand" to conserve memory. Large DICOM elements are determined by their size in bytes - see the default value for this in the FileByteSource._largeObjectSize

public static DicomFile Open(string fileName, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)

Parameters

fileName string

The filename of the DICOM file

readOption FileReadOption

An option how to deal with large dicom tags like pixel data.

largeObjectSize int

Custom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.

Returns

DicomFile

DicomFile instance

Open(string, Encoding, Func<ParseState, bool>, FileReadOption, int)

Reads the specified filename and returns a DicomFile object. Note that the values for large DICOM elements (e.g. PixelData) are read in "on demand" to conserve memory. Large DICOM elements are determined by their size in bytes - see the default value for this in the FileByteSource._largeObjectSize

public static DicomFile Open(string fileName, Encoding fallbackEncoding, Func<ParseState, bool> stop = null, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)

Parameters

fileName string

The filename of the DICOM file

fallbackEncoding Encoding

Encoding to apply when attribute Specific Character Set is not available.

stop Func<ParseState, bool>

Stop criterion in dataset.

readOption FileReadOption

Option how to deal with large values, if they should be loaded directly into memory or lazy loaded on demand

largeObjectSize int

Custom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.

Returns

DicomFile

DicomFile instance

OpenAsync(Stream, FileReadOption, int)

Asynchronously read a DICOM file from stream.

public static Task<DicomFile> OpenAsync(Stream stream, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)

Parameters

stream Stream

Stream to read.

readOption FileReadOption

The option how to deal with large DICOM tags like pixel data.

largeObjectSize int

Custom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.

Returns

Task<DicomFile>

Awaitable DicomFile instance.

OpenAsync(Stream, Encoding, Func<ParseState, bool>, FileReadOption, int)

Asynchronously read a DICOM file from stream.

public static Task<DicomFile> OpenAsync(Stream stream, Encoding fallbackEncoding, Func<ParseState, bool> stop = null, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)

Parameters

stream Stream

Stream to read.

fallbackEncoding Encoding

Encoding to use if encoding cannot be obtained from DICOM file.

stop Func<ParseState, bool>

Stop criterion in dataset.

readOption FileReadOption

The option how to deal with large DICOM tags like pixel data.

largeObjectSize int

Custom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.

Returns

Task<DicomFile>

Awaitable DicomFile instance.

OpenAsync(string, FileReadOption, int)

Asynchronously reads the specified filename and returns a DicomFile object. Note that the values for large DICOM elements (e.g. PixelData) are read in "on demand" to conserve memory. Large DICOM elements are determined by their size in bytes - see the default value for this in the FileByteSource._largeObjectSize

public static Task<DicomFile> OpenAsync(string fileName, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)

Parameters

fileName string

The filename of the DICOM file

readOption FileReadOption

The option how to deal with large dicom tags like pixel data.

largeObjectSize int

Custom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.

Returns

Task<DicomFile>

Awaitable DicomFile instance.

OpenAsync(string, Encoding, Func<ParseState, bool>, FileReadOption, int)

Asynchronously reads the specified filename and returns a DicomFile object. Note that the values for large DICOM elements (e.g. PixelData) are read in "on demand" to conserve memory. Large DICOM elements are determined by their size in bytes - see the default value for this in the FileByteSource._largeObjectSize

public static Task<DicomFile> OpenAsync(string fileName, Encoding fallbackEncoding, Func<ParseState, bool> stop = null, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)

Parameters

fileName string

The filename of the DICOM file

fallbackEncoding Encoding

Encoding to apply when attribute Specific Character Set is not available.

stop Func<ParseState, bool>

Stop criterion in dataset.

readOption FileReadOption

Option how to deal with large values, if they should be loaded directly into memory or lazy loaded on demand

largeObjectSize int

Custom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.

Returns

Task<DicomFile>

Awaitable DicomFile instance.

Save(Stream, DicomWriteOptions)

Save DICOM file to stream.

public void Save(Stream stream, DicomWriteOptions options = null)

Parameters

stream Stream

Stream on which to save DICOM file.

options DicomWriteOptions

Options to apply during writing.

Save(string, DicomWriteOptions)

Save DICOM file.

public void Save(string fileName, DicomWriteOptions options = null)

Parameters

fileName string

File name.

options DicomWriteOptions

Options to apply during writing.

SaveAsync(Stream, DicomWriteOptions)

Asynchronously save DICOM file to stream.

public Task SaveAsync(Stream stream, DicomWriteOptions options = null)

Parameters

stream Stream

Stream on which to save DICOM file.

options DicomWriteOptions

Options to apply during writing.

Returns

Task

Awaitable task.

SaveAsync(string, DicomWriteOptions)

Save to file asynchronously.

public Task SaveAsync(string fileName, DicomWriteOptions options = null)

Parameters

fileName string

Name of file.

options DicomWriteOptions

Options to apply during writing.

Returns

Task

Awaitable Task.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.