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

Zeiss Datetime #112

Open
maxfscher opened this issue Oct 30, 2024 · 1 comment
Open

Zeiss Datetime #112

maxfscher opened this issue Oct 30, 2024 · 1 comment

Comments

@maxfscher
Copy link

maxfscher commented Oct 30, 2024

Hi all,

thanks for this intuitive and easy to use dicom converter. I have some data from a Zeiss scanner (I know you explicitly mention that you only provide base level compabilities). Thus I was also not surprised that the conversion did not work out of the box. I tried converting the data and got the error: ValueError: Invalid isoformat string: '2024-09-27T13:49:45.4425991Z'
Within the file #https://github.com/imi-bigpicture/wsidicomizer/blob/main/wsidicomizer/sources/czi/czi_metadata.py

added the parts in bold however solved the issue for me and the conversion produced totally fine DICOM files:

def aquisition_datetime(self) -> Optional[datetime]: value = self.get_value_from_element( self._metadata, "AcquisitionDateAndTime", str, nested=["Metadata", "Information", "Image"], ) **value=value.rstrip('Z') value=value[:26]** return datetime.fromisoformat(value)

Stripping the length of the time to only milliseconds was also necessary since the datetime tag in DICOM has a maximum lenght of 16.

@erikogabrielsson
Copy link
Collaborator

Hi @maxfscher and thanks for reporting this issue.
Are you using a python version prior to 3.11? If so, then the ValueError might be due that older python versions did not have as nice isoformat parsing. https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat
Removing the z and the last decimal seems to work.

For the datetime formatting into a DICOM dataset, this is handled by pydicom's DT class, which should format a correct DICOM element for any valid datetime-object (I hope...).

Would you like to make a PR to fix this 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