Skip to content

Commit

Permalink
Merge pull request #134 from big97kai/timestamp
Browse files Browse the repository at this point in the history
Fix .e2e timestamp
  • Loading branch information
marksgraham authored Feb 7, 2024
2 parents 1b93b31 + 013f25d commit 86839e1
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions oct_converter/readers/e2e.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

import time
import warnings
from collections import defaultdict
from datetime import date, datetime, timedelta
from datetime import date
from itertools import chain
from pathlib import Path

Expand Down Expand Up @@ -145,14 +146,18 @@ def _make_lut():
elif chunk.type == 10004: # bscan metadata
raw = f.read(104)
bscan_metadata = e2e_binary.bscan_metadata.parse(raw)
start_epoch = datetime(
year=1600, month=12, day=31, hour=23, minute=59
)
acquisition_datetime = start_epoch + timedelta(
seconds=bscan_metadata.acquisitionTime * 1e-7

windowsTicks = bscan_metadata.acquisitionTime
windowsTicksToUnixFactor = 10000000
secToUnixEpechFromWindowsTicks = 11644473600
unixtime = (
windowsTicks / windowsTicksToUnixFactor
- secToUnixEpechFromWindowsTicks
)
utc_time = time.gmtime(unixtime)
utc_time_string = time.strftime("%Y-%m-%d %H:%M:%S", utc_time)
if self.acquisition_date is None:
self.acquisition_date = acquisition_datetime.date()
self.acquisition_date = utc_time_string
if self.pixel_spacing is None:
# scaley found, x and z not yet found in file
# but taken from E2E reader settings
Expand Down

0 comments on commit 86839e1

Please sign in to comment.