-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from ArcanaFramework/dicom-metadata
Cleans up the reading of DICOM metadata and returns dictionary not DICOM object
- Loading branch information
Showing
21 changed files
with
257 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
extras/fileformats/extras/application/tests/test_application_medical.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
import pytest | ||
from fileformats.application import Dicom | ||
|
||
|
||
def test_dicom_metadata(): | ||
|
||
dicom = Dicom.sample() | ||
|
||
assert dicom.metadata["EchoTime"] == "2.07" | ||
assert dicom.metadata["EchoTime"] == 2.07 | ||
|
||
|
||
def test_dicom_metadata_with_specific_tags(): | ||
|
||
dicom = Dicom(Dicom.sample(), metadata_keys=["EchoTime"]) | ||
|
||
assert dicom.metadata["EchoTime"] == 2.07 | ||
with pytest.raises(KeyError): | ||
dicom.metadata["PatientName"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
import imageio | ||
import typing as ty | ||
import numpy # noqa: F401 | ||
import typing # noqa: F401 | ||
from fileformats.core import extra_implementation | ||
from fileformats.core import FileSet, extra_implementation | ||
from fileformats.image.raster import RasterImage, DataArrayType | ||
|
||
|
||
@extra_implementation(RasterImage.load) | ||
def read_raster_data(image: RasterImage) -> DataArrayType: | ||
@extra_implementation(FileSet.load) | ||
def read_raster_data(image: RasterImage, **kwargs: ty.Any) -> DataArrayType: | ||
return imageio.imread(image.fspath) # type: ignore | ||
|
||
|
||
@extra_implementation(RasterImage.save) | ||
def write_raster_data(image: RasterImage, data: DataArrayType) -> None: | ||
imageio.imwrite(image.fspath, data) | ||
@extra_implementation(FileSet.save) | ||
def write_raster_data( | ||
image: RasterImage, data: DataArrayType, **kwargs: ty.Any | ||
) -> None: | ||
imageio.imwrite(image.fspath, data, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.