unit.py 2.5 KB

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