olfactometer

pydantic model aind_behavior_services.calibration.olfactometer.CalibrationLogic[source]

Bases: AindBehaviorTaskLogicModel

Olfactometer operation control model that is used to run a calibration data acquisition workflow

Config:
  • extra: str = forbid

  • validate_assignment: bool = True

  • validate_defaults: bool = True

  • strict: bool = True

  • str_strip_whitespace: bool = True

Fields:
Validators:
field name: str = 'OlfactometerCalibrationLogic'[source]
field task_parameters: CalibrationParameters [Required][source]
field version: Literal['0.4.0'] = '0.4.0'[source]
Validated by:
  • coerce_version

pydantic model aind_behavior_services.calibration.olfactometer.CalibrationParameters[source]

Bases: TaskParameters

Config:
  • extra: str = allow

  • validate_assignment: bool = True

  • validate_defaults: bool = True

  • strict: bool = True

  • str_strip_whitespace: bool = True

Fields:
Validators:

field channel_config: Dict[OlfactometerChannel, OlfactometerChannelConfig] = {}[source]

Configuration of olfactometer channels

field full_flow_rate: float = 1000[source]

Full flow rate of the olfactometer

Constraints:
  • ge = 0

  • le = 1000

field n_repeats_per_stimulus: int = 1[source]

Number of repeats per stimulus

Constraints:
  • ge = 1

field time_off: float = 1[source]

Time (s) the valve is close during calibration

Constraints:
  • ge = 0

field time_on: float = 1[source]

Time (s) the valve is open during calibration

Constraints:
  • ge = 0

pydantic model aind_behavior_services.calibration.olfactometer.CalibrationRig[source]

Bases: AindBehaviorRigModel

Fields:
Validators:
field harp_analog_input: HarpAnalogInput [Required][source]
field harp_clock_generator: HarpClockGenerator [Required][source]
field harp_olfactometer: Olfactometer [Required][source]
field version: Literal['0.0.0'] = '0.0.0'[source]
Validated by:
pydantic model aind_behavior_services.calibration.olfactometer.Olfactometer[source]

Bases: HarpOlfactometer

Fields:
field calibration: OlfactometerCalibration | None = None[source]
pydantic model aind_behavior_services.calibration.olfactometer.OlfactometerCalibration[source]

Bases: Calibration

Olfactometer calibration class

Fields:
field description: Literal['Calibration of the harp olfactometer device'] = 'Calibration of the harp olfactometer device'[source]
field device_name: str = 'Olfactometer'[source]

Name of the device being calibrated

field input: OlfactometerCalibrationInput [Required][source]
field output: OlfactometerCalibrationOutput [Required][source]
pydantic model aind_behavior_services.calibration.olfactometer.OlfactometerCalibrationInput[source]

Bases: BaseModel

Fields:
field channel_config: Dict[OlfactometerChannel, OlfactometerChannelConfig] = {}[source]

Configuration of olfactometer channels

pydantic model aind_behavior_services.calibration.olfactometer.OlfactometerCalibrationOutput[source]

Bases: BaseModel

class aind_behavior_services.calibration.olfactometer.OlfactometerChannel(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

Harp Olfactometer available channel

Channel0 = 0[source]
Channel1 = 1[source]
Channel2 = 2[source]
Channel3 = 3[source]
pydantic model aind_behavior_services.calibration.olfactometer.OlfactometerChannelConfig[source]

Bases: BaseModel

Fields:
field channel_index: int [Required][source]
field channel_type: OlfactometerChannelType = OlfactometerChannelType.ODOR[source]
field flow_rate: float = 100[source]
Constraints:
  • le = 100

field flow_rate_capacity: Literal[100, 1000] = 100[source]
field odorant: str | None = None[source]
field odorant_dilution: float | None = None[source]
class aind_behavior_services.calibration.olfactometer.OlfactometerChannelType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, Enum

Channel type

CARRIER = 'Carrier'[source]
ODOR = 'Odor'[source]

Example

import os

from aind_behavior_services.base import get_commit_hash
from aind_behavior_services.calibration import olfactometer as olf
from aind_behavior_services.session import AindBehaviorSessionModel
from aind_behavior_services.utils import utcnow

channels_config = {
    olf.OlfactometerChannel.Channel0: olf.OlfactometerChannelConfig(
        channel_index=olf.OlfactometerChannel.Channel0,
        channel_type=olf.OlfactometerChannelType.ODOR,
        flow_rate=100,
        odorant="Banana",
        odorant_dilution=0.1,
    ),
    olf.OlfactometerChannel.Channel1: olf.OlfactometerChannelConfig(
        channel_index=olf.OlfactometerChannel.Channel1,
        channel_type=olf.OlfactometerChannelType.ODOR,
        flow_rate=100,
        odorant="Strawberry",
        odorant_dilution=0.1,
    ),
    olf.OlfactometerChannel.Channel2: olf.OlfactometerChannelConfig(
        channel_index=olf.OlfactometerChannel.Channel2,
        channel_type=olf.OlfactometerChannelType.ODOR,
        flow_rate=100,
        odorant="Apple",
        odorant_dilution=0.1,
    ),
    olf.OlfactometerChannel.Channel3: olf.OlfactometerChannelConfig(
        channel_index=olf.OlfactometerChannel.Channel3, channel_type=olf.OlfactometerChannelType.CARRIER, odorant="Air"
    ),
}

calibration = olf.OlfactometerCalibration(
    input=olf.OlfactometerCalibrationInput(), output=olf.OlfactometerCalibrationOutput()
)

calibration_logic = olf.CalibrationLogic(
    task_parameters=olf.CalibrationParameters(
        channel_config=channels_config,
        full_flow_rate=1000,
        n_repeats_per_stimulus=10,
        time_on=1,
        time_off=1,
    )
)

calibration_session = AindBehaviorSessionModel(
    root_path="C:\\Data",
    date=utcnow(),
    allow_dirty_repo=False,
    experiment="OlfactometerCalibration",
    experiment_version="0.0.0",
    subject="Olfactometer",
    commit_hash=get_commit_hash(),
)

rig = olf.CalibrationRig(
    rig_name="OlfactometerRig",
    harp_olfactometer=olf.Olfactometer(port_name="COM4"),
    harp_analog_input=olf.HarpAnalogInput(port_name="COM5"),
    harp_clock_generator=olf.HarpClockGenerator(port_name="COM6"),
)


seed_path = "local/olfactometer_{suffix}.json"
os.makedirs(os.path.dirname(seed_path), exist_ok=True)

with open(seed_path.format(suffix="calibration_logic"), "w") as f:
    f.write(calibration_logic.model_dump_json(indent=3))
with open(seed_path.format(suffix="session"), "w") as f:
    f.write(calibration_session.model_dump_json(indent=3))
with open(seed_path.format(suffix="rig"), "w") as f:
    f.write(rig.model_dump_json(indent=3))