-
Notifications
You must be signed in to change notification settings - Fork 127
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
Allow filling of acq_time when AcquisitionDate AcquisitionTime missing #614
Conversation
Following up on this. Does this patch look viable? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it took so long!
- not yet sure on UID hash - left comment/idea, sorry didn't dig in detail yet
- would need python 3.7 incompatibility (
:=
) addressed - docstrings should follow numpy
- push and hopefully we get CI running on it
heudiconv/dicoms.py
Outdated
dicom_time_str = dcm_date + dcm_time.split('.', 1)[0] # YYYYMMDDHHMMSS | ||
# convert to epoch | ||
return calendar.timegm(time.strptime(dicom_time_str, '%Y%m%d%H%M%S')) | ||
if (dicom_datetime := get_datetime_from_dcm(dicom)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:=
was added in python 3.8. We still remain compatible with 3.7.
if (dicom_datetime := get_datetime_from_dcm(dicom)): | |
dicom_datetime = get_datetime_from_dcm(dicom) | |
if dicom_datetime: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The walrus operator has now been removed
rg ":="
utils/test-compare-two-versions.sh
16:outdir=${OUTDIR:=compare-versions}
heudiconv/dicoms.py
Outdated
Returns: | ||
int: either an int representing when the first dicom was created, | ||
in number of seconds since epoch, or if no datetime info is found then a hash of the | ||
SeriesInstanceUID (meaningless value, but reproducible) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a "hash" -- it would not be properly sortable between different dicom series. I can't recall ATM if that might not make it a trouble somewhere - needs checking on how datetime is used -- if not used anywhere for sorting.
heudiconv/dicoms.py
Outdated
dcm_data (pydicom.FileDataset): dicom with header, e.g., as ready by pydicom.dcmread | ||
|
||
Returns: | ||
datetime.datetime | None: one of several datetimes that are related to when the scan occurred. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make docstrings follow numpy docstring format https://numpydoc.readthedocs.io/en/latest/format.html#parameters
heudiconv/tests/test_dicoms.py
Outdated
def test_get_datetime_from_dcm(): | ||
import datetime | ||
typical_dcm = dcm.dcmread(op.join(TESTS_DATA_PATH, 'phantom.dcm'), stop_before_pixels=True) | ||
XA30_enhanced_dcm = dcm.dcmread(op.join(TESTS_DATA_PATH, 'MRI_102TD_PHA_S.MR.Chen_Matthews_1.3.1.2022.11.16.15.50.20.357.31204541.dcm'), stop_before_pixels=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what is our widest line , but this might be aiming to become a winner! Could we keep them within e.g. 120 chars?
Thanks! I will take a look at this in the next few days |
Just in case: is there a style or contributing guide that I'm not seeing? Something the specifies, e.g., docstring format and line length |
indeed there is none yet unfortunately, so everything "rests" on uniformity with "prior art". We should formalize some , filed #636 , contributions on that end are welcome - but may be we would push on it this wed... As for docstrings we have only
;-) |
Thanks for pointing that out! Still learning and I didn't think to look for something like that. :) |
@psadil are you planing to continue working on this PR? There is a number of needed changes for compatibility etc, besides discussion of sorting even. |
Oh, sorry for the miscommunication. I am planning on continuing the pull request but was waiting on a reply from you to this comment. That is, with regards to setting
|
heudiconv/dicoms.py
Outdated
# Reset the date to match the one from the dicom, not from the | ||
# filesystem so we could sort reproducibly | ||
def _assign_dicom_time(ti: tarfile.TarInfo) -> tarfile.TarInfo: | ||
# Try to reset the date to match the one of the last commit, not from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what commit? there is no assumption in heudiconv on having dataset in git here. And is this TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a comment that was there when I forked initially. I see that since then you've updated the note. When updating this pull request I'll make sure to integrate the more recent commits/handle any merge conflicts
@yarikoptic, this is now ready for review again. Thanks! |
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #614 +/- ##
==========================================
- Coverage 81.36% 81.30% -0.07%
==========================================
Files 42 42
Lines 3837 3888 +51
==========================================
+ Hits 3122 3161 +39
- Misses 715 727 +12
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
🤦 Thanks. fixed now |
Following up on this -- I fixed the typos edited by codespell. GitHub tells me that other changes have been requested, but I think those all relate to the initial draft of this request. |
looks good and CI is happy -- let's proceed. Thank you @psadil! |
@yarikoptic thank you for walking through this! |
🚀 PR was released in |
Closes #612