diff --git a/src/aliby/baby_sitter.py b/src/aliby/baby_sitter.py index a7d58df51aa2a4d16e9d0a37b1ee2f246ed358ba..a6b0b7223fca75f203cc5f53f5eec1c9a3a7235f 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 ba5be46e62630e489a66b2f123dad85c2b7644b6..01484929d8b2ebcb779f5d2ce10f08319b6beb21 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()