dicom_parser
dicom_parser copied to clipboard
CSA header tutorial
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
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?
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
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?