Skip to content
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 pixl_dcmd/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ classifiers = ["Programming Language :: Python :: 3"]
dependencies = [
"core==0.2.0rc0",
"arrow==1.4.0",
"deid==0.3.25",
"dicom-anonymizer==1.0.13.post1",
"deid==0.4.12",
"dicom-anonymizer==2.0.0",
"dicom-validator==0.7.3",
"logger==1.4",
"pydicom==2.4.5",
"pydicom==3.0.2",
"pydicom-data",
"python-decouple==3.8",
"requests==2.33.0",
Expand Down
2 changes: 1 addition & 1 deletion pixl_dcmd/tests/test_tagrecording.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

def test_record_dicom_headers(tmpdir, mock_header_record_path):
ds = generate_dicom_dataset()
ds.save_as(str(tmpdir / "test.dcm"), write_like_original=False)
ds.save_as(str(tmpdir / "test.dcm"), enforce_file_format=True)
with open(str(tmpdir / "test.dcm"), "rb") as f:
ds_bytes = f.read()
record_dicom_headers(ds_bytes)
Expand Down
2 changes: 1 addition & 1 deletion pixl_imaging/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies = [
"core==0.2.0rc0",
"aiohttp==3.13.4",
"alembic==1.18.4",
"pydicom==2.4.5",
"pydicom==3.0.2",
"uvicorn==0.44.0",
]

Expand Down
2 changes: 1 addition & 1 deletion pytest-pixl/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ classifiers = [
"Programming Language :: Python :: 3"
]
dependencies = [
"pydicom==2.4.5",
"pydicom==3.0.2",
"pyftpdlib==2.2.0",
"pyOpenSSL==26.0.0",
"python-decouple==3.8",
Expand Down
19 changes: 7 additions & 12 deletions pytest-pixl/src/pytest_pixl/dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def write_volume(filename_pattern: str) -> None:
variables = json.loads(dicom_variables_path.open("r").read())
rng = np.random.default_rng(0)
for i, slice_info in enumerate(variables):
slice_info["pixel_data"] = rng.random(size=(256, 256))
slice_info["pixel_data"] = (rng.random(size=(256, 256)) * 65535).astype(np.uint16)
ds = generate_dicom_dataset(slice_info)
file_name = filename_pattern.format(slice=i)
ds.save_as(file_name, write_like_original=False)
ds.save_as(file_name, enforce_file_format=True)


TAGS_DICT = {
Expand Down Expand Up @@ -101,7 +101,7 @@ def generate_dicom_dataset(tag_values: dict = TAGS_DICT, **kwargs: Any) -> Datas
pixel_data = tag_values["pixel_data"]

if pixel_data is None:
pixel_data = np.zeros((256, 256))
pixel_data = np.zeros((256, 256), dtype=np.uint16)

ds = _generate_default_dicom_dataset()
ds.InstanceCreationTime = instance_creation_time
Expand Down Expand Up @@ -131,7 +131,8 @@ def generate_dicom_dataset(tag_values: dict = TAGS_DICT, **kwargs: Any) -> Datas
# Convert Dataset to FileDataset
# Note: required for image operations using deid which requires FileDataset
with tempfile.NamedTemporaryFile(suffix=".dcm") as tmp:
ds.save_as(tmp.name, write_like_original=False)
# a from_json dataset has no transfer syntax, so state the encoding here
ds.save_as(tmp.name, enforce_file_format=True, implicit_vr=True, little_endian=True)
return dcmread(tmp.name)


Expand All @@ -144,11 +145,7 @@ def _generate_default_dicom_dataset() -> Dataset:
"data/default_dicom_tags.json"
)
variables = json.loads(default_variables_path.open("r").read())
ds = Dataset.from_json(variables)
# Not sure why these weren't carried over to the JSON
ds.is_implicit_VR = True
ds.is_little_endian = True
return ds
return Dataset.from_json(variables)


def _create_default_json(json_file: Path) -> None: # noqa: PLR0915 (too many statements)
Expand All @@ -159,7 +156,7 @@ def _create_default_json(json_file: Path) -> None: # noqa: PLR0915 (too many st

:param json_file: The path to save the JSON file to.
"""
pixel_data = np.zeros((256, 256))
pixel_data = np.zeros((256, 256), dtype=np.uint16)

# File meta info data elements
file_meta = FileMetaDataset()
Expand Down Expand Up @@ -408,8 +405,6 @@ def _create_default_json(json_file: Path) -> None: # noqa: PLR0915 (too many st
ds.PixelData = pixel_data.tobytes()

ds.file_meta = file_meta
ds.is_implicit_VR = True
ds.is_little_endian = True

# Export as JSON dictionary
with Path(json_file, encoding="utf-8").open("w") as f:
Expand Down
2 changes: 1 addition & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def _upload_dicom_instance(dicom_dir: Path, **kwargs: Any) -> None:
dicom_dir
/ f"{kwargs['PatientID']}_{kwargs['AccessionNumber']}_{kwargs['SeriesDescription']}.dcm"
)
ds.save_as(str(test_dcm_file), write_like_original=False)
# I think we can skip writing to disk!
ds.save_as(str(test_dcm_file), enforce_file_format=True)
_upload_to_vna(test_dcm_file)


Expand Down
28 changes: 14 additions & 14 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading