# bpod_core.bpod.flexio

Classes implementing the FlexIO subsystem.

## Classes

### *class* bpod_core.bpod.flexio.FlexIO

Bases: [`AbstractFlexIO`](https://int-brain-lab.github.io/bpod-core/api/bpod_core.bpod.abc/index.html.md#bpod_core.bpod.abc.AbstractFlexIO)

Local FlexIO implementation with direct hardware access.

#### reset()

Reset the FlexIO subsystem to its default settings.

* **Overrides:**
  [`AbstractFlexIO.reset`](https://int-brain-lab.github.io/bpod-core/api/bpod_core.bpod.abc/index.html.md#bpod_core.bpod.abc.AbstractFlexIO.reset)

#### *property* analog_sampling_rate *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Sampling rate for channels configured as analog input, in Hz (1-1000).

The interval between samples is a whole number of state machine cycles (100 µs
on a Bpod 2+), so other rates are rounded: 300 Hz, for example, becomes
303.03 Hz. Analog timestamps are based on the actual rate. The rate is fixed
from the first trial until the Bpod is closed and reopened.

#### *property* n_reads_per_sample *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Number of ADC reads averaged per analog sample (1-4).

More reads reduce noise. The Bpod takes all reads of a sample within a single
state machine cycle, so they don't limit the sampling rate.

## Functions

### bpod_core.bpod.flexio.is_flexio_threshold_ambiguous(channel_types, index)

Whether channel index's analog-threshold event codes are ambiguous.

Firmware numbers analog-threshold events by rank among `ANALOG_INPUT`
channels only, not by physical channel index, while every other FlexIO event
(digital transitions, etc.) is numbered by fixed physical position. The two
schemes only agree when channel index is preceded exclusively by other
`ANALOG_INPUT` channels; otherwise its Trig0/Trig1 codes collide with
another channel's fixed-position event codes, an upstream firmware quirk
also present in MATLAB.

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)
