Link for Image to Property Tag

9 views
Skip to first unread message

Joel Schwartz

unread,
Nov 15, 2016, 4:01:32 PM11/15/16
to Glue development discussion
Dear Glue Development Group,

I have just started working with Glue, and I was wondering if I can get some help.  I have dataset that comprises: 1)  An image that has each object defined by a different number, 1,2... 100 for connected objects.  This is generate using skimage labels and 2) A pandas dataframe that describes the morphology of each object, area, perimeter, etc. 

I have been able to generate scatter plots in Glue for the cell parameters, and I can show the image.  I would like to use Glue to highlight a sub-set of morphological properties and highlight the objects that meet that criteria. 

I have setup a common parameters, the PRIMARY for the image is equal to the label parameter.  Unfortunately, when selecting a subset the layer for the image states: Cannot visualize layer - depends on <property>. 

Am I missing something simple?

Joel

NuclearStain.tif
link_setup.tiff
cell_link.glu

Thomas Robitaille

unread,
Nov 16, 2016, 4:34:38 AM11/16/16
to glue-v...@googlegroups.com
Hi Joel,

The type of linking exposed in the Glue GUI is not designed for 1-to-1 linking but instead if you currently made a histogram of ID and selected from that histogram, it would select that range of IDs from the image. For 1-to-1 linking you instead need (for now) to resort to using the Python method 'join_on_key' - write a small script to load the data, set up the link, and start up glue:

from glue.app.qt import GlueApplication

app = GlueApplication()

d1 = app.add_data('labels.fits')
d2 = app.add_data('catalog.csv')

d1, d2 = app.data_collection

d1.join_on_key(d2, 'PRIMARY', 'id')

app.start()

Run the script - once glue opens, you will then be able to select entries in the scatter plot or table viewer and have these entries be highlighted in the image. Likewise if you select pixels in the image, it will select the entries in the catalog with corresponding ID.

If you want to also load in the original image (in my example this is MSX_E.fits), you can do this with the following:

from glue.app.qt import GlueApplication

app = GlueApplication()

d1 = app.add_data('labels.fits')
d2 = app.add_data('catalog.csv')

# Say yes when asked to merge the datasets
d3 = app.add_data('MSX_E.fits')

# The merging has swapped the order of the datasets
d2, d1 = app.data_collection

# Note that the component names have changed a little
d1.join_on_key(d2, 'labels[PRIMARY]', 'id')

app.start()

Of course, we want to expose all this through the GUI, and it is a work in progress, but for now the above code should (I think) do the trick in your case. Could you let us know if it works?

Thanks!
Tom

--
You received this message because you are subscribed to the Google Groups "Glue development discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glue-viz-dev+unsubscribe@googlegroups.com.
To post to this group, send email to glue-v...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glue-viz-dev/bd9bdbf5-f6dc-4ca6-8ba0-4abff93167e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joel Schwartz

unread,
Dec 2, 2016, 4:06:06 PM12/2/16
to glue-v...@googlegroups.com
Thomas

Sorry for the delayed response, but I was pulled away from this for to finish some other work. 

I have been able to incorporate your description here, and it appears to be working.  Unfortunately, I need to have a bit depth > 8 bit for the image that contains the labels for the individual objects.  I have tried a couple different approaches, but in each case the system seems to default to providing a 8 bit image. I tried to make float images, and scaling, etc.  

Can the system handle 16-bit images.  That would be sufficient for what I am working on 

Joel



You received this message because you are subscribed to a topic in the Google Groups "Glue development discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/glue-viz-dev/6G8uZaIT4xA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to glue-viz-dev...@googlegroups.com.

To post to this group, send email to glue-v...@googlegroups.com.

Joel Schwartz

unread,
Dec 2, 2016, 6:44:32 PM12/2/16
to glue-v...@googlegroups.com
Thomas

I take that back.  I inserted my own TIFF reader at: 

Line 22 

try:
import tifffile as tiff
return tiff.imread(file_name)
except ImportError:
pass


It works like a charm now

Joel
Reply all
Reply to author
Forward
0 new messages