test_openephysrawio.py 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import unittest
  2. from neo.rawio.openephysrawio import OpenEphysRawIO
  3. from neo.test.rawiotest.common_rawio_test import BaseTestRawIO
  4. class TestOpenEphysRawIO(BaseTestRawIO, unittest.TestCase, ):
  5. rawioclass = OpenEphysRawIO
  6. entities_to_test = ['OpenEphys_SampleData_1',
  7. # 'OpenEphys_SampleData_2_(multiple_starts)', # This not implemented this raise error
  8. # 'OpenEphys_SampleData_3',
  9. ]
  10. files_to_download = [
  11. # One segment
  12. 'OpenEphys_SampleData_1/101_CH0.continuous',
  13. 'OpenEphys_SampleData_1/101_CH1.continuous',
  14. 'OpenEphys_SampleData_1/all_channels.events',
  15. 'OpenEphys_SampleData_1/Continuous_Data.openephys',
  16. 'OpenEphys_SampleData_1/messages.events',
  17. 'OpenEphys_SampleData_1/settings.xml',
  18. 'OpenEphys_SampleData_1/STp106.0n0.spikes',
  19. # Multi segment with multi file
  20. # NOT implemented for now in the IO
  21. # Raise Error
  22. 'OpenEphys_SampleData_2_(multiple_starts)/101_CH0_2.continuous',
  23. 'OpenEphys_SampleData_2_(multiple_starts)/101_CH1_2.continuous',
  24. 'OpenEphys_SampleData_2_(multiple_starts)/all_channels_2.events',
  25. 'OpenEphys_SampleData_2_(multiple_starts)/Continuous_Data_2.openephys',
  26. 'OpenEphys_SampleData_2_(multiple_starts)/messages_2.events',
  27. 'OpenEphys_SampleData_2_(multiple_starts)/settings_2.xml',
  28. 'OpenEphys_SampleData_2_(multiple_starts)/STp106.0n0_2.spikes',
  29. 'OpenEphys_SampleData_2_(multiple_starts)/101_CH0.continuous',
  30. 'OpenEphys_SampleData_2_(multiple_starts)/101_CH1.continuous',
  31. 'OpenEphys_SampleData_2_(multiple_starts)/all_channels.events',
  32. 'OpenEphys_SampleData_2_(multiple_starts)/Continuous_Data.openephys',
  33. 'OpenEphys_SampleData_2_(multiple_starts)/messages.events',
  34. 'OpenEphys_SampleData_2_(multiple_starts)/settings.xml',
  35. 'OpenEphys_SampleData_2_(multiple_starts)/STp106.0n0.spikes',
  36. # Multi segment with corrupted file (CH32) : implemenetd
  37. 'OpenEphys_SampleData_3/100_CH1_2.continuous',
  38. 'OpenEphys_SampleData_3/100_CH2_2.continuous',
  39. 'OpenEphys_SampleData_3/100_CH32_2.continuous',
  40. 'OpenEphys_SampleData_3/100_CH32.continuous',
  41. 'OpenEphys_SampleData_3/all_channels_2.events',
  42. 'OpenEphys_SampleData_3/Continuous_Data_2.openephys',
  43. 'OpenEphys_SampleData_3/messages_2.events',
  44. 'OpenEphys_SampleData_3/settings_2.xml',
  45. 'OpenEphys_SampleData_3/100_CH1.continuous',
  46. 'OpenEphys_SampleData_3/100_CH2.continuous',
  47. 'OpenEphys_SampleData_3/100_CH3_2.continuous',
  48. 'OpenEphys_SampleData_3/100_CH3.continuous',
  49. 'OpenEphys_SampleData_3/all_channels.events',
  50. 'OpenEphys_SampleData_3/Continuous_Data.openephys',
  51. 'OpenEphys_SampleData_3/messages.events',
  52. 'OpenEphys_SampleData_3/settings.xml',
  53. ]
  54. def test_raise_error_if_discontinuous_files(self):
  55. # the case of discontinuous signals is NOT cover by the IO for the moment
  56. # It must raise an error
  57. reader = OpenEphysRawIO(dirname=self.get_filename_path(
  58. 'OpenEphys_SampleData_2_(multiple_starts)'))
  59. with self.assertRaises(Exception):
  60. reader.parse_header()
  61. def test_raise_error_if_strange_timestamps(self):
  62. # In this dataset CH32 have strange timestamps
  63. reader = OpenEphysRawIO(dirname=self.get_filename_path('OpenEphys_SampleData_3'))
  64. with self.assertRaises(Exception):
  65. reader.parse_header()
  66. if __name__ == "__main__":
  67. unittest.main()