@author Donald MacDonald <a href=”mailto:donald@lifesci.dundee.ac.uk“>donald@lifesci.dundee.ac.uk</a> @version 3.0 <small> (<b>Internal version:</b> $Revision: $Date: $) </small> @since 3.0-Beta4.2
Bases: object
Bases: omero.util.OmeroPopo.ShapeData
Bases: omero.util.OmeroPopo.DataObject
Bases: omero.util.OmeroPopo.ShapeData
Bases: omero.util.OmeroPopo.ShapeData
Bases: omero.util.OmeroPopo.DataObject
Bases: omero.util.OmeroPopo.ShapeData
Bases: omero.util.OmeroPopo.DataObject
Bases: omero.util.OmeroPopo.DataObject
Wrap the serverSide shape as the appropriate OmeroPopos @param serverSideShape The shape object to wrap. @return See above.
Convert a list to a Comma Separated Value string. @param list The list to convert. @return See above.
Convert a csv string to a list of strings @param csvString The CSV string to convert. @return See above.
Example code to draw 10 ellipses randomly on an image:
import ROI_utils;
import ROIDrawingUtils;
from random import randint;
l = [];
for i in range(0,10):
e = ROI_utils.EllipseData(
ROI_utils.ROICoordinate(),
randint(100, 300), randint(100, 300),
randint(20, 50), randint(20, 50))
l.append(e);
d = ROIDrawingUtils.DrawingCanvas();
d.createImage(400,400)
v = d.drawElements(l);
d.image.show()
Example code to draw a polyline on an image an display it in PIL:
try:
from PIL import Image, ImageDraw # see ticket:2597
except ImportError:
import Image, ImageDraw # see ticket:2597
import ROI_utils
import ROIDrawingUtils
drawingCanvas = ROIDrawingUtils.DrawingCanvas();
points = [10,30, 40, 80, 100, 150]
polygonData = ROI_utils.PolylineData(ROI_utils.ROICoordinate(), points);
drawingCanvas.createImage(400,400);
drawingCanvas.drawElements([polygonData]);
drawingCanvas.image.show()
Bases: omero.util.ROI_utils.ShapeData, omero.util.ROI_utils.ROIDrawingI
Bases: omero.util.ROI_utils.ShapeData, omero.util.ROI_utils.ROIDrawingI
Bases: omero.util.ROI_utils.ShapeData, omero.util.ROI_utils.ROIDrawingI
Bases: omero.util.ROI_utils.ShapeData, omero.util.ROI_utils.ROIDrawingI
Bases: omero.util.ROI_utils.ShapeData, omero.util.ROI_utils.ROIDrawingI
Bases: omero.util.ROI_utils.ShapeData, omero.util.ROI_utils.ROIDrawingI
Bases: omero.util.ROI_utils.ShapeData, omero.util.ROI_utils.ROIDrawingI
Method for converting the string returned from omero.model.ShapeI.getPoints() into list of (x,y) points. E.g: “points[309,427, 366,503, 190,491] points1[309,427, 366,503, 190,491] points2[309,427, 366,503, 190,491]” or the new format: “309,427 366,503 190,491”
Returns a bounding box (x,y,w,h) that will contain the shape represented by the XY points list
Reconcile and cleanse where necessary an OMERO data directory of orphaned data.
Bases: object
Keeps file cleansing state and performs OMERO database reconciliation of files within an OMERO binary repository.
Begins a cleansing operation from a given OMERO binary repository root directory. /OMERO/Files or /OMERO/Pixels for instance.
Actually performs the reconciliation check against OMERO and removes relevant files.
Takes the final set of deferred paths and performs a reconciliation check against OMERO for them. This method’s purpose is basically to catch the final set of paths in the deferred path list and/or perform any cleanup.
Adds a given path to the list of deferred paths. If the number of deferred paths has reached the QUERY_THRESHOLD (to reduce database hits) a reconciliation check will happen against OMERO.
Default main() that performs OMERO data directory cleansing.
Prints usage so that we don’t have to. :)
Bases: threading._Event
threading.Event extension which provides an additional method setAtExit() which sets “atexit” to true.
This class was introduced in 4.2.1 to work around issue #3260 in which logging from background threads produced error messages.
Bases: threading._Timer
Based on threading._Thread but allows for resetting the Timer.
t = Timer(30.0, f, args=[], kwargs={}) t.start() t.cancel() # stop the timer’s action if it’s still waiting
# or
t.reset()
After excecution, the status of the run can be checked via the “completed” and the “exception” Event instances.
Returns a threading.Event instance which is registered to be “set” (Event.set()) on system exit.
Bases: object
Decorator to measure the execution time of a function. Assumes that a logger global var is available and is the logger instance from logging.getLogger().
@param level: the level to use for logging @param name: the name to use when logging, function name is used if None
Decorator for using the self._lock argument of the calling instance
Decorator for (optionally) printing performance statistics
Decorator for catching any uncaught exception and converting it to an InternalException
For BlitzObjectWrapper class derivate functions, sets the session group to match the object group.
A collection of utility methods used by Figure scripts for producing publication type of figures.
@author William Moore <a href=”mailto:will@lifesci.dundee.ac.uk“>will@lifesci.dundee.ac.uk</a> @author Jean-Marie Burel <a href=”mailto:j.burel@dundee.ac.uk“>j.burel@dundee.ac.uk</a> @author Donald MacDonald <a href=”mailto:donald@lifesci.dundee.ac.uk“>donald@lifesci.dundee.ac.uk</a> @version 3.0 <small> (<b>Internal version:</b> $Revision: $Date: $) </small> @since 3.0-Beta4.1
Adds a scalebar at the bottom right of an image, No text.
@param scalebar length of scalebar in microns @param xIndent indent from the right of the image @param yIndent indent from the bottom of the image @param image the PIL image to add scalebar to @param pixels the pixels object @param colour colour of the overlay as r,g,b tuple
Returns a string formatting of the time (in seconds) according to the chosen timeUnits: “SECS_MILLIS”, “SECS”, “MINS”, “HOURS”, “MINS_SECS”, “HOURS_MINS”, “HOURS_MINS_SECS”, “HOURS_MINS_SECS_MILLIS”
@param seconds: Time in seconds. float or int @param timeUnits: A string denoting the format. One of the choices above. @return: A string, such as “10” or “3:20”
Query returns a map where each key is the imageId and the value is a list of (projectName, datasetName) tuples. If the image does not have a Dataset AND Project, the map will hold an empty list for that imageId.
@param queryService: The Omero query service @param imageIds: A list of image IDs. [long] @return: A map imageId:[(projectName, datasetName)]
Query returns a map of key = imageId, value = [tagNames] for the image
@param metadataService: The Omero metadata service @param imageIds: A list of image IDs. [long] @return: A map of imageId:[tagName]
Returns a list of time labels e.g. “10”, “20” for the first plane at each t-index (C=0 and Z=0). If no planeInfo is available, returns plane number/total e.g “3/10” If time units are not specified, the most suitable units are chosen based on the max time. The list of label returned includes the timeUnits as the last string in the list, in case you didn’t specify it.
@param queryService: The Omero query service @param pixelsId: The ID of the pixels you want info for @param tIndexes: List of t-index to get the times for.
Assumed to be in t order.
@param timeUnits: Format choice, see formatTime(). String @param showRoiDuration: If true, times shown are from the start of
the ROI frames, otherwise use movie timestamp.
@return: A list of strings, ordered same as tIndexes
Get the time in seconds (float) for the first plane (C = 0 & Z = 0) at each time-point for the defined pixels. Returns a map of tIndex: timeInSecs
@param queryService: The Omero queryService @param pixelsId: The ID of the pixels object. long @param tIndexes: List of time indexes. [int] @param theZ: The Z plane index. Default is 0 @param theC: The Channel index. Default is 0 @return: A map of tIndex: timeInSecs
Returns an image with the labels written vertically with the given font, black on white background
A collection of utility methods based on the Python Imaging Library (PIL) used for making figures.
@author William Moore <a href=”mailto:will@lifesci.dundee.ac.uk“>will@lifesci.dundee.ac.uk</a> @author Jean-Marie Burel <a href=”mailto:j.burel@dundee.ac.uk“>j.burel@dundee.ac.uk</a> @author Donald MacDonald <a href=”mailto:donald@lifesci.dundee.ac.uk“>donald@lifesci.dundee.ac.uk</a> @version 3.0 <small> (<b>Internal version:</b> $Revision: $Date: $) </small> @since 3.0-Beta4.1
Returns a tuple of (r,g,b) from an integer colour r, g, b are 0-255.
@param RGB: A colour as integer. Int @return: A tuple of (r,g,b)
Returns a tuple of (r,g,b,a) from an integer colour r, g, b, a are 0-255.
@param RGB: A colour as integer. Int @return: A tuple of (r,g,b,a)
Checks that the value is between 0 and 255. Returns integer value If the value is not valid, return 255 (better to see something than nothing!)
@param value: The value to check. @return: An integer between 0 and 255
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
Returns a thumbnail (as string) from the pixelsId, the longest side is ‘length’
@param thumbnailStore: The Omero thumbnail store @param pixelsId: The ID of the pixels. long @param length: Length of longest side. int @return: The thumbnail as a String,
or None if not found (invalid image)
Returns map of thumbnails whose keys are the pixels id and the values are the image, the longest side is ‘length’
@param thumbnailStore: The Omero thumbnail store @param pixelIds: The collection of pixels ID. @param length: Length of longest side. int @return: See above
Returns the factor by which the Image has to be shrunk so that its dimensions are less that maxW and maxH E.g. If the image must be half-sized, this method returns 2.0 (float)
@param imageSize: Size of the image as tuple (width, height) @param maxW: The max width after zooming @param maxH: The max height after zooming @return: The factor by which to shrink the image to be
within max width and height
Retrieves thumbnails for each pixelId, and places them in a grid, with White background. Option to add a vertical label to the left of the canvas Creates a PIL ‘Image’ which is returned
@param thumbnailStore: The omero thumbnail store. @param length: Length of longest thumbnail side. int @param spacing: The spacing between thumbnails and around the
edges. int
@param pixelIds: List of pixel IDs. [long] @param colCount: The number of columns. int @param bg: Background colour as (r,g,b).
Default is white (255,255,255)
@param leftLabel: Optional string to display vertically to the left. @param textColour: The colour of the text as (r,g,b).
Default is black (0,0,0)
@return: The PIL Image canvas.
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
Resize the image so that it is as big as possible, within the dimensions maxW, maxH
@param image: The PIL Image to zoom @param maxW: The max width of the zoomed image @param maxH: The max height of the zoomed image @return: The zoomed image. PIL Image.
Utility method for calling the equivalent of “bin/omero import -f”. Results are parsed when using as_dictionary.
Copyright 2009 Glencoe Software, Inc. All rights reserved. Use is subject to license terms supplied in LICENSE.txt
Guarantees that a list of strings will be returned. Handles unicode caused by “%s” % path.path.
Run as_stdout, parses the output and returns a dictionary of the form:
{
some_file_in_group :
[
some_file_in_group
some_other_file_in_group
...
last_file_in_group
],
some_file_in_second_group : ...
}
Utilities for manipulating bulk-annotations
Includes classes to help with basic data-munging (TODO), and for formatting data for clients.
Bases: object
Parent class for handling bulk-annotation column configurations
Replace unspecified fields in a column config with defaults
Get the default column configuration, fill in unspecified fields
Check whether a column config section is valid, throws Exception if not
Check whether a column config section is valid after filling all optional fields with defaults
Bases: object
Converts bulk-annotation rows into key-value lists without any transformation
Pass through a table row unchanged :param values: A table rows :return: A row in the form
[(k1, v1), (k2, v2), ...]
Bases: omero.util.metadata_utils.BulkAnnotationConfiguration
Converts bulk-annotation rows into key-value lists
Get the full set of output column configs, taking into account specified column positions and columns included/excluded according to the defaults:
positioned columns are at the specified index (1-based)
gaps between positioned columns are filled with unpositioned columns in order of - Configured but unpositioned columns - Unconfigured columns in order of headers (assuming the default
config is for them to be included)
If there are gaps and no remaing columns to be included raise an exception
Transform a table row :param rowvalues: A table row :return: The transformed rows in the form [(k1, v1), (k2, v2), ...].
v* will be a list of length: - 1 in most cases - 0 if omitempty=True and value was empty - 1+ if split option is enabled
Process a single value corresponding to a single table row-column
Returns: | The key and a list of [value]. In general [values] will be a single item unless split is specified in cfg in which case there may be multiple. |
---|
Populate bulk metadata tables from delimited text files.
Bases: omero.util.populate_metadata._QueryContext
Processor for creating MapAnnotations from BulkAnnotations.
Bases: omero.util.populate_metadata._QueryContext
Processor for deleting MapAnnotations in the BulkAnnotations namespace on these types: Image WellSample Well PlateAcquisition Plate Screen
Bases: object
Header resolver for known header names which is responsible for creating the column set for the OMERO.tables instance.
Bases: exceptions.Exception
Raised by the metadata parsing context when an error condition is reached.
Bases: object
Generic parsing context for CSV files.
If we’re processing a plate but the bulk-annotations file contains a plate column then select rows for this plate only
Bases: object
Instance to denote a row skip request.
Bases: object
Value resolver for column types which is responsible for filling up non-metadata columns with their OMERO data model identifiers.
Bases: object
Helper class container query methods
Run a projection query designed to return scalars only :param q: The query to be projected, should contain either :ids
or :id as a parameter
Param: | ids: Either a list of IDs to be passed as :ids parameter or a single scalar id to be passed as :id parameter in query |
---|---|
Ns: | Optional namespace to be passed as :ns parameter in query |
Prints usage so that we don’t have to. :)
...
Bases: object
Abstract class which aggregates and represents all the results produced from a given measurement run. It also provides a scaffold for interacting with the OmeroTables infrastructure.
Creates a file annotation to represent a set of columns from our measurment.
Returns the name of the measurement, and a set of columns.
Takes a row and a col index and returns a tuple of Well and image. Either might be None. Uses the first image found to find the Well and therefore must be loaded (image->wellSample->well)
Returns the image from which an original file has originated.
Parses result files, returning a MeasurementParsingResult.
Calls parse and populate, updating the OmeroTables instance backing our results and the OMERO database itself.
Parses and populates ROI from column data in the OMERO database.
Populates an OmeroTables instance backing our results and ROI linkages.
Updates a set of ROI for a given batch updating the batches dictionary with the saved IDs.
Updates the OmeroTables instance backing our results.
Bases: object
Abstract class which aggregates and represents all measurement runs made on a given Plate.
alias of DownloadingOriginalFileProvider
Returns the number of recognized measurement runs.
Returns the measurement context for a given index.
Return the number of result files associated with a measurement run.
Concrete implementations are to return True if the class pertinent for the original files associated with the plate.
Bases: object
Provides original file data by downloading it from an OMERO raw file store.
Downloads an original file to a temporary file and returns an open file handle to that temporary file seeked to zero. The caller is responsible for closing the temporary file.
Bases: omero.util.populate_roi.AbstractMeasurementCtx
Flex measurements are located deep within a ”.res” XML file container and contain no ROI.
Retrieves a set of empty OmeroTables columns for the analysis results prefixed by a WellColumn to handle linked object indexes.
Bases: omero.util.populate_roi.AbstractPlateAnalysisCtx
Flex dataset concrete class implementation of an analysis context. Flex measurements are aggregated in a single ”.res” XML file and contain no ROI.
Bases: omero.util.populate_roi.AbstractMeasurementCtx
InCell Analyzer measurements are located deep within an XML file container.
Checks a set of columns for sparse data (one column shorter than the rest) and adds -1 where appropriate.
Bases: omero.util.populate_roi.AbstractPlateAnalysisCtx
InCell dataset concrete class implementation of an analysis context. InCell measurements are from InCell Analyzer and are aggregated in a single gargantuan (often larger than 100MB per plate) XML file.
Bases: omero.util.populate_roi.AbstractMeasurementCtx
MIAS measurements are a set of tab delimited text files per well. Each TSV file’s content is prefixed by the analysis parameters.
Parses out ROI from OmeroTables columns for ‘MNU’ datasets.
Parses out ROI from OmeroTables columns for ‘NEO’ datasets.
Retrieves a set of empty OmeroTables columns for the analysis results prefixed by an ImageColumn and RoiColumn to handle these linked object indexes.
Overriding the abstract implementation since the companion files are no longer attached to the images, but only to the plate for MIAS. Instead, we use the filename itself to find the image.
Query performed:
first_roi = columns[self.ROI_COL].values[0]
first_roi = self.query_service.findByQuery(
'select roi from Roi as roi ' 'join fetch roi.annotationLinks as link ' 'join fetch link.child ' 'where roi.id = %d' % first_roi, None)
self.file_annotation = first_roi.copyAnnotationLinks()[0].child
Bases: omero.util.populate_roi.AbstractPlateAnalysisCtx
MIAS dataset concrete class implementation of an analysis context. MIAS measurements are aggregated based on a single “log” file. A result file is present for each stitched (of multiple fields) mosaic and contains the actual measured results and ROI.
Strips out erroneous files and collects the log and result original files based on regular expression matching.
Result original files are only recognizable as part of a given measurement (declared by a log file) based upon their parsed date/time of completion as encoded in the filename. This method collects result original files and groups them by collective parsed date/time of completion.
Bases: exceptions.Exception
Raised by the analysis or measurement context when an error condition is reached.
Bases: object
Holds the results of a measurement parsing event.
Adds a set of columns to the parsing result.
Bases: object
The plate analysis context factory is responsible for detecting and returning a plate analysis context instance for a given plate.
OMERO5 support. See #12235
Retrieves all the images associated with a given plate. Fetched are the Image’s WellSample, the WellSample’s Well, the annotation stack associated with the Image and each annotation’s linked original file.
Retrieves a plate analysis context for a given plate.
Pool of threads consuming tasks from a queue
Add a task to the queue
Wait for completion of all the tasks in the queue
Bases: threading.Thread
Thread executing tasks from a given tasks queue
Prints usage so that we don’t have to. :)
Utility methods for dealing with scripts.
Convert an RGB value to a PIL colour value. @param RGB the RGB value. @return See above.
Add the annotation to an image. @param updateService The update service to create the annotation link. @param image The ImageI object that should be annotated. @param annotation The annotation object @return The new annotationlink object
Convert the numpy array data to a csv file. @param data the Numpy Array @return The CSV string.
Attach an array, stored as a csv file to an image. Returns the annotation. @param updateService The updateService to create the annotation link. @param image The image to attach the data to. @param filename The name of the file. @param namespace The namespace of the file. @return
Attaches the original file (file) to a Project, Dataset or Image (parent)
@param updateService: The update service @param parent: A ProjectI, DatasetI or ImageI to attach
the file to
@param originalFile: The OriginalFileI to attach @param description: Optional description for the file annotation.
String
@param namespace: Optional namespace for file annotataion. String @return: The saved and returned *AnnotationLinkI
(* = Project, Dataset or Image)
Returns a hash of the file identified by filename
@param filename: pathName of the file @return: The hash of the file
Calculate the Sha1 Hash from a data array @param data The data array. @return The Hash
Creates an original file, saves it to the server and returns the result
@param queryService: The query service E.g. session.getQueryService() @param updateService: The update service E.g. session.getUpdateService() @param filename: The file path and name (or name if in same folder).
String
@param origFilePathName: Optional path/name for the original file @return: The saved OriginalFileI, as returned from the
server
Create a file from the data of type format, setting sha1, .. @param updateService The updateService to create the annotation link. @param filename The name of the file. @param data The data to save. @param format The Format of the file. @return The newly created OriginalFile.
Uploads a local file to the server, as an Original File and attaches it to the parent (Project, Dataset or Image)
@param conn: The omero.gateway.BlitzGateway connection. @param parent: The ProjectI or DatasetI or ImageI to attach
file to
@param mimetype: The original file mimetype. E.g. “PNG”. String @param description: Optional description for the file annotation.
String
@param namespace: Namespace to set for the original file @param @param origFilePathName: The /path/to/file/fileName.ext you want on the
server. If none, use output as name
Creates a new single-channel, single-timepoint image from the list of 2D numpy arrays in plane2Dlist with each numpy 2D plane becoming a Z-section.
@param imageName Name of new image @param description Description for the new image @param dataset If specified, put the image in this dataset.
omero.model.Dataset object
@return The new OMERO image: omero.model.ImageI
Create the plane rendering def, for z,t @param Z the Z-Section @param T The T-Point. @return The RenderingDef Object.
Downloads an OriginalFile from the server.
@param rawFileStore: The Omero rawFileStore @param originalFile: The OriginalFileI @param filePath: Where to download the file.
If None, use originalFile.getName().getValue()
Download the plane [z,c,t] for image pixels. Pixels must have pixelsType loaded. N.B. The rawPixelsStore must have already been initialised by setPixelsId() @param rawPixelsStore The rawPixelStore service to get the image. @param pixels The pixels of the image. @param z The Z-Section to retrieve. @param c The C-Section to retrieve. @param t The T-Section to retrieve. @return The Plane of the image for z, c, t
Draw line on image. @param draw The PIL Draw class. @param x0 The x0-coord of line. @param y0 The y0-coord of line. @param x1 The x1-coord of line. @param y1 The y1-coord of line. @param colour The colour as a PIL colour fill in the line.
Draw test on image. @param draw The PIL Draw class. @param x The x-coord to draw. @param y The y-coord to draw. @param text The text to render. @param colour The colour as a PIL colour string to draw the text in.
Finds the ROI with the given namespace linked to the image. Returns a collection of ROIs. @param roiService The ROI service. @param image The image the ROIs are linked to . @param namespace The namespace of the ROI. @return see above.
Get the objects specified by the script parameters. Assume the parameters contain the keys IDs and Data_Type
@param conn: The omero.gateway.BlitzGateway connection. @param params: The script parameters @return: The valid objects and a log message
Get the rendered Image of the plane for the z, t with the default channels. @param renderingEngine The already instantiated renderEngine. @param z The Z-section. @param t The Timepoint.
Reads a local image (E.g. single plane tiff) and returns it as a numpy 2D array.
@param imagePath Path to image.
Get the plane info for the pixels object returning it in order of z,t,c @param iQuery The query service. @param pixelsId The pixels for Id. @param asOrderedList @return list of planeInfoTimes or map[z:t:c:]
Get the ROI from the server for the image with the namespace @param iROIService The iROIService object @param imageId The imageId to retreive ROI from. @param namespace The namespace of the ROI. @return See above.
Get the rawFileStore for the file with fileId @param fileId The fileId of the object to retrieve. @return The rawFileStore service.
Get the rawPixelsStore for the Image with pixelsId @param pixelsId The pixelsId of the object to retrieve. @return The rawPixelsStore service.
Create the renderingEngine for the pixelsId. @param session The current session to create the renderingEngine from. @return The renderingEngine Service for the pixels.
parse the inputs from the client object and map it to some other form, values may be transformed by function. @param client The client object @param session The current session (deprecated). @param processFn A function to transform data to some other form. @return Parsed inputs as defined by ProcessFn.
Map a range to a string of numbers @param range See above. @return See above.
Read an OriginalFile with id and column separator and return it as an array. @param rawFileService The RawFileService service to read the originalfile. @param iQuery The Query Service. @param fileId The id of the originalFile object. @param row The number of rows in the file. @param col The number of columns in the file. @param sep the column separator. @return The file as an NumPy array.
Read the RawImageFlimFile with fileId and return it as an array [c, x, y] @param rawPixelsStore The rawPixelStore service to get the image. @param pixels The pixels of the image. @return The Contents of the image for z = 0, t = 0, all channels;
Read the OriginalFile with fileId and return it as a string. @param rawFileService The RawFileService service to read the originalfile. @param iQuery The Query Service. @param fileId The id of the originalFile object. @param maxBlockSize The block size of each read. @return The OriginalFile object contents as a string
Register a workflow with the server, if the workflow does not exist create it and returns it, otherwise it returns the already created workflow. @param iQuery The query service. @param iUpdate The update service. @param namespace The namespace of the workflow. @param keywords The keywords associated with the workflow. @return see above.
Simply resests the rendering settings for a pixel set, according to the min and max values The rendering engine does NOT have to be primed with pixelsId, as that is handled by this method.
@param renderingEngine The OMERO rendering engine @param pixelsId The Pixels ID @param minValue Minimum value of rendering window @param maxValue Maximum value of rendering window @param rgba Option to set the colour of the channel.
(r,g,b,a) tuple.
Convert an R,G,B value to an int. @param R the Red value. @param G the Green value. @param B the Blue value. @return See above.
Splits the image into component planes, which are saved as local tiffs according to unformattedImageName. E.g. myLocalDir/tubulin_P037_T%05d_C%s_Z%d_S1.tif which will be formatted according to dims, E.g. (‘T’, ‘C’, ‘Z’) Channel will be formatted according to channel name, not index. @param rawPixelsStore The rawPixelStore @param queryService @param c The C-Section to retrieve. @param t The T-Section to retrieve. @param imageName the local location to save the image.
Convert a list to a Comma Separated Value string. @param list The list to convert. @return See above.
Convert a csv string to a list of strings @param csvString The CSV string to convert. @return See above.
Uploads a local file to the server, as an Original File and attaches it to the parent (Project, Dataset or Image)
@param queryService: The query service @param updateService: The update service @param rawFileStore: The rawFileStore @param parent: The ProjectI or DatasetI or ImageI to attach
file to
@param mimetype: The original file mimetype. E.g. “PNG”. String @param description: Optional description for the file annotation.
String
@param namespace: Namespace to set for the original file @param origFilePathName: The /path/to/file/fileName.ext you want on the
server. If none, use output as name
@return: The originalFileLink child. (FileAnnotationI)
Upload the data to the server, creating the OriginalFile Object and attaching it to the image. @param rawFileStore The rawFileStore used to create the file. @param updateService The updateService to create the annotation link. @param image The image to attach the data to. @param filename The name of the file. @param namespace The name space associated to the annotation. @param data The data to save. @return The newly created file.
Parses a single line of cecog output and saves as a roi.
Adds a Rectangle (particle) to the current OMERO image, at point x, y. Uses the self.image (OMERO image) and self.updateService
Reads all the images in the directory specified by ‘path’ and uploads them to OMERO as a single multi-dimensional image, placed in the specified ‘dataset’ Uses regex to determine the Z, C, T position of each image by name, and therefore determines sizeZ, sizeC, sizeT of the new Image.
@param path the path to the directory containing images. @param dataset the OMERO dataset, if we want to put images somewhere.
omero.model.DatasetI
Uploads an OriginalFile to the server
@param rawFileStore: The Omero rawFileStore @param originalFile: The OriginalFileI @param filePath: Where to find the file to upload.
If None, use originalFile.getName().getValue()
Upload the plane to the server attching it to the current z,c,t of the already instantiated rawPixelStore. @param rawPixelsStore The rawPixelStore which is already pointing
to the data.
@param plane The data to upload @param z The Z-Section of the plane. @param c The C-Section of the plane. @param t The T-Section of the plane.
Upload the plane to the server one row at a time, attching it to the current z,c,t of the already instantiated rawPixelStore. @param rawPixelsStore The rawPixelStore which is already pointing
to the data.
@param plane The data to upload @param z The Z-Section of the plane. @param c The C-Section of the plane. @param t The T-Section of the plane.
Library for managing user sessions.
Bases: object
The store is a file-based repository of user sessions. By default, stores use $HOME/omero/sessions as their repository path.
Use add() to add items to the repository
Stores a file containing the properties at REPO/host/name/id
Simple helper. Delegates to create() using the session as both the username and the password. This reproduces the logic of client.joinSession()
Returns the path to property files which are stored. Internal accounting files are not returned.
Walks through all sessions and calls killSession. Regardless of exceptions, it will remove the session files from the store.
Compares if the passed properties are compatible with with those for the host, name, id tuple
If ignore_nulls is True, then a null in new_props means matches anything.
Returns a map of maps with all the contents of the store. Internal accounting files are skipped.
Returns the sum of all files visited by walk()
Creates a new omero.client object, and returns: (cilent, session_id, timeToIdle, timeToLive)
Checks if the given file exists.
Returns the name of a user for which the session key exists. This value is taken from the path rather than from the properties file since that value may have been overwritten. An exception is raised if there is more than one name since keys should be UUIDs. A None may be returned.
Returns the properties stored in the given session file
Returns the path-object which stores the last active host
Prints either the last saved host (see get_current()) or “localhost”
Prints either the last saved port (see get_current()) or “4064”
Only returns the files (not directories) contained in d that don’t start with a dot
Returns the path-object which stores the last active port
Parses the path-object into properties
Removes the given session file from the store and removes the sess_file() if it is equal to the session we just removed.
Simple dump utility
Returns the path-object which stores the last active session
Sets the current session, user, and host files These are used as defaults by other methods.
Returns the path-object which stores the last active user
Applies func to all host, name, and session path-objects.
OMERO Support for temporary files and directories
Bases: object
Creates temporary files and folders and makes a best effort to remove them on exit (or sooner). Typically only a single instance of this class will exist (“manager” variable in this module below)
Returns True if the current user can write to the given directory
Deletes self.dir
Attempts to delete all directories under self.userdir other than the one owned by this process. If a directory is locked, it is skipped.
Releases self.lock and deletes self.dir. The lock is released first since on some platforms like Windows the lock file cannot be deleted even by the owner of the lock.
If the given directory doesn’t exist, creates it (with mode 0700) and returns True. Otherwise False.
Uses tempfile.mkdtemp and tempfile.mkstemp to create temporary folders and files, respectively, under self.dir
Directory under which all temporary files and folders will be created. An attempt to remove a path not in this directory will lead to an exception.
Returns the directory under which all temporary files and folders will be created.
.lock file under self.dir which is used to prevent other TempFileManager instances (also in other languages) from cleaning up this directory.
Similar to tempfile.mkstemp name but immediately closes the file descriptor returned and passes back just the name. This prevents various Windows issues.
Returns some representation of the current process’s id
If the given path is under self.dir, then it is deleted whether file or folder. Otherwise, an exception is thrown.
Returns a platform-specific user-writable temporary directory
First, the value of “OMERO_TMPDIR” is attempted (if available), then user’s home directory, then the global temp director.
User-accessible directory of the form $TMPDIR/omero_$USERNAME. If the given directory is not writable, an attempt is made to use an alternative
Returns the current OS-user’s name
Uses the global TempFileManager to create a temporary file.
Returns the dir value for the global TempFileManager.
Global TempFileManager instance for use by the current process and registered with the atexit module for cleaning up all created files on exit. Other instances can be created for specialized purposes.
Removes the file from the global TempFileManager. The file will be deleted if it still exists.
Bases: omero.util.text.PlainStyle
Bases: list
Bases: omero.util.text.Style
Bases: omero.util.text.Style
Bases: object
Bases: dict
Bases: object
OMERO-addition to make working with Tables easier
Add a new column and back fill spaces
Similar to col() but only adds unknown columns
Return a column by header name.
Replace a column by header name, it must be the same length.
Replace a header name with a new name.
Set column alignments using alignments string, one char for each column. ‘r’ for right-aligned columns, the default, anything else, is left-aligned. If the argument list in too short it will be padded with the default.
Sort the results on a given column by transposing, sorting and then transposing.
Formats the value like a ‘human-readable’ file size (i.e. 13 KB, 4.1 MB, 102 bytes, etc).
Copied largely from django.template.defaultfilters
Lookup method for well-known styles by name. None may be returned.
List the styles that are known by find_style
Copyright 2011 Glencoe Software, Inc. All rights reserved. Use is subject to license terms supplied in LICENSE.txt
Bases: omero.util.tiles.TileData
Bases: omero.util.tiles.TileLoop
Iterates over every tile in a given Pixels object based on the over arching dimensions and a requested maximum tile width and height. :param tileWidth: <b>Maximum</b> width of the tile requested. The tile request itself will be smaller than the original tile width requested if <code>x + tileWidth > sizeX</code>. :param tileHeight: <b>Maximum</b> height of the tile requested. The tile request itself will be smaller if <code>y + tileHeight > sizeY</code>. :param iteration: Invoker to call for each tile. @return The total number of tiles iterated over.
After saving the binary data, the update event of the {@link Pixels} instance will be updated and therefore need to be reloaded. As a convenience the returned value is accessible here.
Used by RPSTileData to set a reloaded Pixels instance for client use.
Bases: object
“Interface” which must be returned by concrete TileLoop implementations.
Parameters: |
|
---|---|
Returns: | byte[] |
buffer: byte[] :param z: int :param c: int :param t: int :param y: int :param w: int :param h: int
Bases: object
Subclasses must provide a fresh instance of {@link TileData}. The instance will be closed after the run of forEachTile.
Returns: | TileData |
---|
Iterates over every tile in a given Pixels object based on the over arching dimensions and a requested maximum tile width and height. :param sizeX: int :param sizeY: int :param sizeZ: int :param sizeC: int :param sizeT: int :param iteration: Invoker to call for each tile. :param pixel: Pixel instance :param tileWidth: <b>Maximum</b> width of the tile requested. The tile request itself will be smaller than the original tile width requested if <code>x + tileWidth > sizeX</code>. :param tileHeight: <b>Maximum</b> height of the tile requested. The tile request itself will be smaller if <code>y + tileHeight > sizeY</code>. :returns: The total number of tiles iterated over.
Copyright 2009 Glencoe Software, Inc. All rights reserved. Use is subject to license terms supplied in LICENSE.txt
Bases: object
Port of Java UpgradeCheck:
>>> from omero.util.upgrade_check import UpgradeCheck
>>> uc = UpgradeCheck("doctest")
>>> uc.run()
>>> uc.isUpgradeNeeded()
False
>>> uc.isExceptionThrown()
False
>>> uc = UpgradeCheck("doctest", version = "0.0.0")
>>> uc.run()
>>> uc.isUpgradeNeeded()
True
>>> uc.isExceptionThrown()
False
>>>
>>> uc = UpgradeCheck("doctest",
... url = "http://some-completely-unknown-host.abcd/")
>>> uc.run()
>>> uc.isUpgradeNeeded()
False
>>> uc.isExceptionThrown()
True
Bases: object
Centralized logic for declaring and logging a service dependency on a non-shipped library. This is called lazily from the run method of the application to give logging time to be initialized.
See #4566
Get version method which returns a string representing. Should be overwritten by subclasses for packages/modules with no __version__ field.
Simple class for creating an executable environment
Manually adds a value to the environment string
Manually sets a value in the target environment.
Container class for storing resources which should be cleaned up on close and periodically checked. Use stop_event.set() to stop the internal thread.
While stop_event is unset, go through the copy of stuff and call the check method on each entry. Any that throws an exception or returns a False value will be returned in the remove list.
Within a lock, copy the “stuff” list and reverse it. The list is reversed so that entries added later, which may depend on earlier added entries get a chance to be cleaned up first.
Finally, within another lock, call the “cleanup” method on all the entries in remove, and remove them from the official stuff list. (If stop_event is set during execution, we return with the assumption that Resources.cleanup() will take care of them)
Bases: omero.util.SimpleServant
Abstract servant which can be used along with a slice2py generated dispatch class as the base type of high-level servants. These provide resource cleanup as per the omero.util.Server class.
By passing “needs_session = True” to this constructor, an internal session will be created and stored in ServerContext as well as registered with self.resources
Cleanups all resoures created by this servant. Calling cleanup multiple times should be safe.
Bases: Ice.Application
Basic server implementation which can be used for implementing a standalone python server which can be started from icegridnode.
The servant implementation MUST have a constructor which takes a single ServerContext argument AND have a cleanup() method
Logging is configured relative to the current directory to be in var/log by default.
Usage:
if __name__ == "__main__":
app=Server(
ServicesI, "ServicesAdapter", Ice.Identity("Services",""))
sys.exit(app.main(sys.argv))
app.impl now points to an instance of ServicesI
Cleans up all resources that were created by this server. Primarily the one servant instance.
Bases: object
Context passed to all servants.
server_id, communicator, and stop_event will be constructed by the top-level Server instance.
A context instance may also be configured to hold on to an internal session (ServiceFactoryPrx) and keep it alive.
This instance obeys the Resources API and calls sf.keepAlive(None) on every check call, but does nothing on cleanup. The sf instance must be manually cleaned as the final operation of a servant.
(Note: cleanup of the server context indicates server shutdown, so should be infrequent)
Calls getSession() but always returns True. This keeps the context available in the resources for later uses, and tries to re-establish a connection in case Blitz goes down.
Does nothing. Context clean up must happen manually since later activities may want to reuse it. Servants using a server connection should cleanup the instance after Resources is cleaned up
Returns the ServiceFactoryPrx configured for the context if available. If the context was not configured for sessions, an ApiUsageException will be thrown: servants should know whether or not they were configured for sessions. See Servant(..., needs_session = True)
Otherwise, if there is no ServiceFactoryPrx, an attempt will be made to create one if recreate == True. If the value is None or non can be recreated, an InternalException will be thrown.
TODO : currently no arguments are provided for re-creating these, but also not in Servant.__init__
Bases: object
Base servant initialization. Doesn’t create or try to cleanup a top-level Resources thread. This is useful for large numbers of servants. For servers and other singleton-like servants, see “Servant”
Should be overwritten for post-initialization activities. The reason this method exists is that the implementation must be complete before registering it with the adapter.
Bases: object
Since all server components should exclusively using the logging module any output to stdout or stderr is caught and logged at “WARN”. This is useful, especially in the case of Windows, where stdout/stderr is eaten.
Takes an Ice.Properties instance and configures logging
Returns the OMERO user directory
Returns the username. For most purposes, this value will be the same as getpass.getuser on *nix and win32api.GetUserName on Windows, but in some situations (when running without a terminal, etc) getuser may throw a KeyError. In which case, or if the username resolves to False, the default value be returned.
Any unexpected exceptions will be thrown.
See ticket:6307
Try to return a ServiceFactory from the grid.
Try a number of times then give up and raise the last exception returned. This method will only work internally to the grid, i.e. behind the Glacier2 firewall. It is intended for internal servers to be able to create sessions for accessing the database.
communicator := Ice.Communicator used to find the registry
user := Username which should have a session created
group := Group into which the session should be logged
retries := Number of session creation retries before throwing
interval := Seconds between retries
client_uuid := Uuid of the client which should be used
Load a Python class of the form “pkg.mod.Class” via __import__ and return it. No ctor or similar is called.
Converts a long to a path such that for all directiories only a 1000 files and a 1000 subdirectories will be returned.
This method duplicates the logic in ome.io.nio.AbstractFileSystemService.java:getPath()
Generates a logname from the given instance using the module and name from its class
Does what “tail -10 filename” would have done Parameters:
filename file to read linesback Number of lines to read from end of file returnlist Return a list containing the lines instead of a string