fo-dicom / fo-dicom

Fellow Oak DICOM for .NET, .NET Core, Universal Windows, Android, iOS, Mono and Unity
https://fo-dicom.github.io/stable/v5/index.html
Other
1.06k stars 638 forks source link

DICOM File Load error #944

Open samprakos opened 4 years ago

samprakos commented 4 years ago

Expected behavior

_dicomFile = DicomFile.Open(_rawData) succeeds (raw data is a Stream)

Actual behavior

Error Message:
Dicom.DicomFileException : Input string was not in a correct format.

---- System.FormatException : Input string was not in a correct format. Stack Trace: at Dicom.DicomFile.Open(Stream stream, Encoding fallbackEncoding, Func2 stop, FileReadOption readOption) in C:\dev\GitHub\fo-dicom\fo-dicom\DICOM\DicomFile.cs:line 323 at Phoenix.Core.VMSFileManager.VMSDicom.FODicom.LoadIfNecessary() in /Users/esamprakos/go/src/github.com/idexx/phoenix/app/Phoenix.Core/VMSFileManager/VMSDicom/FODicom.cs:line 114 at Phoenix.Core.VMSFileManager.VMSDicom.FODicom.TagExists(UInt32 tag) in /Users/esamprakos/go/src/github.com/idexx/phoenix/app/Phoenix.Core/VMSFileManager/VMSDicom/FODicom.cs:line 74 at Phoenix.Core.Tests.FileManager.VMSDicom.DicomTests.TestTagExists_TEL38615() in /Users/esamprakos/go/src/github.com/idexx/phoenix/app/Phoenix.Core.Tests/VMSFileManager/VMSDicom/DicomTests.cs:line 254 ----- Inner Stack Trace ----- at System.Text.StringBuilder.FormatError() at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args) at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args) at System.String.Format(String format, Object[] args) at Dicom.DicomFile.Open(Stream stream, Encoding fallbackEncoding, Func2 stop, FileReadOption readOption) in C:\dev\GitHub\fo-dicom\fo-dicom\DICOM\DicomFile.cs:line 306

Steps to reproduce the behavior

Load the attached file using fi-dicom version 4.03

NOTE: File loads fine using DicomObjects (windows) and using dcmdump (MacOS).

dcmdump output:

dcmdump ~/OneDrive\ -\ IDEXX/IDEXX/VMS/UploadTestImages/TEL38615.dcm 

# Dicom-File-Format

# Dicom-Meta-Information-Header
# Used TransferSyntax: Little Endian Explicit
(0002,0000) UL 140                                      #   4, 1 FileMetaInformationGroupLength
(0002,0001) OB 00\01                                    #   2, 1 FileMetaInformationVersion
(0002,0002) UI =DigitalXRayImageStorageForPresentation  #  28, 1 MediaStorageSOPClassUID
(0002,0003) UI [1.2.276.0.74.3.20040810120315.1.1]      #  34, 1 MediaStorageSOPInstanceUID
(0002,0010) UI =LittleEndianExplicit                    #  20, 1 TransferSyntaxUID
(0002,0012) UI [1.2.276.0.74]                           #  12, 1 ImplementationClassUID

# Dicom-Data-Set
# Used TransferSyntax: Little Endian Explicit
(0008,0016) UI =DigitalXRayImageStorageForPresentation  #  28, 1 SOPClassUID
(0008,0018) UI [1.2.276.0.74.3.20040810120315.1.1]      #  34, 1 SOPInstanceUID
(0008,0020) DA [20040810]                               #   8, 1 StudyDate
(0008,0021) DA [20040810]                               #   8, 1 SeriesDate
(0008,0030) TM [120315]                                 #   6, 1 StudyTime
(0008,0031) TM [120315]                                 #   6, 1 SeriesTime
(0008,0050) SH (no value available)                     #   0, 0 AccessionNumber
(0008,0060) CS [DX]                                     #   2, 1 Modality
(0008,0070) LO [IDEXX Laboratories, Inc.]               #  24, 1 Manufacturer
(0008,0080) LO (no value available)                     #   0, 0 InstitutionName
(0008,0090) PN (no value available)                     #   0, 0 ReferringPhysicianName
(0008,1030) LO [2004/08/10 12:03:15]                   #  20, 1 StudyDescription
(0008,103e) LO [RF Foot Ext]                           #  12, 1 SeriesDescription
(0008,1090) LO [DX810--unknown serial no--]             #  26, 1 ManufacturerModelName
(0010,0010) PN [Abbey^Arnsman,Maria]                   #  20, 1 PatientName
(0010,0020) LO [91415874-7850-4b05-8af6-5d5f15eff4ad]   #  36, 1 PatientID
(0010,0030) DA [20040810]                               #   8, 1 PatientBirthDate
(0010,0040) CS [F]                                     #   2, 1 PatientSex
(0010,1000) LO (no value available)                     #   0, 0 RETIRED_OtherPatientIDs
(0010,1001) PN [Horse]                                 #   6, 1 OtherPatientNames
(0010,1002) UN 41\72\6e\73\6d\61\6e\2c\4d\61\72\69\61\00 #  14, 1 OtherPatientIDsSequence
(0018,0015) CS [RF - Lat Med]                           #  12, 1 BodyPartExamined
(0018,1020) LO (no value available)                     #   0, 0 SoftwareVersions
(0018,1164) DS [0.129\0.129]                           #  12, 2 ImagerPixelSpacing
(0018,5101) CS (no value available)                     #   0, 0 ViewPosition
(0020,000d) UI [1.2.276.0.74.1.20040810120315]          #  30, 1 StudyInstanceUID
(0020,000e) UI [1.2.276.0.74.2.20040810120315.1]        #  32, 1 SeriesInstanceUID
(0020,0010) SH [20040810120315]                         #  14, 1 StudyID
(0020,0011) IS [1]                                     #   2, 1 SeriesNumber
(0020,0013) IS [1]                                     #   2, 1 InstanceNumber
(0020,0020) CS (no value available)                     #   0, 0 PatientOrientation
(0020,4000) LT (no value available)                     #   0, 0 ImageComments
(0028,0002) US 1                                        #   2, 1 SamplesPerPixel
(0028,0004) CS [MONOCHROME1]                           #  12, 1 PhotometricInterpretation
(0028,0010) US 1536                                     #   2, 1 Rows
(0028,0011) US 2048                                     #   2, 1 Columns
(0028,0030) DS [0.129\0.129]                           #  12, 2 PixelSpacing
(0028,0034) IS [1\1]                                   #   4, 2 PixelAspectRatio
(0028,0100) US 16                                       #   2, 1 BitsAllocated
(0028,0101) US 14                                       #   2, 1 BitsStored
(0028,0102) US 13                                       #   2, 1 HighBit
(0028,0103) US 0                                        #   2, 1 PixelRepresentation
(0028,1050) DS [4088]                                   #   4, 1 WindowCenter
(0028,1051) DS [16353]                                 #   6, 1 WindowWidth
(0028,1052) DS [-286643.2]                             #  10, 1 RescaleIntercept
(0028,1053) DS [30.73921]                               #   8, 1 RescaleSlope
(7fe0,0010) OB 75\34\59\34\d9\07\04\18\1d\28\ea\25\b9\23\dc\25\fd\27\e4\27\ca\27... # 6291456, 1 PixelData

fo-dicom version and OS/platform

fo-dicom: 4.0.3 OS: MacOS 10.14.6

TEL38615.dcm.zip

gofal commented 4 years ago

the file is corrupt.

Because in Tag 0010,1002 "other patient ids sequece", which is defined as VR SQ, there is a value of 14 characters: "Arnsman,Maria" plus the ending 0-character. Because the tag is defined as SQ, fo-dicom wants to parse the content as sq and fails.

As you can see in dcmdump output, it also could not parse the content of tag 0010,1002. instead of writing its string content, the application outputs the raw byte array values.

Fo-dicom tries to be as tollerant as possible when reading/receiving data. So corrupt files, where there is an obvious fix, should be readable. But this file here as no obvious fix. Because the tag OberPatiendIdsSequence requires a sequence. I cannot convert the content into a sequece. And I do not like to open a file without an error and silently removing some content.

Any ideas?

samprakos commented 4 years ago

Ah makes sense thank you that was helpful.

Ideally it would be good if the library read the whole file and maintained a list of parsing errors that I could interrogate and handle accordingly after the fact.

Or, 2nd choice, provide more context about the parsing error (e.g. Error parsing tag 0010,1002).

gofal commented 4 years ago

adding more information to the parsing error would not be too hard to implement. I could also think about adding a property DatasetParsedSoFar that contains the information that has been parsed until the exception had happened. So even if there is an exception, you have at least some data.

2024AmitRamraje commented 2 years ago

Hello gofal,

I am also facing some issues but a little bit different from the above one. I am sharing with you snapshot for your reference.

Looking forward to hearing from you. Diacom Error 2022-04-27 095854

2024AmitRamraje commented 2 years ago

I am just starting my career as a Developer in C#. The source code is below one. Erroe_DICOM Core dll 2022-04-27 104721

mrbean-bremen commented 2 years ago

@2024AmitRamraje - if you have a different issue, please write a separate issue. Also, without seeing the DICOM data (an anomymized version of the problematic file if possible, otherwise a dump as done by the author of this issue) there is not much we can help. Finally, please do not post screenshots of code, but the code itself in text form, so that it can be copied.

2024AmitRamraje commented 2 years ago

@2024AmitRamraje - if you have a different issue, please write a separate issue. Also, without seeing the DICOM data (an anomymized version of the problematic file if possible, otherwise a dump as done by the author of this issue) there is not much we can help. Finally, please do not post screenshots of code, but the code itself in text form, so that it can be copied.

I apologize for my mistake in the query. I will keep this in mind afterward. Thank you for your kind reply on it.