return a dict with all there is to know about a channel
@param channel: L{omero.gateway.ChannelWrapper} @return: Dict
Helper for marshalling a Chgrp response. Uses conn to lookup unlinked objects. Returns dict of e.g. {‘includedObjects’: {‘Datasets’:[1,2,3]},
‘unlinkedDetails’: {‘Tags’:[{‘id’:1, ‘name’:’t’}]} }
return a dict with pretty much everything we know and care about an image, all wrapped in a pretty structure.
@param image: L{omero.gateway.ImageWrapper} @param key: key of specific attributes to select @return: Dict
converts a bin int number into css colour and alpha fraction. E.g. -1006567680 to ‘#00ff00’, 0.5
converts a bin int number into (r, g, b, alpha) tuple. E.g. 1694433280 to (255, 0, 0, 0.390625)
return a dict with all there is to know about a shape
@param channel: L{omero.model.ShapeI} @return: Dict
Method for converting the string returned from omero.model.ShapeI.getPoints() into an SVG for display on web. E.g: “points[309,427, 366,503, 190,491] points1[309,427, 366,503, 190,491]
points2[309,427, 366,503, 190,491]”
To: M 309 427 L 366 503 L 190 491 z
Module to encapsulate operations concerned with displaying the contents of a plate as a grid.
Retrieve annotations for object specified by object type and identifier, optionally traversing object model graph.
This url will download the Original Image File(s) archived at import time. If it’s a single file, this will be downloaded directly. For multiple files, they are assembled into a zip file on the fly, and this is downloaded.
Copy the rendering settings from one image to a list of images, specified in request by ‘fromid’ and list of ‘toids’. See L{views.copy_image_rdef_json}
json method: returns details of specified Dataset. See L{views.datasetDetail_json}. Returns E.g {“description”: “”, “type”: “Dataset”, “id”: 901, “name”: “example”}
- webgateway/dataset/<did>/detail params are:
- did: Dataset ID
Returns html page displaying full image viewer and image details, rendering settings etc. See L{views.full_viewer}.
- webgateway/img_detail/<iid>/ params are:
- iid: Image ID.
Gets rendering definition from the ‘session’ if saved. Returns json dict of ‘c’, ‘m’, ‘z’, ‘t’.
gets all the ROIs for an Image as json. Image-ID is request: imageId=123 [{‘id’:123, ‘shapes’:[{‘type’:’Rectangle’, ‘theZ’:5, ‘theT’:0, ‘x’:250,
‘y’:100, ‘width’:10 ‘height’:45} ]
gets a Shape as json. ROI-ID, Shape-ID is request: roiId=123 and shapeId=123 {‘type’:’Rectangle’, ‘theZ’:5, ‘theT’:0, ‘x’:250, ‘y’:100, ‘width’:10, ‘height’:45}
json method: returns details of specified Image. See L{views.imageData_json}. Returns E.g {“description”: “”, “type”: “Dataset”, “id”: 901, “name”: “example”}
webgateway/imgData/<iid>/<key> params are:
did: Dataset ID
- key: Optional key of selected attributes to return. E.g. meta,
pixel_range, rdefs, split_channel, size etc
json method: returns list of Datasets belonging to specified Project. See L{views.listDatasets_json}. Returns E.g list of {“child_count”: 4, “description”: “”, “type”: “Dataset”, “id”: 901,
“name”: “example”}
- webgateway/proj/<pid>/children params are:
- pid: Project ID
json method: returning list of all projects available to current user. See L{views.listProjects_json} . List of E.g. {“description”: “”, “id”: 651, “name”: “spim”}
json method: returns list of IDs for images that have channels compatible with the specified image, such that rendering settings can be copied from the image to those returned. Images are selected from the same project that the specified image is in.
- webgateway/compatImgRDef/<iid>/ params are:
- iid: Image ID.
Query bulk annotations table attached to an object specified by object type and identifier, optionally traversing object model graph.
Get a json dict of original file paths. ‘repo’ is a list of path/name strings for original files in managed repo ‘client’ is a list of paths for original files on the client when imported
json method: returns details of specified Project. See L{views.projectDetail_json}. Returns E.g {“description”: “”, “type”: “Project”, “id”: 651, “name”: “spim”}
- webgateway/proj/<pid>/detail params are:
- pid: Project ID
Returns a bird’s eye view JPEG of the OMERO Image. See L{views.render_birds_eye_view}. Uses current rendering settings. Params in render_birds_eye_view/<iid>/ are:
iid: Image ID
- size: Maximum size of the longest side of the resulting bird’s eye
view.
Returns a gif graph of pixel values for a column of an image plane. See L{views.render_col_plot}. Channels can be turned on/off using request. E.g. c=-1,2,-3,-4 Params in render_col_plot/<iid>/<z>/<t>/<x>/<w> are:
- iid: Image ID
- z: Z index
- t: T index
- x: X position of pixel column
- w: Optional line width of plot
Returns a jpeg of the OMERO image. See L{views.render_image}. Rendering settings can be specified in the request parameters. See L{views.getImgDetailsFromReq} for details. Params in render_image/<iid>/<z>/<t>/ are:
- iid: Image ID
- z: Z index
- t: T index
Returns a jpeg of the OMERO image, rendering only a region specified in query string as region=x,y,width,height. E.g. region=0,512,256,256 See L{views.render_image_region}. Rendering settings can be specified in the request parameters. Params in render_image/<iid>/<z>/<t>/ are:
- iid: Image ID
- z: Z index
- t: T index
Generates a movie file from the image, spanning Z or T frames. See L{views.render_movie} Returns the file or redirects to temp file location. Params in render_movie/<iid>/<axis>/<pos> are:
- iid: Image ID
- axis: ‘z’ or ‘t’ dimension that movie plays
- pos: The T index (for ‘z’ movie) or Z index (for ‘t’ movie)
Generates an OME-TIFF of an Image (or zip for multiple OME-TIFFs) and returns the file or redirects to a temp file location. See L{views.render_ome_tiff} Params in render_ome_tiff/<ctx>/<cid> are:
- ctx: The container context. ‘p’ for Project, ‘d’ for Dataset or ‘i’
Returns a thumbnail jpeg of the OMERO ROI. See L{views.render_roi_thumbnail}. Uses current rendering settings.
Returns a gif graph of pixel values for a row of an image plane. See L{views.render_row_plot}. Channels can be turned on/off using request. E.g. c=-1,2,-3,-4 Params in render_row_plot/<iid>/<z>/<t>/<y>/<w> are:
- iid: Image ID
- z: Z index
- t: T index
- y: Y position of pixel row
- w: Optional line width of plot
Returns a mask for the specified shape
Returns a thumbnail jpeg of the OMERO Shape. See L{views.render_shape_thumbnail}. Uses current rendering settings.
Returns a jpeg of OMERO Image with channels split into different panes in a grid. See L{views.render_split_channel}. Rendering settings can be specified in the request parameters (as above). Params in render_split_channel/<iid>/<z>/<t> are:
- iid: Image ID
- z: Z index
- t: T index
Returns a thumbnail jpeg of the OMERO Image, optionally scaled to max-width and max-height. See L{views.render_thumbnail}. Uses current rendering settings. Query string can be used to specify Z or T section. E.g. ?z=10. Params in render_thumbnail/<iid>/<w>/<h> are:
- iid: Image ID
- w: Optional max width
- h: Optional max height
Apply the owner’s rendering settings to the specified objects. Objects defined in request by E.g. totype=dataset&toids=1&toids=2
Reset the images within specified objects to their rendering settings at import time” Objects defined in request by E.g. totype=dataset&toids=1&toids=2
Saves rendering definition (from request parameters) on the image. See L{views.save_image_rdef_json}. For rendering parameters, see L{views.getImgDetailsFromReq} for details. Returns ‘true’ if worked OK.
- webgateway/saveImgRDef/<iid>/ params are:
- iid: Image ID.
Query a table specified by fileid
Returns a main prefix
json method: returns list of Images belonging to specified Dataset. See L{views.listImages_json}. Returns E.g list of {“description”: “”, “author”: “Will Moore”, “date”: 1291325060.0,
“thumb_url”: “/webgateway/render_thumbnail/4701/”, “type”: “Image”, “id”: 4701, “name”: “spim.png”}
webgateway/dataset/<did>/children params are: - did: Dataset ID
request variables: - thumbUrlPrefix: view key whose reverse url is to be used as prefix for
thumb_url instead of default webgateway.views.render_thumbnail
- tiled: if set with anything other than an empty string will add
information on whether each image is tiled on this server
json method: returns list of Images belonging to specified Well. See L{views.listWellImages_json}. Returns E.g list of {“description”: “”, “author”: “Will Moore”, “date”: 1291325060.0,
“thumb_url”: “/webgateway/render_thumbnail/4701/”, “type”: “Image”, “id”: 4701, “name”: “spim.png”}
- webgateway/well/<did>/children params are:
- did: Well ID
json method: returns search results. All parameters in request. See L{views.search_json}
Admin method to switch to the specified user, identified by username: <user> Returns ‘true’ if switch went OK.
Util function to download original files from a list of images and arrange them within a temp file, such that there are no name clashes and multi-image filesets are kept distict. Handles archived files from OMERO 4 images and fileset files for OMERO 5 images.
@param images: Images as source of original files. @type List of ImageWrappers @param temp: Directory for creating Zip file @param zipName: Name of zip
Bases: object
Represents the current user of the connection, with methods delegating to the connection itself.
True if the current user can be admin
@return: True if the current user can be admin @rtype: Boolean
Returns the first name of the current user
@return: First Name @rtype: String
Returns the ID of the current user
@return: User ID @rtype: Long
Returns the Name of the current user
@return: User Name @rtype: String
True if the current user is an admin
@return: True if the current user is an admin @rtype: Boolean
Sets the loggedIn Flag to True
Retrieve annotations for object specified by object type and identifier, optionally traversing object model graph. Returns dictionary containing annotations in NSBULKANNOTATIONS namespace if successful, otherwise returns error information. If the graph has multiple parents, we return annotations from all parents.
@param request: http request. @param objtype: Type of target object, or type of target object
followed by a slash-separated list of properties to resolve
@param conn: L{omero.gateway.BlitzGateway} @param **kwargs: unused @return: A dictionary with key ‘error’ with an error message or
with key ‘data’ containing an array of dictionaries with keys ‘id’ and ‘file’ of the retrieved annotations
Fetches the Image object for image ‘iid’ and prepares it according to the request query, setting the channels, rendering model and projection arguments. The compression level is parsed and returned too. For parameters in request, see L{getImgDetailsFromReq}
@param request: http request @param iid: Image ID @param conn: L{omero.gateway.BlitzGateway} connection @param saveDefs: Try to save the rendering settings, default z and t. @param retry: Try an extra attempt at this method @return: Tuple (L{omero.gateway.ImageWrapper} image, quality)
returns a string that identifies this image, along with the settings passed on the request. Useful for using as img identifier key, for prepared image.
@param request: http request @return: String
Splits the request query channel information for images into a sequence of channels, window ranges and channel colors.
@type rchannels: String @return: E.g. [1, -2, 3] [[100.0, 505.0], (None, None), [620.0,
3879.0]] [u‘0000FF’, None, u’FF0000’]
@rtype: tuple of 3 lists
Query a table specified by fileid Returns a dictionary with query result if successful, error information otherwise
@param fileid: Numeric identifier of file containing the table @param conn: L{omero.gateway.BlitzGateway} @param **kwargs: unused @return: A dictionary with key ‘error’ with an error message
or with key ‘data’ containing a dictionary with keys ‘columns’ (an array of column names) and ‘rows’ (an array of rows, each an array of values)
Downloads the archived file(s) as a single file or as a zip (if more than one file)
Decorator for adding debugging functionality to methods.
@param f: The function to wrap @return: The wrapped function
Downloads the image as a single jpeg/png/tiff or as a zip (if more than one image)
This view is responsible for showing the omero_image template Image rendering options in request are used in the display page. See L{getImgDetailsFromReq}.
@param request: http request. @param iid: Image ID @param conn: L{omero.gateway.BlitzGateway} @param **kwargs: Can be used to specify the html ‘template’ for
rendering
@return: html page of image and metadata
Break the GET information from the request object into details on how to render the image. The following keys are recognized: z - Z axis position t - T axis position q - Quality set (0,0..1,0) m - Model (g for greyscale, c for color) p - Projection (see blitz_gateway.ImageWrapper.PROJECTIONS for keys) x - X position (for now based on top/left offset on the browser window) y - Y position (same as above) c - a comma separated list of channels to be rendered (start index 1)
- format for each entry [-]ID[|wndst:wndend][#HEXCOLOR][,...]
zm - the zoom setting (as a percentual value)
@param request: http request with keys above @param as_string: If True, return a string representation of the
rendering details
@rtype: Dict or String
Render a region around the specified Shape, scale to width and height (or default size) and draw the shape on to the region. Returns jpeg data.
@param image: ImageWrapper @param s: omero.model.Shape
/webgateway/ index placeholder
Decorator for adding connection debugging and returning function result as json, depending on values in kwargs
@param f: The function to wrap @return: The wrapped function, which will return json
Lists the images on the same project that would be viable targets for copying rendering settings. TODO: change method to: list_compatible_imgs_json (request, iid, server_id=None, conn=None, **kwargs):
@param request: http request @param iid: Image ID @param conn: L{omero.gateway.BlitzGateway} @return: json list of image IDs
Returns an HttpResponse wrapped jpeg with the rendered bird’s eye view for image ‘iid’. We now use a thumbnail for performance. #10626
@param request: http request @param iid: Image ID @param conn: L{omero.gateway.BlitzGateway} connection @param size: Maximum size of the longest side of the resulting
bird’s eye view.
@return: http response containing jpeg
Renders the image with id {{iid}} at {{z}} and {{t}} as jpeg. Many options are available from the request dict. See L{getImgDetailsFromReq} for list. I am assuming a single Pixels object on image with image-Id=’iid’. May be wrong
@param request: http request @param iid: image ID @param z: Z index @param t: T index @param conn: L{omero.gateway.BlitzGateway} connection @return: http response wrapping jpeg
Returns a jpeg of the OMERO image, rendering only a region specified in query string as region=x,y,width,height. E.g. region=0,512,256,256 Rendering settings can be specified in the request parameters.
@param request: http request @param iid: image ID @param z: Z index @param t: T index @param conn: L{omero.gateway.BlitzGateway} connection @return: http response wrapping jpeg
Renders a movie from the image with id iid
@param request: http request @param iid: Image ID @param axis: Movie frames are along ‘z’ or ‘t’ dimension. String @param pos: The T index (for z axis) or Z index (for t axis) @param conn: L{omero.gateway.BlitzGateway} connection @return: http response wrapping the file, or redirect to temp
file
Renders the OME-TIFF representation of the image(s) with id cid in ctx (i)mage, (d)ataset, or (p)roject. For multiple images export, images that require pixels pyramid (big images) will be silently skipped. If exporting a single big image or if all images in a multple image export are big, a 404 will be triggered. A request parameter dryrun can be passed to return the count of images that would actually be exported.
@param request: http request @param ctx: ‘p’ or ‘d’ or ‘i’ @param cid: Project, Dataset or Image ID @param conn: L{omero.gateway.BlitzGateway} connection @return: http response wrapping the tiff (or zip for multiple
files), or redirect to temp file/zip if dryrun is True, returns count of images that would be exported
For the given ROI, choose the shape to render (first time-point, mid z-section) then render a region around that shape, scale to width and height (or default size) and draw the shape on to the region
Returns mask as a png (supports transparency)
For the given Shape, redner a region around that shape, scale to width and height (or default size) and draw the shape on to the region.
Renders a split channel view of the image with id {{iid}} at {{z}} and {{t}} as jpeg. Many options are available from the request dict. Requires Pillow to be installed on the server.
@param request: http request @param iid: Image ID @param z: Z index @param t: T index @param conn: L{omero.gateway.BlitzGateway} connection @return: http response wrapping a jpeg
Returns an HttpResponse wrapped jpeg with the rendered thumbnail for image ‘iid’
@param request: http request @param iid: Image ID @param w: Thumbnail max width. 64 by default @param h: Thumbnail max height @return: http response containing jpeg
Requests that the rendering defs passed in the request be set as the default for this image. Rendering defs in request listed at L{getImgDetailsFromReq} TODO: jsonp
@param request: http request @param iid: Image ID @param conn: L{omero.gateway.BlitzGateway} @return: http response ‘true’ or ‘false’
Returns a dict of options for searching, based on parameters in the http request Request keys include:
- ctx: (http request) ‘imgs’ to search only images
- text: (http request) the actual text phrase
- start: starting index (0 based) for result
- limit: nr of results to retuen (0 == unlimited)
- author:
- grabData:
- parents:
@param request: http request @return: Dict of options
Bases: file
Class extends file to facilitate creation and deletion of lock file.
tries to delete the lock file and close the file
Bases: object
Caching base class - extended by L{FileCache} for file-based caching. Methods of this base class return None or False providing a no-caching implementation if needed
Bases: omeroweb.webgateway.webgateway_cache.CacheBase
Implements file-based caching within the directory specified in constructor.
Verifies if a specific cache entry (provided as absolute file path) is expired. If expired, it gets deleted and method returns false. If not expired, returns True.
If fname is a file object, fpos will advance size_of_double bytes.
@param fname: File path or file object @rtype Boolean @return True if entry is valid, False if expired
Creates a directory for the root dir of the cache.
Tries to delete the data at the specified absolute file path
@param fname: File name of data to delete
Disk Usage count on the filesystem the cache is based at
@rtype: int @return: the current usage, in KB
Checks whether the cache is full, either because we have exceeded max number of entries or the cache space is full.
@return: True if cache is full @rtype: Boolean
Returns the number of files in the cache @rtype: int
Uses the key to construct an absolute path to the cache data. @param key: Cache key @return: Path @rtype: String
Returns the number of files in the cache @rtype: int
Iterate the whole cache structure searching and cleaning expired entries. this method may be expensive, so only call it when really necessary.
Adds data to cache, returning False if already cached. Otherwise delegating to L{set}
@param key: Unique key for cache @param value: Value to cache - must be String @param timeout: Optional timeout - otherwise use default @param invalidateGroup: Not used?
Attempt to delete the cache data referenced by key @param key: Cache key
Gets data from cache
@param key: cache key @param default: default value to return @return: cache data or default if timout has passed
Returns true if the cache has the specified key @param key: Key to look for. @rtype: Boolean
Adds data to cache, overwriting if already cached.
@param key: Unique key for cache @param value: Value to cache - must be String @param timeout: Optional timeout - otherwise use default @param invalidateGroup: Not used?
Deletes everything in the cache
Bases: object
Caching class for webgateway.
Calls cache.delete(key)
Calls cache.set(key, obj)
Returns a key for caching the Image, based on parameters above, including rendering settings specified in the http request.
@param client_base: server_id for cache key @param img: L{omero.gateway.ImageWrapper} for ID @param obj: Data to cache @param size: Size used for cache key. Tuple
Creates a cache key for storing json data based on params above.
@param r: http request - not used @param client_base: server_id @param obj: ObjectWrapper @param ctx: Additional string for cache key @return: Cache key @rtype: String
Generates a string key for caching the thumbnail, based on the above parameters
@param r: not used @param client_base: server-id, forms stem of the key @param user_id: OMERO user ID to partition caching upon @param iid: image ID @param size: size of the thumbnail - tuple. E.g. (100,)
Updates the timeout, max_entries and max_size (if specified) for the given cache
@param cache: Cache or caches to update. @type cache: L{CacheBase} or list of caches
Clears all the caches.
Clears data from the json cache using ‘contents’ as context
@param r: http request - not used @param client_base: server_id for cache key @param ds: ObjectWrapper for cache key @rtype: True
Clears image data from cache using default rendering settings (r=None) T and Z indexes ( = 0). TODO: Doesn’t clear any data stored WITH r, t, or z specified in cache key? Also clears thumbnail (but not thumbs with size specified) and json data for this image.
@param r: http request for cache key @param client_base: server_id for cache key @param user_id: OMERO user ID to partition caching upon @param img: ImageWrapper for cache key @param obj: Data to cache @param rtype: True
TODO: document WAS: Only handles Dataset obj, calling L{clearDatasetContents}
Clears thumbnail from cache.
@param r: for cache key - Not used? @param client_base: server_id for cache key @param user_id: OMERO user ID to partition caching upon @param iid: image ID for cache key @param size: Size used for cache key. Tuple @return: True
handle events coming our way from blitz.onEventLogs.
Because all processes will be listening to the same events, we use a simple file lock mechanism to make sure the first process to get the event will be the one handling things from then on.
@param client_base: TODO: docs! @param events:
Gets data from the json cache using ‘contents’ as context
@param r: http request - not used @param client_base: server_id for cache key @param ds: ObjectWrapper for cache key @rtype: String or None
Gets image data from cache.
@param r: http request for cache key @param client_base: server_id for cache key @param img: ImageWrapper for cache key @param z: Z index for cache key @param t: T index for cache key @param ctx: Additional string for cache key @return: Image data @rtype: String
Gets data from the json cache
@param r: http request - not used @param client_base: server_id for cache key @param obj: ObjectWrapper for cache key @param ctx: context string used for cache key @rtype: String or None
Calls L{getImage} with ‘-ometiff’ context @rtype: String
Calls L{getImage} with ‘-sc’ context @rtype: String
Gets thumbnail from cache.
@param r: for cache key - Not used? @param client_base: server_id for cache key @param user_id: OMERO user ID to partition caching upon @param iid: image ID for cache key @param size: Size used for cache key. Tuple @return: Cached data or None @rtype: String
Handle one event from blitz.onEventLogs.
Meant to be overridden, this implementation just logs.
@param client_base: TODO: docs! @param e:
Invalidates all caches for this particular object
@param client_base: The server_id @param user_id: OMERO user ID to partition caching upon @param obj: The object wrapper. E.g.
L{omero.gateway.ImageWrapper}
Adds data to the json cache using ‘contents’ as context
@param r: http request - not used @param client_base: server_id for cache key @param ds: ObjectWrapper for cache key @param data: Data to cache @rtype: True
Puts image data into cache.
@param r: http request for cache key @param client_base: server_id for cache key @param img: ImageWrapper for cache key @param z: Z index for cache key @param t: T index for cache key @param obj: Data to cache @param ctx: Additional string for cache key
Adds data to the json cache
@param r: http request - not used @param client_base: server_id for cache key @param obj: ObjectWrapper for cache key @param data: Data to cache @param ctx: context string used for cache key @rtype: True
Calls L{setImage} with ‘-ometiff’ context
Calls L{setImage} with ‘-sc’ context
Puts thumbnail into cache.
@param r: for cache key - Not used? @param client_base: server_id for cache key @param user_id: OMERO user ID to partition caching upon @param iid: image ID for cache key @param obj: Data to cache @param size: Size used for cache key. Tuple
simple lock mechanisn to avoid multiple processes on the same cache to step on each other’s toes.
@rtype: boolean @return: True if we created a lockfile or already had it. False
otherwise.
Bases: object
Class for handling creation of temporary files
Tries to delete all the temp files that have expired their cache timeout.
Tries to create the directories required for the temp file base dir
Creates a new directory if needed, see L{newdir} and checks whether this contains a file ‘name’. If not, a file lock is created for this location and returned.
@param name: Name of file we want to create. @param key: The new dir name @return: Tuple of (abs path to new directory, relative path
key/name, L{AutoFileLock} or True if exists)
Creates a new directory using key as the dir name, and adds a timestamp file with its creation time. If key is not specified, use a unique key based on timestamp.
@param key: The new dir name @return: Tuple of (path to new directory, key used)