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
DicomDatasetValues with that the DicomFile is initialized
Properties
Dataset
Gets the DICOM dataset of the file.
public DicomDataset Dataset { get; protected set; }
Property Value
File
Gets the file reference of the DICOM file.
public IFileReference File { get; protected set; }
Property Value
FileMetaInfo
Gets the DICOM file meta information of the file.
public DicomFileMetaInformation FileMetaInfo { get; protected set; }
Property Value
Format
Gets the DICOM file format.
public DicomFileFormat Format { get; protected set; }
Property Value
IsPartial
Gets whether the parsing of the file ended prematurely.
public bool IsPartial { get; protected set; }
Property Value
Methods
HandleOpenError(DicomFile, DicomReaderResult)
Throw if reading the file resulted in an error.
protected static void HandleOpenError(DicomFile dicomFile, DicomReaderResult result)
Parameters
dicomFile
DicomFileresult
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
stringPath 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
StreamStream to read.
readOption
FileReadOptionThe option how to deal with large DICOM tags like pixel data.
largeObjectSize
intCustom limit of what are large values and what are not. If 0 is passed, then the default of 64k is used.
Returns
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
StreamStream to read.
fallbackEncoding
EncodingEncoding to use if encoding cannot be obtained from DICOM file.
stop
Func<ParseState, bool>Stop criterion in dataset.
readOption
FileReadOptionThe option how to deal with large DICOM tag like pixel data
largeObjectSize
intCustom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.
Returns
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
stringThe filename of the DICOM file
readOption
FileReadOptionAn option how to deal with large dicom tags like pixel data.
largeObjectSize
intCustom 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
stringThe filename of the DICOM file
fallbackEncoding
EncodingEncoding to apply when attribute Specific Character Set is not available.
stop
Func<ParseState, bool>Stop criterion in dataset.
readOption
FileReadOptionOption how to deal with large values, if they should be loaded directly into memory or lazy loaded on demand
largeObjectSize
intCustom 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
StreamStream to read.
readOption
FileReadOptionThe option how to deal with large DICOM tags like pixel data.
largeObjectSize
intCustom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.
Returns
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
StreamStream to read.
fallbackEncoding
EncodingEncoding to use if encoding cannot be obtained from DICOM file.
stop
Func<ParseState, bool>Stop criterion in dataset.
readOption
FileReadOptionThe option how to deal with large DICOM tags like pixel data.
largeObjectSize
intCustom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.
Returns
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
stringThe filename of the DICOM file
readOption
FileReadOptionThe option how to deal with large dicom tags like pixel data.
largeObjectSize
intCustom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.
Returns
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
stringThe filename of the DICOM file
fallbackEncoding
EncodingEncoding to apply when attribute Specific Character Set is not available.
stop
Func<ParseState, bool>Stop criterion in dataset.
readOption
FileReadOptionOption how to deal with large values, if they should be loaded directly into memory or lazy loaded on demand
largeObjectSize
intCustom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.
Returns
Save(Stream, DicomWriteOptions)
Save DICOM file to stream.
public void Save(Stream stream, DicomWriteOptions options = null)
Parameters
stream
StreamStream on which to save DICOM file.
options
DicomWriteOptionsOptions to apply during writing.
Save(string, DicomWriteOptions)
Save DICOM file.
public void Save(string fileName, DicomWriteOptions options = null)
Parameters
fileName
stringFile name.
options
DicomWriteOptionsOptions to apply during writing.
SaveAsync(Stream, DicomWriteOptions)
Asynchronously save DICOM file to stream.
public Task SaveAsync(Stream stream, DicomWriteOptions options = null)
Parameters
stream
StreamStream on which to save DICOM file.
options
DicomWriteOptionsOptions 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
stringName of file.
options
DicomWriteOptionsOptions to apply during writing.
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.