-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsosyal2.py
60 lines (48 loc) · 2.59 KB
/
sosyal2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import numpy as np
from fillmissing import fill_missing
from loadh5 import load_h5_data
from cleaning import clean_and_validate_data
from proximity import detect_proximity_interactions_with_nodes_and_angles
from gui import create_gui, get_xy_range, digital_imprint_frame
# Load data using the load_h5_data function from loadh5.py
filename = "h5try/7_3_dev.h5" # Replace with your actual file path
"""
try:
# Load and preprocess data
print("Loading data...")
frame_count, node_count, instance_count, locations, track_names, node_names = load_h5_data(filename)
cleaned_locations = clean_and_validate_data(locations)
filled_locations = fill_missing(cleaned_locations)
# Detect and print proximity interactions with nodes and angles
interactions = detect_proximity_interactions_with_nodes_and_angles(
filled_locations,
proximity_threshold=400,
min_angle=50,
max_angle=130
)
print("Detected Interactions with Node and Angle Information:")
for interaction in interactions:
print(f"Active termite {interaction[0]} interacted with passive termite {interaction[1]} at node {interaction[2]} "
f"between frames {interaction[3]} and {interaction[4]}")
# Launch the GUI for interactive visualization
create_gui(filled_locations, interactions, track_names=track_names, node_names=node_names)
except Exception as e:
print(f"An error occurred: {e}")
"""
# Main code
if __name__ == "__main__":
# Load data using the load_h5_data function from loadh5.py
filename = "h5try/7_3_dev.h5" # Replace with your actual file path
frame_count, node_count, instance_count, locations, track_names, node_names = load_h5_data(filename)
# Clean and validate the data using the function from cleaning.py
cleaned_locations = clean_and_validate_data(locations)
# Fill missing data (if needed)
filled_locations = fill_missing(cleaned_locations)
interactions = detect_proximity_interactions_with_nodes_and_angles(filled_locations, proximity_threshold=400, min_angle=50, max_angle=130)
#print("Detected Interactions with Node and Angle Information:")
#for interaction in interactions:
#print(f"Active termite {interaction[0]} interacted with passive termite {interaction[1]} at node {interaction[2]} between frames {interaction[3]} and {interaction[4]}")
# Get x and y range from the .h5 file
x_min, x_max, y_min, y_max = get_xy_range(filename)
# Create GUI for visualizing specific frames
create_gui(filled_locations, interactions, x_min, x_max, y_min, y_max, track_names=track_names, node_names=node_names)