Page 1 of 2

getting the image IDs and dataset ID from Script

PostPosted: Thu Dec 23, 2010 2:07 pm
by bhcho
Hi all,

Could anyone teach me how to get the image IDs, dataset ID, and project ID that I selected in the Workspace of OMERO.insight? I want to populate input text boxes of "Image ID" and "Dataset ID" automatically when I launch my script.

Best,
BK

ps. wish you a very happy holiday and a very very happy new year!

Re: getting the image IDs and dataset ID from Script

PostPosted: Fri Dec 24, 2010 8:27 am
by jburel
Hi BK

bhcho wrote:Hi all,

Could anyone teach me how to get the image IDs, dataset ID, and project ID that I selected in the Workspace of OMERO.insight? I want to populate input text boxes of "Image ID" and "Dataset ID" automatically when I launch my script.

Best,
BK

ps. wish you a very happy holiday and a very very happy new year!


The data manager keeps a reference to the currently displayed workspace.
If you only need the images,
you will find the method
Code: Select all
getDisplayedImages()
in
Code: Select all
org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent

If you want to retrieve all the objects, look at the implementation of the method
and replace
Code: Select all
db.getBrowser().getVisibleImages();

by
Code: Select all
db.getBrowser().getSelectedDataObjects()


jmarie

Re: getting the image IDs and dataset ID from Script

PostPosted: Tue Dec 28, 2010 4:47 pm
by bhcho
hi Jmarie,

thanks for the answer.
However, I can't figure out hot to use the aforementioned functions.
getDisplayedImages()
in
org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent


db.getBrowser().getVisibleImages();
by
db.getBrowser().getSelectedDataObjects()


Are these from the java code? As you know, I'm working on a python platform for the script.
I'm not sure how to use those.

BK

Re: getting the image IDs and dataset ID from Script

PostPosted: Tue Dec 28, 2010 5:04 pm
by bhcho
I was trying to follow the "Split View Figure" script. I was looking at the "Split_View_Figure.py" code, which I downloaded from " OMERO_DIR/lib/scripts/omero/figure_scripts/".

But I'm not sure if the code is really the one that is executed when I launch the script from the Insight.
there seem so many inconsistencies between the two.
for example, the code creates a List named "Image_IDs" and "Z_Start", but I don't see any of the kinds in the popup script (dialog) window.
I'm using 4.2.1.

BK

Re: getting the image IDs and dataset ID from Script

PostPosted: Tue Dec 28, 2010 5:55 pm
by jburel
Hi BK

I understood you were trying to modify the code of Insight.
The Script is the one invoked from the insight. When building a custom UI, we decided not to expose all
the parameters to the user: good, bad, it depends of the usage.
Looking at the scipt is a good start.

Jmarie

Re: getting the image IDs and dataset ID from Script

PostPosted: Wed Dec 29, 2010 4:12 pm
by bhcho
Hi Jmarie,

As I mentioned above, could you tell me how to use those aforementioned functions in my python script?
those functions look from the java OMERO API.

getDisplayedImages()
in
org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent


db.getBrowser().getVisibleImages();
by
db.getBrowser().getSelectedDataObjects()



BK

Re: getting the image IDs and dataset ID from Script

PostPosted: Wed Dec 29, 2010 7:28 pm
by jburel
Could anyone teach me how to get the image IDs, dataset ID, and project ID that I selected in the Workspace of OMERO.insight?
?
To retrieve the ID of the selected objects in insight, then look at the methods I mentioned in an early post.
Objects are not marked on the server as selected. So you will have to start from insight and pass those IDs to your python script.

Your script should have a method like the one below. Follow some pseudo-code
Code: Select all
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('BK.py', """Description goes here""",
    scripts.List("Image_IDs", optional=False, description="List of image IDs.").ofType(rlong(0)),
...
    authors = ["BK", " Team"],
    )
   
    try:
        session = client.getSession();
        gateway = session.createGateway();
        commandArgs = {}
   
        # process the list of args above.
        for key in client.getInputKeys():
            if client.getInput(key):
                commandArgs[key] = client.getInput(key).getValue()
        print commandArgs
        # call the main script here
        client.closeSession()

if __name__ == "__main__":
    runAsScript()


You can invoke your python script from insight. Look at the method in OMEROGateway.java
Code: Select all
ScriptCallback runScript(ScriptObject script)



jmarie

Re: getting the image IDs and dataset ID from Script

PostPosted: Wed Dec 29, 2010 8:10 pm
by bhcho
Jmarie,

So you will have to start from insight and pass those IDs to your python script.

This sounds scary and I look like I need to very-hardcode it from the Insight java code?

Then if I want that functionality in my script, my Insight (and my users' Insight) should be my own compiled version?


BK

Re: getting the image IDs and dataset ID from Script

PostPosted: Fri Jan 07, 2011 3:36 pm
by jennBakal
jmarie,

we are able to invoke our python scripts from within Insight. what BK and i don't understand is how to access the commands listed in your first response (getDisplayedImages and db.getBrowser().getSelectedDataObjects()) from within the python script. could you please give a more complete example?

thanks,
jenn

Re: getting the image IDs and dataset ID from Script

PostPosted: Fri Jan 07, 2011 3:54 pm
by jmoore
Hi Jenn,

sorry, there was a misunderstanding regarding those functions. Those are client-side only, part of Insight's internal API. The only state that the Python scripts is the named arguments which are retrieved via: client.getInput(), etc.

Cheers,
~Josh