class_docstr: Template class for volumetric (3D/4D) images
class_docstr_tok: ["Template","class","for","volumetric","(","3D\/4D",")","images"]
docstr: Class method to create new instance of own class from `img`
  
  Parameters
  ----------
  img : ``spatialimage`` instance
     In fact, an object with the API of ``spatialimage`` -
     specifically ``dataobj``, ``affine``, ``header`` and ``extra``.
  
  Returns
  -------
  cimg : ``spatialimage`` instance
     Image, of our own class
docstr_tok: ["Class","method","to","create","new","instance","of","own","class","from","`","img","`","Parameters","--","--","--","--","--","img",":","``","spatialimage","``","instance","In","fact",",","an","object","with","the","API","of","``","spatialimage","``","-","specifically","``","dataobj","``",",","``","affine","``",",","``","header","``","and","``","extra","``",".","Returns","--","--","--","-","cimg",":","``","spatialimage","``","instance","Image",",","of","our","own","class"]
code: def from_image(
      klass: type[SpatialImgT], img: SpatialImage | FileBasedImage
  ) -> SpatialImgT:
      """Class method to create new instance of own class from `img`
  
      Parameters
      ----------
      img : ``spatialimage`` instance
         In fact, an object with the API of ``spatialimage`` -
         specifically ``dataobj``, ``affine``, ``header`` and ``extra``.
  
      Returns
      -------
      cimg : ``spatialimage`` instance
         Image, of our own class
      """
      if isinstance(img, SpatialImage):
          return klass(
              img.dataobj,
              img.affine,
              klass.header_class.from_header(img.header),
              extra=img.extra.copy(),
          )
      return super().from_image(img)
  
imports: from __future__ import annotations
  import io
  import typing
  from collections.abc import Sequence
  from typing import Literal
  import numpy
  from .arrayproxy import ArrayLike
  from .casting import sctypes_aliases
  from .dataobj_images import DataobjImage
  from .filebasedimages import FileBasedHeader, FileBasedImage
  from .fileholders import FileMap
  from .fileslice import canonical_slicers
  from .orientations import apply_orientation, inv_ornt_aff
  from .viewers import OrthoSlicer3D
  from .volumeutils import shape_zoom_affine
label_desc: Use image node_id 8 for calling the SpatialImage obj's underlying member method code with example usage: obj.from_image(klass, img) and returns: super, klass