dicom_parser icon indicating copy to clipboard operation
dicom_parser copied to clipboard

CSA header tutorial

Open kteh123 opened this issue 2 years ago • 3 comments
trafficstars

Hi

I'm trying to implement your csa header function. I followed the tutorial here:

https://github.com/open-dicom/dicom_parser/blob/main/docs/siemens/csa_headers.rst#id10

I have raw_csa that i need to read. However .parse() is no longer valid. Can you please help with reading the csa dictionary values like before. This is your example i found in dcm2nii forum:

from dicom_parser import Header header = Header(image) csa = header.get(("0029", "1010")) csa['B_matrix']

output: gives me a dictionary of values

Is there a tutorial or way to do this for raw_csa. Thank you for your help.

Kevin

kteh123 avatar Dec 15 '22 13:12 kteh123

Hi Kevin,

I'm not sure if I understand the issue well enough to help – will you be able to provide a file I can try to read? Or an exception you're raising?

ZviBaratz avatar Dec 15 '22 14:12 ZviBaratz

Hi Zvi

Sorry for not explaining better from your csa header tutorial form these lines of code:

csa_header = CsaHeader(raw_csa)

parsed_csa = csa_header.parse() type(parsed_csa) dict

(we can also use the parsed property)

csa_header.parsed["SliceArray"]["Size"] 60

instance_number = image.header.get("InstanceNumber") parsed_csa["SliceArray"]["Slice"][instance_number]["Position"]["Tra"] -58.1979682425

I'm trying to follow it but the csa_header.parse() and csa_header.parsed is not available anymore. What i want to do is to do from your tutorial something like csa_header.parsed["B_matrix"]["value"]. This works as below per your code:

from dicom_parser import Header header = Header(image) csa = header.get(("0029", "1010")) csa['B_matrix']['value']

I get correct values. But how do I use raw_csa instead of reading header from a dicom file like above. Thank you.

Kevin

kteh123 avatar Dec 15 '22 14:12 kteh123

If I understand correctly, you have the contents of CSA header (raw_csa) separately from a complete DICOM header, and you would like to parse it independently. If so, you should be able to use the CsaHeader class to read the contents, e.g.:

from dicom_parser.utils.siemens.csa.header import CsaHeader
csa = CsaHeader(raw_csa)
parsed = csa.read()

Does that resolve your issue?

ZviBaratz avatar Dec 17 '22 08:12 ZviBaratz