├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── build-docs.yml │ ├── build-main.yml │ ├── publish.yml │ ├── test-and-lint-manual-trigger.yml │ └── test-and-lint.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.md ├── aicssegmentation ├── __init__.py ├── assets │ ├── diagrams │ │ ├── actb.png │ │ ├── actn1.png │ │ ├── atp2a2.png │ │ ├── cetn2.png │ │ ├── ctnnb1.png │ │ ├── dsp.png │ │ ├── fbl.png │ │ ├── gja1.png │ │ ├── h2b_interphase.png │ │ ├── lamp1.png │ │ ├── lmnb1_interphase.png │ │ ├── lmnb1_mitotic.png │ │ ├── myh10.png │ │ ├── npm1.png │ │ ├── nup153.png │ │ ├── pxn.png │ │ ├── rab5a.png │ │ ├── sec61b.png │ │ ├── slc25a17.png │ │ ├── smc1a.png │ │ ├── son.png │ │ ├── st6gal1.png │ │ ├── tjp1.png │ │ ├── tomm20.png │ │ └── tuba1b.png │ └── thumbnails │ │ ├── actb_post.png │ │ ├── actb_pre.png │ │ ├── actn1_post.png │ │ ├── actn1_pre.png │ │ ├── atp2a2_post.png │ │ ├── atp2a2_pre.png │ │ ├── cetn2_post.png │ │ ├── cetn2_pre.png │ │ ├── ctnnb1_post.png │ │ ├── ctnnb1_pre.png │ │ ├── dsp_post.png │ │ ├── dsp_pre.png │ │ ├── fbl_post.png │ │ ├── fbl_pre.png │ │ ├── gja1_post.png │ │ ├── gja1_pre.png │ │ ├── h2b_interphase_post.png │ │ ├── h2b_interphase_pre.png │ │ ├── lamp1_post.png │ │ ├── lamp1_pre.png │ │ ├── lmnb1_interphase_post.png │ │ ├── lmnb1_interphase_pre.png │ │ ├── lmnb1_mitotic_post.png │ │ ├── lmnb1_mitotic_pre.png │ │ ├── myh10_post.png │ │ ├── myh10_pre.png │ │ ├── npm1_post.png │ │ ├── npm1_pre.png │ │ ├── nup153_post.png │ │ ├── nup153_pre.png │ │ ├── pxn_post.png │ │ ├── pxn_pre.png │ │ ├── rab5a_post.png │ │ ├── rab5a_pre.png │ │ ├── sec61b_post.png │ │ ├── sec61b_pre.png │ │ ├── slc25a17_post.png │ │ ├── slc25a17_pre.png │ │ ├── smc1a_post.png │ │ ├── smc1a_pre.png │ │ ├── son_post.png │ │ ├── son_pre.png │ │ ├── st6gal1_post.png │ │ ├── st6gal1_pre.png │ │ ├── tjp1_post.png │ │ ├── tjp1_pre.png │ │ ├── tomm20_post.png │ │ ├── tomm20_pre.png │ │ ├── tuba1b_post.png │ │ └── tuba1b_pre.png ├── bin │ ├── __init__.py │ └── batch_processing.py ├── cli │ ├── __init__.py │ └── to_analysis.py ├── core │ ├── MO_threshold.py │ ├── __init__.py │ ├── hessian.py │ ├── output_utils.py │ ├── pre_processing_utils.py │ ├── seg_dot.py │ ├── utils.py │ ├── vessel.py │ └── visual.py ├── exceptions.py ├── structure_wrapper │ ├── __init__.py │ ├── seg_PCNA_earlyS_midS.py │ ├── seg_PCNA_lateS.py │ ├── seg_PCNA_lateS_hole_fill.py │ ├── seg_actb.py │ ├── seg_actn1.py │ ├── seg_atp2a2.py │ ├── seg_cardio_actn2.py │ ├── seg_cardio_atp2a2.py │ ├── seg_cardio_fbl.py │ ├── seg_cardio_fbl_100x.py │ ├── seg_cardio_myl7.py │ ├── seg_cardio_npm1.py │ ├── seg_cardio_npm1_100x.py │ ├── seg_cardio_tnni1.py │ ├── seg_cardio_ttn.py │ ├── seg_cetn2.py │ ├── seg_ctnnb1.py │ ├── seg_drug_npm1.py │ ├── seg_dsp.py │ ├── seg_fbl.py │ ├── seg_fbl_labelfree_4dn.py │ ├── seg_gja1.py │ ├── seg_h2b_interphase.py │ ├── seg_lamp1.py │ ├── seg_lmnb1_interphase.py │ ├── seg_lmnb1_mitotic.py │ ├── seg_myh10.py │ ├── seg_npm1.py │ ├── seg_npm1_SR.py │ ├── seg_npm_labelfree_4dn.py │ ├── seg_nup153.py │ ├── seg_polr2a.py │ ├── seg_polr2a_blob.py │ ├── seg_pxn.py │ ├── seg_rab5a.py │ ├── seg_sec61b.py │ ├── seg_sec61b_dual.py │ ├── seg_slc25a17.py │ ├── seg_smc1a.py │ ├── seg_son.py │ ├── seg_st6gal1.py │ ├── seg_template.py │ ├── seg_terf2.py │ ├── seg_tjp1.py │ ├── seg_tomm20.py │ ├── seg_tuba1b.py │ ├── seg_ubtf.py │ └── structure_segmenter.py ├── structure_wrapper_config │ ├── __init__.py │ ├── all_functions.json │ ├── conf_actb.json │ ├── conf_actn1.json │ ├── conf_atp2a2.json │ ├── conf_cetn2.json │ ├── conf_ctnnb1.json │ ├── conf_dsp.json │ ├── conf_fbl.json │ ├── conf_gja1.json │ ├── conf_h2b_interphase.json │ ├── conf_lamp1.json │ ├── conf_lmnb1_interphase.json │ ├── conf_lmnb1_mitotic.json │ ├── conf_myh10.json │ ├── conf_npm1.json │ ├── conf_nup153.json │ ├── conf_pxn.json │ ├── conf_rab5a.json │ ├── conf_sec61b.json │ ├── conf_slc25a17.json │ ├── conf_smc1a.json │ ├── conf_son.json │ ├── conf_st6gal1.json │ ├── conf_tjp1.json │ ├── conf_tomm20.json │ ├── conf_tuba1b.json │ └── function_params.md ├── tests │ ├── __init__.py │ ├── conftest.py │ ├── resources │ │ └── images │ │ │ ├── expected_actb_struct_segmentation.tiff │ │ │ ├── expected_actn1_struct_segmentation.tiff │ │ │ ├── expected_atp2a2_struct_segmentation.tiff │ │ │ ├── expected_cardio_actn2_struct_segmentation.tiff │ │ │ ├── expected_cardio_atp2a2_struct_segmentation.tiff │ │ │ ├── expected_cardio_fbl_100x_struct_segmentation.tiff │ │ │ ├── expected_cardio_fbl_struct_segmentation.tiff │ │ │ ├── expected_cardio_myl7_struct_segmentation.tiff │ │ │ ├── expected_cardio_npm1_100x_struct_segmentation.tiff │ │ │ ├── expected_cardio_npm1_struct_segmentation.tiff │ │ │ ├── expected_cardio_tnni1_struct_segmentation.tiff │ │ │ ├── expected_cardio_ttn_struct_segmentation.tiff │ │ │ ├── expected_cetn2_struct_segmentation.tiff │ │ │ ├── expected_ctnnb1_struct_segmentation.tiff │ │ │ ├── expected_drug_npm1_struct_segmentation.tiff │ │ │ ├── expected_dsp_struct_segmentation.tiff │ │ │ ├── expected_fbl_labelfree_4dn_struct_segmentation.tiff │ │ │ ├── expected_fbl_struct_segmentation.tiff │ │ │ ├── expected_gja1_struct_segmentation.tiff │ │ │ ├── expected_h2b_interphase_struct_segmentation.tiff │ │ │ ├── expected_lamp1_struct_segmentation.tiff │ │ │ ├── expected_lmnb1_interphase_struct_segmentation.tiff │ │ │ ├── expected_lmnb1_mitotic_struct_segmentation.tiff │ │ │ ├── expected_myh10_struct_segmentation.tiff │ │ │ ├── expected_npm1_struct_segmentation.tiff │ │ │ ├── expected_npm_labelfree_4dn_struct_segmentation.tiff │ │ │ ├── expected_nup153_struct_segmentation.tiff │ │ │ ├── expected_pxn_struct_segmentation.tiff │ │ │ ├── expected_rab5a_struct_segmentation.tiff │ │ │ ├── expected_sec61b_dual_struct_segmentation.tiff │ │ │ ├── expected_sec61b_struct_segmentation.tiff │ │ │ ├── expected_slc25a17_struct_segmentation.tiff │ │ │ ├── expected_smc1a_struct_segmentation.tiff │ │ │ ├── expected_son_struct_segmentation.tiff │ │ │ ├── expected_st6gal1_struct_segmentation.tiff │ │ │ ├── expected_terf2_struct_segmentation.tiff │ │ │ ├── expected_tjp1_struct_segmentation.tiff │ │ │ ├── expected_tomm20_struct_segmentation.tiff │ │ │ ├── expected_tuba1b_struct_segmentation.tiff │ │ │ ├── expected_ubtf_struct_segmentation.tiff │ │ │ └── random_input.tiff │ ├── test_config.py │ ├── test_structures.py │ └── workflow │ │ ├── __init__.py │ │ ├── mock_module.py │ │ ├── resources │ │ └── test │ │ │ └── test.tiff │ │ ├── test_all_workflows.py │ │ ├── test_batch_workflow.py │ │ ├── test_workflow.py │ │ ├── test_workflow_config.py │ │ ├── test_workflow_definition.py │ │ ├── test_workflow_engine.py │ │ └── test_workflow_step.py ├── util │ ├── __init__.py │ ├── directories.py │ ├── filesystem.py │ └── lazy.py └── workflow │ ├── __init__.py │ ├── batch_workflow.py │ ├── segmenter_function.py │ ├── workflow.py │ ├── workflow_config.py │ ├── workflow_definition.py │ ├── workflow_engine.py │ └── workflow_step.py ├── demo_data ├── RAB5_demo_data.tif ├── TNNI1_demo_data.tif ├── TOM20_demo_data.tif ├── TOMM20_pipeline_example_cell_segmentation.tiff ├── TOMM20_pipeline_example_nucleus_segmentation.tiff └── TOMM20_pipeline_example_structure_segmentation.tiff ├── docs ├── Makefile ├── conda_why.md ├── conf.py ├── contributing.rst ├── doc.rst ├── full.jpg ├── full_doc.md ├── full_mem.jpg ├── full_str.jpg ├── index.rst ├── installation.rst ├── installation_linux.md ├── installation_mac.md ├── installation_windows.md ├── jupyter_lookup_table.md ├── make.bat ├── object_identification.md ├── rab5a_raw.jpg ├── step1.jpg ├── step2.jpg ├── step3_p1.jpg └── step3_p2.jpg ├── lookup_table_demo ├── README.md ├── bridging_the_gap_between_binary_image_and_analysis.ipynb ├── demo_TNNI1.ipynb ├── playground_Sec61b.ipynb ├── playground_curvi.ipynb ├── playground_curvi_WorkshopOct2019.ipynb ├── playground_dots.ipynb ├── playground_filament3d.ipynb ├── playground_gja1.ipynb ├── playground_lamp1.ipynb ├── playground_npm1.ipynb ├── playground_shell.ipynb ├── playground_spotty.ipynb ├── playground_st6gal1.ipynb ├── test_segmentation_TNNI1.tiff └── test_viewer.ipynb ├── pyproject.toml ├── setup.cfg ├── setup.py └── tox.ini /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | charset = utf-8 11 | end_of_line = lf 12 | 13 | [*.bat] 14 | indent_style = tab 15 | end_of_line = crlf 16 | 17 | [LICENSE] 18 | insert_final_newline = false 19 | 20 | [Makefile] 21 | indent_style = tab 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/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/ISSUE_TEMPLATE/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/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/workflows/build-docs.yml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | docs: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - name: Set up Python 14 | uses: actions/setup-python@v5 15 | with: 16 | python-version: 3.9 17 | - name: Install Dependencies 18 | run: | 19 | pip install --upgrade pip 20 | pip install .[dev] --verbose 21 | - name: Generate Docs 22 | run: | 23 | make gen-docs 24 | touch docs/_build/html/.nojekyll 25 | - name: Publish Docs 26 | uses: JamesIves/github-pages-deploy-action@releases/v3 27 | with: 28 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 29 | BASE_BRANCH: main # The branch the action should deploy from. 30 | BRANCH: gh-pages # The branch the action should deploy to. 31 | FOLDER: docs/_build/html/ # The folder the action should deploy. 32 | 33 | -------------------------------------------------------------------------------- /.github/workflows/build-main.yml: -------------------------------------------------------------------------------- 1 | name: Build Main 2 | 3 | on: 4 | push: 5 | branches: 6 | - "**" 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'] 19 | os: [ubuntu-latest, windows-latest, macOS-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] --verbose 31 | - name: Test with pytest 32 | run: | 33 | pytest --cov-report xml --cov=aicssegmentation aicssegmentation/tests/ 34 | 35 | lint: 36 | runs-on: ubuntu-latest 37 | 38 | steps: 39 | - uses: actions/checkout@v4 40 | - name: Set up Python 41 | uses: actions/setup-python@v5 42 | with: 43 | python-version: 3.9 44 | - name: Install Dependencies 45 | run: | 46 | python -m pip install --upgrade pip 47 | pip install .[test] --verbose 48 | - name: Lint with flake8 49 | run: | 50 | flake8 aicssegmentation --count --verbose --show-source --statistics 51 | - name: Check with black 52 | run: | 53 | black --check aicssegmentation 54 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | push: 5 | branches: 6 | - stable 7 | 8 | jobs: 9 | publish: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - name: Set up Python 14 | uses: actions/setup-python@v5 15 | with: 16 | python-version: 3.9 17 | - name: Install Dependencies 18 | run: | 19 | python -m pip install --upgrade pip 20 | pip install setuptools wheel 21 | - name: Build Package 22 | run: | 23 | python setup.py sdist bdist_wheel 24 | - name: Publish to PyPI 25 | uses: pypa/gh-action-pypi-publish@master 26 | with: 27 | user: __token__ 28 | password: ${{ secrets.PYPI_TOKEN }} 29 | -------------------------------------------------------------------------------- /.github/workflows/test-and-lint-manual-trigger.yml: -------------------------------------------------------------------------------- 1 | name: Test and Lint manual trigger 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | test: 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | matrix: 11 | python-version: [3.9, '3.10'] 12 | os: [ubuntu-latest, windows-latest, macOS-latest] 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: Set up Python ${{ matrix.python-version }} 17 | uses: actions/setup-python@v5 18 | with: 19 | python-version: ${{ matrix.python-version }} 20 | - name: Install Dependencies 21 | run: | 22 | python -m pip install --upgrade pip 23 | pip install .[test] --verbose 24 | - name: Test with pytest 25 | run: | 26 | pytest aicssegmentation/tests/ 27 | 28 | lint: 29 | runs-on: ubuntu-latest 30 | 31 | steps: 32 | - uses: actions/checkout@v4 33 | - name: Set up Python 34 | uses: actions/setup-python@v5 35 | with: 36 | python-version: 3.9 37 | - name: Install Dependencies 38 | run: | 39 | python -m pip install --upgrade pip 40 | pip install .[test] 41 | - name: Lint with flake8 42 | run: | 43 | flake8 aicssegmentation --count --verbose --show-source --statistics 44 | - name: Check with black 45 | run: | 46 | black --check aicssegmentation 47 | -------------------------------------------------------------------------------- /.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'] 11 | os: [ubuntu-latest, windows-latest, macOS-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] --verbose 23 | - name: Test with pytest 24 | run: | 25 | pytest aicssegmentation/tests/ 26 | 27 | lint: 28 | runs-on: ubuntu-latest 29 | 30 | steps: 31 | - uses: actions/checkout@v4 32 | - name: Set up Python 33 | uses: actions/setup-python@v5 34 | with: 35 | python-version: 3.9 36 | - name: Install Dependencies 37 | run: | 38 | python -m pip install --upgrade pip 39 | pip install .[test] --verbose 40 | - name: Lint with flake8 41 | run: | 42 | flake8 aicssegmentation --count --verbose --show-source --statistics 43 | - name: Check with black 44 | run: | 45 | black --check aicssegmentation 46 | -------------------------------------------------------------------------------- /.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/aicssegmentation.*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 settings 112 | settings.json 113 | .vscode 114 | 115 | # IDE files 116 | .idea/ 117 | -------------------------------------------------------------------------------- /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 | Ready to contribute? Here's how to set up `aicssegmentation` for local development. 8 | 9 | 1. Fork the `aicssegmentation` repo on GitHub. 10 | 11 | 2. Clone your fork locally: 12 | 13 | ```bash 14 | git clone git@github.com:{your_name_here}/aicssegmentation.git 15 | ``` 16 | 17 | 3. Install the project in editable mode. (It is also recommended to work in a virtualenv or anaconda environment): 18 | 19 | ```bash 20 | cd aicssegmentation/ 21 | pip install -e .[dev] 22 | ``` 23 | 24 | 4. Create a branch for local development: 25 | 26 | ```bash 27 | git checkout -b {your_development_type}/short-description 28 | ``` 29 | 30 | Ex: feature/read-tiff-files or bugfix/handle-file-not-found
31 | Now you can make your changes locally. 32 | 33 | 5. When you're done making changes, check that your changes pass linting and 34 | tests, including testing other Python versions with make: 35 | 36 | ```bash 37 | make build 38 | ``` 39 | 40 | 6. Commit your changes and push your branch to GitHub: 41 | 42 | ```bash 43 | git add . 44 | git commit -m "Resolves gh-###. Your detailed description of your changes." 45 | git push origin {your_development_type}/short-description 46 | ``` 47 | 48 | 7. Submit a pull request through the GitHub website. 49 | 50 | ## Adding a new workflow 51 | New workflows should be added to the [`structure_wrapper` directory](aicssegmentation/structure_wrapper) and be named `seg_structurename.py`. Each of these files must define a function called `Workflow_structurename`. To ensure that the new structure is included in our tests, please include an image in the [`resources` folder](aicssegmentation\tests\resources\images) that shows the expected result of the segmentation. This can be done with the [`run_segmentation()` function ](aicssegmentation\tests\test_structures.py). Please also add the name of the new structure to the `ALL_STRUCTURE_NAMES` list [here](aicssegmentation\tests\test_structures.py). 52 | 53 | ## Deploying 54 | 55 | A reminder for the maintainers on how to deploy. 56 | Make sure all your changes are committed. 57 | Then run: 58 | 59 | ```bash 60 | $ bumpversion patch # possible: major / minor / patch 61 | $ git push 62 | $ git push --tags 63 | git branch -D stable 64 | git checkout -b stable 65 | git push --set-upstream origin stable -f 66 | ``` 67 | 68 | This will release a new package version on Git + GitHub and publish to PyPI. 69 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Allen Institute Software License – This software license is the 2-clause BSD 2 | license plus a third clause that prohibits redistribution and use for 3 | commercial purposes without further permission. 4 | 5 | Copyright © 2020 6 | Jianxu Chen, Allen Institute. All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | 3. Redistributions and use for commercial purposes are not permitted without 19 | the Allen Institute’s written permission. For purposes of this license, 20 | commercial purposes are the incorporation of the Allen Institute's software 21 | into anything for which you will charge fees or other compensation or use of 22 | the software to perform a commercial service for a third party. Contact 23 | terms@alleninstitute.org for commercial licensing opportunities. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 26 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 27 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | 36 | 37 | -------------------------------------------------------------------------------- /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 aicssegmentation/data 11 | 12 | recursive-include aicssegmentation/assets/thumbnails *.png 13 | recursive-include aicssegmentation/assets/diagrams *.png 14 | recursive-include aicssegmentation/structure_wrapper_config *.json 15 | -------------------------------------------------------------------------------- /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/aicssegmentation*.rst 53 | rm -f docs/modules.rst 54 | sphinx-apidoc -o docs/ aicssegmentation **/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 | 61 | test: ## run pytest with coverage report 62 | pytest --cov=aicssegmentation --cov-report xml --cov-report term 63 | 64 | lint: ## run a lint check / report 65 | flake8 aicssegmentation --count --verbose --show-source --statistics 66 | black --check --exclude vendor aicssegmentation 67 | 68 | lint-format: ## reformat files with black 69 | black --exclude vendor aicssegmentation -------------------------------------------------------------------------------- /aicssegmentation/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """Top-level package for aicssegmentation.""" 4 | 5 | __author__ = "Jianxu Chen" 6 | __email__ = "jianxuc@alleninstitute.org" 7 | # Do not edit this string manually, always use bumpversion 8 | # Details in CONTRIBUTING.md 9 | __version__ = "0.5.2" 10 | 11 | 12 | def get_module_version(): 13 | return __version__ 14 | -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/actb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/actb.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/actn1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/actn1.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/atp2a2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/atp2a2.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/cetn2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/cetn2.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/ctnnb1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/ctnnb1.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/dsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/dsp.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/fbl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/fbl.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/gja1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/gja1.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/h2b_interphase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/h2b_interphase.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/lamp1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/lamp1.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/lmnb1_interphase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/lmnb1_interphase.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/lmnb1_mitotic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/lmnb1_mitotic.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/myh10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/myh10.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/npm1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/npm1.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/nup153.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/nup153.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/pxn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/pxn.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/rab5a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/rab5a.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/sec61b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/sec61b.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/slc25a17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/slc25a17.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/smc1a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/smc1a.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/son.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/son.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/st6gal1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/st6gal1.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/tjp1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/tjp1.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/tomm20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/tomm20.png -------------------------------------------------------------------------------- /aicssegmentation/assets/diagrams/tuba1b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/diagrams/tuba1b.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/actb_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/actb_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/actb_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/actb_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/actn1_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/actn1_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/actn1_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/actn1_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/atp2a2_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/atp2a2_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/atp2a2_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/atp2a2_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/cetn2_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/cetn2_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/cetn2_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/cetn2_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/ctnnb1_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/ctnnb1_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/ctnnb1_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/ctnnb1_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/dsp_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/dsp_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/dsp_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/dsp_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/fbl_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/fbl_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/fbl_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/fbl_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/gja1_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/gja1_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/gja1_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/gja1_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/h2b_interphase_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/h2b_interphase_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/h2b_interphase_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/h2b_interphase_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/lamp1_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/lamp1_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/lamp1_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/lamp1_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/lmnb1_interphase_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/lmnb1_interphase_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/lmnb1_interphase_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/lmnb1_interphase_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/lmnb1_mitotic_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/lmnb1_mitotic_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/lmnb1_mitotic_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/lmnb1_mitotic_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/myh10_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/myh10_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/myh10_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/myh10_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/npm1_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/npm1_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/npm1_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/npm1_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/nup153_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/nup153_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/nup153_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/nup153_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/pxn_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/pxn_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/pxn_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/pxn_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/rab5a_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/rab5a_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/rab5a_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/rab5a_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/sec61b_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/sec61b_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/sec61b_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/sec61b_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/slc25a17_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/slc25a17_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/slc25a17_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/slc25a17_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/smc1a_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/smc1a_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/smc1a_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/smc1a_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/son_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/son_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/son_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/son_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/st6gal1_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/st6gal1_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/st6gal1_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/st6gal1_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/tjp1_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/tjp1_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/tjp1_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/tjp1_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/tomm20_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/tomm20_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/tomm20_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/tomm20_pre.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/tuba1b_post.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/tuba1b_post.png -------------------------------------------------------------------------------- /aicssegmentation/assets/thumbnails/tuba1b_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/assets/thumbnails/tuba1b_pre.png -------------------------------------------------------------------------------- /aicssegmentation/bin/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """Bin scripts package for aicssegmentation.""" 4 | -------------------------------------------------------------------------------- /aicssegmentation/cli/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/cli/__init__.py -------------------------------------------------------------------------------- /aicssegmentation/cli/to_analysis.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pandas as pd 3 | from scipy.ndimage.measurements import label 4 | 5 | 6 | def simple_builder(bw, se=None, return_dataframe=False): 7 | """build object table based on connected component""" 8 | 9 | if se is None: 10 | obj_label, obj_num = label(bw > 0) 11 | else: 12 | obj_label, obj_num = label(bw > 0, structure=se) 13 | 14 | if return_dataframe: 15 | import pandas as pd 16 | 17 | obj_df = pd.DataFrame(np.arange(1, obj_num + 1, 1), columns=["object_index"]) 18 | return obj_label, obj_df 19 | else: 20 | return obj_label 21 | 22 | 23 | def masked_builder(bw, mask_label): 24 | """build object table based on mask image""" 25 | 26 | assert mask_label.max() > 0 27 | 28 | if mask_label.max() == 1: 29 | mask_label, num_label = label(mask_label > 0) 30 | label_list = np.arange(1, num_label + 1, 1) 31 | else: 32 | label_list = np.unique(mask_label[mask_label > 0]) 33 | 34 | counter_offset = 0 35 | obj_label = np.zeros_like(mask_label) 36 | multi_index_list = [] 37 | for ii, val in enumerate(label_list): 38 | single_mask = mask_label == val 39 | valid_bw = bw.copy() 40 | valid_bw[single_mask == 0] = 0 41 | valid_label, valid_label_num = label(valid_bw > 0) 42 | for valid_index in range(valid_label_num): 43 | index_plus = valid_index + 1 44 | this_obj_index = index_plus + counter_offset 45 | this_obj = valid_label == index_plus 46 | obj_label[this_obj] = this_obj_index 47 | multi_index_list.append([val, this_obj_index, this_obj.sum()]) 48 | counter_offset = counter_offset + valid_label_num 49 | 50 | obj_df = pd.DataFrame(multi_index_list) 51 | obj_df.columns = ["mask_id", "obj_id", "vol"] 52 | 53 | return obj_label, obj_df.set_index(["mask_id", "obj_id"]) 54 | 55 | 56 | def hierachical_builder(img_list): 57 | print("under construction") 58 | pass 59 | -------------------------------------------------------------------------------- /aicssegmentation/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/core/__init__.py -------------------------------------------------------------------------------- /aicssegmentation/core/hessian.py: -------------------------------------------------------------------------------- 1 | from itertools import combinations_with_replacement 2 | 3 | import numpy as np 4 | from scipy import ndimage as ndi 5 | 6 | from .utils import absolute_eigenvaluesh 7 | 8 | 9 | def compute_3d_hessian_matrix( 10 | nd_array: np.ndarray, 11 | sigma: float = 1, 12 | scale: bool = True, 13 | whiteonblack: bool = True, 14 | ) -> np.ndarray: 15 | """ 16 | Computes the hessian matrix for an nd_array. The implementation was adapted from: 17 | https://github.com/ellisdg/frangi3d/blob/master/frangi/hessian.py 18 | 19 | Parameters: 20 | ---------- 21 | nd_array: np.ndarray 22 | nd array from which to compute the hessian matrix. 23 | sigma: float 24 | Standard deviation used for the Gaussian kernel to smooth the array. Defaul is 1 25 | scale: bool 26 | whether the hessian elements will be scaled by sigma squared. Default is True 27 | whiteonblack: boolean 28 | image is white objects on black blackground or not. Default is True 29 | 30 | 31 | Return: 32 | ---------- 33 | hessian array of shape (..., ndim, ndim) 34 | """ 35 | ndim = nd_array.ndim 36 | 37 | # smooth the nd_array 38 | smoothed = ndi.gaussian_filter(nd_array, sigma=sigma, mode="nearest", truncate=3.0) 39 | 40 | # compute the first order gradients 41 | gradient_list = np.gradient(smoothed) 42 | 43 | # compute the hessian elements 44 | hessian_elements = [ 45 | np.gradient(gradient_list[ax0], axis=ax1) for ax0, ax1 in combinations_with_replacement(range(ndim), 2) 46 | ] 47 | 48 | if sigma > 0 and scale: 49 | # scale the elements of the hessian matrix 50 | if whiteonblack: 51 | hessian_elements = [(sigma**2) * element for element in hessian_elements] 52 | else: 53 | hessian_elements = [-1 * (sigma**2) * element for element in hessian_elements] 54 | 55 | # create hessian matrix from hessian elements 56 | hessian_full = [[()] * ndim for x in range(ndim)] 57 | # hessian_full = [[None] * ndim] * ndim 58 | 59 | for index, (ax0, ax1) in enumerate(combinations_with_replacement(range(ndim), 2)): 60 | element = hessian_elements[index] 61 | hessian_full[ax0][ax1] = element 62 | if ax0 != ax1: 63 | hessian_full[ax1][ax0] = element 64 | 65 | hessian_rows = list() 66 | for row in hessian_full: 67 | # print(row.shape) 68 | hessian_rows.append(np.stack(row, axis=-1)) 69 | 70 | hessian = np.stack(hessian_rows, axis=-2) 71 | return hessian 72 | 73 | 74 | def absolute_3d_hessian_eigenvalues( 75 | nd_array: np.ndarray, 76 | sigma: float = 1, 77 | scale: bool = True, 78 | whiteonblack: bool = True, 79 | ): 80 | """ 81 | Eigenvalues of the hessian matrix calculated from the input array sorted by 82 | absolute value. 83 | 84 | Parameters: 85 | ------------ 86 | nd_array: np.ndarray 87 | nd array from which to compute the hessian matrix. 88 | sigma: float 89 | Standard deviation used for the Gaussian kernel to smooth the array. Defaul is 1 90 | scale: bool 91 | whether the hessian elements will be scaled by sigma squared. Default is True 92 | whiteonblack: boolean 93 | image is white objects on black blackground or not. Default is True 94 | 95 | Return: 96 | ------------ 97 | list of eigenvalues [eigenvalue1, eigenvalue2, ...] 98 | """ 99 | return absolute_eigenvaluesh( 100 | compute_3d_hessian_matrix(nd_array, sigma=sigma, scale=scale, whiteonblack=whiteonblack) 101 | ) 102 | -------------------------------------------------------------------------------- /aicssegmentation/core/output_utils.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | import numpy as np 3 | from skimage.morphology import erosion, ball 4 | from aicsimageio.writers import OmeTiffWriter 5 | 6 | 7 | def save_segmentation( 8 | bw: np.ndarray, 9 | contour_flag: bool, 10 | output_path: Path, 11 | fn: str, 12 | suffix: str = "_struct_segmentation", 13 | ): 14 | """save the segmentation into a tiff file 15 | 16 | Parameters: 17 | ------------ 18 | bw: np.ndarray 19 | the segmentation to save 20 | contour_flag: book 21 | whether to also save segmentation contour 22 | output_path: Path 23 | the path to save 24 | fn: str 25 | the core file name to use, for example, "img_102", then 26 | after a suffix (say "_seg") is added, the file name of the output 27 | is "img_101_seg.tiff" 28 | suffix: str 29 | the suffix to add to the output filename 30 | """ 31 | OmeTiffWriter.save(data=bw, uri=str(output_path / (fn + suffix + ".tiff")), dim_order="ZYX") 32 | 33 | if contour_flag: 34 | bd = generate_segmentation_contour(bw) 35 | 36 | out_fn = str(output_path / (fn + suffix + "_contour.tiff")) 37 | OmeTiffWriter.save(data=bd, uri=out_fn, dim_order="ZYX") 38 | 39 | 40 | def generate_segmentation_contour(im): 41 | """generate the contour of the segmentation""" 42 | 43 | bd = np.logical_xor(erosion(im > 0, footprint=ball(1)), im > 0) 44 | 45 | bd = bd.astype(np.uint8) 46 | bd[bd > 0] = 255 47 | 48 | return bd 49 | 50 | 51 | def output_hook(im, names, out_flag, output_path, fn): 52 | """general hook for cutomized output""" 53 | assert len(im) == len(names) and len(names) == len(out_flag) 54 | 55 | for i in range(len(out_flag)): 56 | if out_flag[i]: 57 | if names[i].startswith("bw_"): 58 | segmentation_type = names[i] 59 | bw = im[i].astype(np.uint8) 60 | bw[bw > 0] = 255 61 | OmeTiffWriter.save(data=bw, uri=str(output_path / (fn + "_bw_" + segmentation_type[3:] + ".tiff"))) 62 | else: 63 | OmeTiffWriter.save(data=im[i], uri=str(output_path / (fn + "_" + names[i] + ".tiff"))) 64 | -------------------------------------------------------------------------------- /aicssegmentation/exceptions.py: -------------------------------------------------------------------------------- 1 | class ArgumentNullError(Exception): 2 | """ 3 | Thrown to indicate that a parameter is None when a value is expected 4 | """ 5 | 6 | def __init__(self, parameter_name: str): 7 | super().__init__(f"Parameter {parameter_name} is None. Non null value expected.") 8 | -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/structure_wrapper/__init__.py -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper/seg_cardio_actn2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from typing import Union 3 | from pathlib import Path 4 | from skimage.morphology import remove_small_objects 5 | from aicssegmentation.core.pre_processing_utils import ( 6 | intensity_normalization, 7 | edge_preserving_smoothing_3d, 8 | ) 9 | from aicssegmentation.core.vessel import vesselness3D 10 | from aicssegmentation.core.output_utils import ( 11 | save_segmentation, 12 | generate_segmentation_contour, 13 | ) 14 | from scipy.ndimage import zoom 15 | 16 | 17 | def Workflow_cardio_actn2( 18 | struct_img: np.ndarray, 19 | rescale_ratio: float = -1, 20 | output_type: str = "default", 21 | output_path: Union[str, Path] = None, 22 | fn: Union[str, Path] = None, 23 | output_func=None, 24 | ): 25 | """ 26 | classic segmentation workflow wrapper for structure Cardio ACTN2 27 | 28 | Parameter: 29 | ----------- 30 | struct_img: np.ndarray 31 | the 3D image to be segmented 32 | rescale_ratio: float 33 | an optional parameter to allow rescale the image before running the 34 | segmentation functions, default is no rescaling 35 | output_type: str 36 | select how to handle output. Currently, four types are supported: 37 | 1. default: the result will be saved at output_path whose filename is 38 | original name without extention + "_struct_segmentaiton.tiff" 39 | 2. array: the segmentation result will be simply returned as a numpy array 40 | 3. array_with_contour: segmentation result will be returned together with 41 | the contour of the segmentation 42 | 4. customize: pass in an extra output_func to do a special save. All the 43 | intermediate results, names of these results, the output_path, and the 44 | original filename (without extension) will be passed in to output_func. 45 | """ 46 | ########################################################################## 47 | # PARAMETERS: 48 | # note that these parameters are supposed to be fixed for the structure 49 | # and work well accross different datasets 50 | 51 | intensity_norm_param = [1, 19] 52 | vesselness_sigma = [1] 53 | vesselness_cutoff = 0.02 54 | minArea = 15 55 | ########################################################################## 56 | 57 | out_img_list = [] 58 | out_name_list = [] 59 | 60 | ################### 61 | # PRE_PROCESSING 62 | ################### 63 | # intenisty normalization (min/max) 64 | struct_img = intensity_normalization(struct_img, scaling_param=intensity_norm_param) 65 | 66 | out_img_list.append(struct_img.copy()) 67 | out_name_list.append("im_norm") 68 | 69 | # rescale if needed 70 | if rescale_ratio > 0: 71 | struct_img = zoom(struct_img, (1, rescale_ratio, rescale_ratio), order=2) 72 | 73 | struct_img = (struct_img - struct_img.min() + 1e-8) / (struct_img.max() - struct_img.min() + 1e-8) 74 | 75 | # smoothing with gaussian filter 76 | structure_img_smooth = edge_preserving_smoothing_3d(struct_img) 77 | 78 | out_img_list.append(structure_img_smooth.copy()) 79 | out_name_list.append("im_smooth") 80 | 81 | ################### 82 | # core algorithm 83 | ################### 84 | 85 | # vesselness 3d 86 | response = vesselness3D(structure_img_smooth, sigmas=vesselness_sigma, tau=1, whiteonblack=True) 87 | bw = response > vesselness_cutoff 88 | 89 | ################### 90 | # POST-PROCESSING 91 | ################### 92 | seg = remove_small_objects(bw > 0, min_size=minArea, connectivity=1) 93 | 94 | # output 95 | seg = seg > 0 96 | seg = seg.astype(np.uint8) 97 | seg[seg > 0] = 255 98 | 99 | out_img_list.append(seg.copy()) 100 | out_name_list.append("bw_final") 101 | 102 | if output_type == "default": 103 | # the default final output, simply save it to the output path 104 | save_segmentation(seg, False, Path(output_path), fn) 105 | elif output_type == "customize": 106 | # the hook for passing in a customized output function 107 | # use "out_img_list" and "out_name_list" in your hook to 108 | # customize your output functions 109 | output_func(out_img_list, out_name_list, Path(output_path), fn) 110 | elif output_type == "array": 111 | return seg 112 | elif output_type == "array_with_contour": 113 | return (seg, generate_segmentation_contour(seg)) 114 | else: 115 | raise NotImplementedError("invalid output type: {output_type}") 116 | -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper/seg_cardio_atp2a2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from typing import Union 3 | from pathlib import Path 4 | from skimage.morphology import remove_small_objects 5 | from aicssegmentation.core.pre_processing_utils import ( 6 | intensity_normalization, 7 | edge_preserving_smoothing_3d, 8 | ) 9 | from aicssegmentation.core.vessel import vesselness3D 10 | from aicssegmentation.core.output_utils import ( 11 | save_segmentation, 12 | generate_segmentation_contour, 13 | ) 14 | from scipy.ndimage import zoom 15 | 16 | 17 | def Workflow_cardio_atp2a2( 18 | struct_img: np.ndarray, 19 | rescale_ratio: float = -1, 20 | output_type: str = "default", 21 | output_path: Union[str, Path] = None, 22 | fn: Union[str, Path] = None, 23 | output_func=None, 24 | ): 25 | """ 26 | classic segmentation workflow wrapper for structure Cardio ATP2A2 27 | 28 | Parameter: 29 | ----------- 30 | struct_img: np.ndarray 31 | the 3D image to be segmented 32 | rescale_ratio: float 33 | an optional parameter to allow rescale the image before running the 34 | segmentation functions, default is no rescaling 35 | output_type: str 36 | select how to handle output. Currently, four types are supported: 37 | 1. default: the result will be saved at output_path whose filename is 38 | original name without extention + "_struct_segmentaiton.tiff" 39 | 2. array: the segmentation result will be simply returned as a numpy array 40 | 3. array_with_contour: segmentation result will be returned together with 41 | the contour of the segmentation 42 | 4. customize: pass in an extra output_func to do a special save. All the 43 | intermediate results, names of these results, the output_path, and the 44 | original filename (without extension) will be passed in to output_func. 45 | """ 46 | ########################################################################## 47 | # PARAMETERS: 48 | # note that these parameters are supposed to be fixed for the structure 49 | # and work well accross different datasets 50 | 51 | intensity_norm_param = [1, 20] 52 | vesselness_sigma = [1] 53 | vesselness_cutoff = 0.002 54 | minArea = 15 55 | ########################################################################## 56 | 57 | out_img_list = [] 58 | out_name_list = [] 59 | 60 | ################### 61 | # PRE_PROCESSING 62 | ################### 63 | # intenisty normalization (min/max) 64 | struct_img = intensity_normalization(struct_img, scaling_param=intensity_norm_param) 65 | 66 | out_img_list.append(struct_img.copy()) 67 | out_name_list.append("im_norm") 68 | 69 | # rescale if needed 70 | if rescale_ratio > 0: 71 | struct_img = zoom(struct_img, (1, rescale_ratio, rescale_ratio), order=2) 72 | 73 | struct_img = (struct_img - struct_img.min() + 1e-8) / (struct_img.max() - struct_img.min() + 1e-8) 74 | 75 | # smoothing with gaussian filter 76 | structure_img_smooth = edge_preserving_smoothing_3d(struct_img) 77 | 78 | out_img_list.append(structure_img_smooth.copy()) 79 | out_name_list.append("im_smooth") 80 | 81 | ################### 82 | # core algorithm 83 | ################### 84 | 85 | # vesselness 3d 86 | response = vesselness3D(structure_img_smooth, sigmas=vesselness_sigma, tau=1, whiteonblack=True) 87 | bw = response > vesselness_cutoff 88 | 89 | ################### 90 | # POST-PROCESSING 91 | ################### 92 | seg = remove_small_objects(bw > 0, min_size=minArea, connectivity=1) 93 | 94 | # output 95 | seg = seg > 0 96 | seg = seg.astype(np.uint8) 97 | seg[seg > 0] = 255 98 | 99 | out_img_list.append(seg.copy()) 100 | out_name_list.append("bw_final") 101 | 102 | if output_type == "default": 103 | # the default final output, simply save it to the output path 104 | save_segmentation(seg, False, Path(output_path), fn) 105 | elif output_type == "customize": 106 | # the hook for passing in a customized output function 107 | # use "out_img_list" and "out_name_list" in your hook to 108 | # customize your output functions 109 | output_func(out_img_list, out_name_list, Path(output_path), fn) 110 | elif output_type == "array": 111 | return seg 112 | elif output_type == "array_with_contour": 113 | return (seg, generate_segmentation_contour(seg)) 114 | else: 115 | raise NotImplementedError("invalid output type: {output_type}") 116 | -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper/seg_cardio_myl7.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from typing import Union 3 | from pathlib import Path 4 | from skimage.morphology import remove_small_objects 5 | from aicssegmentation.core.pre_processing_utils import ( 6 | intensity_normalization, 7 | edge_preserving_smoothing_3d, 8 | ) 9 | from aicssegmentation.core.vessel import vesselness3D 10 | from aicssegmentation.core.output_utils import ( 11 | save_segmentation, 12 | generate_segmentation_contour, 13 | ) 14 | from scipy.ndimage import zoom 15 | 16 | 17 | def Workflow_cardio_myl7( 18 | struct_img: np.ndarray, 19 | rescale_ratio: float = -1, 20 | output_type: str = "default", 21 | output_path: Union[str, Path] = None, 22 | fn: Union[str, Path] = None, 23 | output_func=None, 24 | ): 25 | """ 26 | classic segmentation workflow wrapper for structure Cardio MYL7 27 | 28 | Parameter: 29 | ----------- 30 | struct_img: np.ndarray 31 | the 3D image to be segmented 32 | rescale_ratio: float 33 | an optional parameter to allow rescale the image before running the 34 | segmentation functions, default is no rescaling 35 | output_type: str 36 | select how to handle output. Currently, four types are supported: 37 | 1. default: the result will be saved at output_path whose filename is 38 | original name without extention + "_struct_segmentaiton.tiff" 39 | 2. array: the segmentation result will be simply returned as a numpy array 40 | 3. array_with_contour: segmentation result will be returned together with 41 | the contour of the segmentation 42 | 4. customize: pass in an extra output_func to do a special save. All the 43 | intermediate results, names of these results, the output_path, and the 44 | original filename (without extension) will be passed in to output_func. 45 | """ 46 | ########################################################################## 47 | # PARAMETERS: 48 | # note that these parameters are supposed to be fixed for the structure 49 | # and work well accross different datasets 50 | 51 | intensity_norm_param = [8, 15.5] 52 | vesselness_sigma = [1] 53 | vesselness_cutoff = 0.01 54 | minArea = 15 55 | ########################################################################## 56 | 57 | out_img_list = [] 58 | out_name_list = [] 59 | 60 | ################### 61 | # PRE_PROCESSING 62 | ################### 63 | # intenisty normalization (min/max) 64 | struct_img = intensity_normalization(struct_img, scaling_param=intensity_norm_param) 65 | 66 | out_img_list.append(struct_img.copy()) 67 | out_name_list.append("im_norm") 68 | 69 | # rescale if needed 70 | if rescale_ratio > 0: 71 | struct_img = zoom(struct_img, (1, rescale_ratio, rescale_ratio), order=2) 72 | 73 | struct_img = (struct_img - struct_img.min() + 1e-8) / (struct_img.max() - struct_img.min() + 1e-8) 74 | 75 | # smoothing with gaussian filter 76 | structure_img_smooth = edge_preserving_smoothing_3d(struct_img) 77 | 78 | out_img_list.append(structure_img_smooth.copy()) 79 | out_name_list.append("im_smooth") 80 | 81 | ################### 82 | # core algorithm 83 | ################### 84 | 85 | # vesselness 3d 86 | response = vesselness3D(structure_img_smooth, sigmas=vesselness_sigma, tau=1, whiteonblack=True) 87 | bw = response > vesselness_cutoff 88 | 89 | ################### 90 | # POST-PROCESSING 91 | ################### 92 | seg = remove_small_objects(bw > 0, min_size=minArea, connectivity=1) 93 | 94 | # output 95 | seg = seg > 0 96 | seg = seg.astype(np.uint8) 97 | seg[seg > 0] = 255 98 | 99 | out_img_list.append(seg.copy()) 100 | out_name_list.append("bw_final") 101 | 102 | if output_type == "default": 103 | # the default final output, simply save it to the output path 104 | save_segmentation(seg, False, Path(output_path), fn) 105 | elif output_type == "customize": 106 | # the hook for passing in a customized output function 107 | # use "out_img_list" and "out_name_list" in your hook to 108 | # customize your output functions 109 | output_func(out_img_list, out_name_list, Path(output_path), fn) 110 | elif output_type == "array": 111 | return seg 112 | elif output_type == "array_with_contour": 113 | return (seg, generate_segmentation_contour(seg)) 114 | else: 115 | raise NotImplementedError("invalid output type: {output_type}") 116 | -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper/seg_cardio_tnni1.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from typing import Union 3 | from pathlib import Path 4 | from aicssegmentation.core.vessel import vesselness3D 5 | from aicssegmentation.core.pre_processing_utils import ( 6 | intensity_normalization, 7 | edge_preserving_smoothing_3d, 8 | ) 9 | from skimage.morphology import remove_small_objects 10 | from aicssegmentation.core.output_utils import ( 11 | save_segmentation, 12 | generate_segmentation_contour, 13 | ) 14 | from scipy.ndimage import zoom 15 | 16 | 17 | def Workflow_cardio_tnni1( 18 | struct_img: np.ndarray, 19 | rescale_ratio: float = -1, 20 | output_type: str = "default", 21 | output_path: Union[str, Path] = None, 22 | fn: Union[str, Path] = None, 23 | output_func=None, 24 | ): 25 | """ 26 | classic segmentation workflow wrapper for structure Cardio TNNI1 27 | 28 | Parameter: 29 | ----------- 30 | struct_img: np.ndarray 31 | the 3D image to be segmented 32 | rescale_ratio: float 33 | an optional parameter to allow rescale the image before running the 34 | segmentation functions, default is no rescaling 35 | output_type: str 36 | select how to handle output. Currently, four types are supported: 37 | 1. default: the result will be saved at output_path whose filename is 38 | original name without extention + "_struct_segmentaiton.tiff" 39 | 2. array: the segmentation result will be simply returned as a numpy array 40 | 3. array_with_contour: segmentation result will be returned together with 41 | the contour of the segmentation 42 | 4. customize: pass in an extra output_func to do a special save. All the 43 | intermediate results, names of these results, the output_path, and the 44 | original filename (without extension) will be passed in to output_func. 45 | """ 46 | ########################################################################## 47 | # PARAMETERS: 48 | # note that these parameters are supposed to be fixed for the structure 49 | # and work well accross different datasets 50 | 51 | intensity_norm_param = [2, 11] 52 | vesselness_sigma = [1] 53 | vesselness_cutoff = 0.01 54 | minArea = 15 55 | ########################################################################## 56 | 57 | out_img_list = [] 58 | out_name_list = [] 59 | 60 | ################### 61 | # PRE_PROCESSING 62 | ################### 63 | # intenisty normalization (min/max) 64 | struct_img = intensity_normalization(struct_img, scaling_param=intensity_norm_param) 65 | 66 | out_img_list.append(struct_img.copy()) 67 | out_name_list.append("im_norm") 68 | 69 | # rescale if needed 70 | if rescale_ratio > 0: 71 | struct_img = zoom(struct_img, (1, rescale_ratio, rescale_ratio), order=2) 72 | 73 | struct_img = (struct_img - struct_img.min() + 1e-8) / (struct_img.max() - struct_img.min() + 1e-8) 74 | 75 | # smoothing 76 | structure_img_smooth = edge_preserving_smoothing_3d(struct_img) 77 | 78 | out_img_list.append(structure_img_smooth.copy()) 79 | out_name_list.append("im_smooth") 80 | 81 | ################### 82 | # core algorithm 83 | ################### 84 | 85 | # vesselness 3d 86 | response = vesselness3D(structure_img_smooth, sigmas=vesselness_sigma, tau=1, whiteonblack=True) 87 | bw = response > vesselness_cutoff 88 | 89 | ################### 90 | # POST-PROCESSING 91 | ################### 92 | seg = remove_small_objects(bw > 0, min_size=minArea, connectivity=1) 93 | 94 | # output 95 | seg = seg > 0 96 | seg = seg.astype(np.uint8) 97 | seg[seg > 0] = 255 98 | 99 | out_img_list.append(seg.copy()) 100 | out_name_list.append("bw_final") 101 | 102 | if output_type == "default": 103 | # the default final output, simply save it to the output path 104 | save_segmentation(seg, False, Path(output_path), fn) 105 | elif output_type == "customize": 106 | # the hook for passing in a customized output function 107 | # use "out_img_list" and "out_name_list" in your hook to 108 | # customize your output functions 109 | output_func(out_img_list, out_name_list, Path(output_path), fn) 110 | elif output_type == "array": 111 | return seg 112 | elif output_type == "array_with_contour": 113 | return (seg, generate_segmentation_contour(seg)) 114 | else: 115 | raise NotImplementedError("invalid output type: {output_type}") 116 | -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper/seg_cardio_ttn.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from typing import Union 3 | from pathlib import Path 4 | from skimage.morphology import remove_small_objects 5 | from aicssegmentation.core.pre_processing_utils import ( 6 | intensity_normalization, 7 | edge_preserving_smoothing_3d, 8 | ) 9 | from aicssegmentation.core.vessel import vesselness3D 10 | from aicssegmentation.core.output_utils import ( 11 | save_segmentation, 12 | generate_segmentation_contour, 13 | ) 14 | from scipy.ndimage import zoom 15 | 16 | 17 | def Workflow_cardio_ttn( 18 | struct_img: np.ndarray, 19 | rescale_ratio: float = -1, 20 | output_type: str = "default", 21 | output_path: Union[str, Path] = None, 22 | fn: Union[str, Path] = None, 23 | output_func=None, 24 | ): 25 | """ 26 | classic segmentation workflow wrapper for structure Cardio TTN 27 | 28 | Parameter: 29 | ----------- 30 | struct_img: np.ndarray 31 | the 3D image to be segmented 32 | rescale_ratio: float 33 | an optional parameter to allow rescale the image before running the 34 | segmentation functions, default is no rescaling 35 | output_type: str 36 | select how to handle output. Currently, four types are supported: 37 | 1. default: the result will be saved at output_path whose filename is 38 | original name without extention + "_struct_segmentaiton.tiff" 39 | 2. array: the segmentation result will be simply returned as a numpy array 40 | 3. array_with_contour: segmentation result will be returned together with 41 | the contour of the segmentation 42 | 4. customize: pass in an extra output_func to do a special save. All the 43 | intermediate results, names of these results, the output_path, and the 44 | original filename (without extension) will be passed in to output_func. 45 | """ 46 | ########################################################################## 47 | # PARAMETERS: 48 | # note that these parameters are supposed to be fixed for the structure 49 | # and work well accross different datasets 50 | 51 | intensity_norm_param = [8, 15.5] 52 | vesselness_sigma = [1] 53 | vesselness_cutoff = 0.02 54 | minArea = 15 55 | ########################################################################## 56 | 57 | out_img_list = [] 58 | out_name_list = [] 59 | 60 | ################### 61 | # PRE_PROCESSING 62 | ################### 63 | # intenisty normalization (min/max) 64 | struct_img = intensity_normalization(struct_img, scaling_param=intensity_norm_param) 65 | 66 | out_img_list.append(struct_img.copy()) 67 | out_name_list.append("im_norm") 68 | 69 | # rescale if needed 70 | if rescale_ratio > 0: 71 | struct_img = zoom(struct_img, (1, rescale_ratio, rescale_ratio), order=2) 72 | 73 | struct_img = (struct_img - struct_img.min() + 1e-8) / (struct_img.max() - struct_img.min() + 1e-8) 74 | 75 | # smoothing with gaussian filter 76 | structure_img_smooth = edge_preserving_smoothing_3d(struct_img) 77 | 78 | out_img_list.append(structure_img_smooth.copy()) 79 | out_name_list.append("im_smooth") 80 | 81 | ################### 82 | # core algorithm 83 | ################### 84 | 85 | # vesselness 3d 86 | response = vesselness3D(structure_img_smooth, sigmas=vesselness_sigma, tau=1, whiteonblack=True) 87 | bw = response > vesselness_cutoff 88 | 89 | ################### 90 | # POST-PROCESSING 91 | ################### 92 | seg = remove_small_objects(bw > 0, min_size=minArea, connectivity=1) 93 | 94 | # output 95 | seg = seg > 0 96 | seg = seg.astype(np.uint8) 97 | seg[seg > 0] = 255 98 | 99 | out_img_list.append(seg.copy()) 100 | out_name_list.append("bw_final") 101 | 102 | if output_type == "default": 103 | # the default final output, simply save it to the output path 104 | save_segmentation(seg, False, Path(output_path), fn) 105 | elif output_type == "customize": 106 | # the hook for passing in a customized output function 107 | # use "out_img_list" and "out_name_list" in your hook to 108 | # customize your output functions 109 | output_func(out_img_list, out_name_list, Path(output_path), fn) 110 | elif output_type == "array": 111 | return seg 112 | elif output_type == "array_with_contour": 113 | return (seg, generate_segmentation_contour(seg)) 114 | else: 115 | raise NotImplementedError("invalid output type: {output_type}") 116 | -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper/seg_h2b_interphase.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from typing import Union 3 | from pathlib import Path 4 | from aicssegmentation.core.pre_processing_utils import ( 5 | intensity_normalization, 6 | edge_preserving_smoothing_3d, 7 | ) 8 | from aicssegmentation.core.seg_dot import dot_2d_slice_by_slice_wrapper 9 | from skimage.morphology import remove_small_objects 10 | from aicssegmentation.core.output_utils import ( 11 | save_segmentation, 12 | generate_segmentation_contour, 13 | ) 14 | from scipy.ndimage import zoom 15 | 16 | 17 | def Workflow_h2b_interphase( 18 | struct_img: np.ndarray, 19 | rescale_ratio: float = -1, 20 | output_type: str = "default", 21 | output_path: Union[str, Path] = None, 22 | fn: Union[str, Path] = None, 23 | output_func=None, 24 | ): 25 | """ 26 | classic segmentation workflow wrapper for structure H2B 27 | 28 | Parameter: 29 | ----------- 30 | struct_img: np.ndarray 31 | the 3D image to be segmented 32 | rescale_ratio: float 33 | an optional parameter to allow rescale the image before running the 34 | segmentation functions, default is no rescaling 35 | output_type: str 36 | select how to handle output. Currently, four types are supported: 37 | 1. default: the result will be saved at output_path whose filename is 38 | original name without extention + "_struct_segmentaiton.tiff" 39 | 2. array: the segmentation result will be simply returned as a numpy array 40 | 3. array_with_contour: segmentation result will be returned together with 41 | the contour of the segmentation 42 | 4. customize: pass in an extra output_func to do a special save. All the 43 | intermediate results, names of these results, the output_path, and the 44 | original filename (without extension) will be passed in to output_func. 45 | """ 46 | ########################################################################## 47 | # PARAMETERS: 48 | # note that these parameters are supposed to be fixed for the structure 49 | # and work well accross different datasets 50 | 51 | intensity_norm_param = [1.0, 14] 52 | s2_param = [[1, 0.014], [2, 0.039]] 53 | minArea = 3 54 | ########################################################################## 55 | 56 | out_img_list = [] 57 | out_name_list = [] 58 | 59 | ################### 60 | # PRE_PROCESSING 61 | ################### 62 | # intenisty normalization (min/max) 63 | struct_img = intensity_normalization(struct_img, scaling_param=intensity_norm_param) 64 | 65 | out_img_list.append(struct_img.copy()) 66 | out_name_list.append("im_norm") 67 | 68 | # rescale if needed 69 | if rescale_ratio > 0: 70 | struct_img = zoom(struct_img, (1, rescale_ratio, rescale_ratio), order=2) 71 | 72 | struct_img = (struct_img - struct_img.min() + 1e-8) / (struct_img.max() - struct_img.min() + 1e-8) 73 | 74 | # smoothing with gaussian filter 75 | structure_img_smooth = edge_preserving_smoothing_3d(struct_img) 76 | 77 | out_img_list.append(structure_img_smooth.copy()) 78 | out_name_list.append("im_smooth") 79 | 80 | ################### 81 | # core algorithm 82 | ################### 83 | 84 | bw = dot_2d_slice_by_slice_wrapper(structure_img_smooth, s2_param) 85 | 86 | ################### 87 | # POST-PROCESSING 88 | ################### 89 | seg = remove_small_objects(bw > 0, min_size=minArea, connectivity=1) 90 | 91 | # output 92 | seg = seg > 0 93 | seg = seg.astype(np.uint8) 94 | seg[seg > 0] = 255 95 | 96 | out_img_list.append(seg.copy()) 97 | out_name_list.append("bw_final") 98 | 99 | if output_type == "default": 100 | # the default final output, simply save it to the output path 101 | save_segmentation(seg, False, Path(output_path), fn) 102 | elif output_type == "customize": 103 | # the hook for passing in a customized output function 104 | # use "out_img_list" and "out_name_list" in your hook to 105 | # customize your output functions 106 | output_func(out_img_list, out_name_list, Path(output_path), fn) 107 | elif output_type == "array": 108 | return seg 109 | elif output_type == "array_with_contour": 110 | return (seg, generate_segmentation_contour(seg)) 111 | else: 112 | raise NotImplementedError("invalid output type: {output_type}") 113 | -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper/seg_myh10.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from typing import Union 3 | from pathlib import Path 4 | from skimage.morphology import remove_small_objects 5 | from aicssegmentation.core.pre_processing_utils import ( 6 | intensity_normalization, 7 | edge_preserving_smoothing_3d, 8 | ) 9 | from aicssegmentation.core.vessel import vesselness3D 10 | from aicssegmentation.core.output_utils import ( 11 | save_segmentation, 12 | generate_segmentation_contour, 13 | ) 14 | from scipy.ndimage import zoom 15 | 16 | 17 | def Workflow_myh10( 18 | struct_img: np.ndarray, 19 | rescale_ratio: float = -1, 20 | output_type: str = "default", 21 | output_path: Union[str, Path] = None, 22 | fn: Union[str, Path] = None, 23 | output_func=None, 24 | ): 25 | """ 26 | classic segmentation workflow wrapper for structure MYH10 27 | 28 | Parameter: 29 | ----------- 30 | struct_img: np.ndarray 31 | the 3D image to be segmented 32 | rescale_ratio: float 33 | an optional parameter to allow rescale the image before running the 34 | segmentation functions, default is no rescaling 35 | output_type: str 36 | select how to handle output. Currently, four types are supported: 37 | 1. default: the result will be saved at output_path whose filename is 38 | original name without extention + "_struct_segmentaiton.tiff" 39 | 2. array: the segmentation result will be simply returned as a numpy array 40 | 3. array_with_contour: segmentation result will be returned together with 41 | the contour of the segmentation 42 | 4. customize: pass in an extra output_func to do a special save. All the 43 | intermediate results, names of these results, the output_path, and the 44 | original filename (without extension) will be passed in to output_func. 45 | """ 46 | ########################################################################## 47 | # PARAMETERS: 48 | # note that these parameters are supposed to be fixed for the structure 49 | # and work well accross different datasets 50 | 51 | intensity_norm_param = [2.5, 17] 52 | vesselness_sigma_1 = [2] 53 | vesselness_cutoff_1 = 0.2 54 | vesselness_sigma_2 = [1] 55 | vesselness_cutoff_2 = 0.015 56 | minArea = 16 57 | ########################################################################## 58 | 59 | out_img_list = [] 60 | out_name_list = [] 61 | 62 | ################### 63 | # PRE_PROCESSING 64 | ################### 65 | # intenisty normalization 66 | struct_img = intensity_normalization(struct_img, scaling_param=intensity_norm_param) 67 | 68 | out_img_list.append(struct_img.copy()) 69 | out_name_list.append("im_norm") 70 | 71 | # rescale if needed 72 | if rescale_ratio > 0: 73 | struct_img = zoom(struct_img, (1, rescale_ratio, rescale_ratio), order=2) 74 | 75 | struct_img = (struct_img - struct_img.min() + 1e-8) / (struct_img.max() - struct_img.min() + 1e-8) 76 | 77 | # smoothing 78 | structure_img_smooth = edge_preserving_smoothing_3d(struct_img) 79 | 80 | out_img_list.append(structure_img_smooth.copy()) 81 | out_name_list.append("im_smooth") 82 | 83 | ################### 84 | # core algorithm 85 | ################### 86 | 87 | # vesselness 3d 88 | response_1 = vesselness3D(structure_img_smooth, sigmas=vesselness_sigma_1, tau=1, whiteonblack=True) 89 | response_2 = vesselness3D(structure_img_smooth, sigmas=vesselness_sigma_2, tau=1, whiteonblack=True) 90 | bw = np.logical_or(response_1 > vesselness_cutoff_1, response_2 > vesselness_cutoff_2) 91 | 92 | ################### 93 | # POST-PROCESSING 94 | ################### 95 | seg = remove_small_objects(bw, min_size=minArea, connectivity=1) 96 | 97 | # output 98 | seg = seg > 0 99 | seg = seg.astype(np.uint8) 100 | seg[seg > 0] = 255 101 | 102 | out_img_list.append(seg.copy()) 103 | out_name_list.append("bw_final") 104 | 105 | if output_type == "default": 106 | # the default final output, simply save it to the output path 107 | save_segmentation(seg, False, Path(output_path), fn) 108 | elif output_type == "customize": 109 | # the hook for passing in a customized output function 110 | # use "out_img_list" and "out_name_list" in your hook to 111 | # customize your output functions 112 | output_func(out_img_list, out_name_list, Path(output_path), fn) 113 | elif output_type == "array": 114 | return seg 115 | elif output_type == "array_with_contour": 116 | return (seg, generate_segmentation_contour(seg)) 117 | else: 118 | raise NotImplementedError("invalid output type: {output_type}") 119 | -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper/seg_smc1a.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from typing import Union 3 | from pathlib import Path 4 | from aicssegmentation.core.pre_processing_utils import ( 5 | intensity_normalization, 6 | edge_preserving_smoothing_3d, 7 | ) 8 | from aicssegmentation.core.seg_dot import dot_2d_slice_by_slice_wrapper 9 | from skimage.morphology import remove_small_objects 10 | from aicssegmentation.core.output_utils import ( 11 | save_segmentation, 12 | generate_segmentation_contour, 13 | ) 14 | from scipy.ndimage import zoom 15 | 16 | 17 | def Workflow_smc1a( 18 | struct_img: np.ndarray, 19 | rescale_ratio: float = -1, 20 | output_type: str = "default", 21 | output_path: Union[str, Path] = None, 22 | fn: Union[str, Path] = None, 23 | output_func=None, 24 | ): 25 | """ 26 | classic segmentation workflow wrapper for structure SMC1A 27 | 28 | Parameter: 29 | ----------- 30 | struct_img: np.ndarray 31 | the 3D image to be segmented 32 | rescale_ratio: float 33 | an optional parameter to allow rescale the image before running the 34 | segmentation functions, default is no rescaling 35 | output_type: str 36 | select how to handle output. Currently, four types are supported: 37 | 1. default: the result will be saved at output_path whose filename is 38 | original name without extention + "_struct_segmentaiton.tiff" 39 | 2. array: the segmentation result will be simply returned as a numpy array 40 | 3. array_with_contour: segmentation result will be returned together with 41 | the contour of the segmentation 42 | 4. customize: pass in an extra output_func to do a special save. All the 43 | intermediate results, names of these results, the output_path, and the 44 | original filename (without extension) will be passed in to output_func. 45 | """ 46 | ########################################################################## 47 | # PARAMETERS: 48 | # note that these parameters are supposed to be fixed for the structure 49 | # and work well accross different datasets 50 | 51 | intensity_norm_param = [2.5, 12] 52 | s2_param = [[1, 0.06]] 53 | minArea = 3 54 | ########################################################################## 55 | 56 | out_img_list = [] 57 | out_name_list = [] 58 | 59 | ################### 60 | # PRE_PROCESSING 61 | ################### 62 | # intenisty normalization (min/max) 63 | struct_img = intensity_normalization(struct_img, scaling_param=intensity_norm_param) 64 | 65 | out_img_list.append(struct_img.copy()) 66 | out_name_list.append("im_norm") 67 | 68 | # rescale if needed 69 | if rescale_ratio > 0: 70 | struct_img = zoom(struct_img, (1, rescale_ratio, rescale_ratio), order=2) 71 | 72 | struct_img = (struct_img - struct_img.min() + 1e-8) / (struct_img.max() - struct_img.min() + 1e-8) 73 | 74 | # smoothing with gaussian filter 75 | structure_img_smooth = edge_preserving_smoothing_3d(struct_img) 76 | 77 | out_img_list.append(structure_img_smooth.copy()) 78 | out_name_list.append("im_smooth") 79 | 80 | ################### 81 | # core algorithm 82 | ################### 83 | 84 | bw = dot_2d_slice_by_slice_wrapper(structure_img_smooth, s2_param) 85 | 86 | ################### 87 | # POST-PROCESSING 88 | ################### 89 | seg = remove_small_objects(bw > 0, min_size=minArea, connectivity=1) 90 | 91 | # output 92 | seg = seg > 0 93 | seg = seg.astype(np.uint8) 94 | seg[seg > 0] = 255 95 | 96 | out_img_list.append(seg.copy()) 97 | out_name_list.append("bw_final") 98 | 99 | if output_type == "default": 100 | # the default final output, simply save it to the output path 101 | save_segmentation(seg, False, Path(output_path), fn) 102 | elif output_type == "customize": 103 | # the hook for passing in a customized output function 104 | # use "out_img_list" and "out_name_list" in your hook to 105 | # customize your output functions 106 | output_func(out_img_list, out_name_list, Path(output_path), fn) 107 | elif output_type == "array": 108 | return seg 109 | elif output_type == "array_with_contour": 110 | return (seg, generate_segmentation_contour(seg)) 111 | else: 112 | raise NotImplementedError("invalid output type: {output_type}") 113 | -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper/seg_template.py: -------------------------------------------------------------------------------- 1 | # flake8: noqa 2 | # ##### import functions #### 3 | 4 | # ### do not remove #### 5 | from typing import Union 6 | from pathlib import Path 7 | import numpy as np 8 | from aicssegmentation.core.output_utils import ( 9 | save_segmentation, 10 | generate_segmentation_contour, 11 | ) 12 | 13 | 14 | def Workflow_template( 15 | struct_img: np.ndarray, 16 | rescale_ratio: float = -1, 17 | output_type: str = "default", 18 | output_path: Union[str, Path] = None, 19 | fn: Union[str, Path] = None, 20 | output_func=None, 21 | ): 22 | """ 23 | classic segmentation workflow wrapper tempalte 24 | 25 | Parameter: 26 | ----------- 27 | struct_img: np.ndarray 28 | the 3D image to be segmented 29 | rescale_ratio: float 30 | an optional parameter to allow rescale the image before running the 31 | segmentation functions, default is no rescaling 32 | output_type: str 33 | select how to handle output. Currently, four types are supported: 34 | 1. default: the result will be saved at output_path whose filename is 35 | original name without extention + "_struct_segmentaiton.tiff" 36 | 2. array: the segmentation result will be simply returned as a numpy array 37 | 3. array_with_contour: segmentation result will be returned together with 38 | the contour of the segmentation 39 | 4. customize: pass in an extra output_func to do a special save. All the 40 | intermediate results, names of these results, the output_path, and the 41 | original filename (without extension) will be passed in to output_func. 42 | """ 43 | 44 | ########################################################################## 45 | # PARAMETERS: 46 | 47 | ########################################################################## 48 | 49 | ################### 50 | # PRE_PROCESSING 51 | # make sure the variable name of original image is 'struct_img' 52 | ################### 53 | # intenisty normalization 54 | 55 | # smoothing 56 | 57 | ################### 58 | # core algorithm 59 | ################### 60 | 61 | ################### 62 | # POST-PROCESSING 63 | # make sure the variable name of final segmentation is 'seg' 64 | ################### 65 | 66 | ########################################################################## 67 | # ## no need to change below 68 | ########################################################################## 69 | # output 70 | seg = struct_img 71 | seg = seg > 0 72 | seg = seg.astype(np.uint8) 73 | seg[seg > 0] = 255 74 | 75 | if output_type == "default": 76 | # the default final output 77 | save_segmentation(seg, False, output_path, fn) 78 | elif output_type == "array": 79 | return seg 80 | elif output_type == "array_with_contour": 81 | return (seg, generate_segmentation_contour(seg)) 82 | else: 83 | print("your can implement your output hook here, but not yet") 84 | quit() 85 | -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper/seg_tuba1b.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from typing import Union 3 | from pathlib import Path 4 | from aicssegmentation.core.vessel import vesselness3D 5 | from aicssegmentation.core.pre_processing_utils import ( 6 | intensity_normalization, 7 | edge_preserving_smoothing_3d, 8 | ) 9 | from skimage.morphology import remove_small_objects 10 | from aicssegmentation.core.output_utils import ( 11 | save_segmentation, 12 | generate_segmentation_contour, 13 | ) 14 | from scipy.ndimage import zoom 15 | 16 | 17 | def Workflow_tuba1b( 18 | struct_img: np.ndarray, 19 | rescale_ratio: float = -1, 20 | output_type: str = "default", 21 | output_path: Union[str, Path] = None, 22 | fn: Union[str, Path] = None, 23 | output_func=None, 24 | ): 25 | """ 26 | classic segmentation workflow wrapper for structure TUBA1B 27 | 28 | Parameter: 29 | ----------- 30 | struct_img: np.ndarray 31 | the 3D image to be segmented 32 | rescale_ratio: float 33 | an optional parameter to allow rescale the image before running the 34 | segmentation functions, default is no rescaling 35 | output_type: str 36 | select how to handle output. Currently, four types are supported: 37 | 1. default: the result will be saved at output_path whose filename is 38 | original name without extention + "_struct_segmentaiton.tiff" 39 | 2. array: the segmentation result will be simply returned as a numpy array 40 | 3. array_with_contour: segmentation result will be returned together with 41 | the contour of the segmentation 42 | 4. customize: pass in an extra output_func to do a special save. All the 43 | intermediate results, names of these results, the output_path, and the 44 | original filename (without extension) will be passed in to output_func. 45 | """ 46 | ########################################################################## 47 | ########################################################################## 48 | # PARAMETERS: 49 | # note that these parameters are supposed to be fixed for the structure 50 | # and work well accross different datasets 51 | 52 | intensity_norm_param = [1.5, 8.0] 53 | vesselness_sigma = [1] 54 | vesselness_cutoff = 0.01 55 | minArea = 20 56 | ########################################################################## 57 | 58 | out_img_list = [] 59 | out_name_list = [] 60 | 61 | ################### 62 | # PRE_PROCESSING 63 | ################### 64 | # intenisty normalization (min/max) 65 | struct_img = intensity_normalization(struct_img, scaling_param=intensity_norm_param) 66 | 67 | out_img_list.append(struct_img.copy()) 68 | out_name_list.append("im_norm") 69 | 70 | # rescale if needed 71 | if rescale_ratio > 0: 72 | struct_img = zoom(struct_img, (1, rescale_ratio, rescale_ratio), order=2) 73 | 74 | struct_img = (struct_img - struct_img.min() + 1e-8) / (struct_img.max() - struct_img.min() + 1e-8) 75 | 76 | # smoothing with boundary preserving smoothing 77 | structure_img_smooth = edge_preserving_smoothing_3d(struct_img) 78 | 79 | out_img_list.append(structure_img_smooth.copy()) 80 | out_name_list.append("im_smooth") 81 | 82 | ################### 83 | # core algorithm 84 | ################### 85 | 86 | # vesselness 3d 87 | response = vesselness3D(structure_img_smooth, sigmas=vesselness_sigma, tau=1, whiteonblack=True) 88 | bw = response > vesselness_cutoff 89 | 90 | ################### 91 | # POST-PROCESSING 92 | ################### 93 | seg = remove_small_objects(bw > 0, min_size=minArea, connectivity=1) 94 | 95 | # output 96 | seg = seg > 0 97 | seg = seg.astype(np.uint8) 98 | seg[seg > 0] = 255 99 | 100 | out_img_list.append(seg.copy()) 101 | out_name_list.append("bw_final") 102 | 103 | if output_type == "default": 104 | # the default final output, simply save it to the output path 105 | save_segmentation(seg, False, Path(output_path), fn) 106 | elif output_type == "customize": 107 | # the hook for passing in a customized output function 108 | # use "out_img_list" and "out_name_list" in your hook to 109 | # customize your output functions 110 | output_func(out_img_list, out_name_list, Path(output_path), fn) 111 | elif output_type == "array": 112 | return seg 113 | elif output_type == "array_with_contour": 114 | return (seg, generate_segmentation_contour(seg)) 115 | else: 116 | raise NotImplementedError("invalid output type: {output_type}") 117 | -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper/structure_segmenter.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | import logging 3 | import numpy as np 4 | 5 | # Defaults cloned from existing ../bin/batch_processing script 6 | DEFAULT_MODULE_PATH = "aicssegmentation.structure_wrapper.seg_" 7 | DEFAULT_RESCALE_RATIO = -1 8 | 9 | 10 | class StructureSegmenter: 11 | def __init__(self): 12 | self.log = logging.getLogger(__name__) 13 | 14 | def process_img( 15 | self, 16 | gene: str, 17 | image: np.array, 18 | rescale_ratio=DEFAULT_RESCALE_RATIO, 19 | module_path=DEFAULT_MODULE_PATH, 20 | ) -> (np.array, np.array): 21 | lower_gene = gene.lower() 22 | module_name = module_path + lower_gene 23 | try: 24 | logging.info(f"loading module {module_name}") 25 | seg_module = importlib.import_module(module_name) 26 | function_name = "Workflow_" + lower_gene 27 | logging.info("getting function " + function_name) 28 | SegModuleFunction = getattr(seg_module, function_name) 29 | except Exception as e: 30 | logging.error(f"raising failure while trying to get module/function for {module_name}") 31 | raise e 32 | try: 33 | logging.info("executing") 34 | (array_val, countour_val) = SegModuleFunction( 35 | struct_img=image, 36 | rescale_ratio=rescale_ratio, 37 | output_type="array_with_contour", 38 | output_path=None, # these args are used when the output 39 | fn=None, 40 | ) # is a file 41 | return (array_val, countour_val) 42 | except Exception as e: 43 | logging.error("raising failure in dispatch for process_img") 44 | raise e 45 | -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/structure_wrapper_config/__init__.py -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_actb.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "function": "intensity_normalization", 4 | "category": "preprocessing", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 3, 8 | 15 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "function": "edge_preserving_smoothing", 15 | "category": "preprocessing", 16 | "parent": 1 17 | }, 18 | "3": { 19 | "function": "filament_filter_3D", 20 | "category": "core", 21 | "parameter_values": { 22 | "sigmas": [ 23 | 2 24 | ], 25 | "cutoff": 0.1 26 | }, 27 | "parent": 2 28 | }, 29 | "4": { 30 | "function": "filament_filter_3D", 31 | "category": "core", 32 | "parameter_values": { 33 | "sigmas": [ 34 | 1 35 | ], 36 | "cutoff": 0.04 37 | }, 38 | "parent": 2 39 | }, 40 | "5": { 41 | "function": "merge_segmentation", 42 | "category": "core", 43 | "parent": [ 44 | 3, 45 | 4 46 | ] 47 | }, 48 | "6": { 49 | "function": "size_filter", 50 | "category": "postprocessing", 51 | "parameter_values": { 52 | "min_size": 15, 53 | "method": "3D" 54 | }, 55 | "parent": 5 56 | } 57 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_actn1.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "function": "intensity_normalization", 4 | "category": "preprocessing", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 3, 8 | 15 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "function": "edge_preserving_smoothing", 15 | "category": "preprocessing", 16 | "parent": 1 17 | }, 18 | "3": { 19 | "function": "filament_filter_3D", 20 | "category": "core", 21 | "parameter_values": { 22 | "sigmas": [ 23 | 2 24 | ], 25 | "cutoff": 0.15 26 | }, 27 | "parent": 2 28 | }, 29 | "4": { 30 | "function": "filament_filter_3D", 31 | "category": "core", 32 | "parameter_values": { 33 | "sigmas": [ 34 | 1 35 | ], 36 | "cutoff": 0.05 37 | }, 38 | "parent": 2 39 | }, 40 | "5": { 41 | "function": "merge_segmentation", 42 | "category": "core", 43 | "parent": [ 44 | 3, 45 | 4 46 | ] 47 | }, 48 | "6": { 49 | "function": "size_filter", 50 | "category": "postprocessing", 51 | "parameter_values": { 52 | "min_size": 5, 53 | "method": "3D" 54 | }, 55 | "parent": 5 56 | } 57 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_atp2a2.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "function": "intensity_normalization", 4 | "category": "preprocessing", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 2.5, 8 | 9.0 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "function": "edge_preserving_smoothing", 15 | "category": "preprocessing", 16 | "parent": 1 17 | }, 18 | "3": { 19 | "function": "filament_filter_slice_by_slice", 20 | "category": "core", 21 | "parameter_values": { 22 | "sigmas": [ 23 | 1 24 | ], 25 | "cutoff": 0.25 26 | }, 27 | "parent": 2 28 | }, 29 | "4": { 30 | "function": "size_filter", 31 | "category": "postprocessing", 32 | "parameter_values": { 33 | "min_size": 15, 34 | "method": "3D" 35 | }, 36 | "parent": 3 37 | } 38 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_cetn2.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "function": "intensity_normalization_with_bound", 4 | "category": "preprocessing", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 12, 8 | 160, 9 | 300, 10 | 2000 11 | ] 12 | }, 13 | "parent": 0 14 | }, 15 | "2": { 16 | "function": "intensity_normalization_min_max_with_bound", 17 | "category": "preprocessing", 18 | "parameter_values": { 19 | "scaling_param": [ 20 | 5000 21 | ] 22 | }, 23 | "parent": 0 24 | }, 25 | "3": { 26 | "function": "gaussian_smoothing_slice_by_slice", 27 | "category": "preprocessing", 28 | "parameter_values": { 29 | "sigma": 1 30 | }, 31 | "parent": 1 32 | }, 33 | "4": { 34 | "function": "spot_filter_3D", 35 | "category": "core", 36 | "parameter_values": { 37 | "log_sigma": 1, 38 | "cutoff": 0.04 39 | }, 40 | "parent": 3 41 | }, 42 | "5": { 43 | "function": "size_filter", 44 | "category": "core", 45 | "parameter_values": { 46 | "min_size": 3, 47 | "method": "3D" 48 | }, 49 | "parent": 4 50 | }, 51 | "6": { 52 | "function": "find_local_maxima", 53 | "category": "core", 54 | "parent": [ 55 | 2, 56 | 5 57 | ] 58 | }, 59 | "7": { 60 | "function": "watershed_for_cutting", 61 | "category": "core", 62 | "parent": [ 63 | 5, 64 | 6 65 | ] 66 | }, 67 | "8": { 68 | "function": "size_filter", 69 | "category": "postprocessing", 70 | "parameter_values": { 71 | "min_size": 3, 72 | "method": "3D" 73 | }, 74 | "parent": 7 75 | } 76 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_ctnnb1.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 4, 8 | 27 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "gaussian_smoothing_3D", 16 | "parameter_values": { 17 | "sigma": 1 18 | }, 19 | "parent": 1 20 | }, 21 | "3": { 22 | "category": "core", 23 | "function": "spot_filter_slice_by_slice", 24 | "parameter_values": { 25 | "log_sigma": 1.5, 26 | "cutoff": 0.01 27 | }, 28 | "parent": 2 29 | }, 30 | "4": { 31 | "category": "postprocessing", 32 | "function": "size_filter", 33 | "parent": 3, 34 | "parameter_values": { 35 | "min_size": 10, 36 | "method": "3D" 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_dsp.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization_min_max_with_bound", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 8000 8 | ] 9 | }, 10 | "parent": 0 11 | }, 12 | "2": { 13 | "category": "preprocessing", 14 | "function": "gaussian_smoothing_slice_by_slice", 15 | "parameter_values": { 16 | "sigma": 1 17 | }, 18 | "parent": 1 19 | }, 20 | "3": { 21 | "category": "core", 22 | "function": "spot_filter_3D", 23 | "parameter_values": { 24 | "log_sigma": 1, 25 | "cutoff": 0.012 26 | }, 27 | "parent": 2 28 | }, 29 | "4": { 30 | "category": "core", 31 | "function": "size_filter", 32 | "parameter_values": { 33 | "min_size": 4, 34 | "method": "3D" 35 | }, 36 | "parent": 3 37 | }, 38 | "5": { 39 | "category": "core", 40 | "function": "find_local_maxima", 41 | "parent": [ 42 | 1, 43 | 4 44 | ] 45 | }, 46 | "6": { 47 | "category": "core", 48 | "function": "watershed_for_cutting", 49 | "parent": [ 50 | 4, 51 | 5 52 | ] 53 | }, 54 | "7": { 55 | "category": "postprocessing", 56 | "function": "size_filter", 57 | "parameter_values": { 58 | "min_size": 4, 59 | "method": "3D" 60 | }, 61 | "parent": 6 62 | } 63 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_fbl.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 0.5, 8 | 18 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "gaussian_smoothing_3D", 16 | "parameter_values": { 17 | "sigma": 1 18 | }, 19 | "parent": 1 20 | }, 21 | "3": { 22 | "category": "core", 23 | "function": "masked_object_treshold_low_level", 24 | "parameter_values": { 25 | "global_thresh_method": "ave_tri_med", 26 | "object_minArea": 700, 27 | "dilate": false 28 | }, 29 | "parent": 2 30 | }, 31 | "4": { 32 | "category": "core", 33 | "function": "masked_object_treshold_high_level", 34 | "parameter_values": { 35 | "extra_criteria": false, 36 | "local_adjust": 1.0 37 | }, 38 | "parent": [ 39 | 2, 40 | 3 41 | ] 42 | }, 43 | "5": { 44 | "category": "core", 45 | "function": "spot_filter_slice_by_slice", 46 | "parameter_values": { 47 | "log_sigma": 1, 48 | "cutoff": 0.01 49 | }, 50 | "parent": 2 51 | }, 52 | "6": { 53 | "category": "core", 54 | "function": "size_filter", 55 | "parameter_values": { 56 | "min_size": 5, 57 | "method": "3D" 58 | }, 59 | "parent": 5 60 | }, 61 | "7": { 62 | "category": "core", 63 | "function": "merge_segmentation", 64 | "parent": [ 65 | 4, 66 | 6 67 | ] 68 | }, 69 | "8": { 70 | "category": "postprocessing", 71 | "function": "size_filter", 72 | "parameter_values": { 73 | "min_size": 5, 74 | "method": "3D" 75 | }, 76 | "parent": 7 77 | } 78 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_gja1.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 1, 8 | 40 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "gaussian_smoothing_slice_by_slice", 16 | "parameter_values": { 17 | "sigma": 1 18 | }, 19 | "parent": 1 20 | }, 21 | "3": { 22 | "category": "core", 23 | "function": "spot_filter_3D", 24 | "parameter_values": { 25 | "log_sigma": 1, 26 | "cutoff": 0.031 27 | }, 28 | "parent": 2 29 | }, 30 | "4": { 31 | "category": "postprocessing", 32 | "function": "size_filter", 33 | "parent": 3, 34 | "parameter_values": { 35 | "min_size": 5, 36 | "method": "3D" 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_h2b_interphase.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 1.0, 8 | 14 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "edge_preserving_smoothing", 16 | "parent": 1 17 | }, 18 | "3": { 19 | "category": "core", 20 | "function": "spot_filter_slice_by_slice", 21 | "parameter_values": { 22 | "log_sigma": 1, 23 | "cutoff": 0.014 24 | }, 25 | "parent": 2 26 | }, 27 | "4": { 28 | "category": "core", 29 | "function": "spot_filter_slice_by_slice", 30 | "parameter_values": { 31 | "log_sigma": 2, 32 | "cutoff": 0.039 33 | }, 34 | "parent": 2 35 | }, 36 | "5": { 37 | "category": "core", 38 | "function": "merge_segmentation", 39 | "parent": [ 40 | 3, 41 | 4 42 | ] 43 | }, 44 | "6": { 45 | "category": "postprocessing", 46 | "function": "size_filter", 47 | "parent": 5, 48 | "parameter_values": { 49 | "min_size": 3, 50 | "method": "3D" 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_lamp1.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 3, 8 | 19 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "gaussian_smoothing_slice_by_slice", 16 | "parameter_values": { 17 | "sigma": 1 18 | }, 19 | "parent": 1 20 | }, 21 | "3": { 22 | "category": "core", 23 | "function": "filament_filter_slice_by_slice", 24 | "parameter_values": { 25 | "sigmas": [ 26 | 1 27 | ], 28 | "cutoff": 0.15 29 | }, 30 | "parent": 2 31 | }, 32 | "4": { 33 | "category": "core", 34 | "function": "spot_filter_slice_by_slice", 35 | "parameter_values": { 36 | "log_sigma": 5, 37 | "cutoff": 0.09 38 | }, 39 | "parent": 2 40 | }, 41 | "5": { 42 | "category": "core", 43 | "function": "spot_filter_slice_by_slice", 44 | "parameter_values": { 45 | "log_sigma": 2.5, 46 | "cutoff": 0.07 47 | }, 48 | "parent": 2 49 | }, 50 | "6": { 51 | "category": "core", 52 | "function": "spot_filter_slice_by_slice", 53 | "parameter_values": { 54 | "log_sigma": 1, 55 | "cutoff": 0.01 56 | }, 57 | "parent": 2 58 | }, 59 | "7": { 60 | "category": "core", 61 | "function": "merge_segmentation", 62 | "parent": [ 63 | 3, 64 | 4, 65 | 5, 66 | 6 67 | ] 68 | }, 69 | "8": { 70 | "category": "postprocessing", 71 | "function": "hole_filling", 72 | "parameter_values": { 73 | "hole_min": 0, 74 | "hole_max": 1600, 75 | "fill_2d": true 76 | }, 77 | "parent": 7 78 | }, 79 | "9": { 80 | "category": "postprocessing", 81 | "function": "size_filter", 82 | "parent": 8, 83 | "parameter_values": { 84 | "min_size": 15, 85 | "method": "3D" 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_lmnb1_interphase.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization_min_max_with_bound", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 4000 8 | ] 9 | }, 10 | "parent": 0 11 | }, 12 | "2": { 13 | "category": "preprocessing", 14 | "function": "gaussian_smoothing_3D", 15 | "parameter_values": { 16 | "sigma": 1 17 | }, 18 | "parent": 1 19 | }, 20 | "3": { 21 | "category": "core", 22 | "function": "filament_filter_slice_by_slice", 23 | "parameter_values": { 24 | "sigmas": [ 25 | 1 26 | ], 27 | "cutoff": 0.01 28 | }, 29 | "parent": 2 30 | }, 31 | "4": { 32 | "category": "core", 33 | "function": "filament_filter_slice_by_slice", 34 | "parameter_values": { 35 | "sigmas": [ 36 | 2 37 | ], 38 | "cutoff": 0.01 39 | }, 40 | "parent": 2 41 | }, 42 | "5": { 43 | "category": "core", 44 | "function": "filament_filter_slice_by_slice", 45 | "parameter_values": { 46 | "sigmas": [ 47 | 3 48 | ], 49 | "cutoff": 0.01 50 | }, 51 | "parent": 2 52 | }, 53 | "6": { 54 | "category": "core", 55 | "function": "merge_segmentation", 56 | "parent": [ 57 | 3, 58 | 4, 59 | 5 60 | ] 61 | }, 62 | "7": { 63 | "category": "core", 64 | "function": "generate_seeding_image", 65 | "parameter_values": { 66 | "area_min": 400, 67 | "area_max": 40000, 68 | "bg_seed": true 69 | }, 70 | "parent": [ 71 | 2, 72 | 6 73 | ] 74 | }, 75 | "8": { 76 | "category": "core", 77 | "function": "watershed_for_segmentation", 78 | "parameter_values": { 79 | "watershed_line": true 80 | }, 81 | "parent": [ 82 | 1, 83 | 7 84 | ] 85 | }, 86 | "9": { 87 | "category": "core", 88 | "function": "remove_index_object", 89 | "parent": 8 90 | }, 91 | "10": { 92 | "category": "postprocessing", 93 | "function": "extract_boundary_of_objects", 94 | "parent": 9, 95 | "parameter_values": { 96 | "connectivity": 1, 97 | "mode": "thick" 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_lmnb1_mitotic.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization_min_max_with_bound", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 4000 8 | ] 9 | }, 10 | "parent": 0 11 | }, 12 | "2": { 13 | "category": "preprocessing", 14 | "function": "gaussian_smoothing_3D", 15 | "parameter_values": { 16 | "sigma": 1 17 | }, 18 | "parent": 1 19 | }, 20 | "3": { 21 | "category": "core", 22 | "function": "filament_filter_slice_by_slice", 23 | "parameter_values": { 24 | "sigmas": [ 25 | 0.5 26 | ], 27 | "cutoff": 0.01 28 | }, 29 | "parent": 2 30 | }, 31 | "4": { 32 | "category": "postprocessing", 33 | "function": "size_filter", 34 | "parent": 3, 35 | "parameter_values": { 36 | "min_size": 5, 37 | "method": "3D" 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_myh10.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 2.5, 8 | 17 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "edge_preserving_smoothing", 16 | "parent": 1 17 | }, 18 | "3": { 19 | "category": "core", 20 | "function": "filament_filter_3D", 21 | "parameter_values": { 22 | "sigmas": [ 23 | 2 24 | ], 25 | "cutoff": 0.2 26 | }, 27 | "parent": 2 28 | }, 29 | "4": { 30 | "category": "core", 31 | "function": "filament_filter_3D", 32 | "parameter_values": { 33 | "sigmas": [ 34 | 1 35 | ], 36 | "cutoff": 0.015 37 | }, 38 | "parent": 2 39 | }, 40 | "5": { 41 | "category": "core", 42 | "function": "merge_segmentation", 43 | "parent": [ 44 | 3, 45 | 4 46 | ] 47 | }, 48 | "6": { 49 | "category": "postprocessing", 50 | "function": "size_filter", 51 | "parameter_values": { 52 | "min_size": 16, 53 | "method": "3D" 54 | }, 55 | "parent": 5 56 | } 57 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_npm1.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 0.5, 8 | 15 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "gaussian_smoothing_3D", 16 | "parameter_values": { 17 | "sigma": 1 18 | }, 19 | "parent": 1 20 | }, 21 | "3": { 22 | "category": "core", 23 | "function": "masked_object_treshold_low_level", 24 | "parameter_values": { 25 | "global_thresh_method": "ave_tri_med", 26 | "object_minArea": 700, 27 | "dilate": true 28 | }, 29 | "parent": 2 30 | }, 31 | "4": { 32 | "category": "core", 33 | "function": "masked_object_treshold_high_level", 34 | "parameter_values": { 35 | "extra_criteria": true, 36 | "local_adjust": 0.98 37 | }, 38 | "parent": [ 39 | 2, 40 | 3 41 | ] 42 | }, 43 | "5": { 44 | "category": "core", 45 | "function": "spot_filter_slice_by_slice", 46 | "parameter_values": { 47 | "log_sigma": 2, 48 | "cutoff": 0.025 49 | }, 50 | "parent": 2 51 | }, 52 | "6": { 53 | "category": "core", 54 | "function": "invert_image", 55 | "parent": 2 56 | }, 57 | "7": { 58 | "category": "core", 59 | "function": "spot_filter_slice_by_slice", 60 | "parameter_values": { 61 | "log_sigma": 2, 62 | "cutoff": 0.025 63 | }, 64 | "parent": 6 65 | }, 66 | "8": { 67 | "category": "core", 68 | "function": "spot_filter_slice_by_slice", 69 | "parameter_values": { 70 | "log_sigma": 1, 71 | "cutoff": 0.025 72 | }, 73 | "parent": 6 74 | }, 75 | "9": { 76 | "category": "core", 77 | "function": "merge_segmentation", 78 | "parent": [ 79 | 7, 80 | 8 81 | ] 82 | }, 83 | "10": { 84 | "category": "core", 85 | "function": "invert_image", 86 | "parent": 3 87 | }, 88 | "11": { 89 | "category": "core", 90 | "function": "mask_image", 91 | "parameter_values": { 92 | "value": 0 93 | }, 94 | "parent": [ 95 | 5, 96 | 10 97 | ] 98 | }, 99 | "12": { 100 | "category": "core", 101 | "function": "merge_segmentation", 102 | "parent": [ 103 | 11, 104 | 4 105 | ] 106 | }, 107 | "13": { 108 | "category": "core", 109 | "function": "mask_image", 110 | "parameter_values": { 111 | "value": 0 112 | }, 113 | "parent": [ 114 | 12, 115 | 9 116 | ] 117 | }, 118 | "14": { 119 | "category": "postprocessing", 120 | "function": "size_filter", 121 | "parameter_values": { 122 | "min_size": 5, 123 | "method": "3D" 124 | }, 125 | "parent": 13 126 | } 127 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_nup153.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 1, 8 | 13.5 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "edge_preserving_smoothing", 16 | "parent": 1 17 | }, 18 | "3": { 19 | "category": "core", 20 | "function": "spot_filter_3D", 21 | "parameter_values": { 22 | "log_sigma": 1, 23 | "cutoff": 0.07 24 | }, 25 | "parent": 2 26 | }, 27 | "4": { 28 | "category": "postprocessing", 29 | "function": "size_filter", 30 | "parent": 3, 31 | "parameter_values": { 32 | "min_size": 7, 33 | "method": "3D" 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_pxn.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 11, 8 | 8 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "edge_preserving_smoothing", 16 | "parent": 1 17 | }, 18 | "3": { 19 | "category": "core", 20 | "function": "filament_filter_3D", 21 | "parameter_values": { 22 | "sigmas": [ 23 | 1 24 | ], 25 | "cutoff": 0.35 26 | }, 27 | "parent": 2 28 | }, 29 | "4": { 30 | "category": "postprocessing", 31 | "function": "size_filter", 32 | "parameter_values": { 33 | "min_size": 4, 34 | "method": "slice_by_slice" 35 | }, 36 | "parent": 3 37 | }, 38 | "5": { 39 | "category": "postprocessing", 40 | "function": "size_filter", 41 | "parameter_values": { 42 | "min_size": 15, 43 | "method": "3D" 44 | }, 45 | "parent": 4 46 | }, 47 | "6": { 48 | "category": "postprocessing", 49 | "function": "prune_z_slices", 50 | "parent": 5 51 | } 52 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_rab5a.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization_min_max_with_bound", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 1000 8 | ] 9 | }, 10 | "parent": 0 11 | }, 12 | "2": { 13 | "category": "preprocessing", 14 | "function": "gaussian_smoothing_slice_by_slice", 15 | "parameter_values": { 16 | "sigma": 1 17 | }, 18 | "parent": 1 19 | }, 20 | "3": { 21 | "category": "core", 22 | "function": "spot_filter_3D", 23 | "parameter_values": { 24 | "log_sigma": 1, 25 | "cutoff": 0.03 26 | }, 27 | "parent": 2 28 | }, 29 | "4": { 30 | "category": "postprocessing", 31 | "function": "hole_filling", 32 | "parameter_values": { 33 | "hole_min": 0, 34 | "hole_max": 81, 35 | "fill_2d": true 36 | }, 37 | "parent": 3 38 | }, 39 | "5": { 40 | "category": "postprocessing", 41 | "function": "size_filter", 42 | "parent": 4, 43 | "parameter_values": { 44 | "min_size": 3, 45 | "method": "3D" 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_sec61b.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 2.5, 8 | 7.5 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "edge_preserving_smoothing", 16 | "parent": 1 17 | }, 18 | "3": { 19 | "category": "core", 20 | "function": "filament_filter_slice_by_slice", 21 | "parameter_values": { 22 | "sigmas": [ 23 | 1 24 | ], 25 | "cutoff": 0.15 26 | }, 27 | "parent": 2 28 | }, 29 | "4": { 30 | "category": "postprocessing", 31 | "function": "size_filter", 32 | "parent": 3, 33 | "parameter_values": { 34 | "min_size": 15, 35 | "method": "3D" 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_slc25a17.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 2, 8 | 36 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "gaussian_smoothing_slice_by_slice", 16 | "parameter_values": { 17 | "sigma": 1 18 | }, 19 | "parent": 1 20 | }, 21 | "3": { 22 | "category": "core", 23 | "function": "spot_filter_3D", 24 | "parameter_values": { 25 | "log_sigma": 1, 26 | "cutoff": 0.045 27 | }, 28 | "parent": 2 29 | }, 30 | "4": { 31 | "category": "core", 32 | "function": "size_filter", 33 | "parameter_values": { 34 | "min_size": 3, 35 | "method": "3D" 36 | }, 37 | "parent": 3 38 | }, 39 | "5": { 40 | "category": "core", 41 | "function": "find_local_maxima", 42 | "parent": [ 43 | 1, 44 | 4 45 | ] 46 | }, 47 | "6": { 48 | "category": "core", 49 | "function": "watershed_for_cutting", 50 | "parent": [ 51 | 4, 52 | 5 53 | ] 54 | }, 55 | "7": { 56 | "category": "postprocessing", 57 | "function": "size_filter", 58 | "parameter_values": { 59 | "min_size": 3, 60 | "method": "3D" 61 | }, 62 | "parent": 6 63 | } 64 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_smc1a.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 2.5, 8 | 12 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "edge_preserving_smoothing", 16 | "parent": 1 17 | }, 18 | "3": { 19 | "category": "core", 20 | "function": "spot_filter_3D", 21 | "parameter_values": { 22 | "log_sigma": 1, 23 | "cutoff": 0.06 24 | }, 25 | "parent": 2 26 | }, 27 | "4": { 28 | "category": "postprocessing", 29 | "function": "size_filter", 30 | "parent": 3, 31 | "parameter_values": { 32 | "min_size": 3, 33 | "method": "3D" 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_son.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 2, 8 | 30 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "edge_preserving_smoothing", 16 | "parent": 1 17 | }, 18 | "3": { 19 | "category": "core", 20 | "function": "filament_filter_3D", 21 | "parameter_values": { 22 | "sigmas": [ 23 | 1.2 24 | ], 25 | "cutoff": 0.15 26 | }, 27 | "parent": 2 28 | }, 29 | "4": { 30 | "category": "core", 31 | "function": "spot_filter_3D", 32 | "parameter_values": { 33 | "log_sigma": 3, 34 | "cutoff": 0.2 35 | }, 36 | "parent": 2 37 | }, 38 | "5": { 39 | "category": "core", 40 | "function": "spot_filter_3D", 41 | "parameter_values": { 42 | "log_sigma": 1.15, 43 | "cutoff": 0.07 44 | }, 45 | "parent": 2 46 | }, 47 | "6": { 48 | "category": "core", 49 | "function": "spot_filter_3D", 50 | "parameter_values": { 51 | "log_sigma": 1.15, 52 | "cutoff": 0.03 53 | }, 54 | "parent": 2 55 | }, 56 | "7": { 57 | "category": "core", 58 | "function": "spot_filter_3D", 59 | "parameter_values": { 60 | "log_sigma": 1.15, 61 | "cutoff": 0.02 62 | }, 63 | "parent": 2 64 | }, 65 | "8": { 66 | "category": "core", 67 | "function": "size_filter", 68 | "parent": 6, 69 | "parameter_values": { 70 | "min_size": 150, 71 | "method": "3D" 72 | } 73 | }, 74 | "9": { 75 | "category": "core", 76 | "function": "segmentation_xor", 77 | "parent": [ 78 | 7, 79 | 8 80 | ] 81 | }, 82 | "10": { 83 | "category": "core", 84 | "function": "merge_segmentation", 85 | "parent": [ 86 | 3, 87 | 4, 88 | 5, 89 | 9 90 | ] 91 | }, 92 | "11": { 93 | "category": "postprocessing", 94 | "function": "size_filter", 95 | "parent": 10, 96 | "parameter_values": { 97 | "min_size": 15, 98 | "method": "3D" 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_st6gal1.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 9, 8 | 19 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "gaussian_smoothing_3D", 16 | "parameter_values": { 17 | "sigma": 1 18 | }, 19 | "parent": 1 20 | }, 21 | "3": { 22 | "category": "core", 23 | "function": "masked_object_treshold_low_level", 24 | "parameter_values": { 25 | "global_thresh_method": "triangle", 26 | "object_minArea": 1200, 27 | "dilate": true 28 | }, 29 | "parent": 2 30 | }, 31 | "4": { 32 | "category": "core", 33 | "function": "masked_object_treshold_high_level", 34 | "parameter_values": { 35 | "extra_criteria": false, 36 | "local_adjust": 0.98 37 | }, 38 | "parent": [ 39 | 2, 40 | 3 41 | ] 42 | }, 43 | "5": { 44 | "category": "core", 45 | "function": "topology_preserving_thinning", 46 | "parameter_values": { 47 | "min_thickness": 1.6, 48 | "thin": 1 49 | }, 50 | "parent": 4 51 | }, 52 | "6": { 53 | "category": "core", 54 | "function": "spot_filter_3D", 55 | "parameter_values": { 56 | "log_sigma": 1.6, 57 | "cutoff": 0.02 58 | }, 59 | "parent": 2 60 | }, 61 | "7": { 62 | "category": "core", 63 | "function": "merge_segmentation", 64 | "parent": [ 65 | 5, 66 | 6 67 | ] 68 | }, 69 | "8": { 70 | "category": "postprocessing", 71 | "function": "size_filter", 72 | "parent": 7, 73 | "parameter_values": { 74 | "min_size": 10, 75 | "method": "3D" 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_tjp1.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 3, 8 | 17 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "gaussian_smoothing_3D", 16 | "parameter_values": { 17 | "sigma": 1 18 | }, 19 | "parent": 1 20 | }, 21 | "3": { 22 | "category": "core", 23 | "function": "filament_filter_3D", 24 | "parameter_values": { 25 | "sigmas": [ 26 | 1.5 27 | ], 28 | "cutoff": 0.2 29 | }, 30 | "parent": 2 31 | }, 32 | "4": { 33 | "category": "postprocessing", 34 | "function": "size_filter", 35 | "parent": 3, 36 | "parameter_values": { 37 | "min_size": 15, 38 | "method": "3D" 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_tomm20.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 3.5, 8 | 15 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "gaussian_smoothing_3D", 16 | "parameter_values": { 17 | "sigma": 1 18 | }, 19 | "parent": 1 20 | }, 21 | "3": { 22 | "category": "core", 23 | "function": "filament_filter_slice_by_slice", 24 | "parameter_values": { 25 | "sigmas": [ 26 | 1.5 27 | ], 28 | "cutoff": 0.16 29 | }, 30 | "parent": 2 31 | }, 32 | "4": { 33 | "category": "postprocessing", 34 | "function": "size_filter", 35 | "parent": 3, 36 | "parameter_values": { 37 | "min_size": 10, 38 | "method": "3D" 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /aicssegmentation/structure_wrapper_config/conf_tuba1b.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "category": "preprocessing", 4 | "function": "intensity_normalization", 5 | "parameter_values": { 6 | "scaling_param": [ 7 | 1.5, 8 | 8.0 9 | ] 10 | }, 11 | "parent": 0 12 | }, 13 | "2": { 14 | "category": "preprocessing", 15 | "function": "edge_preserving_smoothing", 16 | "parent": 1 17 | }, 18 | "3": { 19 | "category": "core", 20 | "function": "filament_filter_3D", 21 | "parameter_values": { 22 | "sigmas": [ 23 | 1 24 | ], 25 | "cutoff": 0.01 26 | }, 27 | "parent": 2 28 | }, 29 | "4": { 30 | "category": "postprocessing", 31 | "function": "size_filter", 32 | "parent": 3, 33 | "parameter_values": { 34 | "min_size": 20, 35 | "method": "3D" 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /aicssegmentation/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """Unit test package for aicssegmentation.""" 4 | -------------------------------------------------------------------------------- /aicssegmentation/tests/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from pathlib import Path 4 | 5 | 6 | @pytest.fixture 7 | def resources_dir() -> Path: 8 | return Path(__file__).parent / "resources" 9 | -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_actb_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_actb_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_actn1_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_actn1_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_atp2a2_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_atp2a2_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_cardio_actn2_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_cardio_actn2_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_cardio_atp2a2_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_cardio_atp2a2_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_cardio_fbl_100x_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_cardio_fbl_100x_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_cardio_fbl_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_cardio_fbl_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_cardio_myl7_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_cardio_myl7_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_cardio_npm1_100x_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_cardio_npm1_100x_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_cardio_npm1_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_cardio_npm1_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_cardio_tnni1_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_cardio_tnni1_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_cardio_ttn_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_cardio_ttn_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_cetn2_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_cetn2_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_ctnnb1_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_ctnnb1_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_drug_npm1_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_drug_npm1_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_dsp_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_dsp_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_fbl_labelfree_4dn_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_fbl_labelfree_4dn_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_fbl_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_fbl_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_gja1_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_gja1_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_h2b_interphase_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_h2b_interphase_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_lamp1_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_lamp1_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_lmnb1_interphase_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_lmnb1_interphase_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_lmnb1_mitotic_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_lmnb1_mitotic_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_myh10_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_myh10_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_npm1_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_npm1_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_npm_labelfree_4dn_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_npm_labelfree_4dn_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_nup153_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_nup153_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_pxn_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_pxn_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_rab5a_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_rab5a_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_sec61b_dual_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_sec61b_dual_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_sec61b_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_sec61b_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_slc25a17_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_slc25a17_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_smc1a_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_smc1a_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_son_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_son_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_st6gal1_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_st6gal1_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_terf2_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_terf2_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_tjp1_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_tjp1_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_tomm20_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_tomm20_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_tuba1b_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_tuba1b_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/expected_ubtf_struct_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/expected_ubtf_struct_segmentation.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/resources/images/random_input.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/resources/images/random_input.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/test_config.py: -------------------------------------------------------------------------------- 1 | import json 2 | from aicssegmentation.util.directories import Directories 3 | 4 | 5 | class TestConfig: 6 | def test_category_definition(self): 7 | json_list = sorted(Directories.get_structure_config_dir().glob("conf_*.json")) 8 | for workflow_config in json_list: 9 | with open(workflow_config, "r") as read_file: 10 | cfg = json.load(read_file) 11 | for step in cfg: 12 | assert "category" in cfg[step], f"Step {step} in {workflow_config} needs a category." 13 | 14 | def test_configs_match_all_functions(self): 15 | with open(Directories.get_structure_config_dir() / "all_functions.json") as all_fctns_file: 16 | all_functions = json.load(all_fctns_file) 17 | 18 | json_list = sorted(Directories.get_structure_config_dir().glob("conf_*.json")) 19 | 20 | for workflow_config in json_list: 21 | with open(workflow_config, "r") as read_file: 22 | cfg = json.load(read_file) 23 | for step in cfg: 24 | function_key = cfg[step]["function"] 25 | 26 | # outside packages are not included in all_functions.json 27 | # if "aicssegmentation" not in cfg[step]["module"]: 28 | # continue 29 | 30 | # all functions used in configs must be defined in all_functions.json 31 | assert ( 32 | function_key in all_functions.keys() 33 | ), f'Func "{function_key}" in {workflow_config} is not in all_functions' 34 | 35 | # check that the parameters in the config file match the parameters 36 | # required in all_functions.json 37 | reference_parameters = all_functions[function_key]["parameters"] 38 | if "parameter_values" in cfg[step]: 39 | for param in cfg[step]["parameter_values"]: 40 | assert param in reference_parameters.keys(), ( 41 | f'Parameter "{param}" in {workflow_config} is' f"not defined for function {function_key}" 42 | ) 43 | -------------------------------------------------------------------------------- /aicssegmentation/tests/test_structures.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | import numpy as np 3 | import pytest 4 | 5 | from aicsimageio import imread 6 | from pathlib import Path 7 | from aicsimageio.writers import OmeTiffWriter 8 | 9 | AGREE_THRESH = 0.997 10 | 11 | DEFAULT_MODULE_PATH = "aicssegmentation.structure_wrapper.seg_" 12 | 13 | ALL_STRUCTURE_NAMES = [ 14 | "actb", 15 | "actn1", 16 | "atp2a2", 17 | "cardio_actn2", 18 | "cardio_atp2a2", 19 | "cardio_fbl", 20 | "cardio_fbl_100x", 21 | "cardio_myl7", 22 | "cardio_npm1", 23 | "cardio_npm1_100x", 24 | "cardio_tnni1", 25 | "cardio_ttn", 26 | "cetn2", 27 | "ctnnb1", 28 | "drug_npm1", 29 | "dsp", 30 | "fbl", 31 | "fbl_labelfree_4dn", 32 | "gja1", 33 | "h2b_interphase", 34 | "lamp1", 35 | # 'lmnb1_interphase', 36 | "lmnb1_mitotic", 37 | "myh10", 38 | "npm1", 39 | # 'npm1_SR', 40 | "npm_labelfree_4dn", 41 | "nup153", 42 | "pxn", 43 | "rab5a", 44 | "sec61b", 45 | "sec61b_dual", 46 | "slc25a17", 47 | "smc1a", 48 | "son", 49 | "st6gal1", 50 | "tjp1", 51 | "tomm20", 52 | "tuba1b", 53 | "ubtf", 54 | ] 55 | 56 | IMG_SCALING = {"cetn2": 5100} 57 | 58 | BASE_IMAGE_DIM = (128, 128, 128) 59 | RESCALE_RATIO = 0.7 60 | TEST_IMG_DIR = Path(__file__).parent / "resources" / "images" 61 | 62 | 63 | def create_random_source_image(): 64 | random_array = np.random.rand(*BASE_IMAGE_DIM) 65 | 66 | # write numpy array to .tiff file 67 | OmeTiffWriter.save(data=random_array, uri=TEST_IMG_DIR / "random_input.tiff") 68 | 69 | 70 | def create_all_test_images(): 71 | # create random input image to base segmentations on 72 | create_random_source_image() 73 | for structure_name in ALL_STRUCTURE_NAMES: 74 | print("Creating expected image for", structure_name, "...") 75 | run_segmentation(structure_name, "default") 76 | 77 | 78 | def run_segmentation(structure_name: str, output_type: str = "default"): 79 | # load structure wrapper for specified structure 80 | structure_name = structure_name.lower() 81 | module_name = DEFAULT_MODULE_PATH + structure_name 82 | try: 83 | seg_module = importlib.import_module(module_name) 84 | function_name = "Workflow_" + structure_name 85 | SegModuleFunction = getattr(seg_module, function_name) 86 | except Exception as e: 87 | print(f"raising failure while trying to get module/function for {module_name}") 88 | raise e 89 | 90 | # load stock random image 91 | random_array = imread(TEST_IMG_DIR / "random_input.tiff").reshape(*BASE_IMAGE_DIM) 92 | random_array *= IMG_SCALING.get(structure_name, 1) 93 | 94 | # conduct segmentation 95 | output_array = SegModuleFunction( 96 | struct_img=random_array, 97 | rescale_ratio=RESCALE_RATIO, 98 | output_type=output_type, 99 | output_path=TEST_IMG_DIR, 100 | fn="expected_" + structure_name, 101 | ) 102 | return output_array 103 | 104 | 105 | @pytest.mark.parametrize("structure_name", ALL_STRUCTURE_NAMES) 106 | def test_all_structures(structure_name): 107 | print("Testing", structure_name, "...") 108 | 109 | structure_name = structure_name.lower() 110 | # segment stock random image with current semgentation versions 111 | output_array = run_segmentation(structure_name, output_type="array").ravel() 112 | 113 | # get rid of STC dimensions from AICSImage format, resized to resize_ratio 114 | expected_output = imread(TEST_IMG_DIR / f"expected_{structure_name}_struct_segmentation.tiff").ravel() 115 | 116 | assert np.mean(np.isclose(output_array, expected_output)) > AGREE_THRESH, ( 117 | "Tested and expected outputs differ for " + structure_name 118 | ) 119 | -------------------------------------------------------------------------------- /aicssegmentation/tests/workflow/__init__.py: -------------------------------------------------------------------------------- 1 | # List of all structures supported by the configurable workflow engine 2 | # (used by several tests) 3 | # Update this list if support is added for new structures 4 | SUPPORTED_STRUCTURE_NAMES = [ 5 | "actb", 6 | "actn1", 7 | "atp2a2", 8 | "cetn2", 9 | "ctnnb1", 10 | "dsp", 11 | "fbl", 12 | "gja1", 13 | "h2b_interphase", 14 | "lamp1", 15 | "lmnb1_interphase", 16 | "lmnb1_mitotic", 17 | "myh10", 18 | "npm1", 19 | "nup153", 20 | "pxn", 21 | "rab5a", 22 | "sec61b", 23 | "slc25a17", 24 | "smc1a", 25 | "son", 26 | "st6gal1", 27 | "tjp1", 28 | "tomm20", 29 | "tuba1b", 30 | ] 31 | -------------------------------------------------------------------------------- /aicssegmentation/tests/workflow/mock_module.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | import numpy as np 3 | 4 | 5 | def function_single_input(img: np.ndarray): 6 | if img is None: 7 | raise ValueError("img") 8 | return 1 9 | 10 | 11 | def function_single_input_with_parameters(img: np.ndarray, x: int, y: int): 12 | if img is None: 13 | raise ValueError("img") 14 | return x + y 15 | 16 | 17 | def function_list_input(img: List[np.ndarray]): 18 | if img is None: 19 | raise ValueError("img") 20 | return 1 21 | 22 | 23 | def function_list_input_with_parameters(img: List[np.ndarray], x: int, y: int): 24 | if img is None: 25 | raise ValueError("img") 26 | return x + y 27 | -------------------------------------------------------------------------------- /aicssegmentation/tests/workflow/resources/test/test.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/tests/workflow/resources/test/test.tiff -------------------------------------------------------------------------------- /aicssegmentation/tests/workflow/test_all_workflows.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from aicsimageio import imread 4 | from aicssegmentation.workflow import WorkflowEngine 5 | from . import SUPPORTED_STRUCTURE_NAMES 6 | 7 | 8 | IMG_SCALING = {"cetn2": 5100} 9 | 10 | 11 | class TestAllWorkflows: 12 | def setup_method(self): 13 | self._workflow_engine = WorkflowEngine() 14 | 15 | @pytest.mark.parametrize("workflow_name", SUPPORTED_STRUCTURE_NAMES) 16 | def test_execute_all_workflows(self, workflow_name, resources_dir): 17 | # Arrange 18 | img_path = resources_dir / "images" / "random_input.tiff" 19 | random_array = imread(img_path).reshape(*(128, 128, 128)) 20 | random_array *= IMG_SCALING.get(workflow_name, 1) 21 | 22 | workflow = self._workflow_engine.get_executable_workflow(workflow_name, random_array) 23 | 24 | # Act 25 | workflow.execute_all() 26 | 27 | # Assert 28 | assert workflow.get_next_step() is None 29 | assert workflow.is_done() 30 | -------------------------------------------------------------------------------- /aicssegmentation/tests/workflow/test_batch_workflow.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pytest 3 | 4 | from unittest import mock 5 | from aicsimageio.writers.ome_tiff_writer import OmeTiffWriter 6 | from pathlib import Path 7 | from aicsimageio import AICSImage 8 | from numpy import random 9 | from aicssegmentation.workflow.batch_workflow import BatchWorkflow 10 | from aicssegmentation.workflow.workflow_config import WorkflowConfig 11 | 12 | 13 | @pytest.fixture 14 | def batch_workflow(tmp_path: Path): 15 | input_dir = tmp_path / "input" 16 | output_dir = tmp_path / "output" 17 | input_dir.mkdir(parents=True, exist_ok=True) 18 | output_dir.mkdir(parents=True, exist_ok=True) 19 | 20 | for i in range(0, 10): 21 | three_d_image = np.zeros((10, 100, 100)) 22 | OmeTiffWriter.save(data=three_d_image, uri=input_dir / f"test{i}.tiff", dim_order="ZYX") 23 | 24 | definition = WorkflowConfig().get_workflow_definition("sec61b") 25 | return BatchWorkflow(definition, input_dir, output_dir, channel_index=0) 26 | 27 | 28 | class TestBatchWorkflow: 29 | def test_format_image_to_3d(self, batch_workflow: BatchWorkflow): 30 | three_d_image = AICSImage(random.random((2, 3, 4)), dim_order="ZYX") 31 | 32 | assert len(batch_workflow._format_image_to_3d(three_d_image).shape) == 3 33 | 34 | def test_format_image_to_3d_timeseries(self, batch_workflow: BatchWorkflow): 35 | image = AICSImage(np.ones((5, 1, 10, 100, 100)), dim_order="TCZYX") 36 | with pytest.raises(ValueError): 37 | batch_workflow._format_image_to_3d(image) 38 | 39 | def test_format_image_to_3d_multiscene(self, batch_workflow: BatchWorkflow): 40 | # Two scenes 41 | image = AICSImage([np.ones((5, 1, 10, 100, 100)), np.ones((5, 1, 10, 100, 100))], known_dims="TCZYX") 42 | with pytest.raises(ValueError): 43 | batch_workflow._format_image_to_3d(image) 44 | 45 | @mock.patch("aicssegmentation.workflow.batch_workflow.Workflow.execute_all") 46 | def test_process_all(self, mock_workflow_execute_all, batch_workflow: BatchWorkflow): 47 | # Arrange 48 | mock_workflow_execute_all.return_value = np.zeros((10, 100, 100)) 49 | 50 | # Act 51 | batch_workflow.execute_all() 52 | 53 | # Assert 54 | assert batch_workflow.output_dir.exists() 55 | batch_workflow.output_dir.joinpath("log.txt").exists() 56 | assert len(list(batch_workflow.output_dir.glob("*.tiff"))) == 10 57 | -------------------------------------------------------------------------------- /aicssegmentation/tests/workflow/test_workflow.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from aicssegmentation.workflow.workflow import Workflow 4 | from aicssegmentation.workflow.workflow_config import WorkflowConfig 5 | from skimage import data 6 | 7 | 8 | class TestWorkflow: 9 | def setup_method(self): 10 | self._fake_image = np.asarray(data.astronaut()) 11 | definition = WorkflowConfig().get_workflow_definition("sec61b") # TODO use mock workflow 12 | self._workflow = Workflow(definition, self._fake_image) 13 | 14 | def test_step_by_step_workflow_sec61b(self): 15 | assert self._workflow.get_result(0) is None 16 | assert np.array_equal(self._fake_image, self._workflow.get_most_recent_result()) 17 | assert self._workflow.get_next_step().step_number == 1 18 | 19 | image1 = self._workflow.execute_next() 20 | assert self._workflow.get_next_step().step_number == 2 21 | assert np.array_equal(image1, self._workflow.get_most_recent_result()) 22 | assert np.array_equal(image1, self._workflow.get_result(0)) 23 | 24 | image2 = self._workflow.execute_next() 25 | assert self._workflow.get_next_step().step_number == 3 26 | assert np.array_equal(image2, self._workflow.get_most_recent_result()) 27 | assert np.array_equal(image2, self._workflow.get_result(1)) 28 | 29 | image3 = self._workflow.execute_next() 30 | assert self._workflow.get_next_step().step_number == 4 31 | assert np.array_equal(image3, self._workflow.get_most_recent_result()) 32 | assert np.array_equal(image3, self._workflow.get_result(2)) 33 | 34 | image4 = self._workflow.execute_next() 35 | assert self._workflow.get_next_step() is None 36 | assert np.array_equal(image4, self._workflow.get_most_recent_result()) 37 | assert np.array_equal(image4, self._workflow.get_result(3)) 38 | 39 | assert self._workflow.is_done() 40 | 41 | def test_execute_all_sec61b(self): 42 | self._workflow.execute_all() 43 | assert self._workflow.get_next_step() is None 44 | assert self._workflow.is_done() 45 | -------------------------------------------------------------------------------- /aicssegmentation/tests/workflow/test_workflow_config.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import json 3 | 4 | from pathlib import Path 5 | from aicssegmentation.workflow.workflow_config import WorkflowConfig 6 | from aicssegmentation.util.directories import Directories 7 | from aicssegmentation.workflow.workflow_definition import WorkflowDefinition, PrebuiltWorkflowDefinition 8 | from . import SUPPORTED_STRUCTURE_NAMES 9 | 10 | 11 | class TestWorkflowConfig: 12 | def setup_method(self): 13 | self._workflow_config = WorkflowConfig() 14 | 15 | def test_get_available_workflows(self): 16 | workflows = self._workflow_config.get_available_workflows() 17 | assert workflows == SUPPORTED_STRUCTURE_NAMES 18 | 19 | def test_get_all_functions(self): 20 | functions = self._workflow_config.get_all_functions() 21 | 22 | assert functions is not None 23 | assert len(functions) > 0 24 | 25 | @pytest.mark.parametrize("name", [None, "", " "]) 26 | def test_get_workflow_definition_empty_name_fails(self, name): 27 | with pytest.raises(ValueError): 28 | workflow_def = self._workflow_config.get_workflow_definition(name) 29 | 30 | def test_get_workflow_definition_unavailable_workflow_fails(self): 31 | with pytest.raises(ValueError): 32 | workflow_def = self._workflow_config.get_workflow_definition("unsupported workflow") 33 | 34 | @pytest.mark.parametrize("name", SUPPORTED_STRUCTURE_NAMES) 35 | def test_get_workflow_definition(self, name): 36 | workflow_def = self._workflow_config.get_workflow_definition(name) 37 | assert isinstance(workflow_def, PrebuiltWorkflowDefinition) 38 | assert workflow_def.name == name 39 | 40 | def test_get_workflow_definition_from_config_file(self): 41 | path = Directories.get_structure_config_dir() / "conf_actb.json" 42 | workflow_def = self._workflow_config.get_workflow_definition_from_config_file(path) 43 | assert isinstance(workflow_def, WorkflowDefinition) 44 | assert workflow_def.name == "conf_actb.json" 45 | 46 | @pytest.mark.parametrize("name", SUPPORTED_STRUCTURE_NAMES) 47 | def test_save_workflow_definition_as_json(self, name, tmp_path: Path): 48 | # Arrange 49 | workflow_config_path = Directories.get_structure_config_dir() / f"conf_{name}.json" 50 | expected_json = json.dumps(json.load(open(workflow_config_path, "r")), sort_keys=True) 51 | actb_workflow_def = self._workflow_config.get_workflow_definition_from_config_file(workflow_config_path) 52 | 53 | # Act 54 | output_path = tmp_path / "test_output.json" 55 | self._workflow_config.save_workflow_definition_as_json(actb_workflow_def, output_path) 56 | result = json.dumps(json.load(open(output_path, "r")), sort_keys=True) 57 | 58 | # Assert 59 | assert result == expected_json 60 | -------------------------------------------------------------------------------- /aicssegmentation/tests/workflow/test_workflow_definition.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from aicssegmentation.workflow.workflow_definition import PrebuiltWorkflowDefinition 4 | from . import SUPPORTED_STRUCTURE_NAMES 5 | 6 | 7 | class TestWorkflowDefinition: 8 | @pytest.mark.parametrize("workflow_name", SUPPORTED_STRUCTURE_NAMES) 9 | def test_all_thumbnails(self, workflow_name: str): 10 | definition = PrebuiltWorkflowDefinition(name=workflow_name, steps=list()) 11 | assert definition.thumbnail_pre is not None 12 | assert len(definition.thumbnail_pre.shape) >= 2 13 | assert definition.thumbnail_post is not None 14 | assert len(definition.thumbnail_post.shape) >= 2 15 | 16 | @pytest.mark.parametrize("workflow_name", SUPPORTED_STRUCTURE_NAMES) 17 | def test_all_diagrams(self, workflow_name: str): 18 | definition = PrebuiltWorkflowDefinition(name=workflow_name, steps=list()) 19 | assert definition.diagram_image is not None 20 | assert len(definition.diagram_image.shape) >= 2 21 | -------------------------------------------------------------------------------- /aicssegmentation/tests/workflow/test_workflow_engine.py: -------------------------------------------------------------------------------- 1 | from aicssegmentation.exceptions import ArgumentNullError 2 | from aicssegmentation.workflow.workflow import Workflow 3 | import pytest 4 | import numpy as np 5 | 6 | from unittest.mock import MagicMock, create_autospec 7 | from aicssegmentation.workflow.workflow_config import WorkflowConfig 8 | from aicssegmentation.workflow.workflow_engine import WorkflowEngine 9 | from aicssegmentation.workflow.workflow_definition import PrebuiltWorkflowDefinition, WorkflowDefinition 10 | from aicssegmentation.util.directories import Directories 11 | 12 | 13 | class TestWorkflowEngine: 14 | expected_workflow_names = ["sec61b", "actn1", "test123"] 15 | expected_workflow_definitions = [ 16 | PrebuiltWorkflowDefinition(name="sec61b", steps=list()), 17 | PrebuiltWorkflowDefinition(name="actn1", steps=list()), 18 | PrebuiltWorkflowDefinition(name="test123", steps=list()), 19 | ] 20 | 21 | def setup_method(self): 22 | self._mock_workflow_config: MagicMock = create_autospec(WorkflowConfig) 23 | self._mock_workflow_config.get_available_workflows.return_value = self.expected_workflow_names 24 | self._mock_workflow_config.get_workflow_definition.side_effect = self.expected_workflow_definitions 25 | self._workflow_engine = WorkflowEngine(self._mock_workflow_config) 26 | 27 | def test_workflow_definitions(self): 28 | assert self._workflow_engine.workflow_definitions == self.expected_workflow_definitions 29 | 30 | def test_get_executable_workflow_null_image_fails(self): 31 | with pytest.raises(ArgumentNullError): 32 | self._workflow_engine.get_executable_workflow("sec61b", None) 33 | 34 | def test_get_executable_workflow_unsupported_workflow_fails(self): 35 | with pytest.raises(ValueError): 36 | self._workflow_engine.get_executable_workflow("unsupported", np.ones((1, 1, 1))) 37 | 38 | @pytest.mark.parametrize("workflow_name", ["sec61b", "actn1", "test123"]) 39 | def test_get_executable_workflow(self, workflow_name): 40 | workflow = self._workflow_engine.get_executable_workflow(workflow_name, np.ones((1, 1, 1))) 41 | assert isinstance(workflow, Workflow) 42 | assert workflow.workflow_definition.name == workflow_name 43 | 44 | def test_get_executable_workflow_from_config_file_null_path_fails(self): 45 | with pytest.raises(ArgumentNullError): 46 | self._workflow_engine.get_executable_workflow_from_config_file(None, np.ones((1, 1, 1))) 47 | 48 | def test_get_executable_workflow_from_config_file_null_image_fails(self): 49 | with pytest.raises(ArgumentNullError): 50 | self._workflow_engine.get_executable_workflow( 51 | Directories.get_structure_config_dir() / "conf_actb.json", None 52 | ) 53 | 54 | @pytest.mark.parametrize( 55 | "path", 56 | [ 57 | Directories.get_structure_config_dir() / "conf_actb.json", 58 | f"{Directories.get_structure_config_dir()}/conf_actb.json", 59 | ], 60 | ) 61 | def test_get_executable_workflow_from_config_file(self, path): 62 | workflow = self._workflow_engine.get_executable_workflow_from_config_file(path, np.ones((1, 1, 1))) 63 | assert isinstance(workflow, Workflow) 64 | 65 | def test_save_workflow_definition(self): 66 | # Arrange 67 | path = "/path/to/workflow.json" 68 | workflow_def = create_autospec(WorkflowDefinition) 69 | 70 | # Act 71 | self._workflow_engine.save_workflow_definition(workflow_def, path) 72 | # Assert 73 | self._mock_workflow_config.save_workflow_definition_as_json.assert_called_once_with(workflow_def, path) 74 | -------------------------------------------------------------------------------- /aicssegmentation/util/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/aicssegmentation/util/__init__.py -------------------------------------------------------------------------------- /aicssegmentation/util/directories.py: -------------------------------------------------------------------------------- 1 | import aicssegmentation 2 | 3 | from pathlib import Path 4 | 5 | 6 | class Directories: 7 | """ 8 | Provides safe paths to common module directories 9 | """ 10 | 11 | _module_base_dir = Path(aicssegmentation.__file__).parent 12 | 13 | @classmethod 14 | def get_assets_dir(cls) -> Path: 15 | """ 16 | Path to the assets directory 17 | """ 18 | return cls._module_base_dir / "assets" 19 | 20 | @classmethod 21 | def get_structure_config_dir(cls) -> Path: 22 | """ 23 | Path to the structure json config directory 24 | """ 25 | return cls._module_base_dir / "structure_wrapper_config" 26 | -------------------------------------------------------------------------------- /aicssegmentation/util/filesystem.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | from typing import Union 3 | 4 | 5 | class FileSystemUtilities: 6 | @staticmethod 7 | def create_directory(path: Union[Path, str]): 8 | """ 9 | Create directory for the given path. This will create all parent directories as needed. 10 | """ 11 | Path(path).mkdir(exist_ok=True, parents=True) 12 | -------------------------------------------------------------------------------- /aicssegmentation/util/lazy.py: -------------------------------------------------------------------------------- 1 | # Lazy evaluation utils 2 | 3 | 4 | def lazy_property(fn): 5 | """ 6 | Decorator: make a lazy-evaluated property 7 | """ 8 | attr_name = "_lazy_" + fn.__name__ 9 | 10 | @property 11 | def _lazy_property(self): 12 | if not hasattr(self, attr_name): 13 | setattr(self, attr_name, fn(self)) 14 | return getattr(self, attr_name) 15 | 16 | return _lazy_property 17 | -------------------------------------------------------------------------------- /aicssegmentation/workflow/__init__.py: -------------------------------------------------------------------------------- 1 | from .segmenter_function import SegmenterFunction, FunctionParameter, WidgetType # noqa F401 2 | from .workflow_step import WorkflowStep, WorkflowStepCategory # noqa F401 3 | from .workflow import Workflow # noqa F401 4 | from .batch_workflow import BatchWorkflow # noqa F401 5 | from .workflow_definition import WorkflowDefinition, PrebuiltWorkflowDefinition # noqa F401 6 | from .workflow_engine import WorkflowEngine # noqa F401 7 | -------------------------------------------------------------------------------- /aicssegmentation/workflow/segmenter_function.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | from dataclasses import dataclass 3 | from typing import Dict, List, Union 4 | 5 | 6 | class WidgetType(Enum): 7 | SLIDER = "slider" 8 | DROPDOWN = "drop-down" 9 | 10 | @staticmethod 11 | def from_str(value: str): 12 | if value is not None: 13 | value = value.lower() 14 | if value == WidgetType.SLIDER.value: 15 | return WidgetType.SLIDER 16 | if value == WidgetType.DROPDOWN.value: 17 | return WidgetType.DROPDOWN 18 | raise NotImplementedError() 19 | 20 | 21 | @dataclass 22 | class FunctionParameter: 23 | """ 24 | Represents an input parameter to a segmenter function 25 | """ 26 | 27 | name: str 28 | widget_type: WidgetType 29 | data_type: str 30 | min_value: Union[int, float] = None 31 | max_value: Union[int, float] = None 32 | increment: Union[int, float] = None 33 | options: List[str] = None 34 | 35 | 36 | @dataclass 37 | class SegmenterFunction: 38 | """ 39 | Represents an aicssegmentation function. 40 | Functions are the smallest executable entity in a workflow and directly map 41 | to a python callable 42 | """ 43 | 44 | name: str 45 | display_name: str 46 | function: str 47 | module: str 48 | parameters: Dict[str, List[FunctionParameter]] = None 49 | -------------------------------------------------------------------------------- /aicssegmentation/workflow/workflow_definition.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from aicsimageio import imread 4 | from typing import List 5 | from dataclasses import dataclass 6 | from aicssegmentation.util.lazy import lazy_property 7 | from aicssegmentation.util.directories import Directories 8 | from .workflow_step import WorkflowStep 9 | 10 | 11 | @dataclass 12 | class WorkflowDefinition: 13 | """ 14 | Definition of a custom aics-segmentation Workflow loaded from file. 15 | 16 | This class only defines the workflow (i.e. the workflow characteristics and steps) 17 | and is used either for building an executable Workflow object 18 | or to access information about the Workflow without needing to execute it 19 | """ 20 | 21 | name: str 22 | steps: List[WorkflowStep] 23 | 24 | def __init__(self, name: str, steps: List[WorkflowStep]): 25 | self.name = name 26 | self.steps = steps 27 | self.from_file = True 28 | 29 | 30 | @dataclass 31 | class PrebuiltWorkflowDefinition(WorkflowDefinition): 32 | """ 33 | Definition of a pre-built(default) aics-segmentation Workflow from our assets. 34 | 35 | This class only defines the workflow (i.e. the workflow characteristics and steps) 36 | and is used either for building an executable Workflow object 37 | or to access information about the Workflow without needing to execute it 38 | """ 39 | 40 | def __init__(self, name: str, steps: List[WorkflowStep]): 41 | WorkflowDefinition.__init__(self, name=name, steps=steps) 42 | 43 | @lazy_property 44 | def thumbnail_pre(self) -> np.ndarray: 45 | """ 46 | The Pre-segmentation thumbnail related to this workflow, as a numpy array 47 | """ 48 | return np.squeeze(imread(Directories.get_assets_dir() / f"thumbnails/{self.name.lower()}_pre.png")) 49 | 50 | @lazy_property 51 | def thumbnail_post(self) -> np.ndarray: 52 | """ 53 | The Post-segmentation thumbnail related to this workflow, as a numpy array 54 | """ 55 | return np.squeeze(imread(Directories.get_assets_dir() / f"thumbnails/{self.name.lower()}_post.png")) 56 | 57 | @lazy_property 58 | def diagram_image(self) -> np.ndarray: 59 | """ 60 | Diagram / flow chart image for this workflow, as a numpy array 61 | """ 62 | return np.squeeze(imread(Directories.get_assets_dir() / f"diagrams/{self.name.lower()}.png")) 63 | -------------------------------------------------------------------------------- /aicssegmentation/workflow/workflow_step.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | import numpy as np 3 | 4 | from dataclasses import dataclass 5 | from enum import Enum 6 | from typing import Dict, List, Any 7 | from .segmenter_function import SegmenterFunction 8 | 9 | 10 | class WorkflowStepCategory(Enum): 11 | PRE_PROCESSING = "preprocessing" 12 | CORE = "core" 13 | POST_PROCESSING = "postprocessing" 14 | 15 | @staticmethod 16 | def from_str(value: str): 17 | if value is not None: 18 | value = value.lower() 19 | if value == WorkflowStepCategory.PRE_PROCESSING.value: 20 | return WorkflowStepCategory.PRE_PROCESSING 21 | if value == WorkflowStepCategory.CORE.value: 22 | return WorkflowStepCategory.CORE 23 | if value == WorkflowStepCategory.POST_PROCESSING.value: 24 | return WorkflowStepCategory.POST_PROCESSING 25 | raise NotImplementedError() 26 | 27 | 28 | @dataclass 29 | class WorkflowStep: 30 | """ 31 | Represents a single step in an aicssegmentation Workflow 32 | """ 33 | 34 | category: WorkflowStepCategory 35 | function: SegmenterFunction 36 | step_number: int 37 | parent: List[int] 38 | parameter_values: Dict[str, List] = None 39 | 40 | @property 41 | def name(self): 42 | return self.function.display_name 43 | 44 | def execute(self, input_images: List[np.ndarray], parameters: Dict[str, Any] = None) -> np.ndarray: 45 | """ 46 | Execute this workflow step on the given input image and return the result. 47 | 48 | Params: 49 | input_images (List[np.ndarray]): List of image inputs to perform this 50 | workflow step on, generally parent image 51 | parameters (Dict): Dictionary of parameters to pass to the 52 | underlying function 53 | 54 | Returns: 55 | self.result (np.ndarray): Result of performing workflow step 56 | on the given image. 57 | """ 58 | if not isinstance(input_images, list): 59 | raise ValueError("input_images must be a list") 60 | 61 | if parameters is not None and not self._check_parameters(parameters): 62 | raise ValueError( 63 | "Provided parameters are invalid. All keys in the parameters dictionary" 64 | "must correspond to existing parameter names defined for the underlying workflow function." 65 | "Note: parameter names are case sensitive" 66 | ) 67 | 68 | py_module = importlib.import_module(self.function.module) 69 | py_function = getattr(py_module, self.function.function) 70 | 71 | try: 72 | # Most functions require unpacking the images 73 | if parameters is not None: 74 | return py_function(*input_images, **parameters) 75 | 76 | return py_function(*input_images) 77 | except TypeError: 78 | # Some functions want it as a list 79 | if parameters is not None: 80 | return py_function(input_images, **parameters) 81 | return py_function(input_images) 82 | 83 | def _check_parameters(self, parameters: Dict[str, Any]) -> bool: 84 | for key in parameters.keys(): 85 | if key not in self.function.parameters.keys(): 86 | return False 87 | 88 | return True 89 | -------------------------------------------------------------------------------- /demo_data/RAB5_demo_data.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/demo_data/RAB5_demo_data.tif -------------------------------------------------------------------------------- /demo_data/TNNI1_demo_data.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/demo_data/TNNI1_demo_data.tif -------------------------------------------------------------------------------- /demo_data/TOM20_demo_data.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/demo_data/TOM20_demo_data.tif -------------------------------------------------------------------------------- /demo_data/TOMM20_pipeline_example_cell_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/demo_data/TOMM20_pipeline_example_cell_segmentation.tiff -------------------------------------------------------------------------------- /demo_data/TOMM20_pipeline_example_nucleus_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/demo_data/TOMM20_pipeline_example_nucleus_segmentation.tiff -------------------------------------------------------------------------------- /demo_data/TOMM20_pipeline_example_structure_segmentation.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/demo_data/TOMM20_pipeline_example_structure_segmentation.tiff -------------------------------------------------------------------------------- /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 = aicssegmentation 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/conda_why.md: -------------------------------------------------------------------------------- 1 | # About conda and why we need it 2 | 3 | 4 | [What is conda?](https://conda.io/docs/): Conda is a package that is used to manage many different packages. 5 | 6 | [What is Anaconda?](https://www.anaconda.com/what-is-anaconda/): Anaconda is a platform that includes many standard packages (e.g., conda and python). This is the easiest way to work on Python projects across different operating systems. 7 | 8 | [What is a conda environment?](https://conda.io/docs/user-guide/concepts.html#conda-environments): You can think of a conda environment as a box containing all necessary elements you need for a specific project. It can help avoid potential issues like "cannot find package" or "You need Package A in version X but you have Package A in version Y", which may crash your code. -------------------------------------------------------------------------------- /docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. mdinclude:: ../CONTRIBUTING.md 2 | -------------------------------------------------------------------------------- /docs/doc.rst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/docs/doc.rst -------------------------------------------------------------------------------- /docs/full.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/docs/full.jpg -------------------------------------------------------------------------------- /docs/full_doc.md: -------------------------------------------------------------------------------- 1 | # Full Documentations 2 | 3 | The full documentation for experienced developers is under construction and is expected to be available in early 2019. 4 | 5 | 6 | [scikit-image](http://scikit-image.org/docs/dev/index.html) 7 | 8 | 9 | [ITK in Python](https://itkpythonpackage.readthedocs.io/en/latest/Quick_start_guide.html#usage) -------------------------------------------------------------------------------- /docs/full_mem.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/docs/full_mem.jpg -------------------------------------------------------------------------------- /docs/full_str.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/docs/full_str.jpg -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to aicssegmentation'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 aicssegmentation, run this command in your terminal: 12 | 13 | .. code-block:: console 14 | 15 | $ pip install aicssegmentation 16 | 17 | This is the preferred method to install aicssegmentation, 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 aicssegmentation 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/AllenCell/aicssegmentation 36 | 37 | Or download the `tarball`_: 38 | 39 | .. code-block:: console 40 | 41 | $ curl -OL https://github.com/AllenCell/aicssegmentation/tarball/master 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/AllenCell/aicssegmentation 51 | .. _tarball: https://github.com/AllenCell/aicssegmentation/tarball/master 52 | -------------------------------------------------------------------------------- /docs/installation_linux.md: -------------------------------------------------------------------------------- 1 | # Installation Instruction for Linux 2 | 3 | (tested on Ubuntu 16.04 and 18.04) 4 | 5 | 6 | ## Step 1: Install conda 7 | 8 | *Go to Step 2 if you have anaconda or miniconda installed* 9 | 10 | Go to [Install conda on Linux](https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html), choose Anaconda Installer (for Python 3) and then follow the installation instructions. 11 | 12 | Note: [What is conda and anaconda, and why we need this?](conda_why.md) Because conda can effectively manage environment and package installation, setting up conda will make the following steps straightforward and help avoid future problems (conda itself is also very easy to set up). 13 | 14 | 15 | ## Step 2: Verify requirement and prepare for installing segmenter 16 | 17 | #### Step 2.1: [Start conda](https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html#starting-conda) 18 | 19 | All commands below are typed in the Terminal window 20 | 21 | #### Step 2.2: Test conda version 22 | 23 | ```bash 24 | conda info 25 | ``` 26 | 27 | You may see somthing like 28 | ```bash 29 | conda version : 4.6.11 30 | python version : 3.7.3.final.0 31 | ``` 32 | 33 | `conda version > 4.4` is preferred. To update conda, check out [how to update your conda](https://www.anaconda.com/keeping-anaconda-date/). `python version >=3.7` is required. 34 | 35 | #### Step 2.3: Test git 36 | 37 | ```bash 38 | git --version 39 | ``` 40 | 41 | If you don't have git, follow [Git for Linux](https://www.atlassian.com/git/tutorials/install-git#linux) to install. 42 | #### Step 2.4: Test pip 43 | 44 | ```bash 45 | pip show pip 46 | ``` 47 | 48 | A message will be printed out on your screen. If you see a warning, like a newer version is available, you can follow the instruction to upgrade you pip. 49 | 50 | #### Step 2.5: Create a new empty conda environment, which we will name "segmentation" (You can certainly choose a different name.) 51 | 52 | ``` bash 53 | conda create -n segmentation python=3.7 54 | ``` 55 | 56 | ### Step 2.6: Activate your conda environment "segmentation" 57 | 58 | ``` bash 59 | conda activate segmentation 60 | ``` 61 | 62 | (For older version conda, the command is `source activate segmentation`.) 63 | 64 | ### Step 2.7: Install nb_conda (for easy conda environment management in jupyter notebook) 65 | 66 | ```bash 67 | conda install nb_conda 68 | ``` 69 | 70 | ## Step 3: Install segmenter 71 | 72 | #### Step 3.1: Clone aics-segmentation repository from Github (suppose you want to save the folder under '~/Projects') 73 | 74 | ```bash 75 | cd ~/Projects 76 | git clone https://github.com/AllenCell/aics-segmentation.git 77 | ``` 78 | 79 | #### Step 3.2: install the packages 80 | 81 | ```bash 82 | cd ~/Projects/aics-segmentation 83 | pip install numpy 84 | pip install itkwidgets==0.14.0 85 | pip install -e .[all] 86 | ``` 87 | 88 | Note 1: Please note that for the users with both python 2 and python 3 installed, use `pip3` instead of `pip` in the commands 89 | 90 | Note 2: We use the packge `itkwidgets` for visualizaiotn within jupyter notebook. Currently, we find version `0.14.0` has slightly better performance in visualizing segmentation results. If you find this viwer keeps crashing in your browser, try `pip uninstall itkwidgets` and then `pip install itkwidgets==0.12.2`. For JupyterLab users, version >= `0.17.1` is needed. 91 | 92 | Note 3: For Jupyter Lab users, the itk viewer requires additionally run: 93 | 94 | ``` 95 | jupyter labextension install @jupyter-widgets/jupyterlab-manager itk-jupyter-widgets 96 | ``` 97 | 98 | Note 4: For advanced user to deploy segmenter on cluster, our package is also [available on PyPi](https://pypi.org/project/aicssegmentation/) 99 | 100 | 101 | #### Step 3.3: Test segmenter 102 | 103 | ``` bash 104 | cd ~/Projects/aics-segmentation/lookup_table_demo 105 | jupyter notebook 106 | ``` 107 | 108 | This will take you to your default browser (e.g., Firefox) and launch Jupyter Notebook App within your browser. Open "test_viewer.ipynb" and test if you can run the notebook from beginning to the end. See more details on [How to use Jupyter Notebook to running the workflow in the Look-up Table](../docs/jupyter_lookup_table.md) -------------------------------------------------------------------------------- /docs/installation_mac.md: -------------------------------------------------------------------------------- 1 | # Installation Instruction for MacOS 2 | 3 | ## Step 0: Install XCode 4 | 5 | *Go to Step 1 if you already have XCode installed (it is very likely that you already have it, if you have done any python or C++ programming on your machine).* 6 | 7 | [Download and install XCode from Apple Developer](https://developer.apple.com/xcode/) 8 | 9 | Note: Depending on the time you access this page, you may be directed to a different page. As effective date of Sep 24 2019, you can find ‘Software Downloads’ at the bottom of the page and follow the download and installation instructions. 10 | 11 | ## Step 1: Install Conda 12 | 13 | *Go to Step 2 if you have anaconda or miniconda installed* 14 | 15 | Go to [Install conda on macOS](https://docs.conda.io/projects/conda/en/latest/user-guide/install/macos.html), choose Anaconda Installer (for Python 3) and then follow the installation instructions. 16 | 17 | Note: [What is conda and anaconda, and why we need this?](conda_why.md) Because conda can effectively manage environment and package installation, setting up conda will make the following steps straightforward and help avoid future problems (conda itself is also very easy to set up). 18 | 19 | ## Step 2: Verify requirement and prepare for installing segmenter 20 | 21 | #### Step 2.1: [Start conda](https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html#starting-conda) 22 | 23 | All commands below are typed into the Terminal Window 24 | 25 | #### Step 2.2: Test conda version 26 | 27 | ```bash 28 | conda info 29 | ``` 30 | 31 | You may see somthing like 32 | ```bash 33 | conda version : 4.6.11 34 | python version : 3.7.3.final.0 35 | ``` 36 | 37 | `conda version > 4.4` is preferred. To update conda, check out [how to update your conda](https://www.anaconda.com/keeping-anaconda-date/). `python version >=3.7` is required. 38 | 39 | #### Step 2.3: Test git 40 | 41 | ```bash 42 | git --version 43 | ``` 44 | 45 | If you don't have git, follow [Git for macOS](https://www.atlassian.com/git/tutorials/install-git#mac-os-x) to install and restart conda after installing git. 46 | 47 | #### Step 2.4: Test pip 48 | 49 | ```bash 50 | pip show pip 51 | ``` 52 | 53 | A message will be printed out on your screen. If you see a warning, like a newer version is available, you can follow the instruction to upgrade you pip. 54 | 55 | #### Step 2.5: Create a new empty conda environment, which we will name "segmentation" (You can certainly choose a different name.) 56 | 57 | ``` bash 58 | conda create -n segmentation python=3.7 59 | ``` 60 | 61 | ### Step 2.6: Activate your conda environment "segmentation" 62 | 63 | ``` bash 64 | conda activate segmentation 65 | ``` 66 | 67 | (For older version conda, the command is `source activate segmentation`.) 68 | 69 | ### Step 2.7: Install nb_conda (for easy conda environment management in jupyter notebook) 70 | 71 | ```bash 72 | conda install nb_conda 73 | ``` 74 | 75 | ## Step 3: Install segmenter 76 | 77 | #### Step 3.1: Clone aics-segmentation repository from Github (suppose you want to save the folder under '~/Projects') 78 | 79 | ```bash 80 | cd ~/Projects 81 | git clone https://github.com/AllenCell/aics-segmentation.git 82 | ``` 83 | 84 | #### Step 3.2: install the packages 85 | 86 | ```bash 87 | cd ~/Projects/aics-segmentation 88 | pip install numpy 89 | pip install itkwidgets==0.14.0 90 | pip install -e .[all] 91 | ``` 92 | 93 | Note 1: Please note that for the users with both python 2 and python 3 installed, use `pip3` instead of `pip` in the commands 94 | 95 | Note 2: We use the packge `itkwidgets` for visualizaiotn within jupyter notebook. Currently, we find version `0.14.0` has slightly better performance in visualizing segmentation results. If you find this viwer keeps crashing in your browser, try `pip uninstall itkwidgets` and then `pip install itkwidgets==0.12.2`. For JupyterLab users, version >= `0.17.1` is needed. 96 | 97 | Note 3: For Jupyter Lab users, the itk viewer requires additionally run: 98 | 99 | ``` 100 | jupyter labextension install @jupyter-widgets/jupyterlab-manager itk-jupyter-widgets 101 | ``` 102 | 103 | Note 4: For advanced user to deploy segmenter on cluster, our package is also [available on PyPi](https://pypi.org/project/aicssegmentation/) 104 | 105 | 106 | #### Step 3.3: Test segmenter 107 | 108 | ``` bash 109 | cd ~/Projects/aics-segmentation/lookup_table_demo 110 | jupyter notebook 111 | ``` 112 | 113 | This will take you to your default browser (e.g., Safari) and launch Jupyter Notebook App within your browser.Open "test_viwer.ipynb" and test if you can run the notebook from beginning to the end. See more details on [How to use Jupyter Notebook to running the workflow in the Look-up Table](../docs/jupyter_lookup_table.md) 114 | 115 | -------------------------------------------------------------------------------- /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=aicssegmentation 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 | -------------------------------------------------------------------------------- /docs/object_identification.md: -------------------------------------------------------------------------------- 1 | # What is object identification? 2 | 3 | Suppose you have a multi-channel image with Golgi in one channel and plasma membrane in the another channel. One 2D z-slice of the 3D image is shown below. 4 | 5 | ![raw](./full.jpg) 6 | 7 | 8 | For simiplicity, to explain the concept of object identification, we use a small area (see the yellow box) for example. 9 | 10 | Suppose you have run the segmenter to get a binary image as the output as below. You can get some basic information, like how many pixels have been segmented as your target structure (i.e., Golgi) in this image or the physical size of structure in this whole image. 11 | 12 | ![s1](./step1.jpg) 13 | 14 | A simple way of **object identification** is to extract each [connected component](https://homepages.inf.ed.ac.uk/rbf/HIPR2/label.htm) and define each connected component as one object. 15 | 16 | ![s2](./step2.jpg) 17 | 18 | 19 | Furthermore, you can also convert the binary image into separated groups of analyzable objects according to **mask labels**. 20 | 21 | What is a mask label? Depending on the biological questions, the mask label may vary. It could be areas enclosed by each individual cell or each individual nucleus, or any other way you may want to partition the image into different analyzable regions. All the objects in one particular cell/nucleus/customized region within in the structure segmentation binary image would have the same group id. 22 | 23 | This is useful, for example, when a per-cell measurement is needed. In this case a cell segmentation is used as the mask label. 24 | 25 | 26 | *Note: In this demo, we are using a cell segmentation generated by a deep learning based segmentation algorithm developed at the Allen Institute for Cell Science. We are working on the release of our nuclear/cell segmentation workflows. Please stay tuned :) For your data, you may use your own nuclear/cell segmentation approach or you can do this via manual annotation in Fiji.* 27 | 28 | In this example, when we apply the cell segmentation as the mask label, we have: 29 | 30 | ![s3_1](./step3_p1.jpg) 31 | 32 | Then, we can get the object identification results as below. 33 | 34 | ![s3_2](./step3_p2.jpg) 35 | -------------------------------------------------------------------------------- /docs/rab5a_raw.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/docs/rab5a_raw.jpg -------------------------------------------------------------------------------- /docs/step1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/docs/step1.jpg -------------------------------------------------------------------------------- /docs/step2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/docs/step2.jpg -------------------------------------------------------------------------------- /docs/step3_p1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/docs/step3_p1.jpg -------------------------------------------------------------------------------- /docs/step3_p2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/docs/step3_p2.jpg -------------------------------------------------------------------------------- /lookup_table_demo/README.md: -------------------------------------------------------------------------------- 1 | List of "playgrounds" for the lookup table: 2 | 3 | 1. playground_st6gal.ipynb: workflow for Sialyltransferase 1 4 | 2. playground_spotty.ipynb: workflow for Fibrillarin, Beta catenin 5 | 3. playground_npm1.ipynb: workflow for Nucleophosmin 6 | 4. playground_curvi.ipynb: workflows for Sec61 beta, Tom 20, Lamin B1 (mitosis-specific) 7 | 5. playground_lamp1.ipynb: workflow for LAMP-1 8 | 6. playground_dots.ipynb: workflows for Centrin-2, Desmoplakin, and PMP34 9 | 7. playground_gja1.ipynb: workflow for Connexin-43 10 | 8. playground_filament3d.ipynb: workflows for Tight junction protein ZO1, Beta actin, Non-muscle myosin IIB, Alpha-actinin-1, Alpha tubulin, Troponin I, and Titin 11 | 9. playground_shell.ipynb: workflow for Lamin B1 (Interphase-specific) 12 | 13 | Find the sample in the lookup table with the closest morphology to your data and start the corresponding "playground" to test the workflow. -------------------------------------------------------------------------------- /lookup_table_demo/test_segmentation_TNNI1.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenCell/aics-segmentation/d5bf6a820869e8430e37ab814e664497bcf32c08/lookup_table_demo/test_segmentation_TNNI1.tiff -------------------------------------------------------------------------------- /lookup_table_demo/test_viewer.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from itkwidgets import view\n", 10 | "import numpy as np\n", 11 | "from aicssegmentation.core.pre_processing_utils import image_smoothing_gaussian_3d" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 2, 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "im = np.ones((65,624,624),dtype=np.uint8)" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": 3, 26 | "metadata": {}, 27 | "outputs": [ 28 | { 29 | "data": { 30 | "application/vnd.jupyter.widget-view+json": { 31 | "model_id": "a126140b0c9b4a02a20f1d3fad5307b1", 32 | "version_major": 2, 33 | "version_minor": 0 34 | }, 35 | "text/plain": [ 36 | "Viewer(geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image==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>=7.1.1", 21 | "pytest-cov>=2.9.0", 22 | "pytest-raises>=0.11", 23 | "napari", 24 | ] 25 | 26 | dev_requirements = [ 27 | *setup_requirements, 28 | *test_requirements, 29 | "bumpversion>=0.6.0", 30 | "coverage>=5.1", 31 | "ipython>=7.15.0", 32 | "m2r>=0.2.1", 33 | "pytest-runner>=5.2", 34 | "jinja2==3.0.0", 35 | "Sphinx>=2.0.0b1,<3", 36 | "sphinx_rtd_theme>=0.4.3", 37 | "tox>=3.15.2", 38 | "twine>=3.1.1", 39 | "wheel>=0.34.2", 40 | "napari", 41 | ] 42 | 43 | requirements = [ 44 | "aicsimageio>=4.0.5", 45 | "scipy>=1.1.0", 46 | "numpy>=1.15.1", 47 | "scikit-image", 48 | "pandas>=0.23.4", 49 | "itk", 50 | "itkwidgets", 51 | "jupyter", 52 | "matplotlib", 53 | "dask", 54 | "napari", 55 | ] 56 | 57 | extra_requirements = { 58 | "setup": setup_requirements, 59 | "test": test_requirements, 60 | "dev": dev_requirements, 61 | "all": [ 62 | *requirements, 63 | *dev_requirements, 64 | ], 65 | } 66 | 67 | setup( 68 | author="Jianxu Chen", 69 | author_email="jianxuc@alleninstitute.org", 70 | classifiers=[ 71 | "Development Status :: 2 - Pre-Alpha", 72 | "Intended Audience :: Developers", 73 | "License :: Free for non-commercial use", 74 | "Natural Language :: English", 75 | "Programming Language :: Python :: 3.9", 76 | "Programming Language :: Python :: 3.10", 77 | ], 78 | description="Part 1 of Allen Cell and Structure Segmenter", 79 | entry_points={ 80 | "console_scripts": ["batch_processing=aicssegmentation.bin.batch_processing:main"], 81 | }, 82 | package_data={"demo_data": ["*.png"]}, 83 | install_requires=requirements, 84 | license="Allen Institute Software License", 85 | long_description=readme, 86 | long_description_content_type="text/markdown", 87 | include_package_data=True, 88 | keywords="aicssegmentation", 89 | name="aicssegmentation", 90 | packages=find_packages(exclude=["tests", "*.tests", "*.tests.*"]), 91 | python_requires=">=3.7", 92 | setup_requires=setup_requirements, 93 | test_suite="aicssegmentation/tests", 94 | tests_require=test_requirements, 95 | extras_require=extra_requirements, 96 | url="https://github.com/AllenCell/aicssegmentation", 97 | # Do not edit this string manually, always use bumpversion 98 | # Details in CONTRIBUTING.rst 99 | version="0.5.2", 100 | zip_safe=False, 101 | ) 102 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | skipsdist = True 3 | envlist = py37, py38, lint 4 | 5 | [testenv:lint] 6 | deps = 7 | .[test] 8 | commands = 9 | flake8 aicssegmentation --count --verbose --show-source --statistics 10 | black --check aicssegmentation 11 | 12 | [testenv] 13 | setenv = 14 | PYTHONPATH = {toxinidir} 15 | deps = 16 | .[test] 17 | commands = 18 | pytest --basetemp={envtmpdir} --cov-report html --cov=aicssegmentation aicssegmentation/tests/ 19 | --------------------------------------------------------------------------------