open-dicom / dicom_parser

Facilitates DICOM data access.
https://dicom-parser.readthedocs.io/en/latest/?badge=latest
MIT License
26 stars 15 forks source link

PhaseEncodingDirectionPositive not extracted from CSA header #86

Closed magerkurth closed 2 years ago

magerkurth commented 2 years ago

Describe the bug PhaseEncodingDirectionPositive not extracted from CSA header

To Reproduce Steps to reproduce the behavior:

self._header = dicom_parser.Header(self._filename)
self._csa_header = dicom_parser.utils.siemens.csa.header.CsaHeader(self._header.get("CSASeriesHeaderInfo", parsed=False))
self._csa_header_parsed = self._csa_header.parsed

No key with "PhaseEncodingDirectionPositive" in the dictionary (or sub-diktioniers and lists) of self._csa_header_parsed

Desktop:

Prove that DICOM file contains "PhaseEncodingDirectionPositive" In a bash terminal execute:

strings /incoming/dicom.dcm | sort | grep -I phase

This code finds a field "PhaseEncodingDirectionPositive"

Further comments I was working on the problem of extracting the phase encoding direction, when I came across this issue. I have not checked if other fields are missing too, but that could be very well the case.

magerkurth commented 2 years ago

PS: I am happy to help with the phase encoding direction problem: Fix phase encoding property #81

ZviBaratz commented 2 years ago

@magerkurth Thank you for reporting this!

Two comments:

I think you should try:

>>> header = dicom_parser.Header(path)
>>> csa_header = header.get("CSAImageHeaderInfo")
>>> csa_header.get("PhaseEncodingDirectionPositive")
{'index': 20, 'VR': 'IS', 'VM': 1, 'value': 1}
# Or, do return i/j/-/+:
>>> header.get_phase_encoding_direction()
'i-'

Does this work?

magerkurth commented 2 years ago

Hi,

Thank for the quick response. Oh dear, I have missed the "Image" instead of the "Series". I will try your suggestion after I am back from my annual leave.

Best wishes.

magerkurth commented 2 years ago

"Image" instead of "Series" did the trick.

However, header.get("CSAImageHeaderInfo") does not return a parsed object, but type byte. I can live with this, using the following work around.

 self._csa_image_header = dicom_parser.utils.siemens.csa.header.CsaHeader(self._header.get("CSAImageHeaderInfo", parsed=False))
 logger.debug2('Parsing CSA Image header\n')
 self._csa_image_header_parsed = self._csa_image_header.read()

I am using the dicom_parser version from 19.02. I will try it again with the updated version uploaded a few hours ago.

ZviBaratz commented 2 years ago

Ok, let me know how it goes. If it still doesn't work, I'd suggest trying to use the tag instead of the name (("0029", "1010")).

ZviBaratz commented 2 years ago

@magerkurth any updates? Can this be closed?