EBImage readImage hangs when reading tif file with multiple frames.
2
0
Entering edit mode
krassk • 0
@krassk-10739
Last seen 8.5 years ago
UC Berkeley, Berkeley, CA

Hello, I am trying to read in a tif file which contains a stack of images. I am using EBImage package.

x = readImage(paste(path,file_name,sep=""),type="tif",all=TRUE)

It never returns and I have to restart computer after that. I am using Windows 8.

The file that I am trying to read can be found here

https://www.dropbox.com/s/4vux82ed92vfgbm/DAPI_Mask.tif?dl=0

I can read tif files with single frame fine. I can also read this file with readTiff function from Tiff package.

Can you please help me with that?

Thank you,

Kristina

software error ebimage • 2.5k views
ADD COMMENT
0
Entering edit mode

I have a similar problem under 32-bit R on windows:

> system.time({x = readImage("DAPI_Mask.tif", type="tif", all=TRUE)})
Error: cannot allocate vector of size 1.1 Gb
Timing stopped at: 4.79 0.63 5.46

 

It's running out of memory. In 32-bit R, only 3GB of memory in total can be allocated.  

Perhaps the EBImage author can take a look at it and fix it. 

In the meantime, can you run 64-bit R? It looks from your sessionInfo() like your computer is capable of running the 64-bit sub-architecture. So please try it, double click on the 64-bit R shortcut/icon, or from the command line, do:

R --arch x64

64-bit R should actually be the default R that's run on systems that are capable of it, not sure why that's not the case for you. 

When I run readImage() on this file in 64-bit R on windows, it works fine.

 

ADD REPLY
0
Entering edit mode

Tried 64 bit, see session info below, same thing. I don't think it just runs out of memory, I don't get a nice error message as you did. Machine hangs to the point that I can't restart it using Ctrl-Alt-Del and have to physically turn it off. Can it be something with my EBImage installation?

Thank you

> sessionInfo()
R version 3.2.5 (2016-04-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] EBImage_4.12.2

loaded via a namespace (and not attached):
 [1] parallel_3.2.5      fftwtools_0.9-7     abind_1.4-3        
 [4] jpeg_0.1-8          grid_3.2.5          locfit_1.5-9.1     
 [7] tiff_0.1-5          BiocGenerics_0.16.1 png_0.1-7          
[10] lattice_0.20-33  

ADD REPLY
0
Entering edit mode

I don't know. BTW, I was using R-3.3.0 and Bioconductor 3.3. So perhaps try upgrading?

ADD REPLY
0
Entering edit mode
Joseph Barry ▴ 160
@joseph-barry-5000
Last seen 8.0 years ago
Dana-Farber Cancer Institute, Boston, U…

Hi Kristina,

I can open it fine with the following. The read-in only takes a few seconds.

> library(EBImage)
> x <- readImage("DAPI_Mask.tif")
> dim(x)
[1] 1024 1024  145

I'm using linux (Fedora). At least in principle that shouldn't matter though. Can you post sessionInfo()? Is your installation up to date?

 

 

 
ADD COMMENT
0
Entering edit mode

Here is sessionInfor()

R version 3.2.5 (2016-04-14)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] EBImage_4.12.2

loaded via a namespace (and not attached):
 [1] parallel_3.2.5      fftwtools_0.9-7     abind_1.4-3        
 [4] jpeg_0.1-8          grid_3.2.5          locfit_1.5-9.1     
 [7] tiff_0.1-5          BiocGenerics_0.16.1 png_0.1-7          
[10] lattice_0.20-33    

I installed EBImage couple of weeks ago and had to upgrade R at this point. And actually I have Windows 7 with service pack 1, don't know if it matters.

Thanks a lot

ADD REPLY
0
Entering edit mode
Andrzej Oleś ▴ 750
@andrzej-oles-5540
Last seen 4.0 years ago
Heidelberg, Germany

Hi Kristina,

I tried loading your image but could not reproduce the described behavior. I tried this on a Windows 7 x64 machine with 8GB RAM running R 3.2.5 with the same package versions installed as you are using. Things work fine under 64-bit R, while under 32-bit R I get the same error message as Dan.

How much memory does your machine have? You might be running out of memory, but even then this should result in an error message rather than an unresponsive system.

Once loaded into R, your image data takes up 1.1GB of RAM. This is also the size of the list returned by readTIFF which is called internally by readImage. However, before assigning this list to the data slot of the Image object some additional transformations are necessary: conversion into an array and transposition of the spatial dimensions. Unfortunately, these intermediate steps introduce temporary data copies increasing the total memory consumption. I'm not sure whether the memory footprint of readImage could be significantly improved, but even if, you will most probably run into similar issues as soon as you try to do some computations on the object.

To circumvent the problem, I suggest you either try running your script on a more powerful machine equipped with more memory, or subset the image stack. For example, have a look at RBioFormats (https://github.com/aoles/RBioFormats) which offers functionality to load a subset of frames from multi-frame images.

ADD COMMENT

Login before adding your answer.

Traffic: 862 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6