How to Build an Interactive Cell Selector

Greetings!

I have a grid of images like this:

What I need is each column to have its own selector column appended next to it where I can interactively select the cells (images) that I want. The selected cells will then be filtered downstream.

I’m thinking of either 1 of these selection methods:

  1. An open-ended field where a user may write a nominal value between two options (e.g. writing a dummy score of 1 to select and 0 or nothing to leave the cell unselected), OR

  2. A tickbox function in which case choosing to tick the box selects the image next to it, OR

  3. A dropdown menu with an option of ‘Select’. (For this particular case, I have looked at this workflow but since I’m not a coder, I don’t know how to alter the code for my use case.

Kindly help with this. Thank you.

P.S. Would appreciate a workflow/idea that doesn’t involve looping since I’m working with a quite huge grid table.

Hi @badger101 , I can’t see how this would work in Knime. It does not usually do “cell filter”. It does row filter and column filter as in filtering in our out a whole row or a whole column.

There are a multiple roadblocks to do this. I’m not even sure if you could create such interactivity (cell selection). But let’s say you could do this, the cell selection. How do you apply the filtering after? And can someone pick more than 1 image in a row?

If we look at the Table View node, it offers interactive selection, but it’s done on a row-base:

It allows you to select rows, and it will generate a boolean column called “selected” to indicate which rows were selected. You can then filter the rows (entire row) based on that column.

How would you do a cell filter after you implement the cell selection?

The Generic JavaScript View that you referred to can’t be used in your case, at least I can’t see how to integrate this into your table as a column. I mean, if I understood you correctly, you would want this drop down for each row, correct? You want to have the user select image/images for each of the 545 rows??

Thank you @bruno29a I haven’t used that node before this. I’ll have a look.

And to your question on multiple cell selection, the answer is yes. Also good question on the filtering method afterwards, I can see how it relates to the former. I think I’ll just have to reformat the table post-selection to a double column? (one for image and another for the selection value)

On another note, if the drop down method won’t work for this case, I’ll see what other options I have, starting with the Table View Node you suggested.

Hi @badger101 , in the mean time, I put something together for you.

Not exactly how you imagined it, but it could be an option. That would work only on the back-end though.

The workflow looks like this:
image

The way to work with this would be to open the table that has the images:

And then execute the Loop. It will popup a window for each row, asking you to enter the column number you want to select:
image
image
image

image

image
image

I have 12 rows, so I entered: 1,2,3,4,1,1,2,2,3,3,4,4

And that’s the result after:

You could select more than 1 image, but entering multiple values, with a delimiter. For example: 1,2 would mean image 1 and image 2. It’s a free text after all - you would have to add validation to the input.

Here’s the workflow: Interactive Cell Selector - sort of.knwf (26.3 KB)

3 Likes

@bruno29a That’s impressive on first look. I am yet to download the workflow. If I am to use that idea, since it fulfils my purpose, I’ll have to find a workaround to get rid of looping. Either that, or I’ll have to somehow significantly reduce my image inputs with a pre-filtering mechanism, which I don’t at the moment have, given that these images don’t have metadata to be the basis of filtering, which is one of the reasons I’m relying on visual inspection for filtration in the first place.

On the other hand, I have looked at the Table View node, and unfortunately the interactive output appears in the form of a blob of text instead of images. But it’s a really interesting node since it can filter the row interactively with the tickbox option (which is in one of my lists), and it has the added value of a searchbox (although that won’t help me unless, again, I have the images’ metadata or some kind of labeling for filtration).

Hi @badger101 , indeed having to go through the loop is quite a pain for the user, not to mention that if he/she makes a mistake, he/she would have to start all over.

When I “discarded” the Generic Javascript View, I was thinking about using it to integrate a dropdown in each row of your table, which, as I said, I don’t think it’s possible. However, I have re-visited the idea, and what could work is if you re-create the whole table, including an extra column with an interactive field, via the Generic Javascript View node. But this will require excellent knowledge of Javascript in order to:
1- Generate the table dynamically
2- Add the interactive field (free text box or drop down) with dynamic identifier
3- Implement either an event listener (such as onChange()) or a form with a submit button
4- Translate the interactive input back to the table

Doable, but not as straight forward.

Regarding the Table View, it looks like it’s an issue on your side. My images still display correctly with the Table View.

EDIT: Scratch my last comment. I see what you mean now. It looks like the Table View does not display the images correctly. It looks to be displaying their string representation (probably of their base64).

I figured out how to display them in the Table View. You have to render them as an image first using the Renderer to Image node, like this:

And that’s the interactive view I get now:

Here’s the workflow with the Table View included: Interactive Cell Selector - sort of.knwf (37.6 KB)

2 Likes

Thank you @bruno29a,

  1. When you were working on the new workflow for the Table View renderer, I was busy working on repurposing your Java Snippet idea. I have just finished reorganizing my table to prepare it to take in your looped workflow. Now I’m downloading your previous workflow to test it with my own revised table (Well, not exactly now, as soon as I’m finished writing this reply) :grinning:

  2. The new Table Renderer workflow looks promising too. Thanks for that. I’ll revisit on that too and will update here.

Alrighty. Updating on the java snippet workflow.

Here’s a snippet of the resultant table after applying it to my revised table:

The good thing is it works exactly as you described. It also tolerates the case when the user doesn’t want to score a particular row, which will result in an empty value. That makes it user friendly.

The huge issue that comes with it, which, sadly renders it unusable even to my revised table, is the fact that the popup window during selection was not designed to also pop the row of images out. Unless the user has a strong visual memory like Dr. Strange, it’s impossible to implement the selection without referring to the images visually when it matters.

I guess I’ll have to revisit the Table View renderer idea now. (On another note, the Dropdown method won’t be an option anymore, considering the way you described it would mean that I have to be a coder which I’m not).

Update on the Renderer to Image Node: What a bummer that the node only deals with PNG/SVG and at the moment I can’t figure out how to convert my JPG images to PNG in KNIME.

For converting to PNG: does this help?

1 Like

Hi @ScottF ,

I got this error shown on the console for the Tag Cloud solution:
Executing script failed after 10 attempts. The script is: ‘return document.getElementById(‘node-SINGLE’).contentWindow.knime_tag_cloud.getSVG();’

FYI my input table for the images comes from the Image Reader (Table) Node. It has JPG images rather than SVG.

I know it feels like failing on a KNIME challenge, but there are some great open source batch image conversion tools (online & desktop) that you can use pre-workflow.

I know people run ImageMagick command line batch conversions via KNIME to keep it within the workflow, but I never pulled it off. I only use it occasionally, so I just use a desktop batch conversion app pre-workflow to homogenize my image files a bit.

Also, Thanks for this thread! I had no idea this node could be used for recording user interaction. Very cool!

2 Likes

Hi @badger101 , I think I have something for you that could be useable.

You can use the Table Editor node!!!

The changes from my previous example with the Table View are these 2 nodes:

The Constant Value Column simply adds a new column, which I called “Selection”. The Table Editor allows you to choose which column is editable - in this case I choose only the “Selection”:

And now I can edit any of the rows in the column:


And that’s the result after:

Here’s the workflow: Interactive Cell Selector.knwf (28.9 KB)

With regards to jpegs, you can convert to binary, then use the Binary Objects to PNGs node. Though the name of the node says “to PNGs”, it actually works for jpegs too. You can check what I did there:

4 Likes

Hi @bruno29a those are two really great news!!! I am almost finished with working with reconstructing my upstream parts which come before this interactive part, for efficiency purposes. I’ll definitely have a look at your latest reply once I’m done. Will update here later today.

1 Like

@iCFO Thanks for the + feedback!!!

Thanks a lot @bruno29a for helping. Really appreciate it!

I have marked your last post as the solution since it works and it serves the purpose of what I was asking initially.

  1. Regarding the Renderer to Image Node, it turns out that I don’t actually have to do any conversion. No matter what the original image format is from the links I get it from, (in this case it’s in JPG), once I feed it to the Image Reader (Table) Node, the output of that can be the input of the Renderer to Image Node straight away. The key is that one needs to select the image output format that one needs (PNG/SVG), and choose the right Renderer type in the setting. In my case, the option that did the trick for me was ‘Renders thumbnails and metadata from KNIP values.’

  2. Once that was settled, I was able to visualize the image in the interactive view from the Table Viewer Node. (Finally)

  3. Having said that, both the Table Viewer and Table Editor nodes have a love-hate relationship with my desktop. Sometimes they work, sometimes they stared at me with their blank eyes! (Especially the Table Editor). I noticed this occurs only when images are involved (even when I changed the number of row to 1 just to test it out). Not when the row data is textual.

  4. Regardless, I have since made some revamp in my original idea. I’m no longer interested to do visual selection of images. I have switched to texts, and I actually like this better. The images will stay displayed in grids instead.

I’ve never tried the Table View Node until you brought it up. This interactive node is a big deal in my workflow, even though I’ve changed my original goal. All thanks to you!

2 Likes

I decided to utilize the node to show samples instead. This way I have reduced the need to use so many images which would otherwise render the node non-workable. I’m really happy with how it turned out! Here’s a glimpse of the screen. Now who’s hungry?

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.