Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSA header tutorial #119

Open
kteh123 opened this issue Dec 15, 2022 · 3 comments
Open

CSA header tutorial #119

kteh123 opened this issue Dec 15, 2022 · 3 comments

Comments

@kteh123
Copy link

kteh123 commented Dec 15, 2022

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

@ZviBaratz
Copy link
Collaborator

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?

@kteh123
Copy link
Author

kteh123 commented Dec 15, 2022

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

@ZviBaratz
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants