code: def create_tractogram_header(
      tractogram_type, affine, dimensions, voxel_sizes, voxel_order
  ):
      """Write a standard trk/tck header from spatial attribute"""
      if isinstance(tractogram_type, str):
          tractogram_type = detect_format(tractogram_type)
  
      new_header = tractogram_type.create_empty_header()
      new_header[nib.streamlines.Field.VOXEL_SIZES] = tuple(voxel_sizes)
      new_header[nib.streamlines.Field.DIMENSIONS] = tuple(dimensions)
      new_header[nib.streamlines.Field.VOXEL_TO_RASMM] = affine
      new_header[nib.streamlines.Field.VOXEL_ORDER] = voxel_order
  
      return new_header
  
imports: import logging
  import numbers
  import os
  from dipy.utils.optpkg import optional_package
  import dipy
  import nibabel
  from nibabel.streamlines import detect_format
  from nibabel import Nifti1Image
  import numpy
  from trx import trx_file_memmap
label_desc: Use image node_id 9 for calling a global function with example usage: create_tractogram_header(tractogram_type, affine, dimensions, voxel_sizes, voxel_order) and returns: new_header