Import image from OMERO in Fiji using Python

Hi all,

Is there a simple way to get a file open using Bio-Formats in python with something like this ?

def openImagePlus(HOST, USERNAME, PASSWORD, groupId, imageId):
    options = ImporterOptions()
    options.setStackFormat("Hyperstack")
    options.setStackOrder("XYCZT")
    options.setGroupFiles(False)
    options.setSwapDimensions(False)
    options.setOpenAllSeries(False)
    options.setConcatenate(False)
    options.setStitchTiles(False)
    options.setColorMode("Default")
    options.setAutoscale(True)
    options.setVirtual(False)
    options.setSpecifyRanges(False)
    options.setCrop(False)
    options.setSplitChannels(False)
    options.setSplitFocalPlanes(False)
    options.setSplitTimepoints(False)
    options.setWindowless(False)
    options.setShowMetadata(False)
    options.setShowOMEXML(False)
    options.setShowROIs(True)
    options.setROIsMode("ROI manager")
    options.setLocation("OMERO")

The rest of the script works but I’m a bit lost on how to get BF to open the file that way.

EDIT:

Why is “OMERO” not a possible value in setLocation while it clearly says so here ?

Thanks !

Hi @lguerard

Is there a simple way to get a file open using Bio-Formats in python with something like this ?

I’m a bit lost on how to get BF to open the file that way.

There are a few complete examples that you might want to take a look at in:

If those don’t help, can you show us the rest of your code?

Why is “OMERO” not a possible value in setLocation while it clearly says so … ?

The second example above sets location=[OMERO]. What error are you seeing when trying to use this?

Regards,
~Josh

1 Like

Hi Josh,

Thanks a lot for your answer ! :slight_smile:

The reason I was asking for a different way is because it seems that the import is actually bypassing some settings we have and using the last ones used with windowless = false

Here is the function we’re using:

def openImagePlus(HOST,USERNAME,PASSWORD,groupId,imageId):
    stackview = "stackFormat=Hyperstack stackOrder=XYCZT "
    datasetorg = "groupFiles=false swapDimensions=false openAllSeries=false concatenate=false stitchTiles=false"
    coloropt = "colorMode=Default autoscale=true"
    memorymanage = "virtual=false specifyRanges=false crop=false"
    split = " splitWindows=false splitFocalPlanes=false splitTimepoints=false"
    other = "windowless=true"
    metadataview = "showMetadata=false showOMEXML=false showROIs=false roiMode=[ROI manager]"
    options = ("location=[OMERO] open=[omero:server=%s\nuser=%s\npass=%s\ngroupID=%s\niid=%s] %s %s %s %s %s %s %s " %
    		   (HOST, USERNAME, PASSWORD, groupId, imageId, stackview, datasetorg, coloropt, metadataview, memorymanage, split, other ))
    IJ.runPlugIn("loci.plugins.LociImporter", options);

If I change showROIs between true or false, it actually doesn’t change and uses the last settings with the GUI.

Hope I’m clear enough ^^’

1 Like

Hi @lguerard, I was able to reproduce the issue using the same command. After much debugging I believe I have found the issue, when the LociImporter is parsing the boolean options it appears to be converting the keys to lower case. Changing your options to use showrois=false as lower case should work as a short term solution. I will look at fixing this parsing for the future though so that it is not case sensitive.

1 Like

Hi @dgault,

Thanks a lot for finding the solution ! I just tested it now and it worked ! :slight_smile: