From 80c06dba844cbb6e370e6117a2e950e320b7f785 Mon Sep 17 00:00:00 2001 From: Peter Swain <peter.swain@ed.ac.uk> Date: Sat, 17 Feb 2024 18:35:39 +0000 Subject: [PATCH] fix(baby_sitter): bug in getdata Data now passed with x and y in the correct order; References to session removed from BabyParameters --- src/aliby/baby_sitter.py | 12 +++--------- src/aliby/pipeline.py | 8 ++++---- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/aliby/baby_sitter.py b/src/aliby/baby_sitter.py index a7d58df..a6b0b72 100644 --- a/src/aliby/baby_sitter.py +++ b/src/aliby/baby_sitter.py @@ -10,7 +10,7 @@ from agora.abc import ParametersABC, StepABC class BabyParameters(ParametersABC): - """Parameters used for analysing the results from BABY.""" + """Parameters used for running BABY.""" def __init__( self, @@ -18,7 +18,6 @@ class BabyParameters(ParametersABC): clogging_thresh, min_bud_tps, isbud_thresh, - session, ): """Initialise parameters for BABY.""" # pixel_size is specified in BABY's model sets @@ -26,7 +25,6 @@ class BabyParameters(ParametersABC): self.clogging_thresh = clogging_thresh self.min_bud_tps = min_bud_tps self.isbud_thresh = isbud_thresh - self.session = session @classmethod def default(cls, **kwargs): @@ -36,7 +34,6 @@ class BabyParameters(ParametersABC): clogging_thresh=1, min_bud_tps=3, isbud_thresh=0.5, - session=None, ) def update_baby_modelset(self, path: t.Union[str, Path, t.Dict[str, str]]): @@ -85,7 +82,6 @@ class BabyRunner(StepABC): clogging_thresh=parameters.clogging_thresh, min_bud_tps=parameters.min_bud_tps, isbud_thresh=parameters.isbud_thresh, - session=parameters.session, ) self.crawler = BabyCrawler(brain) self.brightfield_channel = self.tiler.ref_channel_index @@ -98,10 +94,8 @@ class BabyRunner(StepABC): def get_data(self, tp): """Get image and re-arrange axes.""" img_from_tiler = self.tiler.get_tp_data(tp, self.brightfield_channel) - # move z axis to the last axis - img_z_at_end = np.moveaxis(img_from_tiler, 1, destination=-1) - # move y axis before the x axis - img = np.moveaxis(img_z_at_end, 2, destination=1) + # move z axis to the last axis; Baby expects (n, x, y, z) + img = np.moveaxis(img_from_tiler, 1, destination=-1) return img def _run_tp( diff --git a/src/aliby/pipeline.py b/src/aliby/pipeline.py index ba5be46..0148492 100644 --- a/src/aliby/pipeline.py +++ b/src/aliby/pipeline.py @@ -1,4 +1,5 @@ """Set up and run pipelines: tiling, segmentation, extraction, and then post-processing.""" + import logging import os import re @@ -15,7 +16,7 @@ from pathos.multiprocessing import Pool from tqdm import tqdm try: - if baby.__version__ == "v0.30.1": + if baby.__version__: from aliby.baby_sitter import BabyParameters, BabyRunner except AttributeError: from aliby.baby_client import BabyParameters, BabyRunner @@ -178,6 +179,7 @@ class Pipeline(ProcessABC): for k in ("host", "username", "password") } self.expt_id = config["general"]["id"] + self.setLogger(config["general"]["directory"]) @staticmethod def setLogger( @@ -233,7 +235,6 @@ class Pipeline(ProcessABC): print("\t" + f"{i}: " + pos.split(".")[0]) # add directory to configuration self.parameters.general["directory"] = str(directory) - self.setLogger(directory) return position_ids def channels_from_OMERO(self): @@ -464,8 +465,7 @@ def check_earlystop(filename: str, es_parameters: dict, tile_size: int): ) # find tiles with cells covering too great a fraction of the tiles' area traps_above_athresh = ( - cells_used.groupby("trap").sum().apply(np.mean, axis=1) - / tile_size**2 + cells_used.groupby("trap").sum().apply(np.mean, axis=1) / tile_size**2 > es_parameters["thresh_trap_area"] ) return (traps_above_nthresh & traps_above_athresh).mean() -- GitLab