simba-uw-tf-dev 4.6.3__py3-none-any.whl → 4.6.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. simba/assets/lookups/tooptips.json +6 -1
  2. simba/data_processors/cuda/geometry.py +45 -27
  3. simba/data_processors/cuda/image.py +1620 -1600
  4. simba/data_processors/cuda/statistics.py +17 -9
  5. simba/data_processors/egocentric_aligner.py +24 -6
  6. simba/data_processors/kleinberg_calculator.py +61 -29
  7. simba/feature_extractors/feature_subsets.py +12 -5
  8. simba/feature_extractors/straub_tail_analyzer.py +0 -2
  9. simba/mixins/statistics_mixin.py +9 -2
  10. simba/plotting/gantt_creator_mp.py +7 -5
  11. simba/plotting/pose_plotter_mp.py +7 -3
  12. simba/plotting/roi_plotter_mp.py +4 -3
  13. simba/plotting/yolo_pose_track_visualizer.py +3 -2
  14. simba/plotting/yolo_pose_visualizer.py +5 -4
  15. simba/sandbox/analyze_runtimes.py +30 -0
  16. simba/sandbox/cuda/egocentric_rotator.py +374 -374
  17. simba/sandbox/proboscis_to_tip.py +28 -0
  18. simba/sandbox/test_directionality.py +47 -0
  19. simba/sandbox/test_nonstatic_directionality.py +27 -0
  20. simba/sandbox/test_pycharm_cuda.py +51 -0
  21. simba/sandbox/test_simba_install.py +41 -0
  22. simba/sandbox/test_static_directionality.py +26 -0
  23. simba/sandbox/test_static_directionality_2d.py +26 -0
  24. simba/sandbox/verify_env.py +42 -0
  25. simba/ui/pop_ups/fsttc_pop_up.py +27 -25
  26. simba/ui/pop_ups/kleinberg_pop_up.py +39 -40
  27. simba/ui/tkinter_functions.py +3 -0
  28. simba/utils/data.py +0 -1
  29. simba/utils/errors.py +441 -440
  30. simba/utils/lookups.py +1203 -1203
  31. simba/utils/printing.py +124 -125
  32. simba/utils/read_write.py +43 -14
  33. simba/video_processors/egocentric_video_rotator.py +41 -36
  34. simba/video_processors/video_processing.py +5247 -5233
  35. simba/video_processors/videos_to_frames.py +41 -31
  36. {simba_uw_tf_dev-4.6.3.dist-info → simba_uw_tf_dev-4.6.6.dist-info}/METADATA +2 -2
  37. {simba_uw_tf_dev-4.6.3.dist-info → simba_uw_tf_dev-4.6.6.dist-info}/RECORD +41 -32
  38. {simba_uw_tf_dev-4.6.3.dist-info → simba_uw_tf_dev-4.6.6.dist-info}/LICENSE +0 -0
  39. {simba_uw_tf_dev-4.6.3.dist-info → simba_uw_tf_dev-4.6.6.dist-info}/WHEEL +0 -0
  40. {simba_uw_tf_dev-4.6.3.dist-info → simba_uw_tf_dev-4.6.6.dist-info}/entry_points.txt +0 -0
  41. {simba_uw_tf_dev-4.6.3.dist-info → simba_uw_tf_dev-4.6.6.dist-info}/top_level.txt +0 -0
@@ -38,5 +38,10 @@
38
38
  "EGOCENTRIC_ANCHOR": "This body-part will be placed in the center of the video",
39
39
  "EGOCENTRIC_DIRECTION_ANCHOR": "This body-part will be placed at N degrees relative to the anchor",
40
40
  "EGOCENTRIC_DIRECTION": "The anchor body-part will always be placed at these degrees relative to the center anchor",
41
- "CORE_COUNT": "Higher core counts speeds up processing but may require more RAM memory"
41
+ "CORE_COUNT": "Higher core counts speeds up processing but may require more RAM memory",
42
+ "KLEINBERG_SIGMA": "Higher values (e.g., 2-3) produce fewer but longer bursts; lower values (e.g., 1.1-1.5) detect more frequent, shorter bursts. Must be > 1.01",
43
+ "KLEINBERG_GAMMA": "Higher values (e.g., 0.5-1.0) reduce total burst count by making downward transitions costly; lower values (e.g., 0.1-0.3) allow more flexible state changes",
44
+ "KLEINBERG_HIERARCHY": "Hierarchy level to extract bursts from (0=lowest, higher=more selective).\n Level 0 captures all bursts; level 1-2 typically filters noise; level 3+ selects only the most prominent, sustained bursts.\nHigher levels yield fewer but more confident detections",
45
+ "KLEINBERG_HIERARCHY_SEARCH": "If True, searches for target hierarchy level within detected burst periods,\n falling back to lower levels if target not found. If False, extracts only bursts at the exact specified hierarchy level.\n Recommended when target hierarchy may be sparse.",
46
+ "KLEINBERG_SAVE_ORIGINALS": "If True, saves the original data in a new sub-directory of \nthe project_folder/csv/machine_results directory"
42
47
  }
@@ -8,6 +8,7 @@ from numba import cuda, njit
8
8
 
9
9
  from simba.utils.checks import check_float, check_valid_array
10
10
  from simba.utils.enums import Formats
11
+ from simba.utils.printing import SimbaTimer
11
12
 
12
13
  try:
13
14
  import cupy as cp
@@ -401,20 +402,21 @@ def find_midpoints(x: np.ndarray,
401
402
 
402
403
 
403
404
  @cuda.jit()
404
- def _directionality_to_static_targets_kernel(left_ear, right_ear, nose, target, results):
405
+ def _directionality_to_static_targets_kernel(left_ear, right_ear, nose, target_x, target_y, results):
405
406
  i = cuda.grid(1)
406
- if i > left_ear.shape[0]:
407
+ if i >= left_ear.shape[0]:
407
408
  return
408
409
  else:
409
- LE, RE = left_ear[i], right_ear[i]
410
- N, Tx, Ty = nose[i], target[0], target[1]
411
-
412
- Px = abs(LE[0] - Tx)
413
- Py = abs(LE[1] - Ty)
414
- Qx = abs(RE[0] - Tx)
415
- Qy = abs(RE[1] - Ty)
416
- Nx = abs(N[0] - Tx)
417
- Ny = abs(N[1] - Ty)
410
+ LE = left_ear[i]
411
+ RE = right_ear[i]
412
+ N = nose[i]
413
+
414
+ Px = abs(LE[0] - target_x)
415
+ Py = abs(LE[1] - target_y)
416
+ Qx = abs(RE[0] - target_x)
417
+ Qy = abs(RE[1] - target_y)
418
+ Nx = abs(N[0] - target_x)
419
+ Ny = abs(N[1] - target_y)
418
420
  Ph = math.sqrt(Px * Px + Py * Py)
419
421
  Qh = math.sqrt(Qx * Qx + Qy * Qy)
420
422
  Nh = math.sqrt(Nx * Nx + Ny * Ny)
@@ -438,7 +440,8 @@ def _directionality_to_static_targets_kernel(left_ear, right_ear, nose, target,
438
440
  def directionality_to_static_targets(left_ear: np.ndarray,
439
441
  right_ear: np.ndarray,
440
442
  nose: np.ndarray,
441
- target: np.ndarray) -> np.ndarray:
443
+ target: np.ndarray,
444
+ verbose: bool = False) -> np.ndarray:
442
445
  """
443
446
  GPU helper to calculate if an animal is directing towards a static location (e.g., ROI centroid), given the target location and the left ear, right ear, and nose coordinates of the observer.
444
447
 
@@ -487,32 +490,38 @@ def directionality_to_static_targets(left_ear: np.ndarray,
487
490
  >>> directionality_to_static_targets(left_ear=left_ear, right_ear=right_ear, nose=nose, target=target)
488
491
 
489
492
  """
490
-
493
+ timer = SimbaTimer(start=True)
491
494
  left_ear = np.ascontiguousarray(left_ear).astype(np.int32)
492
495
  right_ear = np.ascontiguousarray(right_ear).astype(np.int32)
493
496
  nose = np.ascontiguousarray(nose).astype(np.int32)
494
497
  target = np.ascontiguousarray(target).astype(np.int32)
495
498
 
499
+ target_x = int(target[0])
500
+ target_y = int(target[1])
501
+
496
502
  left_ear_dev = cuda.to_device(left_ear)
497
503
  right_ear_dev = cuda.to_device(right_ear)
498
504
  nose_dev = cuda.to_device(nose)
499
- target_dev = cuda.to_device(target)
500
505
  results = cuda.device_array((left_ear.shape[0], 4), dtype=np.int32)
501
506
  bpg = (left_ear.shape[0] + (THREADS_PER_BLOCK - 1)) // THREADS_PER_BLOCK
502
- _directionality_to_static_targets_kernel[bpg, THREADS_PER_BLOCK](left_ear_dev, right_ear_dev, nose_dev, target_dev, results)
507
+ _directionality_to_static_targets_kernel[bpg, THREADS_PER_BLOCK](left_ear_dev, right_ear_dev, nose_dev, target_x, target_y, results)
503
508
 
504
509
  results = results.copy_to_host()
510
+ timer.stop_timer()
511
+ if verbose: print(f'Directionality to static target computed in for {left_ear.shape[0]} observations (elapsed time: {timer.elapsed_time_str}s)')
505
512
  return results
506
513
 
507
514
 
508
515
  @cuda.jit()
509
516
  def _directionality_to_nonstatic_targets_kernel(left_ear, right_ear, nose, target, results):
510
517
  i = cuda.grid(1)
511
- if i > left_ear.shape[0]:
518
+ if i >= left_ear.shape[0]:
512
519
  return
513
520
  else:
514
- LE, RE = left_ear[i], right_ear[i]
515
- N, T = nose[i], target[i]
521
+ LE = left_ear[i]
522
+ RE = right_ear[i]
523
+ N = nose[i]
524
+ T = target[i]
516
525
 
517
526
  Px = abs(LE[0] - T[0])
518
527
  Py = abs(LE[1] - T[1])
@@ -543,11 +552,19 @@ def _directionality_to_nonstatic_targets_kernel(left_ear, right_ear, nose, targe
543
552
  def directionality_to_nonstatic_target(left_ear: np.ndarray,
544
553
  right_ear: np.ndarray,
545
554
  nose: np.ndarray,
546
- target: np.ndarray) -> np.ndarray:
555
+ target: np.ndarray,
556
+ verbose: bool = False) -> np.ndarray:
547
557
 
548
558
  """
549
559
  GPU method to calculate if an animal is directing towards a moving point location given the target location and the left ear, right ear, and nose coordinates of the observer.
550
560
 
561
+ .. csv-table::
562
+ :header: EXPECTED RUNTIMES
563
+ :file: ../../../docs/tables/directionality_to_nonstatic_target_cuda.csv
564
+ :widths: 30, 30, 20, 10, 10
565
+ :align: center
566
+ :class: simba-table
567
+ :header-rows: 1
551
568
 
552
569
  .. image:: _static/img/directing_moving_targets.png
553
570
  :width: 400
@@ -573,27 +590,28 @@ def directionality_to_nonstatic_target(left_ear: np.ndarray,
573
590
  >>> right_ear = np.random.randint(0, 500, (100, 2))
574
591
  >>> nose = np.random.randint(0, 500, (100, 2))
575
592
  >>> target = np.random.randint(0, 500, (100, 2))
576
- >>> directionality_to_static_targets(left_ear=left_ear, right_ear=right_ear, nose=nose, target=target)
593
+ >>> directionality_to_nonstatic_target(left_ear=left_ear, right_ear=right_ear, nose=nose, target=target)
577
594
  """
578
595
 
579
- left_ear = np.ascontiguousarray(left_ear).astype(np.int32)
580
- right_ear = np.ascontiguousarray(right_ear).astype(np.int32)
581
- nose = np.ascontiguousarray(nose).astype(np.int32)
582
- target = np.ascontiguousarray(target).astype(np.int32)
596
+ timer = SimbaTimer(start=True)
597
+ left_ear = np.ascontiguousarray(left_ear).astype(np.int64)
598
+ right_ear = np.ascontiguousarray(right_ear).astype(np.int64)
599
+ nose = np.ascontiguousarray(nose).astype(np.int64)
600
+ target = np.ascontiguousarray(target).astype(np.int64)
583
601
 
584
602
  left_ear_dev = cuda.to_device(left_ear)
585
603
  right_ear_dev = cuda.to_device(right_ear)
586
604
  nose_dev = cuda.to_device(nose)
587
605
  target_dev = cuda.to_device(target)
588
- results = cuda.device_array((left_ear.shape[0], 4), dtype=np.int32)
606
+ results = cuda.device_array((left_ear.shape[0], 4), dtype=np.int64)
589
607
  bpg = (left_ear.shape[0] + (THREADS_PER_BLOCK - 1)) // THREADS_PER_BLOCK
590
608
  _directionality_to_nonstatic_targets_kernel[bpg, THREADS_PER_BLOCK](left_ear_dev, right_ear_dev, nose_dev, target_dev, results)
591
609
 
592
610
  results = results.copy_to_host()
611
+ timer.stop_timer()
612
+ if verbose: print(f'Directionality to moving target computed in for {left_ear.shape[0]} observations (elapsed time: {timer.elapsed_time_str}s)')
593
613
  return results
594
614
 
595
615
 
596
616
 
597
617
 
598
-
599
-