text: import quantities as pq
  import numpy as np
  
  import pathlib
  
  import neo
  
  import exdir
  
  
  def get_data_path(action):
      action_path = action._backend.path
      project_path = action_path.parent.parent
      #data_path = action.data['main']
      data_path = str(pathlib.Path(pathlib.PureWindowsPath(action.data['main'])))
  
      print("Project path: {}\nData path: {}".format(project_path, data_path))
      return project_path / data_path
  
  
  def read_epoch(exdir_file, path, cascade=True, lazy=False):
      group = exdir_file[path]
      if lazy:
          times = []
      else:
          times = pq.Quantity(group['timestamps'].data,
                              group['timestamps'].attrs['unit'])
  
      if "durations" in group and not lazy:
          durations = pq.Quantity(group['durations'].data, group['durations'].attrs['unit'])
      elif "durations" in group and lazy:
          durations = []
      else:
          durations = None
  
      if 'data' in group and not lazy:
          if 'unit' not in group['data'].attrs:
              labels = group['data'].data
          else:
              labels = pq.Quantity(group['data'].data,
                                   group['data'].attrs['unit'])
      elif 'data' in group and lazy:
          labels = []
      else:
          labels = None
      annotations = {'exdir_path': path}
      annotations.update(group.attrs.to_dict())
  
      if lazy:
          lazy_shape = (group.attrs['num_samples'],)
      else:
          lazy_shape = None
      epo = neo.Epoch(times=times, durations=durations, labels=labels,
                  lazy_shape=lazy_shape, **annotations)
  
      return epo
  