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

ENH: Use AcquisitionTime for acq_time scans file field #459

Merged
merged 5 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions heudiconv/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ def get_formatted_scans_key_row(dcm_fn):
"""
dcm_data = dcm.read_file(dcm_fn, stop_before_pixels=True, force=True)
# we need to store filenames and acquisition times
# parse date and time and get it into isoformat
# parse date and time of start of run acquisition and get it into isoformat
try:
date = dcm_data.ContentDate
time = dcm_data.ContentTime
date = dcm_data.AcquisitionDate
time = dcm_data.AcquisitionTime
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there AcquisitionDate? very unlikely but still possible that date could be different in some very rare case of scanning around midnight.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do have AcquisitionDate in my dicoms, and the standard has it listed, so I'll switch out ContentDate with AcquisitionDate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good now.

acq_time = get_datetime(date, time)
except (AttributeError, ValueError) as exc:
lgr.warning("Failed to get date/time for the content: %s", str(exc))
Expand Down
2 changes: 1 addition & 1 deletion heudiconv/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def test_get_formatted_scans_key_row():

row1 = get_formatted_scans_key_row(dcm_fn)
assert len(row1) == 3
assert row1[0] == '2016-10-14T09:26:36.693000'
assert row1[0] == '2016-10-14T09:26:34.692500'
assert row1[1] == 'n/a'
prandstr1 = row1[2]

Expand Down