From 6387c2336e6c4e55508f59a8be82807371f09cf9 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Fri, 9 Apr 2021 13:02:11 +0100 Subject: [PATCH 1/8] add structure for rtd --- .bumpversion.cfg | 1 + .github/workflows/sphinx.yml | 34 ++++ .gitignore | 1 + .readthedocs.yml | 9 + README.rst | 62 ++++-- docs/Makefile | 20 ++ docs/conf.py | 201 +++++++++++++++++++ docs/index.rst | 19 ++ docs/make.bat | 35 ++++ docs/scripts.rst | 130 ++++++++++++ omero/analysis_scripts/Kymograph.py | 14 +- omero/analysis_scripts/Kymograph_Analysis.py | 41 ++-- omero/analysis_scripts/Plot_Profile.py | 40 ++-- omero/export_scripts/Batch_Image_Export.py | 87 ++++---- omero/export_scripts/Batch_ROI_Export.py | 4 +- omero/export_scripts/Make_Movie.py | 80 +++----- omero/figure_scripts/Movie_Figure.py | 104 +++++----- omero/figure_scripts/Movie_ROI_Figure.py | 79 ++++---- omero/figure_scripts/ROI_Split_Figure.py | 93 +++++---- omero/figure_scripts/Split_View_Figure.py | 129 ++++++------ omero/figure_scripts/Thumbnail_Figure.py | 117 ++++++----- omero/import_scripts/Populate_Metadata.py | 40 ++-- omero/import_scripts/Populate_ROI.py | 87 ++++---- omero/util_scripts/Channel_Offsets.py | 56 +++--- omero/util_scripts/Combine_Images.py | 62 +++--- omero/util_scripts/Dataset_To_Plate.py | 52 +++-- omero/util_scripts/Images_From_ROIs.py | 51 +++-- 27 files changed, 1045 insertions(+), 603 deletions(-) create mode 100644 .github/workflows/sphinx.yml create mode 100644 .readthedocs.yml create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat create mode 100644 docs/scripts.rst diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 414850db5..00f9bce33 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -18,3 +18,4 @@ values = [bumpversion:part:build] [bumpversion:file:setup.py] +[bumpversion:file:docs/conf.py] diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml new file mode 100644 index 000000000..c0aea8aba --- /dev/null +++ b/.github/workflows/sphinx.yml @@ -0,0 +1,34 @@ +# Builds the Sphinx documentation in the specified folder. +# Default values are docs/ for the directory where the Sphinx +# documentation is located and true to run linkcheck +# To pass a new folder, set directory_path to the folder path +# Pass the arguments you wish to run, default command is make clean html linkcheck + +--- +name: sphinx + +on: + push: + pull_request: + schedule: + - cron: '0 0 * * 0' + +jobs: + build: + runs-on: ubuntu-latest + env: + directory_path: + sphinx_commands: clean html linkcheck # commands to run. Update accordingly + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - name: Sphinx install + run: pip install --upgrade sphinx + - name: Set directory + run: | + VAR=${{ env.directory_path }} + echo "docs_dir="${VAR:-./docs} >> $GITHUB_ENV + - name: Build doc + run: | + cd $docs_dir + make ${{ env.sphinx_commands }} diff --git a/.gitignore b/.gitignore index b73e3b511..9c6c78b35 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.pyc .gitignore *.DS_Store* +docs/_build diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 000000000..9d95a25f5 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,9 @@ +# Required +version: 2 + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: docs/conf.py + +python: + version: 3.7 diff --git a/README.rst b/README.rst index 4d901aa48..7a25aeacd 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,9 @@ .. image:: https://github.com/ome/omero-scripts/workflows/OMERO/badge.svg :target: https://github.com/ome/omero-scripts/actions +.. image:: https://github.com/ome/omero-scripts/workflows/sphinx/badge.svg + :target: https://github.com/ome/omero-scripts/actions + .. image:: https://badge.fury.io/py/omero-scripts.svg :target: https://badge.fury.io/py/omero-scripts @@ -12,34 +15,37 @@ OMERO.scripts API. All scripts (e.g. ``*.py``) present in the directory will be automatically distributed with all binary builds. Which file-endings will be detected and how they will be launched are both configured centrally in the server. -``.py``, ``.jy", and ``.m`` (MATLAB) files should all be detected +``.py``, ``.jy``, and ``.m`` (MATLAB) files should all be detected by default starting with OMERO 5. Categories ----------- +========== Scripts are separated into several categories, one per directory. -| In the directory | should be scripts which ... | -| ---------------- | --------------------- | ++------------------------+-------------------------------------------------------------------------------+ +| Directory | Description | ++========================+===============================================================================+ | **analysis_scripts** | crunch images to produce numerical results and similar tasks | ++------------------------+-------------------------------------------------------------------------------+ | **export_scripts** | take one or more images as an input, and produce a representation for exchange| ++------------------------+-------------------------------------------------------------------------------+ | **figure_scripts** | take one or more images as an input, and produce a summary representation | -| **hcs_scripts** | work with screens/plates/wells rather than just images | ++------------------------+-------------------------------------------------------------------------------+ | **import_scripts** | are run on images after import for extra processing | -| **processing_scripts** | create new images from existing images or other data | -| **setup_scripts** | are executed once, often by administrators, to configure OMERO itself | ++------------------------+-------------------------------------------------------------------------------+ | **util_scripts** | perform other miscellaneous tasks like cleaning up or optimizing OMERO itself | ++------------------------+-------------------------------------------------------------------------------+ Scripts which would like to rely on other scripts can -use: +use:: import omero.. For this to work, the official script in question must -be properly importable, i.e.: +be properly importable, i.e.:: def run(): client = omero.scripts.client(...) @@ -49,20 +55,20 @@ be properly importable, i.e.: OMERO User Scripts ------------------- +================== If you would like to provide your own scripts for others to install -into their OMERO installations, please see http://openmicroscopy.org/info/scripts +into their OMERO installations, please see https://openmicroscopy.org/info/scripts Testing -------- +======= Integration tests under ``test/`` require an OMERO server with scripts installed. The tests are run by Travis for open PRs using omero-test-infra to deploy OMERO via Docker containers. -To run tests locally: +To run tests locally:: # All tests $ python setup.py test @@ -70,7 +76,33 @@ To run tests locally: # Single test in a single file $ python setup.py test -t test/integration/test_util_scripts.py -k test_dataset_to_plate +Usage +===== + +See https://omero-scripts.readthedocs.io/en/stable/ + +Release process +=============== + +This repository uses `bump2version `_ to manage version numbers. +To tag a release run:: + + $ bumpversion release + +This will remove the ``.dev0`` suffix from the current version, commit, and tag the release. + +To switch back to a development version run:: + + $ bumpversion --no-tag [major|minor|patch] + +specifying ``major``, ``minor`` or ``patch`` depending on whether the development branch will be a `major, minor or patch release `_. This will also add the ``.dev0`` suffix. + +Remember to ``git push`` all commits and tags.s essential. + +The CI pipeline will automatically deploy the tag onto PyPI. + + Copyright ---------- +========= -2010-2020, The Open Microscopy Environment +2010-2021, The Open Microscopy Environment diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 000000000..d4bb2cbb9 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 000000000..52bb043d1 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,201 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +import os +import sys +from sphinx.util import logging +logger = logging.getLogger(__name__) + + +# To fix 'docs/contents.rst not found' errors we need this, see +# https://github.com/readthedocs/readthedocs.org/issues/2569 + +master_doc = 'index' +docs_root = 'https://docs.openmicroscopy.org' + + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +def get_scripts(directory): + """ + Find all the scripts available + """ + scripts = [] + + # Walk the tree. + for root, directories, files in os.walk(directory): + for filename in files: + if filename.endswith(".py") and "_init_" not in filename: + scripts.append(filename.replace('\n', '').replace(".py", "")) + + return scripts + + +def find_scripts_entry(): + """ + Find the entries corresponding to the scripts. + """ + + with open("scripts.rst") as file: + lines = file.readlines() + + entries = [] + for line in lines: + if "automodule" in line: + values = line.split(".. automodule::") + entries.append(values[1].replace('\n', '').strip()) + return entries + + +def compare(list1, list2): + """ + Return the elements not common to both lists + """ + return [i for i in list1 + list2 if i not in list1 or i not in list2] + + +# List of directories to scan and add the path. +directories = ['../omero/analysis_scripts', '../omero/export_scripts', + '../omero/figure_scripts', '../omero/import_scripts', + '../omero/util_scripts'] +scripts = [] +for d in directories: + sys.path.insert(0, d) + scripts.extend(get_scripts(d)) + +entries = find_scripts_entry() + +# Indicate the scripts not listed for documentation +if len(entries) < len(scripts): + common = compare(scripts, entries) + logger.warning("automodule entries missing for:\n" + '\n'.join(common)) + +# Variables used to define Github extlinks +if "SOURCE_BRANCH" in os.environ and len(os.environ.get('SOURCE_BRANCH')) > 0: + branch = os.environ.get('SOURCE_BRANCH') +else: + branch = 'develop' + +if "SOURCE_USER" in os.environ and len(os.environ.get('SOURCE_USER')) > 0: + user = os.environ.get('SOURCE_USER') +else: + user = 'ome' + +github_root = 'https://github.com/' +omero_github_root = github_root + user + '/openmicroscopy/' +docs_root = 'https://docs.openmicroscopy.org' +downloads_root = 'https://downloads.openmicroscopy.org' + +# -- Project information ----------------------------------------------------- + +project = u'omero scripts' +copyright = u'2021, Open Microscopy Environment' +author = u'Open Microscopy Environment' + +# The full version, including alpha/beta/rc tags +# The short X.Y version. +version = '5.6.2.dev0' +release = version + +version_blitz = '5.5.8' + + +# -- General configuration --------------------------------------------------- + +extlinks = { + 'slicedoc_blitz': (docs_root + '/omero-blitz/' + + version_blitz + '/slice2html/%s', ''), + 'source': (omero_github_root + 'blob/' + branch + '/%s', ''), + 'devs_doc': (docs_root + '/contributing/%s', ''), + 'downloads': (downloads_root + '/%s', ''), + 'general_doc': (docs_root + '/omero/latest%s', ''), + } + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.extlinks', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store'] + +# Build docs without external dependencies +autodoc_mock_imports = ['numpy', 'omero-py', 'omero', "PIL"] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'default' + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = [] + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'OMEROScripts.tex', u'OMERO Scripts Documentation', + author, 'manual'), +] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'omeroscripts', u'OMERO Scripts Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'OMEROScripts', u'OMERO Script Documentation', + author, 'OMEROScripts', 'One line description of project.', + 'Miscellaneous'), +] + + +# -- Options for Epub output ------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +# +# epub_identifier = '' + +# A unique identification for the text. +# +# epub_uid = '' + +# A list of files that should not be packed into the epub file. +epub_exclude_files = ['search.html'] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 000000000..35da24581 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,19 @@ +OMERO.scripts Technical Description +=================================== + +Description of the methods in the +collection of Python scripts available in this repository. + + +.. toctree:: + :maxdepth: 1 + + scripts + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` \ No newline at end of file diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 000000000..922152e96 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/scripts.rst b/docs/scripts.rst new file mode 100644 index 000000000..89a63e350 --- /dev/null +++ b/docs/scripts.rst @@ -0,0 +1,130 @@ +Python Scripts Technical Description +==================================== + +Description of the methods in the +collection of Python scripts available in this repository. + +Analysis scripts +~~~~~~~~~~~~~~~~ + +Kymograph +--------- + +.. automodule:: Kymograph + :members: + + +Kymograph Analysis +------------------ + +.. automodule:: Kymograph_Analysis + :members: + + +Plot Profile +------------ + +.. automodule:: Plot_Profile + :members: + +Export scripts +~~~~~~~~~~~~~~ + +Batch Image Export +------------------ + +.. automodule:: Batch_Image_Export + :members: + +Batch ROI Export +---------------- + +.. automodule:: Batch_ROI_Export + :members: + +Make Movie +---------- + +.. automodule:: Make_Movie + :members: + +Figure scripts +~~~~~~~~~~~~~~ + +Movie Figure +------------ + +.. automodule:: Movie_Figure + :members: + +Movie ROI Figure +---------------- + +.. automodule:: Movie_ROI_Figure + :members: + +ROI Split Figure +---------------- + +.. automodule:: ROI_Split_Figure + :members: + +Split View Figure +----------------- + +.. automodule:: Split_View_Figure + :members: + +Thumbnail Figure +---------------- + +.. automodule:: Thumbnail_Figure + :members: + +Import scripts +~~~~~~~~~~~~~~ + +Populate Metadata +----------------- + +.. automodule:: Populate_Metadata + :members: + +Populate ROI +------------ + +.. automodule:: Populate_ROI + :members: + +Util scripts +~~~~~~~~~~~~ + +Channel Offsets +--------------- + +.. automodule:: Channel_Offsets + :members: + +Combine Images +-------------- + +.. automodule:: Combine_Images + :members: + +Dataset To Plate +---------------- + +.. automodule:: Dataset_To_Plate + :members: + +Images From ROIs +---------------- + +.. automodule:: Images_From_ROIs + :members: + +Move Annotations +---------------- + +.. automodule:: Move_Annotations + :members: \ No newline at end of file diff --git a/omero/analysis_scripts/Kymograph.py b/omero/analysis_scripts/Kymograph.py index dc2f43fcb..4e650a108 100644 --- a/omero/analysis_scripts/Kymograph.py +++ b/omero/analysis_scripts/Kymograph.py @@ -58,12 +58,12 @@ def get_line_data(image, x1, y1, x2, y2, line_w=2, the_z=0, the_c=0, the_t=0): Uses PIL to handle rotating and interpolating the data. Converts to numpy to PIL and back (may change dtype.) - @param pixels: PixelsWrapper object - @param x1, y1, x2, y2: Coordinates of line - @param line_w: Width of the line we want - @param the_z: Z index within pixels - @param the_c: Channel index - @param the_t: Time index + :param pixels: PixelsWrapper object + :param x1, y1, x2, y2: Coordinates of line + :param line_w: Width of the line we want + :param the_z: Z index within pixels + :param the_c: Channel index + :param the_t: Time index """ size_x = image.getSizeX() size_y = image.getSizeY() @@ -143,7 +143,7 @@ def polyline_kymograph(conn, script_params, image, polylines, line_width, """ Create a new kymograph Image from one or more polylines. - @param polylines: map of theT: {theZ:theZ, points: list of (x,y)} + :param polylines: map of theT: {theZ:theZ, points: list of (x,y)} """ size_c = image.getSizeC() size_t = image.getSizeT() diff --git a/omero/analysis_scripts/Kymograph_Analysis.py b/omero/analysis_scripts/Kymograph_Analysis.py index 4526a77fc..079231b6f 100644 --- a/omero/analysis_scripts/Kymograph_Analysis.py +++ b/omero/analysis_scripts/Kymograph_Analysis.py @@ -1,32 +1,33 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2017 University of Dundee. All rights reserved. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2017 University of Dundee. All rights reserved. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ------------------------------------------------------------------------------- +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. -This script is the second Kymograph script, for analyzing lines drawn on -kymograph images that have been created by the 'Kymograph.py' Script. +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# ------------------------------------------------------------------------------ -@author Will Moore -will@lifesci.dundee.ac.uk -@since 3.0 """ +This script is the second Kymograph script, for analyzing lines drawn on +kymograph images that have been created by the 'Kymograph.py' Script. +""" +# @author Will Moore +# will@lifesci.dundee.ac.uk +# @version 5.5.0 +# @since 3.0 from omero.gateway import BlitzGateway import omero diff --git a/omero/analysis_scripts/Plot_Profile.py b/omero/analysis_scripts/Plot_Profile.py index dfc12a67e..815997b02 100644 --- a/omero/analysis_scripts/Plot_Profile.py +++ b/omero/analysis_scripts/Plot_Profile.py @@ -1,34 +1,34 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2017 University of Dundee. All rights reserved. +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2017 University of Dundee. All rights reserved. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ +""" This script processes Images which have Line or PolyLine ROIs, saving the intensity of chosen channels to Excel (csv) files. - -@author Will Moore -will@lifesci.dundee.ac.uk -@since 3.0 """ +# @author Will Moore +# will@lifesci.dundee.ac.uk +# @since 3.0 + from omero.gateway import BlitzGateway import omero from omero.rtypes import rstring, rlong, robject, unwrap @@ -45,7 +45,7 @@ def process_polylines(conn, script_params, image, polylines, line_width, fout): """ Output data from one or more polylines on an image. Attach csv to image. - @param polylines list of theT:T, theZ:Z, points: list of (x,y)} + :param polylines: list of theT:T, theZ:Z, points: list of (x,y)} """ pixels = image.getPrimaryPixels() the_cs = script_params['Channels'] diff --git a/omero/export_scripts/Batch_Image_Export.py b/omero/export_scripts/Batch_Image_Export.py index 227633d39..4f75c4a23 100644 --- a/omero/export_scripts/Batch_Image_Export.py +++ b/omero/export_scripts/Batch_Image_Export.py @@ -1,34 +1,35 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2014 University of Dundee. All rights reserved. + +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2021 University of Dundee. All rights reserved. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ +""" This script takes a number of images and saves individual image planes in a zip file for download. - -@author Will Moore -will@lifesci.dundee.ac.uk -@version 4.3 -@since 3.0-Beta4.3 """ +# @author Will Moore +# will@lifesci.dundee.ac.uk +# @version 4.3 +# @since 3.0-Beta4.3 + import omero.scripts as scripts from omero.gateway import BlitzGateway import omero.util.script_utils as script_utils @@ -66,9 +67,8 @@ def compress(target, base): """ Creates a ZIP recursively from a given base directory. - @param target: Name of the zip file we want to write E.g. - "folder.zip" - @param base: Name of folder that we want to zip up E.g. "folder" + :param target: Name of the zip file we want to write e.g. "folder.zip" + :param base: Name of folder that we want to zip up E.g. "folder" """ zip_file = zipfile.ZipFile(target, 'w') try: @@ -85,18 +85,16 @@ def save_plane(image, format, c_name, z_range, project_z, t=0, channel=None, """ Renders and saves an image to disk. - @param image: The image to render - @param format: The format to save as - @param c_name: The name to use - @param z_range: Tuple of (zIndex,) OR (zStart, zStop) for - projection - @param t: T index - @param channel: Active channel index. If None, use current - rendering settings - @param greyscale: If true, all visible channels will be - greyscale - @param zoom_percent: Resize image by this percent if specified - @param folder_name: Indicate where to save the plane + :param image: The image to render + :param format: The format to save as + :param c_name: The name to use + :param z_range: Tuple of (zIndex,) OR (zStart, zStop) for projection + :param t: T index + :param channel: Active channel index. + If None, use current rendering settings + :param greyscale: If true, all visible channels will begreyscale + :param zoom_percent: Resize image by this percent if specified + :param folder_name: Indicate where to save the plane """ original_name = image.getName() @@ -199,17 +197,14 @@ def save_planes_for_image(conn, image, size_c, split_cs, merged_cs, Saves all the required planes for a single image, either as individual planes or projection. - @param renderingEngine: Rendering Engine, NOT initialised. - @param queryService: OMERO query service - @param imageId: Image ID - @param zRange: Tuple: (zStart, zStop). If None, use default - Zindex - @param tRange: Tuple: (tStart, tStop). If None, use default - Tindex - @param greyscale: If true, all visible channels will be - greyscale - @param zoomPercent: Resize image by this percent if specified. - @param projectZ: If true, project over Z range. + :param renderingEngine: Rendering Engine, NOT initialised. + :param queryService: OMERO query service + :param imageId: Image ID + :param zRange: Tuple: (zStart, zStop). If None, use default Zindex + :param tRange: Tuple: (tStart, tStop). If None, use default Tindex + :param greyscale: If true, all visible channels will be greyscale + :param zoomPercent: Resize image by this percent if specified. + :param projectZ: If true, project over Z range. """ channels = [] diff --git a/omero/export_scripts/Batch_ROI_Export.py b/omero/export_scripts/Batch_ROI_Export.py index a9bbe816b..5c28a34ef 100644 --- a/omero/export_scripts/Batch_ROI_Export.py +++ b/omero/export_scripts/Batch_ROI_Export.py @@ -19,7 +19,9 @@ # ------------------------------------------------------------------------------ -"""This script exports ROI intensities for selected images.""" +""" +This script exports ROI intensities for selected images. +""" import omero.scripts as scripts diff --git a/omero/export_scripts/Make_Movie.py b/omero/export_scripts/Make_Movie.py index 87152e683..4c0e3e1a9 100644 --- a/omero/export_scripts/Make_Movie.py +++ b/omero/export_scripts/Make_Movie.py @@ -1,59 +1,35 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2015 University of Dundee. All rights reserved. +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2021 University of Dundee. All rights reserved. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ +""" Make movie takes a number of parameters and creates an movie from the image with imageId supplied. This movie is uploaded back to the server and attached to the original Image. - -params: - imageId: this id of the image to create the movie from - output: The name of the output file, sans the extension - zStart: The starting z-section to create the movie from - zEnd: The final z-section - tStart: The starting timepoint to create the movie - tEnd: The final timepoint. - channels: The list of channels to use in the movie(index, from 0) - splitView: should we show the split view in the movie(not available yet) - showTime: Show the average time of the aquisition of the channels in the - frame. - showPlaneInfo: Show the time and z-section of the current frame. - fps: The number of frames per second of the movie - scalebar: The scale bar size in microns, if <=0 will not show scale bar. - format: The format of the movie to be created currently supports - 'video/mpeg', 'video/quicktime' - overlayColour: The color of the overlays, scale bar, time, as int(RGB) - fileAnnotation: The fileAnnotation id of the uploaded movie. - -@author Jean-Marie Burel      -j.burel@dundee.ac.uk -@author Donald MacDonald      -donald@lifesci.dundee.ac.uk -@version 3.0 - -(Internal version: $Revision: $Date: $) - -@since 3.0-Beta4.1 - """ +# @author Jean-Marie Burel      +# j.burel@dundee.ac.uk +# @author Donald MacDonald      +# donald@lifesci.dundee.ac.uk +# @version 3.0 +# @since 3.0-Beta4.1 import omero.scripts as scripts import omero.util.script_utils as script_utils @@ -393,11 +369,11 @@ def write_intro_end_slides(conn, command_args, orig_file_id, duration, size_x, Uses an original file (jpeg or png) to add frames to the movie. Scales and pads to fit size_x, size_y. - @param orig_file_id: Original File (png or jpeg) ID - @param duration: Duration of intro / end (secs) - @param size_x: Width of the exported movie - @param size_y: Height of the exported movie - @return: List of file names to add to mencoder list + :param orig_file_id: Original File (png or jpeg) ID + :param duration: Duration of intro / end (secs) + :param size_x: Width of the exported movie + :param size_y: Height of the exported movie + :return: List of file names to add to mencoder list """ slide_filenames = [] @@ -430,7 +406,7 @@ def prepare_watermark(conn, command_args, size_x, size_y): Read Original File (png or jpeg) to use as watermark, scale if needed to fit movie (size_x, size_y) and return - @return: PIL Image to use as watermark. + :return: PIL Image to use as watermark. """ wm_orig_file = command_args["Watermark"] @@ -463,7 +439,7 @@ def write_movie(command_args, conn): """ Makes the movie. - @return Returns the file annotation + :return: Returns the file annotation """ log("Movie created by OMERO") log("") diff --git a/omero/figure_scripts/Movie_Figure.py b/omero/figure_scripts/Movie_Figure.py index e0f9642d0..29dc4814f 100644 --- a/omero/figure_scripts/Movie_Figure.py +++ b/omero/figure_scripts/Movie_Figure.py @@ -1,38 +1,38 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2017 University of Dundee. All rights reserved. + +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2021 University of Dundee. All rights reserved. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------ +""" Script produces a figure of a movie, showing panels of different frames. Saves the figure as a jpg or png attached to the first image in the figure. - -@author William Moore      -will@lifesci.dundee.ac.uk -@author Jean-Marie Burel      -j.burel@dundee.ac.uk -@author Donald MacDonald      -donald@lifesci.dundee.ac.uk -@since 3.0 - """ +# @author William Moore      +# will@lifesci.dundee.ac.uk +# @author Jean-Marie Burel      +# j.burel@dundee.ac.uk +# @author Donald MacDonald      +# donald@lifesci.dundee.ac.uk +# @since 3.0 + import omero.scripts as scripts import omero.util.image_utils as image_utils import omero.util.figureUtil as figUtil @@ -73,22 +73,21 @@ def createmovie_figure(conn, pixel_ids, t_indexes, z_start, z_end, width, frame to show the time-stamp of that frame in the specified units and labels on the left name each image. - @param conn The OMERO session - @param pixel_ids A list of the Pixel IDs for the images in the - figure - @param t_indexes A list of tIndexes to display frames from - @param z_start Projection Z-start - @param z_end Projection Z-end - @param width Maximum width of panels - @param height Max height of panels - @param spacer Space between panels - @param algorithm Projection algorithm e.g. "MAXIMUMINTENSITY" - @param stepping Projecttion z-step - @param scalebar A number of microns for scale-bar - @param overlay_colour Color of the scale bar as tuple (255,255,255) - @param time_units A string such as "SECS" - @param image_labels A list of lists, corresponding to pixelIds, for - labelling each image with one or more strings. + :param conn: The OMERO session + :param pixel_ids: A list of the Pixel IDs for the images in the figure + :param t_indexes: A list of tIndexes to display frames from + :param z_start: Projection Z-start + :param z_end: Projection Z-end + :param width: Maximum width of panels + :param height: Max height of panels + :param spacer: Space between panels + :param algorithm: Projection algorithm e.g. "MAXIMUMINTENSITY" + :param stepping: Projection z-step + :param scalebar: A number of microns for scale-bar + :param overlay_colour: Color of the scale bar as tuple (255,255,255) + :param time_units: A string such as "SECS" + :param image_labels: A list of lists, corresponding to pixelIds, \ + for labelling each image with one or more strings. """ mode = "RGB" @@ -283,13 +282,13 @@ def add_left_labels(panel_canvas, image_labels, row_index, width, spacer): index of the current image panel) so that we know what is the max label count and can give all panels the same margin on the left. - @param panelCanvas: PIL image - add labels to the left of this - @param imageLabels: A series of label lists, one per image. We only - add labels from one list - @param rowIndex: The index of the label list we're going to use - from imageLabels - @param width: Simply used for finding a suitable font size - @param spacer: Space between panels + :param panelCanvas: PIL image - add labels to the left of this + :param imageLabels: A series of label lists, one per image. We only\ + add labels from one list + :param rowIndex: The index of the label list we're going to use from \ + imageLabels + :param width: Simply used for finding a suitable font size + :param spacer: Space between panels """ # add lables to row... @@ -346,10 +345,10 @@ def movie_figure(conn, command_args): Makes the figure using the parameters in @command_args, attaches the figure to the parent Project/Dataset, and returns the file-annotation ID - @param session The OMERO session - @param command_args Map of parameters for the script - @ returns Returns the id of the originalFileLink child. (ID - object, not value) + :param session: The OMERO session + :param command_args: Map of parameters for the script + :return: Returns the id of the originalFileLink child. \ + (ID object, not value) """ log("Movie figure created by OMERO on %s" % date.today()) @@ -561,8 +560,7 @@ def run_script(): """Export a figure of a movie, showing a row of frames for each \ chosen image. NB: OMERO.insight client provides a nicer UI for this script under \ -'Publishing Options' -See http://help.openmicroscopy.org/publish.html#movies""", +'Publishing Options'""", # provide 'Data_Type' and 'IDs' parameters so that Insight # auto-populates with currently selected images. diff --git a/omero/figure_scripts/Movie_ROI_Figure.py b/omero/figure_scripts/Movie_ROI_Figure.py index 5815df06a..4142035fe 100644 --- a/omero/figure_scripts/Movie_ROI_Figure.py +++ b/omero/figure_scripts/Movie_ROI_Figure.py @@ -1,38 +1,38 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2014 University of Dundee. All rights reserved. - - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2021 University of Dundee. All rights reserved. +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# ------------------------------------------------------------------------------ +""" This script takes a number of images and displays regions defined by their ROIs as zoomed panels beside the images. - -@author William Moore      -will@lifesci.dundee.ac.uk -@author Jean-Marie Burel      -j.burel@dundee.ac.uk -@author Donald MacDonald      -donald@lifesci.dundee.ac.uk -@since 3.0 - """ +# @author William Moore      +# will@lifesci.dundee.ac.uk +# @author Jean-Marie Burel      +# j.burel@dundee.ac.uk +# @author Donald MacDonald      +# donald@lifesci.dundee.ac.uk +# @since 3.0 + import omero.scripts as scripts import omero.util.image_utils as image_utils import omero.util.figureUtil as figUtil @@ -331,15 +331,15 @@ def get_split_view(conn, image_ids, pixel_ids, merged_indexes, merged_colours, The figure is returned as a PIL 'Image' - @ session session for server access - @ pixelIds a list of the Ids for the pixels we want to display - @ mergedIndexes list or set of channels in the merged image - @ mergedColours index: colour dictionary of channels in the merged - image - @ width the size in pixels to show each panel - @ height the size in pixels to show each panel - @ spacer the gap between images and around the figure. Doubled - between rows. + :param session: session for server access + :param pixelIds: a list of the Ids for the pixels we want to display + :param mergedIndexes: list or set of channels in the merged image + :param mergedColours: index: colour dictionary of channels in the\ + merged image + :param width: the size in pixels to show each panel + :param height: the size in pixels to show each panel + :param spacer: the gap between images and around the figure.\ + Doubled between rows. """ roi_service = conn.getRoiService() @@ -486,15 +486,14 @@ def roi_figure(conn, command_args): Then calls a method to make the figure, and finally uploads and attaches this to the primary image. - @param: session The OMERO session - @param: command_args Map of String:Object parameters for the script. + :param session: The OMERO session + :param command_args: Map of String:Object parameters for the script. Objects are not rtypes, since getValue() was called when the map was processed below. But, list and map objects may contain rtypes (need to call getValue()) - @return: the id of the originalFileLink child. (ID object, - not value) + :return: the id of the originalFileLink child. (ID object, not value) """ log("ROI figure created by OMERO on %s" % date.today()) diff --git a/omero/figure_scripts/ROI_Split_Figure.py b/omero/figure_scripts/ROI_Split_Figure.py index 90a63fc3d..7de770078 100644 --- a/omero/figure_scripts/ROI_Split_Figure.py +++ b/omero/figure_scripts/ROI_Split_Figure.py @@ -1,37 +1,35 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2017 University of Dundee. All rights reserved. - - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2021 University of Dundee. All rights reserved. +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# ------------------------------------------------------------------------------ +""" This script takes a number of images and displays regions defined by their ROIs as zoomed panels beside the images. - -@author William Moore      -will@lifesci.dundee.ac.uk -@author Jean-Marie Burel      -j.burel@dundee.ac.uk -@author Donald MacDonald      -donald@lifesci.dundee.ac.uk -@since 3.0 - """ +# @author William Moore      +# will@lifesci.dundee.ac.uk +# @author Jean-Marie Burel      +# j.burel@dundee.ac.uk +# @author Donald MacDonald      +# donald@lifesci.dundee.ac.uk +# @since 3.0 import omero import omero.scripts as scripts @@ -75,7 +73,7 @@ def get_roi_split_view(re, pixels, z_start, z_end, split_indexes, This takes a ROI rectangle from an image and makes a split view canvas of the region in the ROI, zoomed by a defined factor. - @param re The OMERO rendering engine. + :param re: The OMERO rendering engine. """ if algorithm is None: # omero::constants::projection::ProjectionType @@ -306,7 +304,9 @@ def draw_rectangle(image, roi_x, roi_y, roi_x2, roi_y2, colour, stroke=1): def get_rectangle(roi_service, image_id, roi_label): """ Returns (x, y, width, height, zMin, zMax, tMin, tMax) of the first - rectange in the image that has @roi_label as text + rectange in the image that has roi_label as text. + + :return: First rectangle. """ result = roi_service.findByImage(image_id, None) @@ -382,19 +382,19 @@ def get_split_view(conn, image_ids, pixel_ids, split_indexes, channel_names, The figure is returned as a PIL 'Image' - @ session session for server access - @ pixel_ids a list of the Ids for the pixels we want to display - @ split_indexes a list of the channel indexes to display. Same - channels for each image/row - @ channel_names the Map of index:names for all channels - @ colour_channels the colour to make each column/ channel - @ merged_indexes list or set of channels in the merged image - @ merged_colours index: colour dictionary of channels in the merged - image - @ width the size in pixels to show each panel - @ height the size in pixels to show each panel - @ spacer the gap between images and around the figure. Doubled - between rows. + :param session: session for server access + :param pixel_ids: a list of the Ids for the pixels we want to display + :param split_indexes: a list of the channel indexes to display.\ + Same channels for each image/row + :param channel_names: the Map of index:names for all channels + :param colour_channels: the colour to make each column/ channel + :param merged_indexes: list or set of channels in the merged image + :param merged_colours: index: colour dictionary of channels in the\ + merged image + :param width: the size in pixels to show each panel + :param height: the size in pixels to show each panel + :param spacer: the gap between images and around the figure.\ + Doubled between rows. """ roi_service = conn.getRoiService() @@ -557,15 +557,14 @@ def roi_figure(conn, command_args): Then calls a method to make the figure, and finally uploads and attaches this to the primary image. - @param: session The OMERO session - @param: command_args Map of String:Object parameters for the script. + :param: session The OMERO session + :param: command_args Map of String:Object parameters for the script. Objects are not rtypes, since getValue() was called when the map was processed below. But, list and map objects may contain rtypes (need to call getValue()) - @return: the id of the originalFileLink child. (ID object, - not value) + :return: the id of the originalFileLink child. (ID object, not value) """ log("ROI figure created by OMERO on %s" % date.today()) diff --git a/omero/figure_scripts/Split_View_Figure.py b/omero/figure_scripts/Split_View_Figure.py index db5e07fdd..720871dc8 100644 --- a/omero/figure_scripts/Split_View_Figure.py +++ b/omero/figure_scripts/Split_View_Figure.py @@ -1,36 +1,35 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2017 University of Dundee. All rights reserved. - - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2021 University of Dundee. All rights reserved. +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# ------------------------------------------------------------------------------ +""" This script takes a number of images an makes a split view figure, one image per row, displayed as a split view with merged image. - -@author Jean-Marie Burel      -j.burel@dundee.ac.uk -@author Donald MacDonald      -donald@lifesci.dundee.ac.uk -@since 3.0 - """ +# @author Jean-Marie Burel      +# j.burel@dundee.ac.uk +# @author Donald MacDonald      +# donald@lifesci.dundee.ac.uk +# @since 3.0 + import omero.scripts as scripts import omero.util.figureUtil as figUtil import omero.util.image_utils as image_utils @@ -75,28 +74,28 @@ def get_split_view(conn, pixel_ids, z_start, z_end, split_indexes, each row being the split-view of a single image. The channels are arranged left to right, with the combined image added on the right. The combined image is rendered according to current settings on the - server, but it's channels will be turned on/off according to + server, but its channels will be turned on/off according to @merged_indexes. No text labels are added to the image at this stage. The figure is returned as a PIL 'Image' - @ conn session for server access - @ pixel_ids a list of the Ids for the pixels we want to display - @ z_start the start of Z-range for projection - @ z_end the end of Z-range for projection - @ split_indexes a list of the channel indexes to display. Same - channels for each image/row - @ channel_names the Map of index:names to go above the columns for - each split channel - @ colour_channels the colour to make each column/ channel - @ merged_indexes list or set of channels in the merged image - @ merged_colours index: colour dictionary of channels in the merged - image - @ width the size in pixels to show each panel - @ height the size in pixels to show each panel - @ spacer the gap between images and around the figure. Doubled - between rows. + :param conn: session for server access + :param pixel_ids: a list of the Ids for the pixels we want to display + :param z_start: the start of Z-range for projection + :param z_end: the end of Z-range for projection + :param split_indexes: a list of the channel indexes to display.\ + Same channels for each image/row + :param channel_names: the Map of index:names to go above the columns\ + for each split channel + :param colour_channels: the colour to make each column/ channel + :param merged_indexes: list or set of channels in the merged image + :param merged_colours: index: colour dictionary of channels in the\ + merged image + :param width: the size in pixels to show each panel + :param height: the size in pixels to show each panel + :param spacer: the gap between images and around the figure.\ + Doubled between rows. """ if algorithm is None: # omero::constants::projection::ProjectionType @@ -328,38 +327,38 @@ def make_split_view_figure(conn, pixel_ids, z_start, z_end, split_indexes, each row being the split-view of a single image. The channels are arranged left to right, with the combined image added on the right. The combined image is rendered according to current settings on the - server, but it's channels will be turned on/off according to + server, but its channels will be turned on/off according to @merged_indexes. The colour of each channel turned white if colour_channels is false or the channel is not in the merged image. Otherwise channel is changed to merged_colours[i] Text is added at the top of the figure, to display channel names above - each column, and the combined image may have it's various channels named + each column, and the combined image may have its various channels named in coloured text. The optional image_labels is a list of string lists for naming the images at the left of the figure (Each image may have 0 or multiple labels). The figure is returned as a PIL 'Image' - @ conn session for server access - @ pixel_ids a list of the Ids for the pixels we want to display - @ z_start the start of Z-range for projection - @ z_end the end of Z-range for projection - @ split_indexes a list of the channel indexes to display. Same - channels for each image/row - @ channel_names map of index:name to go above the columns for each - split channel - @ colour_channels true if split channels are - @ merged_indexes list (or set) of channels in the merged image - @ merged_colours index: colour map of channels in the merged image - @ merged_names if true, label with merged panel with channel names - (otherwise, label "Merged") - @ width the width of primary image (all images zoomed to this - height) - @ height the height of primary image - @ image_labels optional list of string lists. - @ algorithm for projection MAXIMUMINTENSITY or MEANINTENSITY - @ stepping projection increment + :param conn: session for server access + :param pixel_ids: a list of the Ids for the pixels we want to display + :param z_start: the start of Z-range for projection + :param z_end: the end of Z-range for projection + :param split_indexes: a list of the channel indexes to display.\ + Same channels for each image/row + :param channel_names: map of index:name to go above the columns for\ + each split channel + :param colour_channels: true if split channels are + :param merged_indexes: list (or set) of channels in the merged image + :param merged_colours: index: colour map of channels in the merged image + :param merged_names: if true, label with merged panel with channel names\ + (otherwise, label "Merged") + :param width: the width of primary image.\ + All images zoomed to this height + :param height: the height of primary image + :param image_labels: optional list of string lists. + :param algorithm: for projection MAXIMUMINTENSITY or MEANINTENSITY + :param stepping: projection increment """ fontsize = 12 @@ -488,7 +487,7 @@ def split_view_figure(conn, script_params): then calls make_split_view_figure() to make the figure, attaches it to the Image as an 'originalFile' annotation, with fig-legend as the description. - @return: the id of the originalFileLink child. (ID object, not value) + :return: the id of the originalFileLink child. (ID object, not value) """ log("Split-View figure created by OMERO on %s" % date.today()) diff --git a/omero/figure_scripts/Thumbnail_Figure.py b/omero/figure_scripts/Thumbnail_Figure.py index 459d2ccc5..d303dcdf3 100644 --- a/omero/figure_scripts/Thumbnail_Figure.py +++ b/omero/figure_scripts/Thumbnail_Figure.py @@ -1,38 +1,38 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2017 University of Dundee. All rights reserved. - - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2021 University of Dundee. All rights reserved. +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# ------------------------------------------------------------------------------ +""" This script displays a bunch of thumbnails from OMERO as a jpg or png, saved back to the server as a FileAnnotation attached to the parent dataset or project. +""" -@author William Moore      -will@lifesci.dundee.ac.uk -@author Jean-Marie Burel      -j.burel@dundee.ac.uk -@author Donald MacDonald      -donald@lifesci.dundee.ac.uk -@since 3.0 +# @author William Moore      +# will@lifesci.dundee.ac.uk +# @author Jean-Marie Burel      +# j.burel@dundee.ac.uk +# @author Donald MacDonald      +# donald@lifesci.dundee.ac.uk +# @since 3.0 -""" from io import BytesIO import omero.scripts as scripts from omero.gateway import BlitzGateway @@ -69,10 +69,10 @@ def paste_image(image, canvas, x, y): Pastes the image onto the canvas at the specified coordinates Image and canvas are instances of PIL 'Image' - @param image: The PIL image to be pasted. Image - @param canvas: The PIL image on which to paste. Image - @param x: X coordinate (left) to paste - @param y: Y coordinate (top) to paste + :param image: The PIL image to be pasted. Image + :param canvas: The PIL image on which to paste. Image + :param x: X coordinate (left) to paste + :param y: Y coordinate (top) to paste """ x = int(x) @@ -89,8 +89,8 @@ def get_font(fontsize): Returns a PIL ImageFont Sans-serif true-type font of the specified size or a pre-compiled font of fixed size if the ttf font is not found - @param fontsize: The size of the font you want - @return: A PIL Font + :param fontsize: The size of the font you want + :return: A PIL Font """ fontsize = int(fontsize) font_path = os.path.join(GATEWAYPATH, "pilfonts", "FreeSans.ttf") @@ -110,21 +110,18 @@ def paint_thumbnail_grid(thumbnail_store, length, spacing, pixel_ids, Option to add a vertical label to the left of the canvas Creates a PIL 'Image' which is returned - @param thumbnail_store: The omero thumbnail store. - @param length: Length of longest thumbnail side, int - @param spacing: The spacing between thumbnails and around the - edges. int - @param pixel_ids: List of pixel IDs. [long] - @param col_count: The number of columns. int - @param bg: Background colour as (r,g,b). - Default is white (255, 255, 255) - @param left_label: Optional string to display vertically to the left. - @param text_color: The color of the text as (r,g,b). - Default is black (0, 0, 0) - @param fontsize: Size of the font. - Default is calculated based on thumbnail length, - int - @return: The PIL Image canvas. + :param thumbnail_store: The omero thumbnail store. + :param length: Length of longest thumbnail side, int + :param spacing: The spacing between thumbnails and around the edges. int + :param pixel_ids: List of pixel IDs. [long] + :param col_count: The number of columns. int + :param bg: Background colour as (r,g,b). Default is white (255, 255, 255) + :param left_label: Optional string to display vertically to the left. + :param text_color: The color of the text as (r,g,b).\ + Default is black (0, 0, 0) + :param fontsize: Size of the font. Default is calculated based on\ + thumbnail length, int + :return: The PIL Image canvas. """ mode = "RGB" # work out how many rows and columns are needed for all the images @@ -254,17 +251,17 @@ def sort_images_by_tag(tag_ids, img_tags): def paint_dataset_canvas(conn, images, title, tag_ids=None, show_untagged=False, col_count=10, length=100): """ - Paints and returns a canvas of thumbnails from images, laid out in a - set number of columns. - Title and date-range of the images is printed above the thumbnails, - to the left and right, respectively. - - @param conn: Blitz connection - @param image: Image IDs - @param title: title to display at top of figure. String - @param tag_ids: Optional to sort thumbnails by tag. [long] - @param col_count: Max number of columns to lay out thumbnails - @param length: Length of longest side of thumbnails + Paints and returns a canvas of thumbnails from images, laid out in a + set number of columns. + Title and date-range of the images is printed above the thumbnails, + to the left and right, respectively. + + :param conn: Blitz connection + :param image: Image IDs + :param title: title to display at top of figure. String + :param tag_ids: Optional to sort thumbnails by tag. [long] + :param col_count: Max number of columns to lay out thumbnails + :param length: Length of longest side of thumbnails """ mode = "RGB" @@ -499,7 +496,7 @@ def make_thumbnail_figure(conn, script_params): Makes the figure using the parameters in @script_params, attaches the figure to the parent Project/Dataset, and returns the file-annotation ID - @ returns Returns the id of the originalFileLink child. (ID object, + :return: Returns the id of the originalFileLink child. (ID object, not value) """ diff --git a/omero/import_scripts/Populate_Metadata.py b/omero/import_scripts/Populate_Metadata.py index 874bf9f39..3a86adb78 100644 --- a/omero/import_scripts/Populate_Metadata.py +++ b/omero/import_scripts/Populate_Metadata.py @@ -1,24 +1,24 @@ -# coding=utf-8 -''' ------------------------------------------------------------------------------ - Copyright (C) 2014-2020 Glencoe Software, Inc. All rights reserved. - - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ------------------------------------------------------------------------------- +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# ----------------------------------------------------------------------------- +# Copyright (C) 2014-2020 Glencoe Software, Inc. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# ------------------------------------------------------------------------------ +''' Populate metadata from CSV. ''' diff --git a/omero/import_scripts/Populate_ROI.py b/omero/import_scripts/Populate_ROI.py index 1ae092d83..c97167dd9 100644 --- a/omero/import_scripts/Populate_ROI.py +++ b/omero/import_scripts/Populate_ROI.py @@ -1,26 +1,25 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" - ------------------------------------------------------------------------------ - Copyright (C) 2016 University of Dundee. All rights reserved. - - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2021 University of Dundee. All rights reserved. +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# ------------------------------------------------------------------------------ +""" Uses the omero.util.populate_roi functionality to parse all the measurement files attached to a plate, and generate server-side rois. @@ -35,23 +34,31 @@ import omero.scripts as scripts from omero.util.populate_roi import PlateAnalysisCtxFactory -client = scripts.client( - 'Populate_ROI.py', - scripts.Long( - "Plate_ID", optional=False, - description="ID of a valid plate with attached results files"), - version="4.2.0", - contact="ome-users@lists.openmicroscopy.org.uk", - description="""Generates regions of interest from the measurement files \ -associated with a plate - -This script is executed by the server on initial import, and should typically\ -not need to be run by users.""") - -factory = PlateAnalysisCtxFactory(client.getSession()) -analysis_ctx = factory.get_analysis_ctx(client.getInput("Plate_ID").val) -n_measurements = analysis_ctx.get_measurement_count() - -for i in range(n_measurements): - measurement_ctx = analysis_ctx.get_measurement_ctx(i) - measurement_ctx.parse_and_populate() + +def run_script(): + + client = scripts.client( + 'Populate_ROI.py', + scripts.Long( + "Plate_ID", optional=False, + description="ID of a valid plate with attached\ + results files"), + version="4.2.0", + description=""" + Generates regions of interest from the measurement files \ + associated with a plate + + This script is executed by the server on initial import, \ + and should typically not need to be run by users.""") + + factory = PlateAnalysisCtxFactory(client.getSession()) + analysis_ctx = factory.get_analysis_ctx(client.getInput("Plate_ID").val) + n_measurements = analysis_ctx.get_measurement_count() + + for i in range(n_measurements): + measurement_ctx = analysis_ctx.get_measurement_ctx(i) + measurement_ctx.parse_and_populate() + + +if __name__ == "__main__": + run_script() diff --git a/omero/util_scripts/Channel_Offsets.py b/omero/util_scripts/Channel_Offsets.py index fcda87ca8..15a6dbfc9 100644 --- a/omero/util_scripts/Channel_Offsets.py +++ b/omero/util_scripts/Channel_Offsets.py @@ -1,38 +1,34 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2014 University of Dundee. All rights reserved. - - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2021 University of Dundee. All rights reserved. +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# ------------------------------------------------------------------------------ +""" This script creates new images from existing images, applying x, y, and z shifts to each channel independently, as specified in the parameters. - -@author Will Moore      -will@lifesci.dundee.ac.uk -@version 3.0 - -(Internal version: $Revision: $Date: $) - -@since 3.0-Beta4.3 - """ +# @author Will Moore      +# will@lifesci.dundee.ac.uk +# @version 3.0 +# @since 3.0-Beta4.3 + import omero from omero.gateway import BlitzGateway import omero.scripts as scripts @@ -48,8 +44,8 @@ def new_image_with_channel_offsets(conn, image_id, channel_offsets, Process a single image here: creating a new image and passing planes from original image to new image - applying offsets to each channel as we go. - @param image_id: Original image - @param channel_offsets: List of map for each channel {'index':index, + :param image_id: Original image + :param channel_offsets: List of map for each channel {'index':index, 'x':x, 'y'y, 'z':z} """ diff --git a/omero/util_scripts/Combine_Images.py b/omero/util_scripts/Combine_Images.py index f74bea1c4..23d9cf85c 100644 --- a/omero/util_scripts/Combine_Images.py +++ b/omero/util_scripts/Combine_Images.py @@ -1,38 +1,34 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2014 University of Dundee. All rights reserved. - - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2021 University of Dundee. All rights reserved. +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# ------------------------------------------------------------------------------ +""" This script takes a number of images (or Z-stacks) and merges them to create additional C, T, Z dimensions. - -@author Will Moore      -will@lifesci.dundee.ac.uk -@version 3.0 - -(Internal version: $Revision: $Date: $) - -@since 3.0-Beta4.2 - """ +# @author Will Moore      +# will@lifesci.dundee.ac.uk +# @version 3.0 +# @since 3.0-Beta4.2 + import re from numpy import zeros @@ -74,11 +70,11 @@ def get_plane(raw_pixel_store, pixels, the_z, the_c, the_t): This method downloads the specified plane of the OMERO image and returns it as a numpy array. - @param session The OMERO session - @param imageId The ID of the image to download - @param pixels The pixels object, with pixelsType - @param imageName The name of the image to write. If no path, saved in - the current directory. + :param session: The OMERO session + :param imageId: The ID of the image to download + :param pixels: The pixels object, with pixelsType + :param imageName: The name of the image to write.\ + If no path, saved in the current directory. """ # get the plane diff --git a/omero/util_scripts/Dataset_To_Plate.py b/omero/util_scripts/Dataset_To_Plate.py index c1fbcea68..88183b078 100644 --- a/omero/util_scripts/Dataset_To_Plate.py +++ b/omero/util_scripts/Dataset_To_Plate.py @@ -1,36 +1,34 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2014 University of Dundee. All rights reserved. - - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2021 University of Dundee. All rights reserved. +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# ------------------------------------------------------------------------------ +""" This script converts a Dataset of Images to a Plate, with one image per Well. - -@author Will Moore -will@lifesci.dundee.ac.uk -@version 4.3 - -(Internal version: $Revision: $Date: $) - -@since 3.0-Beta4.3 """ + +# @author Will Moore +# will@lifesci.dundee.ac.uk +# @version 4.3 +# @since 3.0-Beta4.3 + import omero.scripts as scripts from omero.gateway import BlitzGateway import omero diff --git a/omero/util_scripts/Images_From_ROIs.py b/omero/util_scripts/Images_From_ROIs.py index be5c300d0..174dcb627 100644 --- a/omero/util_scripts/Images_From_ROIs.py +++ b/omero/util_scripts/Images_From_ROIs.py @@ -1,37 +1,34 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" ------------------------------------------------------------------------------ - Copyright (C) 2006-2016 University of Dundee. All rights reserved. - - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- +# Copyright (C) 2006-2021 University of Dundee. All rights reserved. +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# ------------------------------------------------------------------------------ +""" This script gets all the Rectangles from a particular image, then creates new images with the regions within the ROIs, and saves them back to the server. +""" -@author Will Moore      -will@lifesci.dundee.ac.uk -@version 3.0 - -(Internal version: $Revision: $Date: $) - -@since 3.0-Beta4.2 +# @author Will Moore      +# will@lifesci.dundee.ac.uk +# @version 3.0 +# @since 3.0-Beta4.2 -""" from __future__ import print_function import omero import omero.scripts as scripts From 23399b3214ab1d481b901f7db64318fc12eca8cf Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Fri, 9 Apr 2021 14:03:22 +0100 Subject: [PATCH 2/8] split files --- docs/analysis_scripts.rst | 22 +++++++ docs/export_scripts.rst | 21 ++++++ docs/figure_scripts.rst | 33 ++++++++++ docs/import_scripts.rst | 14 ++++ docs/index.rst | 8 ++- docs/scripts.rst | 130 -------------------------------------- docs/util_scripts.rst | 32 ++++++++++ 7 files changed, 128 insertions(+), 132 deletions(-) create mode 100644 docs/analysis_scripts.rst create mode 100644 docs/export_scripts.rst create mode 100644 docs/figure_scripts.rst create mode 100644 docs/import_scripts.rst delete mode 100644 docs/scripts.rst create mode 100644 docs/util_scripts.rst diff --git a/docs/analysis_scripts.rst b/docs/analysis_scripts.rst new file mode 100644 index 000000000..5f3ba1c67 --- /dev/null +++ b/docs/analysis_scripts.rst @@ -0,0 +1,22 @@ +Analysis scripts +================ + +Kymograph +--------- + +.. automodule:: Kymograph + :members: + + +Kymograph Analysis +------------------ + +.. automodule:: Kymograph_Analysis + :members: + + +Plot Profile +------------ + +.. automodule:: Plot_Profile + :members: diff --git a/docs/export_scripts.rst b/docs/export_scripts.rst new file mode 100644 index 000000000..760972ea0 --- /dev/null +++ b/docs/export_scripts.rst @@ -0,0 +1,21 @@ +Export scripts +============== + + +Batch Image Export +------------------ + +.. automodule:: Batch_Image_Export + :members: + +Batch ROI Export +---------------- + +.. automodule:: Batch_ROI_Export + :members: + +Make Movie +---------- + +.. automodule:: Make_Movie + :members: diff --git a/docs/figure_scripts.rst b/docs/figure_scripts.rst new file mode 100644 index 000000000..72f527e4e --- /dev/null +++ b/docs/figure_scripts.rst @@ -0,0 +1,33 @@ +Figure scripts +============== + + +Movie Figure +------------ + +.. automodule:: Movie_Figure + :members: + +Movie ROI Figure +---------------- + +.. automodule:: Movie_ROI_Figure + :members: + +ROI Split Figure +---------------- + +.. automodule:: ROI_Split_Figure + :members: + +Split View Figure +----------------- + +.. automodule:: Split_View_Figure + :members: + +Thumbnail Figure +---------------- + +.. automodule:: Thumbnail_Figure + :members: diff --git a/docs/import_scripts.rst b/docs/import_scripts.rst new file mode 100644 index 000000000..35cca87bc --- /dev/null +++ b/docs/import_scripts.rst @@ -0,0 +1,14 @@ +Import scripts +============== + +Populate Metadata +----------------- + +.. automodule:: Populate_Metadata + :members: + +Populate ROI +------------ + +.. automodule:: Populate_ROI + :members: diff --git a/docs/index.rst b/docs/index.rst index 35da24581..15ac112ff 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -8,7 +8,11 @@ collection of Python scripts available in this repository. .. toctree:: :maxdepth: 1 - scripts + analysis_scripts + export_scripts + figure_scripts + import_scripts + util_scripts Indices and tables @@ -16,4 +20,4 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` -* :ref:`search` \ No newline at end of file +* :ref:`search` diff --git a/docs/scripts.rst b/docs/scripts.rst deleted file mode 100644 index 89a63e350..000000000 --- a/docs/scripts.rst +++ /dev/null @@ -1,130 +0,0 @@ -Python Scripts Technical Description -==================================== - -Description of the methods in the -collection of Python scripts available in this repository. - -Analysis scripts -~~~~~~~~~~~~~~~~ - -Kymograph ---------- - -.. automodule:: Kymograph - :members: - - -Kymograph Analysis ------------------- - -.. automodule:: Kymograph_Analysis - :members: - - -Plot Profile ------------- - -.. automodule:: Plot_Profile - :members: - -Export scripts -~~~~~~~~~~~~~~ - -Batch Image Export ------------------- - -.. automodule:: Batch_Image_Export - :members: - -Batch ROI Export ----------------- - -.. automodule:: Batch_ROI_Export - :members: - -Make Movie ----------- - -.. automodule:: Make_Movie - :members: - -Figure scripts -~~~~~~~~~~~~~~ - -Movie Figure ------------- - -.. automodule:: Movie_Figure - :members: - -Movie ROI Figure ----------------- - -.. automodule:: Movie_ROI_Figure - :members: - -ROI Split Figure ----------------- - -.. automodule:: ROI_Split_Figure - :members: - -Split View Figure ------------------ - -.. automodule:: Split_View_Figure - :members: - -Thumbnail Figure ----------------- - -.. automodule:: Thumbnail_Figure - :members: - -Import scripts -~~~~~~~~~~~~~~ - -Populate Metadata ------------------ - -.. automodule:: Populate_Metadata - :members: - -Populate ROI ------------- - -.. automodule:: Populate_ROI - :members: - -Util scripts -~~~~~~~~~~~~ - -Channel Offsets ---------------- - -.. automodule:: Channel_Offsets - :members: - -Combine Images --------------- - -.. automodule:: Combine_Images - :members: - -Dataset To Plate ----------------- - -.. automodule:: Dataset_To_Plate - :members: - -Images From ROIs ----------------- - -.. automodule:: Images_From_ROIs - :members: - -Move Annotations ----------------- - -.. automodule:: Move_Annotations - :members: \ No newline at end of file diff --git a/docs/util_scripts.rst b/docs/util_scripts.rst new file mode 100644 index 000000000..966b2510e --- /dev/null +++ b/docs/util_scripts.rst @@ -0,0 +1,32 @@ +Utility scripts +=============== + +Channel Offsets +--------------- + +.. automodule:: Channel_Offsets + :members: + +Combine Images +-------------- + +.. automodule:: Combine_Images + :members: + +Dataset To Plate +---------------- + +.. automodule:: Dataset_To_Plate + :members: + +Images From ROIs +---------------- + +.. automodule:: Images_From_ROIs + :members: + +Move Annotations +---------------- + +.. automodule:: Move_Annotations + :members: \ No newline at end of file From 89c3dd26276713fd0fee2ea04bedd2bf51d75dcd Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Fri, 9 Apr 2021 14:03:40 +0100 Subject: [PATCH 3/8] review setup --- docs/conf.py | 53 +++++++++++++++------------------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 52bb043d1..ffc4429a0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,19 +4,13 @@ # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html +from datetime import datetime import os import sys from sphinx.util import logging logger = logging.getLogger(__name__) -# To fix 'docs/contents.rst not found' errors we need this, see -# https://github.com/readthedocs/readthedocs.org/issues/2569 - -master_doc = 'index' -docs_root = 'https://docs.openmicroscopy.org' - - # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, @@ -38,12 +32,12 @@ def get_scripts(directory): return scripts -def find_scripts_entry(): +def find_scripts_entry(file_name): """ Find the entries corresponding to the scripts. """ - with open("scripts.rst") as file: + with open(file_name) as file: lines = file.readlines() entries = [] @@ -65,58 +59,40 @@ def compare(list1, list2): directories = ['../omero/analysis_scripts', '../omero/export_scripts', '../omero/figure_scripts', '../omero/import_scripts', '../omero/util_scripts'] + scripts = [] +entries = [] for d in directories: sys.path.insert(0, d) scripts.extend(get_scripts(d)) - -entries = find_scripts_entry() + p = d.split("/") + name = "%s.rst" % (p[len(p) - 1]) + entries.extend(find_scripts_entry(name)) # Indicate the scripts not listed for documentation if len(entries) < len(scripts): common = compare(scripts, entries) logger.warning("automodule entries missing for:\n" + '\n'.join(common)) -# Variables used to define Github extlinks -if "SOURCE_BRANCH" in os.environ and len(os.environ.get('SOURCE_BRANCH')) > 0: - branch = os.environ.get('SOURCE_BRANCH') -else: - branch = 'develop' - -if "SOURCE_USER" in os.environ and len(os.environ.get('SOURCE_USER')) > 0: - user = os.environ.get('SOURCE_USER') -else: - user = 'ome' - -github_root = 'https://github.com/' -omero_github_root = github_root + user + '/openmicroscopy/' -docs_root = 'https://docs.openmicroscopy.org' -downloads_root = 'https://downloads.openmicroscopy.org' - # -- Project information ----------------------------------------------------- +# The master toctree document. +master_doc = 'index' + project = u'omero scripts' -copyright = u'2021, Open Microscopy Environment' +now = datetime.now() author = u'Open Microscopy Environment' +copyright = u'2016-%d, %s ' % (now.year, author) # The full version, including alpha/beta/rc tags # The short X.Y version. version = '5.6.2.dev0' release = version -version_blitz = '5.5.8' - # -- General configuration --------------------------------------------------- -extlinks = { - 'slicedoc_blitz': (docs_root + '/omero-blitz/' + - version_blitz + '/slice2html/%s', ''), - 'source': (omero_github_root + 'blob/' + branch + '/%s', ''), - 'devs_doc': (docs_root + '/contributing/%s', ''), - 'downloads': (downloads_root + '/%s', ''), - 'general_doc': (docs_root + '/omero/latest%s', ''), - } +extlinks = {} # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom @@ -124,6 +100,7 @@ def compare(list1, list2): extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.extlinks', + "sphinx_rtd_theme", ] # Add any paths that contain templates here, relative to this directory. From 8729a0f987250e923ea48121520c809a197ffee4 Mon Sep 17 00:00:00 2001 From: jean-marie burel Date: Mon, 21 Aug 2023 11:29:55 +0100 Subject: [PATCH 4/8] remove sphinx theme --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index ffc4429a0..d5e11ecb5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -100,7 +100,6 @@ def compare(list1, list2): extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.extlinks', - "sphinx_rtd_theme", ] # Add any paths that contain templates here, relative to this directory. From 642be8b791905e6e4ad6e0e3b6fa09b27cdebef6 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Mon, 21 Aug 2023 11:49:58 +0100 Subject: [PATCH 5/8] remove whitespace --- omero/figure_scripts/ROI_Split_Figure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omero/figure_scripts/ROI_Split_Figure.py b/omero/figure_scripts/ROI_Split_Figure.py index 7de770078..681b98a8e 100644 --- a/omero/figure_scripts/ROI_Split_Figure.py +++ b/omero/figure_scripts/ROI_Split_Figure.py @@ -305,7 +305,7 @@ def get_rectangle(roi_service, image_id, roi_label): """ Returns (x, y, width, height, zMin, zMax, tMin, tMax) of the first rectange in the image that has roi_label as text. - + :return: First rectangle. """ From 07e130dda4e9b58de423a0d0c48be8dd40190e6d Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Mon, 21 Aug 2023 12:06:43 +0100 Subject: [PATCH 6/8] add dependencies --- docs/conf.py | 1 + docs/requirements.txt | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 docs/requirements.txt diff --git a/docs/conf.py b/docs/conf.py index d5e11ecb5..1a83b67e3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -100,6 +100,7 @@ def compare(list1, list2): extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.extlinks', + 'sphinx_rtd_theme', ] # Add any paths that contain templates here, relative to this directory. diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 000000000..691e5218e --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,2 @@ +sphinx==5.3.0 +sphinx_rtd_theme==1.1.1 From 523292b5e04ff43ac2360ae66a7f094aab552e96 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Mon, 21 Aug 2023 12:08:56 +0100 Subject: [PATCH 7/8] prepare config --- .readthedocs.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 9d95a25f5..0459a136b 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,9 +1,16 @@ # Required version: 2 +build: + os: "ubuntu-22.04" + tools: + python: "3.11" + # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/conf.py + python: - version: 3.7 + install: + - requirements: docs/requirements.txt From 743084b2a3eade5e5d24d742aaf174a4edceaeeb Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Mon, 21 Aug 2023 12:30:24 +0100 Subject: [PATCH 8/8] remove sphinx job, replace by rtd --- .github/workflows/sphinx.yml | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 .github/workflows/sphinx.yml diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml deleted file mode 100644 index c0aea8aba..000000000 --- a/.github/workflows/sphinx.yml +++ /dev/null @@ -1,34 +0,0 @@ -# Builds the Sphinx documentation in the specified folder. -# Default values are docs/ for the directory where the Sphinx -# documentation is located and true to run linkcheck -# To pass a new folder, set directory_path to the folder path -# Pass the arguments you wish to run, default command is make clean html linkcheck - ---- -name: sphinx - -on: - push: - pull_request: - schedule: - - cron: '0 0 * * 0' - -jobs: - build: - runs-on: ubuntu-latest - env: - directory_path: - sphinx_commands: clean html linkcheck # commands to run. Update accordingly - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - name: Sphinx install - run: pip install --upgrade sphinx - - name: Set directory - run: | - VAR=${{ env.directory_path }} - echo "docs_dir="${VAR:-./docs} >> $GITHUB_ENV - - name: Build doc - run: | - cd $docs_dir - make ${{ env.sphinx_commands }}