class_docstr: A class representing data embedded in a 3D space
  
  This object has data stored in an array like, that knows how it is
  mapped to a 3D "real-world space", and how it can change real-world
  coordinate system.
  
  Attributes
  -----------
  
  world_space: string
      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 class consistency of this information is
      not maintained as the data is modified.
  _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","class","representing","data","embedded","in","a","3D","space","This","object","has","data","stored","in","an","array","like",",","that","knows","how","it","is","mapped","to","a","3D","``","real-world","space","''",",","and","how","it","can","change","real-world","coordinate","system",".","Attributes","--","--","--","--","--","-","world_space",":","string","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","class","consistency","of","this","information","is","not","maintained","as","the","data","is","modified",".","_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: Resample the data to be on the same voxel grid than the target
  volume structure.
  
  Parameters
  ----------
  target_image : nipy image
      Nipy image onto the voxel grid of which the data will be
      resampled. This can be any kind of img understood by Nipy
      (datasets, pynifti objects, nibabel object) or a string
      giving the path to a nifti of analyse image.
  interpolation : None, 'continuous' or 'nearest', optional
      Interpolation type used when calculating values in
      different word spaces. If None, the image's interpolation
      logic is used.
  
  Returns
  -------
  resampled_image : nipy_image
      New nipy image with the data resampled.
  
  Notes
  -----
  Both the target image and the original image should be
  embedded in the same world space.
docstr_tok: ["Resample","the","data","to","be","on","the","same","voxel","grid","than","the","target","volume","structure",".","Parameters","--","--","--","--","--","target_image",":","nipy","image","Nipy","image","onto","the","voxel","grid","of","which","the","data","will","be","resampled",".","This","can","be","any","kind","of","img","understood","by","Nipy","(","datasets",",","pynifti","objects",",","nibabel","object",")","or","a","string","giving","the","path","to","a","nifti","of","analyse","image",".","interpolation",":","None",",","'continuous","'","or","'nearest","'",",","optional","Interpolation","type","used","when","calculating","values","in","different","word","spaces",".","If","None",",","the","image","'s","interpolation","logic","is","used",".","Returns","--","--","--","-","resampled_image",":","nipy_image","New","nipy","image","with","the","data","resampled",".","Notes","--","--","-","Both","the","target","image","and","the","original","image","should","be","embedded","in","the","same","world","space","."]
code: def resampled_to_img(self, target_image, interpolation=None):
      """Resample the data to be on the same voxel grid than the target
      volume structure.
  
      Parameters
      ----------
      target_image : nipy image
          Nipy image onto the voxel grid of which the data will be
          resampled. This can be any kind of img understood by Nipy
          (datasets, pynifti objects, nibabel object) or a string
          giving the path to a nifti of analyse image.
      interpolation : None, 'continuous' or 'nearest', optional
          Interpolation type used when calculating values in
          different word spaces. If None, the image's interpolation
          logic is used.
  
      Returns
      -------
      resampled_image : nipy_image
          New nipy image with the data resampled.
  
      Notes
      -----
      Both the target image and the original image should be
      embedded in the same world space.
      """
      if not hasattr(target_image, "world_space"):
          from ..converters import as_volume_img
  
          target_image = as_volume_img(target_image)
      if not target_image.world_space == self.world_space:
          raise CompositionError(
              "The two images are not embedded in the same world space"
          )
      x, y, z = target_image.get_world_coords()
      new_data = self.values_in_world(
          x, y, z, interpolation=interpolation
      )
      new_img = target_image.like_from_data(new_data)
      new_img.metadata = copy.copy(self.metadata)
      return new_img
  
file_path: nipy/nipy/labs/datasets/volumes/volume_data.py
imports: import copy
  import numpy
  from ..transforms.transform import CompositionError
  from .volume_field import VolumeField
label_desc: Use image node_id 3 for calling the VolumeData obj's underlying member method code with example usage: obj.resampled_to_img(target_image, interpolation) and returns: new_img