예제 #1
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()
예제 #2
0
    def testParse(self):
        try:
            class mock(object):
                def setAgent(self, *args):
                    pass

                def createSession(self, *args):
                    return self

                def detachOnDestroy(self, *args):
                    pass

                def getProperty(self, *args):
                    return "true"

                def setOutput(self, *args):
                    pass
            script_client = client(
                "testParse", "simple ping script", Long("a").inout(),
                String("b").inout(), client=mock())
            print "IN CLIENT: " + \
                script_client.getProperty("omero.scripts.parse")
            assert False, "Should have raised ParseExit"
        except ParseExit:
            pass
def runAsScript():
    """
    The main entry point of the script, as called by the client via the scripting service, passing the required parameters. 
    """
    client = scripts.client('Save_Image_As_Em.py', """Use EMAN2 to save an image as mrc etc.
See http://trac.openmicroscopy.org.uk/omero/wiki/EmPreviewFunctionality""", 
    scripts.List("Image_IDs", optional=False, description="List of image IDs.").ofType(rlong(0)), 
    scripts.Int("Channel_Index",description="If images are multi-channel, specify a channel to save"),
    scripts.String("Extension", description="File type/extension. E.g. 'mrc'. If not given, will try to use extension of each image name"),
    )
    
    try:
        session = client.getSession()
    
        # process the list of args above. 
        parameterMap = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                parameterMap[key] = client.getInput(key).getValue()
    
        originalFiles = saveImageAs(session, parameterMap)        # might return None if failed. 
    
        # Return a single list for other scripts to use
        client.setOutput("Original_Files", wrap(originalFiles))
        # But also return individual objects so Insight can offer 'Download' for each
        for i, o in enumerate(originalFiles):
            client.setOutput("Original_File%s"%i, omero.rtypes.robject(o))

    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
    """

    objparams = get_params()

    client = scripts.client(
        'Example Dynamic Test',
        'Example script using dynamic parameters',
        scripts.String('Dataset',
                       optional=False,
                       grouping='1',
                       description='Select a dataset',
                       values=objparams),
        namespaces=[omero.constants.namespaces.NSDYNAMIC],
    )

    try:
        scriptParams = client.getInputs(unwrap=True)
        message = 'Params: %s\n' % scriptParams
        print(message)
        client.setOutput('Message', rstring(str(message)))

    finally:
        client.closeSession()
예제 #6
0
    def testParse(self):
        try:
            class mock(object):
                def setAgent(self, *args):
                    pass

                def createSession(self, *args):
                    return self

                def detachOnDestroy(self, *args):
                    pass

                def getProperty(self, *args):
                    return "true"

                def setOutput(self, *args):
                    pass
            script_client = client(
                "testParse", "simple ping script", Long("a").inout(),
                String("b").inout(), client=mock())
            print "IN CLIENT: " + \
                script_client.getProperty("omero.scripts.parse")
            assert False, "Should have raised ParseExit"
        except ParseExit:
            pass
예제 #7
0
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()
예제 #8
0
def runAsScript():
    """
    The main entry point of the script, as called by the client via the
    scripting service, passing the required parameters.
    """
    print_duration(False)    # start timer
    dataTypes = [rstring('Dataset'), rstring('Image')]

    client = scripts.client(
        'Images_From_ROIs.py',
        """Crop rectangular regions from slide scanner images.""",

        scripts.String(
            "Data_Type", optional=False, grouping="1",
            description="Choose Images via their 'Dataset' or directly by "
            " 'Image' IDs.", values=dataTypes, default="Image"),

        scripts.List(
            "IDs", optional=False, grouping="2",
            description="List of Dataset IDs or Image IDs to "
            " process.").ofType(rlong(0)),

        scripts.String(
            "Container_Name", grouping="3",
            description="Option: put Images in new Dataset with this name",
            default="From_ROIs"),
                            
        scripts.Bool(
            "Email_Results", grouping="4", default=True,
            description="E-mail the results"),
                            
        scripts.String("Email_address", grouping="4.1",
        description="Specify e-mail address"),

        version="5.0.2",
        authors=["Daniel Matthews", "QBI"],
        institutions = ["University of Queensland"],
        contact = "*****@*****.**",
    )

    try:
        parameterMap = client.getInputs(unwrap=True)
        print parameterMap

        # create a wrapper so we can use the Blitz Gateway.
        conn = BlitzGateway(client_obj=client)
        
        if parameterMap['Email_Results'] and not validate_email(conn, parameterMap):
            client.setOutput("Message", rstring("No valid email address"))
            return

        robj, message = make_images_from_rois(conn, parameterMap)

        client.setOutput("Message", rstring(message))
        if robj is not None:
            client.setOutput("Result", robject(robj))

    finally:
        client.closeSession()
        print_duration()
예제 #9
0
def runAsScript():
    """
    The main entry point of the script, as called by the client via the
    scripting service, passing the required parameters.
    """

    client = scripts.client('CLI Test.py', "Test script/CLI interactions")

    try:
        conn = BlitzGateway(client_obj=client)

        cli = omero.cli.CLI()
        cli.loadplugins()

        cmd = []
        cmd.extend(["login"])
        cmd.extend(["-s", "localhost"])
        # cmd.extend(["-g", conn.getGroupFromContext().getName()])
        cmd.extend(["-p", "4064"])
        cmd.extend(["-k", conn._getSessionId()])

        cli.invoke(cmd, strict=True)

    finally:
        client.closeSession()
def setup():
    """
    Defines the OMERO.scripts parameters and
    returns the created client object.
    """
    import omero.scripts as scripts
    client = scripts.client(SCRIPT_NAME,
        scripts.Long(
            "Image_ID",
            optional = False,
            description = "ID of a valid image",
            grouping = "1"),
        scripts.Long(
            "Dataset_ID",
            optional = True,
            description = "ID of a dataset to which output images should be added. If not provided,"+\
"the latest dataset which the image is contained in will be used. If the image is not in a dataset, one will be created.",
            grouping = "2"),
        scripts.Long(
            "Settings_ID",
            optional = True,
            description = "ID of a CeCog configuration file. If not provided, a default configuration will be used.",
            grouping = "3"),
        scripts.Bool(
            "Debug",
            optional = False,
            default = False,
            description = "Whether or not to print debugging text",
            grouping = "4"),
        version = "4.2.1",
        contact = "*****@*****.**",
        description = """Executes CeCog via the batch interface.""")
    return client
예제 #11
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()
def run_as_script():
    """
    The main entry point of the script, as called by the client via the scripting service, passing the required parameters.
    """

    dataTypes = [rstring('Image')]
    
    fileTypes = [k for k in FILE_TYPES.iterkeys()]

    client = scripts.client('Localisation_Density_In_ROIs.py', """This script calculates the density of localisations 
within a distance scale set by the user (`Radius`).
Do not use `Convert coordinates to nm` option on Zeiss data.""",

    scripts.String("Data_Type", optional=False, grouping="01",
        description="Choose source of images (only Image supported)", values=dataTypes, default="Image"),
        
    scripts.Int("ImageID", optional=False, grouping="02",
        description="ID of super resolved image to process"),
        
    scripts.Int("AnnotationID", optional=False, grouping="03",
        description="ID of file to process"),
        
    scripts.String("File_Type", optional=False, grouping="04",
        description="Indicate the type of data being processed", values=fileTypes, default="zeiss2D"),
                            
    scripts.Int("Radius", optional=False, grouping="05",
        description="Distance scale for calculation (in nm)", default=50),

    scripts.Bool("Convert_coordinates_to_nm", optional=False, grouping="06",
        description="Convert to nm - DO NOT USE WITH ZEISS DATA", default=False),
                            
    scripts.Int("Parent_Image_Pixel_Size", grouping="06.1",
        description="Convert the localisation coordinates to nm (multiply by parent image pixel size)"),
        
    authors = ["Daniel Matthews", "QBI"],
    institutions = ["University of Queensland"],
    contact = "*****@*****.**",
    )

    try:

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

        print scriptParams

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

        # process images in Datasets
        message = run_processing(conn, scriptParams)
        client.setOutput("Message", rstring(message))
        
        #client.setOutput("Message", rstring("No plates created. See 'Error' or 'Info' for details"))
    finally:
        client.closeSession()
def save_as_cecog():
    """
    The main entry point of the script, as called by the client via the scripting service, passing the required parameters. 
    """
    
    client = scripts.client('Save_as_Cecog.py', """Script takes a single image and saves it as single plane tiff files, named according to 
    the MetaMorph_PlateScanPackage as used by Cecog Analyzer""", 
    
    scripts.Long("Image_ID", optional=False, grouping="1",
        description="The Image you want to Save As Cecog"),
        
    version = "4.2.1",
    authors = ["William Moore", "OME Team"],
    institutions = ["University of Dundee"],
    contact = "*****@*****.**",
    )

    try:
        session = client.getSession()

        # process the list of args above.
        parameterMap = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                parameterMap[key] = client.getInput(key).getValue()

        print parameterMap

        queryService = session.getQueryService()
        updateService = session.getUpdateService()
        rawFileStore = session.createRawFileStore()
        
        curr_dir = os.getcwd()
        tiff_dir = os.path.join(curr_dir, "cecogZip")
        os.mkdir(tiff_dir)
        
        imageId = parameterMap["Image_ID"]
        image = queryService.get("Image", imageId)
        
        print "Downloading tiffs to %s" % tiff_dir
        
        split_image(client, imageId, tiff_dir, unformattedImageName = "cecog_P001_T%05d_C%s_Z%d_S1.tif", dims = ('T', 'C', 'Z'))

        zip_file_name = "Image_%s_tiffs.zip" % imageId
        zip_file = os.path.join(curr_dir, zip_file_name)
        compress(zip_file, tiff_dir)
        
        fileAnnotation = None
        if os.path.exists(zip_file_name):
            fileAnnotation = script_utils.uploadAndAttachFile(queryService, updateService, rawFileStore, image, zip_file_name, mimetype="zip")
        
        if fileAnnotation:
            client.setOutput("Message", rstring("Cecog Zip Created"))
            client.setOutput("File_Annotation", robject(fileAnnotation))
        else:
            client.setOutput("Message", rstring("Save failed - see Errors"))
            
    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()
def runScript():
    """
    The main entry point of the script, as called by the client via the scripting service, passing the required parameters. 
    """

    client = scripts.client(
        'Long_Running_Script_Test.py',
        'Writes messages at intervals to a test file ' + \
            '/<tempdir>/<File_Prefix>-<Date_Time>-<XXXX>.txt',

        scripts.String('File_Prefix', optional=False, grouping='1',
                       description='The filename prefix, [A-Za-z0-9_-].',
                       default='Test'),

        scripts.Long(
            'Log_Interval', optional=False, grouping='2', min=0,
            description='Sleep for this period between messages (seconds).',
            default=60),

        scripts.Long(
            'Number_Of_Messages', optional=False, grouping='2', min=0,
            description='Number of messages, 0 for infinite.',
            default=10),

        scripts.Long(
            'Keep_Alive_Interval', optional=False, grouping='2', min=0,
            description='Keep alive interval, 0 to disable.',
            default=0),

        version = '0.0.1',
        authors = ['Simon Li', 'OME Team'],
        institutions = ['University of Dundee'],
        contact = '*****@*****.**',
    )

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

        # process the list of args above.
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)
        message = str(scriptParams) + '\n'
        message +='Session: %s\n session id: %s\n' % (session, client.getSessionId())

        # Run the script
        message += process(client, scriptParams) + '\n'

        stopTime = datetime.now()
        message += 'Duration: %s' % str(stopTime - startTime)

        print message
        client.setOutput('Message', rstring(message))

    finally:
        client.closeSession()
예제 #16
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('Image')]
    axes = [rstring('Y'), rstring('X')]

     
    client = scripts.client('ImageJ_Processing.py',
"""
Does ImageJ 'Rotation Projection' macro processing, creating a new Image in OMERO
""",

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

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

    scripts.String("Rotation_Axis", optional=False, grouping="3",
        description="3D rotation over Y or X axis", values=axes, default="Y"),

    scripts.Bool("Use_Raw_Data", grouping="4", default=False,
        description="Convert raw pixel data to Tiff for processing? Otherwise use rendered data"),

    scripts.Int("Channel_To_Analyse", grouping="4.1", default=1, min=1,
        description="This channel will be analysed as greyscale Tiffs"),

    scripts.Bool("Analyse_ROI_Regions", grouping="5", default=False,
        description="Use Rectangle ROIs to define regions to analyse. By default analyse whole image"),


    authors = ["William Moore", "Asmi Shah"],
    institutions = ["University of Dundee", "KIT"],
    contact = "*****@*****.**",
    ) 
    
    try:
        session = client.getSession()
        scriptParams = {}

        conn = BlitzGateway(client_obj=client)

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

        robj, message = rotation_proj_stitch(conn, scriptParams)

        client.setOutput("Message", rstring(message))
        if robj is not None:
            client.setOutput("Result", robject(robj))

    finally:
        client.closeSession()
def runScript():
    """
    The main entry point of the script, as called by the client via the scripting service, passing the required parameters. 
    """

    client = scripts.client(
        'Wndcharm_Feature_Extraction_Multichannel.py',
        'Extract the small Wndcharm feature set from images',

        scripts.String('Data_Type', optional=False, grouping='1',
                       description='The data you want to work with.',
                       values=[rstring('Project'), rstring('Dataset')],
                       default='Dataset'),

        scripts.List(
            'IDs', optional=False, grouping='1',
            description='List of Dataset IDs or Image IDs').ofType(rlong(0)),

        scripts.String(
            'Context_Name', optional=False, grouping='2',
            description='The name of the classification context.',
            default='Example'),

        scripts.Bool(
            'New_Images_Only', optional=False, grouping='3',
            description='If features already exist for an image do not recalculate.',
            default=True),

        version = '0.0.1',
        authors = ['Simon Li', 'OME Team'],
        institutions = ['University of Dundee'],
        contact = '*****@*****.**',
    )

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

        # process the list of args above.
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)
        message = str(scriptParams) + '\n'

        # Run the script
        message += processImages(client, scriptParams) + '\n'

        stopTime = datetime.now()
        message += 'Duration: %s' % str(stopTime - startTime)

        print message
        client.setOutput('Message', rstring(str(message)))

    finally:
        client.closeSession()
def run_as_script():
    """
    The main entry point of the script, as called by the client via the scripting service, passing the required parameters.
    """

    dataTypes = [rstring('Image')]
    
    fileTypes = [k for k in FILE_TYPES.iterkeys()]

    client = scripts.client('Build_2D_Histogram_From_Localisations.py', """This script creates a 2D histogram from a localisation microscopy dataset""",

    scripts.String("Data_Type", optional=False, grouping="01",
        description="Choose source of images (only Image supported)", values=dataTypes, default="Image"),
        
    scripts.Int("ImageID", optional=False, grouping="02",
        description="ID of parent localisation microscopy movie"),
        
    scripts.Int("AnnotationID", optional=False, grouping="03",
        description="ID of file to process"),
        
    scripts.String("File_Type", optional=False, grouping="04",
        description="Indicate the type of data being processed", values=fileTypes, default="zeiss2D"),
        
    scripts.Int("SR_pixel_size", optional=False, grouping="05",
        description="Pixel size in super resolved image in nm"),

    scripts.Bool("Set_Parent_Pixel_Size", optional=True, grouping="06.1",
        description="Use if physical pixel size is not set in parent image", default=False),
                                                        
    scripts.Int("Parent_Image_Pixel_Size", optional=True, grouping="06.2",
        description="Convert the localisation coordinates to nm (multiply by parent image pixel size)"),
        
    authors = ["Daniel Matthews", "QBI"],
    institutions = ["University of Queensland"],
    contact = "*****@*****.**",
    )

    try:

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

        print scriptParams

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

        # process images in Datasets
        message = run_processing(conn, scriptParams)
        client.setOutput("Message", rstring(message))
        
        #client.setOutput("Message", rstring("No plates created. See 'Error' or 'Info' for details"))
    finally:
        client.closeSession()
def run_as_script():
    """
    The main entry point of the script, as called by the client via the scripting service, passing the required parameters.
    """

    dataTypes = [rstring('Image')]
    
    fileTypes = [k for k in FILE_TYPES.iterkeys()]

    client = scripts.client('Nearest_Neighbours_In_ROIs.py', """This script calculates near neighbour distances for each 
localisation in an OMERO ROI.
Do not use `Convert coordinates to nm` option on Zeiss data.""",

    scripts.String("Data_Type", optional=False, grouping="01",
        description="Choose source of images (only Image supported)", values=dataTypes, default="Image"),
        
    scripts.Int("ImageID", optional=False, grouping="02",
        description="ID of super resolved image to process"),
        
    scripts.Int("AnnotationID", optional=False, grouping="03",
        description="ID of file to process"),
        
    scripts.String("File_Type", optional=False, grouping="04",
        description="Indicate the type of data being processed", values=fileTypes, default="zeiss2D"),

    scripts.Bool("Convert_coordinates_to_nm", optional=False, grouping="05",
        description="Convert to nm - DO NOT USE WITH ZEISS DATA", default=False),
                            
    scripts.Int("Parent_Image_Pixel_Size", grouping="05.1",
        description="Convert the localisation coordinates to nm (multiply by parent image pixel size)"),
        
    authors = ["Daniel Matthews", "QBI"],
    institutions = ["University of Queensland"],
    contact = "*****@*****.**",
    )

    try:

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

        print scriptParams

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

        # process images in Datasets
        message = run_processing(conn, scriptParams)
        client.setOutput("Message", rstring(message))
        
        #client.setOutput("Message", rstring("No plates created. See 'Error' or 'Info' for details"))
    finally:
        client.closeSession()
예제 #20
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()
예제 #21
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()
예제 #22
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('Dataset'),rstring('Image')]
    
    client = scripts.client('Rename_Images.py', """\
Replace the specified string in the selected images names.
""", 
    
    scripts.String(PARAM_DATATYPE, optional=False, grouping="1.1",
        description="The data you want to work with.", values=dataTypes, 
        default="Image"),

    scripts.List(PARAM_IDS, optional=True, grouping="1.2",
        description="List of Dataset IDs or Image IDs").ofType(rlong(0)),

    scripts.Bool(PARAM_ALL_IMAGES, grouping="1.3", 
        description="Process all images (ignore the ID parameters)", 
        default=False),

    scripts.String(PARAM_SEARCH, optional=False, grouping="2",
        description="The character string you want to change.",
        default="/data/OMERO/DropBox/"),

    scripts.String(PARAM_REPLACEBY, optional=True, grouping="3",
        description="The character string that will replace the previous value.",
        default=""),

    version = "1.0",
    authors = ["Pierre Pouchin", "GReD"],
    institutions = ["Universite d'Auvergne"],
    contact = "*****@*****.**",
    ) 
    
    conn = BlitzGateway(client_obj=client)
    
    # Process the list of args above. 
    params = {}
    for key in client.getInputKeys():
      if client.getInput(key):
        params[key] = client.getInput(key, unwrap=True)
    
    # Call the main script - returns the number of images and total bytes
    count = run(conn, params)
    
    if count >= 0:
      # Combine the totals for the summary message
      msg = summary(count)
      print msg
      client.setOutput("Message", rstring(msg))

    client.closeSession()
예제 #23
0
def runAsScript():
    client = scripts.client('FLIM_initialise.py', """Sets up the namespace and keywords for the FLIM script.""",
    version = "4.2.0",
    authors = ["Donald MacDonald", "OME Team"],
    institutions = ["University of Dundee"],
    contact = "*****@*****.**",)
    try:
        session = client.getSession();
        initialise(session)
    finally:
        client.closeSession()
예제 #24
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("Dataset"),rstring("Image")]

    client = scripts.client('Clear_Outside.py', """Run the "Clear Outside" ImageJ processing on
polygon region of interest.""",

    scripts.String("Data_Type", optional=False, grouping="01",
        description="Choose source of images", values=dataTypes, default="Image"),
        
    scripts.List("IDs", optional=False, grouping="02",
        description="IDs of images to be cleared").ofType(rlong(0)),                                            
                            
    scripts.Bool("Email_Results", grouping="11", default=False,
        description="E-mail the results"),
                            
    scripts.String("Email_address", grouping="11.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)
                
        session = {}
        session['ID'] = client.getSessionId()
        session['host'] = client.getProperty('omero.host')
                
        print scriptParams
        
        # wrap client to use the Blitz Gateway
        conn = BlitzGateway(client_obj=client)

        if scriptParams['Email_Results'] and not validate_email(conn, scriptParams):
            client.setOutput("Message", rstring("No valid email address"))
            return
        
        # process images in Datasets
        robj,message = run_processing(conn, session, scriptParams)
        client.setOutput("Message", rstring(message))
        if robj is not None:
            client.setOutput("Result", robject(robj))
    finally:
        client.closeSession()
예제 #25
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'),rstring('Image'),rstring('Plate')]
    
    client = scripts.client('Restore_colors.py', """\
    Sets channel colors for chosen images.
    Can use original metadata for LIF and LSM files or
    you can choose the channel colors manually.
    """, 
    
    scripts.String(PARAM_DATATYPE, optional=False, grouping="1",
        description="The data you want to work with.", values=dataTypes, 
        default="Image"),

    scripts.List(PARAM_IDS, optional=True, grouping="1.2",
        description="List of Dataset IDs or Image IDs").ofType(rlong(0)),

    scripts.Bool(PARAM_ALL_IMAGES, grouping="1.3", 
        description="Process all images (ignore the ID parameters)", 
        default=False),

    scripts.List(PARAM_COLORS, optional=True, grouping="2.0",
        description="Manually choose colors instead of using original metadata",
        default=COLOR_PLACEHOLDER,
        values=colorOptions).ofType(rstring("")),

    version = "1.0",
    authors = ["Pierre Pouchin", "GReD"],
    institutions = ["Universite d'Auvergne"],
    contact = "*****@*****.**",
    ) 
    
    conn = BlitzGateway(client_obj=client)
    
    # Process the list of args above. 
    params = {}
    for key in client.getInputKeys():
      if client.getInput(key):
        params[key] = client.getInput(key, unwrap=True)
    
    # Call the main script - returns the number of images and total bytes
    count = run(conn, params)
    
    if count >= 0:
      # Combine the totals for the summary message
      msg = summary(count)
      print msg
      client.setOutput("Message", rstring(msg))

    client.closeSession()
def runScript():
    """
    The main entry point of the script, as called by the client via the scripting service, passing the required parameters.
    """

    client = scripts.client(
        'OMERO.searcher delete individual image feature tables',
        'Delete the image feature tables belonging to each image. '
        'Note this does not delete the entries from the ContentDB',

        scripts.String('Data_Type', optional=False, grouping='1',
                       description='The data you want to work with.',
                       values=[rstring(dt) for dt in supportedDataTypes],
                       default='Dataset'),

        scripts.List(
            'IDs', optional=False, grouping='1',
            description='List of Dataset, Project or Image IDs').ofType(rlong(0)),

        scripts.String('Feature_set', optional=False, grouping='1',
                       description='SLF set',
                       values=[rstring(f) for f in enabled_featuresets],
                       default=enabled_featuresets[0]),

        version = '0.0.1',
        authors = ['Murphy Lab'],
        institutions = ['Carnegie Mellon University'],
        contact = '*****@*****.**',
    )

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

        # process the list of args above.
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)
        message = str(scriptParams) + '\n'

        # Run the script
        message += processImages(client, scriptParams) + '\n'

        stopTime = datetime.now()
        message += 'Duration: %s' % str(stopTime - startTime)

        print message
        client.setOutput('Message', rstring(message))

    finally:
        client.closeSession()
예제 #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('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()
예제 #28
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()
예제 #29
0
def runScript():
    """
    The main entry point of the script, as called by the client
    via the scripting service, passing the required parameters.
    """

    exportOptions = [rstring('PDF'), rstring('PDF_IMAGES'),
                     rstring('TIFF'), rstring('TIFF_IMAGES')]

    client = scripts.client(
        'Figure_To_Pdf.py',
        """Used by web.figure to generate pdf figures from json data""",

        scripts.String("Figure_JSON", optional=False,
                       description="All figure info as json stringified"),

        scripts.String("Export_Option", values=exportOptions,
                       default="PDF"),

        scripts.String("Webclient_URI", grouping="4",
                       description="webclient URL for adding links to images"),

        scripts.String("Figure_Name", grouping="4",
                       description="Name of the Pdf Figure"),

        scripts.String("Figure_URI", description="URL to the Figure")
    )

    try:
        scriptParams = {}

        conn = BlitzGateway(client_obj=client)

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

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

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

    finally:
        client.closeSession()
예제 #30
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()
예제 #31
0
def runAsScript():
    client = scripts.client(
        'FLIM_initialise.py',
        """Sets up the namespace and keywords for the FLIM script.""",
        version="4.2.0",
        authors=["Donald MacDonald", "OME Team"],
        institutions=["University of Dundee"],
        contact="*****@*****.**",
    )
    try:
        session = client.getSession()
        initialise(session)
    finally:
        client.closeSession()
예제 #32
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()
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()
        client.setOutput("Message", rstring(message))

    finally:
        client.closeSession()
예제 #34
0
def runScript():
    """
    The main entry point of the script, as called by the client
    via the scripting service, passing the required parameters.
    """

    exportOptions = [
        rstring('PDF'),
        rstring('PDF_IMAGES'),
        rstring('TIFF'),
        rstring('TIFF_IMAGES')
    ]

    client = scripts.client(
        'Figure_To_Pdf.py',
        """Used by web.figure to generate pdf figures from json data""",
        scripts.String("Figure_JSON",
                       optional=False,
                       description="All figure info as json stringified"),
        scripts.String("Export_Option", values=exportOptions, default="PDF"),
        scripts.String("Webclient_URI",
                       grouping="4",
                       description="webclient URL for adding links to images"),
        scripts.String("Figure_Name",
                       grouping="4",
                       description="Name of the Pdf Figure"),
        scripts.String("Figure_URI", description="URL to the Figure"))

    try:
        scriptParams = {}

        conn = BlitzGateway(client_obj=client)

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

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

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

    finally:
        client.closeSession()
def runAsScript():
    """
    The main entry point of the script, as called by the client via the scripting service, passing the required parameters. 
    """
    
    client = scripts.client('Segger_Segmentation.py', """Run Segger segmentation on an EM-map/Image in OMERO
See http://people.csail.mit.edu/gdp/segger/docs_segmenting.html""", 
    scripts.Long("Image_ID", optional=False, grouping="1",
        description="The OMERO Image we want to segment"),
        
    scripts.Float("Threshold", optional=False, grouping="2",
        description="The threshold to apply - only voxels above this threshold will appear in the segmentation"), 
        
    scripts.Int("Smoothing_Steps", grouping="3", 
        description="""The number of smoothing iterations - at each iteration, the number
of segmented regions typically decreases; hence the more iterations,
the fewer regions that will result""", default=3),

    scripts.Int("Standard_Deviation", grouping="4",
        description="""The initial standard deviation of the smoothing filter
the higher this number, the more smoothing that occurs at each step, and
hence also the fewer the regions that will be obtained after each step""", default=1),

    scripts.Int("Target_Region_Count", grouping="5",
        description="""The number of regions we are aiming for.
If, while smoothing and grouping, the number of regions becomes lower
than this number, the process stops.""", default=1),
    )
    
    try:
        session = client.getSession()
    
        # process the list of args above. 
        parameterMap = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                parameterMap[key] = client.getInput(key).getValue()
        
        print parameterMap
        
        origFile = runSegger(session, parameterMap)
        
        if origFile == None:
            client.setOutput("Message", rstring("No segmentation file created. See Error"))
        else:
            client.setOutput("Message", rstring("Segger file attached to Image"))
            client.setOutput("Segger_File", robject(origFile))
            
    finally: client.closeSession()
예제 #36
0
def runAsScript():
	client = scripts.client('frapFigure.py', 'Create a figure of FRAP data for an image.', 
	scripts.Long("imageId").inout(),		# IDs of the image we want to analyse
	scripts.Long("theC", optional=True).inout(),		# Channel we want to analyse. Default is 0
	scripts.Long("fileAnnotation").out());  	# script returns a file annotation
	
	session = client.getSession()
	commandArgs = {}
	
	for key in client.getInputKeys():
		if client.getInput(key):
			commandArgs[key] = client.getInput(key).getValue()
	
	fileId = makeFrapFigure(session, commandArgs)
	client.setOutput("fileAnnotation",fileId)
예제 #37
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)
    
    client = scripts.client('Make_Movie','MakeMovie creates a movie of the image and attaches it to the originating image.',
    scripts.Long("Image_ID", description="The Image Identifier.", optional=False, grouping="1"),
    scripts.String("Movie_Name", description="The name of the movie", grouping="2"),
    scripts.Int("Z_Start", description="Projection range (if not specified, use defaultZ only - no projection)", min=0, default=0, grouping="3.1"),
    scripts.Int("Z_End", description="Projection range (if not specified or, use defaultZ only - no projection)", min=0, grouping="3.2"),
    scripts.Int("T_Start", description="The first time-point", min=0, default=0, grouping="4.1"),
    scripts.Int("T_End", description="The last time-point", min=0, grouping="4.2"),
    scripts.List("Channels", description="The selected channels", grouping="5").ofType(rint(0)),
    scripts.Bool("Show_Time", description="If true, display the time.", default=True, grouping="6"),
    scripts.Bool("Show_Plane_Info", description="If true, display the information about the plane e.g. Exposure Time.", default=True, grouping="7"),
    scripts.Int("FPS", description="Frames Per Second.", default=2, grouping="8"),
    scripts.Int("Scalebar", description="Scale bar size in microns. Only shown if image has pixel-size info.", min=1, grouping="9"),
    scripts.String("Format", description="Format to save movie", values=formats, default=QT, grouping="10"),
    scripts.String("Overlay_Colour", description="The colour of the scalebar.",default='White',values=cOptions, grouping="11"),
    scripts.Map("Plane_Map", description="Specify the individual planes (instead of using T_Start, T_End, Z_Start and Z_End)", grouping="12"),
    version = "4.2.0",
    authors = ["Donald MacDonald", "OME Team"],
    institutions = ["University of Dundee"],
    contact = "*****@*****.**",
    )

    try:
        session = client.getSession()
        commandArgs = {}

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

        fileAnnotation = writeMovie(commandArgs, session)
        if fileAnnotation:
            client.setOutput("Message", rstring("Movie Created"))
            client.setOutput("File_Annotation", robject(fileAnnotation))
    finally:
        client.closeSession()
def run_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()
예제 #39
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 runScript():
    """
    The main entry point of the script, as called by the client via the scripting service, passing the required parameters. 
    """

    client = scripts.client(
        'Wndcharm_Multichannel_Check.py',
        'Check all images in selected datasetes have the same channel names',

        scripts.String('Data_Type', optional=False, grouping='1',
                       description='The data you want to work with.',
                       values=[rstring('Dataset')], default='Dataset'),

        scripts.List(
            'IDs', optional=False, grouping='1',
            description='List of Dataset IDs or Image IDs').ofType(rlong(0)),

        version = '0.0.1',
        authors = ['Simon Li', 'OME Team'],
        institutions = ['University of Dundee'],
        contact = '*****@*****.**',
    )

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

        # process the list of args above.
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)
        message = str(scriptParams) + '\n'

        # Run the script
        message += processImages(client, scriptParams) + '\n'

        stopTime = datetime.now()
        message += 'Duration: %s' % str(stopTime - startTime)

        print message
        client.setOutput('Message', rstring(str(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. 
    Calls the Spider command line.
    
    """
    dataTypes = [rstring('Dataset'),rstring('Image')]
    
    client = scripts.client('Run_Spider_Procedure.py', """Run a Spider Procedure File against Images on OMERO.
See http://trac.openmicroscopy.org.uk/omero/wiki/EmPreviewFunctionality
Can process images with a single Spider command with args E.g. WI; 75,75 ; 1,75
See list at http://www.wadsworth.org/spider_doc/spider/docs/operations_doc.html""", 
    scripts.String("Data_Type", optional=False, grouping="1",
        description="The data you want to work with.", values=dataTypes, default="Dataset"),
    scripts.List("IDs", optional=False, grouping="2",
        description="List of Dataset IDs or Image IDs").ofType(rlong(0)),
    scripts.String("Spf", optional=False, grouping="3",
        description="The FileAnnotation-ID of the Spider Procedure File, OR Spider commands separated by ; E.g. WI; 75,75 ; 1,75"), 
    scripts.String("New_Dataset_Name", grouping="4", 
        description="If specified, make a dataset to put results."),
    scripts.String("Input_Name", grouping="5",
        description="The name of the input image at the start of the spf file.", default="input"),
    scripts.String("Output_Name", grouping="6",
        description="The name of the output image at the start of the spf file.", default="output"),
    )
    
    try:
        session = client.getSession()
    
        # process the list of args above. 
        parameterMap = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                parameterMap[key] = client.getInput(key).getValue()
    
        dataset, images = runSpf(session, parameterMap)
        
        if len(images) == 0:
            client.setOutput("Message", rstring("No images created. SPIDER not installed on server? See Errors"))
        else:
            print [i.getName().getValue() for i in images]
            client.setOutput("Message", rstring("SPIDER script created %s images in dataset" % len(images)))
            for i in images[-3:]:    # return last 3 images 
                client.setOutput("Image_%s" % i.getId().getValue(),robject(i))
            if dataset:
                client.setOutput("Dataset",robject(dataset))
예제 #42
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()
def run_as_script():
    """
    Main entry point of the script, as called via the scripting service.
    """

    client = scripts.client(
    	'Export_Tree_Hierarchy.py',
    	'Trigger an update of the symlink tree hierarchy on the sciCORE '
        'cluster filesystem.',
    	authors = ["Niko Ehrenfeuchter"],
    	institutions = ["IMCF, University of Basel"],
    	contact = "*****@*****.**",
    )

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

        username = conn.getUser().getName()
        markdir = os.path.join(os.environ['HOME'], '.omero_tree_export_usernames')

        if not os.path.exists(markdir):
            # do not create the marker directory, send back an error message
            # instead - the directory has to exist, otherwise the wrapper
            # daemon is not running!
            message = "ERROR: Marker directory '%s' missing!" % markdir
            client.setOutput("Message", rstring(message))
            raise IOError("directory '%s' missing!" % markdir)

        filename = os.path.join(markdir, username)

        if os.path.exists(filename):
            message = ("WARNING: a request for username '%s' is already "
                       "existing! Please contact an administrator if this "
                       "request does not get processed soon!" % username)
        else:
            message = "Requested update for username '%s'." % username
            with open(filename, 'a') as out:
                out.write('%s' % username)

        client.setOutput("Message", rstring(message))

    finally:
        # Cleanup
        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()
예제 #45
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()
예제 #46
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()
def runAsScript():
    """
    The main entry point of the script, as called by the client via the
    scripting service, passing the required parameters.
    """
    printDuration(False)    # start timer
    dataTypes = [rstring('Dataset'), rstring('Image')]

    client = scripts.client(
        'Images_From_ROIs.py',
        """Crop rectangular regions from slide scanner images. WARNING: THIS PROCESS CAN TAKE A LONG TIME - APPROX MAXIMUM BATCH SIZE IS 10 ROIs!""",

        scripts.String(
            "Data_Type", optional=False, grouping="1",
            description="Choose Images via their 'Dataset' or directly by "
            " 'Image' IDs.", values=dataTypes, default="Image"),

        scripts.List(
            "IDs", optional=False, grouping="2",
            description="List of Dataset IDs or Image IDs to "
            " process.").ofType(rlong(0)),

        scripts.String(
            "Container_Name", grouping="3",
            description="Option: put Images in new Dataset with this name",
            default="From_ROIs"),
    )

    try:
        parameterMap = client.getInputs(unwrap=True)
        print parameterMap

        # create a wrapper so we can use the Blitz Gateway.
        conn = BlitzGateway(client_obj=client)

        robj, message = make_images_from_rois(conn, parameterMap)

        client.setOutput("Message", rstring(message))
        if robj is not None:
            client.setOutput("Result", robject(robj))

    finally:
        client.closeSession()
        printDuration()
예제 #48
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()
예제 #49
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()
예제 #50
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()
예제 #51
0
def runAsScript():
    client = scripts.client()

    try:
        conn = BlitzGateway(client_obj=client)

        containerService = conn.getContainerService()
        tmp = containerService.getImages("Project", [405], None)
        ids = map(lambda img: int(img.getId()._val), tmp)
        scriptParams = {
            "Data_Type": "Image",
            "IDs": ids,
            "DryRun": True,
            "Choice": "default",
            "Combine": "no"
        }

        message = processImages(conn, scriptParams)
        client.setOutput("Message", rstring(message))

    finally:
        client.closeSession()
예제 #52
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()
예제 #53
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()
    return create_omero_figure(conn, images, frap_plots)


if __name__ == "__main__":
    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():
예제 #55
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()
예제 #56
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()
예제 #57
0
def run_script():
    """The main entry point of the script, as called by the client."""
    data_types = [
        rstring(s) for s in ['Screen', 'Plate', 'Project', 'Dataset', '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=[1, 2, 3, 4],
            description="Indices of Channels to measure intensity.").ofType(
                rint(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()
예제 #58
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()
예제 #59
0
    dataTypes = [rstring('Dataset'), rstring('Image')]

    # Here we define the script name and description.
    # Good practice to put url here to give users more guidance on how to run your script.
    client = scripts.client(
        'Edit_Descriptions.py',
        """Edits the descriptions of multiple Images,
either specified via Image IDs or by the Dataset IDs.
See http://trac.openmicroscopy.org.uk/ome/wiki/OmeroPy/ScriptingServiceGuide for the tutorial that uses this script.""",
        scripts.String("Data_Type",
                       optional=False,
                       grouping="1",
                       description="The data you want to work with.",
                       values=dataTypes,
                       default="Dataset"),
        scripts.List("IDs",
                     optional=False,
                     grouping="2",
                     description="List of Dataset IDs or Image IDs").ofType(
                         rlong(0)),
        scripts.String(
            "New_Description",
            grouping="3",
            description=
            "The new description to set for each Image in the Dataset"),
    )

    try:
        # process the list of args above. Not scrictly necessary, but useful for more complex scripts
        scriptParams = {}
        for key in client.getInputKeys():