Page 1 of 1

Images from ROIs script error

PostPosted: Tue Aug 04, 2015 1:18 am
by Lachie
Hi All,

For some of my current uses the "Images from ROIs" script in OMERO would be a killer application except for the fact I can't get it to work on the filers required. These are .svs files from an Aperio ScanScope system. I suspect the issue may be in the way the pixel data is stored in these files (bioformats sees them as a few series at different resolutions). Error report is attached.

Unfortunately editing the script is a little beyond my abilities at this stage (although always eager to learn) so any input from the community here would be greatly appreciated.

Thanks,
-Lachie

Re: Images from ROIs script error

PostPosted: Tue Aug 04, 2015 9:48 am
by wmoore
Hi Lachie,

You didn't add your script error, but I'm guessing it's some problem with working with big images, such as memory limits or trying to create a tiled image from a single big plane.

For example, see the discussion at viewtopic.php?f=6&t=7565
During that discussion, Dan Matthews adapted the "Images_From_ROIs" script to work with big images.

You can find the result of that here:
https://github.com/will-moore/omero_scr ... om_ROIs.py

Give it a try and let us know how it goes.
However, it can take a long time to run, depending on the size of your images.

Hope that works!

Will.

Re: Images from ROIs script error

PostPosted: Wed Aug 05, 2015 12:00 am
by Lachie
Hi Will,

Thanks for your reply, that's done the trick!

However, now I can't get the images out (granted the ROIs I'm extracting are large as well - I know it's not ideal but I'm trying to make sure my current workflows will also be possible using omero).

Omero is telling me it can't extract large images. I've done a brief search but not sure if there's a fix for this or not.

Thanks,
-Lachie

Re: Images from ROIs script error

PostPosted: Wed Aug 05, 2015 12:45 pm
by wmoore
Hi Lachie,

Glad that the image cropping worked. NB: these new images are full copies of the pixel data so will take up extra space on disk, especially since they are not compressed like the original .svs files.

In what format do you want to export the images? RGB tiff or OME-TIFF?
How big are the images you're exporting (size X & Y)?

If you want to export as 8bit TIFF (or png or jpeg) and your images are not "too big" then you can remove the check in the Batch_Image_Export script that checks for "tiled" images.

https://github.com/ome/scripts/blob/dev ... rt.py#L394

Code: Select all
        if img._prepareRE().requiresPixelsPyramid():
            log("  ** Can't export a 'Big' image to %s. **" % format)
            if len(images) == 1:
                return None, "Can't export a 'Big' image to %s." % format
            continue
        else:
            log("Exporting image as %s: %s" % (format, img.getName()))


Then select the images to export, launch the script, choosing NOT to "Export Individual Channels" (just the Merged Image) and choose TIFF (or other format) at the bottom.
This will try to get the whole rendered plane for the image and save it as a TIFF for each image in a zip file for download.
NB: if this is large, you probably want to delete the zip after download (it will be attached to the image).

This worked fine for me just now with a 4k * 6k image, but you'll have to try and see if it works for you (or causes problems for your server).

If this fails then you might need to try reading data in tiles and assembling into full images in the client?

Let us know how it goes!

Will.

Re: Images from ROIs script error

PostPosted: Tue Apr 12, 2016 5:50 pm
by labriedion
Hi Will,

I'm also trying to extract ROIs from slide scanner images. I tried your Slide_Scanner_Images_From_ROIs script (https://github.com/will-moore/omero_scr ... om_ROIs.py) and it doesn't seem to work for me. I get this error message:

Traceback (most recent call last):
File "./script", line 445, in <module>
runAsScript()
File "./script", line 434, in runAsScript
robj, message = make_images_from_rois(conn, parameterMap)
File "./script", line 326, in make_images_from_rois
images = [image for image in images if image.getROICount("Rect") > 0]
File "C:\OMERO.server\lib\python\omero\gateway\__init__.py", line 9048, in getROICount
count = sum(1 for roi in result.rois if isValidROI(roi))
File "C:\OMERO.server\lib\python\omero\gateway\__init__.py", line 9048, in <genexpr>
count = sum(1 for roi in result.rois if isValidROI(roi))
File "C:\OMERO.server\lib\python\omero\gateway\__init__.py", line 9023, in isValidROI
if isValidType(shape):
File "C:\OMERO.server\lib\python\omero\gateway\__init__.py", line 9017, in isValidType
elif isinstance(shape, getattr(omero.model, shapeType)):
AttributeError: 'module' object has no attribute 'Rect'


Do you have any idea what's causing this?

Thanks,
Étienne

Re: Images from ROIs script error

PostPosted: Tue Apr 12, 2016 7:43 pm
by sbesson
Hi Étienne,

I suspect you are running your script against a OMERO 5.2 server where omero.model.Rect has been renamed as omero.model.Rectangle - see http://www.openmicroscopy.org/site/supp ... tsnew.html. You might want apply modifications to your scripts similar to what was done in https://github.com/ome/scripts/pull/104 to fix it.

Best,
Sébastien

Re: Images from ROIs script error

PostPosted: Wed Apr 13, 2016 6:41 pm
by labriedion
Hi Sébastien,

Wow! I fixed the script and that worked perfectly, thanks! I'm quite new to all this and it was such a simple fix. Thanks for answering so fast too!

Étienne