nibabel.arrayproxy

Array proxy base class

The proxy API is - at minimum:

  • The object has a read-only attribute shape

  • read only is_proxy attribute / property set to True

  • the object returns the data array from np.asarray(prox)

  • returns array slice from prox[<slice_spec>] where <slice_spec> is any ndarray slice specification that does not use numpy ‘advanced indexing’.

  • modifying no object outside obj will affect the result of np.asarray(obj). Specifically:

    • Changes in position (obj.tell()) of passed file-like objects will not affect the output of from np.asarray(proxy).

    • if you pass a header into the __init__, then modifying the original header will not affect the result of the array return.

See nibabel.tests.test_proxy_api for proxy API conformance checks.

Functions

is_proxy(obj)

Return True if obj is an array proxy

reshape_dataobj(obj, shape)

Use obj reshape method if possible, else numpy reshape function

Classes

ArrayProxy(file_like, spec, *[, mmap, ...])

Class to act as proxy for the array that can be read from a file