Read a single plane from a multi-dimensional image

imagej-common
scifio
bio-formats
Tags: #<Tag:0x00007fb87e6649f8> #<Tag:0x00007fb87e664840> #<Tag:0x00007fb87e664598>

#1

On Sun, Sep 27, 2015 at 10:37 AM, Mongis Cyril wrote:

I would like to read a single plane from a multi-plane image (without loading the whole image into memory, and using SCIFIO or BioFormat) and convert it into a Dataset object. The ImgOpener seems to allow to read the whole image but not just a single plane. How can I do this ? Is there a service that already does it ?
I could send you the code I made but I don’t think it would be on any help. I want to use the method dataset.setPlane(int,planarAccess) but I don’t know how to get a planarAccess object from the SCIFIO reader.
reader.openPlane(…) doesn’t seems to return anything helpful/compatible. I’m completly lost T-T

I would advise against using the plane-related API methods of Dataset, since that class is going to undergo some serious changes within the next few months.

The good news is that you can achieve what you want without worrying about Dataset at all. There are a few ways:

Lastly, @hinerm might have more suggestions, since I might be forgetting something.


#2

Hi,

I’m not sure if this is better off in its own topic, but it seemed to be nice following on from this. I am attempting something similar, and I have chosen to go with “configure SCIFIO to force ImgMode.CELL”. Is there anyway that I can instruct such an image to ditch the cached pixels?

As I iterate over some large images (> 200GB) the amount of RAM consumed keeps increasing as I am iterating over more and more pixels. I would like to free up that ram after I have iterated over certain parts of the image.

P.S New to this forum (first post), sorry if this was a stupid question. Google failed me


#3

Hi @BugzyUK,

you might want to take a look at the following discussion:

There are some new (and very recent) developments with regard to caching.

Best,
Stefan


#4

@cmongis

dear Cyril,
If I’ve understood well your problem I think you can use the ImporterOptions (https://downloads.openmicroscopy.org/bio-formats/5.0.5/api/loci/plugins/in/ImporterOptions.html) and BioFormats BF (https://downloads.openmicroscopy.org/bio-formats/5.0.5/api/loci/plugins/BF.html) classes of Bio-Formats API.
I’ve used it in last months to open specific time point from a confocal multi-acquisition series.

Something like that in jython:

from loci.plugins.in import ImporterOptions
from loci.plugins import BF

file_path = "path/to/your/exp.lif" 

s = 1 #set the series number you want to read
t = 3 #set the time point you want to read

options = ImporterOptions()
options.setColorMode(ImporterOptions.COLOR_MODE_GRAYSCALE)
options.setId(file_path)
#HERE! you set the time, there are the analogous methods for Channel and Z-plane
options.setTBegin(s, t) 
options.setTEnd(s, t)  

options.setSeriesOn(s,True)
imps = BF.openImagePlus(options)

you can also check here https://gist.github.com/ctrueden/6282856 , this jython example from @ctrueden.

hoping to be helpful,
have a nice day
Emanuele