docs: def _create_bvals_bvecs(multiframe_dicom, bval_file, bvec_file, nifti, nifti_file):
      """
      Write the bvals from the sorted dicom files to a bval file
      Inspired by https://github.com/IBIC/ibicUtils/blob/master/ibicBvalsBvecs.py
      """
  
      # create the empty arrays
      number_of_stack_slices = common.get_ss_value(multiframe_dicom[Tag(0x2001, 0x105f)][0][Tag(0x2001, 0x102d)])
      number_of_stacks = int(int(multiframe_dicom.NumberOfFrames) / number_of_stack_slices)
  
      bvals = numpy.zeros([number_of_stacks], dtype=numpy.int32)
      bvecs = numpy.zeros([number_of_stacks, 3])
  
      # loop over all timepoints and create a list with all bvals and bvecs
      for stack_index in range(0, number_of_stacks):
          stack = multiframe_dicom[Tag(0x5200, 0x9230)][stack_index]
          if str(stack[Tag(0x0018, 0x9117)][0][Tag(0x0018, 0x9075)].value) == 'DIRECTIONAL':
              bvals[stack_index] = common.get_fd_value(stack[Tag(0x0018, 0x9117)][0][Tag(0x0018, 0x9087)])
              bvecs[stack_index, :] = common.get_fd_array_value(stack[Tag(0x0018, 0x9117)][0]
                                                                [Tag(0x0018, 0x9076)][0][Tag(0x0018, 0x9089)], 3)
  
      # truncate nifti if needed
      nifti, bvals, bvecs = _fix_diffusion_images(bvals, bvecs, nifti, nifti_file)
  
      # save the found bvecs to the file
      if numpy.count_nonzero(bvals) > 0 or numpy.count_nonzero(bvecs) > 0:
          common.write_bval_file(bvals, bval_file)
          common.write_bvec_file(bvecs, bvec_file)
      else:
          bval_file = None
          bvec_file = None
          bvals = None
          bvecs = None
  
      return bvals, bvecs, bval_file, bvec_file