File browser in omero script gui

Hi, Is there a way to open a file browser window from omero script gui?

Hi @memphizz,

no, there’s not. What it is it you’d like to achieve? See the results from the script in the GUI? Interact with the script?

~Josh

Hi Josh. The script is used to import a slidebook file from a lattice light sheet instrument as it acquires and do SIM reconstruction and deskew during import. I was hoping that we could have a file browser that allows users select a file as script input.

Hi @memphizz

One option could be to used the scripting facility of Fiji.
You will first need to install the OMERO.insight-ij plugin (see https://help.openmicroscopy.org/imagej.html).
I wrote a simple groovy script doing the following:

Cheers

Jmarie

Thanks for the tip. For this application, a few processing steps happen outside fiji during import which makes fiji route difficult. Currently we have a fixed folder that users can store their data and it is mounted on the server. We give a list of existing files as a drop-down in the gui, but as the number of files increase it becomes difficult to find the files in the drop-down.

Which GUI are you referring to?
This points is a bit unclear.

Thanks

Sorry about that. OMERO script UI in this page:
https://docs.openmicroscopy.org/omero/5.4.5/developers/scripts/style-guide.html

Hi @memphizz

Unfortunately as it stands we do not support such feature, we could consider adding a new type
i.e.
"scripts.Dialog("file", description="Choose files", default="File")
default could be folder and use something like tkinter to pop up a selection dialog

I will open a GitHub issue
Thanks

Jmarie

That would be really helpful. How complex is adding this feature?

I don’t think it will be too complex.
We are in the process of migrating our Python code base to Python 3.
We can look into adding this RFE when the work is complete.
GitHub issue created https://github.com/ome/openmicroscopy/issues/6095
Feel free to add comment

Currently, the scripting service can only receive files as OMERO FileAnnotations or OriginalFile. I don’t know how hard it will be to pass a file from the UI in a client to the scripting service via the OMERO server without first creating an OriginalFile on the server, but it seems it could be quite tricky.
So, assuming we need to use a FileAnnotation, I opened a PR to do that at https://github.com/ome/openmicroscopy/pull/6096

Having read this discussion more carefully, I see that you’re wanting to browse a File System that’s server-side, allowing the script to read files directly.
@memphizz if you are able to share your current script, that would be helpful in understanding your current use-case.
Are you currently hard-coding a list of available files, or auto-populating a list when the script is launched? Does the script read the file directly from the mounted folder?
I’m not sure that the OMERO API can be used to allow a client to browse a mounted directory? So this might need more than a client-side file-picker.
Also, are you using the webclient or Insight for launching scripts?
Thanks,
Will.

I’d also add that by default the script will be able to view all files that the OMERO server can view and so allowing arbitrary file reading by the script can pose a security risk. Either you will want to run the script processor as a second user or your script will need to take care of authorizing all file requests.

~Josh

Hi Will,
below is the code snippet for getting list of all files in a NAS storage that is mounted on omero server. Users have read and write access to the NAS location and directly write slidebook files from the instrument. Once the instrument starts acquiring, they start the import script by finding the file in the NAS location in the UI drop-down. It would be helpful to have a file browser instead of the UI drop-down. We also thought about filtering the file list by a keyword (user input) but not sure if it’s possible to dynamically create the file list once UI is initialized.

sld_directory = "/media/nas/"
output_directory = "/media/InPlaceData/"
helper = dnb_slidebook_helper(sld_directory, output_directory, debug_print=False, batch_size = 16)
slides = helper.get_slidebook_list()
.
.
.
scripts.String( "Slidebook", optional=False, grouping="1",
            description="Please select Slidebook to convert",
            values=slides, default=slides[0])

Hi, All,
there are a couple important aspects of the use-case Memphizz is describing.

  1. As mentioned above, the files are located server side.
  2. The selected file could be changing. That is, the script processes the file while it is being written by another process.

Because of 2), the script isn’t uploading the file directly. It processes the file and uploads the result of the processing. In the script’s current form, a list of files is generated as the UI is being created, and the user then chooses from that list.
The list has become so long as to be unwieldy for the user. (Hopefully, this comment clarifies more than it confuses, but I’m not sure…)
Thanks,
Michael

Thanks for the clarification. That certainly helps us understand the issue better.

Would the usage of an auto-complete widget be useful such as https://harvesthq.github.io/chosen/ which we use in other places? This would allow you to filter the list by keyword etc.
We could try using this if the number of options exceeds e.g. 20 items.

Regards,
Will.

Hi @will-moore, an auto-complete would certainly solve the problem. Is there a way to add the functionality to our current omero installation?

The change is quite minor. I opened a PR with it at https://github.com/ome/openmicroscopy/pull/6099 but this won’t be released anytime soon.

Will.

Looks like a very similar request at Omero scripts interactive parameter loading