Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

test_tdtio.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # -*- coding: utf-8 -*-
  2. """
  3. Tests of neo.io.tdtio
  4. """
  5. # needed for python 3 compatibility
  6. from __future__ import absolute_import, division
  7. import unittest
  8. from neo.io import TdtIO
  9. from neo.test.iotest.common_io_test import BaseTestIO
  10. from neo.test.iotest.tools import get_test_file_full_path
  11. import numpy as np
  12. class TestTdtIO(BaseTestIO, unittest.TestCase, ):
  13. ioclass = TdtIO
  14. files_to_test = ['aep_05']
  15. files_to_download = ['aep_05/Block-1/aep_05_Block-1.Tbk',
  16. 'aep_05/Block-1/aep_05_Block-1.Tdx',
  17. 'aep_05/Block-1/aep_05_Block-1.tev',
  18. 'aep_05/Block-1/aep_05_Block-1.tsq',
  19. 'aep_05/Block-2/aep_05_Block-2.Tbk',
  20. 'aep_05/Block-2/aep_05_Block-2.Tdx',
  21. 'aep_05/Block-2/aep_05_Block-2.tev',
  22. 'aep_05/Block-2/aep_05_Block-2.tsq',
  23. # ~ 'aep_05/Block-3/aep_05_Block-3.Tbk',
  24. # ~ 'aep_05/Block-3/aep_05_Block-3.Tdx',
  25. # ~ 'aep_05/Block-3/aep_05_Block-3.tev',
  26. # ~ 'aep_05/Block-3/aep_05_Block-3.tsq',
  27. ]
  28. def test_signal_group_mode(self):
  29. dirname = get_test_file_full_path(ioclass=TdtIO,
  30. filename='aep_05', directory=self.local_test_dir,
  31. clean=False)
  32. # TdtIO is a hard case they are 3 groups at rawio level
  33. # there are 3 groups of signals
  34. nb_sigs_by_group = [1, 16, 16]
  35. signal_group_mode = 'group-by-same-units'
  36. reader = TdtIO(dirname=dirname)
  37. bl = reader.read_block(signal_group_mode=signal_group_mode)
  38. for seg in bl.segments:
  39. assert len(seg.analogsignals) == 3
  40. i = 0
  41. for anasig in seg.analogsignals:
  42. # print(anasig.shape, anasig.sampling_rate)
  43. assert anasig.shape[1] == nb_sigs_by_group[i]
  44. i += 1
  45. signal_group_mode = 'split-all'
  46. reader = TdtIO(dirname=dirname)
  47. bl = reader.read_block(signal_group_mode=signal_group_mode)
  48. for seg in bl.segments:
  49. assert len(seg.analogsignals) == np.sum(nb_sigs_by_group)
  50. for anasig in seg.analogsignals:
  51. # print(anasig.shape, anasig.sampling_rate)
  52. assert anasig.shape[1] == 1
  53. if __name__ == "__main__":
  54. unittest.main()