Skip to content

Commit 1219d39

Browse files
committed
DOC: rewrite docstring for get_data
Use "array image" instead of "in-memory image". Rewrite a little with the experience of writing the main documentation.
1 parent fa1ea86 commit 1219d39

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

nibabel/spatialimages.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -451,16 +451,20 @@ def __str__(self):
451451
def get_data(self, caching='fill'):
452452
""" Return image data from image with any necessary scalng applied
453453
454-
If the image data is an array proxy (an object that knows how to load
455-
the image data from disk) then the default behavior (`caching` ==
456-
"fill") is to read the data from the proxy, and store in an internal
457-
cache. Future calls to ``get_data`` will return the cached array.
454+
The image ``dataobj`` property can be an array proxy or an array. An
455+
array proxy is an object that knows how to load the image data from
456+
disk. An image with an array proxy ``dataobj`` is a *proxy image*; an
457+
image with an array in ``dataobj`` is an *array image*.
458458
459-
Once the data has been cached and returned from an image array proxy,
460-
if you modify the returned array, you will also modify the cached
461-
array (because they are the same array). Regardless of the `caching`
462-
flag, this is always true of an in-memory image (where the image data
463-
is an array rather than an array proxy).
459+
The default behavior for ``get_data()`` on a proxy image is to read the
460+
data from the proxy, and store in an internal cache. Future calls to
461+
``get_data`` will return the cached array. This is the behavior
462+
selected with `caching` == "fill"`.
463+
464+
Once the data has been cached and returned from an array proxy, if you
465+
modify the returned array, you will also modify the cached array
466+
(because they are the same array). Regardless of the `caching` flag,
467+
this is always true of an array image.
464468
465469
Parameters
466470
----------
@@ -494,19 +498,17 @@ def get_data(self, caching='fill'):
494498
data. Images that have been loaded from files usually do not load the
495499
array data from file immediately, in order to reduce image load time
496500
and memory use. For these images, ``dataobj`` is an *array proxy*; an
497-
object that knows how to load the image array data from file. Images
498-
with an array proxy ``dataobj`` are called *proxy images*. In contrast,
499-
images created directly from numpy arrays carry a simple reference to
500-
their array data in ``dataobj``. These are *in-memory images*.
501+
object that knows how to load the image array data from file.
501502
502503
By default (`caching` == "fill"), when you call ``get_data`` on a
503504
proxy image, we load the array data from disk, store (cache) an
504505
internal reference to this array data, and return the array. The next
505506
time you call ``get_data``, you will get the cached reference to the
506507
array, so we don't have to load the array data from disk again.
507508
508-
In-memory images are already in memory, so there is no benefit to
509-
caching, and the `caching` keywords have no effect.
509+
Array images have a ``dataobj`` property that already refers to an
510+
array in memory, so there is no benefit to caching, and the `caching`
511+
keywords have no effect.
510512
511513
For proxy images, you may not want to fill the cache after reading the
512514
data from disk because the cache will hold onto the array memory until
@@ -518,7 +520,7 @@ def get_data(self, caching='fill'):
518520
the cache full and returns the cached array reference.
519521
520522
The cache can effect the behavior of the image, because if the cache is
521-
full, or you have an in-memory image, then modifying the returned array
523+
full, or you have an array image, then modifying the returned array
522524
will modify the result of future calls to ``get_data()``. For example
523525
you might do this:
524526

0 commit comments

Comments
 (0)