-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to decode java object returned by using javabridge? #200
Comments
Hi Malhar - glad you're using bioformats and javabridge. Look at this page for hints on how to do what you want: https://github.com/LeeKamentsky/python-javabridge/blob/master/docs/highlevel.rst In particular, you probably want to use javabridge.JWrapper. If you use it in something like a Jupyter notebook, you can use code completion to look at the available methods, I think. The tests might give you a good idea of how to use it: Hope this helps. Please close the issue if it does. |
Hey @LeeKamentsky . I appreciate your reply. The issue is my script doesn't use javabridge directly but through another package called python-bioformat. So, I am not sure if your comments apply in my case. |
They do. python-bioformats uses Javabridge under the hood. |
Yeah that is why I am not sure how to apply what you said, to my problem. |
Post the code you're using to access bioformats that returns your Java object. |
Here is my code.
It prints Here is how python-bioformat implements it, in case it helps. |
Try something like this: from javabridge.wrappers import JWrapper
if __name__ == "__main__":
javabridge.start_vm(class_path=bioformats.JARS)
tif_file_path = "/tmp/xyz.tif"
try:
with get_image_reader('my_image_key', tif_file_path) as reader:
r = reader.rdr
metadata = JWrapper(r.getMetadata())
print(metadata.toString())
print(metadata.getClass().toString())
except Exception as e:
print(e)
javabridge.kill_vm() For my TIFF file, this printed
So it's a hashtable and you can do things to look inside it like |
It alt least show some meaningful but still unable to iterate the HashTable. I use following code.
It throws
|
Tried this one.
It prints Also, tried following.
It prints |
Got success with following code.
|
I am trying to call some methods in python package
python-bioformats
that usesjavabridge
to call a java lib calledBioformats
.When I call one of those methods, it returns following.
<Java object at 0x246ef80>
How can I check what this object is and how can I use it in python? Docs in
Bioformats
says it should be HashTable. If it is, I have no idea how to iterate it.The text was updated successfully, but these errors were encountered: