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')] client = scripts.client( 'Set_Pixel_Size.py', """Use this utility if your image has been saved without scaling information (e.g. TIF from Zen Black)""", 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 on which to set pixel size").ofType( rlong(0)), scripts.Float("X_Pixel_Size", optional=False, grouping="03.1", description="Pixel size in um (micro-metres"), scripts.Float("Y_Pixel_Size", optional=False, grouping="03.2", description="Pixel size in um (micro-metres"), scripts.Float("Z_Pixel_Size", optional=True, grouping="03.3", description="Pixel size in um (micro-metres"), 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)) 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()
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"], contact="*****@*****.**", ) try: # process the list of args above.
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", 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),
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 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 runAsScript(): dataTypes = [rstring('Dataset'), rstring('Image')] microscopyTypes = [rstring('CONFOCAL'), rstring('TWOPHOTON'), rstring('WIDEFIELD')] immersionTypes = [rstring('Oil'), rstring('Water'), rstring('Air'), rstring('CLARITY')] psfTypes = [rstring('Measured PSF'), rstring('Manual theoretical PSF'), rstring('Automatic theoretical PSF')] client = scripts.client('Omdecon', """Omdecon: deconvolution on the OMERO server. Omdecon uses AIDA, the Adaptative Image Deconvolution Algorithm, to deconvolve images. More info: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3166524/ Also: https://github.com/erikhom/aida ; https://code.google.com/archive/p/aida-deconvolution/ Omdecon can calculate the theoretical PSF if you don't have one on hand. This feature uses Christoph Gohlke's PSF.py module. More info: http://www.lfd.uci.edu/~gohlke/code/psf.py.html READ BEFORE YOU USE OMDECON: 1- Omdecon only works with square images (i.e. 512x512, 600x600). 2- The automatic background subtraction requires a single rectangular ROI. Make sure this ROI doesn't overlap any important feature on any plane or frame. 3- The automatic theoretical PSF calculation requires the following metadata: -Objective, Numerical Aperture, Excitation and Emission for all channels and Pixel Calibration. 4- You need to input the right number of channels when setting the PSF manually. 5- Images are saved in the same dataset with "_Deconv" added to the name. """, scripts.String("Data_Type", optional=False, grouping="1", description="Type of data to deconvolve", values=dataTypes, default=rstring('Image')), scripts.List("IDs", optional=False, grouping="1.1", description = "List of images to deconvolve.").ofType(rlong(0)), scripts.String("Background", grouping = "2", description="Background", values=None, default=None), scripts.Int("Background_value_to_subtract", optional=False, grouping="2.1", description = "Manually supply the background to subtract.", default=0), scripts.Bool("Automatically_measure_background_from_ROI", grouping="2.2", description = "Trace a rectangular ROI to automatically perform background measurement.", default=False), scripts.String("PSF Configuration", grouping = "3", description="PSF settings", values=None, default=None), scripts.String("Type_of_PSF", grouping = "3.1", description="Choose the type of PSF you want to use.", values=psfTypes, default=rstring('Measured PSF')), scripts.Long("Measured_PSF_Image", optional=True, grouping="3.2", description="Input '0' to calculate the theoretical PSF", default=0), scripts.String("Manual settings for theoretical PSF (ignored for automatic)", grouping = "4", description="Supply the parameters here to generate a theoretical PSF with manual settings", values=None, default=None), scripts.String("Fluorescence_Microscopy_", grouping="4.01", description="Choose the type of fluorescence microscopy used", values=microscopyTypes, default=rstring('CONFOCAL')), scripts.String("Imaging_Medium_________", grouping="4.02", description="Select the media used for imaging", values=immersionTypes, default=rstring('Oil')), scripts.Float("Objective_NA_____________", optional=False, grouping="4.03", description="Supply the numerical aperture of the objective", default=1.42), scripts.Float("Pixel_Size_in_microns", optional=False, grouping="4.04", description="Enter the size of your pixels", default=0.05), scripts.Float("Confocal_Pinhole______", optional=False, grouping="4.05", description="Enter the pinhole radius for confocal microscopy", default=0.55), scripts.Int("_____Channel_1_-_Excitation",default=488, grouping="5.1", description="Input '0' if not using this channel"), scripts.Int("_____Channel_1_-_Emission__",default=510, grouping="5.2", description="Input '0' if not using this channel"), scripts.Int("_____Channel_2_-_Excitation",default=0, grouping="5.3", description="Input '0' if not using this channel"), scripts.Int("_____Channel_2_-_Emission__",default=0, grouping="5.4", description="Input '0' if not using this channel"), scripts.Int("_____Channel_3_-_Excitation",default=0, grouping="5.5", description="Input '0' if not using this channel"), scripts.Int("_____Channel_3_-_Emission__",default=0, grouping="5.6", description="Input '0' if not using this channel"), version="1.0.0", authors=["Etienne Labrie-Dion"], institutions=["Douglas Hospital Research Center, McGill University, Montreal"], contact="*****@*****.**", ) try: #Obtain the user parameters scriptParams = {} conn = BlitzGateway(client_obj=client) client.enableKeepAlive(240) for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams robj, message = process(conn, scriptParams) client.setOutput("Message", rstring(message)) if robj is not None: client.setOutput("Result", robject(robj)) finally: #TODO: send an email confirming the end of the deconvolution and success/failure client.closeSession()