code: def _annotate_bad_segments(directory, start_time, meas_date):
      fname = op.join(directory, "bad.segments")
      if not op.exists(fname):
          return None
  
      # read in bad segment file
      onsets = []
      durations = []
      desc = []
      with open(fname) as fid:
          for f in fid.readlines():
              tmp = f.strip().split()
              desc.append("bad_%s" % tmp[0])
              onsets.append(np.float64(tmp[1]) - start_time)
              durations.append(np.float64(tmp[2]) - np.float64(tmp[1]))
      # return None if there are no bad segments
      if len(onsets) == 0:
          return None
  
      return Annotations(onsets, durations, desc, meas_date)
  
imports: import os.path
  from calendar import timegm
  from time import strptime
  import numpy
  from ..._fiff.constants import FIFF
  from ..._fiff.ctf_comp import _add_kind, _calibrate_comp
  from ..._fiff.meas_info import _empty_info
  from ..._fiff.write import get_new_file_id
  from ...annotations import Annotations
  from ...transforms import _coord_frame_name, apply_trans, combine_transforms, invert_transform
  from ...utils import _clean_names, logger, warn
  from .constants import CTF
label_desc: Use image node_id 15 for calling a global function with example usage: _annotate_bad_segments(directory, start_time, meas_date) and returns: Annotations, None, None