datan

Reading image data with python

In [2]:
import numpy as np
import scipy
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import matplotlib as mpl
from skimage import data, io, filters
from skimage.morphology import disk
%matplotlib inline

Limitation of scipy.ndimage and matplotlib.image

Using imread() from either scipy.ndimage or maptplotlib.image results in importing only the first image of a tif (multichannel) time sequence.

In [3]:
im=scipy.ndimage.imread("/home/dati/GBM_persson/data/15.02.05_cal-GBM5-pBJclop/ph633/1_20_40.tif")
print(im.ndim, im.shape, 'max = ', im.max())
plt.imshow(im)
2 (1038, 1388) max =  3405
Out[3]:
In [4]:
im=mpl.image.imread("/home/dati/GBM_persson/data/15.02.05_cal-GBM5-pBJclop/ph633/1_20_40.tif")
print(im.ndim, im.shape, 'max = ', im.max())
plt.imshow(im)
2 (1038, 1388) max =  3405
Out[4]:

scikit-image

In [5]:
im = io.imread("/home/dati/GBM_persson/data/15.02.05_cal-GBM5-pBJclop/ph633/1_20_40.tif")
print(im.ndim, im.shape, 'max = ', im.max())
plt.imshow(im[0])
3 (20, 1038, 1388) max =  3578
Out[5]:

Conclusions

Scikit-image is the winner (over scipy.ndimage and matplotlib.image) when importing microscopy data tiff stacks (multiplanes, multichannels, multitime points).

skimage conventions are here.

This post was written entirely in the IPython notebook. You can download this notebook.