예제 #1
0
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()
예제 #2
0
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()
예제 #3
0
def runAsScript():
    """
    The main entry point of the script. Gets the parameters from the scripting service, makes the figure and 
    returns the output to the client. 
    def __init__(self, name, optional = False, out = False, description = None, type = None, min = None, max = None, values = None)
    """
    formats = wrap(formatMap.keys())  # wrap each key in it's rtype
    ckeys = COLOURS.keys()
    ckeys = ckeys
    ckeys.sort()
    cOptions = wrap(ckeys)
    dataTypes = [rstring("Image")]

    client = scripts.client(
        'Make_Movie',
        'MakeMovie creates a movie of the image and attaches it to the originating image.',
        scripts.String("Data_Type",
                       optional=False,
                       grouping="1",
                       description="Choose Images via their 'Image' IDs.",
                       values=dataTypes,
                       default="Image"),
        scripts.List("IDs",
                     optional=False,
                     grouping="1",
                     description="List of Image IDs to process.").ofType(
                         rlong(0)),
        scripts.Long("RenderingDef_ID",
                     description="The Rendering Definitions for the Image.",
                     default=-1,
                     optional=True,
                     grouping="1"),
        scripts.String("Movie_Name",
                       description="The name of the movie",
                       grouping="2"),
        scripts.Int(
            "Z_Start",
            description=
            "Projection range (if not specified, use defaultZ only - no projection)",
            min=0,
            default=0,
            grouping="3.1"),
        scripts.Int(
            "Z_End",
            description=
            "Projection range (if not specified or, use defaultZ only - no projection)",
            min=0,
            grouping="3.2"),
        scripts.Int("T_Start",
                    description="The first time-point",
                    min=0,
                    default=0,
                    grouping="4.1"),
        scripts.Int("T_End",
                    description="The last time-point",
                    min=0,
                    grouping="4.2"),
        scripts.List("Channels",
                     description="The selected channels",
                     grouping="5").ofType(rint(0)),
        scripts.Bool("Show_Time",
                     description="If true, display the time.",
                     default=True,
                     grouping="6"),
        scripts.Bool(
            "Show_Plane_Info",
            description=
            "If true, display the information about the plane e.g. Exposure Time.",
            default=True,
            grouping="7"),
        scripts.Int("FPS",
                    description="Frames Per Second.",
                    default=2,
                    grouping="8"),
        scripts.Int(
            "Scalebar",
            description=
            "Scale bar size in microns. Only shown if image has pixel-size info.",
            min=1,
            grouping="9"),
        scripts.String("Format",
                       description="Format to save movie",
                       values=formats,
                       default=QT,
                       grouping="10"),
        scripts.String("Overlay_Colour",
                       description="The colour of the scalebar.",
                       default='White',
                       values=cOptions,
                       grouping="11"),
        scripts.String(
            "Canvas_Colour",
            description="The background colour when using minimum size.",
            default='Black',
            values=cOptions),
        scripts.Int("Min_Width",
                    description="Minimum width for output movie.",
                    default=-1),
        scripts.Int("Min_Height",
                    description="Minimum height for output movie.",
                    default=-1),
        scripts.Map(
            "Plane_Map",
            description=
            "Specify the individual planes (instead of using T_Start, T_End, Z_Start and Z_End)",
            grouping="12"),
        scripts.Object(
            "Watermark",
            description=
            "Specifiy a watermark as an Original File (png or jpeg)",
            default=omero.model.OriginalFileI()),
        scripts.Object(
            "Intro_Slide",
            description=
            "Specifiy an Intro slide as an Original File (png or jpeg)",
            default=omero.model.OriginalFileI()),
        scripts.Int(
            "Intro_Duration",
            default=3,
            description="Duration of Intro in seconds. Default is 3 secs."),
        scripts.Object(
            "Ending_Slide",
            description=
            "Specifiy a finishing slide as an Original File, (png or jpeg)",
            default=omero.model.OriginalFileI()),
        scripts.Int(
            "Ending_Duration",
            default=3,
            description=
            "Duration of finishing slide in seconds. Default is 3 secs."),
        scripts.Bool(
            "Do_Link",
            description=
            "If true, creates a FileAnnotation with the OriginalFile holding the movie and links it to the Image.",
            default=True),
        version="4.2.0",
        authors=["Donald MacDonald", "OME Team"],
        institutions=["University of Dundee"],
        contact="*****@*****.**",
    )

    try:
        conn = BlitzGateway(client_obj=client)
        commandArgs = {}

        for key in client.getInputKeys():
            if client.getInput(key):
                commandArgs[key] = client.getInput(key, unwrap=True)
        print commandArgs

        fileAnnotation, message = writeMovie(commandArgs, conn)

        # return this fileAnnotation to the client.
        client.setOutput("Message", rstring(message))
        if fileAnnotation is not None:
            client.setOutput("File_Annotation", robject(fileAnnotation))
    finally:
        client.closeSession()