Skip to content
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

Selecting a row in table panel loads more than the specific image for preview in case of image-/roi-based OMERO.table input #38

Open
abhamacher opened this issue Feb 10, 2023 · 4 comments

Comments

@abhamacher
Copy link

Hi Will,

to put it into the right repo, I would like to add something already mentioned at the omero-metadata repo (ome/omero-metadata#64).

During tests with omero-metadata to upload either image-based or roi-based data to plates, the following issue was observed with pradade-crossfiler:

When selecting one row of the table view panel of image- or roi-based data, only one specific image should be shown (basically the one, that is selected and highlighted in the scatter plot). However, instead of a single image all fields from the selected well are shown.

parade-crossf

This was tested with Firefox and Chrome on a Windows 10 Desktop.

BR, Anna

@will-moore
Copy link
Owner

Hi Anna,
Just looked at the logic for this..
I think it's because the code is expecting an ROI column or an Image column and is being case sensitive:

if (Number.isInteger(rowData.ROI)) {

When those aren't found, it's falling back to Well column.

I guess I need to be clearer about what's expected - or try not to be case-sensitive.
But if you want to try with re-named columns and see if that helps?

@abhamacher
Copy link
Author

Hi Will,

thanks for looking into this. Just to be clear about the expectations -- is the code expecting a number for "Image" and "ROI" or is a name also being accepted? Because I only have the names and not the OMERO internal IDs of these objects. I tested two things just now:

  1. Upload of data with plate, well and image information. I renamed column "image" to "Image". There was no change in the described behaviour. All fields are visible in the preview when selecting one row == image.

  2. Upload of data with plate, well, image and roi informtion. Renamed column "image" to "Image" and "roi" to "ROI". This is loading now only one image in the preview, but the wrong! It basically takes my ROI names (which are in this test scenario numbers) and interpretes them as ROI IDs. So it basically shows me an image from a completely different dataset:

crossfilter1a

When the ROI name cannot be resolved within OMERO (because such an ID doesn't exist, I guess), the preview stays empty:

crossfilter1

In general, being not case-sensitive is always a good idea :-)

Regards, Anna

@will-moore
Copy link
Owner

will-moore commented Feb 14, 2023

Ah, yes, Image, ROI columns are expecting OMERO IDs.

I'll look at making the column names case-insensitive, but that's not the real problem here...

I'd prefer not to add logic into the app to handle Image Names, so instead I thought it would be easiest for a "simple" python script to look up these Image IDs, based on the Well ID and Image Names...

So here is a script (below) that will take a csv like yours and replace the "Image" names with IDs, adding an "Image Name" column:

Input csv... data.csv:

Well, Image, ROI, Cell line
16052, A1-field1, 123, Hela
16053, A2-field1, 456, Hela

Usage:

$ omero login
# ...do login...
$ python lookup_image_id_for_well.py data.csv

creates out_data.csv:

Well,Image,Image_Name,ROI,Cell line
16052,4531005,A1-field1,123,Hela
16053,4531032,A2-field1,456,Hela
lookup_image_id_for_well.py
import argparse
import csv

from omero.cli import cli_login
from omero.gateway import BlitzGateway


def main(args):
    parser = argparse.ArgumentParser()
    parser.add_argument('csv')
    args = parser.parse_args(args)
    csvToRead = args.csv
    print("csvToRead", csvToRead)

    with cli_login() as cli:
        conn = BlitzGateway(client_obj=cli._client)

        row_data = []
        well_col = None
        img_name_col = None

        # cache {wellID: {"img name": img_id}}
        imagesByWell = {}

        with open(csvToRead, newline='') as csvfile:
            filereader = csv.reader(csvfile, delimiter=',', skipinitialspace=True)
            for row in filereader:
                print("row", row)
                if well_col is None:
                    # first row - find columns...
                    well_col = row.index("Well")
                    img_name_col = row.index("Image")
                    print("well_col", well_col, "img_name_col", img_name_col)
                    # add column 'Image Name' *after* 'Image' column
                    row.insert(img_name_col + 1, 'Image_Name')
                else:
                    # process row: find Image ID from Well ID and Image Name
                    well_id = row[well_col]
                    img_name = row[img_name_col]
                    if well_id not in imagesByWell:
                        # load data...
                        well = conn.getObject("Well", well_id, opts={'load_images': True})
                        imgDict = {}
                        for ws in well.listChildren():
                            img = ws.getImage()
                            imgDict[img.name] = img.id
                        imagesByWell[well_id] = imgDict
                    img_id = imagesByWell[well_id].get(img_name, "")
                    # Add Image ID under 'Image' column.
                    row.insert(img_name_col, img_id)

                row_data.append(row)
                
        with open("out_" + csvToRead, 'w', newline='') as csvfile:
            csvwriter = csv.writer(csvfile, delimiter=',')
            for row in row_data:
                csvwriter.writerow(row)


if __name__ == '__main__':
    import sys
    main(sys.argv[1:])

@will-moore
Copy link
Owner

I opened a PR #40 to be case-insensitive for various OMERO ID columns (roi, image, well, shape), but I realise that this will produce the same effect as your ROI column renaming above: That column will be interpreted as OMERO IDs and the app will try to show an ROI.

So, if we go ahead with that change, you'll need to rename the column to "roi name" or "roi_" or something.
Hopefully that's not going to cause a problem (or is something else relying on that "roi" name)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants