code: def test_io_save_peaks_error(rng):
      with TemporaryDirectory() as tmpdir:
          fname = "test.pam5"
  
          pam = PeaksAndMetrics()
  
          npt.assert_raises(
              OSError, save_peaks, pjoin(tmpdir, "test.pam"), pam
          )
          npt.assert_raises(
              (ValueError, AttributeError),
              save_peaks,
              pjoin(tmpdir, fname),
              pam,
          )
  
          pam.affine = np.eye(4)
          pam.peak_dirs = rng.random((10, 10, 10, 5, 3))
          pam.peak_values = np.zeros((10, 10, 10, 5))
          pam.peak_indices = np.zeros((10, 10, 10, 5))
          pam.shm_coeff = np.zeros((10, 10, 10, 45))
          pam.sphere = default_sphere
          pam.B = np.zeros((45, default_sphere.vertices.shape[0]))
          pam.total_weight = 0.5
          pam.ang_thr = 60
          pam.gfa = np.zeros((10, 10, 10))
          pam.qa = np.zeros((10, 10, 10, 5))
          pam.odf = np.zeros(
              (10, 10, 10, default_sphere.vertices.shape[0])
          )
  
file_path: dipy/dipy/io/tests/test_io_peaks.py
imports: import os
  from os.path import join
  from tempfile import TemporaryDirectory
  import numpy
  import numpy.testing
  from dipy.direction.peaks import PeaksAndMetrics
  from dipy.data import default_sphere
  from dipy.io.peaks import load_peaks, save_peaks, peaks_to_niftis
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 2 for calling a global function with example usage: test_io_save_peaks_error(rng) without return types