Hi, Is there a way to open a file browser window from omero script gui?
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?
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.
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:
- let the user enter the omero credentials
- select a local file to import
- import the file into a new dataset (the name is hard-coded in the script)
You can find the example at https://github.com/ome/training-scripts/pull/69
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.
Sorry about that. OMERO script UI in this page:
Unfortunately as it stands we do not support such feature, we could consider adding a new type
"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
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
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?
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.
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)
there are a couple important aspects of the use-case Memphizz is describing.
- As mentioned above, the files are located server side.
- 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 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.
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.
Looks like a very similar request at Omero scripts interactive parameter loading