Skip to content

Commit

Permalink
Merge pull request #140 from T0mSIlver/poct_decode
Browse files Browse the repository at this point in the history
fix poct header decoding error handling and acquisition date conversion
  • Loading branch information
marksgraham authored Jun 23, 2024
2 parents cbd5f00 + edf1ea9 commit 576b9c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions oct_converter/dicom/dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,7 @@ def write_opt_dicom(
ds.ImageType = ["DERIVED", "SECONDARY"]
ds.SamplesPerPixel = 1
if meta.series_info.acquisition_date:
# Convert string to datetime object
input_datetime = datetime.strptime(
meta.series_info.acquisition_date, "%Y-%m-%d %H:%M:%S"
)
ds.AcquisitionDateTime = input_datetime.strftime("%Y%m%d%H%M%S.%f")
ds.AcquisitionDateTime = meta.series_info.acquisition_date.strftime("%Y%m%d%H%M%S.%f")
else:
ds.AcquisitionDateTime = ""

Expand Down
4 changes: 2 additions & 2 deletions oct_converter/readers/boct.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import h5py
import numpy as np
from construct import Struct
from construct import Struct, StringError
from numpy.typing import NDArray

from oct_converter.exceptions import InvalidOCTReaderError
Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(self, filepath: Path | str) -> None:
def _validate(self, path: Path) -> bool:
try:
self.header_structure.parse_file(path)
except UnicodeDecodeError:
except StringError:
raise InvalidOCTReaderError(
"OCT header does not match Bioptigen .OCT format. Did you mean to use Optovue .oct (POCT)?"
)
Expand Down

0 comments on commit 576b9c6

Please sign in to comment.