Skip to content

Commit

Permalink
Merge pull request #1 from MicheleBortol/dev
Browse files Browse the repository at this point in the history
Adds autoconfig
  • Loading branch information
MicheleBortol authored Aug 1, 2024
2 parents a7b76c1 + 845eecf commit 6b059f4
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 95 deletions.
69 changes: 61 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
![Badge_OMERO](https://github.com/MicheleBortol/omero-vitessce/actions/workflows/omero_plugin.yml/badge.svg)
![Badge_PyPI](https://img.shields.io/pypi/v/omero-vitessce?label=pypi%20package)


OMERO.omero_vitessce
=======================

Expand Down Expand Up @@ -33,25 +37,74 @@ Add the omero web address (replace ´'"http://localhost:4080"'´ with your addre

Now restart OMERO.web as normal for the configuration above to take effect.

### omero-web-zarr
While [omero-web-zarr](https://github.com/ome/omero-web-zarr) is not a requirement, but it is strongly recommended to have it installed and enabled for using this plugin
omero-web-zarr is necessary to take advantage fully of the autogenerated config files for the Vitessce viewer,
as they rely on omero-web-zarr to serve the images to the viewer.

Please see https://pypi.org/project/omero-web-zarr/ for instructions on installing and enabling the omero-web-zarr plugin.

Usage
============
### Right-hand-side panel:
- Prexisting config files
- Autogenerating config file: COMING SOON!

### Selecting the viewer
The plugin can be used with:
- `Vitessce` Tab on the right hand side panel.
- `Open with` `->` `Vitessce` on the left side panel.

#### Right-hand-side panel:
- **Prexisting config files**:
![Right-Config](https://github.com/user-attachments/assets/b8fea5f0-1d8f-4578-a577-8744d32dcaa5)
Clicking the link will open a new tab with the viewer displaying the selected configuration.
- **Autogenerating config file**:
![Right-Auto](https://github.com/user-attachments/assets/8dfa22cc-dbb5-493d-b837-d609a11a1346)
Clicking the button will autogenerate a config file and attach it to the dataset/image, and the viewer displaying the autogenerated configuration.

### Open-with:
Right click on `projects`, `datasets` or `images` in the left-panel and select `open-witch` -> `Vitessce`.
#### Open-with:
Right click on a `dataset` or an `images` in the left-panel and select `open-with` -> `Vitessce`.
This will open the vitessce viewer in a new tab using the first configuration file attachement.
![Openwith-image](https://github.com/user-attachments/assets/f75cc27c-4cd3-4a19-ae20-7d8f0a47aa87)

### Viewer window
After using a The Vitessce viewer is opened in a new tab:
![image](https://github.com/user-attachments/assets/77de517e-67e4-42d6-a2b6-2a3a6a11dc7e)

### Config files
The omero-vitessce plugin considers all files with the `.json.txt` extension attached to the image or dataset as config files for the viewer.
The config files should follow the vitessce view-config-json format: http://vitessce.io/docs/view-config-json/

#### Autogenerated config files
Config files can be autogenerated for:
- `images`: A spatial view and a layer controller view are setup for the image.
- `datasets`: All images in the dataset are bundled togheter and a spatial view and a layer controller are setup.

Assumes that the images are in the OME-NGFF format v0.4 and that [omero-web-zarr](https://github.com/ome/omero-web-zarr) is
available to serve the images.

#### Custom config files
Custom config files should have a `.json.txt` extension and added as attachements to a dataset or an image.
The configuration files does not need to refer to the dataset / image it is attached to and can refer to other images.


[examples](http://vitessce.io/examples/)

#### Serving the images / data /metadata
Images and data can be served through:
- [omero-web-zarr](https://pypi.org/project/omero-web-zarr/): OME-NGFF images only.
- [omero-openlink](https://github.com/sukunis/OMERO.openlink): all images and file attachements.
- ´webclient/annotation/´ endpoint: only for Annotations (useful for file attachments).

Development
=======================

## Sources

The main sources are:
- cookiecutter-omero-webapp: https://github.com/ome/cookiecutter-omero-webapp
- `react_webapp` from omero-web-apps-examples: https://github.com/ome/omero-web-apps-examples/tree/master/react-webapp
- Vitessce python package (will be used for generating config files) http://python-docs.vitessce.io/
- Vitessce python package used for generating config files http://python-docs.vitessce.io/
- omero-web-zarr to serve OME-NGFF images: https://github.com/ome/omero-web-zarr
- omero-openlink to serve images and other files: https://github.com/sukunis/OMERO.openlink

## React web app

Expand Down Expand Up @@ -97,9 +150,9 @@ You also need to install the app into your `omero-web` environment:

You will need to have the app configured in your OMERO.web install:

$ omero config append omero.web.apps '"omero_vitessce"'
$ omero config append omero.web.apps '"omero_vitessce"'
$ omero config append omero.web.ui.right_plugins '["Vitessce", "omero_vitessce/webclient_plugins/right_plugin.vitessce.js.html", "vitessce_tab"]'
$ omero config set omero.web.omero_vitessce.serveraddress '"http://localhost:4080"'
$ omero config set omero.web.omero_vitessce.serveraddress '"http://localhost:4080"'

It bundles React in production mode and optimizes the build for the best performance.

Expand Down
16 changes: 0 additions & 16 deletions omero_vitessce/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +0,0 @@
#
# Copyright (c) 2019 University of Dundee.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
2 changes: 2 additions & 0 deletions omero_vitessce/omero_vitessce_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@


def str_not_empty(o):
"""Checks for empty/invalid strings.
"""
s = str(o)
if not o or not s:
raise ValueError('Invalid empty value')
Expand Down
8 changes: 6 additions & 2 deletions omero_vitessce/templates/omero_vitessce/vitessce_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
</body>
{% if json_configs %}
<div class="right_tab_inner">
<p>Please select a config file or clic "Auto" to autogenerate one.</p>
<p>Please select an attached config file from the list below:</p>
{% for file, url in json_configs.items%}
<a href={{url}}> {{file}}</a>
<a href={{url}} target="_blank"> {{file}}</a>
{% endfor %}
</div>
{% else %}
<div class="right_tab_inner">
<p> There are no config files attached! </p>
<p> Either attach a config file or click below to autogenerate one:</p>
<button type="button">
<a href="{% url 'generate_config' %}/{{obj_type}}/{{obj_id}}";>Generate Config File</a>
</button>

</div>
{% endif %}
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$(document).ready(function() {

$("#vitessce_tab").omeroweb_right_plugin({
supported_obj_types: ['project','dataset','image'],
supported_obj_types: ['dataset','image'],
load_plugin_content: function(selected, obj_dtype, obj_id) { // Url based on selected object(s)
var url = '{% url 'vitessce_tab' %}' + obj_dtype + '/' + obj_id + '/';
$(this).load(url);
Expand Down
25 changes: 8 additions & 17 deletions omero_vitessce/urls.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
#
# Copyright (c) 2017 University of Dundee.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

from django.urls import re_path

from . import views

urlpatterns = [
# Generate config Button
re_path(r"^generate_config/(?P<obj_type>[a-z]+)/(?P<obj_id>[0-9]+)",
views.generate_config, name='generate_config'),

# Button placeholder
re_path(r"^generate_config$", views.vitessce_index,
name="generate_config"),

# Right panel plugin
re_path(r"(?P<obj_type>[a-z]+)/(?P<obj_id>[0-9]+)",
views.vitessce_panel, name='vitessce_tab'),
Expand Down
Loading

0 comments on commit 6b059f4

Please sign in to comment.