Skip to content
Snippets Groups Projects
Commit 80c06dba authored by pswain's avatar pswain
Browse files

fix(baby_sitter): bug in getdata

Data now passed with x and y in the correct order;
References to session removed from BabyParameters
parent f7840615
No related branches found
No related tags found
No related merge requests found
......@@ -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(
......
"""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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment