buffer

Models for a data stream from a miniscope device: header formats, containers, etc.

class mio.models.buffer.BufferHeader(*, linked_list: int, frame_num: int, buffer_count: int, frame_buffer_count: int, write_buffer_count: int, dropped_buffer_count: int, timestamp: int, write_timestamp: int)

Container for the data stream’s header, structured by MetadataHeaderFormat

buffer_count: int
dropped_buffer_count: int
frame_buffer_count: int
frame_num: int
classmethod from_format(vals: Sequence, format: BufferHeaderFormat, construct: bool = False) _T

Instantiate a buffer header from linearized values (eg. in an ndarray or list) and an associated format that tells us what index the model values are found in that data.

Parameters:
  • vals (list, numpy.ndarray) – Indexable values to cast to the header model

  • format (BufferHeaderFormat) – Format used to index values

  • construct (bool) – If True , use model_construct() to create the model instance (ie. without validation, but faster). Default: False

Returns:

BufferHeader

linked_list: int
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

timestamp: int
write_buffer_count: int
write_timestamp: int
class mio.models.buffer.BufferHeaderFormat(*, id: Annotated[str, _PydanticGeneralMetadata(pattern='[\\w\\-\\/#]+')], mio_model: Annotated[str, AfterValidator(func=_is_identifier)] = None, mio_version: str = '0.10.1.dev6+g8c206e3', linked_list: int, frame_num: int, buffer_count: int, frame_buffer_count: int, write_buffer_count: int, dropped_buffer_count: int, timestamp: int, write_timestamp: int)

Format model used to parse header at the beginning of every buffer.

Parameters:
  • linked_list (int) – Index of data buffers within the circulating structure. This increments with each buffer until it reaches [num_buffers](../api/stream.md), then resets to zero.

  • frame_num (int) – The index of the image frame, which increments with each image frame (comprising multiple data buffers).

  • buffer_count (int) – Index of data buffers, which increments with each buffer.

  • frame_buffer_count (int) – Index of the data buffer within the image frame. It is set to frame_buffer_count = 0 at the first buffer in each frame.

  • write_buffer_count (int) – Number of data buffers transmitted out of the MCU.

  • dropped_buffer_count (int) – Number of dropped data buffers.

  • timestamp (int) – Timestamp in milliseconds. This should increase approximately by 1 / framerate * 1000 every frame.

  • write_timestamp (int) – Timestamp in milliseconds when the buffer was transmitted out of the MCU.

buffer_count: int
dropped_buffer_count: int
frame_buffer_count: int
frame_num: int
linked_list: int
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

timestamp: int
write_buffer_count: int
write_timestamp: int