Fellow Oak DICOM
Search Results for

    Show / Hide Table of Contents

    Class DicomFile

    Representation of one DICOM file.

    Inheritance
    System.Object
    DicomFile
    DicomDirectory
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: FellowOakDicom
    Assembly: fo-dicom.core.dll
    Syntax
    public class DicomFile

    Constructors

    DicomFile()

    Declaration
    public DicomFile()

    DicomFile(DicomDataset)

    Declaration
    public DicomFile(DicomDataset dataset)
    Parameters
    Type Name Description
    DicomDataset dataset

    Properties

    Dataset

    Gets the DICOM dataset of the file.

    Declaration
    public DicomDataset Dataset { get; protected set; }
    Property Value
    Type Description
    DicomDataset

    File

    Gets the file reference of the DICOM file.

    Declaration
    public IFileReference File { get; protected set; }
    Property Value
    Type Description
    IFileReference

    FileMetaInfo

    Gets the DICOM file meta information of the file.

    Declaration
    public DicomFileMetaInformation FileMetaInfo { get; protected set; }
    Property Value
    Type Description
    DicomFileMetaInformation

    Format

    Gets the DICOM file format.

    Declaration
    public DicomFileFormat Format { get; protected set; }
    Property Value
    Type Description
    DicomFileFormat

    IsPartial

    Gets whether the parsing of the file ended prematurely.

    Declaration
    public bool IsPartial { get; protected set; }
    Property Value
    Type Description
    System.Boolean

    Methods

    HandleOpenError(DicomFile, DicomReaderResult)

    Throw if reading the file resulted in an error.

    Declaration
    protected static void HandleOpenError(DicomFile dicomFile, DicomReaderResult result)
    Parameters
    Type Name Description
    DicomFile dicomFile
    DicomReaderResult result
    Exceptions
    Type Condition
    DicomFileException

    If the file could not be read properly.

    HasValidHeader(String)

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

    Declaration
    public static bool HasValidHeader(string path)
    Parameters
    Type Name Description
    System.String path

    Path to file

    Returns
    Type Description
    System.Boolean

    True if valid DICOM 3.0 file header is detected.

    OnSave()

    Method to call before performing the actual saving.

    Declaration
    protected virtual void OnSave()

    Open(Stream, FileReadOption, Int32)

    Read a DICOM file from stream.

    Declaration
    public static DicomFile Open(Stream stream, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)
    Parameters
    Type Name Description
    System.IO.Stream stream

    Stream to read.

    FileReadOption readOption

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

    System.Int32 largeObjectSize

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

    Returns
    Type Description
    DicomFile

    Read DicomFile.

    Open(Stream, Encoding, Func<ParseState, Boolean>, FileReadOption, Int32)

    Read a DICOM file from stream.

    Declaration
    public static DicomFile Open(Stream stream, Encoding fallbackEncoding, Func<ParseState, bool> stop = null, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)
    Parameters
    Type Name Description
    System.IO.Stream stream

    Stream to read.

    System.Text.Encoding fallbackEncoding

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

    System.Func<ParseState, System.Boolean> stop

    Stop criterion in dataset.

    FileReadOption readOption

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

    System.Int32 largeObjectSize

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

    Returns
    Type Description
    DicomFile

    Read DicomFile.

    Open(String, FileReadOption, Int32)

    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

    Declaration
    public static DicomFile Open(string fileName, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)
    Parameters
    Type Name Description
    System.String fileName

    The filename of the DICOM file

    FileReadOption readOption

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

    System.Int32 largeObjectSize

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

    Returns
    Type Description
    DicomFile

    DicomFile instance

    Open(String, Encoding, Func<ParseState, Boolean>, FileReadOption, Int32)

    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

    Declaration
    public static DicomFile Open(string fileName, Encoding fallbackEncoding, Func<ParseState, bool> stop = null, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)
    Parameters
    Type Name Description
    System.String fileName

    The filename of the DICOM file

    System.Text.Encoding fallbackEncoding

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

    System.Func<ParseState, System.Boolean> stop

    Stop criterion in dataset.

    FileReadOption readOption

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

    System.Int32 largeObjectSize

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

    Returns
    Type Description
    DicomFile

    DicomFile instance

    OpenAsync(Stream, FileReadOption, Int32)

    Asynchronously read a DICOM file from stream.

    Declaration
    public static Task<DicomFile> OpenAsync(Stream stream, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)
    Parameters
    Type Name Description
    System.IO.Stream stream

    Stream to read.

    FileReadOption readOption

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

    System.Int32 largeObjectSize

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

    Returns
    Type Description
    System.Threading.Tasks.Task<DicomFile>

    Awaitable DicomFile instance.

    OpenAsync(Stream, Encoding, Func<ParseState, Boolean>, FileReadOption, Int32)

    Asynchronously read a DICOM file from stream.

    Declaration
    public static async Task<DicomFile> OpenAsync(Stream stream, Encoding fallbackEncoding, Func<ParseState, bool> stop = null, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)
    Parameters
    Type Name Description
    System.IO.Stream stream

    Stream to read.

    System.Text.Encoding fallbackEncoding

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

    System.Func<ParseState, System.Boolean> stop

    Stop criterion in dataset.

    FileReadOption readOption

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

    System.Int32 largeObjectSize

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

    Returns
    Type Description
    System.Threading.Tasks.Task<DicomFile>

    Awaitable DicomFile instance.

    OpenAsync(String, FileReadOption, Int32)

    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

    Declaration
    public static Task<DicomFile> OpenAsync(string fileName, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)
    Parameters
    Type Name Description
    System.String fileName

    The filename of the DICOM file

    FileReadOption readOption

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

    System.Int32 largeObjectSize

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

    Returns
    Type Description
    System.Threading.Tasks.Task<DicomFile>

    Awaitable DicomFile instance.

    OpenAsync(String, Encoding, Func<ParseState, Boolean>, FileReadOption, Int32)

    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

    Declaration
    public static async Task<DicomFile> OpenAsync(string fileName, Encoding fallbackEncoding, Func<ParseState, bool> stop = null, FileReadOption readOption = FileReadOption.Default, int largeObjectSize = 0)
    Parameters
    Type Name Description
    System.String fileName

    The filename of the DICOM file

    System.Text.Encoding fallbackEncoding

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

    System.Func<ParseState, System.Boolean> stop

    Stop criterion in dataset.

    FileReadOption readOption

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

    System.Int32 largeObjectSize

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

    Returns
    Type Description
    System.Threading.Tasks.Task<DicomFile>

    Awaitable DicomFile instance.

    Save(Stream, DicomWriteOptions)

    Save DICOM file to stream.

    Declaration
    public void Save(Stream stream, DicomWriteOptions options = null)
    Parameters
    Type Name Description
    System.IO.Stream stream

    Stream on which to save DICOM file.

    DicomWriteOptions options

    Options to apply during writing.

    Save(String, DicomWriteOptions)

    Save DICOM file.

    Declaration
    public void Save(string fileName, DicomWriteOptions options = null)
    Parameters
    Type Name Description
    System.String fileName

    File name.

    DicomWriteOptions options

    Options to apply during writing.

    SaveAsync(Stream, DicomWriteOptions)

    Asynchronously save DICOM file to stream.

    Declaration
    public async Task SaveAsync(Stream stream, DicomWriteOptions options = null)
    Parameters
    Type Name Description
    System.IO.Stream stream

    Stream on which to save DICOM file.

    DicomWriteOptions options

    Options to apply during writing.

    Returns
    Type Description
    System.Threading.Tasks.Task

    Awaitable task.

    SaveAsync(String, DicomWriteOptions)

    Save to file asynchronously.

    Declaration
    public async Task SaveAsync(string fileName, DicomWriteOptions options = null)
    Parameters
    Type Name Description
    System.String fileName

    Name of file.

    DicomWriteOptions options

    Options to apply during writing.

    Returns
    Type Description
    System.Threading.Tasks.Task

    Awaitable System.Threading.Tasks.Task.

    ToString()

    Returns a string that represents the current object.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    A string that represents the current object.

    Overrides
    System.Object.ToString()

    Extension Methods

    DicomFileExtensions.Clone(DicomFile)
    ConsoleExtensions.WriteToConsole(DicomFile)
    Extensions.WriteToLog(DicomFile, ILogger, LogLevel)
    Extensions.WriteToLog(DicomFile, ILogger, LogLevel)
    Extensions.WriteToString(DicomFile)
    DicomXML.WriteToXml(DicomFile)
    LinqExtensions.IsOneOf<T>(T, T[])
    DicomCodecExtensions.Clone(DicomFile, DicomTransferSyntax, DicomCodecParams)
    In This Article
    Back to top Copyright (c) 2012-2025 fo-dicom contributors