]> Creatis software - gdcm.git/blob - gdcmPython/testSuite.py
* src/gdcmElValSet.cxx, gdcmFile.cxx: JPR bug fix, removal of
[gdcm.git] / gdcmPython / testSuite.py
1 import unittest
2 import os
3 from gdcmPython import *
4
5 class gdcmTestCase(unittest.TestCase):
6    # The files whose name starts with a modality (e.g. CR-MONO1-10-chest.dcm)
7    # come from Sebastien Barre's Dicom2 highly recommendable site
8    # http://www.barre.nom.fr/medical/samples/index.html
9    BarreFiles = [
10       ####################################
11       # CR modality examples:
12       ####################################
13       ["CR-MONO1-10-chest.dcm",
14          [ ["Modality", "CR"],
15            #"Transfer Syntax UID" is absent.
16            ["Rows", "440"],
17            ["Columns", "440"],
18            ["Bits Stored", "10"],
19            ["Bits Allocated", "16"],
20            ["High Bit", "9"],
21            ["Pixel Representation", "0"],
22            ["Manufacturer", "FUJI PHOTO FILM CO. LTD."],
23            ["Manufacturer Model Name", "9000"],
24            ["Pixel Data", "gdcm::NotLoaded. Address:776 Length:387200"] ] ],
25       ####################################
26       # CT modality examples:
27       ####################################
28       ["CT-MONO2-16-brain.dcm",
29          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"],  # Explicit VR, LE
30            ["Modality", "CT"],
31            ["Rows", "512"],
32            ["Columns", "512"],
33            ["Bits Stored", "16"],
34            ["Bits Allocated", "16"],
35            ["High Bit", "15"],
36            ["Pixel Representation", "1"],
37            ["Manufacturer", "Picker International, Inc."],
38            ["Manufacturer Model Name", "PQ5000"],
39            ["Pixel Data", "gdcm::NotLoaded. Address:1680 Length:524288"] ] ],
40       ["CT-MONO2-16-ort.dcm",
41          [ ["Transfer Syntax UID", "1.2.840.10008.1.2"],  # Implicit VR, LE
42            ["Modality", "CT"],
43            ["Rows", "512"],
44            ["Columns", "512"],
45            ["Bits Stored", "16"],
46            ["Bits Allocated", "16"],
47            ["High Bit", "15"],
48            ["Pixel Representation", "1"],
49            ["Manufacturer", "GE MEDICAL SYSTEMS"],
50            ["Manufacturer Model Name", "HiSpeed CT/i"],
51            ["Pixel Data", "gdcm::NotLoaded. Address:1674 Length:524288"] ] ],
52       ["CT-MONO2-16-ankle.dcm",
53          [ ["Transfer Syntax UID", "1.2.840.10008.1.2"],  # Implicit, little
54            ["Modality", "CT"],
55            ["Rows", "512"],
56            ["Columns", "512"],
57            ["Bits Stored", "16"],
58            ["Bits Allocated", "16"],
59            ["High Bit", "15"],
60            ["Pixel Representation", "1"],
61            ["Manufacturer", "GE MEDICAL SYSTEMS"],
62            ["Manufacturer Model Name", "GENESIS_ZEUS"],
63            ["Pixel Data", "gdcm::NotLoaded. Address:1148 Length:524288"] ] ],
64       ["CT-MONO2-8-abdo.dcm",
65          [ ["Transfer Syntax UID", "1.2.840.10008.1.2"],  # Implicit, little
66            ["Modality", "CT"],
67            ["Rows", "512"],
68            ["Columns", "512"],
69            ["Bits Stored", "8"],
70            ["Bits Allocated", "8"],
71            ["High Bit", "7"],
72            ["Pixel Representation", "0"],
73            ["Manufacturer", "FUJI"],
74            ["Pixel Data", "gdcm::NotLoaded. Address:796 Length:262144"] ] ],
75       ["CT-MONO2-12-lomb-an2.acr2",
76          [ ["Modality", "CT"],
77            #"Transfer Syntax UID" and "Photometric Interpretation" are absent.
78            ["Rows", "512"],
79            ["Columns", "512"],
80            ["Bits Stored", "12"],
81            ["Bits Allocated", "16"],
82            ["High Bit", "11"],
83            ["Pixel Representation", "0"],
84            ["Manufacturer", "SIEMENS"],
85            ["Pixel Data", "gdcm::NotLoaded. Address:1230 Length:524288"] ] ],
86       ["CT-MONO2-16-chest.dcm",
87          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.4.70"], # jpeg...
88            ["Modality", "CT"],
89            ["Photometric Interpretation", "MONOCHROME2"],
90            ["Rows", "400"],
91            ["Columns", "512"],
92            ["Bits Stored", "16"],
93            ["Bits Allocated", "16"],
94            ["High Bit", "15"],
95            ["Pixel Representation", "1"],
96            ["Manufacturer", "GE MEDICAL SYSTEMS"],
97            ["Pixel Data", "gdcm::NotLoaded. Address:1638 Length:143498"] ] ],
98       ####################################
99       ### MR modality examples:
100       ####################################
101       ["MR-MONO2-12-angio-an1.acr1",
102          [ ["Recognition Code", "ACR-NEMA 1.0"],
103            ["Modality", "MR"],
104            #"Transfer Syntax UID" and "Photometric Interpretation" are absent.
105            ["Rows", "256"],
106            ["Columns", "256"],
107            ["Bits Stored", "12"],
108            ["Bits Allocated", "12"],
109            ["High Bit", "11"],
110            ["Pixel Representation", "0"],
111            ["Manufacturer", "Philips"],
112            # Note: 256*256*12/8 = 98304
113            ["Pixel Data", "gdcm::NotLoaded. Address:650 Length:98304"] ] ],
114       ["MR-MONO2-12-an2.acr2",
115          [ ["Modality", "MR"],
116            ["Photometric Interpretation", "MONOCHROME2"],
117            ["Rows", "256"],
118            ["Columns", "256"],
119            ["Bits Stored", "12"],
120            ["Bits Allocated", "16"],
121            ["High Bit", "11"],
122            ["Pixel Representation", "0"],
123            ["Manufacturer", "SIEMENS"],
124            ["Manufacturer Model Name", "MAGNETOM VISION"],
125            ["Pixel Data", "gdcm::NotLoaded. Address:1866 Length:131072"] ] ],
126       ["MR-MONO2-16-head.dcm",
127          [ ["Transfer Syntax UID", "1.2.840.10008.1.2"], # Imp VR, LE
128            ["Modality", "MR"],
129            ["Photometric Interpretation", "MONOCHROME2"],
130            ["Rows", "256"],
131            ["Columns", "256"],
132            ["Bits Stored", "16"],
133            ["Bits Allocated", "16"],
134            ["High Bit", "15"],
135            ["Pixel Representation", "1"],
136            ["Manufacturer", "GE MEDICAL SYSTEMS"],
137            ["Manufacturer Model Name", "GENESIS_SIGNA"],
138            ["Pixel Data", "gdcm::NotLoaded. Address:1804 Length:131072"] ] ],
139       # MR-MONO2-12-shoulder example is present in the Jpeg section.
140       # MR-MONO2-16-knee is not present in the test suite since it is too
141       #    closely related to MR-MONO2-16-head.dcm to be of interest.
142       ####################################
143       # OT modality examples:
144       ####################################
145       # OT-MONO2-8-hip is not present in the test suite since it is too
146       #    closely related to OT-MONO2-8-a7 to be of interest.
147       ["OT-PAL-8-face.dcm",
148          # Interest: has a color palette
149          [#"Transfer Syntax UID", and "Manufacturer" are absent.
150            ["Modality", "OT"],
151            ["Photometric Interpretation", "PALETTE COLOR"],
152            ["Rows", "480"],
153            ["Columns", "640"],
154            ["Bits Stored", "8"],
155            ["Bits Allocated", "8"],
156            ["High Bit", "7"],
157            ["Pixel Representation", "0"],
158            ["Pixel Data", "gdcm::NotLoaded. Address:1654 Length:307200"] ] ],
159       # OT-MONO2-8-colon is not present in the test suite since it is too
160       #    closely related to OT-MONO2-8-a7 to be of interest.
161       ["OT-MONO2-8-a7.dcm",
162          [#"Transfer Syntax UID" is absent.
163            ["Modality", "OT"],
164            ["Photometric Interpretation", "MONOCHROME2"],
165            ["Rows", "512"],
166            ["Columns", "512"],
167            ["Bits Stored", "8"],
168            ["Bits Allocated", "8"],
169            ["High Bit", "7"],
170            ["Pixel Representation", "0"],
171            ["Manufacturer", "Philips Medical Systems"],
172            ["Pixel Data", "gdcm::NotLoaded. Address:438 Length:262144"] ] ],
173       ####################################
174       # US (Ultra Sound) modality examples:
175       ####################################
176       ["US-RGB-8-esopecho.dcm",
177          # Interest: RGB image
178          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"],  # Exp VR, LE
179            ["Modality", "US"],
180            ["Photometric Interpretation", "RGB"],
181            ["Rows", "120"],
182            ["Columns", "256"],
183            ["Bits Stored", "8"],
184            ["Bits Allocated", "8"],
185            ["High Bit", "7"],
186            ["Pixel Representation", "0"],
187            ["Manufacturer", "Acme Products"],
188          # FIXME: 92160 / (120*256) = 3 bytes per pixel NOT 1. Maybe
189          # it has something to do with [Samples Per Pixel] = [3] ???
190          # You said it, puffy (tu l'as dit, bouffi, in french language)
191          # RGB is 3 bytes per pixel
192          # + Planar configuration (0028,0006) = 0 --> Pixels RGB       
193            ["Pixel Data", "gdcm::NotLoaded. Address:904 Length:92160"] ] ],
194       ["US-RGB-8-epicard.dcm",
195          # Interest: Big endian transfert syntax
196          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.2"],  # Big endian
197          # But ... group 0000 is LE .
198            ["Modality", "US"],
199            ["Photometric Interpretation", "RGB"],
200            ["Rows", "480"],
201            ["Columns", "640"],
202            ["Bits Stored", "8"],
203            ["Bits Allocated", "8"],
204            ["High Bit", "7"],
205            ["Pixel Representation", "0"],
206            ["Manufacturer", "G.E. Medical Systems"],
207            ["Manufacturer Model Name", "LOGIQ 700"],
208          # + Planar configuration (0028,0006) = 1 --> Plane R, Plane G, Plane B  
209            ["Implementation Version Name", "OFFIS-DCMTK-311"],
210            ["Pixel Data", "gdcm::NotLoaded. Address:1012 Length:921600"] ] ],
211    ]
212
213    MultiFrameFiles = [
214    # The number of images is contained in the "Number of Frames" element
215       ["MR-MONO2-8-16x-heart.dcm",
216          # Interest: multi-frame
217          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"], # ExpVR, LE
218            ["Number of Frames", "16"],
219            ["Modality", "MR"],
220            ["Photometric Interpretation", "MONOCHROME2"],
221            ["Rows", "256"],
222            ["Columns", "256"],
223            ["Bits Stored", "8"],
224            ["Bits Allocated", "8"],
225            ["High Bit", "7"],
226            ["Pixel Representation", "0"],
227            ["Manufacturer", "Philips"],
228            # Note: 256*256*16=1048576 (16 is the number of Frames) 
229            ["Pixel Data", "gdcm::NotLoaded. Address:920 Length:1048576"] ] ],
230       ["NM-MONO2-16-13x-heart.dcm",
231          # Interest: NM modality, multi-frame
232          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"], # ExpVR, LE
233            ["Number of Frames", "13"],
234            ["Modality", "NM"],
235            ["Photometric Interpretation", "MONOCHROME2"],
236            ["Rows", "64"],
237            ["Columns", "64"],
238            ["Bits Stored", "16"],
239            ["Bits Allocated", "16"],
240            ["High Bit", "15"],
241            ["Pixel Representation", "0"],
242            ["Manufacturer", "ACME Products"],
243            # Note: 64*64*13*2=106496
244            ["Pixel Data", "gdcm::NotLoaded. Address:1234 Length:106496"] ] ],
245       ["US-MONO2-8-8x-execho.dcm",
246          # Interest: multi-frame
247          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"], # ExpVR, LE
248            ["Number of Frames", "8"],
249            ["Modality", "US"],
250            ["Photometric Interpretation", "MONOCHROME2"],
251            ["Rows", "120"],
252            ["Columns", "128"],
253            ["Bits Stored", "8"],
254            ["Bits Allocated", "8"],
255            ["High Bit", "7"],
256            ["Pixel Representation", "0"],
257            ["Manufacturer", "Acme Products"],
258            ["Pixel Data", "gdcm::NotLoaded. Address:976 Length:122880"] ] ],
259       ["US-PAL-8-10x-echo.dcm",
260          # Interest: RLE (Run Length Encoded) compression, multiframe
261          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.5"], # RLE
262            ["Number of Frames", "10"],
263            ["Modality", "US"],
264            ["Photometric Interpretation", "PALETTE COLOR"],
265            ["Rows", "430"],
266            ["Columns", "600"],
267            ["Bits Stored", "8"],
268            ["Bits Allocated", "8"],
269            ["High Bit", "7"],
270            ["Pixel Representation", "0"],
271            ["Manufacturer", "ACME Products"],
272            ["Pixel Data", "gdcm::NotLoaded. Address:2428 Length:481182"] ] ],
273       ["XA-MONO2-8-12x-catheter.dcm",
274          # Interest: XA modality, multi-frame
275          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.4.70"], # jpeg
276            ["Number of Frames", "12"],  # 12 images
277            ["Modality", "XA"],
278            ["Photometric Interpretation", "MONOCHROME2"],
279            ["Rows", "512"],
280            ["Columns", "512"],
281            ["Bits Stored", "8"],
282            ["Bits Allocated", "8"],
283            ["High Bit", "7"],
284            ["Pixel Representation", "0"],
285            ["Manufacturer", "Acme Products"],
286            ["Pixel Data", "gdcm::NotLoaded. Address:1006 Length:920072"] ] ],
287    ]
288
289    GdcmFiles = [
290       ["gdcm-MR-SIEMENS-16.acr1",
291          # Interest: good old Acr-Nema Version 1, see also Oddities below
292          [ ["Recognition Code", "ACR-NEMA 1.0"],
293            ["Modality", "MR"],
294            ["Rows", "256"],
295            ["Columns", "256"],
296            ["Bits Stored", "12"],
297            ["Bits Allocated", "16"],
298            ["High Bit", "11"],
299            ["Pixel Representation", "0"],
300            ["Manufacturer", "SIEMENS"],
301            ["Manufacturer Model Name", "GBS III"],
302          # FIXME: this image looks padded at the end. The length of the file
303          # is 140288. Notice that, 256*256*2 + 1024 = 131072 + 1024 = 132096
304            ["Pixel Data", "gdcm::NotLoaded. Address:8192 Length:132096"],
305            # Oddities: "Study ID" and "Series Number" are empty
306            ["Study ID", ""],
307            ["Series Number", ""] ] ],
308            # Oddities: "Study" and "Serie Instance UID" are not present
309       ["gdcm-MR-SIEMENS-16.acr2",
310          # Interest: Acr-Nema Version 2
311          [ ["Recognition Code", "ACR-NEMA 2.0"],
312            ["Modality", "MR"],
313            ["Rows", "512"],
314            ["Columns", "512"],
315            ["Bits Stored", "12"],
316            ["Bits Allocated", "16"],
317            ["High Bit", "11"],
318            ["Pixel Representation", "0"],
319            ["Manufacturer", "SIEMENS"],
320            ["Manufacturer Model Name", "MAGNETOM VISION"],
321            ["Study Instance UID",
322             "1.3.12.2.1107.5.2.4.7630.20000918174641000"],
323            ["Study ID", "1"],
324            ["Series Instance UID",
325             "1.3.12.2.1107.5.2.4.7630.20000918175714000007"],
326            ["Series Number", "7"],
327            ["Pixel Data", "gdcm::NotLoaded. Address:6052 Length:524288"] ] ],
328       ["gdcm-US-ALOKA-16.dcm",
329          # Interest: - possesses 3 LUTS: a Green (checked), a Red and BLue.
330          #           - announced as implicit VR, but really explicit VR.
331          [ ["Transfer Syntax UID", "1.2.840.10008.1.2"],  # Implicit VR, LE
332            ["Modality", "US"],
333            ["Photometric Interpretation", "PALETTE COLOR"],
334            ["Segmented Green Palette Color LUT Data",
335             "gdcm::NotLoaded. Address:89576 Length:113784"],
336            ["Rows", "480"],
337            ["Columns", "640"],
338            ["Bits Stored", "16"],
339            ["Bits Allocated", "16"],
340            ["High Bit", "15"],
341            ["Pixel Representation", "0"],
342            ["Manufacturer", "ALOKA CO., LTD."],
343            ["Manufacturer Model Name", "SSD-4000"],
344            ["Pixel Data", "gdcm::NotLoaded. Address:258740 Length:614400"] ] ],
345       ["gdcm-MR-PHILIPS-16.dcm",
346          # Interest: - possesses a sequence
347          #           - dicom file, with a recognition code of ACR-NEMA1
348          [ ["Transfer Syntax UID", "1.2.840.10008.1.2"],  # Implicit VR, LE
349            ["Recognition Code", "ACR-NEMA 1.0"],
350            ["Modality", "MR"],
351            ["Photometric Interpretation", "MONOCHROME2"],
352            ["Rows", "256"],
353            ["Columns", "256"],
354            ["Bits Stored", "8"],
355            ["Bits Allocated", "16"],
356            ["High Bit", "7"],
357            ["Pixel Representation", "0"],
358            ["Manufacturer", "Philips Medical Systems"],
359            ["Manufacturer Model Name", "Gyroscan Intera"],
360            ["Sequence Variant", "OTHER"],
361            ["Pixel Data", "gdcm::NotLoaded. Address:6584 Length:131072"] ] ],
362       ["gdcm-MR-PHILIPS-16-Multi-Seq.dcm",
363          # Interest: - possesses many sequences in group 0x0029
364          #           - Big sequence 28808 bytes at (0x0029, 0x263d)
365          #           - dicom file, with a recognition code of ACR-NEMA1
366          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"],
367            ["Recognition Code", "ACR-NEMA 1.0"],
368            ["Modality", "MR"],
369            ["Photometric Interpretation", "MONOCHROME2"],
370            ["Rows", "128"],
371            ["Columns", "128"],
372            ["Bits Stored", "12"],
373            ["Bits Allocated", "16"],
374            ["High Bit", "11"],
375            ["Pixel Representation", "0"],
376            ["Manufacturer", "Philips Medical Systems"],
377            ["Manufacturer Model Name", "Gyroscan Intera"],
378            ["Sequence Variant", "OTHER"],
379            ["Pixel Data", "gdcm::NotLoaded. Address:35846 Length:32768"] ] ],
380       ["gdcm-MR-PHILIPS-16-NonRectPix.dcm",
381          # Interest: - pixels are non rectangular
382          #           - private elements are in explicit VR (which is normal)
383          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"],  # Explicit VR, LE
384            ["Modality", "MR"],
385            ["Photometric Interpretation", "MONOCHROME2"],
386            ["Rows", "64"],
387            ["Columns", "160"],
388            ["Bits Stored", "12"],
389            ["Bits Allocated", "16"],
390            ["High Bit", "11"],
391            ["Pixel Representation", "0"],
392            ["Manufacturer", "Philips Medical Systems"],
393            ["Manufacturer Model Name", "Gyroscan Intera"],
394            ["Pixel Spacing", "0.487416\\0.194966"],
395            ["Pixel Data", "gdcm::NotLoaded. Address:5010 Length:20480"] ] ],
396       ["gdcm-CR-DCMTK-16-NonSamplePerPix.dcm",
397          # Interest: - Misses the "Samples Per Pixel" element which prevents
398          #             e-film from reading it.
399          #           - Misses the Manufacturer related info
400          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"],  # Explicit VR, LE
401            ["Modality", "CR"],
402            ["Photometric Interpretation", "MONOCHROME2"],
403            ["Rows", "750"],
404            ["Columns", "750"],
405            ["Bits Stored", "8"],
406            ["Bits Allocated", "8"],
407            ["High Bit", "7"],
408            ["Pixel Representation", "0"],
409            ["Implementation Version Name", "OFFIS_DCMTK_341"],
410            ["Pixel Data", "gdcm::NotLoaded. Address:740 Length:562500"] ] ],
411    ]
412
413    GdcmJpegFiles = [
414       ["gdcm-JPEG-Extended.dcm",
415          # Interest: Jpeg compression [Extended (2,4)]
416          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.4.51"],
417            ["Modality", "CT"],
418            ["Photometric Interpretation", "MONOCHROME2"],
419            ["Rows", "512"],
420            ["Columns", "512"],
421            ["Bits Stored", "12"],
422            ["Bits Allocated", "16"],
423            ["High Bit", "11"],
424            ["Pixel Representation", "0"],
425            ["Manufacturer", "SIEMENS"],
426            ["Manufacturer Model Name", "Volume Zoom"],
427            ["Pixel Data", "gdcm::NotLoaded. Address:2946 Length:192218"] ] ],
428       ["MR-MONO2-12-shoulder.dcm",
429          # Interest: Jpeg compression [Lossless, non-hierar. (14)]
430          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.4.57"],
431            ["Modality", "MR"],
432            ["Photometric Interpretation", "MONOCHROME2"],
433            ["Rows", "1024"],
434            ["Columns", "1024"],
435            ["Bits Stored", "12"],
436            ["Bits Allocated", "16"],
437            ["High Bit", "11"],
438            ["Pixel Representation", "0"],
439            ["Manufacturer", "Philips Medical Systems"],
440            ["Manufacturer Model Name", "Gyroscan NT"],
441            ["Pixel Data", "gdcm::NotLoaded. Address:1580 Length:718948"] ] ],
442       ["gdcm-JPEG-LossLess3a.dcm",
443          # Interest: - Jpeg compression [Lossless, hierar., first-order
444          #             pred. 14, Select. Val. 1]
445          #           - contains a sequence [circa (0008,2112)]
446          #           - contains additional data after the pixels ???
447          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.4.70"],
448            ["Modality", "CT"],
449            ["Photometric Interpretation", "MONOCHROME2"],
450            ["Rows", "512"],
451            ["Columns", "512"],
452            ["Bits Stored", "12"],
453            ["Bits Allocated", "16"],
454            ["High Bit", "11"],
455            ["Pixel Representation", "0"],
456            ["Manufacturer", "SIEMENS"],
457            ["Manufacturer Model Name", "Volume Zoom"] ] ],
458          # FIXME: the pixel data looks like corrupted. As stated by "od -A d -c"
459          #   0002528     à 177 020 \0  O  B \0 \0   ÿ  ÿ   ÿ   ÿ  þ  ÿ \0  à
460          #   0002544    \0  \0  \0 \0  þ  ÿ \0  à 202  ? 003  \0  ÿ  Ø  ÿ  Ã
461          # which we interpret as follows:
462          #   - 2528: (à 177, 020 \0) = (0x7fe0, 0x0010) i.e. Pixel Data tag,
463          #   - 2532: OB i.e. encapsulated encoded Pixel Data,
464          #   - 2534: Two bytes reserved,
465          #   - 2536: ÿ ÿ ÿ ÿ = 0xffffffff i.e. data element length is undefined.
466          #   - 2540: (þ ÿ, \0 à) = (0xfffe, 0xe000) i.e. basic offset table
467          #           item tag
468          #   - 2544: \0 \0 \0 \0 i.e. offset table as length zero, i.e. no
469          #           item value for offset table.
470          #   - 2548: (þ ÿ, \0 à) = (0xfffe, 0xe000) i.e. item tag of first
471          #           fragment of (encoded) pixel data.
472          #   - 2552: 202 ? 003 \0 = 212866 bytes i.e. length of first fragment
473          #           of (encoded) pixel data.
474          # and so the next item tag should be found at the 2556+212866 th
475          # octet i.e. at address 215422. But, as stated by od, we find:
476          #   0215408   E   u Ö 026   Î   É 7 ¬ Ã ¸ ó ¿ ÿ Ù \f °
477          #   0215424   ¶ 016 P   Ñ 002 016
478          # and (\f °, ¶ 016) is NOT an OB item TAG which is required to be
479          # present (at least there should be a sequence delimiter), refer to
480          # PS 3.5-2001 page 50. 
481       ["gdcm-JPEG-LossLess3b.dcm",
482          # Interest: - Jpeg compression [Lossless, hierar., first-order
483          #             pred. 14, Select. Val. 1]
484          #           - encoding is sligthly different from LossLess3a.dcm ???
485          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.4.70"],
486            ["Modality", "CR"],
487            ["Photometric Interpretation", "MONOCHROME2"],
488            ["Rows", "2076"],
489            ["Columns", "1876"],
490            ["Bits Stored", "15"],
491            ["Bits Allocated", "16"],
492            ["High Bit", "14"],
493            ["Pixel Representation", "0"],
494            ["Manufacturer", "Philips Medical Systems"],
495            ["Manufacturer Model Name", "Cassette Holder Type 9840 500 35201"],
496            ["Pixel Data", "gdcm::NotLoaded. Address:3144 Length:4795668"] ] ],
497    ]
498
499    def _BaseTest(self, FileSet):
500       for entry in FileSet:
501          fileName = os.path.join(GDCM_TEST_DATA_PATH, entry[0])
502          toRead = gdcmHeader(fileName)
503          valDict = toRead.GetPubElVal()
504          for subEntry in entry[1]:
505             element = subEntry[0]
506             value   = subEntry[1]
507             self.assertEqual(valDict[element], value, 
508                              ("Wrong %s for file %s (got %s, shoud be %s)"
509                                % (element,fileName, valDict[element], value)) )
510
511    def testBarre(self):
512       gdcmTestCase._BaseTest(self, gdcmTestCase.BarreFiles)
513
514    def testMultiFram(self):
515       gdcmTestCase._BaseTest(self, gdcmTestCase.MultiFrameFiles)
516
517    def testFiles(self):
518       gdcmTestCase._BaseTest(self, gdcmTestCase.GdcmFiles)
519
520    def testJpeg(self):
521       gdcmTestCase._BaseTest(self, gdcmTestCase.GdcmJpegFiles)
522
523    def testWrite(self):
524       import md5
525       SourceFileName = os.path.join(GDCM_TEST_DATA_PATH,
526                                     'gdcm-MR-PHILIPS-16-Multi-Seq.dcm')
527       Source = gdcmFile(SourceFileName);
528       Source.GetImageData()
529       TargetFileName = "junk"
530       Target = Source.WriteDcmImplVR(TargetFileName)
531       Sign = 'c3d27238647b7eaa773bff6ea0692b54'
532       ComputeSign = md5.new(open(TargetFileName).read()).hexdigest()
533       self.assertEqual(ComputeSign, Sign,
534           ("Wrong signature for file %s (got %s, shoud be %s)"
535            % (SourceFileName, ComputeSign, Sign)) )
536       os.unlink(TargetFileName)
537
538 if __name__ == '__main__':
539    if not GDCM_TEST_DATA_PATH:
540       print "GDCM_TEST_DATA_PATH is not setup properly. This test suite"
541       print "   requires that some Dicom reference files be installed."
542       print "   For further details on installation of gdcmData, please"
543       print "   refer to the developper's section of page "
544       print "       http://www.creatis.insa-lyon.fr/Public/Gdcm"
545    unittest.main()
546