-
Notifications
You must be signed in to change notification settings - Fork 15
feat: ED-1855 Dicom and Nifti Space #1056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
55138d4
Move video space to more generic multiframe space
clinton-encord 2153f82
Add test for medical space
clinton-encord 57f36d4
Move video_space to multiframe_space folder
clinton-encord 90388cc
Small changes to Space enums
clinton-encord 5a0486c
Add medical stack space
clinton-encord ef4dbc6
Fix test
clinton-encord 85eca14
Fix test
clinton-encord 15f86fd
Fix mypy
clinton-encord 46dec3f
Fix sdk test
clinton-encord a2940d7
Add unit test for deserde dicom stack
clinton-encord 3d02eb2
Removen width and height from MultiFrameSpace
clinton-encord dc2d769
Rename space enums
clinton-encord cce4cdd
Rename folder
clinton-encord 769dc62
Fix test
clinton-encord 25ece52
Fix another test
clinton-encord 0f39a19
Reuse some logic in multiframe space
clinton-encord File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
46 changes: 46 additions & 0 deletions
46
encord/objects/spaces/multiframe_space/medical_file_space.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from encord.constants.enums import SpaceType | ||
| from encord.objects.spaces.multiframe_space.multiframe_space import MultiFrameSpace | ||
| from encord.objects.spaces.types import MedicalFileSpaceInfo | ||
| from encord.objects.types import LabelBlob | ||
|
|
||
| if TYPE_CHECKING: | ||
| from encord.objects.ontology_labels_impl import LabelRowV2 | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class MedicalFileSpace(MultiFrameSpace): | ||
| """Space for medical files (e.g. DICOM, NIfTI).""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| space_id: str, | ||
| label_row: LabelRowV2, | ||
| number_of_frames: int, | ||
| width: int, | ||
| height: int, | ||
| ): | ||
| super().__init__(space_id, label_row, number_of_frames=number_of_frames) | ||
| self._number_of_frames = number_of_frames | ||
| self._width = width | ||
| self._height = height | ||
|
|
||
| def _get_frame_dimensions(self, frame: int) -> tuple[int, int]: | ||
| return self._width, self._height | ||
|
|
||
| def _to_space_dict(self) -> MedicalFileSpaceInfo: | ||
| """Export space to dictionary format.""" | ||
| frame_labels = self._build_frame_labels_dict() | ||
|
|
||
| return MedicalFileSpaceInfo( | ||
| space_type=SpaceType.MEDICAL_FILE, | ||
| labels=frame_labels, | ||
| number_of_frames=self._number_of_frames, | ||
| width=self._width, | ||
| height=self._height, | ||
| ) |
38 changes: 38 additions & 0 deletions
38
encord/objects/spaces/multiframe_space/medical_stack_space.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| from typing import TYPE_CHECKING, List, Optional | ||
|
|
||
| from encord.constants.enums import SpaceType | ||
| from encord.exceptions import LabelRowError | ||
| from encord.objects.spaces.multiframe_space.multiframe_space import MultiFrameSpace | ||
| from encord.objects.spaces.types import DicomFrameInfo, MedicalStackSpaceInfo | ||
| from encord.objects.types import LabelBlob | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| if TYPE_CHECKING: | ||
| from encord.objects.ontology_labels_impl import LabelRowV2 | ||
|
|
||
|
|
||
| class MedicalStackSpace(MultiFrameSpace): | ||
clinton-encord marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """Space for medical files (e.g. DICOM, NIfTI).""" | ||
|
|
||
| def __init__(self, space_id: str, label_row: LabelRowV2, frames: List[DicomFrameInfo]): | ||
| super().__init__(space_id, label_row, number_of_frames=len(frames)) | ||
| self._frames = frames | ||
|
|
||
| def _get_frame_dimensions(self, frame_number: int) -> tuple[int, int]: | ||
| if frame_number >= self._number_of_frames: | ||
| raise LabelRowError( | ||
| f"Invalid frame number '{frame_number}'. This file only has {self._number_of_frames} frames." | ||
| ) | ||
|
|
||
| frame = self._frames[frame_number] | ||
| return frame["width"], frame["height"] | ||
|
|
||
| def _to_space_dict(self) -> MedicalStackSpaceInfo: | ||
| """Export space to dictionary format.""" | ||
| frame_labels = self._build_frame_labels_dict() | ||
|
|
||
| return MedicalStackSpaceInfo(space_type=SpaceType.MEDICAL_STACK, labels=frame_labels, frames=self._frames) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.