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.

unit.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # -*- coding: utf-8 -*-
  2. '''
  3. This module defines :class:`Unit`, a container of :class:`SpikeTrain` objects
  4. from a unit.
  5. :class:`Unit` derives from :class:`Container`,
  6. from :module:`neo.core.container`.
  7. '''
  8. # needed for python 3 compatibility
  9. from __future__ import absolute_import, division, print_function
  10. import numpy as np
  11. from neo.core.container import Container
  12. class Unit(Container):
  13. '''
  14. A container of :class:`SpikeTrain` objects from a unit.
  15. A :class:`Unit` regroups all the :class:`SpikeTrain`
  16. objects that were emitted by a single spike source during a :class:`Block`.
  17. A spike source is often a single neuron but doesn't have to be. The spikes
  18. may come from different :class:`Segment` objects within the :class:`Block`,
  19. so this object is not contained in the usual :class:`Block`/
  20. :class:`Segment`/:class:`SpikeTrain` hierarchy.
  21. A :class:`Unit` is linked to :class:`ChannelIndex` objects from
  22. which it was detected. With tetrodes, for instance, multiple channels may
  23. record the same :class:`Unit`.
  24. *Usage*::
  25. >>> from neo.core import Unit, SpikeTrain
  26. >>>
  27. >>> unit = Unit(name='pyramidal neuron')
  28. >>>
  29. >>> train0 = SpikeTrain(times=[.01, 3.3, 9.3], units='sec', t_stop=10)
  30. >>> unit.spiketrains.append(train0)
  31. >>>
  32. >>> train1 = SpikeTrain(times=[100.01, 103.3, 109.3], units='sec',
  33. ... t_stop=110)
  34. >>> unit.spiketrains.append(train1)
  35. *Required attributes/properties*:
  36. None
  37. *Recommended attributes/properties*:
  38. :name: (str) A label for the dataset.
  39. :description: (str) Text description.
  40. :file_origin: (str) Filesystem path or URL of the original data file.
  41. Note: Any other additional arguments are assumed to be user-specific
  42. metadata and stored in :attr:`annotations`.
  43. *Container of*:
  44. :class:`SpikeTrain`
  45. '''
  46. _data_child_objects = ('SpikeTrain',)
  47. _single_parent_objects = ('ChannelIndex',)
  48. _recommended_attrs = Container._recommended_attrs
  49. def __init__(self, name=None, description=None, file_origin=None,
  50. **annotations):
  51. '''
  52. Initialize a new :clas:`Unit` instance (spike source)
  53. '''
  54. super(Unit, self).__init__(name=name, description=description,
  55. file_origin=file_origin, **annotations)
  56. self.channel_index = None
  57. def get_channel_indexes(self):
  58. """
  59. """
  60. if self.channel_index:
  61. return self.channel_index.index
  62. else:
  63. return None