'How can I read a binary file that contains xml in python?
I have a binary file containing contours of DICOM image for MRI (exported from cvi42 software), I want to convert it to XML format.
with open('myfile.cvi42ws','rb') as f:
data = f.read()
print(f.tell())
print(data)
>> 177349
>> b'x\x9c\xec\x9d\x07`\\\xc5\xf1\xff\x9fD1-`\x08!\x84_B\x1cZH!Q\xb9 ...
When I run decode method I got this error:
data.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9c in position 1: invalid start byte
Solution 1:[1]
Thank you. Here is the answer I got from the cvi42 software producer company:
"The cvi42ws file format is not decodable. This file format is used only to transfer the saved cvi workspaces between different workstations. So it can be saved on one cvi42 workstation and then imported to another cvi42 workstation, but the contents are not decodable, and it is not possible to convert it to cvi42wsx. The cvi42wsx format can be on the other hand decoded. However, Circle does not provide the users with this file format, as it contains very sensitive information about the algorithms employed in cvi42."
Solution 2:[2]
I open this file as text and looking for point x and y. then plot contours. I looking for register DICOM with contours.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Behnamkvl |
Solution 2 | hamed aghapanah |