From c97b681fb0a8d339af0198b62f63b3d7f951af36 Mon Sep 17 00:00:00 2001 From: alessandrofelder Date: Fri, 15 Sep 2023 16:41:36 +0100 Subject: [PATCH] scripts -> workflows --- README.md | 2 +- .../__init__.py | 0 brainglobe_workflows/registration_script.py | 54 +++++++++++++++++++ pyproject.toml | 4 +- 4 files changed, 57 insertions(+), 3 deletions(-) rename {brainglobe_scripts => brainglobe_workflows}/__init__.py (100%) create mode 100644 brainglobe_workflows/registration_script.py diff --git a/README.md b/README.md index 48477139..e3bf3ae6 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# brainglobe-scripts +# brainglobe-workflows diff --git a/brainglobe_scripts/__init__.py b/brainglobe_workflows/__init__.py similarity index 100% rename from brainglobe_scripts/__init__.py rename to brainglobe_workflows/__init__.py diff --git a/brainglobe_workflows/registration_script.py b/brainglobe_workflows/registration_script.py new file mode 100644 index 00000000..a60b10cb --- /dev/null +++ b/brainglobe_workflows/registration_script.py @@ -0,0 +1,54 @@ +import os +from pathlib import Path +import subprocess +import json +from typing import Dict, Union + +Pathlike = Union[str, bytes, os.PathLike] +# TODO: use pydantic or attrs, and/or a dataclass, for this?? +def _default_config(): + defaults = { + "sample_data_path" + } + +def _validate_config(config_dict: Dict[str]): + expected_keys = [ + "sample_data_path", + "output_path", + "voxel size", + "orientation" + "atlas" + ] + expected_types = [ + Pathlike, + ] + for key, type in zip(expected_keys, expected_types): + assert key in config_dict.keys() + + +def example_workflow(): + input_config_path = Path(os.environ("BRAINGLOBE_REGISTRATION_CONFIG_PATH")) + if input_config_path.exists(): + config = json.loads(input_config_path) + else: + config = _default_config() + input_data = read_from_config(config) + preprocessed_data = process(input_data) # if required + results = run_main_tool(prepocessed_data) + save(results) + +if __name__ == "__main__": + example_workflow() + +""" +To run brainreg, you need to pass: + * The path to the sample data + * The path to the directory to save the results + * The voxel sizes + * The orientation + * The atlas to use + +We put this all together in a single command: + +brainreg test_brain brainreg_output -v 50 40 40 --orientation psl --atlas allen_mouse_50um +""" diff --git a/pyproject.toml b/pyproject.toml index f55d6f89..ec5c3257 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] -name = "brainglobe-scripts" +name = "brainglobe-workflows" authors = [{name = "BrainGlobe developers", email= "a.felder@ucl.ac.uk"}] -description = "A place to keep scripts to use as benchmarks, end-to-end tests and for tutorials" +description = "A place to keep scripts to use as benchmarks, user-examples end-to-end tests and for tutorials" readme = "README.md" requires-python = ">=3.8.0" dynamic = ["version"]