def run_as_script(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring('Image')] fileTypes = [k for k in FILE_TYPES.iterkeys()] client = scripts.client('Nearest_Neighbours_In_ROIs.py', """This script calculates near neighbour distances for each localisation in an OMERO ROI. Do not use `Convert coordinates to nm` option on Zeiss data.""", scripts.String("Data_Type", optional=False, grouping="01", description="Choose source of images (only Image supported)", values=dataTypes, default="Image"), scripts.Int("ImageID", optional=False, grouping="02", description="ID of super resolved image to process"), scripts.Int("AnnotationID", optional=False, grouping="03", description="ID of file to process"), scripts.String("File_Type", optional=False, grouping="04", description="Indicate the type of data being processed", values=fileTypes, default="zeiss2D"), scripts.Bool("Convert_coordinates_to_nm", optional=False, grouping="05", description="Convert to nm - DO NOT USE WITH ZEISS DATA", default=False), scripts.Int("Parent_Image_Pixel_Size", grouping="05.1", description="Convert the localisation coordinates to nm (multiply by parent image pixel size)"), authors = ["Daniel Matthews", "QBI"], institutions = ["University of Queensland"], contact = "*****@*****.**", ) try: # process the list of args above. scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) # process images in Datasets message = run_processing(conn, scriptParams) client.setOutput("Message", rstring(message)) #client.setOutput("Message", rstring("No plates created. See 'Error' or 'Info' for details")) finally: client.closeSession()
def run_script(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ data_types = [rstring('Image')] sum_avg_options = [rstring('Average'), rstring('Sum'), rstring('Average, with raw data')] client = scripts.client( 'Plot_Profile.py', """This script processes Images, which have Line or PolyLine ROIs \ and outputs the data as CSV files, for plotting in e.g. Excel.""", scripts.String( "Data_Type", optional=False, grouping="1", description="Choose source of images (only Image supported).", values=data_types, default="Image"), scripts.List( "IDs", optional=False, grouping="2", description="List of Image IDs to process.").ofType(rlong(0)), scripts.Int( "Line_Width", optional=False, grouping="3", default=1, description="Width in pixels of each line plot.", min=1), scripts.String( "Sum_or_Average", optional=False, grouping="3.1", description="Output the Sum or Average (mean) of Line Profile." " Option to include ALL line data with Average.", default='Average', values=sum_avg_options), scripts.List( "Channels", grouping="4", description="Optional list of Channels to process e.g. 1, 2. Use" " ALL Channels by default.").ofType(omero.rtypes.rint(0)), version="4.3.3", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: script_params = client.getInputs(unwrap=True) # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) file_anns, message = process_images(conn, script_params) if file_anns: if len(file_anns) == 1: client.setOutput("Line_Data", robject(file_anns[0]._obj)) client.setOutput("Message", rstring(message)) finally: client.closeSession()
def runScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring('Image')] axes = [rstring('Y'), rstring('X')] client = scripts.client('ImageJ_Processing.py', """ Does ImageJ 'Rotation Projection' macro processing, creating a new Image in OMERO """, scripts.String("Data_Type", optional=False, grouping="1", description="The data you want to work with.", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Dataset IDs or Image IDs").ofType(rlong(0)), scripts.String("Rotation_Axis", optional=False, grouping="3", description="3D rotation over Y or X axis", values=axes, default="Y"), scripts.Bool("Use_Raw_Data", grouping="4", default=False, description="Convert raw pixel data to Tiff for processing? Otherwise use rendered data"), scripts.Int("Channel_To_Analyse", grouping="4.1", default=1, min=1, description="This channel will be analysed as greyscale Tiffs"), scripts.Bool("Analyse_ROI_Regions", grouping="5", default=False, description="Use Rectangle ROIs to define regions to analyse. By default analyse whole image"), authors = ["William Moore", "Asmi Shah"], institutions = ["University of Dundee", "KIT"], contact = "*****@*****.**", ) try: session = client.getSession() scriptParams = {} conn = BlitzGateway(client_obj=client) # process the list of args above. for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams robj, message = rotation_proj_stitch(conn, scriptParams) client.setOutput("Message", rstring(message)) if robj is not None: client.setOutput("Result", robject(robj)) finally: client.closeSession()
def runAsScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring('Image')] labels = [rstring('Image Name'), rstring('Datasets'), rstring('Tags')] algorithums = [rstring('Maximum Intensity'), rstring('Mean Intensity')] roiLabel = """Specify an ROI to pick by specifying it's shape label. \ 'FigureROI' by default, (not case sensitive). If matching ROI not found, use \ any ROI.""" formats = [rstring('JPEG'), rstring('PNG'), rstring('TIFF')] ckeys = COLOURS.keys() ckeys.sort() oColours = wrap(OVERLAY_COLOURS.keys()) client = scripts.client( 'ROI_Split_Figure.py', """Create a figure of an ROI region as separate zoomed split-channel \ panels. NB: OMERO.insight client provides a nicer UI for this script under \ 'Publishing Options' See http://help.openmicroscopy.org/scripts.html""", # provide 'Data_Type' and 'IDs' parameters so that Insight # auto-populates with currently selected images. scripts.String( "Data_Type", optional=False, grouping="01", description="The data you want to work with.", values=dataTypes, default="Image"), scripts.List( "IDs", optional=False, grouping="02", description="List of Dataset IDs or Image IDs").ofType(rlong(0)), scripts.Map( "Channel_Names", grouping="03", description="Map of index: channel name for All channels"), scripts.Bool( "Merged_Names", grouping="04", description="If true, label the merged panel with channel names." " Otherwise label with 'Merged'"), scripts.List( "Split_Indexes", grouping="05", description="List of the channels in the split view panels"), scripts.Bool( "Split_Panels_Grey", grouping="06", description="If true, all split panels are grayscale"), scripts.Map( "Merged_Colours", grouping="07", description="Map of index:int colors for each merged channel." " Otherwise use existing colour settings"), scripts.Int( "Width", grouping="08", description="Max width of each image panel", min=1), scripts.Int( "Height", grouping="09", description="The max height of each image panel", min=1), scripts.String( "Image_Labels", grouping="10", description="Label images with the Image's Name or it's Datasets" " or Tags", values=labels), scripts.String( "Algorithm", grouping="11", description="Algorithum for projection.", values=algorithums), scripts.Int( "Stepping", grouping="12", description="The Z-plane increment for projection. Default is 1", min=1), scripts.Int( "Scalebar", grouping="13", description="Scale bar size in microns. Only shown if image has" " pixel-size info.", min=1), scripts.String( "Format", grouping="14", description="Format to save image. E.g 'PNG'.", values=formats, default='JPEG'), scripts.String( "Figure_Name", grouping="15", description="File name of the figure to save."), scripts.String( "Overlay_Colour", grouping="16", description="The color of the scale bar.", default='White', values=oColours), scripts.Float( "ROI_Zoom", grouping="17", description="How much to zoom the ROI. E.g. x 2. If 0 then zoom" " roi panel to fit", min=0), scripts.String("ROI_Label", grouping="18", description=roiLabel), version="4.3.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: conn = BlitzGateway(client_obj=client) commandArgs = client.getInputs(unwrap=True) print commandArgs # call the main script, attaching resulting figure to Image. Returns # the id of the originalFileLink child. (ID object, not value) fileAnnotation, message = roiFigure(conn, commandArgs) # Return message and file annotation (if applicable) to the client client.setOutput("Message", rstring(message)) if fileAnnotation is not None: client.setOutput("File_Annotation", robject(fileAnnotation._obj)) finally: client.closeSession()
def run_script(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ data_types = [rstring('Image')] labels = [rstring('Image Name'), rstring('Datasets'), rstring('Tags')] algorithms = [rstring('Maximum Intensity'), rstring('Mean Intensity')] formats = [rstring('JPEG'), rstring('PNG'), rstring('TIFF')] ckeys = COLOURS.keys() ckeys.sort() o_colours = wrap(OVERLAY_COLOURS.keys()) client = scripts.client( 'Split_View_Figure.py', """Create a figure of split-view images. See http://help.openmicroscopy.org/publish.html#figures""", # provide 'Data_Type' and 'IDs' parameters so that Insight # auto-populates with currently selected images. scripts.String("Data_Type", optional=False, grouping="01", description="The data you want to work with.", values=data_types, default="Image"), scripts.List("IDs", optional=False, grouping="02", description="List of Image IDs").ofType(rlong(0)), scripts.String( "Algorithm", grouping="3", description="Algorithm for projection. Only used if a Z-range is" " chosen below", values=algorithms, default='Maximum Intensity'), scripts.Int( "Z_Start", grouping="3.1", description="Projection range (if not specified, use defaultZ" " only - no projection)", min=0), scripts.Int( "Z_End", grouping="3.2", description="Projection range (if not specified, use defaultZ" " only - no projection)", min=0), scripts.Map("Channel_Names", grouping="4", description="Map of index: channel name for all channels"), scripts.List("Split_Indexes", grouping="5", description="List of the channels in the split" " view").ofType(rint(0)), scripts.Bool("Split_Panels_Grey", grouping="6", description="If true, all split panels are grayscale", default=False), scripts.Map( "Merged_Colours", grouping="7", description="Map of index:int colors for each merged channel"), scripts.Bool( "Merged_Names", grouping="8", description="If true, label the merged panel with channel names." " Otherwise label with 'Merged'", default=True), scripts.Int("Width", grouping="9", description="The max width of each image panel. Default is" " first image width", min=1), scripts.Int( "Height", grouping="91", description="The max height of each image panel. Default is" " first image height", min=1), scripts.String( "Image_Labels", grouping="92", description="Label images with Image name (default) or datasets" " or tags", values=labels, default='Image Name'), scripts.Int("Stepping", grouping="93", description="The Z increment for projection.", default=1, min=1), scripts.Int( "Scalebar", grouping="94", description="Scale bar size in microns. Only shown if image has" " pixel-size info.", min=1), scripts.String("Format", grouping="95", description="Format to save image", values=formats, default='JPEG'), scripts.String("Figure_Name", grouping="96", description="File name of the figure to save.", default='Split_View_Figure'), scripts.String("Overlay_Colour", grouping="97", description="The color of the scale bar.", default='White', values=o_colours), version="4.3.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: conn = BlitzGateway(client_obj=client) script_params = client.getInputs(unwrap=True) # call the main script, attaching resulting figure to Image. Returns # the FileAnnotationI [file_annotation, message] = split_view_figure(conn, script_params) # Return message and file annotation (if applicable) to the client client.setOutput("Message", rstring(message)) if file_annotation is not None: client.setOutput("File_Annotation", robject(file_annotation._obj)) finally: client.closeSession()
def runScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring('Dataset'), rstring('Image')] formats = [rstring('JPEG'), rstring('PNG'), rstring('OME-TIFF')] defaultZoption = 'Default-Z (last-viewed)' zChoices = [ rstring(defaultZoption), rstring('ALL Z planes'), rstring( 'Max projection' ), # currently ImageWrapper only allows full Z-stack projection rstring('Other (see below)') ] defaultToption = 'Default-T (last-viewed)' tChoices = [ rstring(defaultToption), rstring('ALL T planes'), rstring('Other (see below)') ] client = scripts.client( 'Batch_Image_Export.py', """Save multiple images as jpegs or pngs in a zip file available for download as a batch export. See http://www.openmicroscopy.org/site/support/omero4/getting-started/tutorial/running-scripts/running-util-scripts/""", scripts.String("Data_Type", optional=False, grouping="1", description="The data you want to work with.", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Dataset IDs or Image IDs").ofType( rlong(0)), scripts.Bool("Export_Individual_Channels", grouping="3", description="Save individual channels as separate images", default=True), scripts.Bool( "Individual_Channels_Grey", grouping="3.1", description= "If true, all individual channel images will be greyscale", default=False), scripts.List("Channel_Names", grouping="3.2", description="Names for saving individual channel images"), scripts.Bool( "Export_Merged_Image", grouping="4", description="Save merged image, using current rendering settings", default=True), scripts.String( "Choose_Z_Section", grouping="5", description= "Default Z is last viewed Z for each image, OR choose Z below.", values=zChoices, default=defaultZoption), scripts.Int("OR_specify_Z_index", grouping="5.1", description="Choose a specific Z-index to export", min=1), scripts.Int("OR_specify_Z_start_AND...", grouping="5.2", description="Choose a specific Z-index to export", min=1), scripts.Int("...specify_Z_end", grouping="5.3", description="Choose a specific Z-index to export", min=1), scripts.String( "Choose_T_Section", grouping="6", description= "Default T is last viewed T for each image, OR choose T below.", values=tChoices, default=defaultToption), scripts.Int("OR_specify_T_index", grouping="6.1", description="Choose a specific T-index to export", min=1), scripts.Int("OR_specify_T_start_AND...", grouping="6.2", description="Choose a specific T-index to export", min=1), scripts.Int("...specify_T_end", grouping="6.3", description="Choose a specific T-index to export", min=1), scripts.Int( "Image_Width", grouping="7", description= "The max width of each image panel. Default is actual size", min=1), scripts.String("Format", grouping="8", description="Format to save image", values=formats, default='PNG'), scripts.String( "Folder_Name", grouping="9", description="Name of folder (and zip file) to store images", default='Batch_Image_Export'), version="4.3.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: startTime = datetime.now() session = client.getSession() scriptParams = {} conn = BlitzGateway(client_obj=client) # process the list of args above. for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) log(scriptParams) # call the main script - returns a file annotation wrapper fileAnnotation, message = batchImageExport(conn, scriptParams) stopTime = datetime.now() log("Duration: %s" % str(stopTime - startTime)) # return this fileAnnotation to the client. client.setOutput("Message", rstring(message)) if fileAnnotation is not None: client.setOutput("File_Annotation", robject(fileAnnotation._obj)) finally: client.closeSession()
def run_script(): data_types = [rstring('Image')] client = scripts.client( 'Channel_Offsets.py', """Create new Images from existing images, applying an x, y and z \ shift to each channel independently. See http://help.openmicroscopy.org/scripts.html""", scripts.String( "Data_Type", optional=False, grouping="1", description="Pick Images by 'Image' ID or by the ID of their " "Dataset'", values=data_types, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Dataset IDs or Image IDs to " "process.").ofType(rlong(0)), scripts.String( "New_Dataset_Name", grouping="3", description="If you want the new image(s) in a new Dataset, " "put name here"), scripts.Bool( "Channel_1", grouping="4", default=True, description="Choose to include this channel in the output image"), scripts.Int( "Channel1_X_shift", grouping="4.1", default=0, description="Number of pixels to shift this channel in the X " "direction. (negative to shift left)"), scripts.Int( "Channel1_Y_shift", grouping="4.2", default=0, description="Number of pixels to shift this channel in the Y" " direction. (negative to shift up)"), scripts.Int("Channel1_Z_shift", grouping="4.3", default=0, description="Offset channel by a number of Z-sections"), scripts.Bool( "Channel_2", grouping="5", default=True, description="Choose to include this channel in the output image"), scripts.Int( "Channel2_X_shift", grouping="5.1", default=0, description="Number of pixels to shift this channel in the X " "direction. (negative to shift left)"), scripts.Int( "Channel2_Y_shift", grouping="5.2", default=0, description="Number of pixels to shift this channel in the Y " "direction. (negative to shift up)"), scripts.Int("Channel2_Z_shift", grouping="5.3", default=0, description="Offset channel by a number of Z-sections"), scripts.Bool( "Channel_3", grouping="6", default=True, description="Choose to include this channel in the output image"), scripts.Int( "Channel3_X_shift", grouping="6.1", default=0, description="Number of pixels to shift this channel in the X " "direction. (negative to shift left)"), scripts.Int( "Channel3_Y_shift", grouping="6.2", default=0, description="Number of pixels to shift this channel in the Y " "direction. (negative to shift up)"), scripts.Int("Channel3_Z_shift", grouping="6.3", default=0, description="Offset channel by a number of Z-sections"), scripts.Bool( "Channel_4", grouping="7", default=True, description="Choose to include this channel in the output image"), scripts.Int( "Channel4_X_shift", grouping="7.1", default=0, description="Number of pixels to shift this channel in the X " "direction. (negative to shift left)"), scripts.Int( "Channel4_Y_shift", grouping="7.2", default=0, description="Number of pixels to shift this channel in the Y " "direction. (negative to shift up)"), scripts.Int("Channel4_Z_shift", grouping="7.3", default=0, description="Offset channel by a number of Z-sections"), version="4.2.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: script_params = client.getInputs(unwrap=True) # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) images, dataset, message = process_images(conn, script_params) # Return message, new image and new dataset (if applicable) to the # client client.setOutput("Message", rstring(message)) if len(images) == 1: client.setOutput("Image", robject(images[0]._obj)) if dataset is not None: client.setOutput("New Dataset", robject(dataset._obj)) finally: client.closeSession()
def runAsScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring('Dataset')] firstAxis = [rstring('column'), rstring('row')] rowColNaming = [rstring('letter'), rstring('number')] client = scripts.client( 'Dataset_To_Plate.py', """Take a Dataset of Images and put them in a new Plate, \ arranging them into rows or columns as desired. Optionally add the Plate to a new or existing Screen. See http://help.openmicroscopy.org/utility-scripts.html""", scripts.String( "Data_Type", optional=False, grouping="1", description="Choose source of images (only Dataset supported)", values=dataTypes, default="Dataset"), scripts.List("IDs", optional=False, grouping="2", description="List of Dataset IDs to convert to new" " Plates.").ofType(rlong(0)), scripts.String( "Filter_Names", grouping="2.1", description="Filter the images by names that contain this value"), scripts.String( "First_Axis", grouping="3", optional=False, default='column', values=firstAxis, description="""Arrange images accross 'column' first or down" " 'row'"""), scripts.Int( "First_Axis_Count", grouping="3.1", optional=False, default=12, description="Number of Rows or Columns in the 'First Axis'", min=1), scripts.String( "Column_Names", grouping="4", optional=False, default='number', values=rowColNaming, description="""Name plate columns with 'number' or 'letter'"""), scripts.String( "Row_Names", grouping="5", optional=False, default='letter', values=rowColNaming, description="""Name plate rows with 'number' or 'letter'"""), scripts.String( "Screen", grouping="6", description="Option: put Plate(s) in a Screen. Enter Name of new" " screen or ID of existing screen" ""), scripts.Bool( "Remove_From_Dataset", grouping="7", default=True, description="Remove Images from Dataset as they are added to" " Plate"), version="4.3.2", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: scriptParams = client.getInputs(unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) # convert Dataset(s) to Plate(s). Returns new plates or screen newObj, message = datasets_to_plates(conn, scriptParams) client.setOutput("Message", rstring(message)) if newObj: client.setOutput("New_Object", robject(newObj)) finally: client.closeSession()
def runAsScript(): """ 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) """ formats = [rstring('JPEG'), rstring('PNG'), rstring('TIFF')] dataTypes = [rstring('Dataset'), rstring('Image')] client = scripts.client( 'Thumbnail_Figure.py', """Export a figure of thumbnails, optionally sorted by tag. See http://help.openmicroscopy.org/scripts.html""", scripts.String("Data_Type", optional=False, grouping="1", description="The data you want to work with.", values=dataTypes, default="Dataset"), scripts.List("IDs", optional=False, grouping="2", description="List of Dataset IDs or Image" " IDs").ofType(rlong(0)), scripts.List("Tag_IDs", grouping="3", description="Group thumbnails by these tags."), scripts.Bool("Show_Untagged_Images", grouping="3.1", default=False, description="If true (and you're sorting by tagIds) also" " show images without the specified tags"), scripts.Long("Parent_ID", grouping="4", description="Attach figure to this Project (if datasetIds" " above) or Dataset if imageIds. If not specifed, attach" " figure to first dataset or image."), # this will be ignored if only a single ID in list - attach to # that object instead. scripts.Int( "Thumbnail_Size", grouping="5", min=10, max=250, default=100, description="The dimension of each thumbnail. Default is 100"), scripts.Int( "Max_Columns", grouping="5.1", min=1, default=10, description="The max number of thumbnail columns. Default is 10"), scripts.String("Format", grouping="6", description="Format to save image.", values=formats, default="JPEG"), scripts.String("Figure_Name", grouping="6.1", default='Thumbnail_Figure', description="File name of figure to create"), version="4.3.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: conn = BlitzGateway(client_obj=client) commandArgs = client.getInputs(unwrap=True) print commandArgs # Makes the figure and attaches it to Project/Dataset. Returns # FileAnnotationI object fileAnnotation, message = makeThumbnailFigure(conn, commandArgs) # Return message and file annotation (if applicable) to the client client.setOutput("Message", rstring(message)) if fileAnnotation is not None: client.setOutput("File_Annotation", robject(fileAnnotation._obj)) finally: client.closeSession()
def runAsScript(): """ 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) """ formats = wrap(formatMap.keys()) # wrap each key in it's rtype ckeys = COLOURS.keys() ckeys = ckeys ckeys.sort() cOptions = wrap(ckeys) dataTypes = [rstring("Image")] client = scripts.client( 'Make_Movie', 'MakeMovie creates a movie of the image and attaches it to the originating image.', scripts.String("Data_Type", optional=False, grouping="1", description="Choose Images via their 'Image' IDs.", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="1", description="List of Image IDs to process.").ofType( rlong(0)), scripts.Long("RenderingDef_ID", description="The Rendering Definitions for the Image.", default=-1, optional=True, grouping="1"), scripts.String("Movie_Name", description="The name of the movie", grouping="2"), scripts.Int( "Z_Start", description= "Projection range (if not specified, use defaultZ only - no projection)", min=0, default=0, grouping="3.1"), scripts.Int( "Z_End", description= "Projection range (if not specified or, use defaultZ only - no projection)", min=0, grouping="3.2"), scripts.Int("T_Start", description="The first time-point", min=0, default=0, grouping="4.1"), scripts.Int("T_End", description="The last time-point", min=0, grouping="4.2"), scripts.List("Channels", description="The selected channels", grouping="5").ofType(rint(0)), scripts.Bool("Show_Time", description="If true, display the time.", default=True, grouping="6"), scripts.Bool( "Show_Plane_Info", description= "If true, display the information about the plane e.g. Exposure Time.", default=True, grouping="7"), scripts.Int("FPS", description="Frames Per Second.", default=2, grouping="8"), scripts.Int( "Scalebar", description= "Scale bar size in microns. Only shown if image has pixel-size info.", min=1, grouping="9"), scripts.String("Format", description="Format to save movie", values=formats, default=QT, grouping="10"), scripts.String("Overlay_Colour", description="The colour of the scalebar.", default='White', values=cOptions, grouping="11"), scripts.String( "Canvas_Colour", description="The background colour when using minimum size.", default='Black', values=cOptions), scripts.Int("Min_Width", description="Minimum width for output movie.", default=-1), scripts.Int("Min_Height", description="Minimum height for output movie.", default=-1), scripts.Map( "Plane_Map", description= "Specify the individual planes (instead of using T_Start, T_End, Z_Start and Z_End)", grouping="12"), scripts.Object( "Watermark", description= "Specifiy a watermark as an Original File (png or jpeg)", default=omero.model.OriginalFileI()), scripts.Object( "Intro_Slide", description= "Specifiy an Intro slide as an Original File (png or jpeg)", default=omero.model.OriginalFileI()), scripts.Int( "Intro_Duration", default=3, description="Duration of Intro in seconds. Default is 3 secs."), scripts.Object( "Ending_Slide", description= "Specifiy a finishing slide as an Original File, (png or jpeg)", default=omero.model.OriginalFileI()), scripts.Int( "Ending_Duration", default=3, description= "Duration of finishing slide in seconds. Default is 3 secs."), scripts.Bool( "Do_Link", description= "If true, creates a FileAnnotation with the OriginalFile holding the movie and links it to the Image.", default=True), version="4.2.0", authors=["Donald MacDonald", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: conn = BlitzGateway(client_obj=client) commandArgs = {} for key in client.getInputKeys(): if client.getInput(key): commandArgs[key] = client.getInput(key, unwrap=True) print commandArgs fileAnnotation, message = writeMovie(commandArgs, conn) # return this fileAnnotation to the client. client.setOutput("Message", rstring(message)) if fileAnnotation is not None: client.setOutput("File_Annotation", robject(fileAnnotation)) finally: client.closeSession()
def runAsScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring('Image')] client = scripts.client( 'Simple_FRAP.py', """Analyse average intensity within ellipses over time and \ do simple FRAP analysis to get mobile fraction and half-time of recovery. Needs at least on pre-bleach timepoint and ellipses on all timepoints to be \ analysed. """, scripts.String( "Data_Type", optional=False, grouping="1", description="Choose source of images (only Image supported)", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Image IDs to analyse.").ofType( rlong(0)), scripts.Int("Channel_Index", optional=False, grouping="3", description="The channel to analyse.", default=1, min=1), version="4.4.8", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: # process the list of args above. scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) # process images in Datasets results = doFrapAnalysis(conn, scriptParams) if len(results) == 1: message = "FRAP tHalf: %0.2f seconds" % results[0] elif len(results) == 0: message = "No Images Analysed. See Info for more details" else: average = sum(results) / len(results) message = "Average FRAP t-half (%s images): %0.2f seconds. " \ % (len(results), average) # Return the output - display Message: client.setOutput("Message", rstring(message)) finally: client.closeSession()
def runAsScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring('Image')] labels = [rstring('Image Name'), rstring('Datasets'), rstring('Tags')] algorithums = [rstring('Maximum Intensity'), rstring('Mean Intensity')] roiLabel = """Specify an ROI to pick by specifying it's shape label. \ 'FigureROI' by default, (not case sensitive). If matching ROI not found, use \ any ROI.""" formats = [rstring('JPEG'), rstring('PNG'), rstring('TIFF')] ckeys = COLOURS.keys() ckeys.sort() oColours = wrap(OVERLAY_COLOURS.keys()) client = scripts.client( 'Movie_ROI_Figure.py', """Create a figure of movie frames from ROI region of image. See http://help.openmicroscopy.org/scripts.html""", scripts.String("Data_Type", optional=False, grouping="01", description="The data you want to work with.", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="02", description="List of Image IDs").ofType(rlong(0)), # scripts.List( # "Merged_Colours", grouping="03", # description="A list of colours to apply to merged channels.", # values=cOptions), scripts.List( "Merged_Channels", grouping="03", description="A list of channel indexes to display, starting at 1." " E.g. 1, 2, 3").ofType(rint(0)), scripts.Float( "Roi_Zoom", grouping="04", default=1, description="How much to zoom the ROI. E.g. x 2. If 0 then ROI" " panel will zoom to same size as main image"), scripts.Int( "Max_Columns", grouping="04.1", default=10, description="The maximum number of columns in the figure, for" " ROI-movie frames.", min=1), scripts.Bool( "Resize_Images", grouping="05", default=True, description="Images are shown full-size by default, but can be" " resized below"), scripts.Int("Width", grouping="05.1", description="Max width of each image panel in pixels", min=1), scripts.Int("Height", grouping="05.2", description="The max height of each image panel in pixels", min=1), scripts.String( "Image_Labels", grouping="06", description="Label images with the Image Name or Datasets or" " Tags", values=labels), scripts.Bool("Show_ROI_Duration", grouping="06.1", description="If true, times shown as duration from first " "timepoint of the ROI, otherwise use movie timestamp."), scripts.Int( "Scalebar", grouping="07", description="Scale bar size in microns. Only shown if image has" " pixel-size info.", min=1), scripts.String( "Scalebar_Colour", grouping="07.1", description="The color of the scale bar and ROI outline.", default='White', values=oColours), scripts.String("Roi_Selection_Label", grouping="08", description=roiLabel), scripts.String( "Algorithm", grouping="09", description="Algorithum for projection, if ROI spans several Z" " sections.", values=algorithums), scripts.String("Figure_Name", grouping="10", description="File name of the figure to save.", default='movieROIFigure'), scripts.String("Format", grouping="10.1", description="Format to save figure.", values=formats, default='JPEG'), version="4.3.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: conn = BlitzGateway(client_obj=client) commandArgs = client.getInputs(unwrap=True) print commandArgs # call the main script, attaching resulting figure to Image. Returns # the id of the originalFileLink child. (ID object, not value) fileAnnotation, message = roiFigure(conn, commandArgs) # Return message and file annotation (if applicable) to the client client.setOutput("Message", rstring(message)) if fileAnnotation is not None: client.setOutput("File_Annotation", robject(fileAnnotation._obj)) finally: client.closeSession()
def run_as_script(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring('Image')] fileTypes = [k for k in FILE_TYPES.iterkeys()] client = scripts.client( 'Build_3D_Histogram_From_Localisations.py', """This script creates a 3D histogram from PALM/STORM data. Only Zeiss 3D data is supported (4um Z range).""", scripts.String( "Data_Type", optional=False, grouping="01", description="Choose source of images (only Image supported)", values=dataTypes, default="Image"), scripts.Int("ImageID", optional=False, grouping="02", description="ID of parent localisation microscopy movie"), scripts.Int("AnnotationID", optional=False, grouping="03", description="ID of file to process"), scripts.String("File_Type", optional=False, grouping="04", description="Indicate the type of data being processed", values=fileTypes, default="zeiss3D"), scripts.Int("SR_XY_pixel_size", optional=False, grouping="05", description="Pixel size in super resolved image in nm"), scripts.Int("SR_Z_pixel_size", optional=False, grouping="06", description="Pixel size in super resolved image in nm"), # scripts.Int("Z_range", optional=False, grouping="07w", # description="Z range captured in single plane in micrometres (4um for Zeiss 3D)",default=4), # scripts.Bool("Set_Parent_Pixel_Size", optional=True, grouping="07.1", # description="Use if physical pixel size is not set in parent image", default=False), # # scripts.Int("Parent_Image_XY_Pixel_Size", optional=True, grouping="07.2", # description="Convert the localisation coordinates to nm (multiply by parent image pixel size)"), # # scripts.Int("Parent_Image_Z_Step", optional=True, grouping="07.3", # description="If multiple z planes were recorded, what was the step size"), authors=["Daniel Matthews", "QBI"], institutions=["University of Queensland"], contact="*****@*****.**", ) try: # process the list of args above. scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) # process images in Datasets message = run_processing(conn, scriptParams) client.setOutput("Message", rstring(message)) #client.setOutput("Message", rstring("No plates created. See 'Error' or 'Info' for details")) finally: client.closeSession()
def runAsScript(): dataTypes = [rstring('Image')] client = scripts.client( 'Z_Projection.py', """Do Maximum-Intensity or Mean-Intensity projection of Z-stack images.""", scripts.String("Data_Type", optional=False, grouping="1", description="Pick Images by 'Image' ID", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Image IDs to " "process.").ofType(rlong(0)), scripts.String( "New_Dataset_Name", grouping="3", description="If you want the new image(s) in a new Dataset, " "put name here"), scripts.String("Z_Projection_Type", optional=False, grouping="4", description="Type of Projection", values=wrap(PROJECTIONS.keys()), default="Maximum"), scripts.Int("Z_Start", grouping="4.1", default=1, min=1, description="Start of Z-projection"), scripts.Int( "Z_End", grouping="4.2", min=1, description="End of Z-projection. Default is last Z-section."), scripts.Int("Every_nth_slice", grouping="4.3", min=1, default=1, description="Project every nth Z-section"), scripts.Int( "T_Start", grouping="6.0", default=1, min=1, description="Start of time-points to include in Z-projecton"), scripts.Int( "T_End", grouping="7.0", min=1, description= "End of time-points to include. Default is last Timepoint."), authors=["William Moore", "OME Team"], institutions=["University of Dundee"], ) try: scriptParams = client.getInputs(unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) iids, dataset = processImages(conn, scriptParams) # Return message, new image and new dataset (if applicable) to the # client if len(iids) == 0: message = "No image created." elif len(iids) == 1: message = "New image created." img = conn.getObject("Image", iids[0]) if img is not None: client.setOutput("Image", robject(img._obj)) else: message = "%s new images created." % len(iids) if dataset is None: dataset = conn.getObject("Image", iids[0]).getParent() if dataset is not None: message += " See Dataset:" client.setOutput("New Dataset", robject(dataset._obj)) client.setOutput("Message", rstring(message)) finally: client.closeSession()
This script copies the full resolution images to the new dataset. """, scripts.String( "Data_Type", optional=False, grouping="1", description="Choose source of images (only Dataset supported)", values=dataTypes, default="Dataset"), scripts.List( "IDs", optional=False, grouping="2", description="Dataset to tag and copy images from.").ofType(int), scripts.Int("Project_ID", optional=False, grouping="3", description="Project ID to create new Dataset in."), scripts.String( "Regex_String", optional=False, grouping="4", description="New dataset name will be based on the image name" + "formated by regex", default=r"^(\w+-\w+)-.*"), version="0.1", authors=["Emil Rozbicki"], institutions=["Glencoe Software Inc."], contact="*****@*****.**", ) try:
def runScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ client = scripts.client( 'Metadata_Search.py', """This script searches for Images, using database queries generated \ from a number of parameters.""", scripts.Int( "Min_Size_Z", grouping="1", default=1, min=1, description="Find images with this number of Z-planes or more"), scripts.Int( "Min_Size_T", grouping="2", default=1, min=1, description="Find images with this number of time-points or" " more"), scripts.Int( "Min_Channel_Count", grouping="3", default=1, min=1, description="Find images with this number of channels or more"), scripts.List( "Channel_Names", grouping="4", description="Find images containing channels with these names"), scripts.Int( "Excitation_Wavelength", grouping="4.1", description="Find images with channels of this excitation" " wavelength"), scripts.String( "Objective_Model", grouping="5", description="Save individual channels as separate images"), scripts.Int( "Magnification", grouping="5.1", description="Find images with this Nominal Magnification"), scripts.String( "Lens_NA", grouping="5.2", description="Find images with this Lens NA value"), version="4.4.9", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: scriptParams = {} conn = BlitzGateway(client_obj=client) # process the list of args above. for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams # call the main script - returns a message message = metadataSearch(conn, scriptParams) client.setOutput("Message", rstring(message)) finally: client.closeSession()
def run_script(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ data_types = [rstring('Dataset'), rstring('Image')] client = scripts.client( 'Images_From_ROIs.py', """Crop an Image using Rectangular ROIs, to create new Images. ROIs that extend across Z and T will crop according to the Z and T limits of each ROI. If NO Z set, use all Z planes. If NO T set, use all T planes. If you choose to 'make an image stack' from all the ROIs, the script \ will create a single new Z-stack image with a single plane from each ROI. ROIs that are 'Big', typically over 3k x 3k pixels will create 'tiled' images using the specified tile size. """, scripts.String( "Data_Type", optional=False, grouping="1", description="Choose Images via their 'Dataset' or directly by " " 'Image' IDs.", values=data_types, default="Image"), scripts.List( "IDs", optional=False, grouping="2", description="List of Dataset IDs or Image IDs to " " process.").ofType(rlong(0)), scripts.String( "Container_Name", grouping="3", description="Option: put Images in new Dataset with this name" " OR use this name for new Image stacks, if 'Make_Image_Stack')", default="From_ROIs"), scripts.Bool( "Make_Image_Stack", grouping="4", default=False, description="If true, make a single Image (stack) from all the" " ROIs of each parent Image"), scripts.Int( "Tile_Size", optional=False, grouping="5", min=50, max=2500, description="If the new image is large and tiled, " "create tiles of this width & height", default=1024), version="5.3.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: parameter_map = client.getInputs(unwrap=True) # create a wrapper so we can use the Blitz Gateway. conn = BlitzGateway(client_obj=client) robj, message = make_images_from_rois(conn, parameter_map) client.setOutput("Message", rstring(message)) if robj is not None: client.setOutput("Result", robject(robj)) finally: client.closeSession()
This script applies a gaussian filter to the selected images, uploads the generated images to OMERO and creates an OMERO.figure """, scripts.String("Data_Type", optional=False, grouping="1", description="Choose source of images", values=dataTypes, default="Dataset"), scripts.List("IDs", optional=False, grouping="2", description="Dataset IDs.").ofType(rlong(0)), scripts.Int("Kernel_Window_Size", optional=False, grouping="3", default=20, description="Window size for the gaussian filter"), scripts.Int("Sigma", optional=False, grouping="4", default=2, description="Sigma for the gaussian filter"), scripts.Bool( "Create_Omero_Figure", default=True, grouping="5", description="Create An OMERO.Figure from the resultant images"), authors=["Balaji Ramalingam", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**",
def runAsScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ printDuration(False) # start timer ckeys = COLOURS.keys() ckeys.sort() cOptions = [rstring(col) for col in ckeys] dataTypes = [rstring('Dataset'), rstring('Image')] firstDim = [rstring('Time'), rstring('Channel'), rstring('Z')] extraDims = [ rstring(''), rstring('Time'), rstring('Channel'), rstring('Z') ] channelRegs = [rstring(r) for r in channelRegexes.keys()] zRegs = [rstring(r) for r in zRegexes.keys()] tRegs = [rstring(r) for r in timeRegexes.keys()] client = scripts.client( 'Combine_Images.py', """Combine several single-plane images (or Z-stacks) into one with greater Z, C, T dimensions. See http://www.openmicroscopy.org/site/support/omero4/users/client-tutorials/insight/insight-util-scripts.html""", scripts.String( "Data_Type", optional=False, grouping="1", description= "Use all the images in specified 'Datasets' or choose individual 'Images'.", values=dataTypes, default="Image"), scripts.List( "IDs", optional=False, grouping="2", description="List of Dataset IDs or Image IDs to combine.").ofType( rlong(0)), scripts.String( "Filter_Names", grouping="2.1", description="Filter the images by names that contain this value"), scripts.Bool( "Auto_Define_Dimensions", grouping="3", default=True, description= """Choose new dimensions with respect to the order of the input images. See URL above.""" ), scripts.String( "Channel_Name_Pattern", grouping="3.1", default=DEFAULT_C_REGEX, values=channelRegs, description="""Auto-pick images by channel in the image name"""), scripts.String( "Z_Name_Pattern", grouping="3.2", default=DEFAULT_Z_REGEX, values=zRegs, description="""Auto-pick images by Z-index in the image name"""), scripts.String( "Time_Name_Pattern", grouping="3.3", default=DEFAULT_T_REGEX, values=tRegs, description="""Auto-pick images by T-index in the image name"""), scripts.Bool( "Manually_Define_Dimensions", grouping="4", default=False, description= """Choose new dimensions with respect to the order of the input images. See URL above.""" ), scripts.String("Dimension_1", grouping="4.1", description="The first Dimension to change", values=firstDim), scripts.String( "Dimension_2", grouping="4.2", values=extraDims, default="", description= "The second Dimension to change. Only specify this if combining multiple dimensions." ), scripts.String( "Dimension_3", grouping="4.3", values=extraDims, default="", description= "The third Dimension to change. Only specify this if combining multiple dimensions." ), scripts.Int("Size_Z", grouping="4.4", description="Number of Z planes in new image", min=1), scripts.Int("Size_C", grouping="4.5", description="Number of channels in new image", min=1), scripts.Int("Size_T", grouping="4.6", description="Number of time-points in new image", min=1), scripts.List("Channel_Colours", grouping="7", description="List of Colours for channels.", default="White", values=cOptions).ofType(rstring("")), scripts.List( "Channel_Names", grouping="8", description="List of Names for channels in the new image."), version="4.2.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: session = client.getSession() # process the list of args above. parameterMap = {} for key in client.getInputKeys(): if client.getInput(key): parameterMap[key] = client.getInput(key).getValue() print parameterMap conn = BlitzGateway(client_obj=client) # create the combined image images, message = combineImages(conn, parameterMap) client.setOutput("Message", rstring(message)) if images: if len(images) == 1: client.setOutput("Combined_Image", robject(images[0])) elif len(images) > 1: client.setOutput("First_Image", robject(images[0])) finally: client.closeSession() printDuration()
def run_as_script(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ printDuration(False) dataTypes = [rstring('Image')] fileTypes = [k for k in FILE_TYPES.iterkeys()] client = scripts.client( 'Ripley_Lfunction.py', """This script calculates the Ripley L function for OMERO ROIs on a reconstructed super resolution image. Do not use `Convert coordinates to nm` option on Zeiss data""", scripts.String( "Data_Type", optional=False, grouping="01", description="Choose source of images (only Image supported)", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="02", description="ID of super resolved image to process"), scripts.List("AnnotationIDs", optional=False, grouping="03", description="ID of file to process"), scripts.String("File_Type", optional=False, grouping="04", description="Indicate the type of data being processed", values=fileTypes, default="zeiss2D"), scripts.Bool( "Convert_coordinates_to_nm", optional=False, grouping="05", description= "Convert localisation coordinates to nm - DO NOT USE WITH ZEISS DATA", default=False), scripts.Int( "Parent_Image_Pixel_Size", grouping="05.1", description= "Convert the localisation coordinates to nm (multiply by parent image pixel size)" ), scripts.Int( "Max_radius", optional=False, grouping="06", description="Maximum distance scale for calculation (in nm)", default=1000), scripts.Bool("Email_Results", grouping="07", default=False, description="E-mail the results"), scripts.String("Email_address", grouping="07.1", description="Specify e-mail address"), authors=["Daniel Matthews", "QBI"], institutions=["University of Queensland"], contact="*****@*****.**", ) try: # this could run for a long time so keepAlive client.enableKeepAlive(3600) # process the list of args above. scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) # validate email address if provided if scriptParams['Email_Results'] and not validate_email( conn, scriptParams): client.setOutput("Message", rstring("No valid email address")) return # process images in Datasets robj, message = run_processing(conn, scriptParams) client.setOutput("Message", rstring(message)) if robj is not None: client.setOutput("Result", robject(robj)) #client.setOutput("Message", rstring("No plates created. See 'Error' or 'Info' for details")) finally: client.closeSession() printDuration()
same sizeC as input.""", scripts.String( "Data_Type", optional=False, grouping="1", description="Choose source of images (only Image supported)", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Image IDs to process.").ofType( rlong(0)), scripts.Int("Line_Width", optional=False, grouping="3", default=4, description="Width in pixels of each time slice", min=1), scripts.Bool( "Use_All_Timepoints", grouping="4", default=True, description="Use every timepoint in the kymograph. If False, only" " use timepoints with ROI-shapes"), scripts.Float( "Time_Increment", grouping="5", description="If source movie has no time info, specify increment" " per time point (secs)"), scripts.Float( "Pixel_Size",
def runAsScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring('Dataset')] rowColNaming = [rstring('letter'), rstring('number')] client = scripts.client( 'Dataset_To_Well.py', """Take a Dataset of Images and put them in a Well, \ of an existing or new Plate. See http://help.openmicroscopy.org/scripts.html""", scripts.String( "Data_Type", optional=False, grouping="1", description="Choose source of images (only Dataset supported)", values=dataTypes, default="Dataset"), scripts.List("IDs", optional=False, grouping="2", description="Dataset ID to convert to new" " Well.").ofType(rlong(0)), scripts.String( "Filter_Names", grouping="2.1", description="Filter the images by names that contain this value"), scripts.String( "Column_Names", grouping="3", default='number', values=rowColNaming, description="""Name plate columns with 'number' or 'letter'", " (please specify for new Plate!!!)"""), scripts.String( "Row_Names", grouping="4", default='letter', values=rowColNaming, description="""Name plate rows with 'number' or 'letter'", " (please specify for new Plate!!!)"""), scripts.String("Plate", grouping="5", optional=False, description="Destination Plate. Enter Name of new" " plate or ID of existing plate"), scripts.Int("Well_Row", grouping="5.1", default=1, description="Put Images as Fields into specified Well Row", min=1), scripts.Int( "Well_Column", grouping="5.2", default=1, description="Put Images as Fields into specified Well Column", min=1), scripts.Bool( "Remove_From_Dataset", grouping="6", default=True, description="Remove Images from Dataset as they are added to" " Plate"), version="0.0.1", authors=["Damir Sudar"], institutions=["Quantitative Imaging Systems LLC"], contact="*****@*****.**", ) try: scriptParams = client.getInputs(unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) # convert Dataset(s) to Plate. Returns new plate if created newObj, message = dataset_to_platewell(conn, scriptParams) client.setOutput("Message", rstring(message)) if newObj: client.setOutput("New_Object", robject(newObj)) finally: client.closeSession()
def run_script(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ data_types = [rstring('Dataset'), rstring('Image')] formats = [ rstring('JPEG'), rstring('PNG'), rstring('TIFF'), rstring('OME-TIFF') ] default_z_option = 'Default-Z (last-viewed)' z_choices = [ rstring(default_z_option), rstring('ALL Z planes'), # currently ImageWrapper only allows full Z-stack projection rstring('Max projection'), rstring('Other (see below)') ] default_t_option = 'Default-T (last-viewed)' t_choices = [ rstring(default_t_option), rstring('ALL T planes'), rstring('Other (see below)') ] zoom_percents = omero.rtypes.wrap( ["25%", "50%", "100%", "200%", "300%", "400%"]) client = scripts.client( 'Batch_Image_Export.py', """Save multiple images as JPEG, PNG, TIFF or OME-TIFF \ in a zip file available for download as a batch export. \ See http://help.openmicroscopy.org/export.html#batch""", scripts.String("Data_Type", optional=False, grouping="1", description="The data you want to work with.", values=data_types, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Dataset IDs or Image IDs").ofType( rlong(0)), scripts.Bool("Export_Individual_Channels", grouping="3", description="Save individual channels as separate images", default=True), scripts.Bool( "Individual_Channels_Grey", grouping="3.1", description="If true, all individual channel images will be" " grayscale", default=False), scripts.List("Channel_Names", grouping="3.2", description="Names for saving individual channel images"), scripts.Bool( "Export_Merged_Image", grouping="4", description="Save merged image, using current rendering settings", default=True), scripts.String( "Choose_Z_Section", grouping="5", description="Default Z is last viewed Z for each image, OR choose" " Z below.", values=z_choices, default=default_z_option), scripts.Int("OR_specify_Z_index", grouping="5.1", description="Choose a specific Z-index to export", min=1), scripts.Int("OR_specify_Z_start_AND...", grouping="5.2", description="Choose a specific Z-index to export", min=1), scripts.Int("...specify_Z_end", grouping="5.3", description="Choose a specific Z-index to export", min=1), scripts.String( "Choose_T_Section", grouping="6", description="Default T is last viewed T for each image, OR choose" " T below.", values=t_choices, default=default_t_option), scripts.Int("OR_specify_T_index", grouping="6.1", description="Choose a specific T-index to export", min=1), scripts.Int("OR_specify_T_start_AND...", grouping="6.2", description="Choose a specific T-index to export", min=1), scripts.Int("...specify_T_end", grouping="6.3", description="Choose a specific T-index to export", min=1), scripts.String( "Zoom", grouping="7", values=zoom_percents, description="Zoom (jpeg, png or tiff) before saving with" " ANTIALIAS interpolation", default="100%"), scripts.String("Format", grouping="8", description="Format to save image", values=formats, default='JPEG'), scripts.String( "Folder_Name", grouping="9", description="Name of folder (and zip file) to store images", default='Batch_Image_Export'), version="4.3.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: start_time = datetime.now() script_params = {} conn = BlitzGateway(client_obj=client) script_params = client.getInputs(unwrap=True) for key, value in script_params.iteritems(): log("%s:%s" % (key, value)) # call the main script - returns a file annotation wrapper file_annotation, message = batch_image_export(conn, script_params) stop_time = datetime.now() log("Duration: %s" % str(stop_time - start_time)) # return this fileAnnotation to the client. client.setOutput("Message", rstring(message)) if file_annotation is not None: client.setOutput("File_Annotation", robject(file_annotation._obj)) finally: client.closeSession()
def run_as_script(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring("Dataset"), rstring("Image")] fusion_method = [ rstring('Linear Blending'), rstring('Average'), rstring('Median'), rstring('Max. Intensity'), rstring('Min. Intensity'), rstring('Intensity of random input tile'), rstring('Do not fuse tiles (only write TileConfiguration') ] client = scripts.client( 'Grid_Stitching.py', """Run the "Stitching" FIJI plugin. MAXIMUM NUMBER OF DATASETS FOR BATCH IS FIVE!""", scripts.String( "Data_Type", optional=False, grouping="01", description="Choose source of images (only Image supported)", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="02", description="IDs of images to be stitched").ofType( rlong(0)), scripts.Bool("Single_Channel", grouping="03", default=False, description=("Stitch all channels or a single channel?" "Uncheck for all channels")), scripts.Int("Channel", grouping="03.1", description="channel to be stitched"), scripts.Bool("Single_Z", grouping="04", default=False, description=("Stitch all z slices or a single" "slice? Uncheck for all z slices")), scripts.Int("Z_slice", grouping="04.1", description="z-slice to be stitched"), scripts.Bool( "Range_Z", grouping="05", default=False, description="Stitch a range of slices? Uncheck for all z slices"), scripts.Int("Z_start", grouping="05.1", description="start at this z-slice"), scripts.Int("Z_stop", grouping="05.2", description="stop at this z slice"), scripts.Int("grid_x", optional=False, grouping="06", default=2, description="how many tiles in the x-direction"), scripts.Int("grid_y", optional=False, grouping="07", default=2, description="how many tiles in the y-direction"), scripts.Int("tile_overlap", optional=False, grouping="08", default=20, description="percentage overlap between tiles"), scripts.String("fusion_method", optional=False, grouping="09", default='Linear Blending', description="method used to fuse the tiles", values=fusion_method), scripts.Float("regression_threshold", optional=False, grouping="10", default=0.3, description="global optimisation parameter"), scripts.Float("ave_displacement_threshold", optional=False, grouping="11", default=2.5, description="global optimisation parameter"), scripts.Float("abs_displacement_threshold", optional=False, grouping="12", default=3.5, description="global optimisation parameter"), scripts.Bool("Email_Results", grouping="13", default=False, description="E-mail the results"), scripts.String("Email_address", grouping="13.1", description="Specify e-mail address"), authors=["Daniel Matthews", "QBI"], institutions=["University of Queensland"], contact="*****@*****.**", ) try: client.enableKeepAlive(3600) # process the list of args above. scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) session = {} session['ID'] = client.getSessionId() session['host'] = client.getProperty('omero.host') print(scriptParams) # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) if (scriptParams['Email_Results'] and not validate_email(conn, scriptParams)): client.setOutput("Message", rstring("No valid email address")) return # process images in Datasets robj, message = run_processing(conn, session, scriptParams) client.setOutput("Message", rstring(message)) if robj is not None: client.setOutput("Result", robject(robj)) finally: client.closeSession()
def run_script(): """ The main entry point of the script, as called by the client. Called via the scripting service, passing the required parameters. """ data_types = [rstring('Image')] client = scripts.client( 'Kymograph.py', """This script processes Images, which have Line or PolyLine ROIs to \ create kymographs. Kymographs are created in the form of new OMERO Images, with single Z and T, \ same sizeC as input.""", scripts.String( "Data_Type", optional=False, grouping="1", description="Choose source of images (only Image supported)", values=data_types, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Image IDs to process").ofType( rlong(0)), scripts.Int("Line_Width", optional=False, grouping="3", default=4, description="Width in pixels of each time slice", min=1), scripts.Bool( "Use_All_Timepoints", grouping="4", default=True, description="Use every timepoint in the kymograph. If False, only" " use timepoints with ROI-shapes"), scripts.Float( "Time_Increment", grouping="5", description="If source movie has no time info, specify increment" " per time point (seconds)"), scripts.Float( "Pixel_Size", grouping="6", description="If source movie has no Pixel size info, specify" " pixel size (microns)"), version="4.3.3", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: script_params = client.getInputs(unwrap=True) # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) new_images, message = process_images(conn, script_params) if new_images: if len(new_images) == 1: client.setOutput("New_Image", robject(new_images[0]._obj)) elif len(new_images) > 1: # return the first one client.setOutput("First_Image", robject(new_images[0]._obj)) client.setOutput("Message", rstring(message)) finally: client.closeSession()
scripts.Long("File_Annotation"), scripts.String("Data_Type", optional=False, grouping="1", description="The data you want to work with.", values=data_types, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Dataset IDs or Image IDs").ofType( rlong(0)), #define the position of the key in the csv file scripts.Int( "Key_position_in_csv", optional=False, grouping="3", description="Indicate the position of the key in the csv table"), ) # we can now create our Blitz Gateway by wrapping the client object conn = BlitzGateway(client_obj=client) script_params = client.getInputs(unwrap=True) print script_params #set the namespace which will allow to retrieve the map annotations generated by the script tags_namespace = "kvpairs.from.tags.script" voc_namespace = "kvpairs.from.vocabulary.script" # get the 'IDs' parameter of the csv file imported as annotation key_position = script_params[ "Key_position_in_csv"] #this has been added to give the user the opportunity to define the position of the key in the csv file
def 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. """ data_types = [rstring('Image')] labels = [rstring('Image Name'), rstring('Datasets'), rstring('Tags')] algorithms = [rstring('Maximum Intensity'), rstring('Mean Intensity')] tunits = [ rstring("SECS"), rstring("MINS"), rstring("HOURS"), rstring("MINS SECS"), rstring("HOURS MINS") ] formats = [rstring('JPEG'), rstring('PNG'), rstring('TIFF')] ckeys = COLOURS.keys() ckeys.sort() o_colours = wrap(OVERLAY_COLOURS.keys()) client = scripts.client( 'Movie_Figure.py', """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""", # provide 'Data_Type' and 'IDs' parameters so that Insight # auto-populates with currently selected images. scripts.String("Data_Type", optional=False, grouping="01", description="The data you want to work with.", values=data_types, default="Image"), scripts.List("IDs", optional=False, grouping="02", description="List of Image IDs").ofType(rlong(0)), scripts.List( "T_Indexes", grouping="03", description="The time frames to display in the figure for each" " image").ofType(rint(0)), scripts.String( "Image_Labels", grouping="04", description="Label images with Image name (default) or datasets" " or tags", values=labels), scripts.Int( "Width", grouping="06", description="The max width of each image panel. Default is first" " image width", min=1), scripts.Int( "Height", grouping="07", description="The max height of each image panel. Default is first" " image height", min=1), scripts.Bool("Z_Projection", grouping="08", default=True), scripts.Int( "Z_Start", grouping="08.1", description="Projection range (if not specified, use defaultZ" " only - no projection)", min=0), scripts.Int( "Z_End", grouping="08.2", description="Projection range (if not specified or, use defaultZ" " only - no projection)", min=0), scripts.String("Algorithm", grouping="08.3", description="Algorithm for projection.", values=algorithms), scripts.Int("Stepping", grouping="08.4", description="The Z increment for projection.", default=1, min=1), scripts.Bool("Show_Scalebar", grouping="10", default=True), scripts.Int( "Scalebar", grouping="10.1", description="Scale bar size in microns. Only shown if image has" " pixel-size info.", min=1), scripts.String("Scalebar_Colour", grouping="10.2", description="The color of the scale bar.", default='White', values=o_colours), scripts.String("Format", grouping="11", description="Format to save image.", values=formats, default='JPEG'), scripts.String("Figure_Name", grouping="12", description="File name of the figure to save."), scripts.String("Time_Units", grouping="13", description="The units to use for time display", values=tunits), scripts.Int( "Max_Columns", grouping="04.1", default=10, description="The maximum number of columns in the figure, for" " movie frames.", min=1), version="4.3.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: conn = BlitzGateway(client_obj=client) command_args = client.getInputs(unwrap=True) # Makes the figure and attaches it to Image. Returns the id of the # originalFileLink child. (ID object, not value) file_annotation, message = movie_figure(conn, command_args) # Return message and file annotation (if applicable) to the client client.setOutput("Message", rstring(message)) if file_annotation: client.setOutput("File_Annotation", robject(file_annotation._obj)) finally: client.closeSession()
Specifiy the plane to threshold (channel, z plane, timepoint) and optionally a threshold value (hint: check the histogram of the channel to get an idea for a good value). If you specify a negative value, a simple iterative approach is used to automatically find a good value. """, scripts.String( "Data_Type", optional=False, grouping = "a", description="Choose source of images", values=dataTypes, default="Dataset"), scripts.List( "IDs", optional=False, grouping = "a.2", description="List of IDs to process.").ofType(rlong(0)), scripts.Int( "Channel", optional=False, grouping = "b", description="Which channel to use for indexing (first channel = 0)", min=0, default=0), scripts.Int( "Z_Plane", optional=False, grouping = "b.2", description="Which Z plane to use for indexing (first channel = 0)", min=0, default=0), scripts.Int( "Timepoint", optional=False, grouping = "b.3", description="Which timepoint to use for indexing (first channel = 0)", min=0, default=0), scripts.Float("Threshold", optional=False, grouping = "b.4", description="Threshold value to separate foreground from background " "(enter negative value in order to use auto thresholding)", default=-1.0), scripts.Bool("Save_Images", grouping = "d",
def run_as_script(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring('Image')] model = [rstring('Exponential') ] #,rstring('Gaussian+Exponential',rstring('Cosine+Exponential')] pc_corr = [rstring('auto'), rstring('cross')] client = scripts.client( 'Pair_Correlation_Function.py', """This script calculates the pair (auto or cross) correlation function for ROIs on PALM/STORM images. This script should only be run on super resolved images where the physical pixel size has been set (e.g. CZI or OME-TIFF files). This script uses code, translated to Python, that was provided in: "Correlation Functions Quantify Super-Resolution Images and Estimate Apparent Clustering Due to Over-Counting" Veatch et al, PlosONE, DOI: 10.1371/journal.pone.0031457 This paper should be referenced in any publication that results from the use of this script.""", scripts.String( "Data_Type", optional=False, grouping="01", description="Choose source of images (only Image supported)", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="02", description="ID of super resolved image to process"), scripts.String( "Pair_correlation", optional=False, grouping="03", description="Choose the type of pair correlation to perform", values=pc_corr, default="auto"), scripts.Int( "Max_radius", optional=False, grouping="04", description="Maximum distance scale for calculation (in pixels)", default=50), scripts.Bool("Fit_exponential_model", grouping="05", default=True, description="Choose model to fit to correlation data"), scripts.Int("Exponential_amplitude", optional=False, grouping="05.1", description="Amplitude of exponential", default=30), scripts.Int("Exponential_decay", optional=False, grouping="05.2", description="Decay length of exponential (in nm)", default=80), scripts.Int("Exponential_baseline", optional=False, grouping="05.3", description="Baseline of exponential", default=1), scripts.Bool("Fit_exponential+gaussian_model", grouping="06", default=False, description="Choose model to fit to correlation data"), scripts.Int("Density", optional=False, grouping="06.1", description="Surface density of probe (1/um^2)", default=1), scripts.Int("PSF", optional=False, grouping="06.2", description="sqrt(2)*PSF of the image (nm)", default=30), scripts.Int("Amplitude", optional=False, grouping="06.3", description="Amplitude of exponential", default=30), scripts.Int("Decay", optional=False, grouping="06.4", description="Decay length of exponential (in nm)", default=80), scripts.Int("Baseline", optional=False, grouping="06.5", description="Baseline of exponential", default=1), scripts.Bool("Email_Results", grouping="07", default=False, description="E-mail the results"), scripts.String("Email_address", grouping="07.1", description="Specify e-mail address"), authors=["Daniel Matthews", "QBI"], institutions=["University of Queensland"], contact="*****@*****.**", ) try: # process the list of args above. scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) if scriptParams['Email_Results'] and not validate_email( conn, scriptParams): client.setOutput("Message", rstring("No valid email address")) return # process images in Datasets message = run_processing(conn, scriptParams) client.setOutput("Message", rstring(message)) #client.setOutput("Message", rstring("No plates created. See 'Error' or 'Info' for details")) finally: client.closeSession()
and outputs the data as CSV files, for plotting in e.g. Excel.""", scripts.String( "Data_Type", optional=False, grouping="1", description="Choose source of images (only Image supported).", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Image IDs to process.").ofType( rlong(0)), scripts.Int("Line_Width", optional=False, grouping="3", default=1, description="Width in pixels of each line plot.", min=1), scripts.String( "Sum_or_Average", optional=False, grouping="3.1", description="Output the Sum or Average (mean) of Line Profile." " Option to include ALL line data with Average.", default='Average', values=sumAvgOptions), scripts.List( "Channels", grouping="4", description="Optional list of Channels to process. E.g 1, 2. Use" " ALL Channels by default.").ofType(omero.rtypes.rint(0)),