├── .github ├── PULL_REQUEST_TEMPLATE.md ├── bug_report.md ├── feature_request.md └── workflows │ ├── build-main.yml │ └── test-and-lint.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.md ├── docs ├── Makefile ├── conf.py ├── contributing.rst ├── index.rst ├── installation.rst └── make.bat ├── leonardo_toolset ├── __init__.py ├── bin │ ├── __init__.py │ └── leonardo_workflow.py ├── tests │ ├── __init__.py │ ├── data │ │ └── example_values.json │ └── test_function.py └── workflows.py ├── setup.cfg ├── setup.py └── tox.ini /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Pull request recommendations:** 2 | - [ ] Name your pull request _your-development-type/short-description_. Ex: _feature/read-tiff-files_ 3 | - [ ] Link to any relevant issue in the PR description. Ex: _Resolves [gh-12], adds tiff file format support_ 4 | - [ ] Provide context of changes. 5 | - [ ] Provide relevant tests for your feature or bug fix. 6 | - [ ] Provide or update documentation for any feature added by your pull request. 7 | 8 | Thanks for contributing! 9 | -------------------------------------------------------------------------------- /.github/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: '"Something''s wrong..."' 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Description 11 | *A clear description of the bug* 12 | 13 | 14 | 15 | 16 | ## Expected Behavior 17 | *What did you expect to happen instead?* 18 | 19 | 20 | 21 | 22 | ## Reproduction 23 | *A minimal example that exhibits the behavior.* 24 | 25 | 26 | 27 | 28 | ## Environment 29 | *Any additional information about your environment* 30 | -------------------------------------------------------------------------------- /.github/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: '"It would be really cool if x did y..."' 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Use Case 11 | *Please provide a use case to help us understand your request in context* 12 | 13 | 14 | 15 | 16 | ## Solution 17 | *Please describe your ideal solution* 18 | 19 | 20 | 21 | 22 | ## Alternatives 23 | *Please describe any alternatives you've considered, even if you've dismissed them* 24 | -------------------------------------------------------------------------------- /.github/workflows/build-main.yml: -------------------------------------------------------------------------------- 1 | name: Build Main 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | schedule: 8 | # 9 | # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07 10 | # Run every Monday at 18:00:00 UTC (Monday at 10:00:00 PST) 11 | - cron: '0 18 * * 1' 12 | 13 | jobs: 14 | test: 15 | runs-on: ${{ matrix.os }} 16 | strategy: 17 | matrix: 18 | python-version: [3.9, '3.10', 3.11] 19 | os: [ubuntu-latest, windows-latest] 20 | 21 | steps: 22 | - uses: actions/checkout@v4 23 | - name: Set up Python ${{ matrix.python-version }} 24 | uses: actions/setup-python@v5 25 | with: 26 | python-version: ${{ matrix.python-version }} 27 | - name: Install Dependencies 28 | run: | 29 | python -m pip install --upgrade pip 30 | pip install .[test] 31 | - name: Test with pytest 32 | run: | 33 | pytest --cov-report xml --cov=leonardo_toolset leonardo_toolset/tests/ 34 | - name: Upload codecov 35 | uses: codecov/codecov-action@v1 36 | 37 | lint: 38 | runs-on: ubuntu-latest 39 | 40 | steps: 41 | - uses: actions/checkout@v4 42 | - name: Set up Python 43 | uses: actions/setup-python@v5 44 | with: 45 | python-version: 3.9 46 | - name: Install Dependencies 47 | run: | 48 | python -m pip install --upgrade pip 49 | pip install .[test] 50 | - name: Lint with flake8 51 | run: | 52 | flake8 leonardo_toolset --count --verbose --show-source --statistics 53 | - name: Check with black 54 | run: | 55 | black --check leonardo_toolset 56 | 57 | publish: 58 | if: "contains(github.event.head_commit.message, 'Bump version')" 59 | needs: [test, lint] 60 | runs-on: ubuntu-latest 61 | 62 | steps: 63 | - uses: actions/checkout@v4 64 | - name: Set up Python 65 | uses: actions/setup-python@v5 66 | with: 67 | python-version: 3.9 68 | - name: Install Dependencies 69 | run: | 70 | python -m pip install --upgrade pip 71 | pip install setuptools wheel 72 | - name: Build Package 73 | run: | 74 | python setup.py sdist bdist_wheel 75 | - name: Publish to PyPI 76 | uses: pypa/gh-action-pypi-publish@master 77 | with: 78 | user: __token__ 79 | password: ${{ secrets.PYPI_TOKEN }} 80 | -------------------------------------------------------------------------------- /.github/workflows/test-and-lint.yml: -------------------------------------------------------------------------------- 1 | name: Test and Lint 2 | 3 | on: pull_request 4 | 5 | jobs: 6 | test: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | matrix: 10 | python-version: [3.9, '3.10', 3.11] 11 | os: [ubuntu-latest, windows-latest] 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Set up Python ${{ matrix.python-version }} 16 | uses: actions/setup-python@v5 17 | with: 18 | python-version: ${{ matrix.python-version }} 19 | - name: Install Dependencies 20 | run: | 21 | python -m pip install --upgrade pip 22 | pip install .[test] 23 | - name: Test with pytest 24 | run: | 25 | pytest leonardo_toolset/tests/ 26 | - name: Upload codecov 27 | uses: codecov/codecov-action@v1 28 | 29 | lint: 30 | runs-on: ubuntu-latest 31 | 32 | steps: 33 | - uses: actions/checkout@v4 34 | - name: Set up Python 35 | uses: actions/setup-python@v5 36 | with: 37 | python-version: 3.9 38 | - name: Install Dependencies 39 | run: | 40 | python -m pip install --upgrade pip 41 | pip install .[test] 42 | - name: Lint with flake8 43 | run: | 44 | flake8 leonardo_toolset --count --verbose --show-source --statistics 45 | - name: Check with black 46 | run: | 47 | black --check leonardo_toolset 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # OS generated files 29 | .DS_Store 30 | 31 | # PyInstaller 32 | # Usually these files are written by a python script from a template 33 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 34 | *.manifest 35 | *.spec 36 | 37 | # Installer logs 38 | pip-log.txt 39 | pip-delete-this-directory.txt 40 | 41 | # Unit test / coverage reports 42 | htmlcov/ 43 | .tox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | docs/leonardo_toolset.*rst 71 | 72 | # PyBuilder 73 | target/ 74 | 75 | # Jupyter Notebook 76 | .ipynb_checkpoints 77 | 78 | # pyenv 79 | .python-version 80 | 81 | # celery beat schedule file 82 | celerybeat-schedule 83 | 84 | # Dask 85 | dask-worker-space 86 | 87 | # SageMath parsed files 88 | *.sage.py 89 | 90 | # dotenv 91 | .env 92 | 93 | # virtualenv 94 | .venv 95 | venv/ 96 | ENV/ 97 | 98 | # Spyder project settings 99 | .spyderproject 100 | .spyproject 101 | 102 | # Rope project settings 103 | .ropeproject 104 | 105 | # mkdocs documentation 106 | /site 107 | 108 | # mypy 109 | .mypy_cache/ 110 | 111 | # VSCode 112 | .vscode -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting any of the maintainers of this project and 59 | we will attempt to resolve the issues with respect and dignity. 60 | 61 | Project maintainers who do not follow or enforce the Code of Conduct in good 62 | faith may face temporary or permanent repercussions as determined by other 63 | members of the project's leadership. 64 | 65 | ## Attribution 66 | 67 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 68 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 69 | 70 | [homepage]: https://www.contributor-covenant.org 71 | 72 | For answers to common questions about this code of conduct, see 73 | https://www.contributor-covenant.org/faq 74 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are welcome, and they are greatly appreciated! Every little bit 4 | helps, and credit will always be given. 5 | 6 | ## Get Started! 7 | 8 | Ready to contribute? Here's how to set up `leonard_toolset` for local development. 9 | 10 | 1. Fork the `leonardo_toolset` repo on GitHub. 11 | 12 | 2. Clone your fork locally: 13 | 14 | ```bash 15 | git clone git@github.com:{your_name_here}/leonardo_toolset.git 16 | ``` 17 | 18 | 3. Install the project in editable mode. (It is also recommended to work in a virtualenv or anaconda environment): 19 | 20 | ```bash 21 | cd leonardo_toolset/ 22 | pip install -e .[dev] 23 | ``` 24 | 25 | 4. Create a branch for local development: 26 | 27 | ```bash 28 | git checkout -b {your_development_type}/short-description 29 | ``` 30 | 31 | Ex: feature/read-tiff-files or bugfix/handle-file-not-found
32 | Now you can make your changes locally. 33 | 34 | 5. When you're done making changes, check that your changes pass linting and 35 | tests, including testing other Python versions with make: 36 | 37 | ```bash 38 | make build 39 | ``` 40 | 41 | 6. Commit your changes and push your branch to GitHub: 42 | 43 | ```bash 44 | git add . 45 | git commit -m "Resolves gh-###. Your detailed description of your changes." 46 | git push origin {your_development_type}/short-description 47 | ``` 48 | 49 | 7. Submit a pull request through the GitHub website. 50 | 51 | ## Deploying 52 | 53 | A reminder for the maintainers on how to deploy. 54 | Make sure all your changes are committed. 55 | Then run: 56 | 57 | ```bash 58 | bump2version patch # possible: major / minor / patch 59 | git push 60 | git push --tags 61 | ``` 62 | 63 | This will release a new package version on Git + GitHub and publish to PyPI. 64 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 peng-lab 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include CONTRIBUTING.md 2 | include LICENSE 3 | include README.md 4 | 5 | recursive-include tests * 6 | recursive-exclude * __pycache__ 7 | recursive-exclude * *.py[co] 8 | 9 | recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif 10 | graft leonardo_toolset/data 11 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean build docs help 2 | .DEFAULT_GOAL := help 3 | 4 | define BROWSER_PYSCRIPT 5 | import os, webbrowser, sys 6 | 7 | try: 8 | from urllib import pathname2url 9 | except: 10 | from urllib.request import pathname2url 11 | 12 | webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) 13 | endef 14 | export BROWSER_PYSCRIPT 15 | 16 | define PRINT_HELP_PYSCRIPT 17 | import re, sys 18 | 19 | for line in sys.stdin: 20 | match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) 21 | if match: 22 | target, help = match.groups() 23 | print("%-20s %s" % (target, help)) 24 | endef 25 | export PRINT_HELP_PYSCRIPT 26 | 27 | BROWSER := python -c "$$BROWSER_PYSCRIPT" 28 | 29 | help: 30 | @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) 31 | 32 | clean: ## clean all build, python, and testing files 33 | rm -fr build/ 34 | rm -fr dist/ 35 | rm -fr .eggs/ 36 | find . -name '*.egg-info' -exec rm -fr {} + 37 | find . -name '*.egg' -exec rm -f {} + 38 | find . -name '*.pyc' -exec rm -f {} + 39 | find . -name '*.pyo' -exec rm -f {} + 40 | find . -name '*~' -exec rm -f {} + 41 | find . -name '__pycache__' -exec rm -fr {} + 42 | rm -fr .tox/ 43 | rm -fr .coverage 44 | rm -fr coverage.xml 45 | rm -fr htmlcov/ 46 | rm -fr .pytest_cache 47 | 48 | build: ## run tox / run tests and lint 49 | tox 50 | 51 | gen-docs: ## generate Sphinx HTML documentation, including API docs 52 | rm -f docs/leonardo_toolset*.rst 53 | rm -f docs/modules.rst 54 | sphinx-apidoc -o docs/ leonardo_toolset **/tests/ 55 | $(MAKE) -C docs html 56 | 57 | docs: ## generate Sphinx HTML documentation, including API docs, and serve to browser 58 | make gen-docs 59 | $(BROWSER) docs/_build/html/index.html 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Leonardo: a toolset to remove sample-induced aberrations in light sheet microscopy images 2 | 3 | [![Build Status](https://github.com/peng-lab/leonardo_toolset/workflows/Build%20Main/badge.svg)](https://github.com/peng-lab/leonardo_toolset/actions) 4 | --- 5 | 6 | *Leonardo* is a toolbox able to resolve all sample-induced aberrations in selective plane illumination microscopy (SPIM, also called light-sheet fluorescence microscopy, LSFM) by using two major modules: (1) **DeStripe** removes the stripe artifacts caused by light absorption; (2) **FUSE** reconstructs one single high-quality image from dual-sided illumination and/or dual-sided detection while eliminating optical distortions (ghosts) caused by light refraction. 7 | 8 | ## Documentation and Tutorials: 9 | 10 | https://leonardo-lsfm.readthedocs.io/en/latest/installation.html 11 | 12 | ## Installation 13 | 14 | **Stable Release:** `pip install leonardo_toolset`
15 | **Development Head:** `pip install git+https://github.com/peng-lab/leonardo_toolset.git` 16 | 17 | **Full software including napari plugins:** `pip install leonardo_toolset[napari]`
18 | 19 | This **leonardo_toolset** package contains everything you need for using the toolset, including batch processing support for different workflows, such as running destriping then fusion. If you need only one specific component, you can find more info below: 20 | 21 |
22 | More details about the leonardo_toolset package 23 | 24 | ## packages for core componets: 25 | 26 | * Leonardo-DeStripe: https://github.com/peng-lab/lsfm_destripe 27 | * Leonardo-FUSE: https://github.com/peng-lab/lsfm_fuse 28 | 29 | ## packages for napari plugins: 30 | 31 | * plugin for Leonardo-DeStripe: https://github.com/peng-lab/lsfm_destripe_napari 32 | * plugin for Leonardo-FUSE: https://github.com/peng-lab/lsfm_fusion_napari 33 | 34 |
35 | 36 | 37 | ## Development 38 | 39 | See [CONTRIBUTING.md](CONTRIBUTING.md) for information related to developing the code. 40 | 41 | **MIT license** 42 | 43 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = python -msphinx 7 | SPHINXPROJ = leonardo_toolset 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # leonardo_toolset documentation build configuration file, created by 5 | # sphinx-quickstart on Fri Jun 9 13:47:02 2017. 6 | # 7 | # This file is execfile()d with the current directory set to its 8 | # containing dir. 9 | # 10 | # Note that not all possible configuration values are present in this 11 | # autogenerated file. 12 | # 13 | # All configuration values have a default; values that are commented out 14 | # serve to show the default. 15 | 16 | # If extensions (or modules to document with autodoc) are in another 17 | # directory, add these directories to sys.path here. If the directory is 18 | # relative to the documentation root, use os.path.abspath to make it 19 | # absolute, like shown here. 20 | # 21 | import os 22 | import sys 23 | 24 | import sphinx_rtd_theme 25 | 26 | import leonardo_toolset 27 | 28 | sys.path.insert(0, os.path.abspath("..")) 29 | 30 | 31 | # -- General configuration --------------------------------------------- 32 | 33 | # If your documentation needs a minimal Sphinx version, state it here. 34 | # 35 | # needs_sphinx = "1.0" 36 | 37 | # Add any Sphinx extension module names here, as strings. They can be 38 | # extensions coming with Sphinx (named "sphinx.ext.*") or your custom ones. 39 | extensions = [ 40 | "sphinx.ext.autodoc", 41 | "sphinx.ext.viewcode", 42 | "sphinx.ext.napoleon", 43 | "sphinx.ext.mathjax", 44 | "m2r2", 45 | ] 46 | 47 | # Control napoleon 48 | napoleon_google_docstring = False 49 | napolean_include_init_with_doc = True 50 | napoleon_use_ivar = True 51 | napoleon_use_param = False 52 | 53 | # Control autodoc 54 | autoclass_content = "both" # include init doc with class 55 | 56 | # Add any paths that contain templates here, relative to this directory. 57 | templates_path = ["_templates"] 58 | 59 | # The suffix(es) of source filenames. 60 | # You can specify multiple suffix as a list of string: 61 | # 62 | source_suffix = { 63 | ".rst": "restructuredtext", 64 | ".txt": "markdown", 65 | ".md": "markdown", 66 | } 67 | 68 | # The master toctree document. 69 | master_doc = "index" 70 | 71 | # General information about the project. 72 | project = u"leonardo_toolset" 73 | copyright = u'2024, Yu Liu' 74 | author = u"Yu Liu" 75 | 76 | # The version info for the project you"re documenting, acts as replacement 77 | # for |version| and |release|, also used in various other places throughout 78 | # the built documents. 79 | # 80 | # The short X.Y version. 81 | version = leonardo_toolset.__version__ 82 | # The full version, including alpha/beta/rc tags. 83 | release = leonardo_toolset.__version__ 84 | 85 | # The language for content autogenerated by Sphinx. Refer to documentation 86 | # for a list of supported languages. 87 | # 88 | # This is also used if you do content translation via gettext catalogs. 89 | # Usually you set "language" from the command line for these cases. 90 | language = None 91 | 92 | # List of patterns, relative to source directory, that match files and 93 | # directories to ignore when looking for source files. 94 | # This patterns also effect to html_static_path and html_extra_path 95 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] 96 | 97 | # The name of the Pygments (syntax highlighting) style to use. 98 | pygments_style = "sphinx" 99 | 100 | # If true, `todo` and `todoList` produce output, else they produce nothing. 101 | todo_include_todos = False 102 | 103 | 104 | # -- Options for HTML output ------------------------------------------- 105 | 106 | # The theme to use for HTML and HTML Help pages. See the documentation for 107 | # a list of builtin themes. 108 | # 109 | html_theme = "sphinx_rtd_theme" 110 | 111 | # Theme options are theme-specific and customize the look and feel of a 112 | # theme further. For a list of options available for each theme, see the 113 | # documentation. 114 | # 115 | html_theme_options = { 116 | "collapse_navigation": False, 117 | "prev_next_buttons_location": "top", 118 | } 119 | 120 | # Add any paths that contain custom static files (such as style sheets) here, 121 | # relative to this directory. They are copied after the builtin static files, 122 | # so a file named "default.css" will overwrite the builtin "default.css". 123 | html_static_path = ["_static"] 124 | 125 | 126 | # -- Options for HTMLHelp output --------------------------------------- 127 | 128 | # Output file base name for HTML help builder. 129 | htmlhelp_basename = "leonardo_toolsetdoc" 130 | 131 | 132 | # -- Options for LaTeX output ------------------------------------------ 133 | 134 | latex_elements = { 135 | # The paper size ("letterpaper" or "a4paper"). 136 | # 137 | # "papersize": "letterpaper", 138 | 139 | # The font size ("10pt", "11pt" or "12pt"). 140 | # 141 | # "pointsize": "10pt", 142 | 143 | # Additional stuff for the LaTeX preamble. 144 | # 145 | # "preamble": "", 146 | 147 | # Latex figure (float) alignment 148 | # 149 | # "figure_align": "htbp", 150 | } 151 | 152 | # Grouping the document tree into LaTeX files. List of tuples 153 | # (source start file, target name, title, author, documentclass 154 | # [howto, manual, or own class]). 155 | latex_documents = [ 156 | (master_doc, "leonardo_toolset.tex", 157 | u"leonardo_toolset Documentation", 158 | u"Yu Liu", "manual"), 159 | ] 160 | 161 | 162 | # -- Options for manual page output ------------------------------------ 163 | 164 | # One entry per manual page. List of tuples 165 | # (source start file, name, description, authors, manual section). 166 | man_pages = [ 167 | (master_doc, "leonardo_toolset", 168 | u"leonardo_toolset Documentation", 169 | [author], 1) 170 | ] 171 | 172 | 173 | # -- Options for Texinfo output ---------------------------------------- 174 | 175 | # Grouping the document tree into Texinfo files. List of tuples 176 | # (source start file, target name, title, author, 177 | # dir menu entry, description, category) 178 | texinfo_documents = [ 179 | (master_doc, "leonardo_toolset", 180 | u"leonardo_toolset Documentation", 181 | author, 182 | "leonardo_toolset", 183 | "One line description of project.", 184 | "Miscellaneous"), 185 | ] 186 | -------------------------------------------------------------------------------- /docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. mdinclude:: ../CONTRIBUTING.md 2 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to leonardo_toolset's documentation! 2 | ====================================== 3 | 4 | .. toctree:: 5 | :hidden: 6 | :maxdepth: 1 7 | :caption: Contents: 8 | 9 | Overview 10 | installation 11 | Package modules 12 | contributing 13 | math 14 | 15 | .. mdinclude:: ../README.md 16 | 17 | Indices and tables 18 | ================== 19 | * :ref:`genindex` 20 | * :ref:`modindex` 21 | * :ref:`search` 22 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Installation 5 | ============ 6 | 7 | 8 | Stable release 9 | -------------- 10 | 11 | To install leonardo_toolset, run this command in your terminal: 12 | 13 | .. code-block:: console 14 | 15 | $ pip install leonardo_toolset 16 | 17 | This is the preferred method to install Leonardo_toolset, as it will always install the most recent stable release. 18 | 19 | If you don't have `pip`_ installed, this `Python installation guide`_ can guide 20 | you through the process. 21 | 22 | .. _pip: https://pip.pypa.io 23 | .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ 24 | 25 | 26 | From sources 27 | ------------ 28 | 29 | The sources for leonardo_toolset can be downloaded from the `Github repo`_. 30 | 31 | You can either clone the public repository: 32 | 33 | .. code-block:: console 34 | 35 | $ git clone git://github.com/peng-lab/leonardo_toolset 36 | 37 | Or download the `tarball`_: 38 | 39 | .. code-block:: console 40 | 41 | $ curl -OL https://github.com/peng-lab/leonardo_toolset/tarball/main 42 | 43 | Once you have a copy of the source, you can install it with: 44 | 45 | .. code-block:: console 46 | 47 | $ python setup.py install 48 | 49 | 50 | .. _Github repo: https://github.com/peng-lab/leonardo_toolset 51 | .. _tarball: https://github.com/peng-lab/leonardo_toolset/tarball/main 52 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=python -msphinx 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | set SPHINXPROJ=leonardo_toolset 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The Sphinx module was not found. Make sure you have Sphinx installed, 20 | echo.then set the SPHINXBUILD environment variable to point to the full 21 | echo.path of the 'sphinx-build' executable. Alternatively you may add the 22 | echo.Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /leonardo_toolset/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """Top-level package for leonardo_toolset.""" 4 | 5 | __author__ = "Yu Liu" 6 | __email__ = "liuyu9671@gmail.com" 7 | # Do not edit this string manually, always use bumpversion 8 | # Details in CONTRIBUTING.md 9 | __version__ = "0.1.1" 10 | 11 | 12 | def get_module_version(): 13 | return __version__ 14 | 15 | 16 | from .workflows import workflow_wrapper # noqa: F401 17 | from lsfm_destripe import DeStripe # noqa: F401 18 | from lsfm_fuse import FUSE_illu # noqa: F401 19 | from lsfm_fuse import FUSE_det # noqa: F401 20 | -------------------------------------------------------------------------------- /leonardo_toolset/bin/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """Bin scripts package for leonardo_toolset.""" 4 | -------------------------------------------------------------------------------- /leonardo_toolset/bin/leonardo_workflow.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | This sample script will get deployed in the bin directory of the 6 | users' virtualenv when the parent module is installed using pip. 7 | """ 8 | 9 | import argparse 10 | import logging 11 | import sys 12 | import traceback 13 | 14 | from leonardo_toolset import workflow_wrapper, get_module_version 15 | 16 | ############################################################################### 17 | 18 | log = logging.getLogger() 19 | logging.basicConfig( 20 | level=logging.INFO, format="[%(levelname)4s:%(lineno)4s %(asctime)s] %(message)s" 21 | ) 22 | 23 | ############################################################################### 24 | 25 | 26 | class Args(argparse.Namespace): 27 | 28 | def __init__(self): 29 | # Arguments that could be passed in through the command line 30 | self.debug = False 31 | self.__parse() 32 | 33 | def __parse(self): 34 | p = argparse.ArgumentParser( 35 | prog="run_leonardo_workflows", 36 | description="batch running for leonardo workflows", 37 | ) 38 | 39 | p.add_argument( 40 | "-v", 41 | "--version", 42 | action="version", 43 | version="%(prog)s " + get_module_version(), 44 | ) 45 | p.add_argument( 46 | "--input", 47 | dest="input_dir", 48 | required=True, 49 | help="path to the input folder", 50 | ) 51 | p.add_argument( 52 | "--output", 53 | dest="output_dir", 54 | required=True, 55 | help="path to save the results", 56 | ) 57 | p.add_argument( 58 | "--workflow", 59 | dest="workflow_type", 60 | default="destripe_fuse", 61 | help=( 62 | "select the type of workflow: destripe_fuse (default), " 63 | "destripe_only, fuse_only" 64 | ), 65 | ) 66 | p.add_argument( 67 | "--debug", 68 | action="store_true", 69 | dest="debug", 70 | help=argparse.SUPPRESS, 71 | ) 72 | p.parse_args(namespace=self) 73 | 74 | 75 | ############################################################################### 76 | 77 | 78 | def main(): 79 | try: 80 | args = Args() 81 | dbg = args.debug 82 | 83 | exe = workflow_wrapper(args.workflow_type, args.input_dir, args.output_dir) 84 | exe.process() 85 | 86 | except Exception as e: 87 | log.error("=============================================") 88 | if dbg: 89 | log.error("\n\n" + traceback.format_exc()) 90 | log.error("=============================================") 91 | log.error("\n\n" + str(e) + "\n") 92 | log.error("=============================================") 93 | sys.exit(1) 94 | 95 | 96 | ############################################################################### 97 | # Allow caller to directly run this module (usually in development scenarios) 98 | 99 | if __name__ == "__main__": 100 | main() 101 | -------------------------------------------------------------------------------- /leonardo_toolset/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """Unit test package for leonardo_toolset.""" 4 | -------------------------------------------------------------------------------- /leonardo_toolset/tests/data/example_values.json: -------------------------------------------------------------------------------- 1 | { 2 | "start_val": 1, 3 | "next_val": 2 4 | } 5 | -------------------------------------------------------------------------------- /leonardo_toolset/tests/test_function.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | A simple example of a test file using a function. 6 | NOTE: All test file names must have one of the two forms. 7 | - `test_.py` 8 | - '_test.py' 9 | 10 | Docs: https://docs.pytest.org/en/latest/ 11 | https://docs.pytest.org/en/latest/goodpractices.html#conventions-for-python-test-discovery 12 | """ 13 | 14 | 15 | # If you only have a single condition you need to test, a single test is _okay_ 16 | # but parametrized tests are encouraged 17 | def test_dummy(): 18 | a = 1 19 | b = 1 20 | assert a == b 21 | -------------------------------------------------------------------------------- /leonardo_toolset/workflows.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # Standard library 5 | import logging 6 | 7 | # Third party 8 | 9 | # Relative 10 | 11 | ############################################################################### 12 | 13 | log = logging.getLogger(__name__) 14 | 15 | ############################################################################### 16 | 17 | 18 | class workflow_wrapper(object): 19 | """ 20 | The wrapper for different workflows 21 | 22 | Parameters 23 | ---------- 24 | workflow_type: str 25 | the type of workflow to execute 26 | input_dir: str or Path 27 | input path 28 | output_dir: str or Path 29 | output path 30 | """ 31 | 32 | def __init__(self, workflow_type, input_dir, output_dir): 33 | # TODO: currently, it is a placeholder 34 | print(workflow_type) 35 | print(input_dir) 36 | print(output_dir) 37 | 38 | def process(self): 39 | # TODO: currently, it is a placeholder 40 | if self.workflow_type == "destripe_fuse": 41 | print(self.input_dir) 42 | print(self.output_dir) 43 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.1.1 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:setup.py] 7 | search = version="{current_version}" 8 | replace = version="{new_version}" 9 | 10 | [bumpversion:file:leonardo_toolset/__init__.py] 11 | search = {current_version} 12 | replace = {new_version} 13 | 14 | [bdist_wheel] 15 | universal = 1 16 | 17 | [aliases] 18 | test = pytest 19 | 20 | [tool:pytest] 21 | collect_ignore = ['setup.py'] 22 | 23 | [flake8] 24 | exclude = 25 | docs/ 26 | ignore = 27 | E203 28 | E402 29 | W291 30 | W503 31 | max-line-length = 88 32 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """The setup script.""" 5 | 6 | from setuptools import find_packages, setup 7 | 8 | with open("README.md") as readme_file: 9 | readme = readme_file.read() 10 | 11 | setup_requirements = [ 12 | "pytest-runner>=5.2", 13 | ] 14 | 15 | test_requirements = [ 16 | "black>=19.10b0", 17 | "codecov>=2.1.4", 18 | "flake8>=3.8.3", 19 | "flake8-debugger>=3.2.1", 20 | "pytest>=5.4.3", 21 | "pytest-cov>=2.9.0", 22 | "pytest-raises>=0.11", 23 | ] 24 | 25 | dev_requirements = [ 26 | *setup_requirements, 27 | *test_requirements, 28 | "bump2version>=1.0.1", 29 | "coverage>=5.1", 30 | "ipython>=7.15.0", 31 | "m2r2>=0.2.7", 32 | "pytest-runner>=5.2", 33 | "Sphinx>=3.4.3", 34 | "sphinx_rtd_theme>=0.5.1", 35 | "tox>=3.15.2", 36 | "twine>=3.1.1", 37 | "wheel>=0.34.2", 38 | ] 39 | 40 | requirements = [ 41 | "lsfm-destripe", 42 | "lsfm-fuse", 43 | "numpy<2.0" 44 | ] 45 | 46 | napari_requirements = [ 47 | "lsfm-destripe-napari", 48 | "lsfm-fusion-napari", 49 | "napari[all]" 50 | ] 51 | 52 | extra_requirements = { 53 | "setup": setup_requirements, 54 | "test": test_requirements, 55 | "dev": dev_requirements, 56 | "napari": napari_requirements, 57 | "all": [ 58 | *requirements, 59 | *dev_requirements, 60 | ] 61 | } 62 | 63 | setup( 64 | author="Yu Liu", 65 | author_email="liuyu9671@gmail.com", 66 | classifiers=[ 67 | "Development Status :: 2 - Pre-Alpha", 68 | "Intended Audience :: Developers", 69 | "License :: OSI Approved :: MIT License", 70 | "Natural Language :: English", 71 | "Programming Language :: Python :: 3.9", 72 | "Programming Language :: Python :: 3.10", 73 | "Programming Language :: Python :: 3.11", 74 | ], 75 | description="Leonardo: an LSFM image processing toolset", 76 | entry_points={ 77 | "console_scripts": [ 78 | "run_leonardo=leonardo_toolset.bin.leonardo_workflow:main" 79 | ], 80 | }, 81 | install_requires=requirements, 82 | license="MIT license", 83 | long_description=readme, 84 | long_description_content_type="text/markdown", 85 | include_package_data=True, 86 | keywords="leonardo_toolset", 87 | name="leonardo_toolset", 88 | packages=find_packages(exclude=["tests", "*.tests", "*.tests.*"]), 89 | python_requires=">=3.9", 90 | setup_requires=setup_requirements, 91 | test_suite="leonardo_toolset/tests", 92 | tests_require=test_requirements, 93 | extras_require=extra_requirements, 94 | url="https://github.com/peng-lab/leonardo_toolset", 95 | # Do not edit this string manually, always use bumpversion 96 | # Details in CONTRIBUTING.rst 97 | version="0.1.1", 98 | zip_safe=False, 99 | ) 100 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | skipsdist = True 3 | envlist = py37, py38, py39, lint 4 | 5 | [testenv:lint] 6 | deps = 7 | .[test] 8 | commands = 9 | flake8 leonardo_toolset --count --verbose --show-source --statistics 10 | black --check leonardo_toolset 11 | 12 | [testenv] 13 | setenv = 14 | PYTHONPATH = {toxinidir} 15 | deps = 16 | .[test] 17 | commands = 18 | pytest --basetemp={envtmpdir} --cov-report html --cov=leonardo_toolset leonardo_toolset/tests/ 19 | --------------------------------------------------------------------------------