-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NickAkhmetov/CAT-775 - EPIC builders boilerplate, migrate API client (#…
…91)
- Loading branch information
1 parent
8d8e16e
commit 40c7be6
Showing
12 changed files
with
1,287 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.2.5 | ||
0.2.6 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from abc import ABC, abstractmethod | ||
from vitessce import VitessceConfig | ||
from .base_builders import ConfCells | ||
from ..utils import get_conf_cells | ||
|
||
|
||
# EPIC builders take in a vitessce conf output by a previous builder and modify it | ||
# accordingly to add the EPIC-specific configuration. | ||
class EPICConfBuilder(ABC): | ||
def __init__(self, base_conf: ConfCells, epic_uuid) -> None: | ||
|
||
conf, cells = base_conf | ||
|
||
if conf is None: | ||
raise ValueError("ConfCells object must have a conf attribute") | ||
|
||
self._is_plural = isinstance(conf, list) | ||
|
||
if self._is_plural: | ||
self._base_conf = [ | ||
VitessceConfig.from_dict(conf) for conf in conf | ||
] | ||
else: | ||
self._base_conf: VitessceConfig = VitessceConfig.from_dict(base_conf.conf) | ||
|
||
self._epic_uuid = epic_uuid | ||
pass | ||
|
||
def get_conf_cells(self): | ||
self.apply() | ||
if (self._is_plural): | ||
return get_conf_cells([conf.to_dict() for conf in self._base_conf]) | ||
return get_conf_cells(self._base_conf) | ||
|
||
def apply(self): | ||
if self._is_plural: | ||
for conf in self._base_conf: | ||
self._apply(conf) | ||
else: | ||
self._apply(self._base_conf) | ||
|
||
@abstractmethod | ||
def _apply(self, conf): # pragma: no cover | ||
pass | ||
|
||
|
||
class SegmentationMaskBuilder(EPICConfBuilder): | ||
|
||
def _apply(self, conf): | ||
datasets = conf.get_datasets() | ||
print(f"Found {len(datasets)} datasets") | ||
# Proof of concept using one of the kaggle segmentation masks for now | ||
# segmentations = ObsSegmentationsOmeTiffWrapper( | ||
# img_url='https://assets.hubmapconsortium.org/c9d9ab5c9ee9642b60dd351024968627/ometiff-pyramids/VAN0042-RK-3-18-registered-PAS-to-postAF-registered.ome_mask.ome.tif?token=AgndN7NVbn83wwDXjpnY1Y0lDoJj2j7zOGmn1WN6qr9pqdkjKmt9C1XYm4KrlWrOXE9rVJvpnEKrPjIXrlKd1hmDGjV', | ||
# # offsets_path=f'./{name}/{name}/offsets/{name}.segmentations.offsets.json', | ||
# obs_types_from_channel_names=True, | ||
# ) | ||
# dataset.add_object(segmentations) | ||
pass |
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.