Skip to content

Commit 6bae600

Browse files
d33bspre-commit-ci-lite[bot]jenna-tomkinson
authored
Enable 3D visualizations with CytoDataFrame (#186)
* trame-based display * add 3d image example data for testing * 3d framing * visual adjustments * docs, tests, notebook example * linting * Update poetry.lock * [pre-commit.ci lite] apply automatic fixes * updates for test coverage * [pre-commit.ci lite] apply automatic fixes * remove unused zarr test data * address coderabbit review suggestions * [pre-commit.ci lite] apply automatic fixes * address coderabbit review suggestions * [pre-commit.ci lite] apply automatic fixes * address copilot review suggestions * [pre-commit.ci lite] apply automatic fixes * updates from copilot review * [pre-commit.ci lite] apply automatic fixes * readd pytest-cov * [pre-commit.ci lite] apply automatic fixes * address coderabbit review suggestions * address issues with pyproject file * Update pyproject.toml * update lockfile * [pre-commit.ci lite] apply automatic fixes * fix installs and code cov * [pre-commit.ci lite] apply automatic fixes * override opts * fix yaml issue * Update cytodataframe_at_a_glance.ipynb * Update cytodataframe_at_a_glance.py Co-Authored-By: Jenna Tomkinson <107513215+jenna-tomkinson@users.noreply.github.com> * remove col specificity for 3d example Co-Authored-By: Jenna Tomkinson <107513215+jenna-tomkinson@users.noreply.github.com> * docstring for build_3d_image_html_stub Co-Authored-By: Jenna Tomkinson <107513215+jenna-tomkinson@users.noreply.github.com> * updates from review Co-Authored-By: Jenna Tomkinson <107513215+jenna-tomkinson@users.noreply.github.com> * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Jenna Tomkinson <107513215+jenna-tomkinson@users.noreply.github.com>
1 parent 56aa698 commit 6bae600

28 files changed

Lines changed: 4328 additions & 1582 deletions

.github/workflows/run-tests.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# used for running tests
33
name: tests
44

5-
on:
5+
"on":
66
push:
77
branches: [main]
88
pull_request:
@@ -28,7 +28,7 @@ jobs:
2828
run: |
2929
poetry version 99.0.0
3030
- name: Install environment
31-
run: poetry install --no-interaction --no-ansi
31+
run: poetry install --with dev --no-interaction --no-ansi
3232
# run pre-commit
3333
- uses: pre-commit/action@v3.0.1
3434
id: pre_commit
@@ -57,15 +57,17 @@ jobs:
5757
run: |
5858
poetry version 99.0.0
5959
- name: Install environment
60-
run: poetry install --no-interaction --no-ansi
60+
run: poetry install --with dev --no-interaction --no-ansi
6161
- name: Run pytest (non-3.13)
6262
if: ${{ matrix.python_version != '3.13' }}
6363
# run all tests
64-
run: poetry run pytest
64+
run: poetry run pytest -o addopts=
6565
- name: Run pytest (py 3.13)
6666
if: ${{ matrix.python_version == '3.13' }}
6767
# run all tests except integration tests with cosmicqc
68-
run: poetry run pytest --ignore=tests/test_project_integration.py
68+
run: |
69+
poetry run pytest -o addopts= \
70+
--ignore=tests/test_project_integration.py
6971
- name: Reset version to 0.0.0
7072
run: |
7173
poetry version 0.0.0

.pre-commit-config.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ repos:
3131
.*\.lock |
3232
.*\.json |
3333
.*\.ipynb |
34-
.*\.cppipe
34+
.*\.cppipe |
35+
tests/data/CP_tutorial_3D_noise_nuclei_segmentation/output/MyExpt_Experiment\.csv
3536
)$
3637
- repo: https://github.com/executablebooks/mdformat
3738
rev: 0.7.18
@@ -53,25 +54,26 @@ repos:
5354
hooks:
5455
- id: actionlint
5556
- repo: https://github.com/astral-sh/ruff-pre-commit
56-
rev: "v0.14.14"
57+
rev: "v0.15.0"
5758
hooks:
5859
- id: ruff-format
5960
- id: ruff-check
6061
- repo: https://github.com/software-gardening/almanack
61-
rev: v0.1.13
62+
rev: v0.1.15
6263
hooks:
6364
- id: almanack-check
6465
- repo: https://gitlab.com/vojko.pribudic.foss/pre-commit-update
6566
rev: v0.6.0
6667
hooks:
6768
- id: pre-commit-update
68-
args: ["--keep", "mdformat", "--keep", "pre-commit-update", "--keep", "cffconvert"]
69+
args: ["--keep", "mdformat", "--keep", "pre-commit-update", "--keep", "cffconvert",
70+
"--keep", "pyproject-fmt"]
6971
- repo: local
7072
hooks:
7173
- id: code-cov-gen
7274
name: Generate code coverage
7375
language: system
74-
entry: poetry run coverage run -m pytest
76+
entry: poetry run coverage run -m pytest -o addopts=
7577
pass_filenames: false
7678
always_run: true
7779
- repo: https://github.com/Weird-Sheep-Labs/coverage-pre-commit

CITATION.cff

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,39 @@ references:
168168
JUMP (cpg0000-jump-pilot) was used to help demonstrate CytoDataFrame performance
169169
with large data. See here for more information:
170170
https://github.com/broadinstitute/cellpainting-gallery
171+
- type: article
172+
authors:
173+
- family-names: Blin
174+
given-names: Guillaume
175+
- family-names: Sadurska
176+
given-names: Dominika
177+
- family-names: Portero Migueles
178+
given-names: Rafael
179+
- family-names: Chen
180+
given-names: Ni
181+
- family-names: Watson
182+
given-names: James A.
183+
- family-names: Lowell
184+
given-names: Sally
185+
title: "Nessys: A new set of tools for the automated detection of nuclei within intact tissues and dense 3D cultures"
186+
journal: PLoS Biology
187+
volume: "17"
188+
issue: "8"
189+
pages: e3000388
190+
year: 2019
191+
doi: "10.1371/journal.pbio.3000388"
192+
url: "https://doi.org/10.1371/journal.pbio.3000388"
193+
notes: >
194+
This work used the file "6001240_labels.zarr" from the DISCEPTS imaging
195+
dataset, available through the Image Data Resource (IDR) under accession
196+
number idr0062.
197+
- type: data
198+
title: "3D Noise Nuclei Segmentation Tutorial"
199+
authors:
200+
- name: "CellProfiler Tutorials Team"
201+
url: "https://tutorials.cellprofiler.org/#3d-noise-nuclei-segmentation"
202+
publisher:
203+
name: "CellProfiler Organization"
204+
notes: >
205+
This work uses data that were slightly modified from the
206+
CellProfiler 3D Noise Nuclei Segmentation tutorial.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ With CytoDataFrame you can:
2222
- View image objects alongside their feature data using a Pandas DataFrame-like interface.
2323
- Highlight image objects using mask or outline files to understand their segmentation.
2424
- Adjust image displays on-the-fly using interactive slider widgets.
25+
- Automatically detect 3D image volumes and render interactive [trame](https://github.com/Kitware/trame) views in notebooks when 3D dependencies are installed (with graceful fallback otherwise).
26+
27+
For 3D notebook display behavior:
28+
29+
- 3D-aware rendering is enabled by default (`display_options={"auto_trame_for_3d": True}`).
30+
- Disable automatic trame switching with `display_options={"auto_trame_for_3d": False}`.
31+
- Force trame layout regardless of auto-detection with `display_options={"view": "trame"}`.
2532

2633
📓 ___Want to see CytoDataFrame in action?___ Check out our [example notebook](docs/src/examples/cytodataframe_at_a_glance.ipynb) for a quick tour of its key features.
2734

docs/src/contributing.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ You can run pytest on your work using the following example:
5353
% poetry run pytest
5454
```
5555

56+
Pytest output includes a terminal coverage summary to help track current
57+
coverage and uncovered lines.
58+
5659
## Making changes to this repository
5760

5861
We welcome anyone to use [GitHub issues](https://docs.github.com/en/issues/tracking-your-work-with-issues/about-issues) (requires a GitHub login) or create [pull requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) (to directly make changes within this repository) to modify content found within this repository.

docs/src/examples/cytodataframe_at_a_glance.ipynb

Lines changed: 126 additions & 1455 deletions
Large diffs are not rendered by default.

docs/src/examples/cytodataframe_at_a_glance.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# extension: .py
66
# format_name: light
77
# format_version: '1.5'
8-
# jupytext_version: 1.18.1
8+
# jupytext_version: 1.17.3
99
# kernelspec:
10-
# display_name: Python 3 (ipykernel)
10+
# display_name: cytodataframe-shAZamSV-py3.12
1111
# language: python
1212
# name: python3
1313
# ---
@@ -338,3 +338,19 @@
338338

339339
# read OME Parquet file into the CytoDataFrame
340340
CytoDataFrame(data="example.ome.parquet")
341+
342+
# +
343+
# %%time
344+
# 3D example dataset, showing how
345+
# CytoDataFrame can be used with 3D data for visualization.
346+
cp_3d_path = "../../../tests/data/CP_tutorial_3D_noise_nuclei_segmentation"
347+
348+
# send the data to CytoDataFrame
349+
# note: because we have 3d input images, CytoDataFrame will automatically process
350+
# using the 3D display options for interactive visualization.
351+
cdf = CytoDataFrame(
352+
data=pathlib.Path(cp_3d_path) / "output/MyExpt_RealsizeNuclei.csv",
353+
data_context_dir=str(pathlib.Path(cp_3d_path) / "input"),
354+
)
355+
356+
cdf[["ImageNumber", "ObjectNumber", "FileName_Nuclei"]][:3]

media/coverage-badge.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)