Exemplo n.º 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')]
    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()
Exemplo n.º 2
0
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()
Exemplo n.º 3
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('Project'),
        rstring('Dataset'),
        rstring('Image'),
        rstring('Well'),
        rstring('Plate'),
        rstring('Screen')
    ]

    client = scripts.client(
        'Change_Channel_Names.py',
        """Rename channel Names for a given object.""",
        scripts.String("Data_Type",
                       optional=False,
                       grouping="1",
                       description="Choose source of images",
                       values=dataTypes,
                       default="Dataset"),
        scripts.List("IDs",
                     optional=False,
                     grouping="2",
                     description="List of object IDs"
                     " Plates.").ofType(rlong(0)),
        scripts.List(
            "New_Channel_Names",
            optional=False,
            grouping="3",
            description="Comma separated list of the new Channel Names").
        ofType(rstring(",")),
        version="0.1",
        authors=["Emil Rozbicki"],
        institutions=["Glencoe Software Inc."],
        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)

        # wrap client to use the Blitz Gateway
        conn = BlitzGateway(client_obj=client)
        nameChanger = renameChannels(conn, scriptParams)
        message = nameChanger.run()
        print(message)
        client.setOutput("Message", rstring(message))
    finally:
        client.closeSession()
def runAsScript():
    """
    The main entry point of the script, as called by the client via the
    scripting service, passing the required parameters.
    """
    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 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 run_as_script():
    """
    The main entry point of the script, as called by the client via the scripting service, passing the required parameters.
    """

    dataTypes = [rstring('Image')]

    client = scripts.client(
        'Set_Pixel_Size.py',
        """Use this utility if your image has been saved without scaling information (e.g. TIF from Zen Black)""",
        scripts.String(
            "Data_Type",
            optional=False,
            grouping="01",
            description="Choose source of images (only Image supported)",
            values=dataTypes,
            default="Image"),
        scripts.List(
            "IDs",
            optional=False,
            grouping="02",
            description="IDs of images on which to set pixel size").ofType(
                rlong(0)),
        scripts.Float("X_Pixel_Size",
                      optional=False,
                      grouping="03.1",
                      description="Pixel size in um (micro-metres"),
        scripts.Float("Y_Pixel_Size",
                      optional=False,
                      grouping="03.2",
                      description="Pixel size in um (micro-metres"),
        scripts.Float("Z_Pixel_Size",
                      optional=True,
                      grouping="03.3",
                      description="Pixel size in um (micro-metres"),
        authors=["Daniel Matthews", "QBI"],
        institutions=["University of Queensland"],
        contact="*****@*****.**",
    )

    try:

        # process the list of args above.
        scriptParams = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)

        print scriptParams

        # wrap client to use the Blitz Gateway
        conn = BlitzGateway(client_obj=client)

        # process images in Datasets
        message = run_processing(conn, scriptParams)
        client.setOutput("Message", rstring(message))
    finally:
        client.closeSession()
Exemplo n.º 7
0
def runAsScript():
    dataTypes = [rstring('Image')]
    client = scripts.client(
        'MinMax.py',
        """Create or reset StatsInfo objects for all channels

See http://help.openmicroscopy.org/utility-scripts.html""",
        scripts.String(
            "Data_Type",
            optional=False,
            grouping="1",
            description="Pick Images by 'Image' ID or by the ID of their "
            "Dataset'",
            values=dataTypes,
            default="Image"),
        scripts.List("IDs",
                     optional=False,
                     grouping="2",
                     description="List of Dataset IDs or Image IDs to "
                     "process.").ofType(rlong(0)),
        scripts.Bool("DryRun",
                     optional=True,
                     grouping="3",
                     description="Whether to print or set values",
                     default=True),
        scripts.String("Choice",
                       optional=True,
                       grouping="4",
                       description="How to choose which planes will be chosen",
                       default="default",
                       values=("default", "random", "all")),
        scripts.String("Combine",
                       optional=True,
                       grouping="5",
                       description="Whether and if so how to combine values",
                       default="no",
                       values=("no", "outer", "inner", "average")),
        scripts.Bool("Debug",
                     optional=True,
                     grouping="6",
                     description="Whether to print debug statements",
                     default=False),
        version="5.1.3",
        authors=["Josh Moore", "OME Team"],
        institutions=["University of Dundee"],
        contact="*****@*****.**",
    )

    try:
        scriptParams = client.getInputs(unwrap=True)
        conn = BlitzGateway(client_obj=client)
        message = processImages(conn, scriptParams)
        client.setOutput("Message", rstring(message))

    finally:
        client.closeSession()
Exemplo n.º 8
0
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()
Exemplo n.º 9
0
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()
Exemplo n.º 10
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('Dataset')]

    client = scripts.client(
        'Shapes_To_Table.py',
        ("This script processes images, measuring the length of ROI Lines and"
         " saving the results to an OMERO.table."),
        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)),
        version="4.3.2",
        authors=["William Moore", "OME Team"],
        institutions=["University of Dundee"],
        contact="*****@*****.**",
    )

    try:

        # process the list of args above.
        scriptParams = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)

        print scriptParams

        # wrap client to use the Blitz Gateway
        conn = BlitzGateway(client_obj=client)

        # process images in Datasets
        message = processData(conn, scriptParams)
        if message is not None:
            client.setOutput("Message", rstring(message))
        else:
            client.setOutput("Message", rstring("No datasets found"))
    finally:
        client.closeSession()
Exemplo n.º 11
0
def run():
    """
    """
    data_types = [rstring("Plate")]

    client = scripts.client(
        "Unlink_Images.py",
        "Unlink Images from a given Plate",

        scripts.String("Data_Type", optional=False, grouping="1",
                       description="The data type you want to work with.",
                       values=data_types,
                       default="Plate"),

        scripts.List("IDs", optional=False, grouping="2",
                     description="List of Plate IDs").ofType(rlong(0)),

        version="0.1",
        authors=["Chris Allan"],
        institutions=["Glencoe Software Inc."],
        contact="*****@*****.**",
    )

    try:
        script_params = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                script_params[key] = client.getInput(key, unwrap=True)

        session = client.getSession()
        update_service = session.getUpdateService()
        query_service = session.getQueryService()

        count = 0
        for plate_id in script_params["IDs"]:
            params = ParametersI()
            params.addId(plate_id)
            plate = query_service.findByQuery(
                "SELECT p from Plate AS p "
                "LEFT JOIN FETCH p.wells as w "
                "LEFT JOIN FETCH w.wellSamples as ws "
                "WHERE p.id = :id", params)
            for well in plate.copyWells():
                count += well.sizeOfWellSamples()
                well.clearWellSamples()
            update_service.saveObject(plate)

        client.setOutput("Message", rstring(
            "Unlinking of %d Image(s) successful." % count))
    finally:
        client.closeSession()
Exemplo n.º 12
0
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(
        'Dataset_Images_To_New_Figure.py',
        """Use Images from a Dataset to replace those in a Figure and
        save the result as a new Figure, in the same group as the Images""",
        scripts.String("Data_Type",
                       optional=False,
                       grouping="1",
                       description="Only support Dataset",
                       values=[rstring("Dataset")],
                       default="Dataset"),
        scripts.List("IDs",
                     optional=False,
                     grouping="2",
                     description="Dataset ID. Only 1 supported").ofType(
                         rlong(0)),
        scripts.List("Figure_IDs",
                     optional=False,
                     grouping="3",
                     description="Figure ID").ofType(rlong(0)),
    )

    try:
        conn = BlitzGateway(client_obj=client)
        params = client.getInputs(unwrap=True)
        print("params", params)

        msg = dataset_images_to_new_figure(conn, params)
        client.setOutput("Message", rstring(msg))

    finally:
        client.closeSession()
Exemplo n.º 13
0
def run_script():

    data_types = [rstring(otype) for otype in OBJECT_TYPES]
    client = scripts.client(
        'Populate_Metadata.py',
        """
    This script processes a CSV file, attached to a container,
    converting it to an OMERO.table, with one row per Image or Well.
    The table data can then be displayed in the OMERO clients.
    For full details of the supported CSV format, see
    https://github.com/ome/omero-metadata/
        """ + DEPRECATED,
        scripts.String("Data_Type",
                       optional=False,
                       grouping="1",
                       description="Choose source of images",
                       values=data_types,
                       default=OBJECT_TYPES[0]),
        scripts.List("IDs",
                     optional=False,
                     grouping="2",
                     description="Container ID.").ofType(rlong(0)),
        scripts.String(
            "File_Annotation",
            grouping="3",
            description="File Annotation ID containing metadata to populate. "
            "Note this is not the same as the File ID."),
        authors=["Emil Rozbicki", "OME Team"],
        institutions=["Glencoe Software Inc."],
        contact="*****@*****.**",
    )

    try:
        # process the list of args above.
        script_params = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                script_params[key] = client.getInput(key, unwrap=True)

        # wrap client to use the Blitz Gateway
        conn = BlitzGateway(client_obj=client)
        message = populate_metadata(client, conn, script_params)
        client.setOutput("Message", rstring(message))

    finally:
        client.closeSession()
def run_script():
    """
    The main entry point of the script, as called by the client via the
    scripting service, passing the required parameters.
    """
    data_types = [rstring('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()
Exemplo n.º 15
0
def run_script():

    data_types = [rstring('Dataset')]
    client = scripts.client(
        'Add_Key_Val_from_csv',
        """
    This script processes a csv file, attached to a Dataset
        """,
        scripts.String("Data_Type",
                       optional=False,
                       grouping="1",
                       description="Choose source of images",
                       values=data_types,
                       default="Dataset"),
        scripts.List("IDs",
                     optional=False,
                     grouping="2",
                     description="Plate or Screen ID.").ofType(rlong(0)),
        scripts.String("File_Annotation",
                       grouping="3",
                       description="File ID containing metadata to populate."),
        authors=["Christian Evenhuis"],
        institutions=["MIF UTS"],
        contact="*****@*****.**")

    try:
        # process the list of args above.
        script_params = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                script_params[key] = client.getInput(key, unwrap=True)

        # wrap client to use the Blitz Gateway
        conn = BlitzGateway(client_obj=client)
        print("script params")
        for k, v in script_params.items():
            print(k, v)
        message = populate_metadata(client, conn, script_params)
        client.setOutput("Message", rstring(message))

    except:
        pass

    finally:
        client.closeSession()
Exemplo n.º 16
0
def run_script():
    # Script definition
    # Script name, description and 2 parameters are defined here.
    # These parameters will be recognised by the Insight and web clients and
    # populated with the currently selected Image(s)
    # A username and password will be entered too.
    # this script takes Images or Datasets
    message = ""
    data_types = [rstring('Dataset'), rstring('Image')]
    client = scripts.client(
        "Export_to_other_omero_keychain.py",
        "Script to export a file to another omero server.",
        scripts.String("Data_Type",
                       optional=False,
                       values=data_types,
                       default="Image",
                       description="The data you want to work with.",
                       grouping="1.1"),
        scripts.List("IDs",
                     optional=False,
                     grouping="1.2",
                     description="List of Dataset IDs or Image IDs").ofType(
                         rlong(0)),
        # username
        scripts.String("username", optional=False, grouping="2.1")  # ,
        # password - getting from keyring, just for testing.
        # scripts.String("password", optional=False, grouping="2.2")
    )
    try:
        # we can now create our local Blitz Gateway by wrapping the client.
        local_conn = BlitzGateway(client_obj=client)
        script_params = client.getInputs(unwrap=True)

        message = copy_to_remote_omero(client, local_conn, script_params)
    finally:
        client.setOutput("Message: ", rstring(message))

        # Return some value(s).
        # Here, we return anything useful the script has produced.
        # NB: The Insight and web clients will display the "Message" output.
        # msg = "Script ran with Image ID: %s, Name: %s and \nUsername: %s"\
        #       % (image_id, image.getName(), username)
        # client.setOutput("Message", rstring(msg))
        client.closeSession()
        local_conn.close()
Exemplo n.º 17
0
def run_script():

    data_types = [rstring('Plate'), rstring('Screen')]
    client = scripts.client(
        'Populate_Metadata.py',
        """
    This script processes a csv file, attached to a Screen or Plate,
    converting it to an OMERO.table, with one row per Well.
    The table data can then be displayed in the OMERO clients.
    For full details, see
    http://help.openmicroscopy.org/scripts.html#metadata
        """,
        scripts.String("Data_Type",
                       optional=False,
                       grouping="1",
                       description="Choose source of images",
                       values=data_types,
                       default="Plate"),
        scripts.List("IDs",
                     optional=False,
                     grouping="2",
                     description="Plate or Screen ID.").ofType(rlong(0)),
        scripts.String("File_Annotation",
                       grouping="3",
                       description="File ID containing metadata to populate."),
        authors=["Emil Rozbicki", "OME Team"],
        institutions=["Glencoe Software Inc."],
        contact="*****@*****.**",
    )

    try:
        # process the list of args above.
        script_params = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                script_params[key] = client.getInput(key, unwrap=True)

        # wrap client to use the Blitz Gateway
        conn = BlitzGateway(client_obj=client)
        message = populate_metadata(client, conn, script_params)
        client.setOutput("Message", rstring(message))

    finally:
        client.closeSession()
Exemplo n.º 18
0
def runAsScript():

    dataTypes = [rstring('Image'), rstring('Dataset')]

    client = scripts.client(
        'Fix_PixelSize.py',
        """Fix PixelSize setting""",
        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)),
        version="1.0.0",
        authors=["Paul van Schayck"],
        institutions=["Maastricht University"],
        contact="*****@*****.**",
    )

    try:
        scriptParams = client.getInputs(unwrap=True)

        # wrap client to use the Blitz Gateway
        conn = BlitzGateway(client_obj=client)

        message = processImages(client, conn, scriptParams)

        # Return message, new image and new dataset (if applicable) to the
        # client
        client.setOutput("Message", rstring(message))

    finally:
        client.closeSession()
Exemplo n.º 19
0
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()
Exemplo n.º 20
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()
Exemplo n.º 21
0
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()
Exemplo n.º 22
0
def runScript():
    """
    The main entry point of the script, as called by the client via the scripting service, passing the required parameters. 
    """

    dataTypes = [rstring('Dataset'), rstring('Image')]
    formats = [rstring('JPEG'), rstring('PNG'), rstring('OME-TIFF')]
    defaultZoption = 'Default-Z (last-viewed)'
    zChoices = [
        rstring(defaultZoption),
        rstring('ALL Z planes'),
        rstring(
            'Max projection'
        ),  # currently ImageWrapper only allows full Z-stack projection
        rstring('Other (see below)')
    ]
    defaultToption = 'Default-T (last-viewed)'
    tChoices = [
        rstring(defaultToption),
        rstring('ALL T planes'),
        rstring('Other (see below)')
    ]

    client = scripts.client(
        'Batch_Image_Export.py',
        """Save multiple images as jpegs or pngs in a zip
file available for download as a batch export. 
See http://www.openmicroscopy.org/site/support/omero4/getting-started/tutorial/running-scripts/running-util-scripts/""",
        scripts.String("Data_Type",
                       optional=False,
                       grouping="1",
                       description="The data you want to work with.",
                       values=dataTypes,
                       default="Image"),
        scripts.List("IDs",
                     optional=False,
                     grouping="2",
                     description="List of Dataset IDs or Image IDs").ofType(
                         rlong(0)),
        scripts.Bool("Export_Individual_Channels",
                     grouping="3",
                     description="Save individual channels as separate images",
                     default=True),
        scripts.Bool(
            "Individual_Channels_Grey",
            grouping="3.1",
            description=
            "If true, all individual channel images will be greyscale",
            default=False),
        scripts.List("Channel_Names",
                     grouping="3.2",
                     description="Names for saving individual channel images"),
        scripts.Bool(
            "Export_Merged_Image",
            grouping="4",
            description="Save merged image, using current rendering settings",
            default=True),
        scripts.String(
            "Choose_Z_Section",
            grouping="5",
            description=
            "Default Z is last viewed Z for each image, OR choose Z below.",
            values=zChoices,
            default=defaultZoption),
        scripts.Int("OR_specify_Z_index",
                    grouping="5.1",
                    description="Choose a specific Z-index to export",
                    min=1),
        scripts.Int("OR_specify_Z_start_AND...",
                    grouping="5.2",
                    description="Choose a specific Z-index to export",
                    min=1),
        scripts.Int("...specify_Z_end",
                    grouping="5.3",
                    description="Choose a specific Z-index to export",
                    min=1),
        scripts.String(
            "Choose_T_Section",
            grouping="6",
            description=
            "Default T is last viewed T for each image, OR choose T below.",
            values=tChoices,
            default=defaultToption),
        scripts.Int("OR_specify_T_index",
                    grouping="6.1",
                    description="Choose a specific T-index to export",
                    min=1),
        scripts.Int("OR_specify_T_start_AND...",
                    grouping="6.2",
                    description="Choose a specific T-index to export",
                    min=1),
        scripts.Int("...specify_T_end",
                    grouping="6.3",
                    description="Choose a specific T-index to export",
                    min=1),
        scripts.Int(
            "Image_Width",
            grouping="7",
            description=
            "The max width of each image panel. Default is actual size",
            min=1),
        scripts.String("Format",
                       grouping="8",
                       description="Format to save image",
                       values=formats,
                       default='PNG'),
        scripts.String(
            "Folder_Name",
            grouping="9",
            description="Name of folder (and zip file) to store images",
            default='Batch_Image_Export'),
        version="4.3.0",
        authors=["William Moore", "OME Team"],
        institutions=["University of Dundee"],
        contact="*****@*****.**",
    )

    try:
        startTime = datetime.now()
        session = client.getSession()
        scriptParams = {}

        conn = BlitzGateway(client_obj=client)

        # process the list of args above.
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)
        log(scriptParams)

        # call the main script - returns a file annotation wrapper
        fileAnnotation, message = batchImageExport(conn, scriptParams)

        stopTime = datetime.now()
        log("Duration: %s" % str(stopTime - startTime))

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

    finally:
        client.closeSession()
def run_script():
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    data_types = [rstring('Dataset')]
    client = scripts.client(
        'Export_kvpairs_to_csv',
        """
    This script reads the key values pairs of the images "children" of the dataset and creates a csv file which is then attached to the dataset
        """,
        scripts.String(
            "Data_Type", optional=False, grouping="1",
            description="Choose source of images",
            values=data_types, default="Dataset"),

        scripts.List(
            "IDs", optional=False, grouping="2",
            description="dataset ID.").ofType(rlong(0)),


        authors=["Christian Evenhuis"],
        institutions=["MIF UTS"],
        contact="*****@*****.**"
    )

    try:
        # process the list of args above.
        script_params = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                script_params[key] = client.getInput(key, unwrap=True)

        # wrap client to use the Blitz Gateway
        conn = BlitzGateway(client_obj=client)
        print("connection made")

        dataType = script_params["Data_Type"]
        print(dataType)
        ids      = script_params["IDs"]
        datasets = list(conn.getObjects(dataType, ids))    # generator of images or datasets
        print(ids)
        print("datasets:")
        print( datasets )
        for ds in datasets:
            # name of the file
            csv_name = "{}_metadata_out.csv".format(ds.getName())
            print(csv_name)

            # remove the csv if it exists
            for ann in ds.listAnnotations():
                if( isinstance(ann, omero.gateway.FileAnnotationWrapper) ):
                    if( ann.getFileName() == csv_name ):
                        # if the name matches delete it
                        try:
                            delete = Delete2(targetObjects={'FileAnnotation': [int(ann.getId())]})
                            handle = conn.c.sf.submit(delete)
                            conn.c.waitOnCmd(handle, loops=10, ms=500, failonerror=True,
                                         failontimeout=False, closehandle=False)
                            print("Deleted existing csv")
                        except Exception, ex:
                            print("Failed to delete existing csv: {}".format(ex.message))
                else:
                    print("No exisiting file")

            #                                 filename         key          multiple vals
            # assemble the metadata into an OrderedDict of ( OrderedDict of Sets          )
            file_names = [ img.getName() for img in list(ds.listChildren()) ]
            kv_dict = OrderedDict()
            for img in ds.listChildren():
                fn = img.getName()
                kv_dict[fn] = GetExistingMapAnnotions(img)

            # attach the data
            mess = attach_csv_file( conn, ds, kv_dict )
            print(mess)
        mess="done"
        client.setOutput("Message", rstring(mess))
    dataTypes = [rstring('Dataset'), rstring('Image')]
    client = scripts.client(
        'Simple_FRAP_with_figure.py',
        """
    This script does simple FRAP analysis using Ellipse ROIs previously
    saved on images. If matplotlib is installed, data is plotted and new
    OMERO images are created from the plots.
        """,
        scripts.String("Data_Type",
                       optional=False,
                       grouping="1",
                       description="Choose source of images",
                       values=dataTypes,
                       default="Dataset"),
        scripts.List("IDs",
                     optional=False,
                     grouping="2",
                     description="Dataset or Image IDs.").ofType(rlong(0)),
        authors=["Will 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
Exemplo n.º 25
0
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()
# Script definition

# Script name, description and 2 parameters are defined here.
# These parameters will be recognised by the Insight and web clients and
# populated with the currently selected Image(s)

# this script only takes Datasets
data_types = [rstring('Dataset')]
client = scripts.client(
    "add_keys_and_values_to_a_dataset_from_csv.py",
    ("Customised script for adding key_values pairs to a dataset from imported csv. Note that the kvpairs will not be editable afterwards."),
    # first parameter
    scripts.String(
        "Data_Type", grouping="1", optional=False, values=data_types, default="Dataset"),
    # second parameter
    scripts.List("IDs", grouping="2", optional=False).ofType(rlong(0)),
    scripts.String("File_Annotation", grouping="3", default=""),
    #scripts.Long("File_Annotation", grouping="3", default=""),

)
# we can now create our Blitz Gateway by wrapping the client object
conn = BlitzGateway(client_obj=client)
script_params = client.getInputs(unwrap=True)
print script_params


# Define namespace to not allow editing in Insight & web

namespace = "metadatafile.from.csv"

# otherwise if kvpairs want to be kept editable
Exemplo n.º 27
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()
# Script name, description and parameters are defined here.
# These parameters will be recognised by the Insight and web clients and
# populated with the currently selected Image(s)

# this script reads the image name and convert it into a tag. It works only with images.
data_types = [rstring('Image')]
client = scripts.client(
    "create_tag_from_image_name.py",
    ("Customised script for creating a tag from the image name"),
    #scripts.Long("File_Annotation"),
    # first parameter
    scripts.String(
        "Data_Type", optional=False, values=data_types, default="Image"),
    # second parameter
    scripts.List("IDs", optional=False).ofType(rlong(0)),

)
# we can now create our Blitz Gateway by wrapping the client object
conn = BlitzGateway(client_obj=client)
script_params = client.getInputs(unwrap=True)
print script_params


# get the 'IDs' parameter of the Images
ids = unwrap(client.getInput("IDs"))
images = conn.getObjects("Image", ids)

for i in images:
    image_name = i.name
    print "image name is", image_name
Exemplo n.º 29
0
def run_as_script():
    """
    The main entry point of the script, as called by the client via the scripting service,
    passing the required parameters.
    """

    dataTypes = [rstring('Image')]
    model = [rstring('Exponential')
             ]  #,rstring('Gaussian+Exponential',rstring('Cosine+Exponential')]
    pc_corr = [rstring('auto'), rstring('cross')]

    client = scripts.client(
        'Pair_Correlation_Function.py',
        """This script calculates the 
pair (auto or cross) correlation function for ROIs on PALM/STORM images.

This script should only be run on super resolved images where the 
physical pixel size has been set (e.g. CZI or OME-TIFF files).

This script uses code, translated to Python, that was provided in:

"Correlation Functions Quantify Super-Resolution Images 
and Estimate Apparent Clustering Due to Over-Counting"
Veatch et al, PlosONE, DOI: 10.1371/journal.pone.0031457

This paper should be referenced in any publication that
results from the use of this script.""",
        scripts.String(
            "Data_Type",
            optional=False,
            grouping="01",
            description="Choose source of images (only Image supported)",
            values=dataTypes,
            default="Image"),
        scripts.List("IDs",
                     optional=False,
                     grouping="02",
                     description="ID of super resolved image to process"),
        scripts.String(
            "Pair_correlation",
            optional=False,
            grouping="03",
            description="Choose the type of pair correlation to perform",
            values=pc_corr,
            default="auto"),
        scripts.Int(
            "Max_radius",
            optional=False,
            grouping="04",
            description="Maximum distance scale for calculation (in pixels)",
            default=50),
        scripts.Bool("Fit_exponential_model",
                     grouping="05",
                     default=True,
                     description="Choose model to fit to correlation data"),
        scripts.Int("Exponential_amplitude",
                    optional=False,
                    grouping="05.1",
                    description="Amplitude of exponential",
                    default=30),
        scripts.Int("Exponential_decay",
                    optional=False,
                    grouping="05.2",
                    description="Decay length of exponential (in nm)",
                    default=80),
        scripts.Int("Exponential_baseline",
                    optional=False,
                    grouping="05.3",
                    description="Baseline of exponential",
                    default=1),
        scripts.Bool("Fit_exponential+gaussian_model",
                     grouping="06",
                     default=False,
                     description="Choose model to fit to correlation data"),
        scripts.Int("Density",
                    optional=False,
                    grouping="06.1",
                    description="Surface density of probe (1/um^2)",
                    default=1),
        scripts.Int("PSF",
                    optional=False,
                    grouping="06.2",
                    description="sqrt(2)*PSF of the image (nm)",
                    default=30),
        scripts.Int("Amplitude",
                    optional=False,
                    grouping="06.3",
                    description="Amplitude of exponential",
                    default=30),
        scripts.Int("Decay",
                    optional=False,
                    grouping="06.4",
                    description="Decay length of exponential (in nm)",
                    default=80),
        scripts.Int("Baseline",
                    optional=False,
                    grouping="06.5",
                    description="Baseline of exponential",
                    default=1),
        scripts.Bool("Email_Results",
                     grouping="07",
                     default=False,
                     description="E-mail the results"),
        scripts.String("Email_address",
                       grouping="07.1",
                       description="Specify e-mail address"),
        authors=["Daniel Matthews", "QBI"],
        institutions=["University of Queensland"],
        contact="*****@*****.**",
    )

    try:

        # process the list of args above.
        scriptParams = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)

        print scriptParams

        # wrap client to use the Blitz Gateway
        conn = BlitzGateway(client_obj=client)

        if scriptParams['Email_Results'] and not validate_email(
                conn, scriptParams):
            client.setOutput("Message", rstring("No valid email address"))
            return

        # process images in Datasets
        message = run_processing(conn, scriptParams)
        client.setOutput("Message", rstring(message))

        #client.setOutput("Message", rstring("No plates created. See 'Error' or 'Info' for details"))
    finally:
        client.closeSession()
Exemplo n.º 30
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('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()