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