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_reachgraspio.py 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import sys
  2. from os.path import join, realpath, dirname
  3. sys.path.insert(0, join(dirname(realpath(__file__)), '..'))
  4. print(sys.path)
  5. import load_local_neo_odml_elephant
  6. import unittest
  7. import reachgraspio.reachgraspio as rg
  8. class RGIOTestCase(unittest.TestCase):
  9. def setUp(self):
  10. rio = rg.ReachGraspIO("../../datasets/i140703-001", odml_directory="../../datasets",
  11. nsx_to_load='all')
  12. self.block = rio.read_block(lazy=True)
  13. def test_group_units_present(self):
  14. unit_groups = [g for g in self.block.groups if 'Unit' in g.name]
  15. self.assertGreater(len(unit_groups), 0)
  16. self.assertGreaterEqual(len(unit_groups), len(self.block.segments[0].spiketrains))
  17. def test_channel_infos_present(self):
  18. for seg in self.block.segments:
  19. for anasig in seg.analogsignals:
  20. if anasig.annotations['neural_signal']:
  21. self.assertIn('connector_aligned_ids', anasig.array_annotations)
  22. self.assertIn('coordinates_x', anasig.array_annotations)
  23. self.assertIn('coordinates_y', anasig.array_annotations)
  24. def test_group_unit_annotations(self):
  25. for group in self.block.groups:
  26. if 'Unit' in group.name:
  27. self.assertIn('unit_id', group.annotations)
  28. self.assertIn('connector_aligned_id', group.annotations)
  29. self.assertIn('sua', group.annotations)
  30. self.assertIn('mua', group.annotations)
  31. self.assertIn('noise', group.annotations)
  32. # To be investigated
  33. # if group.annotations['unit_id'] > 0:
  34. # print(group.annotations)
  35. # self.assertIn('spike_duration', group.annotations)
  36. # self.assertIn('spike_amplitude', group.annotations)
  37. # self.assertIn('spike_count', group.annotations)
  38. def test_group_unit_linking(self):
  39. for group in self.block.groups:
  40. if 'Unit' in group.name:
  41. asig_annotations = group.channelviews[0].obj.array_annotations
  42. idx = group.channelviews[0].index
  43. self.assertEqual(group.annotations['channel_id'],
  44. asig_annotations['channel_ids'][idx])
  45. def test_rejection_annotations_present(self):
  46. for seg in self.block.segments:
  47. for anasig in seg.analogsignals:
  48. if anasig.annotations['neural_signal']:
  49. for key in ['file_origin', 'connector_ID', 'connector_pinID', 'nev_dig_factor',
  50. 'nb_sorted_units', 'nev_hi_freq_order', 'nev_hi_freq_type',
  51. 'nev_lo_freq_order', 'nev_lo_freq_type', 'nsx_hi_freq_order',
  52. 'nsx_lo_freq_order', 'nsx_hi_freq_type', 'nsx_lo_freq_type',
  53. 'description', 'nsx', 'electrode_reject_IFC',
  54. 'electrode_reject_LFC', 'electrode_reject_HFC']:
  55. self.assertIn(key, anasig.array_annotations)
  56. def test_event_annotations(self):
  57. for seg in self.block.segments:
  58. for ev in seg.events:
  59. if ev.name in ['DigitalTrialEvents', 'AnalogTrialEvents', 'TrialEvents']:
  60. for key in ['trial_event_labels', 'trial_timestamp_id', 'trial_id',
  61. 'belongs_to_trialtype', 'performance_in_trial',
  62. 'performance_in_trial_str', 'trial_reject_HFC', 'trial_reject_LFC',
  63. 'trial_reject_IFC']:
  64. self.assertIn(key, ev.array_annotations)
  65. ev_names = [ev.name for ev in seg.events]
  66. for key in ['AnalogTrialEvents', 'DigitalTrialEvents', 'TrialEvents']:
  67. self.assertIn(key, ev_names)
  68. def test_block_annotation(self):
  69. self.assertIn('conditions', self.block.annotations)
  70. self.assertGreater(len(self.block.annotations['conditions']), 0)
  71. def suite():
  72. suite = unittest.makeSuite(RGIOTestCase, 'test')
  73. return suite
  74. if __name__ == "__main__":
  75. runner = unittest.TextTestRunner(verbosity=2)
  76. runner.run(suite())