Skip to content

Commit

Permalink
Cellfinder config + path change (#64)
Browse files Browse the repository at this point in the history
* pass all parameters to cellfinder_run

* changed required, optional and internal fields. read_config passes. add method to config class (WIP)

* add signal and background data from local

* add missing data config fixtures

* mark GIN download data test as slow

* refactor config class methods and remove setup_workflow

* tests pass with default config

* remove unused fixtures

* update entry point

* change cellfinder-core to cellfinder in pyproject

* update cellfinder to cellfinder_core

* renaming cellfinder script workflow to cellfinder_core. fix entrypoint test.

* docstrings for class config

* fix entry point

* skip add input paths test

* feedback from code review
  • Loading branch information
sfmig authored Jan 10, 2024
1 parent 3656862 commit 017f005
Show file tree
Hide file tree
Showing 13 changed files with 623 additions and 973 deletions.
26 changes: 13 additions & 13 deletions benchmarks/cellfinder_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from cellfinder.core.main import main as cellfinder_run
from cellfinder.core.tools.IO import read_with_dask

from brainglobe_workflows.cellfinder_core.cellfinder import (
from brainglobe_workflows.cellfinder_core.cellfinder_core import (
CellfinderConfig,
run_workflow_from_cellfinder_run,
)
from brainglobe_workflows.cellfinder_core.cellfinder import (
from brainglobe_workflows.cellfinder_core.cellfinder_core import (
setup as setup_cellfinder_workflow,
)
from brainglobe_workflows.utils import DEFAULT_JSON_CONFIG_PATH_CELLFINDER
Expand Down Expand Up @@ -112,14 +112,14 @@ def setup_cache(
_ = pooch.retrieve(
url=config.data_url,
known_hash=config.data_hash,
path=config.install_path,
path=config._install_path,
progressbar=True,
processor=pooch.Unzip(extract_dir=config.data_dir_relative),
)

# Check paths to input data should now exist in config
assert Path(config.signal_dir_path).exists()
assert Path(config.background_dir_path).exists()
assert Path(config._signal_dir_path).exists()
assert Path(config._background_dir_path).exists()

def setup(self):
"""
Expand All @@ -146,7 +146,7 @@ def teardown(self):
The input data is kept for all repeats of the same benchmark,
to avoid repeated downloads from GIN.
"""
shutil.rmtree(Path(self.cfg.output_path).resolve())
shutil.rmtree(Path(self.cfg._output_path).resolve())


class TimeFullWorkflow(TimeBenchmarkPrepGIN):
Expand Down Expand Up @@ -177,10 +177,10 @@ class TimeReadInputDask(TimeBenchmarkPrepGIN):
"""

def time_read_signal_with_dask(self):
read_with_dask(self.cfg.signal_dir_path)
read_with_dask(self.cfg._signal_dir_path)

def time_read_background_with_dask(self):
read_with_dask(self.cfg.background_dir_path)
read_with_dask(self.cfg._background_dir_path)


class TimeDetectCells(TimeBenchmarkPrepGIN):
Expand All @@ -199,8 +199,8 @@ def setup(self):
TimeBenchmarkPrepGIN.setup(self)

# add input data as arrays to config
self.signal_array = read_with_dask(self.cfg.signal_dir_path)
self.background_array = read_with_dask(self.cfg.background_dir_path)
self.signal_array = read_with_dask(self.cfg._signal_dir_path)
self.background_array = read_with_dask(self.cfg._background_dir_path)

def time_cellfinder_run(self):
cellfinder_run(
Expand All @@ -215,13 +215,13 @@ def setup(self):
TimeBenchmarkPrepGIN.setup(self)

# add input data as arrays to config
self.signal_array = read_with_dask(self.cfg.signal_dir_path)
self.background_array = read_with_dask(self.cfg.background_dir_path)
self.signal_array = read_with_dask(self.cfg._signal_dir_path)
self.background_array = read_with_dask(self.cfg._background_dir_path)

# detect cells
self.detected_cells = cellfinder_run(
self.signal_array, self.background_array, self.cfg.voxel_sizes
)

def time_save_cells(self):
save_cells(self.detected_cells, self.cfg.detected_cells_path)
save_cells(self.detected_cells, self.cfg._detected_cells_path)
Loading

0 comments on commit 017f005

Please sign in to comment.