commands
sleap.gui.commands
¶
Module for gui command context and commands objects.
Each open project (i.e., MainWindow) will have its own CommandContext.
The context enables commands to access and modify the GuiState and Labels,
as well as potentially maintaining a command history (so we can add support for
undo!). See sleap.gui.app for how the context is created and used.
Every command will have both a method in CommandContext (this is what should
be used to trigger the command, e.g., connected to the menu action) and a
class which inherits from AppCommand (or a more specialized class such as
NavCommand, GoIteratorCommand, or EditCommand). Note that this code relies
on inheritance, so some care and attention is required.
A typical command will override the ask and do_action methods. If the
command updates something which affects the GUI, it should override the topic
attribute (this then gets passed back to the update_callback from the context.
If a command doesn't require any input from the user, then it doesn't need to
override the ask method.
If it's not possible to separate the GUI "ask" and the non-GUI "do" code, then
instead of ask and do_action you should add an ask_and_do method
(for instance, DeleteDialogCommand and MergeProject show dialogues which
handle both the GUI and the action). Ideally we'd endorse separation of "ask"
and "do" for all commands (this is important if we're going to implement undo)--
for now it's at least easy to see where this separation is violated.
Classes:
| Name | Description |
|---|---|
AddInstance |
|
AddMissingInstanceNodes |
|
AddUserInstancesFromPredictions |
|
AddVideo |
|
AppCommand |
Base class for specific commands. |
CommandContext |
Context within in which commands are executed. |
DeleteFrameLimitPredictions |
|
DeleteMultipleTracks |
|
DeleteUserFramePredictions |
Delete predictions on frames that have user instances. |
EditCommand |
Class for commands which change data in project. |
ExportLabeledClip |
Export a labeled video clip with skeleton overlay. |
ExportLabelsSubset |
Export a subset of labels to a new file with either images or a trimmed video. |
ExportPackageThread |
Background thread for exporting labels package without freezing GUI. |
ExportVideoClip |
Base class for exporting video clips. |
FakeApp |
Use if you want to execute commands independently of the GUI app. |
GenerateSuggestionsThread |
Background thread for generating frame suggestions without freezing GUI. |
GoIteratorCommand |
|
InstanceDeleteCommand |
|
LoadLabelsObject |
|
MergeInstances |
Merge two user instances in the current frame into a single instance. |
OpenSkeleton |
|
RenderVideoThread |
Background thread for rendering video without freezing GUI. |
ReplaceVideo |
|
SaveProjectAs |
|
SetInstancePointLocations |
Sets locations for node(s) for an instance. |
SetInstancePointVisibility |
Toggles visibility set for a node for an instance. |
ToggleGrayscale |
|
ToggleNegativeFrame |
Mark or unmark the current frame as a negative (background) frame. |
UpdateTopic |
Topics so context can tell callback what was updated by the command. |
Functions:
| Name | Description |
|---|---|
copy_to_clipboard |
Copy a string to the system clipboard. |
export_dataset_gui |
Export dataset with image data and display progress GUI dialog. |
get_new_version_filename |
Increment version number in filenames that end in |
open_file |
Opens file in native system file browser or registered application. |
open_website |
Open website in default browser. |
render_video_gui |
Render video with progress dialog. |
reveal_file |
Open the file explorer with the given file selected/revealed. |
AddInstance
¶
Bases: EditCommand
Methods:
| Name | Description |
|---|---|
create_new_instance |
Create new instance. |
fill_missing_nodes |
Fill in missing nodes for new instance. |
find_instance_to_copy_from |
Find instance to copy from. |
get_previous_frame_index |
Returns index of previous frame. |
set_visible_nodes |
Sets visible nodes for new instance. |
Source code in sleap/gui/commands.py
4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 | |
create_new_instance(context, from_predicted, copy_instance, mark_complete, init_method, location, from_prev_frame, offset=0)
staticmethod
¶
Create new instance.
Source code in sleap/gui/commands.py
fill_missing_nodes(context, copy_instance, init_method, new_instance, location)
staticmethod
¶
Fill in missing nodes for new instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
copy_instance
|
Optional[Union[Instance, PredictedInstance]]
|
The instance to copy from. |
required |
init_method
|
str
|
The initialization method. |
required |
new_instance
|
Instance
|
The new instance. |
required |
location
|
Optional[QPoint]
|
The location of the instance. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in sleap/gui/commands.py
find_instance_to_copy_from(context, copy_instance, init_method)
staticmethod
¶
Find instance to copy from.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
copy_instance
|
Optional[Union[Instance, PredictedInstance]]
|
The |
required |
init_method
|
bool
|
The initialization method. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[Optional[Union[Instance, PredictedInstance]], Optional[PredictedInstance], bool]
|
The instance to copy from, the predicted instance (if it is from a predicted instance, else None), and whether it's from a previous frame. |
Source code in sleap/gui/commands.py
4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 | |
get_previous_frame_index(context)
staticmethod
¶
Returns index of previous frame.
Source code in sleap/gui/commands.py
set_visible_nodes(context, copy_instance, new_instance, mark_complete, init_method, location=None, offset=0)
staticmethod
¶
Sets visible nodes for new instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
copy_instance
|
Optional[Union[Instance, PredictedInstance]]
|
The instance to copy from. |
required |
new_instance
|
Instance
|
The new instance. |
required |
mark_complete
|
bool
|
Whether to mark the instance as complete. |
required |
init_method
|
str
|
The initialization method. |
required |
location
|
Optional[QPoint]
|
The location of the mouse click if any. |
None
|
offset
|
int
|
The offset to apply to all nodes. |
0
|
Returns:
| Type | Description |
|---|---|
bool
|
Whether the new instance has missing nodes. |
Source code in sleap/gui/commands.py
4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 | |
AddMissingInstanceNodes
¶
Bases: EditCommand
Methods:
| Name | Description |
|---|---|
get_rect_center_xy |
Returns x, y at center of rect. |
get_xy_in_rect |
Returns random x, y coordinates within given rect. |
Source code in sleap/gui/commands.py
4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 | |
AddUserInstancesFromPredictions
¶
Bases: EditCommand
Methods:
| Name | Description |
|---|---|
fill_missing_predicted_nodes |
Position undetected (NaN) nodes with a force-directed layout, hidden. |
make_instance_from_predicted_instance |
Create a user Instance from a PredictedInstance. |
Source code in sleap/gui/commands.py
4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 | |
fill_missing_predicted_nodes(new_instance)
staticmethod
¶
Position undetected (NaN) nodes with a force-directed layout, hidden.
The model leaves occluded nodes at NaN coordinates, and
make_instance_from_predicted_instance keeps them visible=False
(correct -- the converted instance should look like the prediction). But
a NaN coordinate renders at a default/garbage location when the user
enables "show non-visible nodes" (QtInstance still creates a node
item for every node in that mode, positioned at its xy).
Spread the missing nodes with a force-directed (spring) layout of the
skeleton graph, centered on the detected keypoints' centroid and scaled
to their extent, so they sit on the animal -- spread out and grabbable --
regardless of how many nodes the model detected, while staying
visible=False. (Template/alignment placement is unreliable when only
a few nodes are detected -- there is no way to infer where occluded nodes
are from a couple of visible ones -- so a force-directed layout, one of
the brand-new-instance init options, is used for robustness.)
Already-detected points, the track, and from_predicted are untouched.
No GUI player is required. No-op when every node was detected, or when nothing was detected (no anchor for the layout center).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_instance
|
Instance
|
The user |
required |
Source code in sleap/gui/commands.py
make_instance_from_predicted_instance(copy_instance)
staticmethod
¶
Create a user Instance from a PredictedInstance.
Creates an empty Instance with proper PointsArray dtype, then copies coordinates and visibility from the prediction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
copy_instance
|
PredictedInstance
|
The PredictedInstance to convert. |
required |
Returns:
| Type | Description |
|---|---|
Instance
|
A new Instance with the same points, skeleton, and track, and from_predicted linking back to the original prediction. |
Source code in sleap/gui/commands.py
AddVideo
¶
Bases: EditCommand
Methods:
| Name | Description |
|---|---|
ask |
Shows gui for adding video to project. |
Source code in sleap/gui/commands.py
ask(context, params)
staticmethod
¶
Shows gui for adding video to project.
AppCommand
¶
Base class for specific commands.
Note that this is not an abstract base class. For specific commands, you
should override ask and/or do_action methods, or add an ask_and_do
method. In many cases you'll want to override the topics and does_edits
attributes. That said, these are not virtual methods/attributes and have
are implemented in the base class with default behaviors (i.e., doing
nothing).
You should not override execute or do_with_signal.
Attributes:
| Name | Type | Description |
|---|---|---|
topics |
List[UpdateTopic]
|
List of |
does_edits |
bool
|
Whether command will modify data that could be saved. |
Methods:
| Name | Description |
|---|---|
ask |
Method for information gathering. |
do_action |
Method for performing action. |
do_with_signal |
Wrapper to perform action and notify/track changes. |
execute |
Entry point for running command. |
Source code in sleap/gui/commands.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
ask(context, params)
staticmethod
¶
Method for information gathering.
Returns:
| Type | Description |
|---|---|
bool
|
Whether to perform action. By default returns True, but this is where we should return False if we prompt user for confirmation and they abort. |
Source code in sleap/gui/commands.py
do_action(context, params)
staticmethod
¶
do_with_signal(context, params)
classmethod
¶
Wrapper to perform action and notify/track changes.
Don't override this method!
Source code in sleap/gui/commands.py
execute(context, params=None)
¶
Entry point for running command.
This calls internal methods to gather information required for execution, perform the action, and notify about changes.
Ideally, any information gathering should be performed in the ask
method, and be added to the params dictionary which then gets
passed to do_action. The ask method should not modify state.
(This will make it easier to add support for undo,
using an undo_action which will be given the same params
dictionary.)
If it's not possible to easily separate information gathering from
performing the action, the child class should implement ask_and_do,
which it turn should call do_with_signal to notify about changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
'CommandContext'
|
This is the |
required |
params
|
dict
|
Dictionary of any params for command. |
None
|
Source code in sleap/gui/commands.py
CommandContext
¶
Context within in which commands are executed.
When you create a new command, you should both create a class for the
command (which inherits from CommandClass) and add a distinct method
for the command in the CommandContext class. This method is what should
be connected/called from other code to invoke the command.
Attributes:
| Name | Type | Description |
|---|---|---|
state |
GuiState
|
The |
app |
'MainWindow'
|
The |
update_callback |
Optional[Callable]
|
A callback to receive update notifications.
This function should accept a list of |
Methods:
| Name | Description |
|---|---|
addCurrentFrameAsSuggestion |
Add current frame as a suggestion. |
addTrack |
Creates new track and moves selected instance into this track. |
addUserInstancesFromAllPredictions |
Create user instances from all predicted instances across all frames. |
addUserInstancesFromPredictions |
Create user instance from a predicted instance. |
addVideo |
Shows gui for adding videos to project. |
changestack_clear |
Clears stack of changes. |
changestack_push |
Adds to stack of changes made by user. |
changestack_savepoint |
Marks that project was just saved. |
clearSuggestions |
Clear all suggestions. |
completeInstanceNodes |
Adds missing nodes to given instance. |
copyInstance |
Copy the selected instance to the instance clipboard. |
copyInstanceTrack |
Copies the selected instance's track to the track clipboard. |
deleteAreaPredictions |
Gui for deleting instances within some rect on frame images. |
deleteClipPredictions |
Deletes all predictions within selected range of video frames. |
deleteDialog |
Deletes using options selected in a dialog. |
deleteEdge |
Removes (currently selected) edge from skeleton. |
deleteFrameLimitPredictions |
Gui for deleting instances beyond some frame number. |
deleteFramePredictions |
Deletes all predictions on current frame. |
deleteInstanceLimitPredictions |
Gui for deleting instances beyond some number in each frame. |
deleteLowScorePredictions |
Gui for deleting instances below some score threshold. |
deleteMultipleTracks |
Delete all tracks. |
deleteNode |
Removes (currently selected) node from skeleton. |
deletePredictions |
Deletes all predicted instances in project. |
deleteSelectedInstance |
Deletes currently selected instance. |
deleteSelectedInstanceTrack |
Deletes all instances from track of currently selected instance. |
deleteTrack |
Delete a track and remove from all instances. |
deleteUserFramePredictions |
Gui for deleting predictions on frames with user instances. |
execute |
Execute command in this context, passing named arguments. |
exportAnalysisFile |
Shows gui for exporting analysis h5 file. |
exportCSVFile |
Shows gui for exporting analysis csv file. |
exportFullPackage |
Gui for exporting the dataset with any labeled frames and suggestions. |
exportLabeledClip |
Shows gui for exporting clip with visual annotations. |
exportLabelsSubset |
Exports a selected range of video frames and their corresponding labels. |
exportNWB |
Show gui for exporting nwb file. |
exportTrainingPackage |
Gui for exporting the dataset with user-labeled images and suggestions. |
exportUserLabelsPackage |
Gui for exporting the dataset with user-labeled images. |
from_labels |
Creates a command context for use independently of GUI app. |
generateSuggestions |
Generates suggestions using given params dictionary. |
gotoFrame |
Shows gui to go to frame by number. |
gotoVideoAndFrame |
Activates video and goes to frame. |
gotoVideoAndFrameAndInstance |
Activates video, goes to frame, and highlights instance. |
importAnalysisFile |
Imports SLEAP analysis hdf5 files. |
importCoco |
Imports COCO datasets. |
importDLC |
Imports DeepLabCut datasets. |
importDLCFolder |
Imports multiple DeepLabCut datasets. |
importNWB |
Imports NWB datasets. |
lastInteractedFrame |
Goes to last frame that user interacted with. |
loadLabelsObject |
Loads a |
loadProjectFile |
Loads given labels file into GUI. |
mergeInstance |
Merge another user instance in the frame into the selected one. |
mergeProject |
Starts gui for importing another dataset into currently one. |
newEdge |
Adds new edge to skeleton. |
newInstance |
Creates a new instance, copying node coordinates as appropriate. |
newNode |
Adds new node to skeleton. |
newProject |
Create a new project in a new window. |
nextLabeledFrame |
Goes to labeled frame after current frame. |
nextSuggestedFrame |
Goes to next suggested frame. |
nextTrackFrame |
Goes to next frame on which a track starts. |
nextUserLabeledFrame |
Goes to next labeled frame with user instances. |
openProject |
Allows user to select and then open a saved project. |
openSkeleton |
Shows gui for loading saved skeleton into project. |
openSkeletonTemplate |
Shows gui for loading saved skeleton into project. |
openWebsite |
Open a website from URL using the native system browser. |
pasteInstance |
Paste the instance from the clipboard as a new copy. |
pasteInstanceTrack |
Pastes the track in the clipboard to the selected instance. |
prevSuggestedFrame |
Goes to previous suggested frame. |
prevUserLabeledFrame |
Goes to previous labeled frame with user instances. |
previousLabeledFrame |
Goes to labeled frame prior to current frame. |
removeSuggestion |
Remove the selected frame from suggestions. |
removeVideo |
Removes selected video from project. |
replaceVideo |
Shows gui for replacing videos to project. |
saveProject |
Show gui to save project (or save as if not yet saved). |
saveProjectAs |
Show gui to save project as a new file. |
saveSkeleton |
Shows gui for saving skeleton from project. |
selectToFrame |
Shows gui to go to frame by number. |
setInstancePointVisibility |
Toggles visibility set for a node for an instance. |
setInstanceTrack |
Sets track for selected instance. |
setNodeName |
Changes name of node in skeleton. |
setNodeSymmetry |
Sets node symmetry in skeleton. |
setPointLocations |
Sets locations for node(s) for an instance. |
setTrackName |
Sets name for track. |
showImportVideos |
Show video importer GUI without the file browser. |
signal_update |
Calls the update callback after data has been changed. |
toggleCurrentFrameNegative |
Mark or unmark the current frame as a negative (background) frame. |
toggleGrayscale |
Toggles grayscale setting for current video. |
transposeInstance |
Transposes tracks for two instances. |
updateEdges |
Called when edges in skeleton have been changed. |
Source code in sleap/gui/commands.py
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 278 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 349 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 408 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 447 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 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 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 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | |
labels
property
¶
Alias to app.labels.
addCurrentFrameAsSuggestion()
¶
addTrack()
¶
addUserInstancesFromAllPredictions()
¶
addUserInstancesFromPredictions()
¶
addVideo()
¶
changestack_clear()
¶
changestack_push(change='')
¶
Adds to stack of changes made by user.
Source code in sleap/gui/commands.py
changestack_savepoint()
¶
clearSuggestions()
¶
completeInstanceNodes(instance)
¶
copyInstance()
¶
copyInstanceTrack()
¶
deleteAreaPredictions()
¶
deleteClipPredictions()
¶
deleteDialog()
¶
deleteEdge()
¶
deleteFrameLimitPredictions()
¶
deleteFramePredictions()
¶
deleteInstanceLimitPredictions()
¶
deleteLowScorePredictions()
¶
deleteMultipleTracks(delete_all=False)
¶
deleteNode()
¶
deletePredictions()
¶
deleteSelectedInstance()
¶
deleteSelectedInstanceTrack()
¶
deleteTrack(track)
¶
deleteUserFramePredictions()
¶
execute(command, **kwargs)
¶
exportAnalysisFile(all_videos=False)
¶
exportCSVFile(all_videos=False)
¶
exportFullPackage()
¶
exportLabeledClip()
¶
exportLabelsSubset(as_package=False, open_new_project=True)
¶
Exports a selected range of video frames and their corresponding labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
as_package
|
bool
|
Whether to export as a package. |
False
|
open_new_project
|
bool
|
Whether to open the exported labels in a new project GUI. |
True
|
Source code in sleap/gui/commands.py
exportNWB()
¶
exportTrainingPackage()
¶
exportUserLabelsPackage()
¶
from_labels(labels)
classmethod
¶
Creates a command context for use independently of GUI app.
generateSuggestions(params)
¶
gotoFrame()
¶
gotoVideoAndFrame(video, frame_idx)
¶
gotoVideoAndFrameAndInstance(video, frame_idx, instance_idx)
¶
Activates video, goes to frame, and highlights instance.
This is used when navigating from the Size Distribution widget to highlight which specific instance was clicked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video
|
Video
|
Video to navigate to. |
required |
frame_idx
|
int
|
Frame index to navigate to. |
required |
instance_idx
|
int
|
Index of user instance within the frame to highlight. |
required |
Source code in sleap/gui/commands.py
importAnalysisFile()
¶
importCoco()
¶
importDLC()
¶
importDLCFolder()
¶
importNWB()
¶
lastInteractedFrame()
¶
loadLabelsObject(labels, filename=None)
¶
Loads a Labels object into the GUI, replacing any currently loaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
Labels
|
The |
required |
filename
|
Optional[str]
|
The filename where this file is saved, if any. |
None
|
Returns:
| Type | Description |
|---|---|
|
None. |
Source code in sleap/gui/commands.py
loadProjectFile(filename)
¶
Loads given labels file into GUI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Union[str, Labels]
|
The path to the saved labels dataset or the |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in sleap/gui/commands.py
mergeInstance(donor=None)
¶
Merge another user instance in the frame into the selected one.
The selected instance is kept (survivor) and gains the donor's labeled
keypoints for any nodes it is missing. If donor is None and the frame
has exactly two user instances, the other one is used as the donor.
Source code in sleap/gui/commands.py
mergeProject(filenames=None)
¶
newEdge(src_node, dst_node)
¶
newInstance(copy_instance=None, init_method='best', location=None, mark_complete=False, offset=0)
¶
Creates a new instance, copying node coordinates as appropriate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
copy_instance
|
Optional[Instance]
|
The :class: |
None
|
init_method
|
str
|
Method to use for positioning nodes. |
'best'
|
location
|
Optional[QPoint]
|
The location where instance should be added (if node init method supports custom location). |
None
|
mark_complete
|
bool
|
Whether to mark the instance as complete. |
False
|
offset
|
int
|
Offset to apply to the location if given. |
0
|
Source code in sleap/gui/commands.py
newNode()
¶
newProject()
¶
nextLabeledFrame()
¶
nextSuggestedFrame()
¶
nextTrackFrame()
¶
nextUserLabeledFrame()
¶
openProject(filename=None, first_open=False)
¶
Allows user to select and then open a saved project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Optional[str]
|
Filename of the project to be opened. If None, a file browser dialog will prompt the user for a path. |
None
|
first_open
|
bool
|
Whether this is the first window opened. If True, then the new project is loaded into the current window rather than a new application window. |
False
|
Returns:
| Type | Description |
|---|---|
|
None. |
Source code in sleap/gui/commands.py
openSkeleton()
¶
openSkeletonTemplate()
¶
openWebsite(url)
¶
pasteInstance()
¶
pasteInstanceTrack()
¶
prevSuggestedFrame()
¶
prevUserLabeledFrame()
¶
previousLabeledFrame()
¶
removeSuggestion()
¶
removeVideo()
¶
replaceVideo()
¶
saveProject()
¶
saveProjectAs()
¶
saveSkeleton()
¶
selectToFrame()
¶
setInstancePointVisibility(instance, node, visible)
¶
Toggles visibility set for a node for an instance.
setInstanceTrack(new_track)
¶
setNodeName(skeleton, node, name)
¶
setNodeSymmetry(skeleton, node, symmetry)
¶
setPointLocations(instance, nodes_locations)
¶
Sets locations for node(s) for an instance.
Source code in sleap/gui/commands.py
setTrackName(track, name)
¶
showImportVideos(filenames)
¶
signal_update(what)
¶
toggleCurrentFrameNegative()
¶
toggleGrayscale()
¶
transposeInstance()
¶
Transposes tracks for two instances.
If there are only two instances, then this swaps tracks. Otherwise, it allows user to select the instances for which we want to swap tracks.
Source code in sleap/gui/commands.py
DeleteFrameLimitPredictions
¶
Bases: InstanceDeleteCommand
Methods:
| Name | Description |
|---|---|
get_frame_instance_list |
Called from the parent |
Source code in sleap/gui/commands.py
get_frame_instance_list(context, params)
staticmethod
¶
Called from the parent InstanceDeleteCommand.ask method.
Returns:
| Type | Description |
|---|---|
|
List of instances to be deleted. |
Source code in sleap/gui/commands.py
DeleteMultipleTracks
¶
Bases: EditCommand
Methods:
| Name | Description |
|---|---|
do_action |
Delete either all tracks or just unused tracks. |
Source code in sleap/gui/commands.py
do_action(context, params)
staticmethod
¶
Delete either all tracks or just unused tracks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
The command parameters. delete_all: If True, delete all tracks. If False, delete only unused tracks. |
required |
Source code in sleap/gui/commands.py
DeleteUserFramePredictions
¶
Bases: InstanceDeleteCommand
Delete predictions on frames that have user instances.
This command cleans up predictions that were merged into frames that already have user labels, which causes both to be displayed in the GUI (confusing UX).
Two modes are supported:
- Unlinked only (default): Delete predictions not linked via any user instance's
from_predicted attribute. These are the "orphan" predictions causing duplicates.
- All predictions: Delete all predictions on user-labeled frames.
Source code in sleap/gui/commands.py
EditCommand
¶
Bases: AppCommand
Class for commands which change data in project.
Source code in sleap/gui/commands.py
ExportLabeledClip
¶
Bases: AppCommand
Export a labeled video clip with skeleton overlay.
Uses sleap-io's rendering API for high-quality video export with real-time preview capabilities.
Methods:
| Name | Description |
|---|---|
ask |
Show the render dialog and collect export parameters. |
do_action |
Export the labeled video clip. |
write_new_video |
Write annotated video using sleap-io rendering. |
Source code in sleap/gui/commands.py
1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 | |
ask(context, params)
classmethod
¶
Show the render dialog and collect export parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
Dictionary to store collected parameters. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if user confirmed, False if cancelled. |
Source code in sleap/gui/commands.py
1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 | |
do_action(context, params)
classmethod
¶
Export the labeled video clip.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
Export parameters from ask(). |
required |
Source code in sleap/gui/commands.py
1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 | |
write_new_video(context, params)
classmethod
¶
Write annotated video using sleap-io rendering.
.. deprecated::
This method is deprecated. Use render_video_gui() for GUI rendering
with progress dialog, or call sleap_io.render_video() directly for
programmatic use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
The parameters for the export. |
required |
Source code in sleap/gui/commands.py
ExportLabelsSubset
¶
Bases: ExportFullPackage
Export a subset of labels to a new file with either images or a trimmed video.
This command subclasses ExportFullPackage, but uses also uses methods from
ExportVideoClip to provide functionality for exporting a subset of labels to a new
file with either images or a trimmed video. It allows the user to specify the labels
to export and the format of the output file.
Methods:
| Name | Description |
|---|---|
get_labels_subset_unshifted |
Get the labels subset for the export. |
get_lfs_subset |
Get the labeled frames subset for the export. |
get_or_create_video_subset |
Get the video subset for the export. |
get_suggestions_subset |
Get the suggestions subset for the labels. |
Source code in sleap/gui/commands.py
2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 | |
get_labels_subset_unshifted(context, params)
classmethod
¶
Get the labels subset for the export.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
The parameters for the export. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Labels |
Labels
|
The labels subset for the export. |
Source code in sleap/gui/commands.py
get_lfs_subset(labels_subset_unshifted, video_subset, params)
classmethod
¶
Get the labeled frames subset for the export.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels_subset_unshifted
|
Labels
|
The labels subset to export. |
required |
video_subset
|
Video
|
The video subset to export. |
required |
params
|
dict
|
The parameters for the export. |
required |
Returns:
| Type | Description |
|---|---|
list[LabeledFrame]
|
list[LabeledFrame]: The labeled frames subset for the export. |
Source code in sleap/gui/commands.py
get_or_create_video_subset(context, params)
classmethod
¶
Get the video subset for the export.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
The parameters for the export. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Video |
Video
|
The video subset for the export. |
Source code in sleap/gui/commands.py
get_suggestions_subset(labels_subset_unshifted, video_subset, params)
classmethod
¶
Get the suggestions subset for the labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels_subset_unshifted
|
Labels
|
The labels subset to export. |
required |
video_subset
|
Video
|
The video subset to export. |
required |
Returns:
| Type | Description |
|---|---|
list[SuggestionFrame]
|
list[SuggestionFrame]: The suggestions subset for the labels. |
Source code in sleap/gui/commands.py
ExportPackageThread
¶
Bases: QThread
Background thread for exporting labels package without freezing GUI.
Methods:
| Name | Description |
|---|---|
cancel |
Request cancellation of the export. |
run |
Run the export in background thread. |
Source code in sleap/gui/commands.py
1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 | |
cancel()
¶
run()
¶
Run the export in background thread.
Source code in sleap/gui/commands.py
1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 | |
ExportVideoClip
¶
Bases: AppCommand
Base class for exporting video clips.
The ask method provides all functionality to gather parameters from the export dialog.
Methods:
| Name | Description |
|---|---|
ask |
Ask the user for parameters to export a video clip. |
do_action |
Export video clip using the parameters provided. |
get_export_options |
Get export options from the user. |
get_frame_range_params |
Get frame range parameters. |
get_video_augmentation_params |
Get video augmentation parameters. |
get_video_markup_params |
Get video markup parameters. |
get_video_save_params |
Get video save parameters. |
write_new_video |
Write a new video using the parameters provided. |
Source code in sleap/gui/commands.py
1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 | |
ask(context, params)
classmethod
¶
Ask the user for parameters to export a video clip.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
The parameters for the export. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the user provided valid parameters, False otherwise. |
Source code in sleap/gui/commands.py
do_action(context, params)
classmethod
¶
Export video clip using the parameters provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
The parameters for the export. |
required |
Source code in sleap/gui/commands.py
get_export_options(context, params)
classmethod
¶
Get export options from the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
The parameters for the export. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict | None
|
The export options. |
Source code in sleap/gui/commands.py
get_frame_range_params(context, params)
classmethod
¶
Get frame range parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
The parameters for the export. |
required |
Side Effects
Sets "frames" in params.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Containing the frame range parameters (in addition to other params). |
Source code in sleap/gui/commands.py
get_video_augmentation_params(context, params, export_options)
classmethod
¶
Get video augmentation parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
The parameters for the export. |
required |
export_options
|
dict
|
The export options. |
required |
Side Effects
Sets "scale", "background", and "crop" in params.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Containing the video augmentation parameters (in addition to other params). |
Source code in sleap/gui/commands.py
get_video_markup_params(context, params, export_options)
classmethod
¶
Get video markup parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
The parameters for the export. |
required |
export_options
|
dict
|
The export options. |
required |
Side Effects
Sets "color_manager", "show edges", "edge_is_wedge", and "marker size" in params.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Containing the video markup parameters (in addition to other params). |
Source code in sleap/gui/commands.py
get_video_save_params(params, export_options)
classmethod
¶
Get video save parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
dict
|
The parameters for the export. |
required |
export_options
|
dict
|
The export options. |
required |
Side Effects
Sets "video_filename", "fps", and "open_when_done" in params.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Containing the video save parameters (in addition to other params). |
Source code in sleap/gui/commands.py
write_new_video(context, params)
classmethod
¶
Write a new video using the parameters provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The command context. |
required |
params
|
dict
|
The parameters for the export. |
required |
Source code in sleap/gui/commands.py
FakeApp
¶
GenerateSuggestionsThread
¶
Bases: QThread
Background thread for generating frame suggestions without freezing GUI.
Source code in sleap/gui/commands.py
GoIteratorCommand
¶
Bases: AppCommand
Source code in sleap/gui/commands.py
InstanceDeleteCommand
¶
Bases: EditCommand
Source code in sleap/gui/commands.py
3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 | |
LoadLabelsObject
¶
Bases: AppCommand
Methods:
| Name | Description |
|---|---|
do_action |
Loads a |
Source code in sleap/gui/commands.py
do_action(context, params)
staticmethod
¶
Loads a Labels object into the GUI, replacing any currently loaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
The |
required | |
filename
|
The filename where this file is saved, if any. |
required |
Returns:
| Type | Description |
|---|---|
|
None. |
Source code in sleap/gui/commands.py
MergeInstances
¶
Bases: EditCommand
Merge two user instances in the current frame into a single instance.
The currently selected instance (context.state["instance"]) is the
survivor. The instance to merge into it is the donor, taken from
params["donor"]; if no donor is given and the frame has exactly two
user instances, the other one is used automatically.
For every skeleton node, if the survivor's node is missing (NaN coordinates
or not visible) and the donor's node is labeled/visible, the donor's
xy/visible/complete values are copied onto the survivor. This
lets a "front keypoints" instance and a "back keypoints" instance be
combined into one. The survivor keeps its own track.
Conflict policy: if BOTH the survivor and the donor have a node labeled/visible, the survivor's value is kept (the donor's value for that node is discarded).
Scope/behavior decisions:
- Only user Instances participate. PredictedInstances are never
chosen as survivor or donor and are left untouched on the frame.
- If there are fewer than two user instances, no donor can be resolved,
the survivor is not a user Instance, or required state is
missing, this is a no-op (with a status message when running in the
GUI).
- After merging, the donor is removed from the frame by identity and
labels.update() is called. There is no dedicated undo (matching
DeleteSelectedInstance/PasteInstance); EditCommand only
flags the project as having unsaved changes.
Source code in sleap/gui/commands.py
3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 | |
OpenSkeleton
¶
Bases: EditCommand
Methods:
| Name | Description |
|---|---|
do_action |
Replace skeleton with new skeleton. |
get_template_skeleton_filename |
Helper function to get the template skeleton filename from dropdown. |
Source code in sleap/gui/commands.py
3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 | |
do_action(context, params)
staticmethod
¶
Replace skeleton with new skeleton.
Note that we modify the existing skeleton in-place to essentially match the new
skeleton. However, we cannot rename the skeleton since Skeleton.name is used
for hashing (see Skeleton.name setter).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
CommandContext |
required |
params
|
dict
|
dict filename: str delete_nodes: List[str] add_nodes: List[str] linked_nodes: Dict[str, str] |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in sleap/gui/commands.py
3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 | |
get_template_skeleton_filename(context)
staticmethod
¶
Helper function to get the template skeleton filename from dropdown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
CommandContext
|
The |
required |
Returns:
| Type | Description |
|---|---|
str
|
Path to the template skeleton shipped with SLEAP. |
Source code in sleap/gui/commands.py
RenderVideoThread
¶
Bases: QThread
Background thread for rendering video without freezing GUI.
Uses sleap-io's render_video() with progress_callback for non-blocking rendering.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the render video thread. |
cancel |
Request cancellation of the render. |
run |
Run the render in background thread. |
Source code in sleap/gui/commands.py
1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 | |
__init__(labels, filename, video, frame_inds, render_params, parent=None)
¶
Initialize the render video thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
Labels object to render. |
required | |
filename
|
str
|
Output video path. |
required |
video
|
Video to render from. |
required | |
frame_inds
|
list[int] | None
|
Frame indices to render (None = all labeled). |
required |
render_params
|
dict
|
Dict of rendering parameters for sio.render_video(). |
required |
parent
|
Parent QObject. |
None
|
Source code in sleap/gui/commands.py
cancel()
¶
run()
¶
Run the render in background thread.
Source code in sleap/gui/commands.py
ReplaceVideo
¶
Bases: EditCommand
Methods:
| Name | Description |
|---|---|
ask |
Shows gui for replacing videos in project. |
Source code in sleap/gui/commands.py
2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 | |
ask(context, params)
staticmethod
¶
Shows gui for replacing videos in project.
Source code in sleap/gui/commands.py
2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 | |
SaveProjectAs
¶
Bases: AppCommand
Source code in sleap/gui/commands.py
1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 | |
SetInstancePointLocations
¶
Bases: EditCommand
Sets locations for node(s) for an instance.
Note: It's important that this command does not update the visual scene, since this would redraw the frame and create new visual objects. The calling code is responsible for updating the visual scene.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
The instance |
required | |
nodes_locations
|
A dictionary of data to set |
required |
Source code in sleap/gui/commands.py
SetInstancePointVisibility
¶
Bases: EditCommand
Toggles visibility set for a node for an instance.
Note: It's important that this command does not update the visual scene, since this would redraw the frame and create new visual objects. The calling code is responsible for updating the visual scene.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
The instance |
required | |
node
|
The |
required | |
visible
|
Whether to set or clear visibility for node |
required |
Source code in sleap/gui/commands.py
ToggleGrayscale
¶
Bases: EditCommand
Methods:
| Name | Description |
|---|---|
do_action |
Reset the video backend. |
Source code in sleap/gui/commands.py
do_action(context, params)
staticmethod
¶
Reset the video backend.
Source code in sleap/gui/commands.py
ToggleNegativeFrame
¶
Bases: EditCommand
Mark or unmark the current frame as a negative (background) frame.
A negative frame is explicitly marked as containing no animals. It is used as a background training example so the model learns to predict nothing on empty frames, which reduces false positives.
Source code in sleap/gui/commands.py
4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 | |
UpdateTopic
¶
Bases: Enum
Topics so context can tell callback what was updated by the command.
Source code in sleap/gui/commands.py
copy_to_clipboard(text)
¶
Copy a string to the system clipboard. Args: text: String to copy to clipboard.
Source code in sleap/gui/commands.py
export_dataset_gui(labels, filename, all_labeled=False, suggested=False, verbose=True, as_package=True)
¶
Export dataset with image data and display progress GUI dialog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
Labels
|
|
required |
filename
|
str
|
Output filename. Should end in |
required |
all_labeled
|
bool
|
If |
False
|
suggested
|
bool
|
If |
False
|
verbose
|
bool
|
If |
True
|
as_package
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The filename if successful, "canceled" if canceled by user. |
Source code in sleap/gui/commands.py
2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 | |
get_new_version_filename(filename)
¶
Increment version number in filenames that end in .v###.slp.
Source code in sleap/gui/commands.py
open_file(filename)
¶
Opens file in native system file browser or registered application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to file or folder. |
required |
Notes
Source code in sleap/gui/commands.py
open_website(url)
¶
Open website in default browser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to open. |
required |
render_video_gui(labels, filename, video, frame_inds, render_params, open_when_done=True)
¶
Render video with progress dialog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
Labels object to render. |
required | |
filename
|
str
|
Output video path. |
required |
video
|
Video to render from. |
required | |
frame_inds
|
list[int] | None
|
Frame indices to render (None = all labeled). |
required |
render_params
|
dict
|
Dict of rendering parameters for sio.render_video(). |
required |
open_when_done
|
bool
|
If True, open video after rendering. |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The filename if successful, "canceled" if canceled by user. |
Source code in sleap/gui/commands.py
1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 | |
reveal_file(filepath)
¶
Open the file explorer with the given file selected/revealed.
Similar to open_file() but reveals the file in its containing folder
rather than opening it with the default application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
The path to the file to reveal. |
required |