behavior_launcher.slims_picker¶
SlimsPicker ¶
SlimsPicker(
launcher: Optional[
BehaviorLauncher[TRig, TSession, TTaskLogic]
] = None,
*,
ui_helper: Optional[DefaultUIHelper] = None,
slims_url: str = SLIMS_URL,
username: Optional[str] = SLIMS_USERNAME,
password: Optional[str] = SLIMS_PASSWORD,
water_calculator: Optional[
Callable[[SlimsPicker], float]
] = None,
**kwargs,
)
Bases: _BehaviorPickerAlias[TRig, TSession, TTaskLogic]
Picker class that handles the selection of rigs, sessions, and task logic from SLIMS.
This class integrates with the SLIMS laboratory information management system to fetch experiment configurations, manage mouse records, and handle water logging for behavior experiments.
Example
# Initialize picker with launcher and SLIMS credentials
picker = SlimsPicker(launcher=my_launcher, username="user", password="pass")
# Connect to SLIMS and test connection
picker.initialize()
# Pick rig, session, and task logic from SLIMS
rig = picker.pick_rig()
session = picker.pick_session()
task_logic = picker.pick_task_logic()
# Finalize picker (suggest water and write waterlog)
picker.finalize()
Initializes the SLIMS picker with connection parameters and optional water calculator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
launcher
|
Optional[BehaviorLauncher[TRig, TSession, TTaskLogic]]
|
The launcher instance associated with the picker |
None
|
ui_helper
|
Optional[DefaultUIHelper]
|
Helper for user interface interactions |
None
|
slims_url
|
str
|
SLIMS server URL. Defaults to dev version if not provided |
SLIMS_URL
|
username
|
Optional[str]
|
SLIMS username. Defaults to SLIMS_USERNAME environment variable |
SLIMS_USERNAME
|
password
|
Optional[str]
|
SLIMS password. Defaults to SLIMS_PASSWORD environment variable |
SLIMS_PASSWORD
|
water_calculator
|
Optional[Callable[[SlimsPicker], float]]
|
Function to calculate water amount. If None, user will be prompted |
None
|
**kwargs
|
Additional keyword arguments |
{}
|
Example
# Initialize with explicit credentials
picker = SlimsPicker(launcher=my_launcher, username="user", password="pass")
# Initialize with environment variables
picker = SlimsPicker(launcher=my_launcher)
# Initialize with custom water calculator
def calc_water(picker): return 1.5
picker = SlimsPicker(launcher=my_launcher, water_calculator=calc_water)
Source code in src/clabe/behavior_launcher/slims_picker.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
slims_client
property
¶
slims_client: SlimsClient
Returns the SLIMS client being used for session operations.
Returns:
Name | Type | Description |
---|---|---|
SlimsClient |
SlimsClient
|
The configured SLIMS client object |
slims_mouse
property
¶
slims_mouse: SlimsMouseContent
Returns the SLIMS mouse model being used for the current session.
Returns:
Name | Type | Description |
---|---|---|
SlimsMouseContent |
SlimsMouseContent
|
The current mouse/subject record from SLIMS |
Raises:
Type | Description |
---|---|
ValueError
|
If SLIMS mouse instance is not set |
slims_session
property
¶
slims_session: SlimsBehaviorSession
Returns the SLIMS session model being used for task logic loading.
Returns:
Name | Type | Description |
---|---|---|
SlimsBehaviorSession |
SlimsBehaviorSession
|
The current behavior session record from SLIMS |
Raises:
Type | Description |
---|---|
ValueError
|
If SLIMS session instance is not set |
slims_rig
property
¶
slims_rig: SlimsInstrument
Returns the SLIMS instrument model being used for rig configuration.
Returns:
Name | Type | Description |
---|---|---|
SlimsInstrument |
SlimsInstrument
|
The current rig/instrument record from SLIMS |
Raises:
Type | Description |
---|---|
ValueError
|
If SLIMS rig instance is not set |
write_waterlog ¶
write_waterlog(
weight_g: float,
water_earned_ml: float,
water_supplement_delivered_ml: float,
water_supplement_recommended_ml: Optional[float] = None,
) -> None
Add waterlog event to SLIMS with the specified water and weight measurements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
weight_g
|
float
|
Animal weight in grams |
required |
water_earned_ml
|
float
|
Water earned during session in mL |
required |
water_supplement_delivered_ml
|
float
|
Supplemental water given in session in mL |
required |
water_supplement_recommended_ml
|
Optional[float]
|
Optional recommended water amount in mL |
None
|
Example
# Write a waterlog entry to SLIMS
picker.write_waterlog(weight_g=25.0, water_earned_ml=1.2, water_supplement_delivered_ml=0.5)
Source code in src/clabe/behavior_launcher/slims_picker.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
pick_rig ¶
pick_rig() -> TRig
Prompts the user to provide a rig name and fetches configuration from SLIMS.
Searches SLIMS for the specified rig and deserializes the latest attachment into a rig schema model.
Returns:
Name | Type | Description |
---|---|---|
TRig |
TRig
|
The selected rig configuration from SLIMS |
Raises:
Type | Description |
---|---|
ValueError
|
If no rig is found in SLIMS or no valid attachment exists |
Example
# Pick a rig configuration from SLIMS
rig = picker.pick_rig()
Source code in src/clabe/behavior_launcher/slims_picker.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|
pick_session ¶
pick_session() -> TSession
Prompts the user to select or create a session configuration using SLIMS data.
Fetches mouse information from SLIMS and creates a session configuration with experimenter details and session metadata.
Returns:
Name | Type | Description |
---|---|---|
TSession |
TSession
|
The created session configuration with SLIMS integration |
Raises:
Type | Description |
---|---|
ValueError
|
If no session model is found in SLIMS for the specified mouse |
Example
# Pick a session configuration from SLIMS
session = picker.pick_session()
Source code in src/clabe/behavior_launcher/slims_picker.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
|
pick_task_logic ¶
pick_task_logic() -> TTaskLogic
Returns task logic found as an attachment from the session loaded from SLIMS.
Attempts to load task logic from CLI first, then from SLIMS session attachments.
Returns:
Name | Type | Description |
---|---|---|
TTaskLogic |
TTaskLogic
|
Task logic configuration from SLIMS session attachments |
Raises:
Type | Description |
---|---|
ValueError
|
If no valid task logic attachment is found in the SLIMS session |
Example
# Pick task logic from SLIMS session attachments
task_logic = picker.pick_task_logic()
Source code in src/clabe/behavior_launcher/slims_picker.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
|
write_behavior_session ¶
write_behavior_session(
task_logic: TTaskLogic,
notes: Optional[str] = None,
is_curriculum_suggestion: Optional[bool] = None,
software_version: Optional[str] = None,
schedule_date: Optional[datetime] = None,
) -> None
Pushes a new behavior session to SLIMS with task logic for the next session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_logic
|
TTaskLogic
|
Task logic configuration to use for the next session |
required |
notes
|
Optional[str]
|
Optional notes for the SLIMS session |
None
|
is_curriculum_suggestion
|
Optional[bool]
|
Whether the mouse is following a curriculum |
None
|
software_version
|
Optional[str]
|
Software version used to run the session |
None
|
schedule_date
|
Optional[datetime]
|
Date when the session will be run |
None
|
Example
# Write a new behavior session to SLIMS
picker.write_behavior_session(task_logic=task_logic, notes="Session notes")
Source code in src/clabe/behavior_launcher/slims_picker.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
|
initialize ¶
initialize() -> None
Initializes the picker by connecting to SLIMS and testing the connection.
Establishes the SLIMS client connection and validates connectivity before proceeding with picker operations.
Example
# Initialize the picker and connect to SLIMS
picker.initialize()
Source code in src/clabe/behavior_launcher/slims_picker.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
|
prompt_experimenter ¶
Prompts the user to enter the experimenter's name(s).
Accepts multiple experimenter names separated by commas or spaces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strict
|
bool
|
Whether to enforce non-empty input |
True
|
Returns:
Type | Description |
---|---|
Optional[List[str]]
|
Optional[List[str]]: List of experimenter names |
Source code in src/clabe/behavior_launcher/slims_picker.py
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
|
suggest_water ¶
suggest_water() -> None
Calculates and suggests water amount based on current weight and water earned.
Prompts user for current weight and water earned, calculates suggested amount, and optionally writes the waterlog to SLIMS.
Source code in src/clabe/behavior_launcher/slims_picker.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
|
finalize ¶
finalize()
Finalizes the picker by suggesting water amount and handling waterlog.
Called at the end of the experiment to manage post-session water calculations and SLIMS waterlog entries.
Source code in src/clabe/behavior_launcher/slims_picker.py
599 600 601 602 603 604 605 606 607 |
|