Skip to content

Commit 5e9bbcf

Browse files
committed
Fix view position bug for Implant Displaced
These were exporting DICOM with a ViewPosition tag of LCCIDID, the implant displaced suffix needed to be considered.
1 parent ddb0dc4 commit 5e9bbcf

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/modality_emulator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ def generate_dicom(self) -> Dataset:
6161
logger.error("No dataset provided for DICOM generation")
6262
return ds
6363

64-
img_path = f"{SAMPLE_IMAGES_PATH}/L{self.view.replace('ID', '')}.jpg"
64+
view_position = self.view.replace("ID", "")
65+
66+
img_path = f"{SAMPLE_IMAGES_PATH}/L{view_position}.jpg"
6567
img = Image.open(img_path).convert("L")
6668
if self.laterality == "R":
6769
img = img.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
@@ -89,7 +91,7 @@ def generate_dicom(self) -> Dataset:
8991
ds.PixelRepresentation = 0
9092
ds.PixelData = pixel_bytes
9193
ds.ImageLaterality = self.laterality
92-
ds.ViewPosition = self.view
94+
ds.ViewPosition = view_position
9395

9496
ds.AccessionNumber = self.dataset.AccessionNumber
9597
ds.PatientID = self.dataset.PatientID

tests/scripts/test_database.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import pytest
21
import sqlite3
32
import sys
43
from pathlib import Path
54

5+
import pytest
6+
67
sys.path.append(f"{Path(__file__).parent.parent.parent}/scripts/python")
78

89
from database import backup_database, reset_worklist_database

tests/test_modality_emulator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_generate_dicom_creates_valid_dataset(
5757
dicom = DicomExample(
5858
dataset=ds,
5959
laterality="L",
60-
view="CC",
60+
view="CCID",
6161
study_instance_uid=study_instance_uid,
6262
series_number=1,
6363
)

0 commit comments

Comments
 (0)