Export scripts

Batch Image Export

This script takes a number of images and saves individual image planes in a zip file for download.

Batch_Image_Export.compress(target, base)

Creates a ZIP recursively from a given base directory.

Parameters
  • target – Name of the zip file we want to write e.g. “folder.zip”

  • base – Name of folder that we want to zip up E.g. “folder”

Batch_Image_Export.log(text)

Adds the text to a list of logs. Compiled into text file at the end.

Batch_Image_Export.make_image_name(original_name, c_name, z_range, t, extension, folder_name)

Produces the name for the saved image. E.g. imported/myImage.dv -> myImage_DAPI_z13_t01.png

Batch_Image_Export.run_script()

The main entry point of the script, as called by the client via the scripting service, passing the required parameters.

Batch_Image_Export.save_as_ome_tiff(conn, image, folder_name=None)

Saves the image as an ome.tif in the specified folder

Batch_Image_Export.save_plane(image, format, c_name, z_range, project_z, t=0, channel=None, greyscale=False, zoom_percent=None, folder_name=None)

Renders and saves an image to disk.

Parameters
  • image – The image to render

  • format – The format to save as

  • c_name – The name to use

  • z_range – Tuple of (zIndex,) OR (zStart, zStop) for projection

  • t – T index

  • channel – Active channel index. If None, use current rendering settings

  • greyscale – If true, all visible channels will begreyscale

  • zoom_percent – Resize image by this percent if specified

  • folder_name – Indicate where to save the plane

Batch_Image_Export.save_planes_for_image(conn, image, size_c, split_cs, merged_cs, channel_names=None, z_range=None, t_range=None, greyscale=False, zoom_percent=None, project_z=False, format='PNG', folder_name=None)

Saves all the required planes for a single image, either as individual planes or projection.

Parameters
  • renderingEngine – Rendering Engine, NOT initialised.

  • queryService – OMERO query service

  • imageId – Image ID

  • zRange – Tuple: (zStart, zStop). If None, use default Zindex

  • tRange – Tuple: (tStart, tStop). If None, use default Tindex

  • greyscale – If true, all visible channels will be greyscale

  • zoomPercent – Resize image by this percent if specified.

  • projectZ – If true, project over Z range.

Batch ROI Export

This script exports ROI intensities for selected images.

Batch_ROI_Export.add_shape_coords(shape, row_data, pixel_size_x, pixel_size_y, include_points=True)

Add shape coordinates and length or area to the row_data dict.

Batch_ROI_Export.batch_roi_export(conn, script_params)

Main entry point. Get images, process them and return result.

Batch_ROI_Export.get_export_data(conn, script_params, image, units=None)

Get pixel data for shapes on image and returns list of dicts.

Batch_ROI_Export.is_big_image(image)

Return True if image is tiled.

Link the File Annotation to each object.

Batch_ROI_Export.log(data)

Handle logging or printing in one place.

Batch_ROI_Export.run_script()

The main entry point of the script, as called by the client.

Make Movie

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.

Make_Movie.add_plane_info(z, t, pixels, image, colour)

Displays the plane information.

Make_Movie.add_scalebar(scalebar, image, pixels, command_args)

Adds the scalebar.

Make_Movie.add_time_points(time, pixels, image, colour)

Displays the time-points as hrs:mins:secs

Make_Movie.build_avi(size_x, size_y, filelist, fps, movie_name, format)

Encodes.

Make_Movie.build_plane_map_from_ranges(z_range, t_range)

Determines the plane to load.

Make_Movie.calculate_acquisition_time(conn, pixels_id, c_list, tz_list)

Loads the plane information.

Make_Movie.calculate_ranges(size_z, size_t, command_args)

Determines the plane to load.

Make_Movie.download_plane(gateway, pixels, pixels_id, x, y, z, c, t)

Retrieves the selected plane

Make_Movie.get_plane(rendering_engine, z, t)

Retrieves the specified XY-plane.

Make_Movie.get_rendering_engine(conn, pixels_id, size_c, c_range)

Initializes the rendering engine for the specified pixels set.

Make_Movie.in_range(low, high, max)

Determines if the passed values are in the range.

Make_Movie.log(text)

Adds lines of text to the log_lines list, so they can be collected into a figure legend.

Make_Movie.mac_osx()

Identifies if the Operating System is Mac or not.

Make_Movie.paste_watermark(image, watermark)

Paste the watermark onto the bottom left corner of the image. Return image

Make_Movie.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

Returns

PIL Image to use as watermark.

Make_Movie.reshape_to_fit(image, size_x, size_y, bg=(0, 0, 0))

Make the PIL image fit the sizeX and sizeY dimensions by scaling as necessary and then padding with background. Used for watermark and intro & outro slides.

Make_Movie.run_script()

The main entry point of the script. Gets the parameters from the scripting service, makes the figure and returns the output to the client.

def __init__(self, name, optional = False, out = False, description =

None, type = None, min = None, max = None, values = None)

Make_Movie.upload_plane(gateway, new_pixels_id, x, y, z, c, t, new_plane)

Uploads the specified plane.

Make_Movie.valid_channels(set, size_c)

Determines if the channels are valid

Make_Movie.valid_colour_range(colour)

Checks if the passed value is valid.

Make_Movie.write_intro_end_slides(conn, command_args, orig_file_id, duration, size_x, size_y)

Uses an original file (jpeg or png) to add frames to the movie. Scales and pads to fit size_x, size_y.

Parameters
  • orig_file_id – Original File (png or jpeg) ID

  • duration – Duration of intro / end (secs)

  • size_x – Width of the exported movie

  • size_y – Height of the exported movie

Returns

List of file names to add to mencoder list

Make_Movie.write_movie(command_args, conn)

Makes the movie.

Returns

Returns the file annotation