npstreams.iload

npstreams.iload(files, load_func, **kwargs)

Create a stream of arrays from files, which are loaded lazily.

In cases where the consumer function is much faster than data loading, consider using pload() instead.

Parameters:
  • pattern (iterable of str or str) – Either an iterable of filenames or a glob-like pattern str.
  • load_func (callable, optional) – Function taking a filename as its first arguments
  • kwargs – Keyword arguments are passed to load_func.
Yields:

arr (~numpy.ndarray) – Loaded data.

See also

pload()
load files from parallel processes.

Examples

To load images using scikit-image

from skimage.io import imread
ims = iload('images_*.tif', imread)

Keyword arguments are passed to the load_func; for example, to specify the scikit-image plugin 'tifffile':

ims = iload('images_*.tif', imread, plugin = 'tifffile')

In case the list of images is already known:

ims = iload(['im1.tif', 'im2.tif', 'im3.tif'], imread)