class_docstr: A regularly-spaced image for embedding data in an x, y, z 3D
  world, for neuroimaging.
  
  This object is an ndarray representing a volume, with the first 3
  dimensions being spatial, and mapped to a named world space using
  an affine (4x4 matrix).
  
  Attributes
  ----------
  
  affine : 4x4 ndarray
      Affine mapping from indices to world coordinates.
  world_space : string
      Name of the world space the data is embedded in. For
      instance `mni152`.
  metadata : dictionary
      Optional, user-defined, dictionary used to carry around
      extra information about the data as it goes through
      transformations. The consistency of this information may not
      be maintained as the data is modified.
  interpolation : 'continuous' or 'nearest'
      String giving the interpolation logic used when calculating
      values in different world spaces
  _data :
      Private pointer to the data.
  
  Notes
  ------
  
  The data is stored in an undefined way: prescalings might need to
  be applied to it before using it, or the data might be loaded on
  demand. The best practice to access the data is not to access the
  _data attribute, but to use the `get_fdata` method.
class_docstr_tok: ["A","regularly-spaced","image","for","embedding","data","in","an","x",",","y",",","z","3D","world",",","for","neuroimaging",".","This","object","is","an","ndarray","representing","a","volume",",","with","the","first","3","dimensions","being","spatial",",","and","mapped","to","a","named","world","space","using","an","affine","(","4x4","matrix",")",".","Attributes","--","--","--","--","--","affine",":","4x4","ndarray","Affine","mapping","from","indices","to","world","coordinates",".","world_space",":","string","Name","of","the","world","space","the","data","is","embedded","in",".","For","instance","`","mni152","`",".","metadata",":","dictionary","Optional",",","user-defined",",","dictionary","used","to","carry","around","extra","information","about","the","data","as","it","goes","through","transformations",".","The","consistency","of","this","information","may","not","be","maintained","as","the","data","is","modified",".","interpolation",":","'continuous","'","or","'nearest'","String","giving","the","interpolation","logic","used","when","calculating","values","in","different","world","spaces","_data",":","Private","pointer","to","the","data",".","Notes","--","--","--","The","data","is","stored","in","an","undefined","way",":","prescalings","might","need","to","be","applied","to","it","before","using","it",",","or","the","data","might","be","loaded","on","demand",".","The","best","practice","to","access","the","data","is","not","to","access","the","_data","attribute",",","but","to","use","the","`","get_fdata","`","method","."]
docstr: Creates a new neuroimaging image with an affine mapping.
  
  Parameters
  ----------
  
  data : ndarray
      ndarray representing the data.
  affine : 4x4 ndarray
      affine transformation to the reference world space
  world_space : string
      name of the reference world space.
  metadata : dictionary
      dictionary of user-specified information to store with
      the image.
docstr_tok: ["Creates","a","new","neuroimaging","image","with","an","affine","mapping",".","Parameters","--","--","--","--","--","data",":","ndarray","ndarray","representing","the","data",".","affine",":","4x4","ndarray","affine","transformation","to","the","reference","world","space","world_space",":","string","name","of","the","reference","world","space",".","metadata",":","dictionary","dictionary","of","user-specified","information","to","store","with","the","image","."]
code: def __init__(
      self,
      data,
      affine,
      world_space,
      metadata=None,
      interpolation="continuous",
  ):
      """Creates a new neuroimaging image with an affine mapping.
  
      Parameters
      ----------
  
      data : ndarray
          ndarray representing the data.
      affine : 4x4 ndarray
          affine transformation to the reference world space
      world_space : string
          name of the reference world space.
      metadata : dictionary
          dictionary of user-specified information to store with
          the image.
      """
      if interpolation not in ("continuous", "nearest"):
          raise ValueError(
              "interpolation must be either continuous " "or nearest"
          )
      self._data = data
      if not affine.shape == (4, 4):
          raise ValueError("The affine should be a 4x4 array")
      self.affine = affine
      self.world_space = world_space
      if metadata is None:
          metadata = {}
      self.metadata = metadata
      self.interpolation = interpolation
  
imports: import copy
  import numpy
  from scipy import ndimage
  from ..transforms.affine_transform import AffineTransform
  from ..transforms.affine_utils import from_matrix_vector, get_bounds, to_matrix_vector
  from ..transforms.transform import CompositionError
  from .volume_grid import VolumeGrid
label_desc: Use image node_id 1 to create a new VolumeImg object from inherited base classes: VolumeGrid with example: obj = VolumeImg(data, affine, world_space, metadata, interpolation)