bioio-vsi 0.1.0__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.
Files changed (81) hide show
  1. bioio_vsi-0.1.0/.github/workflows/ci.yml +58 -0
  2. bioio_vsi-0.1.0/.github/workflows/publish.yml +85 -0
  3. bioio_vsi-0.1.0/.gitignore +11 -0
  4. bioio_vsi-0.1.0/AGENTS.md +61 -0
  5. bioio_vsi-0.1.0/CLAUDE.md +2 -0
  6. bioio_vsi-0.1.0/Justfile +15 -0
  7. bioio_vsi-0.1.0/LICENSE +29 -0
  8. bioio_vsi-0.1.0/PKG-INFO +134 -0
  9. bioio_vsi-0.1.0/README.md +105 -0
  10. bioio_vsi-0.1.0/bioio_vsi/__init__.py +77 -0
  11. bioio_vsi-0.1.0/bioio_vsi/__main__.py +92 -0
  12. bioio_vsi-0.1.0/bioio_vsi/_accessors.py +451 -0
  13. bioio_vsi-0.1.0/bioio_vsi/_anonymize.py +393 -0
  14. bioio_vsi-0.1.0/bioio_vsi/_anonymize_dates.py +131 -0
  15. bioio_vsi-0.1.0/bioio_vsi/_anonymize_tiff.py +161 -0
  16. bioio_vsi-0.1.0/bioio_vsi/_codecs.py +46 -0
  17. bioio_vsi-0.1.0/bioio_vsi/_describe.py +287 -0
  18. bioio_vsi-0.1.0/bioio_vsi/_describe_redact.py +327 -0
  19. bioio_vsi-0.1.0/bioio_vsi/_ets.py +724 -0
  20. bioio_vsi-0.1.0/bioio_vsi/_fixture_pixels.py +447 -0
  21. bioio_vsi-0.1.0/bioio_vsi/_materialize.py +263 -0
  22. bioio_vsi-0.1.0/bioio_vsi/_paths.py +12 -0
  23. bioio_vsi-0.1.0/bioio_vsi/_stack.py +634 -0
  24. bioio_vsi-0.1.0/bioio_vsi/_synthetic_numbers.py +169 -0
  25. bioio_vsi-0.1.0/bioio_vsi/_tree.py +332 -0
  26. bioio_vsi-0.1.0/bioio_vsi/_vsi.py +615 -0
  27. bioio_vsi-0.1.0/bioio_vsi/errors.py +123 -0
  28. bioio_vsi-0.1.0/bioio_vsi/py.typed +0 -0
  29. bioio_vsi-0.1.0/bioio_vsi/reader.py +435 -0
  30. bioio_vsi-0.1.0/bioio_vsi/reader_metadata.py +18 -0
  31. bioio_vsi-0.1.0/bioio_vsi/tests/__init__.py +0 -0
  32. bioio_vsi-0.1.0/bioio_vsi/tests/conftest.py +55 -0
  33. bioio_vsi-0.1.0/bioio_vsi/tests/content_check.py +82 -0
  34. bioio_vsi-0.1.0/bioio_vsi/tests/interpreted_paths.py +637 -0
  35. bioio_vsi-0.1.0/bioio_vsi/tests/pixel_hash.py +17 -0
  36. bioio_vsi-0.1.0/bioio_vsi/tests/resources/ATTRIBUTION.md +6 -0
  37. bioio_vsi-0.1.0/bioio_vsi/tests/resources/_vsi-ets-test-jpg2k_/stack1/frame_t_0.ets +0 -0
  38. bioio_vsi-0.1.0/bioio_vsi/tests/resources/anonymised/czt-z-up/_anon_/stack1/frame_t_0.ets.skel +0 -0
  39. bioio_vsi-0.1.0/bioio_vsi/tests/resources/anonymised/czt-z-up/anon.vsi +0 -0
  40. bioio_vsi-0.1.0/bioio_vsi/tests/resources/anonymised/expected.json +156 -0
  41. bioio_vsi-0.1.0/bioio_vsi/tests/resources/anonymised/single-plane/_anon_/stack1/frame_t_0.ets.skel +0 -0
  42. bioio_vsi-0.1.0/bioio_vsi/tests/resources/anonymised/single-plane/anon.vsi +0 -0
  43. bioio_vsi-0.1.0/bioio_vsi/tests/resources/anonymised/stitched-origin-1/_anon_/stack1/frame_t_0.ets.skel +0 -0
  44. bioio_vsi-0.1.0/bioio_vsi/tests/resources/anonymised/stitched-origin-1/anon.vsi +0 -0
  45. bioio_vsi-0.1.0/bioio_vsi/tests/resources/anonymised/stitched-origin-15/_anon_/stack1/frame_t_0.ets.skel +0 -0
  46. bioio_vsi-0.1.0/bioio_vsi/tests/resources/anonymised/stitched-origin-15/anon.vsi +0 -0
  47. bioio_vsi-0.1.0/bioio_vsi/tests/resources/anonymised/tzc-z-down/_anon_/stack1/frame_t_0.ets.skel +0 -0
  48. bioio_vsi-0.1.0/bioio_vsi/tests/resources/anonymised/tzc-z-down/anon.vsi +0 -0
  49. bioio_vsi-0.1.0/bioio_vsi/tests/resources/describe_redacted_committed.txt +9 -0
  50. bioio_vsi-0.1.0/bioio_vsi/tests/resources/vsi-ets-test-jpg2k.vsi +0 -0
  51. bioio_vsi-0.1.0/bioio_vsi/tests/synthetic.py +449 -0
  52. bioio_vsi-0.1.0/bioio_vsi/tests/test_anonymised_fixtures.py +95 -0
  53. bioio_vsi-0.1.0/bioio_vsi/tests/test_anonymize.py +261 -0
  54. bioio_vsi-0.1.0/bioio_vsi/tests/test_bioio_reader.py +232 -0
  55. bioio_vsi-0.1.0/bioio_vsi/tests/test_committed_sample.py +69 -0
  56. bioio_vsi-0.1.0/bioio_vsi/tests/test_describe.py +49 -0
  57. bioio_vsi-0.1.0/bioio_vsi/tests/test_ets_index.py +383 -0
  58. bioio_vsi-0.1.0/bioio_vsi/tests/test_fixture_pixels.py +90 -0
  59. bioio_vsi-0.1.0/bioio_vsi/tests/test_materialize.py +144 -0
  60. bioio_vsi-0.1.0/bioio_vsi/tests/test_metadata.py +361 -0
  61. bioio_vsi-0.1.0/bioio_vsi/tests/test_paths_pickling.py +55 -0
  62. bioio_vsi-0.1.0/bioio_vsi/tests/test_pixel_read.py +113 -0
  63. bioio_vsi-0.1.0/bioio_vsi/tests/test_public_samples.py +92 -0
  64. bioio_vsi-0.1.0/bioio_vsi/tests/test_redact.py +523 -0
  65. bioio_vsi-0.1.0/bioio_vsi/tests/test_refusal.py +209 -0
  66. bioio_vsi-0.1.0/bioio_vsi/tests/test_tree_parse.py +141 -0
  67. bioio_vsi-0.1.0/bioio_vsi/tests/tree_rewrite.py +53 -0
  68. bioio_vsi-0.1.0/bioio_vsi.egg-info/PKG-INFO +134 -0
  69. bioio_vsi-0.1.0/bioio_vsi.egg-info/SOURCES.txt +79 -0
  70. bioio_vsi-0.1.0/bioio_vsi.egg-info/dependency_links.txt +1 -0
  71. bioio_vsi-0.1.0/bioio_vsi.egg-info/entry_points.txt +2 -0
  72. bioio_vsi-0.1.0/bioio_vsi.egg-info/requires.txt +19 -0
  73. bioio_vsi-0.1.0/bioio_vsi.egg-info/scm_file_list.json +75 -0
  74. bioio_vsi-0.1.0/bioio_vsi.egg-info/scm_version.json +8 -0
  75. bioio_vsi-0.1.0/bioio_vsi.egg-info/top_level.txt +1 -0
  76. bioio_vsi-0.1.0/docs/design.md +111 -0
  77. bioio_vsi-0.1.0/docs/format.md +338 -0
  78. bioio_vsi-0.1.0/docs/samples.md +80 -0
  79. bioio_vsi-0.1.0/pyproject.toml +73 -0
  80. bioio_vsi-0.1.0/setup.cfg +4 -0
  81. bioio_vsi-0.1.0/uv.lock +2257 -0
@@ -0,0 +1,58 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ lint-type-test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ python-version: ["3.10", "3.13"]
14
+ codecs: ["", "codecs"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: astral-sh/setup-uv@v5
18
+ with:
19
+ python-version: ${{ matrix.python-version }}
20
+ - name: Install dependencies
21
+ run: |
22
+ extras="test"
23
+ if [ -n "${{ matrix.codecs }}" ]; then
24
+ extras="${extras},${{ matrix.codecs }}"
25
+ fi
26
+ uv sync --extra "$extras"
27
+ - name: Ruff
28
+ run: uv run ruff check bioio_vsi
29
+ - name: Mypy
30
+ run: uv run mypy bioio_vsi
31
+ - name: Pytest
32
+ run: uv run pytest -q
33
+
34
+ wheel:
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+ - uses: astral-sh/setup-uv@v5
39
+ with:
40
+ python-version: "3.13"
41
+ - name: Build sdist and wheel from sdist
42
+ run: |
43
+ uv build --sdist
44
+ SDIST=$(ls -1 dist/*.tar.gz | head -1)
45
+ uv build "$SDIST" --wheel
46
+ - name: Install wheel outside checkout and test
47
+ run: |
48
+ WHEEL=$(ls -1 dist/*.whl | head -1)
49
+ uv venv /tmp/wheel-venv
50
+ uv pip install --python /tmp/wheel-venv/bin/python "$WHEEL"[test,codecs]
51
+ mkdir -p /tmp/wheel-test-cwd
52
+ cd /tmp/wheel-test-cwd
53
+ env -u PYTHONPATH /tmp/wheel-venv/bin/python -c "import bioio_vsi; assert bioio_vsi.__file__.startswith('/tmp/wheel-venv')"
54
+ # The wheel ships without tests; run the checkout's tests against the installed code.
55
+ PKG=$(env -u PYTHONPATH /tmp/wheel-venv/bin/python -c "import bioio_vsi, os; print(os.path.dirname(bioio_vsi.__file__))")
56
+ test ! -e "$PKG/tests"
57
+ cp -r "$GITHUB_WORKSPACE/bioio_vsi/tests" "$PKG/tests"
58
+ env -u PYTHONPATH /tmp/wheel-venv/bin/python -m pytest -q --pyargs bioio_vsi.tests
@@ -0,0 +1,85 @@
1
+ name: Publish
2
+
3
+ # Publishing is release-only: nothing reaches PyPI unless a GitHub release is
4
+ # published for a `v*` tag. No credentials are stored: PyPI trusted publishing
5
+ # (OIDC) mints a short-lived token for this workflow. The version comes from the
6
+ # tag (setuptools-scm).
7
+ #
8
+ # Setup before the first upload (project owner, once):
9
+ # 1. PyPI -> Account -> Publishing -> add a pending trusted publisher:
10
+ # Project: bioio-vsi Owner: szarma Repository: bioio-vsi
11
+ # Workflow: publish.yml Environment: pypi
12
+ # 2. GitHub -> Settings -> Environments -> create `pypi` before the first
13
+ # release (required reviewer: the owner; deployments limited to `v*` tags).
14
+
15
+ on:
16
+ release:
17
+ types: [published]
18
+
19
+ permissions: {}
20
+
21
+ jobs:
22
+ build:
23
+ name: Build distributions
24
+ runs-on: ubuntu-latest
25
+ permissions:
26
+ contents: read
27
+ actions: read
28
+ steps:
29
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
30
+ with:
31
+ fetch-depth: 0
32
+ persist-credentials: false
33
+
34
+ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
35
+ with:
36
+ python-version: "3.12"
37
+
38
+ - name: Released commit must be on main
39
+ run: |
40
+ git fetch -q origin main
41
+ git merge-base --is-ancestor "$GITHUB_SHA" origin/main \
42
+ || { echo "::error::$GITHUB_SHA is not on main"; exit 1; }
43
+
44
+ - name: CI must have succeeded for the released commit
45
+ env:
46
+ GH_TOKEN: ${{ github.token }}
47
+ run: |
48
+ n=$(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?head_sha=$GITHUB_SHA&status=success" --jq '.total_count')
49
+ test "$n" -ge 1 || { echo "::error::no successful CI run for $GITHUB_SHA"; exit 1; }
50
+
51
+ - name: Build sdist and wheel
52
+ run: uv build
53
+
54
+ # A tag that setuptools-scm does not read as a clean release version would
55
+ # upload a dev version to an index that never allows replacing one.
56
+ - name: Built version must match the tag
57
+ run: |
58
+ v="${GITHUB_REF_NAME#v}"
59
+ ls dist/
60
+ test -f "dist/bioio_vsi-$v-py3-none-any.whl" \
61
+ || { echo "::error::no wheel for version $v"; exit 1; }
62
+
63
+ - name: Check metadata renders on the index
64
+ run: uvx 'twine==6.2.0' check --strict dist/*
65
+
66
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
67
+ with:
68
+ name: distributions
69
+ path: dist/
70
+
71
+ pypi:
72
+ name: Upload to PyPI
73
+ needs: build
74
+ runs-on: ubuntu-latest
75
+ environment:
76
+ name: pypi
77
+ url: https://pypi.org/p/bioio-vsi
78
+ permissions:
79
+ id-token: write
80
+ steps:
81
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
82
+ with:
83
+ name: distributions
84
+ path: dist/
85
+ - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
@@ -0,0 +1,11 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.egg-info/
4
+ dist/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ # Downloaded sample images and throwaway probes: never committed.
8
+ data/
9
+ scratch/
10
+ CLAUDE.local.md
11
+ .idea/
@@ -0,0 +1,61 @@
1
+ # bioio-vsi
2
+
3
+ Read `README.md` first: what the reader does, what it refuses, and that the
4
+ format is reverse engineered. This file adds what is needed to change the code.
5
+ The package is a bioio-independent core (`open_vsi`, `open_ets`, `describe`)
6
+ with a bioio `Reader` on top.
7
+
8
+ ## Rules
9
+
10
+ 1. **No JVM and no Bio-Formats at runtime.**
11
+ 2. **Do not copy or translate Bio-Formats code** (GPL), and do not read its
12
+ `CellSensReader` source. Its output may be used as a test oracle. slideio's
13
+ VSI driver is BSD-3 and may be consulted; credit it where it helped.
14
+ 3. **Fail loudly, never guess.** Anything not understood that affects pixels,
15
+ axes or calibration raises a named `VsiError`: a plausible wrong answer
16
+ is worse than a refusal.
17
+ 4. **Stay small.** Runtime dependencies are bioio-base and numpy; codecs are an
18
+ optional extra; slideio is a test oracle only.
19
+ 5. **Read lazily.** Opening reads headers and the tile index; one plane never
20
+ loads the stack.
21
+ 6. **Report metadata as found.** No repairing or rounding of calibration.
22
+ 7. **Sample files:** only files whose licence allows redistribution may be
23
+ committed or back tests; record each in `docs/samples.md`. The `.vsi` tree
24
+ embeds the original file name and path, so treat metadata dumps like the
25
+ file itself.
26
+
27
+ ## Traps
28
+
29
+ - The `.vsi` is a valid TIFF holding only a thumbnail; TIFF readers "succeed".
30
+ - Which `.ets` coordinate slot is z, channel or time differs between files and
31
+ is declared in the `.vsi`. Tile data is not in coordinate order: always go
32
+ through the tile table.
33
+ - A tag number means different things under different parents: address values
34
+ by path.
35
+ - Only `frame_t*.ets` files hold pixels.
36
+ - The oracles (Bio-Formats, slideio) disagree in places; agreement with one is
37
+ not proof. `docs/format.md` records each disagreement.
38
+
39
+ ## Development
40
+
41
+ Python 3.10+ with [uv](https://docs.astral.sh/uv/):
42
+
43
+ ```bash
44
+ uv sync --extra test --extra codecs
45
+ just check # ruff, mypy, pytest
46
+ just release-check # before a release: public samples, codecs and slideio must be present
47
+ uv run python -m bioio_vsi describe path/to/file.vsi
48
+ ```
49
+
50
+ Larger public samples are found through `VSI_PUBLIC_SAMPLES` (default `data/`,
51
+ gitignored); their tests skip when absent.
52
+
53
+ ## Documentation
54
+
55
+ - `docs/format.md` is the format specification, with how each fact was
56
+ established. The reader is only as good as the files seen: a new fact about
57
+ the format needs evidence from a file, and goes here when the code learns it.
58
+ - `docs/design.md` records the choices the format leaves open, with reasons.
59
+ Change it together with the code.
60
+ - `docs/samples.md` lists public samples, sources and licences.
61
+ - Feature requests and open questions go to the issue tracker, not the docs.
@@ -0,0 +1,2 @@
1
+ @AGENTS.md
2
+ @CLAUDE.local.md
@@ -0,0 +1,15 @@
1
+ # Development commands (uv)
2
+
3
+ test:
4
+ uv run pytest
5
+
6
+ lint:
7
+ uv run ruff check bioio_vsi
8
+ uv run mypy bioio_vsi
9
+
10
+ check: lint test
11
+
12
+ # Before a release: public samples, imagecodecs and slideio must all be present;
13
+ # any test that would skip for lack of them fails instead.
14
+ release-check:
15
+ VSI_RELEASE_CHECK=1 uv run --extra test --extra codecs pytest
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Srdjan Sarikas
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: bioio-vsi
3
+ Version: 0.1.0
4
+ Summary: JVM-free reader for Olympus/Evident cellSens VSI microscopy images
5
+ Author: Srdjan Sarikas
6
+ License: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/szarma/bioio-vsi
8
+ Project-URL: Issues, https://github.com/szarma/bioio-vsi/issues
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: bioio-base
13
+ Requires-Dist: numpy
14
+ Provides-Extra: codecs
15
+ Requires-Dist: imagecodecs; extra == "codecs"
16
+ Provides-Extra: dev
17
+ Requires-Dist: imagecodecs; extra == "dev"
18
+ Requires-Dist: mypy; extra == "dev"
19
+ Requires-Dist: pytest; extra == "dev"
20
+ Requires-Dist: ruff; extra == "dev"
21
+ Requires-Dist: slideio; extra == "dev"
22
+ Provides-Extra: test
23
+ Requires-Dist: pytest; extra == "test"
24
+ Requires-Dist: mypy; extra == "test"
25
+ Requires-Dist: ruff; extra == "test"
26
+ Requires-Dist: slideio; extra == "test"
27
+ Requires-Dist: bioio>=3.5.1; extra == "test"
28
+ Dynamic: license-file
29
+
30
+ # bioio-vsi
31
+
32
+ A small, JVM-free reader for Olympus/Evident cellSens VSI microscopy images
33
+ (a `.vsi` metadata file plus sibling `.ets` pixel files).
34
+
35
+ The format has no public specification (the vendor's exists but is not
36
+ distributed). This reader is reverse engineered
37
+ from sample files, with the tree layout taken from slideio's BSD-3 VSI driver
38
+ (`src/slideio/drivers/vsi`) and checked against those files, and with
39
+ Bio-Formats and slideio output as test oracles. It reads what it has seen and
40
+ refuses the rest; [`docs/format.md`](https://github.com/szarma/bioio-vsi/blob/main/docs/format.md) records what is known and
41
+ how each fact was established.
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ pip install bioio-vsi
47
+ pip install "bioio-vsi[codecs]" # JPEG 2000 tiles (imagecodecs)
48
+
49
+ # bioio plugin (registers on ``bioio.readers``)
50
+ pip install bioio bioio-vsi
51
+ pip install "bioio-vsi[codecs]" # if your files use JPEG 2000
52
+ ```
53
+
54
+ Developers use [uv](https://docs.astral.sh/uv/); see [AGENTS.md](https://github.com/szarma/bioio-vsi/blob/main/AGENTS.md).
55
+
56
+ ## Supported and refused
57
+
58
+ **Reads** single-image cellSens files: uint8/uint16, raw or JPEG 2000 tiles,
59
+ optional pyramids, any declared order of time, z, and channel.
60
+
61
+ **Refuses** (with a named error): missing pixel file, multiple images per
62
+ ``.vsi``, unsupported compression or pixel type, size mismatches, incomplete
63
+ tile grids, lambda/phase dimensions, truncated metadata fields, and unknown
64
+ metadata units.
65
+
66
+ Why each of these is refused, and how values such as z spacing and channel
67
+ names are reported, is in [docs/design.md](https://github.com/szarma/bioio-vsi/blob/main/docs/design.md).
68
+
69
+ ## Usage
70
+
71
+ Standalone API:
72
+
73
+ ```python
74
+ from bioio_vsi import open_vsi, open_ets, describe
75
+
76
+ img = open_vsi("path/to/file.vsi")
77
+ plane = img.read_plane(t=0, c=0, z=0)
78
+
79
+ orphan = open_ets("path/to/frame_t_0.ets") # geometry only, no axis names
80
+ print(describe("path/to/file.vsi"))
81
+ ```
82
+
83
+ Through bioio:
84
+
85
+ ```python
86
+ from bioio import BioImage
87
+
88
+ image = BioImage("path/to/file.vsi")
89
+ stack = image.get_image_dask_data("TCZYX") # dimension order TCZYX
90
+ plane = stack[0, 0, 0].compute()
91
+ print(image.physical_pixel_sizes, image.channel_names)
92
+ ```
93
+
94
+ Z planes are in acquisition order, and in many cellSens stacks z decreases with
95
+ plane index. bioio reports the z spacing as a positive distance; the signed step
96
+ and each plane's position are in `open_vsi(...).z_step_um` and
97
+ `plane_z_positions_um`. Channel names are the per-channel names cellSens stores
98
+ (usually the dye), which can differ from the names Bio-Formats and slideio report.
99
+
100
+ ```bash
101
+ python -m bioio_vsi describe path/to/file.vsi # what the reader sees in a file
102
+ ```
103
+
104
+ ## Reporting a file that fails to open
105
+
106
+ Open an issue with the output of
107
+
108
+ ```bash
109
+ python -m bioio_vsi describe --redact path/to/file.vsi
110
+ ```
111
+
112
+ which leaves out paths, file names and image or channel names (also in error
113
+ lines).
114
+
115
+ If that is not enough and the acquisition cannot be shared, you can send a
116
+ **structure fixture** instead. It keeps the `.ets` headers, tile table and the
117
+ layout of the metadata, and removes pixels, text, dates and previews; measured
118
+ values such as pixel size, positions and times are replaced by synthetic ones:
119
+
120
+ ```bash
121
+ python -m bioio_vsi anonymize path/to/your.vsi /tmp/fixture-out
122
+ ```
123
+
124
+ Upload the resulting ``anon.vsi`` and ``_anon_/stack*/`` ``.skel`` files (not
125
+ your original ``.vsi`` tree). Maintainers can turn the fixture back into a
126
+ viewable file locally with ``python -m bioio_vsi materialize FIXTURE OUTDIR``.
127
+ See [docs/design.md](https://github.com/szarma/bioio-vsi/blob/main/docs/design.md) for what is kept and stripped.
128
+
129
+ ## Sample files wanted
130
+
131
+ The reader only knows the files it has seen. Files under a licence that allows
132
+ redistribution help most, especially older cellSens versions, slide scanners
133
+ (VS120, VS200), stitched scans and long time series; see the
134
+ [issue tracker](https://github.com/szarma/bioio-vsi/issues).
@@ -0,0 +1,105 @@
1
+ # bioio-vsi
2
+
3
+ A small, JVM-free reader for Olympus/Evident cellSens VSI microscopy images
4
+ (a `.vsi` metadata file plus sibling `.ets` pixel files).
5
+
6
+ The format has no public specification (the vendor's exists but is not
7
+ distributed). This reader is reverse engineered
8
+ from sample files, with the tree layout taken from slideio's BSD-3 VSI driver
9
+ (`src/slideio/drivers/vsi`) and checked against those files, and with
10
+ Bio-Formats and slideio output as test oracles. It reads what it has seen and
11
+ refuses the rest; [`docs/format.md`](https://github.com/szarma/bioio-vsi/blob/main/docs/format.md) records what is known and
12
+ how each fact was established.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ pip install bioio-vsi
18
+ pip install "bioio-vsi[codecs]" # JPEG 2000 tiles (imagecodecs)
19
+
20
+ # bioio plugin (registers on ``bioio.readers``)
21
+ pip install bioio bioio-vsi
22
+ pip install "bioio-vsi[codecs]" # if your files use JPEG 2000
23
+ ```
24
+
25
+ Developers use [uv](https://docs.astral.sh/uv/); see [AGENTS.md](https://github.com/szarma/bioio-vsi/blob/main/AGENTS.md).
26
+
27
+ ## Supported and refused
28
+
29
+ **Reads** single-image cellSens files: uint8/uint16, raw or JPEG 2000 tiles,
30
+ optional pyramids, any declared order of time, z, and channel.
31
+
32
+ **Refuses** (with a named error): missing pixel file, multiple images per
33
+ ``.vsi``, unsupported compression or pixel type, size mismatches, incomplete
34
+ tile grids, lambda/phase dimensions, truncated metadata fields, and unknown
35
+ metadata units.
36
+
37
+ Why each of these is refused, and how values such as z spacing and channel
38
+ names are reported, is in [docs/design.md](https://github.com/szarma/bioio-vsi/blob/main/docs/design.md).
39
+
40
+ ## Usage
41
+
42
+ Standalone API:
43
+
44
+ ```python
45
+ from bioio_vsi import open_vsi, open_ets, describe
46
+
47
+ img = open_vsi("path/to/file.vsi")
48
+ plane = img.read_plane(t=0, c=0, z=0)
49
+
50
+ orphan = open_ets("path/to/frame_t_0.ets") # geometry only, no axis names
51
+ print(describe("path/to/file.vsi"))
52
+ ```
53
+
54
+ Through bioio:
55
+
56
+ ```python
57
+ from bioio import BioImage
58
+
59
+ image = BioImage("path/to/file.vsi")
60
+ stack = image.get_image_dask_data("TCZYX") # dimension order TCZYX
61
+ plane = stack[0, 0, 0].compute()
62
+ print(image.physical_pixel_sizes, image.channel_names)
63
+ ```
64
+
65
+ Z planes are in acquisition order, and in many cellSens stacks z decreases with
66
+ plane index. bioio reports the z spacing as a positive distance; the signed step
67
+ and each plane's position are in `open_vsi(...).z_step_um` and
68
+ `plane_z_positions_um`. Channel names are the per-channel names cellSens stores
69
+ (usually the dye), which can differ from the names Bio-Formats and slideio report.
70
+
71
+ ```bash
72
+ python -m bioio_vsi describe path/to/file.vsi # what the reader sees in a file
73
+ ```
74
+
75
+ ## Reporting a file that fails to open
76
+
77
+ Open an issue with the output of
78
+
79
+ ```bash
80
+ python -m bioio_vsi describe --redact path/to/file.vsi
81
+ ```
82
+
83
+ which leaves out paths, file names and image or channel names (also in error
84
+ lines).
85
+
86
+ If that is not enough and the acquisition cannot be shared, you can send a
87
+ **structure fixture** instead. It keeps the `.ets` headers, tile table and the
88
+ layout of the metadata, and removes pixels, text, dates and previews; measured
89
+ values such as pixel size, positions and times are replaced by synthetic ones:
90
+
91
+ ```bash
92
+ python -m bioio_vsi anonymize path/to/your.vsi /tmp/fixture-out
93
+ ```
94
+
95
+ Upload the resulting ``anon.vsi`` and ``_anon_/stack*/`` ``.skel`` files (not
96
+ your original ``.vsi`` tree). Maintainers can turn the fixture back into a
97
+ viewable file locally with ``python -m bioio_vsi materialize FIXTURE OUTDIR``.
98
+ See [docs/design.md](https://github.com/szarma/bioio-vsi/blob/main/docs/design.md) for what is kept and stripped.
99
+
100
+ ## Sample files wanted
101
+
102
+ The reader only knows the files it has seen. Files under a licence that allows
103
+ redistribution help most, especially older cellSens versions, slide scanners
104
+ (VS120, VS200), stitched scans and long time series; see the
105
+ [issue tracker](https://github.com/szarma/bioio-vsi/issues).
@@ -0,0 +1,77 @@
1
+ """JVM-free reader for Olympus/Evident cellSens VSI microscopy images."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import TYPE_CHECKING, Any, Literal, cast
7
+
8
+ from bioio_vsi._describe import describe_vsi as describe
9
+ from bioio_vsi._paths import resolve_path
10
+ from bioio_vsi._stack import OrphanEtsImage, VsiImage
11
+ from bioio_vsi._vsi import load_vsi
12
+ from bioio_vsi.errors import VsiError
13
+
14
+ if TYPE_CHECKING:
15
+ from bioio_vsi.reader import Reader
16
+ from bioio_vsi.reader_metadata import ReaderMetadata
17
+
18
+ __all__ = [
19
+ "VsiError",
20
+ "Reader",
21
+ "ReaderMetadata",
22
+ "anonymize",
23
+ "describe",
24
+ "materialize",
25
+ "expected_tile_pixels",
26
+ "open_ets",
27
+ "open_vsi",
28
+ "OrphanEtsImage",
29
+ "VsiImage",
30
+ ]
31
+
32
+
33
+ def open_vsi(path: str) -> VsiImage:
34
+ """Open a single-image cellSens VSI and its external ETS pixel file."""
35
+ meta = load_vsi(path)
36
+ return VsiImage(meta)
37
+
38
+
39
+ def anonymize(path: str, out_dir: str, *, synthetic_numbers: bool = True) -> Path:
40
+ from bioio_vsi._anonymize import anonymize as _anonymize
41
+
42
+ return _anonymize(path, out_dir, synthetic_numbers=synthetic_numbers)
43
+
44
+
45
+ def materialize(
46
+ fixture_dir: str,
47
+ out_dir: str,
48
+ *,
49
+ planes: str = "default",
50
+ ) -> Path:
51
+ from bioio_vsi._materialize import materialize as _materialize
52
+
53
+ p: Literal["default", "all"] = cast(Literal["default", "all"], planes)
54
+ return _materialize(fixture_dir, out_dir, planes=p)
55
+
56
+
57
+ def expected_tile_pixels(**kwargs: Any) -> Any:
58
+ from bioio_vsi._fixture_pixels import expected_tile_pixels as _fn
59
+
60
+ return _fn(**kwargs)
61
+
62
+
63
+ def open_ets(path: str) -> OrphanEtsImage:
64
+ """Open an orphan ETS pixel file (geometry only, no axis labels)."""
65
+ return OrphanEtsImage(resolve_path(path))
66
+
67
+
68
+ def __getattr__(name: str) -> Any:
69
+ if name == "Reader":
70
+ from bioio_vsi.reader import Reader as _Reader
71
+
72
+ return _Reader
73
+ if name == "ReaderMetadata":
74
+ from bioio_vsi.reader_metadata import ReaderMetadata as _ReaderMetadata
75
+
76
+ return _ReaderMetadata
77
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -0,0 +1,92 @@
1
+ """CLI entry point: python -m bioio_vsi describe FILE"""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import sys
7
+
8
+ from bioio_vsi import describe
9
+ from bioio_vsi.errors import VsiError
10
+
11
+
12
+ def main(argv: list[str] | None = None) -> int:
13
+ parser = argparse.ArgumentParser(prog="bioio_vsi", description="Inspect cellSens VSI files")
14
+ sub = parser.add_subparsers(dest="command", required=True)
15
+ anon = sub.add_parser("anonymize", help="Write an anonymised structure fixture")
16
+ anon.add_argument("path", help="Path to a .vsi file")
17
+ anon.add_argument("out_dir", help="Output directory for anon.vsi and .skel files")
18
+ anon.add_argument(
19
+ "--keep-numbers",
20
+ action="store_true",
21
+ help="Keep measured values (pixel size, z, times, wavelengths, device settings) "
22
+ "as stored instead of replacing them with synthetic ones",
23
+ )
24
+ mat = sub.add_parser("materialize", help="Rebuild a viewable file from a fixture")
25
+ mat.add_argument("fixture_dir", help="Directory containing anon.vsi")
26
+ mat.add_argument("out_dir", help="Output directory")
27
+ mat.add_argument(
28
+ "--planes",
29
+ choices=("default", "all"),
30
+ default="default",
31
+ help=(
32
+ "Which planes receive synthetic pixels (default: the first plane at each "
33
+ "level of at most 64 MiB, and always at the smallest level)"
34
+ ),
35
+ )
36
+ desc = sub.add_parser("describe", help="Print metadata without reading pixels")
37
+ desc.add_argument("path", help="Path to a .vsi file")
38
+ desc.add_argument(
39
+ "--redact",
40
+ action="store_true",
41
+ help="Omit paths and names (safe to attach to public issues)",
42
+ )
43
+ args = parser.parse_args(argv)
44
+ if args.command == "anonymize":
45
+ from bioio_vsi._anonymize import anonymize
46
+
47
+ try:
48
+ out = anonymize(args.path, args.out_dir, synthetic_numbers=not args.keep_numbers)
49
+ except VsiError as exc:
50
+ sys.stderr.write(f"{exc}\n")
51
+ return 1
52
+ except OSError as exc:
53
+ sys.stderr.write(f"{exc}\n")
54
+ return 1
55
+ sys.stdout.write(f"{out}\n")
56
+ return 0
57
+ if args.command == "materialize":
58
+ from bioio_vsi._materialize import materialize
59
+
60
+ try:
61
+ out = materialize(args.fixture_dir, args.out_dir, planes=args.planes)
62
+ except VsiError as exc:
63
+ sys.stderr.write(f"{exc}\n")
64
+ return 1
65
+ except OSError as exc:
66
+ sys.stderr.write(f"{exc}\n")
67
+ return 1
68
+ sys.stdout.write(f"{out}\n")
69
+ return 0
70
+ if args.command == "describe":
71
+ if args.redact:
72
+ from bioio_vsi._describe_redact import describe_redacted
73
+
74
+ text, has_error = describe_redacted(args.path)
75
+ sys.stdout.write(text)
76
+ return 1 if has_error else 0
77
+ try:
78
+ sys.stdout.write(describe(args.path, redact=False))
79
+ except VsiError as exc:
80
+ sys.stderr.write(f"{exc}\n")
81
+ return 1
82
+ except OSError as exc:
83
+ sys.stderr.write(f"{exc}\n")
84
+ return 1
85
+ except Exception as exc:
86
+ sys.stderr.write(f"{exc}\n")
87
+ return 1
88
+ return 0
89
+
90
+
91
+ if __name__ == "__main__":
92
+ raise SystemExit(main())