docs: def _4d_to_nifti(grouped_dicoms, output_file):
      """
      This function will convert ge 4d series to a nifti
      """
  
      # Create mosaic block
      logger.info('Creating data block')
      full_block = _get_full_block(grouped_dicoms)
  
      logger.info('Creating affine')
      # Create the nifti header info
      affine, slice_increment = common.create_affine(grouped_dicoms[0])
  
      logger.info('Creating nifti')
      # Convert to nifti
      nii_image = nibabel.Nifti1Image(full_block, affine)
      common.set_tr_te(nii_image, float(grouped_dicoms[0][0].RepetitionTime),
                       float(grouped_dicoms[0][0].EchoTime))
      logger.info('Saving nifti to disk %s' % output_file)
      # Save to disk
      if output_file is not None:
          nii_image.to_filename(output_file)
  
      if _is_diffusion_imaging(grouped_dicoms):
          bval_file = None
          bvec_file = None
          # Create the bval en bevec files
          if output_file is not None:
              base_path = os.path.dirname(output_file)
              base_name = os.path.splitext(os.path.splitext(os.path.basename(output_file))[0])[0]
  
              logger.info('Creating bval en bvec files')
              bval_file = '%s/%s.bval' % (base_path, base_name)
              bvec_file = '%s/%s.bvec' % (base_path, base_name)
          bval, bvec = _create_bvals_bvecs(grouped_dicoms, bval_file, bvec_file)
          return {'NII_FILE': output_file,
                  'BVAL_FILE': bval_file,
                  'BVEC_FILE': bvec_file,
                  'NII': nii_image,
                  'BVAL': bval,
                  'BVEC': bvec,
                  'MAX_SLICE_INCREMENT': slice_increment
                  }
  
      return {'NII_FILE': output_file,
              'NII': nii_image}