nixio_fr.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from neo.io.basefromrawio import BaseFromRaw
  2. from neo.rawio.nixrawio import NIXRawIO
  3. # This class subjects to limitations when there are multiple asymmetric blocks
  4. class NixIO(NIXRawIO, BaseFromRaw):
  5. name = 'NIX IO'
  6. _prefered_signal_group_mode = 'group-by-same-units'
  7. _prefered_units_group_mode = 'all-in-one'
  8. def __init__(self, filename):
  9. NIXRawIO.__init__(self, filename)
  10. BaseFromRaw.__init__(self, filename)
  11. def read_block(self, block_index=0, lazy=False, signal_group_mode=None,
  12. units_group_mode=None, load_waveforms=False):
  13. bl = super().read_block(block_index, lazy,
  14. signal_group_mode,
  15. units_group_mode,
  16. load_waveforms)
  17. for chx in bl.channel_indexes:
  18. if "nix_name" in chx.annotations:
  19. nixname = chx.annotations["nix_name"]
  20. chx.annotations["nix_name"] = nixname[0]
  21. return bl
  22. def __enter__(self):
  23. return self
  24. def __exit__(self, *args):
  25. self.header = None
  26. self.file.close()