def testGetAttrWorks(self): rbool(True).val rdouble(0.0).val rfloat(0.0).val rint(0).val rlong(0).val rtime(0).val rinternal(None).val robject(None).val rstring("").val rclass("").val rarray().val rlist().val rset().val rmap().val
def run_script(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ data_types = [rstring('Image')] sum_avg_options = [rstring('Average'), rstring('Sum'), rstring('Average, with raw data')] client = scripts.client( 'Plot_Profile.py', """This script processes Images, which have Line or PolyLine ROIs \ and outputs the data as CSV files, for plotting in e.g. Excel.""", scripts.String( "Data_Type", optional=False, grouping="1", description="Choose source of images (only Image supported).", values=data_types, default="Image"), scripts.List( "IDs", optional=False, grouping="2", description="List of Image IDs to process.").ofType(rlong(0)), scripts.Int( "Line_Width", optional=False, grouping="3", default=1, description="Width in pixels of each line plot.", min=1), scripts.String( "Sum_or_Average", optional=False, grouping="3.1", description="Output the Sum or Average (mean) of Line Profile." " Option to include ALL line data with Average.", default='Average', values=sum_avg_options), scripts.List( "Channels", grouping="4", description="Optional list of Channels to process e.g. 1, 2. Use" " ALL Channels by default.").ofType(omero.rtypes.rint(0)), version="4.3.3", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: script_params = client.getInputs(unwrap=True) # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) file_anns, message = process_images(conn, script_params) if file_anns: if len(file_anns) == 1: client.setOutput("Line_Data", robject(file_anns[0]._obj)) client.setOutput("Message", rstring(message)) finally: client.closeSession()
def 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 runAsScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ print_duration(False) # start timer dataTypes = [rstring('Dataset'), rstring('Image')] client = scripts.client( 'Images_From_ROIs.py', """Crop rectangular regions from slide scanner images.""", 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", default="From_ROIs"), scripts.Bool( "Email_Results", grouping="4", default=True, description="E-mail the results"), scripts.String("Email_address", grouping="4.1", description="Specify e-mail address"), version="5.0.2", authors=["Daniel Matthews", "QBI"], institutions = ["University of Queensland"], contact = "*****@*****.**", ) try: parameterMap = client.getInputs(unwrap=True) print parameterMap # create a wrapper so we can use the Blitz Gateway. conn = BlitzGateway(client_obj=client) if parameterMap['Email_Results'] and not validate_email(conn, parameterMap): client.setOutput("Message", rstring("No valid email address")) return robj, message = make_images_from_rois(conn, parameterMap) client.setOutput("Message", rstring(message)) if robj is not None: client.setOutput("Result", robject(robj)) finally: client.closeSession() print_duration()
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 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 runScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ exportOptions = [rstring('PDF'), rstring('PDF_IMAGES'), rstring('TIFF'), rstring('TIFF_IMAGES')] client = scripts.client( 'Figure_To_Pdf.py', """Used by web.figure to generate pdf figures from json data""", scripts.String("Figure_JSON", optional=False, description="All figure info as json stringified"), scripts.String("Export_Option", values=exportOptions, default="PDF"), scripts.String("Webclient_URI", grouping="4", description="webclient URL for adding links to images"), scripts.String("Figure_Name", grouping="4", description="Name of the Pdf Figure"), scripts.String("Figure_URI", description="URL to the Figure") ) try: scriptParams = {} conn = BlitzGateway(client_obj=client) # process the list of args above. for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams # call the main script - returns a file annotation wrapper fileAnnotation = export_figure(conn, scriptParams) # return this fileAnnotation to the client. client.setOutput("Message", rstring("Pdf Figure created")) if fileAnnotation is not None: client.setOutput( "File_Annotation", robject(fileAnnotation._obj)) finally: client.closeSession()
def runScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ exportOptions = [ rstring('PDF'), rstring('PDF_IMAGES'), rstring('TIFF'), rstring('TIFF_IMAGES') ] client = scripts.client( 'Figure_To_Pdf.py', """Used by web.figure to generate pdf figures from json data""", scripts.String("Figure_JSON", optional=False, description="All figure info as json stringified"), scripts.String("Export_Option", values=exportOptions, default="PDF"), scripts.String("Webclient_URI", grouping="4", description="webclient URL for adding links to images"), scripts.String("Figure_Name", grouping="4", description="Name of the Pdf Figure"), scripts.String("Figure_URI", description="URL to the Figure")) try: scriptParams = {} conn = BlitzGateway(client_obj=client) # process the list of args above. for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams # call the main script - returns a file annotation wrapper fileAnnotation = export_figure(conn, scriptParams) # return this fileAnnotation to the client. client.setOutput("Message", rstring("Pdf Figure created")) if fileAnnotation is not None: client.setOutput("File_Annotation", robject(fileAnnotation._obj)) finally: client.closeSession()
def runAsScript(): """ The main entry point of the script. Gets the parameters from the scripting service, makes the figure and returns the output to the client. def __init__(self, name, optional = False, out = False, description = None, type = None, min = None, max = None, values = None) """ formats = wrap(formatMap.keys()) # wrap each key in it's rtype ckeys = COLOURS.keys() ckeys = ckeys; ckeys.sort() cOptions = wrap(ckeys) client = scripts.client('Make_Movie','MakeMovie creates a movie of the image and attaches it to the originating image.', scripts.Long("Image_ID", description="The Image Identifier.", optional=False, 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.Map("Plane_Map", description="Specify the individual planes (instead of using T_Start, T_End, Z_Start and Z_End)", grouping="12"), version = "4.2.0", authors = ["Donald MacDonald", "OME Team"], institutions = ["University of Dundee"], contact = "*****@*****.**", ) try: session = client.getSession() commandArgs = {} for key in client.getInputKeys(): if client.getInput(key): commandArgs[key] = client.getInput(key).getValue() print commandArgs fileAnnotation = writeMovie(commandArgs, session) if fileAnnotation: client.setOutput("Message", rstring("Movie Created")) client.setOutput("File_Annotation", robject(fileAnnotation)) 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')] client = scripts.client( 'Kymograph_Analysis.py', """This script analyzes Kymograph images, which have Line or \ PolyLine ROIs that track moving objects. It generates a table of the speed \ of movement, saved as an Excel / CSV file.""", 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)), version="4.3.3", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: script_params = client.getInputs(unwrap=True) # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) file_anns, message = process_images(conn, script_params) if file_anns: if len(file_anns) == 1: client.setOutput("Line_Data", robject(file_anns[0]._obj)) client.setOutput("Message", rstring(message)) finally: client.closeSession()
def 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', """Crop rectangular regions from slide scanner images. WARNING: THIS PROCESS CAN TAKE A LONG TIME - APPROX MAXIMUM BATCH SIZE IS 10 ROIs!""", 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", default="From_ROIs"), ) 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 = make_images_from_rois(conn, parameterMap) client.setOutput("Message", rstring(message)) if robj is not None: client.setOutput("Result", robject(robj)) finally: client.closeSession() printDuration()
def runScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ client = scripts.client( 'Figure_To_Pdf.py', """Used by web.figure to generate pdf figures from json data""", scripts.String("Figure_JSON", optional=False, description="All figure info as json stringified"), scripts.String("Webclient_URI", grouping="4", description="Base URL for adding links to images in webclient"), scripts.String("Figure_Name", grouping="4", description="Name of the Pdf Figure") ) 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 if not reportlabInstalled: client.setOutput("Message", rstring("Need to install https://bitbucket.org/rptlab/reportlab")) else: # call the main script - returns a file annotation wrapper fileAnnotation = create_pdf(conn, scriptParams) # return this fileAnnotation to the client. client.setOutput("Message", rstring("Pdf Figure created")) if fileAnnotation is not None: client.setOutput("File_Annotation", robject(fileAnnotation._obj)) finally: client.closeSession()
def runScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ client = scripts.client('Figure_To_Pdf.py', """Used by web.figure to generate pdf figures from json data""", scripts.Int("Page_Width", optional=False, grouping="1", default=612), scripts.Int("Page_Height", optional=False, grouping="2", default=792), scripts.String("Panels_JSON", optional=False, grouping="3", description="All Panel Data as json stringified"), scripts.String("Figure_Name", optional=False, grouping="4", description="Name of the Pdf Figure", default="WebFigure.pdf"), ) 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 # call the main script - returns a file annotation wrapper fileAnnotation = create_pdf(conn, scriptParams) # return this fileAnnotation to the client. client.setOutput("Message", rstring("Pdf Figure created")) 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. """ client = scripts.client( 'Figure_Images_To_Dataset.py', """Add all Images from one or more Figure(s) into the specified Dataset. (this does not remove the Images from any other Datasets)""", scripts.String("Data_Type", optional=False, grouping="2", description="Only support Dataset", values=[rstring("Dataset")], default="Dataset"), scripts.List("IDs", optional=False, grouping="3", description="Dataset ID. Only 1 supported").ofType( rlong(0)), scripts.List("Figure_IDs", optional=False, grouping="1", description="Figure IDs").ofType(rlong(0)), ) try: conn = BlitzGateway(client_obj=client) params = client.getInputs(unwrap=True) print("params", params) msg, dataset = images_to_dataset(conn, params) client.setOutput("Message", rstring(msg)) if dataset is not None: client.setOutput("Dataset", robject(dataset._obj)) finally: client.closeSession()
def runAsScript(): client = scripts.client( 'Transform_Image.py', "Flip or Rotate an Image and create 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.List("Transforms", optional=False, grouping="3", description="List of transforms to apply to the Image", values=actionOptions), ) try: conn = BlitzGateway(client_obj=client) scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams robj, message = transformImages(conn, scriptParams) client.setOutput("Message", rstring(message)) if robj is not None: client.setOutput("Result", robject(robj)) finally: client.closeSession()
def addJSONFile(TXT,conn,client): """ Add a simple text file into the zip to explain what's there """ n = datetime.now() # time-stamp name by default: Figure_2013-10-29_22-43-53.pdf figureName = '/tmp/export_tags_%s-%s-%s_%s-%s-%s.json' % (n.year, n.month, n.day, n.hour, n.minute, n.second) ns='omero.gateway.export_tags' fileAnn=None try: #tempFile=NamedTemporaryFile() tempFile=open(figureName,'w') json.dump(TXT,tempFile) tempFile.flush() fileAnn=conn.createFileAnnfromLocalFile(tempFile.name,mimetype="text/plain",ns=ns) if fileAnn is not None: client.setOutput("File_Annotation",robject(fileAnn._obj)) else: client.setOutput("Message",rstring("no file available for download")) finally: tempFile.close os.remove(figureName)
def runAsScript(): client = scripts.client( 'Transform_Image.py', "Flip or Rotate an Image and create 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.List( "Transforms", optional=False, grouping="3", description="List of transforms to apply to the Image", values=actionOptions), ) try: conn = BlitzGateway(client_obj=client) scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams robj, message = transformImages(conn, scriptParams) client.setOutput("Message", rstring(message)) if robj is not None: client.setOutput("Result", robject(robj)) finally: client.closeSession()
def run_script(): """ The main entry point of the script, as called by the client. Called via the scripting service, passing the required parameters. """ data_types = [rstring('Image')] client = scripts.client( 'Kymograph.py', """This script processes Images, which have Line or PolyLine ROIs to \ create kymographs. Kymographs are created in the form of new OMERO Images, with single Z and T, \ same sizeC as input.""", scripts.String( "Data_Type", optional=False, grouping="1", description="Choose source of images (only Image supported)", values=data_types, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Image IDs to process").ofType( rlong(0)), scripts.Int("Line_Width", optional=False, grouping="3", default=4, description="Width in pixels of each time slice", min=1), scripts.Bool( "Use_All_Timepoints", grouping="4", default=True, description="Use every timepoint in the kymograph. If False, only" " use timepoints with ROI-shapes"), scripts.Float( "Time_Increment", grouping="5", description="If source movie has no time info, specify increment" " per time point (seconds)"), scripts.Float( "Pixel_Size", grouping="6", description="If source movie has no Pixel size info, specify" " pixel size (microns)"), version="4.3.3", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: script_params = client.getInputs(unwrap=True) # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) new_images, message = process_images(conn, script_params) if new_images: if len(new_images) == 1: client.setOutput("New_Image", robject(new_images[0]._obj)) elif len(new_images) > 1: # return the first one client.setOutput("First_Image", robject(new_images[0]._obj)) client.setOutput("Message", rstring(message)) finally: client.closeSession()
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()
# ** BONUS ** # stack the numpy columns horizontally. hstack is a numpy function kymograph_data = hstack(col_data) print "kymograph_data", kymograph_data.shape if kymograph_data.dtype.name not in ('uint8', 'int8'): # we need to scale... minVal = kymograph_data.min() maxVal = kymograph_data.max() valRange = maxVal - minVal scaled = (kymograph_data - minVal) * (float(255) / valRange) convArray = zeros(kymograph_data.shape, dtype=uint8) convArray += scaled print "using converted int8 plane: dtype: %s min: %s max: %s" % (convArray.dtype.name, convArray.min(), convArray.max()) i = Image.fromarray(convArray) else: i = Image.fromarray(plane) #i.show() i.save("kymograph.png", 'PNG') # attach the png to the image fileAnn = conn.createFileAnnfromLocalFile("kymograph.png", mimetype="image/png") print "Attaching kymograph.png to image" image.linkAnnotation(fileAnn) message = "Tile average value: %s" % average client.setOutput("Message", rstring(message)) client.setOutput("Kymograph", robject(fileAnn._obj)) client.closeSession()
def run_script(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ data_types = [rstring('Dataset'), rstring('Image')] formats = [ rstring('JPEG'), rstring('PNG'), rstring('TIFF'), rstring('OME-TIFF') ] default_z_option = 'Default-Z (last-viewed)' z_choices = [ rstring(default_z_option), rstring('ALL Z planes'), # currently ImageWrapper only allows full Z-stack projection rstring('Max projection'), rstring('Other (see below)') ] default_t_option = 'Default-T (last-viewed)' t_choices = [ rstring(default_t_option), rstring('ALL T planes'), rstring('Other (see below)') ] zoom_percents = omero.rtypes.wrap( ["25%", "50%", "100%", "200%", "300%", "400%"]) client = scripts.client( 'Batch_Image_Export.py', """Save multiple images as JPEG, PNG, TIFF or OME-TIFF \ in a zip file available for download as a batch export. \ See http://help.openmicroscopy.org/export.html#batch""", scripts.String("Data_Type", optional=False, grouping="1", description="The data you want to work with.", values=data_types, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Dataset IDs or Image IDs").ofType( rlong(0)), scripts.Bool("Export_Individual_Channels", grouping="3", description="Save individual channels as separate images", default=True), scripts.Bool( "Individual_Channels_Grey", grouping="3.1", description="If true, all individual channel images will be" " grayscale", default=False), scripts.List("Channel_Names", grouping="3.2", description="Names for saving individual channel images"), scripts.Bool( "Export_Merged_Image", grouping="4", description="Save merged image, using current rendering settings", default=True), scripts.String( "Choose_Z_Section", grouping="5", description="Default Z is last viewed Z for each image, OR choose" " Z below.", values=z_choices, default=default_z_option), scripts.Int("OR_specify_Z_index", grouping="5.1", description="Choose a specific Z-index to export", min=1), scripts.Int("OR_specify_Z_start_AND...", grouping="5.2", description="Choose a specific Z-index to export", min=1), scripts.Int("...specify_Z_end", grouping="5.3", description="Choose a specific Z-index to export", min=1), scripts.String( "Choose_T_Section", grouping="6", description="Default T is last viewed T for each image, OR choose" " T below.", values=t_choices, default=default_t_option), scripts.Int("OR_specify_T_index", grouping="6.1", description="Choose a specific T-index to export", min=1), scripts.Int("OR_specify_T_start_AND...", grouping="6.2", description="Choose a specific T-index to export", min=1), scripts.Int("...specify_T_end", grouping="6.3", description="Choose a specific T-index to export", min=1), scripts.String( "Zoom", grouping="7", values=zoom_percents, description="Zoom (jpeg, png or tiff) before saving with" " ANTIALIAS interpolation", default="100%"), scripts.String("Format", grouping="8", description="Format to save image", values=formats, default='JPEG'), scripts.String( "Folder_Name", grouping="9", description="Name of folder (and zip file) to store images", default='Batch_Image_Export'), version="4.3.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: start_time = datetime.now() script_params = {} conn = BlitzGateway(client_obj=client) script_params = client.getInputs(unwrap=True) for key, value in script_params.iteritems(): log("%s:%s" % (key, value)) # call the main script - returns a file annotation wrapper file_annotation, message = batch_image_export(conn, script_params) stop_time = datetime.now() log("Duration: %s" % str(stop_time - start_time)) # return this fileAnnotation to the client. client.setOutput("Message", rstring(message)) if file_annotation is not None: client.setOutput("File_Annotation", robject(file_annotation._obj)) finally: client.closeSession()
def testPassThroughNoneAndRTypes(self): """ To prevent having to check for isintance(int,...) or isintance(RInt,...) all over the place, the static methods automatically check for acceptable types and simply pass them through. Similarly, the primitive types all check for None and return a null RType if necessary. """ # Bool assert None == rbool(None) assert rbool(True) == rbool(rbool(True)) assert rbool(True) == rbool(1) assert rbool(False) == rbool(0) # Double assert None == rdouble(None) assert rdouble(0.0) == rdouble(rdouble(0.0)) assert rdouble(0.0) == rdouble(rdouble(0)) assert rdouble(0.0) == rdouble(rdouble("0.0")) pytest.raises(ValueError, lambda: rdouble("string")) # Float assert None == rfloat(None) assert rfloat(0.0) == rfloat(rfloat(0.0)) assert rfloat(0.0) == rfloat(rfloat(0)) assert rfloat(0.0) == rfloat(rfloat("0.0")) pytest.raises(ValueError, lambda: rfloat("string")) # Long assert None == rlong(None) assert rlong(0) == rlong(rlong(0)) assert rlong(0) == rlong(rlong(0.0)) assert rlong(0) == rlong(rlong("0")) pytest.raises(ValueError, lambda: rlong("string")) # Time assert None == rtime(None) assert rtime(0) == rtime(rtime(0)) assert rtime(0) == rtime(rtime(0.0)) assert rtime(0) == rtime(rtime("0")) pytest.raises(ValueError, lambda: rtime("string")) # Int assert None == rint(None) assert rint(0) == rint(rint(0)) assert rint(0) == rint(rint(0.0)) assert rint(0) == rint(rint("0")) pytest.raises(ValueError, lambda: rint("string")) # # Starting here handling of null is different. # # String assert rstring("") == rstring(None) assert rstring("a") == rstring(rstring("a")) assert rstring("0") == rstring(0) # Class assert rclass("") == rclass(None) assert rclass("c") == rclass(rclass("c")) pytest.raises(ValueError, lambda: rclass(0)) # Internal internal = omero.Internal() assert rinternal(None) == rinternal(None) assert rinternal(internal) == rinternal(rinternal(internal)) pytest.raises(ValueError, lambda: rinternal("string")) # Object obj = omero.model.ImageI() assert robject(None) == robject(None) assert robject(obj) == robject(robject(obj)) pytest.raises(ValueError, lambda: robject("string")) # # Same does not hold for collections # # Array assert rarray([]) == rarray(None) # assert rarray(obj) == rarray(rarray(obj)) # pytest.raises(ValueError, lambda : rarray("string")) # List assert rlist([]) == rlist(None) # assert rlist(obj) == rlist(rlist(obj)) # pytest.raises(ValueError, lambda : rlist("string")) # Set assert rset([]) == rset(None) # assert rset(obj) == rset(rset(obj)) # pytest.raises(ValueError, lambda : rset("string")) # Map assert rmap({}) == rmap(None)
def testObjectCreationEqualsAndHash(self): # RBool true1 = rbool(True) true2 = rbool(True) false1 = rbool(False) false2 = rbool(False) assert true1 == true2 assert false1 == false2 assert true1.getValue() assert not false1.getValue() assert true1 == true2 assert true1 != false1 # RDouble double_zero1 = rdouble(0.0) double_zero2 = rdouble(0.0) double_notzero1 = rdouble(1.1) double_notzero1b = rdouble(1.1) double_notzero2 = rdouble(2.2) assert double_zero1.getValue() == 0.0 assert double_notzero1.getValue() == 1.1 assert double_zero1 == double_zero2 assert double_zero1 != double_notzero1 assert double_notzero1 == double_notzero1b assert double_notzero1 != double_notzero2 # RFloat float_zero1 = rfloat(0.0) float_zero2 = rfloat(0.0) float_notzero1 = rfloat(1.1) float_notzero1b = rfloat(1.1) float_notzero2 = rfloat(2.2) assert float_zero1.getValue() == 0.0 assert float_notzero1.getValue() == 1.1 assert float_zero1 == float_zero2 assert float_zero1 != float_notzero1 assert float_notzero1 == float_notzero1b assert float_notzero1 != float_notzero2 # RInt int_zero1 = rint(0) int_zero2 = rint(0) int_notzero1 = rint(1) int_notzero1b = rint(1) int_notzero2 = rint(2) assert int_zero1.getValue() == 0 assert int_notzero1.getValue() == 1 assert int_zero1 == int_zero2 assert int_zero1 != int_notzero1 assert int_notzero1 == int_notzero1b assert int_notzero1 != int_notzero2 # RLong long_zero1 = rlong(0) long_zero2 = rlong(0) long_notzero1 = rlong(1) long_notzero1b = rlong(1) long_notzero2 = rlong(2) assert long_zero1.getValue() == 0 assert long_notzero1.getValue() == 1 assert long_zero1 == long_zero2 assert long_zero1 != long_notzero1 assert long_notzero1 == long_notzero1b assert long_notzero1 != long_notzero2 # RTime time_zero1 = rtime(0) time_zero2 = rtime(0) time_notzero1 = rtime(1) time_notzero1b = rtime(1) time_notzero2 = rtime(2) assert time_zero1.getValue() == 0 assert time_notzero1.getValue() == 1 assert time_zero1 == time_zero2 assert time_zero1 != time_notzero1 assert time_notzero1 == time_notzero1b assert time_notzero1 != time_notzero2 # RInternal internal_null1 = rinternal(None) internal_null2 = rinternal(None) internal_notnull1 = rinternal(omero.grid.JobParams()) internal_notnull2 = rinternal(omero.grid.JobParams()) assert internal_null1 == internal_null2 assert internal_null1 == internal_null2 assert internal_null1 != internal_notnull2 assert internal_notnull1 == internal_notnull1 assert internal_notnull1 != internal_notnull2 # RObject object_null1 = robject(None) object_null2 = robject(None) object_notnull1 = robject(omero.model.ImageI()) object_notnull2 = robject(omero.model.ImageI()) assert object_null1 == object_null2 assert object_null1 == object_null2 assert object_null1 != object_notnull2 assert object_notnull1 == object_notnull1 assert object_notnull1 != object_notnull2 # RString string_null1 = rstring(None) string_null2 = rstring(None) string_notnull1 = rstring("str1") string_notnull1b = rstring("str1") string_notnull2 = rstring("str2") assert string_null1 == string_null2 assert string_null1 == string_null2 assert string_null1 != string_notnull2 assert string_notnull1 == string_notnull1 assert string_notnull1 != string_notnull2 assert string_notnull1 == string_notnull1b # RClass class_null1 = rclass(None) class_null2 = rclass(None) class_notnull1 = rclass("str1") class_notnull1b = rclass("str1") class_notnull2 = rclass("str2") assert class_null1 == class_null2 assert class_null1 == class_null2 assert class_null1 != class_notnull2 assert class_notnull1 == class_notnull1 assert class_notnull1 != class_notnull2 assert class_notnull1 == class_notnull1b
version="4.3.3", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: # process the list of args above. scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) newImages, message = processImages(conn, scriptParams) if newImages: if len(newImages) == 1: client.setOutput("New_Image", robject(newImages[0]._obj)) elif len(newImages) > 1: # return the first one client.setOutput("First_Image", robject(newImages[0]._obj)) 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('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 testUnwrap(self): # NUMS plain assert 0 == unwrap(0) assert 1 == unwrap(1) assert 0.0 == unwrap(0.0) assert 1.0 == unwrap(1.0) # NUMS rtyped assert 0 == unwrap(rint(0)) assert 0 == unwrap(rlong(0)) assert 1 == unwrap(rint(1)) assert 1 == unwrap(rlong(1)) assert 0.0 == unwrap(rfloat(0.0)) assert 0.0 == unwrap(rdouble(0.0)) assert 1.0 == unwrap(rfloat(1.0)) assert 1.0 == unwrap(rdouble(1.0)) # STRINGS assert "" == unwrap("") assert "str" == unwrap("str") # BOOL assert True == unwrap(True) assert False == unwrap(False) assert True == unwrap(rbool(True)) assert False == unwrap(rbool(False)) # TIME # Bit odd, do we want the long for time, or transformed? assert 0 == unwrap(rtime(0)) assert 1 == unwrap(rtime(1)) # CLASS # same for class, should we map it? assert "k" == unwrap(rclass("k")) # INTERNAL color = omero.Color() assert color == unwrap(rinternal(color)) # OBJECT image = omero.model.ImageI() assert image == unwrap(robject(image)) # COLLECTIONS # empty assert [] == unwrap([]) assert {} == unwrap({}) assert set() == unwrap(set()) # plain in collection assert [1] == unwrap([1]) # rtype in collection assert [1] == unwrap([rint(1)]) assert {"a": 1} == unwrap({"a": 1}) # plain in rcollection ILLEGAL # assert [1] == unwrap(rlist([1])) # assert {"a":1} == unwrap(rmap({"a":1})) # rtype in rcollection assert [1] == unwrap(rlist([rint(1)])) assert {"a": 1} == unwrap(rmap({"a": rint(1)})) # rtype keys ILLEGAL # assert {"a":1} == unwrap(rmap({rstring("a"):rint(1)})) # recursion, ticket:1977 m1 = rmap({"a": rint(1)}) m1.val["m1"] = m1 m2 = {"a": 1} m2["m1"] = m2 unwrap(m1) assert m2["a"] == unwrap(m1)["a"] # Can't compare directly "maximum recursion depth exceeded in cmp" assert type(m2["m1"]) == type(unwrap(m1)["m1"])
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()
print(scriptParams) # handy to have inputs in the std-out log # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) # do the editing... editedImgIds = editDescriptions(conn, scriptParams) # now handle the result, displaying message and returning image if # appropriate if editedImgIds is None: message = "Script failed. See 'error' or 'info' for more details" else: if len(editedImgIds) == 1: # image-wrapper img = conn.getObject("Image", editedImgIds[0]) message = "One Image edited: %s" % img.getName() # omero.model object omeroImage = img._obj # Insight will display 'View' link to image client.setOutput("Edited Image", robject(omeroImage)) elif len(editedImgIds) > 1: message = "%s Images edited" % len(editedImgIds) else: message = ("No images edited. See 'error' or 'info' for more" " details") # Insight will display the 'Message' parameter client.setOutput("Message", rstring(message)) finally: client.closeSession()
print scriptParams # handy to have inputs in the std-out log # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) # do the editing... editedImgIds = editDescriptions(conn, scriptParams) # now handle the result, displaying message and returning image if # appropriate if editedImgIds is None: message = "Script failed. See 'error' or 'info' for more details" else: if len(editedImgIds) == 1: # image-wrapper img = conn.getObject("Image", editedImgIds[0]) message = "One Image edited: %s" % img.getName() # omero.model object omeroImage = img._obj # Insight will display 'View' link to image client.setOutput("Edited Image", robject(omeroImage)) elif len(editedImgIds) > 1: message = "%s Images edited" % len(editedImgIds) else: message = ("No images edited. See 'error' or 'info' for more" " details") # Insight will display the 'Message' parameter client.setOutput("Message", rstring(message)) finally: client.closeSession()
def runScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ anns,names = get_user_annotations(extension="cppipe") dataTypes = [rstring("Dataset"),rstring("Image")] channels = [rstring("0"),rstring("1"),rstring("2"),rstring("3"),rstring("4")] mode = [rstring("Fluorescence"),rstring("Brightfield")] client = scripts.client('CellProfiler_Pipeline.py', """ This script attempts to execute CellProfiler pipeline that has been saved to the server as an annotation. If the 'SaveImages' module is used, make sure to choose 'tif' for the new images in your pipeline. """, 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 Image IDs for each channel being processed").ofType(rlong(0)), scripts.String("Pipeline", optional=False, grouping="3",values=names, description="Cellprofiler pipeline to execute"), scripts.String("Imaging_mode", optional=False, grouping="4", description="The imaging modality of the data to be analysed", values=mode, default="Fluorescence"), scripts.List("Channels_to_process", optional=False, grouping="5", description="channel to be processed in each image list",values=channels).ofType(rstring("")), scripts.List("Channel_names", optional=False, grouping="6", description="channel names",).ofType(rstring("")), scripts.Bool("Analyse_ROI_Regions", grouping="7", default=False, description="Use Rectangle ROIs to define regions to analyse. By default analyse whole image"), scripts.Bool("New_Dataset", grouping="8", description="Put results in new dataset? Only do this if the pipeline creates new images", default=False), scripts.String("Container_Name", grouping="8.1", description="Option: put Images in new Dataset with this name", default="Pipeline_results"), scripts.Bool("Email_Results", grouping="9", default=False, description="E-mail the results"), scripts.String("Email_address", grouping="9.1", description="Specify e-mail address"), authors = ["Daniel Matthews"], institutions = ["University of Queensland", "QBI"], 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) #retrieve the index of the chosen pipeline from the names list pipeIdx = names.index(rstring(scriptParams['Pipeline'])) #get the actual pipeline object at this index from the anns list scriptParams['Pipeline'] = anns[pipeIdx] if scriptParams['Email_Results'] and not validate_email(conn, scriptParams): client.setOutput("Message", rstring("No valid email address")) return robj,message = run_processing(conn, scriptParams) client.setOutput("Message", rstring(message)) if robj is not None: client.setOutput("Result", robject(robj)) finally: client.closeSession()
def runAsScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring('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 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 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. NB: OMERO.insight client provides a nicer UI for this script under \ 'Publishing Options' See http://www.openmicroscopy.org/site/support/omero4/\ users/client-tutorials/insight/insight-export-figures.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 search(self, args): c = self.ctx.conn(args) import omero import omero.all if args.index: if not self.ctx.get_event_context().isAdmin: self.ctx.die(432, "Only admin can index object") try: parts = args.type.split(":") kls = parts[0].strip() kls = getattr(omero.model, kls) kls = kls.ice_staticId() of = c.getCommunicator().findObjectFactory(kls) obj = of.create(kls) id = int(parts[1].strip()) obj.setId(omero.rtypes.rlong(id)) except Exception as e: self.ctx.dbg(e) self.ctx.die(432, "Bad object: %s" % args.type) c.sf.getUpdateService().indexObject(obj) else: group = None if args.admin: group = "-1" ctx = c.getContext(group) search = c.sf.createSearchService() try: try: # Matching OMEROGateway.search() search.setAllowLeadingWildcard(True) search.setCaseSensitive(False) search.onlyType(args.type) if args.no_parse: if args._from or args._to or args.field: self.ctx.err("Ignoring from/to/fields") search.byFullText(args.query) else: try: if args.date_type == "import": args.date_type = "details.creationEvent.time" search.byLuceneQueryBuilder( ",".join(args.field), args._from, args._to, args.date_type, args.query, ctx) except OperationNotExistException: self.ctx.err( "Server does not support byLuceneQueryBuilder") search.byFullText(args.query) if not search.hasNext(ctx): self.ctx.die(433, "No results found.") self.ctx.set("search.results", []) while search.hasNext(ctx): results = search.results(ctx) self.ctx.get("search.results").extend(results) results = [[x] for x in results] if not args.ids_only: results = [[robject(x[0])] for x in results] self.display(results, style=args.style, idsonly=args.ids_only) except omero.ApiUsageException as aue: self.ctx.die(434, aue.message) finally: search.close()
def runAsScript(): dataTypes = [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/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.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: scriptParams = client.getInputs(unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) images, dataset, message = processImages(conn, scriptParams) # Return message, new image and new dataset (if applicable) to the # client client.setOutput("Message", rstring(message)) if len(images) == 1: client.setOutput("Image", robject(images[0]._obj)) if dataset is not None: client.setOutput("New Dataset", robject(dataset._obj)) finally: client.closeSession()
def runAsScript(): """ The main entry point of the script, as called by the client via the scripting service, passing the required parameters. """ dataTypes = [rstring('Image')] labels = [rstring('Image Name'), rstring('Datasets'), rstring('Tags')] algorithums = [rstring('Maximum Intensity'), rstring('Mean Intensity')] formats = [rstring('JPEG'), rstring('PNG'), rstring('TIFF')] ckeys = COLOURS.keys() ckeys.sort() oColours = wrap(OVERLAY_COLOURS.keys()) client = scripts.client( 'Split_View_Figure.py', """Create a figure of split-view images. 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 Image IDs").ofType(rlong(0)), scripts.String( "Algorithm", grouping="3", description="Algorithum for projection. Only used if a Z-range is" " chosen below", values=algorithums, 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 greyscale", default=False), scripts.Map( "Merged_Colours", grouping="7", description="Map of index:int colours 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 colour of the scalebar.", default='White', values=oColours), version="4.3.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: conn = BlitzGateway(client_obj=client) scriptParams = client.getInputs(unwrap=True) print scriptParams # call the main script, attaching resulting figure to Image. Returns # the FileAnnotationI [fileAnnotation, message] = splitViewFigure(conn, scriptParams) # 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()
grouping="2", description="List of Image IDs to process.").ofType( rlong(0)), version="4.3.3", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: # process the list of args above. scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) fileAnns, message = processImages(conn, scriptParams) if fileAnns: if len(fileAnns) == 1: client.setOutput("Line_Data", robject(fileAnns[0]._obj)) client.setOutput("Message", rstring(message)) finally: client.closeSession()
optional=False, grouping="2", description="Image IDs.").ofType(rlong(0)), scripts.String("Channel_Name", optional=False, grouping="3", description="Channel name:"), authors=["OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: # Wrap the script parameters into a dictionary scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) # Use existing session via client object conn = BlitzGateway(client_obj=client) plots = [] for image_id in scriptParams["IDs"]: plots.append(analyse(conn, image_id, scriptParams["Channel_Name"])) client.setOutput("Image", robject(plots[0]._obj)) client.setOutput("Message", rstring("Created {} plot(s).".format(len(plots)))) finally: client.closeSession()
def run_script(): data_types = [rstring('Image')] client = scripts.client( 'Channel_Offsets.py', """Create new Images from existing images, applying an x, y and z \ shift to each channel independently. See http://help.openmicroscopy.org/scripts.html""", scripts.String( "Data_Type", optional=False, grouping="1", description="Pick Images by 'Image' ID or by the ID of their " "Dataset'", values=data_types, default="Image"), scripts.List("IDs", optional=False, grouping="2", description="List of Dataset IDs or Image IDs to " "process.").ofType(rlong(0)), scripts.String( "New_Dataset_Name", grouping="3", description="If you want the new image(s) in a new Dataset, " "put name here"), scripts.Bool( "Channel_1", grouping="4", default=True, description="Choose to include this channel in the output image"), scripts.Int( "Channel1_X_shift", grouping="4.1", default=0, description="Number of pixels to shift this channel in the X " "direction. (negative to shift left)"), scripts.Int( "Channel1_Y_shift", grouping="4.2", default=0, description="Number of pixels to shift this channel in the Y" " direction. (negative to shift up)"), scripts.Int("Channel1_Z_shift", grouping="4.3", default=0, description="Offset channel by a number of Z-sections"), scripts.Bool( "Channel_2", grouping="5", default=True, description="Choose to include this channel in the output image"), scripts.Int( "Channel2_X_shift", grouping="5.1", default=0, description="Number of pixels to shift this channel in the X " "direction. (negative to shift left)"), scripts.Int( "Channel2_Y_shift", grouping="5.2", default=0, description="Number of pixels to shift this channel in the Y " "direction. (negative to shift up)"), scripts.Int("Channel2_Z_shift", grouping="5.3", default=0, description="Offset channel by a number of Z-sections"), scripts.Bool( "Channel_3", grouping="6", default=True, description="Choose to include this channel in the output image"), scripts.Int( "Channel3_X_shift", grouping="6.1", default=0, description="Number of pixels to shift this channel in the X " "direction. (negative to shift left)"), scripts.Int( "Channel3_Y_shift", grouping="6.2", default=0, description="Number of pixels to shift this channel in the Y " "direction. (negative to shift up)"), scripts.Int("Channel3_Z_shift", grouping="6.3", default=0, description="Offset channel by a number of Z-sections"), scripts.Bool( "Channel_4", grouping="7", default=True, description="Choose to include this channel in the output image"), scripts.Int( "Channel4_X_shift", grouping="7.1", default=0, description="Number of pixels to shift this channel in the X " "direction. (negative to shift left)"), scripts.Int( "Channel4_Y_shift", grouping="7.2", default=0, description="Number of pixels to shift this channel in the Y " "direction. (negative to shift up)"), scripts.Int("Channel4_Z_shift", grouping="7.3", default=0, description="Offset channel by a number of Z-sections"), version="4.2.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: script_params = client.getInputs(unwrap=True) # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) images, dataset, message = process_images(conn, script_params) # Return message, new image and new dataset (if applicable) to the # client client.setOutput("Message", rstring(message)) if len(images) == 1: client.setOutput("Image", robject(images[0]._obj)) if dataset is not None: client.setOutput("New Dataset", robject(dataset._obj)) finally: client.closeSession()
args.date_type, args.query, ctx) except OperationNotExistException: self.ctx.err( "Server does not support byLuceneQueryBuilder") search.byFullText(args.query) if not search.hasNext(ctx): self.ctx.die(433, "No results found.") self.ctx.set("search.results", []) while search.hasNext(ctx): results = search.results(ctx) self.ctx.get("search.results").extend(results) results = [[x] for x in results] if not args.ids_only: results = [[robject(x[0])] for x in results] self.display(results, style=args.style, idsonly=args.ids_only) except omero.ApiUsageException, aue: self.ctx.die(434, aue.message) finally: search.close() try: register("search", SearchControl, HELP) except NameError: if __name__ == "__main__": cli = CLI()
args.query, ctx) except OperationNotExistException: self.ctx.err( "Server does not support byLuceneQueryBuilder") search.byFullText(args.query) if not search.hasNext(ctx): self.ctx.die(433, "No results found.") self.ctx.set("search.results", []) while search.hasNext(ctx): results = search.results(ctx) self.ctx.get("search.results").extend(results) results = [[x] for x in results] if not args.ids_only: results = [[robject(x[0])] for x in results] self.display(results, style=args.style, idsonly=args.ids_only) except omero.ApiUsageException, aue: self.ctx.die(434, aue.message) finally: search.close() try: register("search", SearchControl, HELP) except NameError: if __name__ == "__main__": cli = CLI() cli.register("search", SearchControl, HELP)
"IDs", optional=False, grouping="2", description="List of Image IDs to process.").ofType(rlong(0)), version="4.3.3", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: # process the list of args above. scriptParams = {} for key in client.getInputKeys(): if client.getInput(key): scriptParams[key] = client.getInput(key, unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) fileAnns, message = processImages(conn, scriptParams) if fileAnns: if len(fileAnns) == 1: client.setOutput("Line_Data", robject(fileAnns[0]._obj)) 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 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: # process the list of args above. parameterMap = {} for key in client.getInputKeys(): if client.getInput(key): parameterMap[key] = client.getInput(key, unwrap=True) 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_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 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://www.openmicroscopy.org/site/support/omero4/\ users/client-tutorials/insight/insight-export-figures.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 colour of the scalebar and ROI outline.", default='White', values=oColours), scripts.String( "Roi_Selection_Label", grouping="08", description=roiLabel), scripts.String( "Algorithm", grouping="09", description="Algorithum for projection, if ROI spans several Z" " sections.", values=algorithums), scripts.String( "Figure_Name", grouping="10", description="File name of the figure to save.", default='movieROIFigure'), scripts.String( "Format", grouping="10.1", description="Format to save figure.", values=formats, default='JPEG'), version="4.3.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: conn = BlitzGateway(client_obj=client) commandArgs = client.getInputs(unwrap=True) print commandArgs # call the main script, attaching resulting figure to Image. Returns # the id of the originalFileLink child. (ID object, not value) fileAnnotation, message = roiFigure(conn, commandArgs) # Return message and file annotation (if applicable) to the client client.setOutput("Message", rstring(message)) if fileAnnotation is not None: client.setOutput("File_Annotation", robject(fileAnnotation._obj)) finally: client.closeSession()
def run_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()
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()
def runAsScript(): """ The main entry point of the script. Gets the parameters from the scripting service, makes the figure and returns the output to the client. def __init__(self, name, optional = False, out = False, description = None, type = None, min = None, max = None, values = None) """ formats = [rstring('JPEG'), rstring('PNG'), rstring('TIFF')] dataTypes = [rstring('Dataset'), rstring('Image')] client = scripts.client( 'Thumbnail_Figure.py', """Export a figure of thumbnails, optionally sorted by tag. See http://help.openmicroscopy.org/scripts.html""", scripts.String("Data_Type", optional=False, grouping="1", description="The data you want to work with.", values=dataTypes, default="Dataset"), scripts.List("IDs", optional=False, grouping="2", description="List of Dataset IDs or Image" " IDs").ofType(rlong(0)), scripts.List("Tag_IDs", grouping="3", description="Group thumbnails by these tags."), scripts.Bool("Show_Untagged_Images", grouping="3.1", default=False, description="If true (and you're sorting by tagIds) also" " show images without the specified tags"), scripts.Long("Parent_ID", grouping="4", description="Attach figure to this Project (if datasetIds" " above) or Dataset if imageIds. If not specifed, attach" " figure to first dataset or image."), # this will be ignored if only a single ID in list - attach to # that object instead. scripts.Int( "Thumbnail_Size", grouping="5", min=10, max=250, default=100, description="The dimension of each thumbnail. Default is 100"), scripts.Int( "Max_Columns", grouping="5.1", min=1, default=10, description="The max number of thumbnail columns. Default is 10"), scripts.String("Format", grouping="6", description="Format to save image.", values=formats, default="JPEG"), scripts.String("Figure_Name", grouping="6.1", default='Thumbnail_Figure', description="File name of figure to create"), version="4.3.0", authors=["William Moore", "OME Team"], institutions=["University of Dundee"], contact="*****@*****.**", ) try: conn = BlitzGateway(client_obj=client) commandArgs = client.getInputs(unwrap=True) print commandArgs # Makes the figure and attaches it to Project/Dataset. Returns # FileAnnotationI object fileAnnotation, message = makeThumbnailFigure(conn, commandArgs) # Return message and file annotation (if applicable) to the client client.setOutput("Message", rstring(message)) if fileAnnotation is not None: client.setOutput("File_Annotation", robject(fileAnnotation._obj)) finally: client.closeSession()
def runAsScript(): """ The main entry point of the script. Gets the parameters from the scripting service, makes the figure and returns the output to the client. """ dataTypes = [rstring('Image')] labels = [rstring('Image Name'), rstring('Datasets'), rstring('Tags')] algorithums = [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() oColours = 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/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 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="Algorithum for projection.", values=algorithums), 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=oColours), 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) commandArgs = client.getInputs(unwrap=True) print commandArgs # Makes the figure and attaches it to Image. Returns the id of the # originalFileLink child. (ID object, not value) fileAnnotation, message = movieFigure(conn, commandArgs) # Return message and file annotation (if applicable) to the client client.setOutput("Message", rstring(message)) if fileAnnotation: client.setOutput("File_Annotation", robject(fileAnnotation._obj)) finally: client.closeSession()
def runAsScript(): dataTypes = [rstring('Image')] client = scripts.client( 'Z_Projection.py', """Do Maximum-Intensity or Mean-Intensity projection of Z-stack images.""", scripts.String( "Data_Type", optional=False, grouping="1", description="Pick Images by 'Image' ID", values=dataTypes, default="Image"), scripts.List( "IDs", optional=False, grouping="2", description="List of Image IDs to " "process.").ofType(rlong(0)), scripts.String( "New_Dataset_Name", grouping="3", description="If you want the new image(s) in a new Dataset, " "put name here"), scripts.String( "Z_Projection_Type", optional=False, grouping="4", description="Type of Projection", values=wrap(PROJECTIONS.keys()), default="Maximum"), scripts.Int( "Z_Start", grouping="4.1", default=1, min=1, description="Start of Z-projection"), scripts.Int( "Z_End", grouping="4.2", min=1, description="End of Z-projection. Default is last Z-section."), scripts.Int( "Every_nth_slice", grouping="4.3", min=1, default=1, description="Project every nth Z-section"), scripts.Int( "T_Start", grouping="6.0", default=1, min=1, description="Start of time-points to include in Z-projecton"), scripts.Int( "T_End", grouping="7.0", min=1, description="End of time-points to include. Default is last Timepoint."), authors=["William Moore", "OME Team"], institutions=["University of Dundee"], ) try: scriptParams = client.getInputs(unwrap=True) print scriptParams # wrap client to use the Blitz Gateway conn = BlitzGateway(client_obj=client) iids, dataset = processImages(conn, scriptParams) # Return message, new image and new dataset (if applicable) to the # client if len(iids) == 0: message = "No image created." elif len(iids) == 1: message = "New image created." img = conn.getObject("Image", iids[0]) if img is not None: client.setOutput("Image", robject(img._obj)) else: message = "%s new images created." % len(iids) if dataset is None: dataset = conn.getObject("Image", iids[0]).getParent() if dataset is not None: message += " See Dataset:" client.setOutput("New Dataset", robject(dataset._obj)) client.setOutput("Message", rstring(message)) finally: client.closeSession()
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.1").ofType(rint(0)), scripts.List( "ChannelsExtended", description="The selected channels, with optional range" " and colour. Takes precendence over Channels.", grouping="5.2").ofType(rstring('')), 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 color of the scale bar.", default='White', values=cOptions, grouping="11"), scripts.String( "Canvas_Colour", description="The background color 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 = client.getInputs(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 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("TIFF"), rstring("OME-TIFF")] defaultZoption = "Default-Z (last-viewed)" zChoices = [ rstring(defaultZoption), rstring("ALL Z planes"), # currently ImageWrapper only allows full Z-stack projection rstring("Max projection"), rstring("Other (see below)"), ] defaultToption = "Default-T (last-viewed)" tChoices = [rstring(defaultToption), rstring("ALL T planes"), rstring("Other (see below)")] zoomPercents = 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/scripts.html""", 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" " 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=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.String( "Zoom", grouping="7", values=zoomPercents, 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: startTime = datetime.now() scriptParams = {} conn = BlitzGateway(client_obj=client) scriptParams = client.getInputs(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()