Skip to content

Commit

Permalink
rename json factory function
Browse files Browse the repository at this point in the history
  • Loading branch information
sfmig committed Oct 5, 2023
1 parent 654ff31 commit 3af3b8a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
33 changes: 26 additions & 7 deletions brainglobe_workflows/cellfinder/cellfinder_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,38 @@
CELLFINDER_CACHE_DIR = Path.home() / ".cellfinder_workflows"


def default_config_dict(CELLFINDER_CACHE_DIR):
def make_default_config_dict(cellfinder_cache_dir):
"""Generate a config dictionary with the required parameters
for the workflow
The input data is fetched from GIN and downloaded to
the location provided by cellfinder_cache_dir. The results are
also saved in a timestamped output subdirectory under cellfinder_cache_dir
Parameters
----------
cellfinder_cache_dir : _type_
_description_
Returns
-------
dict
dictionary with the required parameters for the workflow
"""
return {
"install_path": CELLFINDER_CACHE_DIR,
"install_path": cellfinder_cache_dir,
"data_url": "https://gin.g-node.org/BrainGlobe/test-data/raw/master/cellfinder/cellfinder-test-data.zip",
"data_hash": (
"b0ef53b1530e4fa3128fcc0a752d0751909eab129d701f384fc0ea5f138c5914"
),
"local_path": CELLFINDER_CACHE_DIR / "cellfinder_test_data",
"local_path": cellfinder_cache_dir / "cellfinder_test_data",
"signal_parent_dir": str(
CELLFINDER_CACHE_DIR / "cellfinder_test_data" / "signal"
cellfinder_cache_dir / "cellfinder_test_data" / "signal"
),
"background_parent_dir": str(
CELLFINDER_CACHE_DIR / "cellfinder_test_data" / "background"
cellfinder_cache_dir / "cellfinder_test_data" / "background"
),
"output_path_basename": CELLFINDER_CACHE_DIR / "cellfinder_output_",
"output_path_basename": cellfinder_cache_dir / "cellfinder_output_",
"detected_cells_filename": "detected_cells.xml",
"voxel_sizes": [5, 2, 2], # microns
"start_plane": 0,
Expand Down Expand Up @@ -203,7 +220,9 @@ def setup_workflow(cellfinder_cache_dir=CELLFINDER_CACHE_DIR):
)
# else use the default config, with the cellfinder cache directory provided
else:
config = CellfinderConfig(**default_config_dict(cellfinder_cache_dir))
config = CellfinderConfig(
**make_default_config_dict(cellfinder_cache_dir)
)
logger.info("Using default configuration")

# Retrieve and add lists of input data to config if neither are defined
Expand Down
4 changes: 2 additions & 2 deletions tests/test_integration/test_cellfinder_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest

from brainglobe_workflows.cellfinder.cellfinder_main import (
default_config_dict,
make_default_config_dict,
run_workflow_from_cellfinder_run,
setup_workflow,
)
Expand Down Expand Up @@ -42,7 +42,7 @@ def prep_json(obj):
# alter config if required by the test
# - missing signal directory
# - missing background directory
config_dict = default_config_dict(cellfinder_cache_dir)
config_dict = make_default_config_dict(cellfinder_cache_dir)

# dump config into json
with open(input_config_path, "w") as js:
Expand Down

0 comments on commit 3af3b8a

Please sign in to comment.