Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nd2shrink
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andrey ARISTOV
nd2shrink
Commits
3a3acf49
Commit
3a3acf49
authored
3 years ago
by
Andrey Aristov
Browse files
Options
Downloads
Patches
Plain Diff
initial commit
parent
295b4d2e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!5
fix testing and stuff
Pipeline
#73958
failed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
QTplugin-napari.ipynb
+128
-0
128 additions, 0 deletions
QTplugin-napari.ipynb
with
128 additions
and
0 deletions
QTplugin-napari.ipynb
0 → 100644
+
128
−
0
View file @
3a3acf49
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"id": "11936ce3-3ddd-4aa3-b907-740aefc2973b",
"metadata": {},
"outputs": [],
"source": [
"from napari import Viewer, run\n",
"from napari.layers import Image, Layer\n",
"\n",
"from qtpy.QtWidgets import QWidget, QVBoxLayout, QLabel, QListWidget\n",
"\n",
"from magicgui.widgets import create_widget\n",
"\n",
"from matplotlib.backends.backend_qtagg import (\n",
" FigureCanvas, NavigationToolbar2QT as NavigationToolbar)\n",
"from matplotlib.figure import Figure"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "d97699e5-db36-46f4-95b9-a56191256ed4",
"metadata": {},
"outputs": [],
"source": [
"class SamplePlugin(QWidget):\n",
" def __init__(self, viewer: Viewer):\n",
" super().__init__()\n",
" self.viewer = viewer\n",
" self.select_image = create_widget(annotation=Image)\n",
" self.select_mask = create_widget(annotation=Layer)\n",
" self.canvas = FigureCanvas(Figure(figsize=(5,5)))\n",
" self.ax = self.canvas.figure.subplots()\n",
"\n",
" self.ax.plot([0, 5, 6], [2, 7, 14])\n",
"\n",
" layout = QVBoxLayout()\n",
" layout.addWidget(self.select_image.native)\n",
" layout.addWidget(self.select_mask.native)\n",
" layout.addWidget(self.canvas)\n",
"\n",
" self.setLayout(layout)\n",
" \n",
" def reset_choices(self, event=None):\n",
" self.select_image.reset_choices(event)\n",
" self.select_mask.reset_choices(event)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "df3e9175-ab4f-41da-be36-9e06402ff404",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"AICSImageIO: Reader will load image in-memory: False\n",
"AICSImageIO: Reader will load image in-memory: False\n"
]
}
],
"source": [
"viewer = Viewer()\n",
"\n",
"plugin = SamplePlugin(viewer)\n",
"\n",
"viewer.window.add_dock_widget(plugin)\n",
"\n",
"run()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "4e69ca83-6eb3-41ad-97eb-f18f80223e8c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"viewer.layers[2].data.min().compute()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c42db7a0-5937-4f7a-9d6e-64de0108b72b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:code id:11936ce3-3ddd-4aa3-b907-740aefc2973b tags:
```
python
from
napari
import
Viewer
,
run
from
napari.layers
import
Image
,
Layer
from
qtpy.QtWidgets
import
QWidget
,
QVBoxLayout
,
QLabel
,
QListWidget
from
magicgui.widgets
import
create_widget
from
matplotlib.backends.backend_qtagg
import
(
FigureCanvas
,
NavigationToolbar2QT
as
NavigationToolbar
)
from
matplotlib.figure
import
Figure
```
%% Cell type:code id:d97699e5-db36-46f4-95b9-a56191256ed4 tags:
```
python
class
SamplePlugin
(
QWidget
):
def
__init__
(
self
,
viewer
:
Viewer
):
super
().
__init__
()
self
.
viewer
=
viewer
self
.
select_image
=
create_widget
(
annotation
=
Image
)
self
.
select_mask
=
create_widget
(
annotation
=
Layer
)
self
.
canvas
=
FigureCanvas
(
Figure
(
figsize
=
(
5
,
5
)))
self
.
ax
=
self
.
canvas
.
figure
.
subplots
()
self
.
ax
.
plot
([
0
,
5
,
6
],
[
2
,
7
,
14
])
layout
=
QVBoxLayout
()
layout
.
addWidget
(
self
.
select_image
.
native
)
layout
.
addWidget
(
self
.
select_mask
.
native
)
layout
.
addWidget
(
self
.
canvas
)
self
.
setLayout
(
layout
)
def
reset_choices
(
self
,
event
=
None
):
self
.
select_image
.
reset_choices
(
event
)
self
.
select_mask
.
reset_choices
(
event
)
```
%% Cell type:code id:df3e9175-ab4f-41da-be36-9e06402ff404 tags:
```
python
viewer
=
Viewer
()
plugin
=
SamplePlugin
(
viewer
)
viewer
.
window
.
add_dock_widget
(
plugin
)
run
()
```
%% Output
AICSImageIO: Reader will load image in-memory: False
AICSImageIO: Reader will load image in-memory: False
%% Cell type:code id:4e69ca83-6eb3-41ad-97eb-f18f80223e8c tags:
```
python
viewer
.
layers
[
2
].
data
.
min
().
compute
()
```
%% Output
0
%% Cell type:code id:c42db7a0-5937-4f7a-9d6e-64de0108b72b tags:
```
python
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment