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