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

Feature Request: support dicom datetime with timezone information #777

Open
AlanKuurstra opened this issue Aug 7, 2024 · 0 comments
Open

Comments

@AlanKuurstra
Copy link
Contributor

Summary

Dicom conversion fails if the dicom datetime contains timezone information, eg. "20230905141258.340-0400"

Traceback (most recent call last):
File "/usr/local/bin/heudiconv", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.9/dist-packages/heudiconv/cli/run.py", line 30, in main
workflow(**kwargs)
File "/usr/local/lib/python3.9/dist-packages/heudiconv/main.py", line 479, in workflow
prep_conversion(
File "/usr/local/lib/python3.9/dist-packages/heudiconv/convert.py", line 259, in prep_conversion
convert(
File "/usr/local/lib/python3.9/dist-packages/heudiconv/convert.py", line 637, in convert
save_scans_key(item, bids_outfiles)
File "/usr/local/lib/python3.9/dist-packages/heudiconv/bids.py", line 494, in save_scans_key
rows[f_name] = get_formatted_scans_key_row(item[-1][0])
File "/usr/local/lib/python3.9/dist-packages/heudiconv/bids.py", line 579, in get_formatted_scans_key_row
acq_datetime = dicoms.get_datetime_from_dcm(dcm_data=dcm_data)
File "/usr/local/lib/python3.9/dist-packages/heudiconv/dicoms.py", line 536, in get_datetime_from_dcm
return strptime_micr(acq_dt, "%Y%m%d%H%M%S[.%f]")
File "/usr/local/lib/python3.9/dist-packages/heudiconv/utils.py", line 689, in strptime_micr
return datetime.strptime(date_string, fmt)
File "/usr/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/lib/python3.9/_strptime.py", line 352, in _strptime
raise ValueError("unconverted data remains: %s" %
ValueError: unconverted data remains: .372-0400

Perhaps strptime_micr could support a fmt with an additional optional [%z]?

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

1 participant