napari-spatialdata 0.4.0__tar.gz → 0.5.0.post0__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.
- napari_spatialdata-0.5.0.post0/.github/workflows/release.yml +30 -0
- napari-spatialdata-0.4.0/.github/workflows/test_and_deploy.yml → napari_spatialdata-0.5.0.post0/.github/workflows/test.yml +0 -26
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/.pre-commit-config.yaml +5 -5
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/CHANGELOG.md +21 -1
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/PKG-INFO +4 -4
- napari_spatialdata-0.5.0.post0/docs/notebooks/scatterwidget.ipynb +172 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/setup.cfg +3 -3
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/__main__.py +1 -1
- napari_spatialdata-0.5.0.post0/src/napari_spatialdata/_annotationwidgets.py +194 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/_model.py +17 -15
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/_scatterwidgets.py +28 -4
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/_sdata_widgets.py +39 -4
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/_version.py +2 -2
- napari_spatialdata-0.5.0.post0/src/napari_spatialdata/_view.py +894 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/_viewer.py +201 -60
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/_widgets.py +126 -34
- {napari-spatialdata-0.4.0/src/napari_spatialdata/_constants → napari_spatialdata-0.5.0.post0/src/napari_spatialdata/constants}/_constants.py +1 -1
- {napari-spatialdata-0.4.0/src/napari_spatialdata/_constants → napari_spatialdata-0.5.0.post0/src/napari_spatialdata/constants}/_utils.py +1 -1
- napari_spatialdata-0.5.0.post0/src/napari_spatialdata/constants/config.py +5 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/napari.yaml +5 -0
- napari_spatialdata-0.5.0.post0/src/napari_spatialdata/resources/exclamation.png +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/utils/_utils.py +32 -17
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata.egg-info/PKG-INFO +4 -4
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata.egg-info/SOURCES.txt +9 -6
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata.egg-info/requires.txt +2 -2
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tests/test_spatialdata.py +12 -10
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tests/test_viewer.py +15 -6
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tests/test_widgets.py +15 -11
- napari-spatialdata-0.4.0/docs/notebooks/scatterwidget.ipynb +0 -235
- napari-spatialdata-0.4.0/src/napari_spatialdata/_constants/config.py +0 -2
- napari-spatialdata-0.4.0/src/napari_spatialdata/_view.py +0 -406
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/.gitignore +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/.mypy.ini +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/.napari/DESCRIPTION.md +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/.readthedocs.yaml +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/LICENSE +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/MANIFEST.in +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/README.md +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/Makefile +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/_static/.gitkeep +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/_templates/.gitkeep +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/_templates/autosummary/class.rst +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/api.md +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/cli.md +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/conf.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/contributing.md +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/extensions/typed_returns.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/index.md +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/make.bat +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/notebooks/mibitof_analysis.ipynb +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/notebooks/nanostring_analysis.ipynb +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/notebooks/spatialdata.ipynb +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/references.bib +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/references.md +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/docs/template_usage.md +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/examples/spatialdata_empty.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/examples/spatialdata_visium.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/pyproject.toml +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/__init__.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/_interactive.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/_reader.py +0 -0
- {napari-spatialdata-0.4.0/src/napari_spatialdata/_constants → napari_spatialdata-0.5.0.post0/src/napari_spatialdata/constants}/__init__.py +0 -0
- {napari-spatialdata-0.4.0/src/napari_spatialdata/_constants → napari_spatialdata-0.5.0.post0/src/napari_spatialdata/constants}/_pkg_constants.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/utils/__init__.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/utils/_categoricals_utils.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/utils/_test_utils.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/utils/_viewer_utils.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata.egg-info/dependency_links.txt +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata.egg-info/entry_points.txt +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata.egg-info/top_level.txt +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tests/__init__.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tests/conftest.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tests/plots/groundtruth/Images_can_add_element_image.png +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tests/plots/groundtruth/Images_can_add_element_label.png +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tests/plots/groundtruth/Images_can_add_element_multiple.png +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tests/test_cli.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tests/test_interactive.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tests/test_scatterwidgets.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tests/test_utils.py +0 -0
- {napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/tox.ini +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
release:
|
|
9
|
+
# requires that you have put your twine API key in your
|
|
10
|
+
# github secrets (see readme for details)
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
if: contains(github.ref, 'tags')
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v2
|
|
15
|
+
- name: Set up Python
|
|
16
|
+
uses: actions/setup-python@v2
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.x"
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: |
|
|
21
|
+
python -m pip install --upgrade pip
|
|
22
|
+
pip install -U setuptools setuptools_scm wheel twine build
|
|
23
|
+
- name: Build and publish
|
|
24
|
+
env:
|
|
25
|
+
TWINE_USERNAME: __token__
|
|
26
|
+
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
|
|
27
|
+
run: |
|
|
28
|
+
git tag
|
|
29
|
+
python -m build .
|
|
30
|
+
twine upload dist/*
|
|
@@ -62,29 +62,3 @@ jobs:
|
|
|
62
62
|
|
|
63
63
|
- name: Coverage
|
|
64
64
|
uses: codecov/codecov-action@v3
|
|
65
|
-
|
|
66
|
-
deploy:
|
|
67
|
-
# this will run when you have tagged a commit, starting with "v*"
|
|
68
|
-
# and requires that you have put your twine API key in your
|
|
69
|
-
# github secrets (see readme for details)
|
|
70
|
-
needs: [test]
|
|
71
|
-
runs-on: ubuntu-latest
|
|
72
|
-
if: contains(github.ref, 'tags')
|
|
73
|
-
steps:
|
|
74
|
-
- uses: actions/checkout@v2
|
|
75
|
-
- name: Set up Python
|
|
76
|
-
uses: actions/setup-python@v2
|
|
77
|
-
with:
|
|
78
|
-
python-version: "3.x"
|
|
79
|
-
- name: Install dependencies
|
|
80
|
-
run: |
|
|
81
|
-
python -m pip install --upgrade pip
|
|
82
|
-
pip install -U setuptools setuptools_scm wheel twine build
|
|
83
|
-
- name: Build and publish
|
|
84
|
-
env:
|
|
85
|
-
TWINE_USERNAME: __token__
|
|
86
|
-
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
|
|
87
|
-
run: |
|
|
88
|
-
git tag
|
|
89
|
-
python -m build .
|
|
90
|
-
twine upload dist/*
|
|
@@ -7,13 +7,13 @@ default_stages:
|
|
|
7
7
|
minimum_pre_commit_version: 2.9.3
|
|
8
8
|
repos:
|
|
9
9
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
10
|
-
rev: v1.
|
|
10
|
+
rev: v1.10.1
|
|
11
11
|
hooks:
|
|
12
12
|
- id: mypy
|
|
13
13
|
additional_dependencies: [numpy>=1.23]
|
|
14
14
|
exclude: docs
|
|
15
15
|
- repo: https://github.com/psf/black
|
|
16
|
-
rev: 24.
|
|
16
|
+
rev: 24.4.2
|
|
17
17
|
hooks:
|
|
18
18
|
- id: black
|
|
19
19
|
additional_dependencies: [toml]
|
|
@@ -22,7 +22,7 @@ repos:
|
|
|
22
22
|
hooks:
|
|
23
23
|
- id: prettier
|
|
24
24
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
25
|
-
rev: v4.
|
|
25
|
+
rev: v4.6.0
|
|
26
26
|
hooks:
|
|
27
27
|
- id: detect-private-key
|
|
28
28
|
- id: check-merge-conflict
|
|
@@ -45,11 +45,11 @@ repos:
|
|
|
45
45
|
- id: check-toml
|
|
46
46
|
- id: requirements-txt-fixer
|
|
47
47
|
- repo: https://github.com/asottile/blacken-docs
|
|
48
|
-
rev: 1.
|
|
48
|
+
rev: 1.18.0
|
|
49
49
|
hooks:
|
|
50
50
|
- id: blacken-docs
|
|
51
51
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
52
|
-
rev: v0.
|
|
52
|
+
rev: v0.5.0
|
|
53
53
|
hooks:
|
|
54
54
|
- id: ruff
|
|
55
55
|
args: [--fix, --exit-non-zero-on-fix]
|
|
@@ -8,7 +8,27 @@ and this project adheres to [Semantic Versioning][].
|
|
|
8
8
|
[keep a changelog]: https://keepachangelog.com/en/1.0.0/
|
|
9
9
|
[semantic versioning]: https://semver.org/spec/v2.0.0.html
|
|
10
10
|
|
|
11
|
-
## [0.
|
|
11
|
+
## [0.5.1] - 2024-xx-xx
|
|
12
|
+
|
|
13
|
+
## [0.5.0] - 2024-07-03
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- New annotation widget for managing shapes annotations @melonora #233 #261
|
|
18
|
+
- Showing image channel names in var widget for easy channel selection #254
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- Fixed scatterplot widget #247
|
|
23
|
+
- Fixed contrast limits for images #265
|
|
24
|
+
|
|
25
|
+
## [0.4.1] - 2024-03-30
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- Saving shapes and points with `Shift + E` now saves 2D data (a z dim was wrongly added)
|
|
30
|
+
|
|
31
|
+
## [0.4.0] - 2024-03-24
|
|
12
32
|
|
|
13
33
|
### Added
|
|
14
34
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: napari-spatialdata
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0.post0
|
|
4
4
|
Summary: Interactive visualization of spatial omics data with napari
|
|
5
5
|
Home-page: https://github.com/scverse/napari-spatialdata.git
|
|
6
6
|
Author: giovanni palla
|
|
7
7
|
Author-email: giov.pll@gmail.com
|
|
8
8
|
License: BSD-3-Clause
|
|
9
9
|
Project-URL: Bug Tracker, https://github.com/scverse/napari-spatialdata/issues
|
|
10
|
-
Project-URL: Documentation, https://
|
|
10
|
+
Project-URL: Documentation, https://spatialdata.scverse.org/projects/napari/en/latest/notebooks/spatialdata.html
|
|
11
11
|
Project-URL: Source Code, https://github.com/scverse/napari-spatialdata
|
|
12
12
|
Project-URL: User Support, https://github.com/scverse/napari-spatialdata/issues
|
|
13
13
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
@@ -26,11 +26,11 @@ License-File: LICENSE
|
|
|
26
26
|
Requires-Dist: anndata
|
|
27
27
|
Requires-Dist: click
|
|
28
28
|
Requires-Dist: cycler
|
|
29
|
-
Requires-Dist: dask
|
|
29
|
+
Requires-Dist: dask<=2024.2.1
|
|
30
30
|
Requires-Dist: geopandas
|
|
31
31
|
Requires-Dist: loguru
|
|
32
32
|
Requires-Dist: matplotlib
|
|
33
|
-
Requires-Dist: napari>=0.4.19
|
|
33
|
+
Requires-Dist: napari>=0.4.19.post1
|
|
34
34
|
Requires-Dist: napari-matplotlib
|
|
35
35
|
Requires-Dist: numba
|
|
36
36
|
Requires-Dist: numpy
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"attachments": {},
|
|
5
|
+
"cell_type": "markdown",
|
|
6
|
+
"metadata": {},
|
|
7
|
+
"source": [
|
|
8
|
+
"# Use the Scatterwidget with AnnData from Notebook"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"attachments": {},
|
|
13
|
+
"cell_type": "markdown",
|
|
14
|
+
"metadata": {},
|
|
15
|
+
"source": [
|
|
16
|
+
"This tutorial is an example of how to use the Napari-Spatialdata ScatterWidget from a notebook."
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"cell_type": "markdown",
|
|
21
|
+
"metadata": {},
|
|
22
|
+
"source": [
|
|
23
|
+
"## Import packages and data"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"attachments": {},
|
|
28
|
+
"cell_type": "markdown",
|
|
29
|
+
"metadata": {},
|
|
30
|
+
"source": [
|
|
31
|
+
"There are two options to install napari-spatialdata:\n",
|
|
32
|
+
"\n",
|
|
33
|
+
"(1) Run `pip install napari-spatialdata`\n",
|
|
34
|
+
"\n",
|
|
35
|
+
"or, \n",
|
|
36
|
+
"\n",
|
|
37
|
+
"(2) Clone this [repo](https://github.com/scverse/napari-spatialdata) and run `pip install -e .`"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"cell_type": "code",
|
|
42
|
+
"execution_count": 10,
|
|
43
|
+
"metadata": {},
|
|
44
|
+
"source": [
|
|
45
|
+
"from napari_spatialdata import QtAdataScatterWidget\n",
|
|
46
|
+
"import squidpy as sq\n",
|
|
47
|
+
"import matplotlib.pyplot as plt"
|
|
48
|
+
],
|
|
49
|
+
"outputs": []
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"attachments": {},
|
|
53
|
+
"cell_type": "markdown",
|
|
54
|
+
"metadata": {},
|
|
55
|
+
"source": [
|
|
56
|
+
"Load in the AnnData:"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"cell_type": "code",
|
|
61
|
+
"execution_count": 11,
|
|
62
|
+
"metadata": {},
|
|
63
|
+
"source": [
|
|
64
|
+
"adata = sq.datasets.visium_hne_adata()"
|
|
65
|
+
],
|
|
66
|
+
"outputs": []
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"attachments": {},
|
|
70
|
+
"cell_type": "markdown",
|
|
71
|
+
"metadata": {},
|
|
72
|
+
"source": [
|
|
73
|
+
"The following line is needed to initialize a widget without a QApplication:"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"cell_type": "code",
|
|
78
|
+
"execution_count": 13,
|
|
79
|
+
"metadata": {},
|
|
80
|
+
"source": [
|
|
81
|
+
"%gui qt5"
|
|
82
|
+
],
|
|
83
|
+
"outputs": []
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"attachments": {},
|
|
87
|
+
"cell_type": "markdown",
|
|
88
|
+
"metadata": {},
|
|
89
|
+
"source": [
|
|
90
|
+
"Open the ScatterWidget:"
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"cell_type": "code",
|
|
95
|
+
"execution_count": 14,
|
|
96
|
+
"metadata": {},
|
|
97
|
+
"source": [
|
|
98
|
+
"widget = QtAdataScatterWidget(adata)\n",
|
|
99
|
+
"widget.show()"
|
|
100
|
+
],
|
|
101
|
+
"outputs": []
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"attachments": {},
|
|
105
|
+
"cell_type": "markdown",
|
|
106
|
+
"metadata": {},
|
|
107
|
+
"source": [
|
|
108
|
+
"The widget:"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"cell_type": "code",
|
|
113
|
+
"execution_count": 15,
|
|
114
|
+
"metadata": {},
|
|
115
|
+
"source": [
|
|
116
|
+
"plt.imshow(widget.screenshot())\n",
|
|
117
|
+
"plt.axis('off')"
|
|
118
|
+
],
|
|
119
|
+
"outputs": []
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"attachments": {},
|
|
123
|
+
"cell_type": "markdown",
|
|
124
|
+
"metadata": {},
|
|
125
|
+
"source": [
|
|
126
|
+
"Some examples of scatterplots:"
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"cell_type": "code",
|
|
131
|
+
"execution_count": 19,
|
|
132
|
+
"metadata": {},
|
|
133
|
+
"source": [
|
|
134
|
+
"plt.imshow(widget.screenshot())\n",
|
|
135
|
+
"plt.axis('off')"
|
|
136
|
+
],
|
|
137
|
+
"outputs": []
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"cell_type": "code",
|
|
141
|
+
"execution_count": 21,
|
|
142
|
+
"metadata": {},
|
|
143
|
+
"source": [
|
|
144
|
+
"plt.imshow(widget.screenshot())\n",
|
|
145
|
+
"plt.axis('off')"
|
|
146
|
+
],
|
|
147
|
+
"outputs": []
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"metadata": {
|
|
151
|
+
"kernelspec": {
|
|
152
|
+
"display_name": "napari",
|
|
153
|
+
"language": "python",
|
|
154
|
+
"name": "python3"
|
|
155
|
+
},
|
|
156
|
+
"language_info": {
|
|
157
|
+
"codemirror_mode": {
|
|
158
|
+
"name": "ipython",
|
|
159
|
+
"version": 3
|
|
160
|
+
},
|
|
161
|
+
"file_extension": ".py",
|
|
162
|
+
"mimetype": "text/x-python",
|
|
163
|
+
"name": "python",
|
|
164
|
+
"nbconvert_exporter": "python",
|
|
165
|
+
"pygments_lexer": "ipython3",
|
|
166
|
+
"version": "3.10.8"
|
|
167
|
+
},
|
|
168
|
+
"orig_nbformat": 4
|
|
169
|
+
},
|
|
170
|
+
"nbformat": 4,
|
|
171
|
+
"nbformat_minor": 2
|
|
172
|
+
}
|
|
@@ -5,7 +5,7 @@ author = giovanni palla
|
|
|
5
5
|
author_email = giov.pll@gmail.com
|
|
6
6
|
project_urls =
|
|
7
7
|
Bug Tracker = https://github.com/scverse/napari-spatialdata/issues
|
|
8
|
-
Documentation = https://
|
|
8
|
+
Documentation = https://spatialdata.scverse.org/projects/napari/en/latest/notebooks/spatialdata.html
|
|
9
9
|
Source Code = https://github.com/scverse/napari-spatialdata
|
|
10
10
|
User Support = https://github.com/scverse/napari-spatialdata/issues
|
|
11
11
|
license = BSD-3-Clause
|
|
@@ -33,11 +33,11 @@ install_requires =
|
|
|
33
33
|
anndata
|
|
34
34
|
click
|
|
35
35
|
cycler
|
|
36
|
-
dask
|
|
36
|
+
dask<=2024.2.1
|
|
37
37
|
geopandas
|
|
38
38
|
loguru
|
|
39
39
|
matplotlib
|
|
40
|
-
napari>=0.4.19
|
|
40
|
+
napari>=0.4.19.post1
|
|
41
41
|
napari-matplotlib
|
|
42
42
|
numba
|
|
43
43
|
numpy
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import random
|
|
4
|
+
|
|
5
|
+
from qtpy.QtCore import QModelIndex, Signal
|
|
6
|
+
from qtpy.QtGui import QStandardItemModel
|
|
7
|
+
from qtpy.QtWidgets import (
|
|
8
|
+
QButtonGroup,
|
|
9
|
+
QColorDialog,
|
|
10
|
+
QComboBox,
|
|
11
|
+
QHeaderView,
|
|
12
|
+
QLabel,
|
|
13
|
+
QLineEdit,
|
|
14
|
+
QPushButton,
|
|
15
|
+
QRadioButton,
|
|
16
|
+
QTextEdit,
|
|
17
|
+
QTreeView,
|
|
18
|
+
QVBoxLayout,
|
|
19
|
+
QWidget,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
__all__ = ["MainWindow"]
|
|
23
|
+
|
|
24
|
+
COLUMNS = [None, "color", "class"]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class TreeView(QTreeView):
|
|
28
|
+
color_button_added = Signal(QPushButton)
|
|
29
|
+
class_name_text_added = Signal(QLineEdit)
|
|
30
|
+
|
|
31
|
+
def __init__(self) -> None:
|
|
32
|
+
super().__init__()
|
|
33
|
+
self.model = QStandardItemModel()
|
|
34
|
+
self.setModel(self.model)
|
|
35
|
+
self.model.setHorizontalHeaderLabels(COLUMNS)
|
|
36
|
+
|
|
37
|
+
self.header().setSectionsClickable(True)
|
|
38
|
+
self.button_group = QButtonGroup()
|
|
39
|
+
|
|
40
|
+
# Required as on mac the selected indexes never get updated.
|
|
41
|
+
self.button_to_color_index: dict[QPushButton, QModelIndex] = {}
|
|
42
|
+
self.button_to_class_index: dict[QPushButton, QModelIndex] = {}
|
|
43
|
+
self.color_button_to_class_line_edit: dict[QPushButton, QLineEdit] = {}
|
|
44
|
+
|
|
45
|
+
def addGroup(self, color: None | str = None, name: str = "Class", auto_exclusive: bool = True) -> None:
|
|
46
|
+
i = self.model.rowCount()
|
|
47
|
+
|
|
48
|
+
if color:
|
|
49
|
+
color_button = ColorButton(color, i)
|
|
50
|
+
name_field = QLineEdit(name)
|
|
51
|
+
if i == 0:
|
|
52
|
+
name_field.setReadOnly(True)
|
|
53
|
+
name_field.setToolTip(
|
|
54
|
+
"The first row of the table is not editable. " "Added annotation groups will be editable."
|
|
55
|
+
)
|
|
56
|
+
else:
|
|
57
|
+
random_color = self.generate_random_color_hex()
|
|
58
|
+
color_button = ColorButton(random_color, i)
|
|
59
|
+
name_field = QLineEdit(name + "_" + str(i))
|
|
60
|
+
name_field.returnPressed.connect(lambda: self.clear_name_field_focus(name_field))
|
|
61
|
+
|
|
62
|
+
radio_button = QRadioButton("")
|
|
63
|
+
self.button_group.addButton(radio_button)
|
|
64
|
+
if i == 0:
|
|
65
|
+
radio_button.setChecked(True)
|
|
66
|
+
radio_button.setAutoExclusive(auto_exclusive)
|
|
67
|
+
|
|
68
|
+
self.model.insertRow(i)
|
|
69
|
+
radio_index = self.model.index(i, 0)
|
|
70
|
+
color_index = self.model.index(i, 1)
|
|
71
|
+
name_index = self.model.index(i, 2)
|
|
72
|
+
|
|
73
|
+
self.button_to_color_index[radio_button] = color_index
|
|
74
|
+
self.button_to_class_index[radio_button] = name_index
|
|
75
|
+
self.color_button_to_class_line_edit[color_button] = name_field
|
|
76
|
+
self.setIndexWidget(color_index, color_button)
|
|
77
|
+
self.setIndexWidget(name_index, name_field)
|
|
78
|
+
self.setIndexWidget(radio_index, radio_button)
|
|
79
|
+
|
|
80
|
+
self.color_button_added.emit(color_button)
|
|
81
|
+
self.class_name_text_added.emit(name_field)
|
|
82
|
+
|
|
83
|
+
def generate_random_color_hex(self) -> str:
|
|
84
|
+
# Generate a random hex color code
|
|
85
|
+
return f"#{random.randint(0, 255):02x}{random.randint(0, 255):02x}{random.randint(0, 255):02x}"
|
|
86
|
+
|
|
87
|
+
def reset_to_default_tree_view(self) -> None:
|
|
88
|
+
if self.model.rowCount() != 1:
|
|
89
|
+
count = self.model.rowCount()
|
|
90
|
+
self.model.removeRows(1, count - 1)
|
|
91
|
+
self.reset_button_group()
|
|
92
|
+
self.button_group.buttons()[0].setChecked(True)
|
|
93
|
+
|
|
94
|
+
def set_class_column_header(self, class_col_name: str) -> None:
|
|
95
|
+
columns_to_set = COLUMNS.copy()
|
|
96
|
+
columns_to_set[-1] = class_col_name
|
|
97
|
+
self.model.setHorizontalHeaderLabels(columns_to_set)
|
|
98
|
+
|
|
99
|
+
def reset_class_column_header(self) -> None:
|
|
100
|
+
self.model.setHorizontalHeaderLabels(COLUMNS)
|
|
101
|
+
|
|
102
|
+
def reset_button_group(self) -> None:
|
|
103
|
+
for button in self.button_group.buttons()[1:]:
|
|
104
|
+
self.button_group.removeButton(button)
|
|
105
|
+
|
|
106
|
+
def clear_name_field_focus(self, name_field: QLineEdit) -> None:
|
|
107
|
+
name_field.clearFocus()
|
|
108
|
+
# for some reasons, in some macs the focus is not removed with the line above
|
|
109
|
+
self.setFocus()
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class MainWindow(QWidget):
|
|
113
|
+
def __init__(self) -> None:
|
|
114
|
+
super().__init__()
|
|
115
|
+
|
|
116
|
+
self._annotators: list[str] = []
|
|
117
|
+
self.layout = QVBoxLayout()
|
|
118
|
+
|
|
119
|
+
self.link_button = QPushButton("Link layer to sdata")
|
|
120
|
+
self.link_button.setToolTip(
|
|
121
|
+
"Link layer to sdata object present in viewer if no sdata object is associated with"
|
|
122
|
+
" layer. Only 1 active spatialdata object must be present in viewer or in "
|
|
123
|
+
"selection. Press Shift+L for a shortcut."
|
|
124
|
+
)
|
|
125
|
+
self.layout.addWidget(self.link_button)
|
|
126
|
+
|
|
127
|
+
self.tree_view = TreeView()
|
|
128
|
+
self.tree_view.addGroup(color="#FFFFFF", name="undefined")
|
|
129
|
+
|
|
130
|
+
self.tree_view.header().setSectionResizeMode(0, QHeaderView.Fixed)
|
|
131
|
+
self.tree_view.header().resizeSection(0, 40)
|
|
132
|
+
self.tree_view.header().setSectionResizeMode(1, QHeaderView.ResizeToContents)
|
|
133
|
+
self.add_button = QPushButton("Add annotation group")
|
|
134
|
+
self.add_button.clicked.connect(lambda: self.tree_view.addGroup(auto_exclusive=True))
|
|
135
|
+
self.layout.addWidget(self.add_button)
|
|
136
|
+
self.layout.addWidget(self.tree_view)
|
|
137
|
+
|
|
138
|
+
self.description_box = QTextEdit()
|
|
139
|
+
self.description_box.setPlaceholderText(
|
|
140
|
+
"Add your description for selected element here and press button below."
|
|
141
|
+
)
|
|
142
|
+
self.description_box.setMaximumHeight(self.description_box.fontInfo().pixelSize() * 8)
|
|
143
|
+
self.layout.addWidget(self.description_box)
|
|
144
|
+
|
|
145
|
+
annotator_label = QLabel("Add / set annotator:")
|
|
146
|
+
self.annotators = QComboBox(editable=True)
|
|
147
|
+
self.annotators.lineEdit().returnPressed.connect(self._clear_focus_on_add_annotator)
|
|
148
|
+
self.annotators.setToolTip(
|
|
149
|
+
"Add annotator by clicking on the dropdown, typing the name of the annotator and pressing enter."
|
|
150
|
+
)
|
|
151
|
+
self.layout.addWidget(annotator_label)
|
|
152
|
+
self.layout.addWidget(self.annotators)
|
|
153
|
+
|
|
154
|
+
self.set_annotation = QPushButton("Set description, class and annotator")
|
|
155
|
+
self.layout.addWidget(self.set_annotation)
|
|
156
|
+
|
|
157
|
+
table_label = QLabel("Annotation table:")
|
|
158
|
+
self._table_names: list[str] = []
|
|
159
|
+
self.table_name_widget = QComboBox()
|
|
160
|
+
|
|
161
|
+
self.layout.addWidget(table_label)
|
|
162
|
+
self.layout.addWidget(self.table_name_widget)
|
|
163
|
+
|
|
164
|
+
self.save_button = QPushButton("Save selected annotation layer")
|
|
165
|
+
self.save_button.setToolTip(
|
|
166
|
+
"Save annotation as Shapes element with associated Table. Requires current active "
|
|
167
|
+
"layer to be a Shapes layer that is linked to a SpatialData object. Shortcut is "
|
|
168
|
+
"pressing shift + E."
|
|
169
|
+
)
|
|
170
|
+
self.layout.addWidget(self.save_button)
|
|
171
|
+
|
|
172
|
+
# Set the layout on the application's window
|
|
173
|
+
self.setLayout(self.layout)
|
|
174
|
+
self.setWindowTitle("Annotation")
|
|
175
|
+
self.show()
|
|
176
|
+
|
|
177
|
+
def _clear_focus_on_add_annotator(self) -> None:
|
|
178
|
+
self.annotators.clearFocus()
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
class ColorButton(QPushButton):
|
|
182
|
+
color_changed = Signal(str, QPushButton)
|
|
183
|
+
|
|
184
|
+
def __init__(self, color: str, button_index: int, parent: QWidget | None = None) -> None:
|
|
185
|
+
super().__init__("", parent)
|
|
186
|
+
if button_index != 0:
|
|
187
|
+
self.clicked.connect(self.openColorDialog)
|
|
188
|
+
self.setStyleSheet(f"background-color: {color}")
|
|
189
|
+
|
|
190
|
+
def openColorDialog(self) -> None:
|
|
191
|
+
color = QColorDialog.getColor(parent=self.parent())
|
|
192
|
+
if color.isValid():
|
|
193
|
+
self.setStyleSheet(f"background-color: {color.name()}")
|
|
194
|
+
self.color_changed.emit(color.name(), self)
|
{napari-spatialdata-0.4.0 → napari_spatialdata-0.5.0.post0}/src/napari_spatialdata/_model.py
RENAMED
|
@@ -6,8 +6,9 @@ import pandas as pd
|
|
|
6
6
|
from anndata import AnnData
|
|
7
7
|
from napari.layers import Layer
|
|
8
8
|
from napari.utils.events import EmitterGroup, Event
|
|
9
|
+
from spatialdata.models import get_table_keys
|
|
9
10
|
|
|
10
|
-
from napari_spatialdata.
|
|
11
|
+
from napari_spatialdata.constants._constants import Symbol
|
|
11
12
|
from napari_spatialdata.utils._utils import NDArrayA, _ensure_dense_vector
|
|
12
13
|
|
|
13
14
|
__all__ = ["DataModel"]
|
|
@@ -85,11 +86,12 @@ class DataModel:
|
|
|
85
86
|
if name not in self.adata.obs.columns:
|
|
86
87
|
raise KeyError(f"Key `{name}` not found in `adata.obs`.")
|
|
87
88
|
if name != self.instance_key:
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
obs_column = self.adata.obs[[self.instance_key, name]]
|
|
90
|
+
obs_column = obs_column.set_index(self.instance_key)[name]
|
|
90
91
|
else:
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
obs_column = self.adata.obs[name].copy()
|
|
93
|
+
obs_column.index = self.adata.obs[self.instance_key]
|
|
94
|
+
return obs_column, self._format_key(name)
|
|
93
95
|
|
|
94
96
|
@_ensure_dense_vector
|
|
95
97
|
def get_columns_df(self, name: Union[str, int], **_: Any) -> Tuple[Optional[NDArrayA], str]:
|
|
@@ -242,20 +244,20 @@ class DataModel:
|
|
|
242
244
|
@property
|
|
243
245
|
def region_key(self) -> Optional[str]: # noqa: D102
|
|
244
246
|
"""The region key of the currently active table in the widget."""
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
if self.adata is not None:
|
|
248
|
+
_, region_key, _ = get_table_keys(self.adata)
|
|
249
|
+
assert isinstance(region_key, str)
|
|
250
|
+
return region_key
|
|
251
|
+
return None
|
|
250
252
|
|
|
251
253
|
@property
|
|
252
254
|
def instance_key(self) -> Optional[str]: # noqa: D102
|
|
253
255
|
"""The instance key of the currently active table in the widget."""
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
if self.adata is not None:
|
|
257
|
+
_, _, instance_key = get_table_keys(self.adata)
|
|
258
|
+
assert isinstance(instance_key, str)
|
|
259
|
+
return instance_key
|
|
260
|
+
return None
|
|
259
261
|
|
|
260
262
|
@property
|
|
261
263
|
def palette(self) -> Optional[str]: # noqa: D102
|