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
datasetDicomDatasetValues with that the DicomFile is initialized
Properties
Dataset
Gets the DICOM dataset of the file.
public DicomDataset Dataset { get; }
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
dicomFileDicomFileresultDicomReaderResult
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
pathstringPath 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
streamStreamStream to read.
readOptionFileReadOptionThe option how to deal with large DICOM tags like pixel data.
largeObjectSizeintCustom 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
streamStreamStream to read.
fallbackEncodingEncodingEncoding to use if encoding cannot be obtained from DICOM file.
stopFunc<ParseState, bool>Stop criterion in dataset.
readOptionFileReadOptionThe option how to deal with large DICOM tag like pixel data
largeObjectSizeintCustom 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
fileNamestringThe filename of the DICOM file
readOptionFileReadOptionAn option how to deal with large dicom tags like pixel data.
largeObjectSizeintCustom 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
fileNamestringThe filename of the DICOM file
fallbackEncodingEncodingEncoding to apply when attribute Specific Character Set is not available.
stopFunc<ParseState, bool>Stop criterion in dataset.
readOptionFileReadOptionOption how to deal with large values, if they should be loaded directly into memory or lazy loaded on demand
largeObjectSizeintCustom 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
streamStreamStream to read.
readOptionFileReadOptionThe option how to deal with large DICOM tags like pixel data.
largeObjectSizeintCustom 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
streamStreamStream to read.
fallbackEncodingEncodingEncoding to use if encoding cannot be obtained from DICOM file.
stopFunc<ParseState, bool>Stop criterion in dataset.
readOptionFileReadOptionThe option how to deal with large DICOM tags like pixel data.
largeObjectSizeintCustom 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
fileNamestringThe filename of the DICOM file
readOptionFileReadOptionThe option how to deal with large dicom tags like pixel data.
largeObjectSizeintCustom 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
fileNamestringThe filename of the DICOM file
fallbackEncodingEncodingEncoding to apply when attribute Specific Character Set is not available.
stopFunc<ParseState, bool>Stop criterion in dataset.
readOptionFileReadOptionOption how to deal with large values, if they should be loaded directly into memory or lazy loaded on demand
largeObjectSizeintCustom 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
streamStreamStream on which to save DICOM file.
optionsDicomWriteOptionsOptions to apply during writing.
Save(string, DicomWriteOptions)
Save DICOM file.
public void Save(string fileName, DicomWriteOptions options = null)
Parameters
fileNamestringFile name.
optionsDicomWriteOptionsOptions to apply during writing.
SaveAsync(Stream, DicomWriteOptions)
Asynchronously save DICOM file to stream.
public Task SaveAsync(Stream stream, DicomWriteOptions options = null)
Parameters
streamStreamStream on which to save DICOM file.
optionsDicomWriteOptionsOptions to apply during writing.
Returns
- Task
Awaitable task.
SaveAsync(string, DicomWriteOptions)
Save to file asynchronously.
public Task SaveAsync(string fileName, DicomWriteOptions options = null)
Parameters
fileNamestringName of file.
optionsDicomWriteOptionsOptions 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.