test_neuroexplorerio.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*- coding: utf-8 -*-
  2. """
  3. Tests of neo.io.neuroexplorerio
  4. """
  5. # needed for python 3 compatibility
  6. from __future__ import absolute_import, division
  7. import sys
  8. import unittest
  9. from neo.io import NeuroExplorerIO
  10. from neo.test.iotest.common_io_test import BaseTestIO
  11. from neo.test.iotest.tools import get_test_file_full_path
  12. class TestNeuroExplorerIO(BaseTestIO, unittest.TestCase, ):
  13. ioclass = NeuroExplorerIO
  14. _prefered_signal_group_mode = 'split-all'
  15. files_to_test = ['File_neuroexplorer_1.nex',
  16. 'File_neuroexplorer_2.nex',
  17. ]
  18. files_to_download = files_to_test
  19. def test_signal_group_mode(self):
  20. filename = get_test_file_full_path(ioclass=NeuroExplorerIO,
  21. filename='File_neuroexplorer_1.nex',
  22. directory=self.local_test_dir,
  23. clean=False)
  24. # test that 2 signals are rendered with 2 sampling_rate
  25. for signal_group_mode in ('group-by-same-units', 'split-all'):
  26. reader = NeuroExplorerIO(filename=filename)
  27. bl = reader.read_block(signal_group_mode=signal_group_mode)
  28. seg = bl.segments[0]
  29. assert len(seg.analogsignals) == 2
  30. anasig0 = seg.analogsignals[0]
  31. anasig1 = seg.analogsignals[1]
  32. assert anasig0.sampling_rate != anasig1.sampling_rate
  33. assert anasig0.shape != anasig1.shape
  34. # ~ for anasig in seg.analogsignals:
  35. # ~ print(anasig.shape, anasig.sampling_rate)
  36. if __name__ == "__main__":
  37. unittest.main()