load_cells

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

Bases: AindBehaviorTaskLogicModel

Load cells 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 = 'LoadCellsCalibrationLogic'[source]
field task_parameters: CalibrationParameters [Required][source]
field version: Literal[TASK_LOGIC_VERSION] = '0.4.0'[source]
Validated by:
  • coerce_version

pydantic model aind_behavior_services.calibration.load_cells.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 channels: List[LoadCellChannel] = [0, 1, 2, 3, 4, 5, 6, 7][source]

List of channels to calibrate

field offset_buffer_size: int = 200[source]

Size of the buffer (in samples) acquired.

Constraints:
  • ge = 1

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

Bases: AindBehaviorRigModel

Fields:
Validators:
field load_cells: LoadCells [Required][source]
field version: Literal[RIG_VERSION] = '0.0.0'[source]
Validated by:
pydantic model aind_behavior_services.calibration.load_cells.LoadCellCalibrationInput[source]

Bases: BaseModel

Fields:
field channel: LoadCellChannel [Required][source]

Load cell channel number available

Constraints:
  • ge = 0

  • le = 7

field offset_measurement: List[MeasuredOffset] = [][source]
field weight_measurement: List[MeasuredWeight] = [][source]
pydantic model aind_behavior_services.calibration.load_cells.LoadCellCalibrationOutput[source]

Bases: BaseModel

Fields:
field baseline: float | None = None[source]
field channel: LoadCellChannel [Required][source]

Load cell channel number available

Constraints:
  • ge = 0

  • le = 7

field offset: LoadCellOffset | None = None[source]
field slope: float | None = None[source]
field weight_lookup: List[MeasuredWeight] = [][source]
pydantic model aind_behavior_services.calibration.load_cells.LoadCells[source]

Bases: HarpLoadCells

Fields:
field calibration: LoadCellsCalibration | None = None[source]
pydantic model aind_behavior_services.calibration.load_cells.LoadCellsCalibration[source]

Bases: Calibration

Load cells calibration class

Fields:
field description: Literal['Calibration of the load cells system'] = 'Calibration of the load cells system'[source]
field device_name: str = 'LoadCells'[source]

Must match a device name in rig/instrument

field input: LoadCellsCalibrationInput [Required][source]
field output: LoadCellsCalibrationOutput [Required][source]
pydantic model aind_behavior_services.calibration.load_cells.LoadCellsCalibrationInput[source]

Bases: BaseModel

Fields:
Validators:
field channels: List[LoadCellCalibrationInput] = [][source]
Validated by:
classmethod calibrate_loadcell_output(value: LoadCellCalibrationInput) LoadCellCalibrationOutput[source]
calibrate_output() LoadCellsCalibrationOutput[source]
validator ensure_unique_channels  »  channels[source]
static get_optimum_offset(value: List[MeasuredOffset] | None) int | None[source]
pydantic model aind_behavior_services.calibration.load_cells.LoadCellsCalibrationOutput[source]

Bases: BaseModel

Fields:
Validators:
field channels: List[LoadCellCalibrationOutput] = [][source]
Validated by:
validator ensure_unique_channels  »  channels[source]
pydantic model aind_behavior_services.calibration.load_cells.MeasuredOffset[source]

Bases: BaseModel

Fields:
field baseline: float [Required][source]

The measured baseline value

field offset: LoadCellOffset [Required][source]

The applied offset resistor value[-255, 255]

Constraints:
  • ge = -255

  • le = 255

pydantic model aind_behavior_services.calibration.load_cells.MeasuredWeight[source]

Bases: BaseModel

Fields:
field baseline: float [Required][source]

The measured baseline value

field weight: float [Required][source]

The applied weight in grams

Example

import os

from aind_behavior_services.base import get_commit_hash
from aind_behavior_services.calibration import load_cells as lc
from aind_behavior_services.session import AindBehaviorSessionModel
from aind_behavior_services.utils import utcnow

lc0 = lc.LoadCellCalibrationInput(
    channel=0,
    offset_measurement=[lc.MeasuredOffset(offset=100, baseline=0.1)],
    weight_measurement=[lc.MeasuredWeight(weight=0.1, baseline=0.1)],
)
lc1 = lc.LoadCellCalibrationInput(
    channel=1,
    offset_measurement=[lc.MeasuredOffset(offset=100, baseline=0.1)],
    weight_measurement=[lc.MeasuredWeight(weight=0.1, baseline=0.1)],
)

lc_calibration_input = lc.LoadCellsCalibrationInput(channels=[lc1, lc0])
lc_calibration_output = lc.LoadCellsCalibrationOutput(
    channels=[
        lc.LoadCellCalibrationOutput(channel=0, offset=6, baseline=1000, weight_lookup=[]),
        lc.LoadCellCalibrationOutput(channel=1, offset=6, baseline=1000, weight_lookup=[]),
    ]
)

calibration = lc.LoadCellsCalibration(
    input=lc_calibration_input,
    output=lc_calibration_output,
    device_name="LoadCells",
    date=utcnow(),
)

calibration_logic = lc.CalibrationLogic(
    task_parameters=lc.CalibrationParameters(channels=[0, 1], offset_buffer_size=10)
)

calibration_session = AindBehaviorSessionModel(
    root_path="C:\\Data",
    allow_dirty_repo=False,
    experiment="LoadCellsCalibration",
    date=utcnow(),
    subject="LoadCells",
    experiment_version="load_cells",
    commit_hash=get_commit_hash(),
)

rig = lc.CalibrationRig(
    load_cells=lc.LoadCells(port_name="COM4"),
    rig_name="LoadCellsRig",
)

seed_path = "local/load_cells_{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))