waveorder 2.2.0__tar.gz → 2.2.1b0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- waveorder-2.2.1b0/.github/workflows/pr.yml +101 -0
- waveorder-2.2.1b0/.pre-commit-config.yaml +34 -0
- waveorder-2.2.1b0/CONTRIBUTING.md +62 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/PKG-INFO +3 -2
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/PTI_experiment/PTI_Experiment_Recon3D_anisotropic_target_small.py +52 -31
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/maintenance/PTI_simulation/PTI_Simulation_Forward_2D3D.py +3 -6
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/maintenance/PTI_simulation/PTI_Simulation_Recon2D.py +2 -6
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/maintenance/PTI_simulation/PTI_Simulation_Recon3D.py +3 -5
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/maintenance/QLIPP_simulation/2D_QLIPP_forward.py +3 -6
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/maintenance/QLIPP_simulation/2D_QLIPP_recon.py +3 -5
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/models/inplane_oriented_thick_pol3d_vector.py +18 -18
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/models/isotropic_thin_3d.py +1 -1
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/models/phase_thick_3d.py +1 -1
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/visuals/plot_greens_tensor.py +7 -5
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/visuals/plot_vector_transfer_function_support.py +10 -5
- {waveorder-2.2.0 → waveorder-2.2.1b0}/pyproject.toml +1 -1
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/models/test_isotropic_fluorescent_thick_3d.py +0 -1
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/models/test_phase_thick_3d.py +3 -3
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/test_examples.py +3 -2
- waveorder-2.2.1b0/tests/test_filter.py +57 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/test_focus_estimator.py +2 -1
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/test_optics.py +2 -1
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/test_sampling.py +1 -4
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/test_util.py +3 -2
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/_version.py +9 -4
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/background_estimator.py +2 -2
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/correction.py +1 -1
- waveorder-2.2.1b0/waveorder/filter.py +206 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/focus.py +5 -3
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/models/inplane_oriented_thick_pol3d.py +6 -2
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/models/inplane_oriented_thick_pol3d_vector.py +29 -60
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/models/isotropic_fluorescent_thick_3d.py +18 -7
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/models/isotropic_thin_3d.py +19 -16
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/models/phase_thick_3d.py +29 -19
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/optics.py +11 -14
- waveorder-2.2.1b0/waveorder/reconstruct.py +28 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/stokes.py +4 -3
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/util.py +9 -9
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/visuals/jupyter_visuals.py +19 -22
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/visuals/matplotlib_visuals.py +4 -4
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/visuals/napari_visuals.py +2 -3
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/visuals/utils.py +1 -2
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/waveorder_reconstructor.py +10 -9
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/waveorder_simulator.py +6 -6
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder.egg-info/PKG-INFO +3 -2
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder.egg-info/SOURCES.txt +6 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder.egg-info/requires.txt +1 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/.git-blame-ignore-revs +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/.github/workflows/pytests.yml +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/.gitignore +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/CITATION.cff +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/LICENSE +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/README.md +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/docs/valuable-prs/2023-02-27.110.pr.open.md +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/README.md +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/PTI_experiment/PTI_Experiment_Recon3D_anisotropic_target_small.pdf +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/PTI_experiment/PTI_full_FOV_anisotropic_target.ipynb +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/PTI_experiment/PTI_full_FOV_cardiac_muscle.ipynb +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/PTI_experiment/PTI_full_FOV_cardiomyocyte_infected_1.ipynb +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/PTI_experiment/PTI_full_FOV_cardiomyocyte_infected_2.ipynb +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/PTI_experiment/PTI_full_FOV_cardiomyocyte_mock.ipynb +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/PTI_experiment/PTI_full_FOV_human_uterus.ipynb +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/PTI_experiment/PTI_full_FOV_mouse_brain_aco.ipynb +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/PTI_experiment/README.md +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/QLIPP_experiment/2D_QLIPP_recon_experiment.ipynb +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/QLIPP_experiment/3D_QLIPP_recon_experiment.ipynb +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/README.md +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/documentation/fluorescence_deconvolution/fluorescence_deconv.ipynb +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/maintenance/PTI_simulation/PTI_formulation.html +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/maintenance/PTI_simulation/README.md +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/maintenance/README.md +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/models/README.md +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/models/inplane_oriented_thick_pol3d.py +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/examples/models/isotropic_fluorescent_thick_3d.py +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/readme.png +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/setup.cfg +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/__init__.py +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/conftest.py +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/models/test_inplane_oriented_thick_pol3D.py +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/models/test_isotropic_thin_3d.py +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/test_correction.py +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/tests/test_stokes.py +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/__init__.py +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder/sampling.py +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder.egg-info/dependency_links.txt +0 -0
- {waveorder-2.2.0 → waveorder-2.2.1b0}/waveorder.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: lint, style, and tests
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
style:
|
|
13
|
+
name: Style Check
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
python-version: ["3.10"]
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v3
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v4
|
|
24
|
+
with:
|
|
25
|
+
python-version: ${{ matrix.python-version }}
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: |
|
|
28
|
+
python -m pip install --upgrade pip
|
|
29
|
+
pip install black==25.1.0
|
|
30
|
+
- name: Check code styling with Black
|
|
31
|
+
run: |
|
|
32
|
+
black --diff -S -t py310 waveorder
|
|
33
|
+
black --check -S -t py310 waveorder
|
|
34
|
+
|
|
35
|
+
# lint:
|
|
36
|
+
# name: Lint Check
|
|
37
|
+
# runs-on: ubuntu-latest
|
|
38
|
+
|
|
39
|
+
# strategy:
|
|
40
|
+
# matrix:
|
|
41
|
+
# python-version: ["3.10"]
|
|
42
|
+
|
|
43
|
+
# steps:
|
|
44
|
+
# - uses: actions/checkout@v3
|
|
45
|
+
# - name: Set up Python
|
|
46
|
+
# uses: actions/setup-python@v4
|
|
47
|
+
# with:
|
|
48
|
+
# python-version: ${{ matrix.python-version }}
|
|
49
|
+
# - name: Install dependencies
|
|
50
|
+
# run: |
|
|
51
|
+
# python -m pip install --upgrade pip
|
|
52
|
+
# pip install flake8
|
|
53
|
+
# - name: Check code with Flake8
|
|
54
|
+
# # E203 conflicts with black
|
|
55
|
+
# run: |
|
|
56
|
+
# flake8 waveorder --extend-ignore=E203
|
|
57
|
+
|
|
58
|
+
isort:
|
|
59
|
+
name: isort Check
|
|
60
|
+
runs-on: ubuntu-latest
|
|
61
|
+
|
|
62
|
+
strategy:
|
|
63
|
+
matrix:
|
|
64
|
+
python-version: ["3.10"]
|
|
65
|
+
|
|
66
|
+
steps:
|
|
67
|
+
- uses: actions/checkout@v3
|
|
68
|
+
- name: Set up Python
|
|
69
|
+
uses: actions/setup-python@v4
|
|
70
|
+
with:
|
|
71
|
+
python-version: ${{ matrix.python-version }}
|
|
72
|
+
- name: Install dependencies
|
|
73
|
+
run: |
|
|
74
|
+
python -m pip install --upgrade pip
|
|
75
|
+
pip install isort
|
|
76
|
+
- name: Check code with isort
|
|
77
|
+
run: |
|
|
78
|
+
isort --check waveorder
|
|
79
|
+
|
|
80
|
+
tests:
|
|
81
|
+
needs: [style, isort] # lint
|
|
82
|
+
runs-on: ubuntu-latest
|
|
83
|
+
strategy:
|
|
84
|
+
matrix:
|
|
85
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
86
|
+
|
|
87
|
+
steps:
|
|
88
|
+
- uses: actions/checkout@v3
|
|
89
|
+
|
|
90
|
+
- uses: actions/setup-python@v4
|
|
91
|
+
with:
|
|
92
|
+
python-version: ${{ matrix.python-version }}
|
|
93
|
+
|
|
94
|
+
- name: Install dependencies
|
|
95
|
+
run: |
|
|
96
|
+
python -m pip install --upgrade pip
|
|
97
|
+
pip install ".[dev]"
|
|
98
|
+
|
|
99
|
+
- name: Test with pytest
|
|
100
|
+
run: |
|
|
101
|
+
pytest -v --cov=./ --cov-report=xml
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
repos:
|
|
3
|
+
# basic pre-commit
|
|
4
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
+
rev: v4.4.0
|
|
6
|
+
hooks:
|
|
7
|
+
- id: trailing-whitespace
|
|
8
|
+
- id: end-of-file-fixer
|
|
9
|
+
- id: check-added-large-files
|
|
10
|
+
- id: check-yaml
|
|
11
|
+
- id: check-toml
|
|
12
|
+
- id: detect-private-key
|
|
13
|
+
# sorting imports
|
|
14
|
+
- repo: https://github.com/pycqa/isort
|
|
15
|
+
rev: 5.12.0
|
|
16
|
+
hooks:
|
|
17
|
+
- id: isort
|
|
18
|
+
# syntax linting and formatting
|
|
19
|
+
- repo: https://github.com/myint/autoflake
|
|
20
|
+
rev: v2.1.1
|
|
21
|
+
hooks:
|
|
22
|
+
- id: autoflake
|
|
23
|
+
args: [--in-place, --remove-all-unused-imports,
|
|
24
|
+
--ignore-init-module-imports]
|
|
25
|
+
# - repo: https://github.com/PyCQA/flake8
|
|
26
|
+
# rev: 6.0.0
|
|
27
|
+
# hooks:
|
|
28
|
+
# - id: flake8
|
|
29
|
+
# args: [--ignore, "E203,W503", --min-python-version, '3.10']
|
|
30
|
+
# additional_dependencies: [flake8-typing-imports==1.12.0]
|
|
31
|
+
- repo: https://github.com/psf/black
|
|
32
|
+
rev: 25.1.0
|
|
33
|
+
hooks:
|
|
34
|
+
- id: black
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Contributing guide
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing to `waveorder`!
|
|
4
|
+
|
|
5
|
+
Please see the following steps for our workflow.
|
|
6
|
+
|
|
7
|
+
## Getting started
|
|
8
|
+
|
|
9
|
+
Please read the [README](./README.md) for an overview of the project,
|
|
10
|
+
and how you can install and use the package.
|
|
11
|
+
|
|
12
|
+
## Issues
|
|
13
|
+
|
|
14
|
+
We use [issues](https://github.com/mehta-lab/waveorder/issues) to track
|
|
15
|
+
bug reports, feature requests, and provide user support.
|
|
16
|
+
|
|
17
|
+
Before opening a new issue, please first search existing issues (including closed ones),
|
|
18
|
+
to see if there is an existing discussion about it.
|
|
19
|
+
|
|
20
|
+
### Setting up development environment
|
|
21
|
+
|
|
22
|
+
For local development, first install [Git](https://git-scm.com/)
|
|
23
|
+
and Python with an environment management tool
|
|
24
|
+
(e.g. [miniforge](https://github.com/conda-forge/miniforge), a minimal community distribution of Conda).
|
|
25
|
+
|
|
26
|
+
If you use Conda, set up an environment with:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
conda create -n waveorder-dev python=3.10
|
|
30
|
+
conda activate waveorder-dev
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If you have push permission to the repository,
|
|
34
|
+
clone the repository (the code blocks below are shell commands):
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
cd # to the directory you want to work in
|
|
38
|
+
git clone https://github.com/mehta-lab/waveorder.git
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Otherwise, you can follow [these instructions](https://docs.github.com/en/get-started/quickstart/fork-a-repo)
|
|
42
|
+
to [fork](https://github.com/mehta-lab/waveorder/fork) the repository.
|
|
43
|
+
|
|
44
|
+
Then install the package in editable mode with the development dependencies:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
cd waveorder/ # or the renamed project root directory
|
|
48
|
+
pip install -e ".[dev]"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Then make the changes and [track them with Git](https://docs.github.com/en/get-started/using-git/about-git#example-contribute-to-an-existing-repository).
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Code style
|
|
55
|
+
|
|
56
|
+
We use [pre-commit](https://pre-commit.com/) to sort imports with [isort](https://github.com/PyCQA/isort) and format code with [black](https://black.readthedocs.io/en/stable/) automatically prior to each commit. To minimize test errors when submitting pull requests, please install pre-commit in your environment as follows:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pre-commit install
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
When these packages are executed within the project root directory, they should automatically use the [project settings](./pyproject.toml).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: waveorder
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1b0
|
|
4
4
|
Summary: Wave-optical simulations and deconvolution of optical properties
|
|
5
5
|
Author-email: CZ Biohub SF <compmicro@czbiohub.org>
|
|
6
6
|
Maintainer-email: Talon Chandler <talon.chandler@czbiohub.org>, Shalin Mehta <shalin.mehta@czbiohub.org>
|
|
@@ -62,6 +62,7 @@ Requires-Dist: torch>=2.4.1
|
|
|
62
62
|
Provides-Extra: dev
|
|
63
63
|
Requires-Dist: pytest; extra == "dev"
|
|
64
64
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
65
|
+
Requires-Dist: black==25.1.0; extra == "dev"
|
|
65
66
|
Provides-Extra: examples
|
|
66
67
|
Requires-Dist: napari[all]; extra == "examples"
|
|
67
68
|
Requires-Dist: jupyter; extra == "examples"
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# %%
|
|
2
2
|
# This notebook-style script requires a ~500 MB download from https://www.ebi.ac.uk/biostudies/files/S-BIAD1063/PTI-BIA/Anisotropic_target_small.zip
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
5
6
|
import matplotlib.pyplot as plt
|
|
7
|
+
import numpy as np
|
|
8
|
+
import zarr
|
|
9
|
+
from iohub import open_ome_zarr
|
|
6
10
|
from numpy.fft import fftshift
|
|
7
11
|
|
|
8
12
|
import waveorder as wo
|
|
9
|
-
from waveorder import optics,
|
|
10
|
-
|
|
11
|
-
import zarr
|
|
12
|
-
from pathlib import Path
|
|
13
|
-
from iohub import open_ome_zarr
|
|
13
|
+
from waveorder import optics, util, waveorder_reconstructor
|
|
14
14
|
from waveorder.visuals import jupyter_visuals
|
|
15
15
|
|
|
16
16
|
# %%
|
|
@@ -62,10 +62,12 @@ PTI_file = zarr.open(PTI_file_name, mode="r")
|
|
|
62
62
|
I_cali_mean = np.array(PTI_file.I_cali_mean)
|
|
63
63
|
|
|
64
64
|
# source polarization, instrument matrix calibration
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
(
|
|
66
|
+
E_in,
|
|
67
|
+
A_matrix,
|
|
68
|
+
I_cali_mean,
|
|
69
|
+
) = wo.waveorder_reconstructor.instrument_matrix_and_source_calibration(
|
|
70
|
+
I_cali_mean, handedness="RCP"
|
|
69
71
|
)
|
|
70
72
|
|
|
71
73
|
# %%
|
|
@@ -238,15 +240,18 @@ jupyter_visuals.parallel_4D_viewer(
|
|
|
238
240
|
# "negative" -> only solution of negatively uniaxial material
|
|
239
241
|
# "unknown" -> both solutions of positively and negatively uniaxial material + optic sign estimation
|
|
240
242
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
243
|
+
(
|
|
244
|
+
differential_permittivity,
|
|
245
|
+
azimuth,
|
|
246
|
+
theta,
|
|
247
|
+
mat_map,
|
|
248
|
+
) = setup.scattering_potential_tensor_to_3D_orientation(
|
|
249
|
+
f_tensor,
|
|
250
|
+
S_image_tm,
|
|
251
|
+
material_type="unknown",
|
|
252
|
+
reg_ret_pr=reg_differential_permittivity,
|
|
253
|
+
itr=10,
|
|
254
|
+
fast_gpu_mode=True,
|
|
250
255
|
)
|
|
251
256
|
|
|
252
257
|
# %%
|
|
@@ -264,7 +269,10 @@ differential_permittivity_PT = np.array(
|
|
|
264
269
|
[
|
|
265
270
|
((-1) ** i)
|
|
266
271
|
* util.wavelet_softThreshold(
|
|
267
|
-
((-1) ** i) * differential_permittivity_PT[i],
|
|
272
|
+
((-1) ** i) * differential_permittivity_PT[i],
|
|
273
|
+
"db8",
|
|
274
|
+
0.00303,
|
|
275
|
+
level=1,
|
|
268
276
|
)
|
|
269
277
|
for i in range(2)
|
|
270
278
|
]
|
|
@@ -374,17 +382,27 @@ mat_map = PTI_array[7:]
|
|
|
374
382
|
|
|
375
383
|
# compute the physical properties from the scattering potential tensor
|
|
376
384
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
)
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
385
|
+
(
|
|
386
|
+
differential_permittivity_p,
|
|
387
|
+
azimuth_p,
|
|
388
|
+
theta_p,
|
|
389
|
+
) = optics.scattering_potential_tensor_to_3D_orientation_PN(
|
|
390
|
+
f_tensor,
|
|
391
|
+
material_type="positive",
|
|
392
|
+
reg_ret_pr=reg_differential_permittivity,
|
|
393
|
+
)
|
|
394
|
+
(
|
|
395
|
+
differential_permittivity_n,
|
|
396
|
+
azimuth_n,
|
|
397
|
+
theta_n,
|
|
398
|
+
) = optics.scattering_potential_tensor_to_3D_orientation_PN(
|
|
399
|
+
f_tensor,
|
|
400
|
+
material_type="negative",
|
|
401
|
+
reg_ret_pr=reg_differential_permittivity,
|
|
402
|
+
)
|
|
403
|
+
differential_permittivity = np.array(
|
|
404
|
+
[differential_permittivity_p, differential_permittivity_n]
|
|
386
405
|
)
|
|
387
|
-
differential_permittivity = np.array([differential_permittivity_p, differential_permittivity_n])
|
|
388
406
|
azimuth = np.array([azimuth_p, azimuth_n])
|
|
389
407
|
theta = np.array([theta_p, theta_n])
|
|
390
408
|
|
|
@@ -402,7 +420,10 @@ differential_permittivity_PT = np.array(
|
|
|
402
420
|
[
|
|
403
421
|
((-1) ** i)
|
|
404
422
|
* util.wavelet_softThreshold(
|
|
405
|
-
((-1) ** i) * differential_permittivity_PT[i],
|
|
423
|
+
((-1) ** i) * differential_permittivity_PT[i],
|
|
424
|
+
"db8",
|
|
425
|
+
0.00303,
|
|
426
|
+
level=1,
|
|
406
427
|
)
|
|
407
428
|
for i in range(2)
|
|
408
429
|
]
|
|
@@ -9,14 +9,11 @@
|
|
|
9
9
|
# density and anisotropy," bioRxiv 2020.12.15.422951 (2020).``` #
|
|
10
10
|
####################################################################
|
|
11
11
|
|
|
12
|
-
import numpy as np
|
|
13
12
|
import matplotlib.pyplot as plt
|
|
13
|
+
import numpy as np
|
|
14
14
|
from numpy.fft import fftshift
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
waveorder_simulator,
|
|
18
|
-
util,
|
|
19
|
-
)
|
|
15
|
+
|
|
16
|
+
from waveorder import optics, util, waveorder_simulator
|
|
20
17
|
from waveorder.visuals import jupyter_visuals
|
|
21
18
|
|
|
22
19
|
#####################################################################
|
{waveorder-2.2.0 → waveorder-2.2.1b0}/examples/maintenance/PTI_simulation/PTI_Simulation_Recon2D.py
RENAMED
|
@@ -9,14 +9,11 @@
|
|
|
9
9
|
# density and anisotropy," bioRxiv 2020.12.15.422951 (2020).``` #
|
|
10
10
|
####################################################################
|
|
11
11
|
|
|
12
|
-
import numpy as np
|
|
13
12
|
import matplotlib.pyplot as plt
|
|
13
|
+
import numpy as np
|
|
14
14
|
from numpy.fft import fftshift
|
|
15
15
|
|
|
16
|
-
from waveorder import
|
|
17
|
-
optics,
|
|
18
|
-
waveorder_reconstructor,
|
|
19
|
-
)
|
|
16
|
+
from waveorder import optics, waveorder_reconstructor
|
|
20
17
|
from waveorder.visuals import jupyter_visuals
|
|
21
18
|
|
|
22
19
|
## Initialization
|
|
@@ -271,7 +268,6 @@ plt.show()
|
|
|
271
268
|
# in-plane orientation
|
|
272
269
|
from matplotlib.colors import hsv_to_rgb
|
|
273
270
|
|
|
274
|
-
|
|
275
271
|
ret_min_color = 0
|
|
276
272
|
ret_max_color = 1.5
|
|
277
273
|
|
{waveorder-2.2.0 → waveorder-2.2.1b0}/examples/maintenance/PTI_simulation/PTI_Simulation_Recon3D.py
RENAMED
|
@@ -8,13 +8,11 @@
|
|
|
8
8
|
# "uPTI: uniaxial permittivity tensor imaging of intrinsic #
|
|
9
9
|
# density and anisotropy," bioRxiv 2020.12.15.422951 (2020).``` #
|
|
10
10
|
####################################################################
|
|
11
|
-
import numpy as np
|
|
12
11
|
import matplotlib.pyplot as plt
|
|
12
|
+
import numpy as np
|
|
13
13
|
from numpy.fft import fftshift
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
waveorder_reconstructor,
|
|
17
|
-
)
|
|
14
|
+
|
|
15
|
+
from waveorder import optics, waveorder_reconstructor
|
|
18
16
|
from waveorder.visuals import jupyter_visuals
|
|
19
17
|
|
|
20
18
|
## Initialization
|
{waveorder-2.2.0 → waveorder-2.2.1b0}/examples/maintenance/QLIPP_simulation/2D_QLIPP_forward.py
RENAMED
|
@@ -10,14 +10,11 @@
|
|
|
10
10
|
#####################################################################################################
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
import numpy as np
|
|
14
13
|
import matplotlib.pyplot as plt
|
|
14
|
+
import numpy as np
|
|
15
15
|
from numpy.fft import fftshift
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
waveorder_simulator,
|
|
19
|
-
util,
|
|
20
|
-
)
|
|
16
|
+
|
|
17
|
+
from waveorder import optics, util, waveorder_simulator
|
|
21
18
|
from waveorder.visuals import jupyter_visuals
|
|
22
19
|
|
|
23
20
|
# Key parameters
|
{waveorder-2.2.0 → waveorder-2.2.1b0}/examples/maintenance/QLIPP_simulation/2D_QLIPP_recon.py
RENAMED
|
@@ -10,13 +10,11 @@
|
|
|
10
10
|
# eLife 9:e55502 (2020).``` #
|
|
11
11
|
#####################################################################################################
|
|
12
12
|
|
|
13
|
-
import numpy as np
|
|
14
13
|
import matplotlib.pyplot as plt
|
|
15
|
-
|
|
16
|
-
waveorder_reconstructor,
|
|
17
|
-
)
|
|
18
|
-
from waveorder.visuals import jupyter_visuals
|
|
14
|
+
import numpy as np
|
|
19
15
|
|
|
16
|
+
from waveorder import waveorder_reconstructor
|
|
17
|
+
from waveorder.visuals import jupyter_visuals
|
|
20
18
|
|
|
21
19
|
# ### Load simulated data
|
|
22
20
|
# Load simulations
|
{waveorder-2.2.0 → waveorder-2.2.1b0}/examples/models/inplane_oriented_thick_pol3d_vector.py
RENAMED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import torch
|
|
2
1
|
import napari
|
|
2
|
+
import torch
|
|
3
3
|
|
|
4
|
-
from waveorder.models import
|
|
5
|
-
inplane_oriented_thick_pol3d_vector,
|
|
6
|
-
)
|
|
4
|
+
from waveorder.models import inplane_oriented_thick_pol3d_vector
|
|
7
5
|
|
|
8
6
|
# Parameters
|
|
9
7
|
# all lengths must use consistent units e.g. um
|
|
@@ -25,20 +23,22 @@ fzyx_object = inplane_oriented_thick_pol3d_vector.generate_test_phantom(
|
|
|
25
23
|
)
|
|
26
24
|
|
|
27
25
|
# Calculate transfer function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
(
|
|
27
|
+
sfZYX_transfer_function,
|
|
28
|
+
intensity_to_stokes_matrix,
|
|
29
|
+
singular_system,
|
|
30
|
+
) = inplane_oriented_thick_pol3d_vector.calculate_transfer_function(
|
|
31
|
+
swing,
|
|
32
|
+
scheme,
|
|
33
|
+
zyx_shape,
|
|
34
|
+
yx_pixel_size,
|
|
35
|
+
z_pixel_size,
|
|
36
|
+
wavelength_illumination,
|
|
37
|
+
z_padding,
|
|
38
|
+
index_of_refraction_media,
|
|
39
|
+
numerical_aperture_illumination,
|
|
40
|
+
numerical_aperture_detection,
|
|
41
|
+
fourier_oversample_factor=fourier_oversample_factor,
|
|
42
42
|
)
|
|
43
43
|
|
|
44
44
|
# Display transfer function
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import os
|
|
2
|
+
|
|
2
3
|
import napari
|
|
3
|
-
from napari.experimental import link_layers
|
|
4
4
|
import numpy as np
|
|
5
5
|
import torch
|
|
6
|
-
import
|
|
7
|
-
from waveorder import util, optics
|
|
6
|
+
from napari.experimental import link_layers
|
|
8
7
|
from scipy.ndimage import gaussian_filter
|
|
8
|
+
from skimage import measure
|
|
9
|
+
|
|
10
|
+
from waveorder import optics, util
|
|
9
11
|
|
|
10
12
|
# Parameters
|
|
11
13
|
# all lengths must use consistent units e.g. um
|
|
12
14
|
output_dirpath = "./greens_plots"
|
|
13
15
|
os.makedirs(output_dirpath, exist_ok=True)
|
|
14
|
-
grid_size = 100
|
|
16
|
+
grid_size = 100 # 300 for publication
|
|
15
17
|
blur_width = grid_size // 35 # blurring to smooth sharp corners
|
|
16
18
|
zyx_shape = 3 * (grid_size,)
|
|
17
19
|
yx_pixel_size = 6.5 / 63
|
{waveorder-2.2.0 → waveorder-2.2.1b0}/examples/visuals/plot_vector_transfer_function_support.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
1
3
|
import napari
|
|
2
4
|
import numpy as np
|
|
3
|
-
import os
|
|
4
|
-
import matplotlib.pyplot as plt
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def plot_otf_support(
|
|
@@ -28,8 +28,14 @@ def plot_otf_support(
|
|
|
28
28
|
points = np.array(
|
|
29
29
|
[
|
|
30
30
|
[0, 0],
|
|
31
|
-
[
|
|
32
|
-
|
|
31
|
+
[
|
|
32
|
+
det_na - ill_na,
|
|
33
|
+
(1 - ill_na**2) ** 0.5 - (1 - det_na**2) ** 0.5,
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
det_na + ill_na,
|
|
37
|
+
(1 - ill_na**2) ** 0.5 - (1 - det_na**2) ** 0.5,
|
|
38
|
+
],
|
|
33
39
|
[2 * ill_na, 0],
|
|
34
40
|
]
|
|
35
41
|
)
|
|
@@ -203,7 +209,6 @@ my_colors = [
|
|
|
203
209
|
]
|
|
204
210
|
|
|
205
211
|
for my_color in my_colors:
|
|
206
|
-
|
|
207
212
|
plot_otf_support(
|
|
208
213
|
ill_na,
|
|
209
214
|
det_na,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import pytest
|
|
2
1
|
import numpy as np
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
3
4
|
from waveorder.models import phase_thick_3d
|
|
4
5
|
|
|
5
6
|
|
|
@@ -27,7 +28,6 @@ def simulate_phase_recon(
|
|
|
27
28
|
z_pixel_size_um=0.1,
|
|
28
29
|
yx_pixel_size_um=6.5 / 63,
|
|
29
30
|
):
|
|
30
|
-
|
|
31
31
|
z_fov_um = 50
|
|
32
32
|
yx_fov_um = 50
|
|
33
33
|
|
|
@@ -98,4 +98,4 @@ def test_phase_invariance():
|
|
|
98
98
|
|
|
99
99
|
# test yx pixel size invariance
|
|
100
100
|
recon2 = simulate_phase_recon(yx_pixel_size_um=0.7 * 6.5 / 63)
|
|
101
|
-
assert np.abs((recon2 - recon) / recon) < 0.02
|
|
101
|
+
assert np.abs((recon2 - recon) / recon) < 0.02
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
import torch
|
|
3
|
+
|
|
4
|
+
from waveorder import filter
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_apply_transfer_function_filter():
|
|
8
|
+
input_array = torch.tensor([[[1.0, 2.0], [3.0, 4.0]]])
|
|
9
|
+
transfer_function_bank = torch.tensor([[[[1, 0], [0, 0]]]])
|
|
10
|
+
result = filter.apply_filter_bank(transfer_function_bank, input_array)
|
|
11
|
+
expected = torch.tensor([[[10, 10], [10, 10]]]) / 4
|
|
12
|
+
assert torch.allclose(result, expected)
|
|
13
|
+
|
|
14
|
+
# Test with incompatible shapes
|
|
15
|
+
input_array = torch.tensor([[[1.0, 2.0], [3.0, 4.0]]])
|
|
16
|
+
transfer_function_bank = torch.tensor(
|
|
17
|
+
[[[[0.5, 0.5, 0.5], [0.5, 0.5, 0.5]]]]
|
|
18
|
+
)
|
|
19
|
+
with pytest.raises(ValueError):
|
|
20
|
+
filter.apply_filter_bank(transfer_function_bank, input_array)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_stretched_multiply():
|
|
24
|
+
small_array = torch.tensor([[1, 2], [3, 4]])
|
|
25
|
+
large_array = torch.tensor(
|
|
26
|
+
[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
|
|
27
|
+
)
|
|
28
|
+
result = filter.stretched_multiply(small_array, large_array)
|
|
29
|
+
expected = torch.tensor(
|
|
30
|
+
[[1, 2, 6, 8], [5, 6, 14, 16], [27, 30, 44, 48], [39, 42, 60, 64]]
|
|
31
|
+
)
|
|
32
|
+
assert torch.all(result == expected)
|
|
33
|
+
assert torch.all(
|
|
34
|
+
filter.stretched_multiply(large_array, large_array) == large_array**2
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# Test that output dims are correct
|
|
38
|
+
rand_array_3x3x3 = torch.rand((3, 3, 3))
|
|
39
|
+
rand_array_99x99x99 = torch.rand((99, 99, 99))
|
|
40
|
+
result = filter.stretched_multiply(rand_array_3x3x3, rand_array_99x99x99)
|
|
41
|
+
assert result.shape == (99, 99, 99)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_stretched_multiply_incompatible_dims():
|
|
45
|
+
# small_array > large_array
|
|
46
|
+
small_array = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
|
|
47
|
+
large_array = torch.tensor([[1, 2], [3, 4]])
|
|
48
|
+
with pytest.raises(ValueError):
|
|
49
|
+
filter.stretched_multiply(small_array, large_array)
|
|
50
|
+
|
|
51
|
+
# Mismatched dims
|
|
52
|
+
small_array = torch.tensor([[1, 2], [3, 4]])
|
|
53
|
+
large_array = torch.tensor(
|
|
54
|
+
[[[1, 2], [4, 5], [7, 8]], [[10, 11], [13, 14], [16, 17]]]
|
|
55
|
+
)
|
|
56
|
+
with pytest.raises(ValueError):
|
|
57
|
+
filter.stretched_multiply(small_array, large_array)
|