From 570ccfd46df9af2d9c57beb1514dff803efa82e4 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Thu, 11 Jul 2024 11:00:09 -0700 Subject: [PATCH] Fix bug in test_estimate_stabilization (#148) fix bug in non-integer z_idx --- mantis/cli/deskew.py | 4 +--- mantis/cli/estimate_stabilization.py | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mantis/cli/deskew.py b/mantis/cli/deskew.py index eb49da59..c848e989 100644 --- a/mantis/cli/deskew.py +++ b/mantis/cli/deskew.py @@ -1,5 +1,3 @@ -import multiprocessing as mp - from pathlib import Path from typing import List @@ -21,7 +19,7 @@ @click.option( "--num-processes", "-j", - default=mp.cpu_count(), + default=1, help="Number of cores", required=False, type=int, diff --git a/mantis/cli/estimate_stabilization.py b/mantis/cli/estimate_stabilization.py index 74fd4208..68cbf768 100644 --- a/mantis/cli/estimate_stabilization.py +++ b/mantis/cli/estimate_stabilization.py @@ -163,7 +163,11 @@ def estimate_xy_stabilization( if (output_folder_path / "positions_focus.csv").exists(): df = pd.read_csv(output_folder_path / "positions_focus.csv") pos_idx = str(Path(*input_data_path.parts[-3:])) - z_idx = list(df[df["position"] == pos_idx]["focus_idx"].replace(0, np.nan).ffill()) + focus_idx = df[df["position"] == pos_idx]["focus_idx"] + # forward fill 0 values, when replace remaining NaN with the mean + focus_idx = focus_idx.replace(0, np.nan).ffill() + focus_idx = focus_idx.fillna(focus_idx.mean()) + z_idx = focus_idx.astype(int).to_list() else: z_idx = [ focus_from_transverse_band(