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(): dataTypes = [rstring('Image')] client = scripts.client( 'MinMax.py', """Create or reset StatsInfo objects for all channels See http://help.openmicroscopy.org/utility-scripts.html""", scripts.String( "Data_Type", optional=False, grouping="1", description="Pick Images by 'Image' ID or by the ID of their " "Dataset'", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Dataset IDs or Image IDs to " "process.").ofType(rlong(0)), scripts.Bool("DryRun", optional=True, grouping="3", description="Whether to print or set values", default=True), scripts.String("Choice", optional=True, grouping="4", description="How to choose which planes will be chosen", default="default", values=("default", "random", "all")), scripts.String("Combine", optional=True, grouping="5", description="Whether and if so how to combine values", default="no", values=("no", "outer", "inner", "average")), scripts.Bool("Debug", optional=True, grouping="6", description="Whether to print debug statements", default=False), version="5.1.3", authors=["Josh Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: scriptParams = client.getInputs(unwrap=True) conn = BlitzGateway(client_obj=client) message = processImages(conn, scriptParams) 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. """ printDuration(False) # start timer dataTypes = [rstring('Dataset'), rstring('Image')] client = scripts.client( 'Images_From_ROIs.py', """Create new Images from the regions defined by Rectangle ROIs on \ other Images. Designed to work with single-plane images (Z=1 T=1) with multiple ROIs per \ image. If you choose to make an image stack from all the ROIs, this script \ assumes that all the ROIs on each Image are the same size.""", scripts.String( "Data_Type", optional=False, grouping="1", description="Choose Images via their 'Dataset' or directly by " " 'Image' IDs.", values=dataTypes, 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"), version="4.2.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: parameterMap = client.getInputs(unwrap=True) print parameterMap # create a wrapper so we can use the Blitz Gateway. conn = BlitzGateway(client_obj=client) robj, message = makeImagesFromRois(conn, parameterMap) client.setOutput("Message", rstring(message)) if robj is not None: client.setOutput("Result", robject(robj)) finally: client.closeSession() printDuration()
def run_script(): """The main entry point of the script, as called by the client.""" data_types = [rstring('Dataset'), rstring('Image')] client = scripts.client( 'Batch_ROI_Export.py', """Export ROI intensities for selected Images as a CSV file.""", 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.List( "Channels", grouping="3", default=[1L, 2L, 3L, 4L], description="Indices of Channels to measure intensity." ).ofType(rlong(0)), scripts.Bool( "Export_All_Planes", grouping="4", description=("Export all Z and T planes for shapes " "where Z and T are not set?"), default=False), scripts.String( "File_Name", grouping="5", default=DEFAULT_FILE_NAME, description="Name of the exported CSV file"), authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: conn = BlitzGateway(client_obj=client) script_params = client.getInputs(unwrap=True) log("script_params:") log(script_params) # call the main script result = batch_roi_export(conn, script_params) # Return message and file_annotation to client if result is None: message = "No images found" else: file_ann, message = result if file_ann is not None: client.setOutput("File_Annotation", robject(file_ann._obj)) client.setOutput("Message", rstring(message)) 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('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 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. 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()
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()
("Customised script for adding key_values pairs to the selected objects (datasets and/or images) from imported csv. Note that the kvpairs will not be editable afterwards." ), # first parameter scripts.String("Data_Type", grouping="1", optional=False, values=data_types, default="Dataset"), # second parameter scripts.List("IDs", grouping="2", optional=False).ofType(rlong(0)), # third parameter scripts.String("File_Annotation", grouping="3", default=""), #scripts.Long("File_Annotation", grouping="3", default=""), # fourth parameter scripts.Bool("Add_kvpairs_to_object", grouping="4", description="object is the selected item", default=True), # fifth parameter scripts.Bool( "Add_kvpairs_to_children", grouping="5", description= "children is the list of objects within the selected item: e.g. images within selected dataset" ), ) # we can now create our Blitz Gateway by wrapping the client object conn = BlitzGateway(client_obj=client) script_params = client.getInputs(unwrap=True) add_self = script_params.get('Add_kvpairs_to_object', False) add_children = script_params.get('Add_kvpairs_to_children', False) data_type = script_params['Data_Type']
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, 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_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()
# this script only takes Datasets data_types = [rstring('Dataset'), rstring('Image')] client = scripts.client( "copy_tags_2kvpairs_per_selected_objects.py", ("Customised script for copying tags to kvpairs for selected objects"), # first parameter scripts.String("Data_Type", grouping="1", optional=False, values=data_types, default="Dataset"), # second parameter scripts.List("IDs", grouping="2", optional=False).ofType(rlong(0)), # third parameter scripts.Bool("Copy_tags_on_object", grouping="3", description="object is the selected item", default=True), # fourth parameter scripts.Bool( "Copy_tags_on_children", grouping="4", description= "children is the list of objects within the selected item: e.g. images within selected dataset" ), ) # we can now create our Blitz Gateway by wrapping the client object conn = BlitzGateway(client_obj=client) script_params = client.getInputs(unwrap=True) copy_self = script_params.get('Copy_tags_on_object', False) copy_children = script_params.get('Copy_tags_on_children', False) data_type = script_params['Data_Type']
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="*****@*****.**", ) 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)
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. 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, 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. """ 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()
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", 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"],
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", description="Save the thresholded images as new images", default=False), scripts.Bool("Delete_previous_Masks", grouping = "e", description="Delete all previous Masks of the images", default=True), scripts.Int("Mask_color_Red", optional=False, grouping = "e.2", description="Display color of the mask", min=0, max=255, default=255), scripts.Int("Mask_color_Green", optional=False, grouping = "e.3", description="Display color of the mask", min=0, max=255, default=255), scripts.Int("Mask_color_Blue", optional=False, grouping = "e.4", description="Display color of the mask", min=0, max=255, default=0), scripts.Int("Mask_color_Alpha", optional=False, grouping = "e.5",
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(): dataTypes = [rstring('Image')] models_path=os.path.join(SCRIPT_PATH, "sample/classifiers/") systems=['carver'] segmentationModel = [] for file in os.listdir(models_path): if file.endswith(".model"): segmentationModel.append(str(os.path.join(models_path,file))) client = scripts.client('weka_tfmq.py', """Segment a dataset using Random Forest and a known classifier""", scripts.String("Data_Type", optional=False, grouping="1", description="Pick Images by 'Image' ID or by the ID of their 'Dataset'", values=dataTypes, default="Image"), scripts.List("IDs", optional=False, grouping="1.1", description="List of Dataset IDs or Image IDs to process.").ofType(rlong(0)), scripts.String("Segmentation_model", optional=False, grouping="2", description="Select model", values=segmentationModel, default=segmentationModel[0]), scripts.String("System", optional=False, grouping="3", description="Select the system", values=systems, default=systems[0]), scripts.String("Wall_time", grouping="3.1", description="Wall time", default='0:30:00'), scripts.String("Private_memory", grouping="3.2", description="Private memory", default='4GB'), scripts.Bool("Big_memory_nodes", grouping="3.2.1", description="Big memory nodes", default='False'), scripts.String("Nodes", grouping="3.3", description="Nodes", default='1'), scripts.String("PPN", grouping="3.4", description="PPN", default='5'), version = "0", authors = ["Joaquin Correa", "Data and Analytics services"], institutions = ["National Energy Research Scientific Computing Center (NERSC)"], contact = "*****@*****.**", ) try: session = client.getSession(); scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) conn = BlitzGateway(client_obj=client) admin = conn.getAdminService() uuid = admin.getEventContext().sessionUuid weka_segmentation(conn, scriptParams, uuid) 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(): """ 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()
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 run_script(): # Script definition # Script name, description and 2 parameters are defined here. # These parameters will be recognised by the Insight and web clients and # populated with the currently selected Image(s) # A username and password will be entered too. # this script takes Images or Datasets message = "Script to export a file to another omero server." data_types = [rstring('Dataset'), rstring('Image')] omero_config = check_omero_config() has_privs = omero_config["has_privs"] scripts_timeout = omero_config["scripts_timeout"] scripts_timeout = (scripts_timeout / 1000) / 60 if has_privs == True: message = "\n\n".join([ message, "You are running this script with" " administrator privileges and the omero.scripts.timeout" " configuration parameter is {}" " minutes.".format(scripts_timeout) ]) else: message = "\n\n".join([ message, "Please note, you are running this script as a" " non-administrator so we are unable to provide an accurate" " value for the omero.scripts.timeout configuration" " parameter. The default of {} minutes is assumed," " though you should check with your OMERO" " administrator.".format(scripts_timeout) ]) image_formats = [rstring('Hypercube'), rstring('TIFF')] client = scripts.client( "Export_to_other_omero.py", message, scripts.String("Data_Type", optional=False, values=data_types, default="Image", description="The data you want to work with.", grouping="1.1"), scripts.List("IDs", optional=False, grouping="1.2", description="List of Dataset IDs or Image IDs").ofType( rlong(0)), # Username scripts.String("Username", optional=False, grouping="2.1"), scripts.String("Password", optional=False, grouping="2.2"), scripts.String("Image_Format", optional=False, values=image_formats, default="Hypercube", grouping="3.1"), scripts.Bool("Include_Annotations", grouping="3.2", default=True)) try: # we can now create our local Blitz Gateway by wrapping the client. local_conn = BlitzGateway(client_obj=client) script_params = client.getInputs(unwrap=True) message = copy_to_remote_omero(client, local_conn, script_params) finally: client.setOutput("Message: ", rstring(message)) # Return some value(s). # Here, we return anything useful the script has produced. # NB: The Insight and web clients will display the "Message" output. # msg = "Script ran with Image ID: %s, Name: %s and \nUsername: %s"\ # % (image_id, image.getName(), username) # client.setOutput("Message", rstring(msg)) client.closeSession() try: local_conn.close() except Exception as e: msg = "Error closing local connection: %s" % (e)
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()
"""Copy Tags from Datasets or Images and apply them to the \ child images of the Dataset and/or other Datasets / Images""", scripts.String("Data_Type", optional=False, grouping="1", description="The object type to Copy tags from.", values=dataTypes, default="Dataset"), scripts.List("IDs", optional=False, grouping="2", description="IDs of Datasets or Images to Copy tags" " from.").ofType(rlong(0)), scripts.Bool( "Paste_To_Contained_Images", grouping="3", description="If Copying from Dataset, Add Tags to child Images?", default=False), scripts.Bool( "Paste_To_Other_Datasets_Or_Images", grouping="4", description="Can also choose other targets to paste the same tags", default=False), scripts.String("Paste_To_Type", grouping="4.1", description="The object type to Paste tags to.", values=dataTypes, default="Dataset"), scripts.List("Paste_To_IDs", grouping="4.2", description="IDs of Datasets or Images to Paste Tags"
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()
def run_script(): dataTypes = [rstring('Project'), rstring('Dataset')] # TODO: enable attaching to images dataTypes_attach = [rstring('Dataset'), rstring('Project')] """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ client = scripts.client( 'Remote_Import.py', """Remote import from dedicated workstations: * Import the content of the OMERO_ImportData/<username>/ folder on the selected workstation. * Appends files with the specified suffix to the Project or Dataset. * The scanned subfolder depth is 10 --------------------------------------------------------------- INPUT: --------------------------------------------------------------- Select PROJECT as TARGET for import : : A Dataset object is created for each subdirectory on OMERO_ImportData/<username>/ Select DATASET as TARGET for import : : All images (also images in subdirectories) are imported into this Dataset """, scripts.String( PARAM_WS, optional=False, grouping="1", description="Choose a workstation where you want to import from", values=WORKSTATION_NAMES), scripts.String(PARAM_DATATYPE, optional=True, grouping="2", description="Choose kind of destination object.", values=dataTypes), scripts.Long( PARAM_ID, optional=False, grouping="3", description= "ID of destination object. Please select only ONE object."), scripts.Bool( PARAM_SKIP_EXISTING, grouping="4", description= "skip files that are already uploaded (checked 'import from' path).", default=False), scripts.Bool(PARAM_ATTACH, grouping="5", description="Attach containing non image files", default=False), scripts.String(PARAM_DEST_ATTACH, grouping="5.1", description="Object to that should be attach", values=dataTypes_attach, default="Dataset"), scripts.String( PARAM_ATTACH_FILTER, grouping="5.2", description= "Filter files by given file extension (for example txt, pdf). Separated by ','." ), namespaces=[omero.constants.namespaces.NSDYNAMIC], version="1.1.0", authors=["Susanne Kunis", "CellNanOs"], institutions=["University of Osnabrueck"], contact="*****@*****.**", ) # noqa try: params = client.getInputs(unwrap=True) if os.path.exists(MOUNT_PATH): conn = BlitzGateway(client_obj=client) datapath = checkWorkstation(conn, params.get(PARAM_WS), MOUNT_PATH, conn.getUser().getName()) if datapath: robj, message = remoteImport(conn, params, datapath) else: message = "No data available on %s for user" % ( params.get(PARAM_WS)) robj = None client.setOutput("Message", rstring(message)) if robj is not None: client.setOutput("Result", robject(robj._obj)) else: client.setOutput( "ERROR", rstring("No such Mount directory: %s" % MOUNT_PATH)) finally: client.closeSession()