I am tryying to read a multi-slice (Mosaic) DICOM image from a Siemens scanner in C++, using DCMTK to read the tag and information on the nibabel pages.
As I understand, Mosaic images have a CSA header and after 8 bytes (CSA1) or 16 bytes (CSA2), contain the structure
<TAG level>
tag name [64x uchar]
vm vr dt it mm [ 5x 4 bytes]
vm: [1x int32]: number of values
vr: [4x uchar]: 'value representation' string
dt: [1x int32]: 'Syngo DT' Siemens version of vr
it: [1x int32]: number of items
mm: [1x int32]: 77 (ascii value for 'M' I guess, or 205 [+128])
<ITEM level>
a b c d [ 4x 4 bytes]
a: [1x int32]: in CSA1: size Nitem in bytes + 'it' of first tag(?!)
b: [1x int32]: in CSA2: size Nitem in bytes
c: [1x int32]: 77 or 205 again, see above
d: [1x int32]: not used by nibabel
val [Nitem bytes]: item value
padding [nextw bytes]: start of next 4-byte word
It's special. But doable. In CSA2, numbers a, b and d would be the same.
Now I've reached the tag MrPhoenixProtocol which contains a JSON structure. This is not a problem (parsers aplenty). The 5 values described above are vm=1, vr='UN', dt=0, it=6, mm=77. The value 6 for it is strange but happens in other tags as well (1 item followed by 5 empty items).
Then for the first item, a, b and d are 192 and c is 77, so all signs say the item size is 192 bytes. But this barely reaches the 1st parameter in the JSON, the field is much larger. So 192 bytes is only a small portion of the item/tag, and after that the checks show that the value 77 or 205 is not being read where it should.
before reading the tag values, the size of their data needs to be known. But in the case of this MrPhoenixProtocol tag, if it is not in those numbers (so not the value 192), can it be computed another way?
EDIT
The function csareader.py shows the MrPhoenixProtocol tag correctly. I added the line
`print('{0} values: 1:{1}, 2:{2}, 3:{3}, 4:{4}, item_len: {5}'.format(name,x0,x1,x2,x3,item_len));
just before the item is read from the buffer and opened my DICOM image. The item length is shown to be 139200 items (in the example above, a, b and d would have that value), 725 times 192 (the value that I read). Completely baffled.
If you have not found it yet, you can inspect the CSA structure of one DICOM file using:
You should get something like this:
The code can be inspected at:
If you are only interested in the 'MrProtocol' sub-section, you can use: