simba-uw-tf-dev 4.6.4__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.
- simba/data_processors/cuda/geometry.py +45 -27
- simba/data_processors/cuda/image.py +1620 -1600
- simba/data_processors/cuda/statistics.py +17 -9
- simba/data_processors/egocentric_aligner.py +24 -6
- simba/data_processors/kleinberg_calculator.py +6 -2
- simba/feature_extractors/feature_subsets.py +12 -5
- simba/feature_extractors/straub_tail_analyzer.py +0 -2
- simba/mixins/statistics_mixin.py +9 -2
- simba/sandbox/analyze_runtimes.py +30 -0
- simba/sandbox/cuda/egocentric_rotator.py +374 -374
- simba/sandbox/proboscis_to_tip.py +28 -0
- simba/sandbox/test_directionality.py +47 -0
- simba/sandbox/test_nonstatic_directionality.py +27 -0
- simba/sandbox/test_pycharm_cuda.py +51 -0
- simba/sandbox/test_simba_install.py +41 -0
- simba/sandbox/test_static_directionality.py +26 -0
- simba/sandbox/test_static_directionality_2d.py +26 -0
- simba/sandbox/verify_env.py +42 -0
- simba/ui/pop_ups/fsttc_pop_up.py +27 -25
- simba/ui/pop_ups/kleinberg_pop_up.py +3 -2
- simba/utils/data.py +0 -1
- simba/utils/errors.py +441 -440
- simba/utils/lookups.py +1203 -1203
- simba/utils/read_write.py +38 -13
- simba/video_processors/egocentric_video_rotator.py +41 -36
- simba/video_processors/video_processing.py +5247 -5233
- simba/video_processors/videos_to_frames.py +41 -31
- {simba_uw_tf_dev-4.6.4.dist-info → simba_uw_tf_dev-4.6.6.dist-info}/METADATA +2 -2
- {simba_uw_tf_dev-4.6.4.dist-info → simba_uw_tf_dev-4.6.6.dist-info}/RECORD +33 -24
- {simba_uw_tf_dev-4.6.4.dist-info → simba_uw_tf_dev-4.6.6.dist-info}/LICENSE +0 -0
- {simba_uw_tf_dev-4.6.4.dist-info → simba_uw_tf_dev-4.6.6.dist-info}/WHEEL +0 -0
- {simba_uw_tf_dev-4.6.4.dist-info → simba_uw_tf_dev-4.6.6.dist-info}/entry_points.txt +0 -0
- {simba_uw_tf_dev-4.6.4.dist-info → simba_uw_tf_dev-4.6.6.dist-info}/top_level.txt +0 -0
|
@@ -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,
|
|
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
|
|
407
|
+
if i >= left_ear.shape[0]:
|
|
407
408
|
return
|
|
408
409
|
else:
|
|
409
|
-
LE
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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
|
|
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,
|
|
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
|
|
518
|
+
if i >= left_ear.shape[0]:
|
|
512
519
|
return
|
|
513
520
|
else:
|
|
514
|
-
LE
|
|
515
|
-
|
|
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
|
|
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
|
-
>>>
|
|
593
|
+
>>> directionality_to_nonstatic_target(left_ear=left_ear, right_ear=right_ear, nose=nose, target=target)
|
|
577
594
|
"""
|
|
578
595
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
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.
|
|
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
|
-
|