diff --git a/src/aliby/utils/imageViewer.py b/src/aliby/utils/imageViewer.py index 044fef6adab919c0b0e4652893cae8e802d82cfc..b5448ae042a5127f4027b013c0462a0f2a3dd16d 100644 --- a/src/aliby/utils/imageViewer.py +++ b/src/aliby/utils/imageViewer.py @@ -30,7 +30,7 @@ from agora.io.cells import Cells from agora.io.writer import load_attributes from aliby.io.image import dispatch_image from aliby.tile.tiler import Tiler, TilerParameters -from aliby.utils.plot import stretch_image +from aliby.utils.plot import stretch_clip default_colours = { "Brightfield": "Greys_r", @@ -56,28 +56,6 @@ def custom_imshow(a, norm=None, cmap=None, *args, **kwargs): ) -class localImageViewer: - """ - Fast access to Images segmented locally without tiling - from image.h5 objects. - """ - - def __init__(self, h5file, data_source=None): - self._hdf = h5py.File(h5file) - self.positions = list(self._hdf.keys()) - self.current_position = self.positions[0] - - def plot_position(self, channel=0, tp=0, z=0, stretch=True): - pixvals = self._hdf[self.current_position][channel, tp, ..., z] - if stretch: - minval = np.percentile(pixvals, 0.5) - maxval = np.percentile(pixvals, 99.5) - pixvals = np.clip(pixvals, minval, maxval) - pixvals = ((pixvals - minval) / (maxval - minval)) * 255 - - Image.fromarray(pixvals.astype(np.uint8)) - - class BaseImageViewer(ABC): def __init__(self, fpath): @@ -112,6 +90,7 @@ class LocalImageViewer(BaseImageViewer): """ Tool to generate figures from local files, either zarr or files organised in directories. + TODO move common functionality from RemoteImageViewer to BaseImageViewer """ def __init__(self, results_path: str, data_path: str): @@ -133,7 +112,7 @@ class LocalImageViewer(BaseImageViewer): self.cells = Cells.from_source(results_path) -class remoteImageViewer(BaseImageViewer): +class RemoteImageViewer(BaseImageViewer): """ This ImageViewer combines fetching remote images with tiling and outline display. """ @@ -364,7 +343,7 @@ class remoteImageViewer(BaseImageViewer): ), "Invalid norm argument." if norm and norm in ("l1", "l2", "max"): - images = {k: stretch_image(v) for k, v in images.items()} + images = {k: stretch_clip(v) for k, v in images.items()} images = [concat_pad(img, width, nrows) for img in images.values()] # TODO convert to RGB to draw fluorescence with colour diff --git a/src/extraction/core/extractor.py b/src/extraction/core/extractor.py index 8a29766f540423f022c99638459f79a9231f0058..34ce783cc0f10b951677e702e3ad38e6b1f75766 100644 --- a/src/extraction/core/extractor.py +++ b/src/extraction/core/extractor.py @@ -61,23 +61,6 @@ class ExtractorParameters(ParametersABC): self.sub_bg = sub_bg self.multichannel_ops = multichannel_ops - @staticmethod - def guess_from_meta(store_name: str, suffix="fast"): - """ - Find the microscope name from the h5 metadata. - - Parameters - ---------- - store_name : str or Path - For a h5 file - suffix : str - Added at the end of the predicted parameter set - """ - with h5py.File(store_name, "r") as f: - microscope = f["/"].attrs.get("microscope") - assert microscope, "No metadata found" - return "_".join((microscope, suffix)) - @classmethod def default(cls): return cls({})