axographio.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. """
  2. AxographIO
  3. ==========
  4. IO class for reading AxoGraph files (.axgd, .axgx)
  5. """
  6. from neo.io.basefromrawio import BaseFromRaw
  7. from neo.rawio.axographrawio import AxographRawIO
  8. class AxographIO(AxographRawIO, BaseFromRaw):
  9. """
  10. IO class for reading AxoGraph files (.axgd, .axgx)
  11. Args:
  12. filename (string):
  13. File name of the AxoGraph file to read.
  14. force_single_segment (bool):
  15. Episodic files are normally read as multi-Segment Neo objects. This
  16. parameter can force AxographIO to put all signals into a single
  17. Segment. Default: False.
  18. Example:
  19. >>> import neo
  20. >>> r = neo.io.AxographIO(filename=filename)
  21. >>> blk = r.read_block(signal_group_mode='split-all')
  22. >>> display(blk)
  23. >>> # get signals
  24. >>> seg_index = 0 # episode number
  25. >>> sigs = [sig for sig in blk.segments[seg_index].analogsignals
  26. ... if sig.name in channel_names]
  27. >>> display(sigs)
  28. >>> # get event markers (same for all segments/episodes)
  29. >>> ev = blk.segments[0].events[0]
  30. >>> print([ev for ev in zip(ev.times, ev.labels)])
  31. >>> # get interval bars (same for all segments/episodes)
  32. >>> ep = blk.segments[0].epochs[0]
  33. >>> print([ep for ep in zip(ep.times, ep.durations, ep.labels)])
  34. >>> # get notes
  35. >>> print(blk.annotations['notes'])
  36. """
  37. name = 'AxographIO'
  38. description = 'This IO reads .axgd/.axgx files created with AxoGraph'
  39. _prefered_signal_group_mode = 'group-by-same-units'
  40. _default_group_mode_have_change_in_0_9 = True
  41. def __init__(self, filename='', force_single_segment=False):
  42. AxographRawIO.__init__(self, filename, force_single_segment)
  43. BaseFromRaw.__init__(self, filename)