Analyse differences between DICOM filesΒΆ

This examples illustrates how to find the differences between two DICOM files.

  Dataset.file_meta -------------------------------

- (0002,0000) File Meta Information Group Length  UL: 190

+ (0002,0000) File Meta Information Group Length  UL: 192

  (0002,0001) File Meta Information Version       OB: b'\x00\x01'

- (0002,0002) Media Storage SOP Class UID         UI: MR Image Storage

+ (0002,0002) Media Storage SOP Class UID         UI: CT Image Storage

- (0002,0003) Media Storage SOP Instance UID      UI: 1.3.6.1.4.1.5962.1.1.4.1.1.20040826185059.5457

+ (0002,0003) Media Storage SOP Instance UID      UI: 1.3.6.1.4.1.5962.1.1.1.1.1.20040119072730.12322

  (0002,0010) Transfer Syntax UID                 UI: Explicit VR Little Endian

  (0002,0012) Implementation Class UID            UI: 1.3.6.1.4.1.5962.2

  (0002,0013) Implementation Version Name         SH: 'DCTOOL100'

  (0002,0016) Source Application Entity Title     AE: 'CLUNIE1'

  -------------------------------------------------

+ (0008,0005) Specific Character Set              CS: 'ISO_IR 100'

- (0008,0008) Image Type                          CS: ['DERIVED', 'SECONDARY', 'OTHER']

+ (0008,0008) Image Type                          CS: ['ORIGINAL', 'PRIMARY', 'AXIAL']

- (0008,0012) Instance Creation Date              DA: '20040826'

+ (0008,0012) Instance Creation Date              DA: '20040119'

- (0008,0013) Instance Creation Time              TM: '185434'

+ (0008,0013) Instance Creation Time              TM: '072731'

  (0008,0014) Instance Creator UID                UI: 1.3.6.1.4.1.5962.3

- (0008,0016) SOP Class UID                       UI: MR Image Storage

+ (0008,0016) SOP Class UID                       UI: CT Image Storage

- (0008,0018) SOP Instance UID                    UI: 1.3.6.1.4.1.5962.1.1.4.1.1.20040826185059.5457

+ (0008,0018) SOP Instance UID                    UI: 1.3.6.1.4.1.5962.1.1.1.1.1.20040119072730.12322

- (0008,0020) Study Date                          DA: '20040826'

+ (0008,0020) Study Date                          DA: '20040119'

- (0008,0021) Series Date                         DA: ''

+ (0008,0021) Series Date                         DA: '19970430'

- (0008,0022) Acquisition Date                    DA: ''

+ (0008,0022) Acquisition Date                    DA: '19970430'

+ (0008,0023) Content Date                        DA: '19970430'

- (0008,0030) Study Time                          TM: '185059'

+ (0008,0030) Study Time                          TM: '072730'

- (0008,0031) Series Time                         TM: ''

+ (0008,0031) Series Time                         TM: '112749'

- (0008,0032) Acquisition Time                    TM: ''

+ (0008,0032) Acquisition Time                    TM: '112936'

+ (0008,0033) Content Time                        TM: '113008'

  (0008,0050) Accession Number                    SH: ''

- (0008,0060) Modality                            CS: 'MR'

+ (0008,0060) Modality                            CS: 'CT'

- (0008,0070) Manufacturer                        LO: 'TOSHIBA_MEC'

+ (0008,0070) Manufacturer                        LO: 'GE MEDICAL SYSTEMS'

- (0008,0080) Institution Name                    LO: 'TOSHIBA'

+ (0008,0080) Institution Name                    LO: 'JFK IMAGING CENTER'

  (0008,0090) Referring Physician's Name          PN: ''

- (0008,0201) Timezone Offset From UTC            SH: '-0400'

+ (0008,0201) Timezone Offset From UTC            SH: '-0500'

- (0008,1010) Station Name                        SH: '000000000'

+ (0008,1010) Station Name                        SH: 'CT01_OC0'

+ (0008,1030) Study Description                   LO: 'e+1'

- (0008,1060) Name of Physician(s) Reading Study  PN: '----'

- (0008,1070) Operators' Name                     PN: '----'

- (0008,1090) Manufacturer's Model Name           LO: 'MRT50H1'

+ (0008,1090) Manufacturer's Model Name           LO: 'RHAPSODE'

+ (0009,0010) Private Creator                     LO: 'GEMS_IDEN_01'

+ (0009,1001) [Full fidelity]                     LO: 'GE_GENESIS_FF'

+ (0009,1002) [Suite id]                          SH: 'CT01'

+ (0009,1004) [Product id]                        SH: 'HiSpeed CT/i'

+ (0009,1027) [Image actual date]                 SL: 862399669

+ (0009,1030) [Service id]                        SH: ''

+ (0009,1031) [Mobile location number]            SH: ''

+ (0009,10E6) [Genesis Version - now]             SH: '05'

+ (0009,10E7) [Exam Record checksum]              UL: 973283917

+ (0009,10E9) [Actual series data time stamp]     SL: 862399669

- (0010,0010) Patient's Name                      PN: 'CompressedSamples^MR1'

+ (0010,0010) Patient's Name                      PN: 'CompressedSamples^CT1'

- (0010,0020) Patient ID                          LO: '4MR1'

+ (0010,0020) Patient ID                          LO: '1CT1'

  (0010,0030) Patient's Birth Date                DA: ''

- (0010,0040) Patient's Sex                       CS: 'F'

+ (0010,0040) Patient's Sex                       CS: 'O'

+ (0010,1002)  Other Patient IDs Sequence  2 item(s) ----

+    (0010,0020) Patient ID                          LO: 'ABCD1234'

+    (0010,0022) Type of Patient ID                  CS: 'TEXT'

+    ---------

+    (0010,0020) Patient ID                          LO: '1234ABCD'

+    (0010,0022) Type of Patient ID                  CS: 'TEXT'

+    ---------

- (0010,1020) Patient's Size                      DS: None

+ (0010,1010) Patient's Age                       AS: '000Y'

- (0010,1030) Patient's Weight                    DS: '80.0000'

+ (0010,1030) Patient's Weight                    DS: '0.000000'

+ (0010,21B0) Additional Patient History          LT: ''

+ (0011,0010) Private Creator                     LO: 'GEMS_PATI_01'

+ (0011,1010) [Patient Status]                    SS: 0

- (0018,0010) Contrast/Bolus Agent                LO: ''

+ (0018,0010) Contrast/Bolus Agent                LO: 'ISOVUE300/100'

- (0018,0020) Scanning Sequence                   CS: 'SE'

- (0018,0021) Sequence Variant                    CS: 'NONE'

- (0018,0022) Scan Options                        CS: ''

+ (0018,0022) Scan Options                        CS: 'HELICAL MODE'

- (0018,0023) MR Acquisition Type                 CS: '3D'

- (0018,0050) Slice Thickness                     DS: '0.8000'

+ (0018,0050) Slice Thickness                     DS: '5.000000'

- (0018,0080) Repetition Time                     DS: '4000.0000'

- (0018,0081) Echo Time                           DS: '240.0000'

+ (0018,0060) KVP                                 DS: '120'

+ (0018,0088) Spacing Between Slices              DS: '5.000000'

+ (0018,0090) Data Collection Diameter            DS: '480.000000'

- (0018,0083) Number of Averages                  DS: '1.0000'

- (0018,0084) Imaging Frequency                   DS: '63.92433900'

- (0018,0085) Imaged Nucleus                      SH: 'H'

- (0018,0086) Echo Number(s)                      IS: '1'

- (0018,0091) Echo Train Length                   IS: None

- (0018,1000) Device Serial Number                LO: '-0000200'

- (0018,1020) Software Versions                   LO: 'V3.51*P25'

+ (0018,1020) Software Versions                   LO: '05'

+ (0018,1040) Contrast/Bolus Route                LO: 'IV'

+ (0018,1100) Reconstruction Diameter             DS: '338.671600'

+ (0018,1110) Distance Source to Detector         DS: '1099.3100585938'

+ (0018,1111) Distance Source to Patient          DS: '630.000000'

+ (0018,1120) Gantry/Detector Tilt                DS: '0.000000'

+ (0018,1130) Table Height                        DS: '133.699997'

+ (0018,1150) Exposure Time                       IS: '1601'

+ (0018,1151) X-Ray Tube Current                  IS: '170'

- (0018,1314) Flip Angle                          DS: '90'

+ (0018,1152) Exposure                            IS: '170'

+ (0018,1160) Filter Type                         SH: 'LARGE BOWTIE FIL'

+ (0018,1190) Focal Spot(s)                       DS: '0.700000'

+ (0018,1210) Convolution Kernel                  SH: 'STANDARD'

- (0018,5100) Patient Position                    CS: 'HFS'

+ (0018,5100) Patient Position                    CS: 'FFS'

+ (0019,0010) Private Creator                     LO: 'GEMS_ACQU_01'

+ (0019,1002) [Detector Channel]                  SL: 912

+ (0019,1003) [Cell number at Theta]              DS: '373.750000'

+ (0019,1004) [Cell spacing]                      DS: '1.016600'

+ (0019,100F) [Horiz. Frame of ref.]              DS: '955.799988'

+ (0019,1011) [Series contrast]                   SS: 2

+ (0019,1013) [Start number for baseline]         SS: 0

+ (0019,1014) [End number for baseline]           SS: 0

+ (0019,1015) [Start number for enhanced scans]   SS: 0

+ (0019,1016) [End number for enhanced scans]     SS: 0

+ (0019,1017) [Series plane]                      SS: 2

+ (0019,1018) [First scan ras]                    LO: 'S'

+ (0019,1019) [First scan location]               DS: '7.791870'

+ (0019,101A) [Last scan ras]                     LO: 'I'

+ (0019,101B) [Last scan loc]                     DS: '-320.197968'

+ (0019,101E) [Display field of view]             DS: '0.000000'

+ (0019,1023) [Table Speed [mm/rotation]]         DS: '5.000000'

+ (0019,1024) [Mid Scan Time [sec]]               DS: '17.784578'

+ (0019,1025) [Mid scan flag]                     SS: 1

+ (0019,1026) [Tube Azimuth [degree]]             SL: 0

+ (0019,1027) [Rotation Speed [msec]]             DS: '1.000000'

+ (0019,102A) [x-ray On position]                 DS: '178.079926'

+ (0019,102B) [x-ray Off position]                DS: '3994.299316'

+ (0019,102C) [Number of triggers]                SL: 10431

+ (0019,102E) [Angle of first view]               DS: '-718.079956'

+ (0019,102F) [Trigger frequency]                 DS: '984.000000'

+ (0019,1039) [SFOV Type]                         SS: 16

+ (0019,1040) [Stat recon flag]                   SS: 0

+ (0019,1041) [Compute type]                      SS: 1

+ (0019,1042) [Segment Number]                    SS: 0

+ (0019,1043) [Total Segments Required]           SS: 0

+ (0019,1044) [Interscan delay]                   DS: '1.000000'

+ (0019,1047) [View compression factor]           SS: 1

+ (0019,104A) [Total no. of ref channels]         SS: 6

+ (0019,104B) [Data size for scan data]           SL: 10431

+ (0019,1052) [Recon post proc. Flag]             SS: 1

+ (0019,1057) [CT water number]                   SS: -95

+ (0019,1058) [CT bone number]                    SS: 0

+ (0019,105E) [Number of channels (1...512)]      SL: 763

+ (0019,105F) [Increment between channels]        SL: 1

+ (0019,1060) [Starting view]                     SL: 1969

+ (0019,1061) [Number of views]                   SL: 1576

+ (0019,1062) [Increment between views]           SL: 1

+ (0019,106A) [Dependent on #views processed]     SS: 4

+ (0019,106B) [Field of view in detector cells]   SS: 852

+ (0019,1070) [Value of back projection button]   SS: 1

+ (0019,1071) [Set if fatq estimates were used]   SS: 0

+ (0019,1072) [Z chan avg over views]             DS: '0.000000'

+ (0019,1073) [Avg of left ref chans over views]  DS: '0.000000'

+ (0019,1074) [Max left chan over views]          DS: '0.000000'

+ (0019,1075) [Avg of right ref chans over views] DS: '0.000000'

+ (0019,1076) [Max right chan over views]         DS: '0.000000'

+ (0019,10DA) [Reference channel used]            SS: 0

+ (0019,10DB) [Back projector coefficient]        DS: '0.000000'

+ (0019,10DC) [Primary speed correction used]     SS: 1

+ (0019,10DD) [Overrange correction used]         SS: 1

+ (0019,10DE) [Dynamic Z alpha value]             DS: '0.000000'

- (0020,000D) Study Instance UID                  UI: 1.3.6.1.4.1.5962.1.2.4.20040826185059.5457

+ (0020,000D) Study Instance UID                  UI: 1.3.6.1.4.1.5962.1.2.1.20040119072730.12322

- (0020,000E) Series Instance UID                 UI: 1.3.6.1.4.1.5962.1.3.4.1.20040826185059.5457

+ (0020,000E) Series Instance UID                 UI: 1.3.6.1.4.1.5962.1.3.1.1.20040119072730.12322

- (0020,0010) Study ID                            SH: '4MR1'

+ (0020,0010) Study ID                            SH: '1CT1'

  (0020,0011) Series Number                       IS: '1'

- (0020,0012) Acquisition Number                  IS: '0'

+ (0020,0012) Acquisition Number                  IS: '2'

  (0020,0013) Instance Number                     IS: '1'

- (0020,0032) Image Position (Patient)            DS: [-83.9063, -91.2000, 6.6406]

+ (0020,0032) Image Position (Patient)            DS: [-158.135803, -179.035797, -75.699997]

- (0020,0037) Image Orientation (Patient)         DS: [1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000]

+ (0020,0037) Image Orientation (Patient)         DS: [1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000]

- (0020,0052) Frame of Reference UID              UI: 1.3.6.1.4.1.5962.1.4.4.1.20040826185059.5457

+ (0020,0052) Frame of Reference UID              UI: 1.3.6.1.4.1.5962.1.4.1.1.20040119072730.12322

  (0020,0060) Laterality                          CS: ''

- (0020,1040) Position Reference Indicator        LO: ''

+ (0020,1040) Position Reference Indicator        LO: 'SN'

- (0020,1041) Slice Location                      DS: '0.0000'

+ (0020,1041) Slice Location                      DS: '-77.2040634155'

  (0020,4000) Image Comments                      LT: 'Uncompressed'

+ (0021,0010) Private Creator                     LO: 'GEMS_RELA_01'

+ (0021,1003) [Series from which Prescribed]      SS: 2

+ (0021,1005) [Genesis Version - now]             SH: '05'

+ (0021,1007) [Series Record checksum]            UL: 1605775145

+ (0021,1015) [Unknown]                           US: 24078

+ (0021,1016) [Unknown]                           SS: 2

+ (0021,1018) [Genesis version - Now]             SH: '05'

+ (0021,1019) [Acq recon record checksum]         UL: 750675506

+ (0021,1037) [Screen Format]                     SS: 16

+ (0021,104A) [Anatomical reference for scout]    LO: ''

+ (0021,1090) [Tube focal spot position]          SS: 7400

+ (0021,1091) [Biopsy position]                   SS: 0

+ (0021,1092) [Biopsy T location]                 FL: 0.0

+ (0021,1093) [Biopsy ref location]               FL: 0.0

+ (0023,0010) Private Creator                     LO: 'GEMS_STDY_01'

+ (0023,1070) [Start time(secs) in first axial]   FD: 862399761.111079

+ (0023,1074) [No. of updates to header]          SL: 1

+ (0023,107D) [Indicates study has complete info  SS: 0

+ (0025,0010) Private Creator                     LO: 'GEMS_SERS_01'

+ (0025,1006) [Last pulse sequence used]          SS: 0

+ (0025,1007) [Images in Series]                  SL: 44

+ (0025,1010) [Landmark Counter]                  SL: 0

+ (0025,1011) [Number of Acquisitions]            SS: 0

+ (0025,1017) [Series Complete Flag]              SL: 0

+ (0025,1018) [Number of images archived]         SL: 0

+ (0025,1019) [Last image number used]            SL: 4

+ (0025,101A) [Primary Receiver Suite and Host]   SH: ''

+ (0027,0010) Private Creator                     LO: 'GEMS_IMAG_01'

+ (0027,1006) [Image archive flag]                SL: 1

+ (0027,1010) [Scout Type]                        SS: 0

+ (0027,101C) [Vma mamp]                          SL: 150

+ (0027,101D) [Vma phase]                         SS: 1

+ (0027,101E) [Vma mod]                           SL: 24

+ (0027,101F) [Vma clip]                          SL: 129

+ (0027,1020) [Smart scan ON/OFF flag]            SS: 1

+ (0027,1030) [Foreign Image Revision]            SH: ''

+ (0027,1035) [Plane Type]                        SS: 2

+ (0027,1040) [RAS letter of image location]      SH: 'I'

+ (0027,1041) [Image location]                    FL: -77.20406341552734

+ (0027,1042) [Center R coord of plane image]     FL: -11.199999809265137

+ (0027,1043) [Center A coord of plane image]     FL: 9.699999809265137

+ (0027,1044) [Center S coord of plane image]     FL: -75.69999694824219

+ (0027,1045) [Normal R coord]                    FL: 0.0

+ (0027,1046) [Normal A coord]                    FL: 0.0

+ (0027,1047) [Normal S coord]                    FL: -1.0

+ (0027,1048) [R Coord of Top Right Corner]       FL: -180.53579711914062

+ (0027,1049) [A Coord of Top Right Corner]       FL: 179.03579711914062

+ (0027,104A) [S Coord of Top Right Corner]       FL: -75.69999694824219

+ (0027,104B) [R Coord of Bottom Right Corner]    FL: -180.53579711914062

+ (0027,104C) [A Coord of Bottom Right Corner]    FL: -159.63580322265625

+ (0027,104D) [S Coord of Bottom Right Corner]    FL: -75.69999694824219

+ (0027,1050) [Scan Start Location]               FL: -63.19999694824219

+ (0027,1051) [Scan End Location]                 FL: -116.20304870605469

+ (0027,1052) [RAS letter for side of image]      SH: 'L'

+ (0027,1053) [RAS letter for anterior/posterior] SH: 'A'

+ (0027,1054) [RAS letter for scout start loc]    SH: 'I'

+ (0027,1055) [RAS letter for scout end loc]      SH: 'I'

  (0028,0002) Samples per Pixel                   US: 1

  (0028,0004) Photometric Interpretation          CS: 'MONOCHROME2'

- (0028,0010) Rows                                US: 64

+ (0028,0010) Rows                                US: 128

- (0028,0011) Columns                             US: 64

+ (0028,0011) Columns                             US: 128

- (0028,0030) Pixel Spacing                       DS: [0.3125, 0.3125]

+ (0028,0030) Pixel Spacing                       DS: [0.661468, 0.661468]

  (0028,0100) Bits Allocated                      US: 16

  (0028,0101) Bits Stored                         US: 16

  (0028,0102) High Bit                            US: 15

  (0028,0103) Pixel Representation                US: 1

- (0028,0106) Smallest Image Pixel Value          SS: 0

- (0028,0107) Largest Image Pixel Value           SS: 4000

+ (0028,0120) Pixel Padding Value                 SS: -2000

+ (0028,1052) Rescale Intercept                   DS: '-1024'

+ (0028,1053) Rescale Slope                       DS: '1'

+ (0029,0010) Private Creator                     LO: 'GEMS_IMPS_01'

+ (0029,1004) [Lower range of Pixels1]            SL: 0

+ (0029,1005) [Lower range of Pixels1]            DS: '0.000000'

+ (0029,1006) [Lower range of Pixels1]            DS: '0.000000'

+ (0029,1007) [Lower range of Pixels1]            SL: 87

+ (0029,1008) [Lower range of Pixels1]            SH: ''

+ (0029,1009) [Lower range of Pixels1]            SH: ''

+ (0029,100A) [Lower range of Pixels1]            SS: 764

+ (0029,1026) [Version of the hdr struct]         SS: 2

+ (0029,1034) [Advantage comp. Overflow]          SL: 0

+ (0029,1035) [Advantage comp. Underflow]         SL: 0

+ (0043,0010) Private Creator                     LO: 'GEMS_PARM_01'

- (0028,1050) Window Center                       DS: '600'

+ (0043,1010) [Window value]                      US: 400

- (0028,1051) Window Width                        DS: '1600'

+ (0043,1011) [Total input views]                 US: 10431

+ (0043,1012) [X-ray chain]                       SS: [14, 2, 3]

+ (0043,1013) [Decon kernel parameters]           SS: [107, 21, 4, 2, 20]

+ (0043,1014) [Calibration parameters]            SS: [4, 4, 5]

+ (0043,1015) [Total output views]                SS: 10431

+ (0043,1016) [Number of overranges]              SS: 0

+ (0043,1017) [IBH image scale factors]           DS: '0.095000'

+ (0043,1018) [BBH coefficients]                  DS: [0.085000, 1.102000, 0.095000]

+ (0043,1019) [Number of BBH chains to blend]     SS: 350

+ (0043,101A) [Starting channel number]           SL: 7

+ (0043,101B) [Ppscan parameters]                 SS: [0, 0, 0, 0, 0]

+ (0043,101C) [GE image integrity]                SS: 0

+ (0043,101D) [Level value]                       SS: 40

+ (0043,101E) [Delta Start Time [msec]]           DS: '2.000000'

+ (0043,101F) [Max overranges in a view]          SL: 0

+ (0043,1020) [Avg overranges all views]          DS: '0.000000'

+ (0043,1021) [Corrected after glow terms]        SS: 0

+ (0043,1025) [Reference channels]                SS: [1, 2, 3, 748, 749, 750]

+ (0043,1026) [No views ref chans blocked]        US: [0, 1, 1, 0, 0, 0]

+ (0043,1027) [Scan Pitch Ratio]                  SH: '/1.0:1'

+ (0043,1028) [Unique image iden]                 OB: Array of 80 elements

+ (0043,1029) [Histogram tables]                  OB: Array of 2068 elements

+ (0043,102A) [User defined data]                 OB: Array of 40 elements

+ (0043,102B) [Private Scan Options]              SS: [4, 4, 0, 0]

+ (0043,1031) [Recon Center Coordinates]          DS: [-11.200000, 9.700000]

+ (0043,1040) [Trigger on position]               FL: 178.07992553710938

+ (0043,1041) [Degree of rotation]                FL: 3816.219482421875

+ (0043,1042) [DAS trigger source]                SL: 0

+ (0043,1043) [DAS fpa gain]                      SL: 0

+ (0043,1044) [DAS output source]                 SL: 1

+ (0043,1045) [DAS ad input]                      SL: 1

+ (0043,1046) [DAS cal mode]                      SL: 3

+ (0043,1047) [DAS cal frequency]                 SL: -1

+ (0043,1048) [DAS reg xm]                        SL: 1

+ (0043,1049) [DAS auto zero]                     SL: 0

+ (0043,104A) [Starting channel of view]          SS: 1

+ (0043,104B) [DAS xm pattern]                    SL: 0

+ (0043,104C) [TGGC trigger mode]                 SS: 0

+ (0043,104D) [Start scan to X-ray on delay]      FL: 0.0

+ (0043,104E) [Duration of X-ray on]              FL: 10.60060977935791

- (7FE0,0010) Pixel Data                          OW: Array of 8192 elements

+ (7FE0,0010) Pixel Data                          OW: Array of 32768 elements

  (FFFC,FFFC) Data Set Trailing Padding           OB: Array of 126 elements

# authors : Guillaume Lemaitre <g.lemaitre58@gmail.com>
# license : MIT

import difflib

from pydicom import examples

print(__doc__)

# difflib compare functions require a list of lines, each terminated with
# newline character massage the string representation of each dicom dataset
# into this form:
rep = []
for ds in [examples.mr, examples.ct]:
    lines = str(ds).split("\n")
    lines = [line + "\n" for line in lines]  # add the newline to end
    rep.append(lines)


diff = difflib.Differ()
for line in diff.compare(rep[0], rep[1]):
    if line[0] != "?":
        print(line)

Total running time of the script: (0 minutes 0.103 seconds)

Gallery generated by Sphinx-Gallery