Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot open mysterious DICOM file using Python

I am trying to open a DICOM file which is accompanied by a .jpeg file. This pair of files is the result of exporting the image acquisition from an imaging device which I guess is a proprietary DICOM or something. Still I can read the information and tags of the file except viewing the actual image data.

I am using PyDicom and do the following:

import pydicom
myfile = pydicom.read_file("thedicomfile.dcm")
myfile.pixel_array # results in error
AttributeError: 'Dataset' object has no attribute 'TransferSyntaxUID'
# so I do 
myfile.file_meta.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian
# then 
myfile.pixel_array

lAttributeError: Amount of pixel data 19404 does not match the expected data 76800

I don't know that to do or how to exploit the information from the .jpg file which accompanies my DICOM.

(The data are of myself and also randomly changed time of birth, so no problem with confidentiality)

Hex dump of file 1:
file name: 1_DThumbN.jpg
mime type: 

0000-0010:  49 49 2a 00-08 00 00 00-18 00 fe 00-04 00 01 00  II*..... ........
0000-0020:  00 00 00 00-00 00 00 01-04 00 01 00-00 00 80 00  ........ ........
0000-0030:  00 00 01 01-04 00 01 00-00 00 80 00-00 00 02 01  ........ ........
0000-0040:  03 00 03 00-00 00 2e 01-00 00 03 01-03 00 01 00  ........ ........
0000-0050:  00 00 07 00-00 00 06 01-03 00 01 00-00 00 06 00  ........ ........
0000-0060:  00 00 12 01-03 00 01 00-00 00 01 00-00 00 15 01  ........ ........
0000-0070:  03 00 01 00-00 00 03 00-00 00 1a 01-05 00 01 00  ........ ........
0000-0080:  00 00 64 01-00 00 1b 01-05 00 01 00-00 00 6c 01  ..d..... ......l.
0000-0090:  00 00 1c 01-03 00 01 00-00 00 01 00-00 00 28 01  ........ ......(.
0000-00a0:  03 00 01 00-00 00 02 00-00 00 29 01-03 00 02 00  ........ ..).....
0000-00b0:  00 00 00 00-00 00 42 01-03 00 01 00-00 00 80 00  ......B. ........
0000-00c0:  00 00 43 01-03 00 01 00-00 00 80 00-00 00 44 01  ..C..... ......D.
0000-00d0:  04 00 01 00-00 00 f4 03-00 00 45 01-04 00 01 00  ........ ..E.....
0000-00e0:  00 00 e2 08-00 00 00 02-03 00 01 00-00 00 01 00  ........ ........
0000-00f0:  00 00 01 02-04 00 01 00-00 00 74 01-00 00 02 02  ........ ..t.....
0000-0100:  04 00 01 00-00 00 62 0b-00 00 03 02-03 00 01 00  ......b. ........
0000-0110:  00 00 00 00-00 00 12 02-03 00 02 00-00 00 02 00  ........ ........
0000-0120:  01 00 13 02-03 00 01 00-00 00 02 00-00 00 14 02  ........ ........
0000-0130:  05 00 06 00-00 00 34 01-00 00 00 00-00 00 08 00  ......4. ........
0000-0140:  08 00 08 00-00 00 00 00-01 00 00 00-ff 00 00 00  ........ ........
0000-0150:  01 00 00 00-80 00 00 00-01 00 00 00-ff 00 00 00  ........ ........
0000-0160:  01 00 00 00-80 00 00 00-01 00 00 00-ff 00 00 00  ........ ........
0000-0170:  01 00 00 00-96 00 00 00-01 00 00 00-96 00 00 00  ........ ........
0000-0180:  01 00 00 00-ff d8 ff e0-00 10 4a 46-49 46 00 01  ........ ..JFIF..
0000-0190:  00 01 00 96-00 96 00 00-ff fe 00 1f-4c 45 41 44  ........ ....LEAD
0000-01a0:  20 54 65 63-68 6e 6f 6c-6f 67 69 65-73 20 49 6e  .Technol ogies.In
0000-01b0:  63 2e 20 56-31 2e 30 31-00 ff db 00-84 00 20 16  c..V1.01 ........
0000-01c0:  18 1c 18 14-20 1c 1a 1c-24 22 20 26-30 50 34 30  ........ $".&0P40
0000-01d0:  2c 2c 30 62-46 4a 3a 50-74 66 7a 78-72 66 70 6e  ,,0bFJ:P tfzxrfpn
0000-01e0:  80 90 b8 9c-80 88 ae 8a-6e 70 a0 da-a2 ae be c4  ........ np......
0000-01f0:  ce d0 ce 7c-9a e2 f2 e0-c8 f0 b8 ca-ce c6 01 22  ...|.... ......."
0000-0200:  24 24 30 2a-30 5e 34 34-5e c6 84 70-84 c6 c6 c6  $$0*0^44 ^..p....
0000-0210:  c6 c6 c6 c6-c6 c6 c6 c6-c6 c6 c6 c6-c6 c6 c6 c6  ........ ........
0000-0220:  c6 c6 c6 c6-c6 c6 c6 c6-c6 c6 c6 c6-c6 c6 c6 c6  ........ ........
0000-0230:  c6 c6 c6 c6-c6 c6 c6 c6-c6 c6 c6 c6-c6 c6 c6 ff  ........ ........
0000-0240:  c4 01 a2 00-00 01 05 01-01 01 01 01-01 00 00 00  ........ ........
0000-0250:  00 00 00 00-00 01 02 03-04 05 06 07-08 09 0a 0b  ........ ........
0000-0260:  01 00 03 01-01 01 01 01-01 01 01 01-00 00 00 00  ........ ........
0000-0270:  00 00 01 02-03 04 05 06-07 08 09 0a-0b 10 00 02  ........ ........
0000-0280:  01 03 03 02-04 03 05 05-04 04 00 00-01 7d 01 02  ........ .....}..
0000-0290:  03 00 04 11-05 12 21 31-41 06 13 51-61 07 22 71  ......!1 A..Qa."q
0000-02a0:  14 32 81 91-a1 08 23 42-b1 c1 15 52-d1 f0 24 33  .2....#B ...R..$3
0000-02b0:  62 72 82 09-0a 16 17 18-19 1a 25 26-27 28 29 2a  br...... ..%&'()*
0000-02c0:  34 35 36 37-38 39 3a 43-44 45 46 47-48 49 4a 53  456789:C DEFGHIJS
0000-02d0:  54 55 56 57-58 59 5a 63-64 65 66 67-68 69 6a 73  TUVWXYZc defghijs
0000-02e0:  74 75 76 77-78 79 7a 83-84 85 86 87-88 89 8a 92  tuvwxyz. ........
0000-02f0:  93 94 95 96-97 98 99 9a-a2 a3 a4 a5-a6 a7 a8 a9  ........ ........
0000-0300:  aa b2 b3 b4-b5 b6 b7 b8-b9 ba c2 c3-c4 c5 c6 c7  ........ ........
0000-0310:  c8 c9 ca d2-d3 d4 d5 d6-d7 d8 d9 da-e1 e2 e3 e4  ........ ........
0000-0320:  e5 e6 e7 e8-e9 ea f1 f2-f3 f4 f5 f6-f7 f8 f9 fa  ........ ........
0000-0330:  11 00 02 01-02 04 04 03-04 07 05 04-04 00 01 02  ........ ........
0000-0340:  77 00 01 02-03 11 04 05-21 31 06 12-41 51 07 61  w....... !1..AQ.a
0000-0350:  71 13 22 32-81 08 14 42-91 a1 b1 c1-09 23 33 52  q."2...B .....#3R
0000-0360:  f0 15 62 72-d1 0a 16 24-34 e1 25 f1-17 18 19 1a  ..br...$ 4.%.....
0000-0370:  26 27 28 29-2a 35 36 37-38 39 3a 43-44 45 46 47  &'()*567 89:CDEFG
0000-0380:  48 49 4a 53-54 55 56 57-58 59 5a 63-64 65 66 67  HIJSTUVW XYZcdefg
0000-0390:  68 69 6a 73-74 75 76 77-78 79 7a 82-83 84 85 86  hijstuvw xyz.....
0000-03a0:  87 88 89 8a-92 93 94 95-96 97 98 99-9a a2 a3 a4  ........ ........
0000-03b0:  a5 a6 a7 a8-a9 aa b2 b3-b4 b5 b6 b7-b8 b9 ba c2  ........ ........
0000-03c0:  c3 c4 c5 c6-c7 c8 c9 ca-d2 d3 d4 d5-d6 d7 d8 d9  ........ ........
0000-03d0:  da e2 e3 e4-e5 e6 e7 e8-e9 ea f2 f3-f4 f5 f6 f7  ........ ........
0000-03e0:  f8 f9 fa ff-c0 00 11 08-00 80 00 80-03 01 21 00  ........ ......!.
0000-03f0:  02 11 01 03-11 01 ff da-00 0c 03 01-00 02 11 03  ........ ........
0000-0400:  11 00 3f 00-e7 e8 1c 50-01 45 00 14-50 01 45 00  ..?....P .E..P.E.
0000-0410:  1d 68 a0 02-8a 00 28 a0-02 8a 00 3b-51 40 05 1d  .h....(. ...;Q@..
0000-0420:  a8 00 a2 80-0a 28 01 f1-c3 2c 9c 47-1b b6 7f ba  .....(.. .,.G....
0000-0430:  09 a9 92 c6-e1 b3 fb 96-18 c9 39 18-c5 27 38 ad  ........ ..9..'8.
0000-0440:  24 c4 d8 d9-2d a5 0d 85-86 4e 83 82-a7 35 0f 6f  $...-... .N...5.o
0000-0450:  7a a7 6b e8-24 ee 21 e3-ad 14 14 14-10 46 32 3a  z.k.$.!. .....F2:
0000-0460:  f4 a4 01 df-02 8a 00 28-a0 03 3c 62-9f 14 4f 33  .......( ..<b..O3
0000-0470:  6c 8c 64 e3-3f 4a 04 dd-95 cd 25 d3-e0 89 17 cc  l.d.?J.. ..%.....
0000-0480:  73 bf 77 de-ec 79 e0 73-f4 e6 a6 8a-28 21 0a 44  s.w..y.s ....(!.D
0000-0490:  78 96 33 bb-0d f3 60 0c-1e bc 7a 8f-cf eb 59 37  x.3...`. ..z...Y7
0000-04a0:  29 46 c8 e7-f6 8d b2 48-8c 6e b1 c4-d9 60 23 d9  )F.....H .n...`#.
0000-04b0:  d1 5b 93 fc-43 d3 a1 3d-7d 3b d4 81-d3 2c 5e 50  .[..C..= };...,^P
0000-04c0:  cb b7 3f 33-6d 3d 7d fa-73 b8 7e 9d-ab 29 a6 ee  ..?3m=}. s.~..)..
0000-04d0:  9a f3 fb ff-00 12 a3 36-9a 69 6c 49-e6 c2 5f 07  .......6 .ilI.._.
0000-04e0:  6e d0 79 c3-f2 08 e3 18-fc 87 d7 1f-5a 64 96 d0  n.y..... ....Zd..
0000-04f0:  ce 59 a4 89-58 ee db 9c-73 d3 bf 3c-9e 7f cf 15  .Y..X... s..<....
0000-0500:  8a e6 87 53-6b f3 d8 48-e0 b5 52 4c-71 07 23 e5  ...Sk..H ..RLq.#.
0000-0510:  25 47 4e d8-ff 00 3e 95-56 e3 4c 49-b6 bc 4c b1  %GN...>. V.LI..L.
0000-0520:  02 bd c6 01-3d 7a 76 ad-55 59 c2 5e-f8 d2 8b 4b  ....=zv. UY.^...K
0000-0530:  97 73 22 48-da 27 28 e3-6b 0e a2 9b-5d 60 29 e3  .s"H.'(. k...]`).
0000-0540:  a8 c5 04 f1-8e d4 00 f8-a2 79 9b 64-6b b9 8f a5  ........ .y.dk...
0000-0550:  5d 8f 4d 45-5c dc 5c 46-a7 b2 06 00-9f c4 f4 3c  ].ME\.\F .......<
0000-0560:  8a 89 ce da-2d c9 72 49-d8 95 34 98-64 2a 44 ae  ....-.rI ..4.d*D.
0000-0570:  17 68 24 91-d4 e3 9f a7-51 d6 ae 06-8e dd 5a 2b  .h$..... Q.....Z+
0000-0580:  78 c8 66 f9-94 63 19 c6-3a 93 9c 7a-74 ac 65 27  x.f..c.. :..zt.e'
0000-0590:  36 a3 f7 ff-00 5b ff 00-5e 86 73 77-5a e8 51 9e  6....[.. ^.swZ.Q.
0000-05a0:  e0 16 2f b7-0a 4e 09 0c-18 7b f7 19-c8 0b d7 de  ../..N.. .{......
0000-05b0:  98 8b 3d c2-e1 e3 51 18-3b 89 31 f3-c9 ec 6b a2  ..=...Q. ;.1...k.
0000-05c0:  2b 91 5e 5f-d7 f5 f7 12-91 33 e9 8c-59 8b 4a 4b  +.^_.... .3..Y.JK
0000-05d0:  05 38 dd 81-c9 fa 9f 5c-fb d4 83 4e-55 6d a2 56  .8.....\ ...NUm.V
0000-05e0:  62 1b 38 c8-c6 46 4f 7e-dd 79 ac d6-20 df d9 49  b.8..FO~ .y.....I
0000-05f0:  e9 b7 f5 ea-36 68 24 4b-79 48 9b 28-41 3b 41 c7  ....6h$K yH.(A;A.
0000-0600:  3b 71 cf b6-07 f8 d4 26-e6 48 46 6e-37 19 a3 ce  ;q.....& .HFn7...
0000-0610:  04 a9 91 8e-9c 1e e7 8e-b9 a7 17 0a-ab 6b 3f ea  ........ .....k?.
0000-0620:  e4 3a 52 81-3c 7a 86 ec-34 a5 fe 51-b8 2e d1 d7  .:R.<z.. 4..Q....
0000-0630:  1f 36 33 d4-63 07 ae 79-ab be 7a 4b-12 b4 9b b0  .63.c..y ..zK....
0000-0640:  e3 20 28 ed-8e 7a 74 06-b9 ea 51 e5-7a 6e 25 51  ..(..zt. ..Q.zn%Q
0000-0650:  ad c8 1d 61-b8 3e 53 22-12 17 1b 8a-9e 31 db 9e  ...a.>S" .....1..
0000-0660:  98 ee 3f fa-f5 56 6d 25-19 09 89 f6-b2 f0 54 9c  ..?..Vm% ......T.
0000-0670:  8f 5f cb 15-51 9c a9 e9-24 69 cd 19-3f 74 48 3e  ._..Q... $i..?tH>
0000-0680:  cd 2c 9b 25-82 25 76 3b-48 1c 05 3b-78 ef f5 ff  .,.%.%v; H..;x...
0000-0690:  00 f5 d4 ab-61 66 ec 5d-43 15 eb b7-76 07 a6 32  ....af.] C...v..2
0000-06a0:  47 f5 ad 65-cf 1d 17 f5-fe 66 5c fa-d8 bb 18 48  G..e.... .f\....H
0000-06b0:  62 5f e0 8f-39 2a 40 db-c7 7f eb ff-00 d7 a6 04  b_..9*@. ........
0000-06c0:  dc 17 ce 53-b9 4e 5b b8-63 c9 00 f3-c7 5c fa 57  ...S.N[. c....\.W
0000-06d0:  3a 6f 9b 99-7f 5f d6 82-8b 4d 5a ff-00 d7 f5 fd  :o..._.. .MZ.....
0000-06e0:  6a 51 bb bc-56 26 28 b0-ab 9f be 18-82 a7 d3 fc  jQ..V&(. ........
0000-06f0:  f1 cf 6a ab-11 99 d1 52-23 b5 07 1b-88 23 9e 78  ..j....R #....#.x
0000-0700:  fa 8c 9e 95-db 18 f2 a4-9e e1 15 a6-a5 c8 34 f8  ........ ......4.
0000-0710:  a0 52 f7 12-02 d8 ce 19-3e e8 c1 cf-d4 fe 7d 3d  .R...... >.....}=
0000-0720:  ea c0 b9 40-ec ca cb b2-21 8f 98 70-a7 b0 fc fd  ...@.... !..p....
0000-0730:  b1 c7 b5 73-49 7b 47 7e-9d 0b f6 9c-ad a4 23 5d  ...sI{G~ ......#]
0000-0740:  9f 21 b1 b7-76 c4 6c a0-c0 c9 3d 79-f4 e3 fc f4  .!..v.l. ..=y....
0000-0750:  6b 4a c6 73-19 da aa 64-da a5 40 3b-5b 23 2d ed  kJ.s...d ..@;[#-.
0000-0760:  cf f3 e6 85-4e 31 df fa-d8 85 39 37-a1 28 df 89  ....N1.. ..97.(..
0000-0770:  0c 81 9a 22-bf 78 e3 9e-32 78 3d 3f-1c fd 68 8b  ...".x.. 2x=?..h.
0000-0780:  65 ca 82 f1-8d c0 6e 65-91 3a 67 bf-fe 3b fe 73  e.....ne .:g..;.s
0000-0790:  59 b4 92 e6-83 34 85 47-b4 b6 22 6d-32 19 1b 28  Y....4.G .."m2..(
0000-07a0:  c2 37 6e d8-dc 07 39 ef-54 e2 b6 ba-da 02 8c f9  .7n...9. T.......
0000-07b0:  25 8a fc db-7a e3 3d 7e-a3 fc 9a de-15 74 fd e2  %...z.=~ .....t..
0000-07c0:  d8 5a 49 da-2e e1 2c b7-11 c8 db d4-30 1f 3f 39  .ZI...,. ....0.?9
0000-07d0:  2a 0f a8 cf-4e 84 71 fe-14 86 65 65-79 02 c4 01  *...N.q. ..eey...
0000-07e0:  66 23 79 24-f4 ce 00 ed-cf f3 fc f7-e5 57 f7 4c  f#y$.... .....W.L
0000-07f0:  dc 2c 33 ca-ba db 86 82-46 1f 7b 23-3f 9f d7 83  .,3..... F.{#?...
0000-0800:  d7 9a 21 92-58 b6 29 06-21 86 01 8e-4f 7c 9e 9f  ..!.X.). !...O|..
0000-0810:  4c 1a 5c ca-5a 5c a6 95-84 49 b9 7d-d3 3b 2f 23  L.\.Z\.. .I.}.;/#
0000-0820:  0c 33 c1 1f-5e b8 fc 2a-78 5e f2 65-01 11 c0 93  .3..^..* x^.e....
0000-0830:  ef 9c 60 37-5e 40 e9 eb-f9 d2 9d b7-90 9a 4b c8  ..`7^@.. ......K.
0000-0840:  b9 6d 65 0d-bc ab 2b 3b-33 12 72 5c-7a f4 eb d3  .me...+; 3.r\z...
0000-0850:  f5 fa 8a 59-2e 4c 68 fb-15 09 05 49-f9 87 cd 8e  ...Y.Lh. ...I....
0000-0860:  dc f3 db f4-3f 5a e5 d6-b4 bc be ff-00 eb fa b9  ....?Z.. ........
0000-0870:  a4 9c 63 b6-ff 00 d7 f5-d8 8e 29 da-23 23 c9 26  ..c..... ..).##.&
0000-0880:  e6 66 00 05-c6 50 13 d3-9e 83 a5 40-b3 2f 9e de  .f...P.. ...@./..
0000-0890:  5b 23 2b 9d-a6 30 bc 1e-be fd 39 f7-eb d2 ba 55  [#+..0.. ..9....U
0000-08a0:  1d 5d ba fe-9f f0 7f 33-0b b6 b6 d0-87 ed 7b 13  .].....3 ......{.
0000-08b0:  38 dc 1a 32-a0 02 40 f4-c6 3b 70 3b-75 e2 a5 37  8..2..@. .;p;u..7
0000-08c0:  c7 23 00 b1-20 13 f3 95-c6 40 f5 eb-f5 1f e3 56  .#...... [email protected]
0000-08d0:  a1 d8 72 83-7d 49 4d d0-99 9b 0d bc-67 2f c6 11  ..r.}IM. ....g/..
0000-08e0:  8e 3d fa 63-68 f5 3d 7d-29 d1 4f 6a-c4 ec 47 dc  .=.ch.=} ).Oj..G.
0000-08f0:  e3 12 1c 6d-3d 79 24 8e-07 ff 00 5f-d2 b2 e4 69  ...m=y$. ..._...i
0000-0900:  5a 3d 04 f9-88 d8 32 c9-90 cc db db-e4 76 7f e2  Z=....2. .....v..
0000-0910:  0d d0 f1 d3-d8 7f f5 c3-6d ee d2 08-84 77 03 7e  ........ m....w.~
0000-0920:  00 d8 73 91-f4 27 fc 33-44 a1 cf 1b-44 ba 72 69  ..s..'.3 D...D.ri
0000-0930:  e9 a3 34 76-99 11 96 37-ce e6 e4 16-07 18 fd 73  ..4v...7 .......s
0000-0940:  51 bd ba 4a-99 64 59 06-40 e3 3d 3d-ff 00 3f e7  Q..J.dY. @.==..?.
0000-0950:  5c b7 94 1e-8f fa f9 ff-00 c3 1d 0a-ac 6a 47 58  \....... .....jGX
0000-0960:  ff 00 5f d7-f5 b8 0b a0-1d 10 fc d2-3f 54 19 ed  .._..... ....?T..
0000-0970:  db 19 eb f5-e9 83 cd 2b-4b 03 10 30-8c 54 16 1b  .......+ K..0.T..
0000-0980:  fd 07 04 91-8e 3b ff 00-f5 e9 fb 39-45 de 3f d7  .....;.. ...9E.?.
0000-0990:  99 0e af 35-94 95 bf af-90 b2 49 6c-1d 58 a8 0c  ...5.... ..Il.X..
0000-09a0:  41 55 23 f8-86 7f 5e b9-fc 7d aa 09-ae 51 22 54  AU#...^. .}...Q"T
0000-09b0:  42 44 67 80-03 6e 24 76-18 3d 47 5e-9e 95 ad 3a  BDg..n$v .=G^...:
0000-09c0:  52 95 9c df-f4 8c e5 52-cf 96 0b 41-ab 70 f7 0d  R......R ...A.p..
0000-09d0:  bd 91 c8 24-e0 23 29 db-8c 60 93 dc-e4 9e b9 a6  ...$.#). .`......
0000-09e0:  32 ac 71 2a-5b b1 28 cd-90 19 80 c7-7c 7a 8c e4  2.q*[.(. ....|z..
0000-09f0:  7e 7e 9d 75-84 39 5a 4b-fa b7 f5 ff-00 07 63 37  ~~.u.9ZK ......c7
0000-0a00:  24 f7 29 48-f2 7d a1 8a-b7 cc 46 ec-2a f0 72 b5  $.)H.}.. ..F.*.r.
0000-0a10:  5d dc bb 96-65 1b 89 24-9f 5a d7 cc-da 29 74 11  ]...e..$ .Z...)t.
0000-0a20:  98 b6 7d 33-9c 50 08 5f-70 45 0a c5-d8 70 93 68  ..}3.P._ pE...p.h
0000-0a30:  52 83 69 19-ef 9c f1 e9-52 45 3e d9-10 0e 53 20  R.i..... RE>...S.
0000-0a40:  6c 6e 9e fc-f6 e4 51 72-1c 6e 4e 97-19 d8 ac aa  ln....Qr .nN.....
0000-0a50:  a0 8c b6 10-8d 83 24 f1-8f 63 50 a8-df 06 77 2a  ......$. .cP...w*
0000-0a60:  95 60 41 ce-48 1d 3d c8-19 c7 e7 46-89 10 a3 62  .`A.H.=. ...F...b
0000-0a70:  c4 c0 86 f3-01 da c9 80-03 27 2f b7-a1 cf 7e 3b  ........ .'/...~;
0000-0a80:  fd 3f 07 43-7a f1 21 79-17 3c e5 48-18 07 a8 24  .?.Cz.!y .<.H...$
0000-0a90:  77 19 3e 9e-86 a5 c5 3f-74 94 ae ae-44 5e 6f 28  w.>....? t...D^o(
0000-0aa0:  14 f3 19 8e-40 6d d9 cf-d3 07 ae 0f-bf 4f ad 3a  ....@m.. .....O.:
0000-0ab0:  29 4f 94 63-6c 86 38 4d-b9 38 c1 00-67 8c 7a 0e  )O.cl.8M .8..g.z.
0000-0ac0:  e7 bd 39 2b-b1 e9 6d 09-9e e1 a4 91-52 3d 8e a5  ..9+..m. ....R=..
0000-0ad0:  01 1b d0 1c-12 40 ea 3a-67 8c fb fa-55 61 32 3e  .....@.: g...Ua2>
0000-0ae0:  cd e3 0a 23-2a 14 9e 32-09 c7 7e 98-34 a3 14 96  ...#*..2 ..~.4...
0000-0af0:  80 93 b0 ef-b4 22 c8 cd-8f ba b8 f9-4e 01 f9 b3  .....".. ....N...
0000-0b00:  c6 08 3d 4f-4f 6f ca bb-cb b8 bb 05-1f 37 50 4e  ..=OOo.. .....7PN
0000-0b10:  41 3e bc f3-9c e4 d3 4a-da 95 18 b2-20 c4 77 e9  A>.....J ......w.
0000-0b20:  49 d4 f4 fc-a9 dc d4 3d-69 29 0c 33-4a 31 df 91  I......= i).3J1..
0000-0b30:  40 0a 0e 71-9c 9c 0e 94-0f ba 7a 63-df b5 35 a8  @..q.... ..zc..5.
0000-0b40:  89 52 7d ac-72 58 a9 18-c7 1d 33 ef-9a 5f 31 76  .R}.rX.. ..3.._1v
0000-0b50:  61 06 d1 d0-b1 51 cf 71-cf a9 3f e4-d3 ba 33 70  a....Q.q ..?...3p
0000-0b60:  b0 d3 29 21-48 04 6d c7-38 e8 71 ed-f4 fd 2a 64  ..)!H.m. 8.q...*d
0000-0b70:  76 70 53 76-c7 71 b4 12-33 bc 12 7f-2f 4e 29 ee  vpSv.q.. 3.../N).
0000-0b80:  12 8a 48 64-ae 49 f9 db-23 00 29 c0-e5 46 79 ff  ..Hd.I.. #.)..Fy.
0000-0b90:  00 eb 53 32-37 12 47 cb-9e 09 c1 e7-8c e3 b1 a2  ..S27.G. ........
0000-0ba0:  ed 2b 30 4b-b0 34 87 cc-04 7c a7 a3-64 7e 7c 7e  .+0K.4.. .|..d~|~
0000-0bb0:  95 16 48 6c-f4 22 a6 4c-b8 a1 28 a9-28 51 8a 4f  ..Hl.".L ..(.(Q.O
0000-0bc0:  5a 60 14 bd-f9 fd 68 40-1e d4 aa c5-73 dc 11 82  Z`....h@ ....s...
0000-0bd0:  33 40 85 62-0e 30 a3 3d-f1 4d c1 e9-9f 7e b4 d8  [email protected].= .M...~..
0000-0be0:  20 c7 19 1f-fe aa 77 f0-7d 3a f3 d4-71 40 07 98  ......w. }:..q@..
0000-0bf0:  4f df 25 f9-cf 27 8a 6f-eb 49 bb 82-56 03 d4 8e  O.%..'.o .I..V...
0000-0c00:  3d 29 28 18-b8 ff 00 3e-b4 94 80 5c-7b 8a 4a 60  =)(....> ...\{.J`
0000-0c10:  14 76 a4 01-45 30 17 8c-7b d2 b1 04-e7 9e 7a e4  .v..E0.. {.....z.
0000-0c20:  e6 81 0d ef-4b 9e 28 18-0e 0f 34 94-00 b8 e3 34  ....K.(. ..4....4
0000-0c30:  94 00 0e 28-a0 02 8a 40-14 50 02 8a-4a 00 3f 1a  ...(...@ .P..J.?.
0000-0c40:  5e dd 29 80-94 b4 80 07-1c d2 53 00-fa d1 40 0a  ^.)..... ..S...@.
0000-0c50:  7d a9 29 00-51 40 05 14-00 52 8a 60-25 29 c0 c7  }.).Q@.. .R.`%)..
0000-0c60:  1f 5a 40 25-2e 78 c5 00-19 ce 79 a4-a0 05 cf 5e  .Z@%.x.. ..y....^
0000-0c70:  07 3f a5 25-00 1d 7a 51-40 05 14 00-a4 92 72 4e  .?.%..zQ @.....rN
0000-0c80:  4d 25 00 14-1a 00 28 ed-40 05 29 39-3e b4 c0 01  M%....(. @.)9>...
0000-0c90:  20 10 0f 5e-0d 04 e4 01-e8 3d 29 00-94 50 01 fc  ...^.... .=)..P..
0000-0ca0:  a8 a0 02 8a-00 29 73 f4-e2 80 12 8a-00 28 a0 02  .....)s. .....(..
0000-0cb0:  8a 00 28 a0-02 8a 00 28-a0 03 ad 14-00 51 40 05  ..(....( .....Q@.
0000-0cc0:  14 00 51 40-05 14 00 51-40 05 14 00-02 41 c8 e0  [email protected] @....A..
0000-0cd0:  d1 40 05 14-00 52 8f ad-30 12 97 9e-87 23 06 80  [email protected].. 0....#..
0000-0cd6:  0c 7a 73 49-48 0f                                .zsIH.

Hex dump of file 2:
file name: 1_Video.dcm
mime type: 

0000-0010:  cc 4b 00 00-00 00 00 00-00 00 00 00-00 00 00 00  .K...... ........
0000-0020:  00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00  ........ ........
0000-0030:  00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00  ........ ........
0000-0040:  00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00  ........ ........
0000-0050:  00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00  ........ ........
0000-0060:  00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00  ........ ........
0000-0070:  00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00  ........ ........
0000-0080:  00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00  ........ ........
0000-0090:  44 49 43 4d-08 00 18 00-55 49 34 00-31 35 46 44  DICM.... UI4.15FD
0000-00a0:  41 36 34 2d-37 37 34 36-2d 34 36 43-46 2d 39 38  A64-7746 -46CF-98
0000-00b0:  44 42 2d 30-30 33 43 45-30 35 31 42-39 46 33 2e  DB-003CE 051B9F3.
0000-00c0:  35 31 33 31-2e 31 36 37-35 34 2e 36-31 39 35 36  5131.167 54.61956
0000-00d0:  08 00 20 00-44 41 08 00-32 30 30 37-30 39 31 38  ....DA.. 20070918
0000-00e0:  08 00 21 00-44 41 08 00-32 30 30 37-30 39 31 38  ..!.DA.. 20070918
0000-00f0:  08 00 31 00-54 4d 06 00-31 36 33 36-34 30 08 00  ..1.TM.. 163640..
0000-0100:  32 00 54 4d-06 00 31 36-33 36 34 31-08 00 60 00  2.TM..16 3641..`.
0000-0110:  43 53 04 00-4f 43 54 20-08 00 70 00-4c 4f 12 00  CS..OCT. ..p.LO..
0000-0120:  43 61 72 6c-20 5a 65 69-73 73 20 4d-65 64 69 74  Carl.Zei ss.Medit
0000-0130:  65 63 08 00-10 10 53 48-04 00 4f 43-54 33 08 00  ec....SH ..OCT3..
0000-0140:  90 10 4c 4f-04 00 33 30-30 30 10 00-10 00 50 4e  ..LO..30 00....PN
0000-0150:  06 00 63 33-5e 32 30 34-10 00 20 00-4c 4f 08 00  ..c3^204 ....LO..
0000-0160:  31 33 36 35-33 37 37 20-10 00 30 00-44 41 08 00  1365377. ..0.DA..
0000-0170:  31 39 34 35-30 31 31 32-10 00 40 00-43 53 02 00  19450112 [email protected]..
0000-0180:  4d 20 10 00-54 21 53 48-02 00 5c 20-10 00 60 21  M...T!SH ..\...`!
0000-0190:  53 48 06 00-57 68 69 74-65 20 10 00-00 40 4c 54  SH..Whit e....@LT
0000-01a0:  00 00 18 00-00 10 4c 4f-0a 00 33 30-30 30 2d 36  ......LO ..3000-6
0000-01b0:  37 30 37 20-18 00 20 10-4c 4f 0c 00-34 2e 30 2e  707..... LO..4.0.
0000-01c0:  37 20 28 30-31 33 32 29-20 00 0d 00-55 49 28 00  7.(0132) ....UI(.
0000-01d0:  31 35 46 44-41 36 34 2d-37 37 34 36-2d 34 36 43  15FDA64- 7746-46C
0000-01e0:  46 2d 39 38-44 42 2d 30-30 33 43 45-30 35 31 42  F-98DB-0 03CE051B
0000-01f0:  39 46 33 2e-35 31 33 31-20 00 0e 00-55 49 2e 00  9F3.5131 ....UI..
like image 388
azal Avatar asked Mar 07 '23 15:03

azal


1 Answers

You have stumbled upon a file containing several non-conformities to the DICOM standard. The one that's most critical is the lack of a file meta header, which would include the file's transfer syntax. It also includes primitive identifier values (such as 15FDA64-7746-46CF-98DB-003CE051B9F3.5131.16754.61956), which are not valid UIDs (due to the presence of hyphens), along with some other inconsistencies. This makes it inevitable harder to manipulate using open, standard-conforming tools and libraries. Once a transfer syntax is unknown, external assumptions need to be made one way or another.

But all is not lost in this particular case. The dcmdump tool, by detecting ExplicitVRLittleEndian as the transfer syntax, has managed to recover some attributes (some parts removed for brevity):

# Dicom-File-Format

# Dicom-Meta-Information-Header
# Used TransferSyntax: Unknown Transfer Syntax

# Dicom-Data-Set
# Used TransferSyntax: Little Endian Explicit
(0008,0018) UI [15FDA64-7746-46CF-98DB-003CE051B9F3.5131.16754.61956] #  52, 1 SOPInstanceUID

[...]

(0008,0060) CS [OCT]                                    #   4, 1 Modality

[...]

(0028,0002) US 1                                        #   2, 1 SamplesPerPixel
(0028,0004) CS [MONOCHROME2]                            #  12, 1 PhotometricInterpretation
(0028,0010) US 240                                      #   2, 1 Rows
(0028,0011) US 320                                      #   2, 1 Columns
(0028,0034) IS [1\1]                                    #   4, 2 PixelAspectRatio
(0028,0100) US 8                                        #   2, 1 BitsAllocated
(0028,0101) US 8                                        #   2, 1 BitsStored
(0028,0102) US 7                                        #   2, 1 HighBit
(0028,0103) US 0                                        #   2, 1 PixelRepresentation

[...]

(7fe0,0010) OW 0000\0c00\506a\2020\0a0d\0a87\0000\1800\7466\7079\706a\2078\0000... # 19404, 1 PixelData

The necessary details to retrieve the pixel data appear to be present at first glance. However, the PixelData has a length of 19404 bytes, whereas a raw 320x240x1 bitmap would require 76800 bytes. This is where pydicom ultimately fails, as it attempts to read the pixel data as an uncompressed array of pixels. At this point we can assume that the image data is in some other encoding. Writing the DICOM element value to a separate file:

with open('PixelData.bin', mode='wb') as f:
    f.write(myfile.PixelData)

We can do a magic test with file:

$ file PixelData.bin
PixelData.bin: JPEG 2000 Part 2 (JPX)

The PixelData field contains a JPEG 2000 image file. The PIL image module can handle the format, so we can manually transform the data into an array without the assistance of pydicom. According to Open PIL image from byte file:

from PIL import Image
import io

image = Image.open(io.BytesIO(myfile.PixelData))
pixels = np.array(image.getdata()).reshape((myfile.Columns, myfile.Rows))

To summarise:

  • Non-conforming DICOM files can be problematic to use because they won't work well with existing tools;
  • With a set of assumptions about the transfer syntax (namely assuming the most common form that is VR-explicit little endian), there's a chance of obtaining the necessary pieces to recover the pixel data.
  • If the pixel data DICOM element is fully identified, it may still be in an unspecified encoding. Luckily, image loading tools such as the one in PIL can automatically detect the underlying format in some cases.
like image 147
E_net4 stands with Ukraine Avatar answered Mar 15 '23 02:03

E_net4 stands with Ukraine