class_docstr: Write data and metadata into files on disk using Nibabel.
  
  .. code-block:: python
  
      import numpy as np
      from monai.data import NibabelWriter
  
      np_data = np.arange(48).reshape(3, 4, 4)
      writer = NibabelWriter()
      writer.set_data_array(np_data, channel_dim=None)
      writer.set_metadata({"affine": np.eye(4), "original_affine": np.eye(4)})
      writer.write("test1.nii.gz", verbose=True)
class_docstr_tok: ["Write","data","and","metadata","into","files","on","disk","using","Nibabel",".","..","code-block",":",":","python","import","numpy","as","np","from","monai.data","import","NibabelWriter","np_data","=","np.arange","(","48",")",".reshape","(","3",",","4",",","4",")","writer","=","NibabelWriter","(",")","writer.set_data_array","(","np_data",",","channel_dim=None",")","writer.set_metadata","(","{","``","affine","''",":","np.eye","(","4",")",",","``","original_affine","''",":","np.eye","(","4",")","}",")","writer.write","(","``","test1.nii.gz","''",",","verbose=True",")"]
docstr: Create a Nibabel object from ``self.create_backend_obj(self.obj, ...)`` and call ``nib.save``.
  
  Args:
      filename: filename or PathLike object.
      verbose: if ``True``, log the progress.
      obj_kwargs: keyword arguments passed to ``self.create_backend_obj``,
  
  See also:
  
      - https://nipy.org/nibabel/reference/nibabel.nifti1.html#nibabel.nifti1.save
docstr_tok: ["Create","a","Nibabel","object","from","``","self.create_backend_obj","(","self.obj",",","...",")","``","and","call","``","nib.save","``",".","Args",":","filename",":","filename","or","PathLike","object",".","verbose",":","if","``","True","``",",","log","the","progress",".","obj_kwargs",":","keyword","arguments","passed","to","``","self.create_backend_obj","``",",","See","also",":","-","https",":","\/\/nipy.org\/nibabel\/reference\/nibabel.nifti1.html","#","nibabel.nifti1.save"]
code: def write(
      self, filename: PathLike, verbose: bool = False, **obj_kwargs
  ):
      """
      Create a Nibabel object from ``self.create_backend_obj(self.obj, ...)`` and call ``nib.save``.
  
      Args:
          filename: filename or PathLike object.
          verbose: if ``True``, log the progress.
          obj_kwargs: keyword arguments passed to ``self.create_backend_obj``,
  
      See also:
  
          - https://nipy.org/nibabel/reference/nibabel.nifti1.html#nibabel.nifti1.save
      """
      super().write(filename, verbose=verbose)
      self.data_obj = self.create_backend_obj(
          cast(NdarrayOrTensor, self.data_obj),
          affine=self.affine,
          dtype=self.output_dtype,
          **obj_kwargs,
      )
      if self.affine is None:
          self.affine = np.eye(4)
      # ITK v5.2.1/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx#L2175-L2176
      _affine = to_affine_nd(
          r=3, affine=convert_data_type(self.affine, np.ndarray)[0]
      )
      self.data_obj.set_sform(_affine, code=1)
      self.data_obj.set_qform(_affine, code=1)
      nib.save(self.data_obj, filename)
  
imports: from __future__ import annotations
  from collections.abc import Mapping, Sequence
  from typing import TYPE_CHECKING, Any, cast
  import numpy
  from monai.apps.utils import get_logger
  from monai.config import DtypeLike, NdarrayOrTensor, PathLike
  from monai.data.meta_tensor import MetaTensor
  from monai.data.utils import affine_to_spacing, ensure_tuple, ensure_tuple_rep, orientation_ras_lps, to_affine_nd
  from monai.transforms.spatial.array import Resize, SpatialResample
  from monai.transforms.utils_pytorch_numpy_unification import ascontiguousarray, moveaxis
  from monai.utils import GridSampleMode, GridSamplePadMode, InterpolateMode, MetaKeys, OptionalImportError, SpaceKeys, convert_data_type, convert_to_tensor, get_equivalent_dtype, look_up_option, optional_import, require_pkg
label_desc: Use image node_id 4 for calling the NibabelWriter obj's underlying member method code with example usage: obj.write(filename, verbose) without return types