code: def save_fibers(oldhdr, oldfib, fname, indices):
      """Stores a new trackvis file fname using only given indices"""
      hdrnew = oldhdr.copy()
      outstreams = []
      for i in indices:
          outstreams.append(oldfib[i])
      n_fib_out = len(outstreams)
      hdrnew["n_count"] = n_fib_out
      iflogger.info("Writing final non-orphan fibers as %s", fname)
      nb.trackvis.write(fname, outstreams, hdrnew)
      return n_fib_out
  
imports: import pickle
  import os.path
  import numpy
  import nibabel
  import networkx
  from ...None import logging
  from ...utils.filemanip import split_filename
  from ..base import BaseInterface, BaseInterfaceInputSpec, traits, File, TraitedSpec, Directory, OutputMultiPath, isdefined
label_desc: Use image node_id 7 for calling a global function with example usage: save_fibers(oldhdr, oldfib, fname, indices) and returns: n_fib_out