From b08b16be2e435eec4f6cd0cdfe7102bf901fc88b Mon Sep 17 00:00:00 2001 From: Matt Einhorn Date: Tue, 9 Apr 2024 23:51:20 -0400 Subject: [PATCH 1/2] Support single z-stack tif file for input. --- brainglobe_workflows/brainmapper/main.py | 8 ++++---- brainglobe_workflows/cellfinder_core/cellfinder_core.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/brainglobe_workflows/brainmapper/main.py b/brainglobe_workflows/brainmapper/main.py index ad82ecde..df344fdb 100644 --- a/brainglobe_workflows/brainmapper/main.py +++ b/brainglobe_workflows/brainmapper/main.py @@ -105,7 +105,7 @@ def run_all(args, what_to_run, atlas): from cellfinder.core.classify import classify from cellfinder.core.detect import detect from cellfinder.core.tools import prep - from cellfinder.core.tools.IO import read_with_dask + from cellfinder.core.tools.IO import read_z_stack from brainglobe_workflows.brainmapper import analyse from brainglobe_workflows.brainmapper.prep import ( @@ -120,7 +120,7 @@ def run_all(args, what_to_run, atlas): if what_to_run.detect: logging.info("Detecting cell candidates") args = prep_candidate_detection(args) - signal_array = read_with_dask( + signal_array = read_z_stack( args.signal_planes_paths[args.signal_channel] ) @@ -165,11 +165,11 @@ def run_all(args, what_to_run, atlas): if points is None: points = get_cells(args.paths.detected_points) if signal_array is None: - signal_array = read_with_dask( + signal_array = read_z_stack( args.signal_planes_paths[args.signal_channel] ) logging.info("Running cell classification") - background_array = read_with_dask(args.background_planes_path[0]) + background_array = read_z_stack(args.background_planes_path[0]) points = classify.main( points, diff --git a/brainglobe_workflows/cellfinder_core/cellfinder_core.py b/brainglobe_workflows/cellfinder_core/cellfinder_core.py index 65a94257..55d4c483 100644 --- a/brainglobe_workflows/cellfinder_core/cellfinder_core.py +++ b/brainglobe_workflows/cellfinder_core/cellfinder_core.py @@ -30,7 +30,7 @@ import pooch from brainglobe_utils.IO.cells import save_cells from cellfinder.core.main import main as cellfinder_run -from cellfinder.core.tools.IO import read_with_dask +from cellfinder.core.tools.IO import read_z_stack from cellfinder.core.train.train_yml import depth_type from brainglobe_workflows.utils import ( @@ -356,7 +356,7 @@ def run_workflow_from_cellfinder_run(cfg: CellfinderConfig): The steps are: 1. Read the input signal and background data as two separate - Dask arrays. + Dask (or memory if single file stack) arrays. 2. Run the main cellfinder pipeline on the input Dask arrays, with the parameters defined in the input configuration (cfg). 3. Save the detected cells as an xml file to the location specified in @@ -369,8 +369,8 @@ def run_workflow_from_cellfinder_run(cfg: CellfinderConfig): the cellfinder workflow """ # Read input data as Dask arrays - signal_array = read_with_dask(str(cfg._signal_dir_path)) - background_array = read_with_dask(str(cfg._background_dir_path)) + signal_array = read_z_stack(str(cfg._signal_dir_path)) + background_array = read_z_stack(str(cfg._background_dir_path)) # Run main analysis using `cellfinder_run` detected_cells = cellfinder_run( From 68b4866fe292d611aa75202d54d2af7d6f0da650 Mon Sep 17 00:00:00 2001 From: Alessandro Felder Date: Fri, 3 May 2024 15:02:25 +0100 Subject: [PATCH 2/2] Apply @K-Meech's suggestions from code review Co-authored-by: Kimberly Meechan <24316371+K-Meech@users.noreply.github.com> --- brainglobe_workflows/cellfinder_core/cellfinder_core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/brainglobe_workflows/cellfinder_core/cellfinder_core.py b/brainglobe_workflows/cellfinder_core/cellfinder_core.py index 55d4c483..7256b43a 100644 --- a/brainglobe_workflows/cellfinder_core/cellfinder_core.py +++ b/brainglobe_workflows/cellfinder_core/cellfinder_core.py @@ -356,8 +356,8 @@ def run_workflow_from_cellfinder_run(cfg: CellfinderConfig): The steps are: 1. Read the input signal and background data as two separate - Dask (or memory if single file stack) arrays. - 2. Run the main cellfinder pipeline on the input Dask arrays, + Dask arrays (or in-memory numpy arrays if single file tiff stack). + 2. Run the main cellfinder pipeline on the input arrays, with the parameters defined in the input configuration (cfg). 3. Save the detected cells as an xml file to the location specified in the input configuration (cfg). @@ -368,7 +368,7 @@ def run_workflow_from_cellfinder_run(cfg: CellfinderConfig): a class with the required setup methods and parameters for the cellfinder workflow """ - # Read input data as Dask arrays + # Read input data as Dask or numpy arrays signal_array = read_z_stack(str(cfg._signal_dir_path)) background_array = read_z_stack(str(cfg._background_dir_path))