We're Hiring!

getting the image IDs and dataset ID from Script

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

getting the image IDs and dataset ID from Script

Postby bhcho » Thu Dec 23, 2010 2:07 pm

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!
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: getting the image IDs and dataset ID from Script

Postby jburel » Fri Dec 24, 2010 8:27 am

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
User avatar
jburel
Team Member
 
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee

Re: getting the image IDs and dataset ID from Script

Postby bhcho » Tue Dec 28, 2010 4:47 pm

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
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: getting the image IDs and dataset ID from Script

Postby bhcho » Tue Dec 28, 2010 5:04 pm

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
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: getting the image IDs and dataset ID from Script

Postby jburel » Tue Dec 28, 2010 5:55 pm

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
User avatar
jburel
Team Member
 
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee

Re: getting the image IDs and dataset ID from Script

Postby bhcho » Wed Dec 29, 2010 4:12 pm

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
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: getting the image IDs and dataset ID from Script

Postby jburel » Wed Dec 29, 2010 7:28 pm

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
User avatar
jburel
Team Member
 
Posts: 348
Joined: Thu May 21, 2009 6:38 pm
Location: dundee

Re: getting the image IDs and dataset ID from Script

Postby bhcho » Wed Dec 29, 2010 8:10 pm

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
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: getting the image IDs and dataset ID from Script

Postby jennBakal » Fri Jan 07, 2011 3:36 pm

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
jennBakal
 
Posts: 18
Joined: Fri Dec 10, 2010 4:45 am

Re: getting the image IDs and dataset ID from Script

Postby jmoore » Fri Jan 07, 2011 3:54 pm

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
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Next

Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 1 guest