tottag 1.1.0__tar.gz

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.
@@ -0,0 +1,2 @@
1
+ include dashboard/*.ico
2
+ include dashboard/*.png
tottag-1.1.0/PKG-INFO ADDED
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: tottag
3
+ Version: 1.1.0
4
+ Summary: TotTag Management Dashboard
5
+ Home-page: https://github.com/lab11/socitrack
6
+ Author: Will Hedgecock
7
+ Author-email: ronald.w.hedgecock@vanderbilt.edu
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/x-rst
12
+ Requires-Dist: bleak
13
+ Requires-Dist: matplotlib
14
+ Requires-Dist: numpy
15
+ Requires-Dist: pandas
16
+ Requires-Dist: pytz
17
+ Requires-Dist: scipy
18
+ Requires-Dist: pyserial
19
+ Requires-Dist: babel
20
+ Requires-Dist: tzlocal
21
+ Requires-Dist: tk
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: requires-dist
29
+ Dynamic: requires-python
30
+ Dynamic: summary
31
+
32
+ TotTag Management Dashboard
33
+ ===========================
34
+
35
+ Overview
36
+ --------
37
+
38
+ This directory contains all source code for the TotTag Management Dashboard. All setup and preparation for live pilot testing should be carried out through the TotTag Dashboard.
39
+
40
+
41
+ Installation
42
+ ------------
43
+
44
+ The easiest way to install this tool is through `pip` by entering:
45
+
46
+ ``python3 -m pip install tottag``
47
+
48
+ If you wish to install the package manually or develop it further, you should first clone the `SociTrack repository <https://github.com/lab11/socitrack>`_ to
49
+ your hard drive, `cd` into the ``software/management`` directory, then issue the following command in a terminal:
50
+
51
+ ``python3 -m pip install -e .``
52
+
53
+
54
+ Usage
55
+ -----
56
+
57
+ Once installed, the management dashboard is accessible from any terminal by entering the following command:
58
+
59
+ ``tottag``
60
+
61
+ You do not need to navigate to the SociTrack source code directory to run the application.
62
+
63
+ Usage of the TotTag Dashboard should be relatively straightforward, keeping in mind a few caveats:
64
+
65
+ • A TotTag device is only discoverable and visible if it is currently being charged. If the device is not on a charger, it will not appear in the TotTag Dashboard.
66
+ • You will not be able to carry out any management functionality unless you are actively connected to a TotTag, so if the action buttons are grayed out, ensure that you are actually connected to a device.
67
+ • If, at any time, the application freezes or becomes unresponsive, you can always force it to close by returning to the terminal in which you entered the “tottag” command and simultaneously pressing CTRL+C. This should cause the application to forcefully terminate.
68
+
69
+ The suggested procedure for setting up a pilot deployment is the following:
70
+
71
+ 1. Determine exactly how many TotTags will be needed for the deployment, and choose this number of devices to set aside.
72
+ 2. Make a note on a piece of scratch paper about which Device IDs should be associated with which user-friendly labels.
73
+ 3. Open the TotTag Dashboard and go to the “Deployment” tab. Do not connect to any TotTags at this time.
74
+ 4. Enter all relevant information about the upcoming deployment, including the mapping of TotTag labels to Device IDs.
75
+ 5. Once all information has been entered, ensure that all relevant TotTags are discoverable in the device bar at the top of the dashboard.
76
+ 6. Click the “Start” button to start the deployment programming process for all relevant devices.
77
+ 7. Once complete, it is a good idea to individually connect to each of the participating devices and verify that both the current time and the experiment details are correct.
78
+
79
+ After the above steps have been completed, your devices are ready for shipment and will automatically shut down until time for the deployment to begin. Upon completion of a pilot test, the first thing you should do upon receipt of the TotTags is to download all log files before putting the TotTags back into storage.
@@ -0,0 +1,48 @@
1
+ TotTag Management Dashboard
2
+ ===========================
3
+
4
+ Overview
5
+ --------
6
+
7
+ This directory contains all source code for the TotTag Management Dashboard. All setup and preparation for live pilot testing should be carried out through the TotTag Dashboard.
8
+
9
+
10
+ Installation
11
+ ------------
12
+
13
+ The easiest way to install this tool is through `pip` by entering:
14
+
15
+ ``python3 -m pip install tottag``
16
+
17
+ If you wish to install the package manually or develop it further, you should first clone the `SociTrack repository <https://github.com/lab11/socitrack>`_ to
18
+ your hard drive, `cd` into the ``software/management`` directory, then issue the following command in a terminal:
19
+
20
+ ``python3 -m pip install -e .``
21
+
22
+
23
+ Usage
24
+ -----
25
+
26
+ Once installed, the management dashboard is accessible from any terminal by entering the following command:
27
+
28
+ ``tottag``
29
+
30
+ You do not need to navigate to the SociTrack source code directory to run the application.
31
+
32
+ Usage of the TotTag Dashboard should be relatively straightforward, keeping in mind a few caveats:
33
+
34
+ • A TotTag device is only discoverable and visible if it is currently being charged. If the device is not on a charger, it will not appear in the TotTag Dashboard.
35
+ • You will not be able to carry out any management functionality unless you are actively connected to a TotTag, so if the action buttons are grayed out, ensure that you are actually connected to a device.
36
+ • If, at any time, the application freezes or becomes unresponsive, you can always force it to close by returning to the terminal in which you entered the “tottag” command and simultaneously pressing CTRL+C. This should cause the application to forcefully terminate.
37
+
38
+ The suggested procedure for setting up a pilot deployment is the following:
39
+
40
+ 1. Determine exactly how many TotTags will be needed for the deployment, and choose this number of devices to set aside.
41
+ 2. Make a note on a piece of scratch paper about which Device IDs should be associated with which user-friendly labels.
42
+ 3. Open the TotTag Dashboard and go to the “Deployment” tab. Do not connect to any TotTags at this time.
43
+ 4. Enter all relevant information about the upcoming deployment, including the mapping of TotTag labels to Device IDs.
44
+ 5. Once all information has been entered, ensure that all relevant TotTags are discoverable in the device bar at the top of the dashboard.
45
+ 6. Click the “Start” button to start the deployment programming process for all relevant devices.
46
+ 7. Once complete, it is a good idea to individually connect to each of the participating devices and verify that both the current time and the experiment details are correct.
47
+
48
+ After the above steps have been completed, your devices are ready for shipment and will automatically shut down until time for the deployment to begin. Upon completion of a pilot test, the first thing you should do upon receipt of the TotTags is to download all log files before putting the TotTags back into storage.
@@ -0,0 +1,59 @@
1
+ """
2
+ Function: This script finds all .pkl files in a specified directory, extracts the subject_id from the filename,
3
+ loads the corresponding data, and processes it using the get_daily_ranging_statistics function.
4
+
5
+ Usage:
6
+ cd SociTrack/software/management/dashboard
7
+ python3 1_tottags_batch.py
8
+ """
9
+
10
+ import re
11
+ import csv
12
+
13
+ # Define input and output file paths
14
+ input_file = "/Users/hannahpiersiak/Desktop/tottags/ranging_statistics.txt"
15
+ output_file = "/Users/hannahpiersiak/Desktop/tottags/ranging_statistics.csv"
16
+
17
+ # Open the input file and read its contents
18
+ with open(input_file, "r") as file:
19
+ data = file.readlines()
20
+
21
+ # Prepare data extraction
22
+ csv_data = []
23
+ current_date = None
24
+
25
+ # Regex patterns to extract data
26
+ date_pattern = re.compile(r"Ranging Statistics on (\d{2}/\d{2}/\d{4}):")
27
+ stats_pattern = re.compile(r"Statistics to (r\.\d+_CG\d|Either of \[.*\]):")
28
+ value_pattern = re.compile(r"^\s+(\w.+):\s+([\d.]+|nan)")
29
+
30
+ # Parse the file line by line
31
+ for line in data:
32
+ date_match = date_pattern.search(line)
33
+ stats_match = stats_pattern.search(line)
34
+ value_match = value_pattern.search(line)
35
+
36
+ if date_match:
37
+ current_date = date_match.group(1) # Extract the date
38
+ elif stats_match:
39
+ current_target = stats_match.group(1) # Extract the target (CG1, CG2, or Either)
40
+ minutes_range = minutes_touch = mean_distance = None
41
+ elif value_match:
42
+ key, value = value_match.groups()
43
+ if key == "Minutes in Range":
44
+ minutes_range = value
45
+ elif key == "Minutes in Touching Distance":
46
+ minutes_touch = value
47
+ elif key == "Mean Distance While in Range":
48
+ mean_distance = value
49
+ # Save row when all values for a section are collected
50
+ csv_data.append([current_date, current_target, minutes_range, minutes_touch, mean_distance])
51
+
52
+ # Write to CSV file
53
+ with open(output_file, "w", newline="") as file:
54
+ writer = csv.writer(file)
55
+ writer.writerow(["Date", "Target", "Minutes in Range", "Minutes in Touching Distance", "Mean Distance While in Range"])
56
+ writer.writerows(csv_data)
57
+
58
+ print(f"CSV file saved: {output_file}")
59
+
@@ -0,0 +1,34 @@
1
+ """
2
+ Function: This script finds all .pkl files in a specified directory, extracts the subject_id from the filename,
3
+ loads the corresponding data, and processes it using the get_daily_ranging_statistics function.
4
+
5
+ Usage:
6
+ cd SociTrack/software/management/dashboard
7
+ python3 1_tottags_batch.py
8
+ """
9
+
10
+ import os
11
+ from processing import *
12
+
13
+
14
+ def process_pkl_files(directory):
15
+ """Find all .pkl files in the directory, extract subject_id, load data, and process it."""
16
+ for filename in os.listdir(directory):
17
+ if filename.endswith(".pkl"):
18
+ filepath = os.path.join(directory, filename)
19
+
20
+ # Extract subject_id from filename
21
+ subject_id = filename.split("_")[0]
22
+
23
+ # Load pkl data
24
+ TC = load_data(filepath)
25
+
26
+ # Call the function with formatted parameters
27
+ get_daily_ranging_statistics(TC, [f"{subject_id}_CG1", f"{subject_id}_CG2"], 3)
28
+
29
+
30
+ # Define directory path
31
+ directory_path = "/Users/hannahpiersiak/Desktop/tottags"
32
+
33
+ # Run the function
34
+ process_pkl_files(directory_path)
@@ -0,0 +1,61 @@
1
+ import csv
2
+ import re
3
+
4
+ # Input and output file paths
5
+ input_file = "/Users/hannahpiersiak/Desktop/tottags/ranging_statistics.txt"
6
+ output_file = "/Users/hannahpiersiak/Desktop/tottags/ranging_statistics.csv"
7
+
8
+ # Regular expressions to extract relevant data
9
+ date_pattern = re.compile(r"Ranging Statistics on (\d{2}/\d{2}/\d{4}):")
10
+ entity_pattern = re.compile(r"Statistics to (\S+):")
11
+ minutes_range_pattern = re.compile(r"Minutes in Range: (\d+)")
12
+ minutes_touch_pattern = re.compile(r"Minutes in Touching Distance: (\d+)")
13
+ mean_distance_pattern = re.compile(r"Mean Distance While in Range: (.+)")
14
+
15
+ # Storage variables
16
+ data = []
17
+ current_date = None
18
+ current_entity = None
19
+
20
+ # Read and parse the text file
21
+ with open(input_file, "r") as infile:
22
+ for line in infile:
23
+ line = line.strip()
24
+
25
+ # Extract date
26
+ date_match = date_pattern.match(line)
27
+ if date_match:
28
+ current_date = date_match.group(1)
29
+ print(f"Date found: {current_date}") # Debugging line
30
+ continue
31
+
32
+ # Extract entity
33
+ entity_match = entity_pattern.match(line)
34
+ if entity_match:
35
+ current_entity = entity_match.group(1)
36
+ print(f"Entity found: {current_entity}") # Debugging line
37
+ continue
38
+
39
+ # Extract statistics
40
+ minutes_range_match = minutes_range_pattern.match(line)
41
+ minutes_touch_match = minutes_touch_pattern.match(line)
42
+ mean_distance_match = mean_distance_pattern.match(line)
43
+
44
+ if minutes_range_match:
45
+ minutes_range = int(minutes_range_match.group(1))
46
+ if minutes_touch_match:
47
+ minutes_touch = int(minutes_touch_match.group(1))
48
+ if mean_distance_match:
49
+ mean_distance = mean_distance_match.group(1) # Keep as string for 'nan' handling
50
+
51
+ # Save extracted data
52
+ print(f"Adding data: {current_date}, {current_entity}, {minutes_range}, {minutes_touch}, {mean_distance}") # Debugging line
53
+ data.append([current_date, current_entity, minutes_range, minutes_touch, mean_distance])
54
+
55
+ # Write to CSV
56
+ with open(output_file, "w", newline="") as outfile:
57
+ writer = csv.writer(outfile)
58
+ writer.writerow(["Date", "Entity", "Minutes in Range", "Minutes in Touching Distance", "Mean Distance While in Range"])
59
+ writer.writerows(data)
60
+
61
+ print(f"Data successfully written to {output_file}")
@@ -0,0 +1,34 @@
1
+ """
2
+ Function: This script finds all .pkl files in a specified directory, extracts the subject_id from the filename,
3
+ loads the corresponding data, and processes it using the get_daily_ranging_statistics function.
4
+
5
+ Usage:
6
+ cd SociTrack/software/management/dashboard
7
+ python3 1_tottags_batch.py
8
+ """
9
+
10
+ import os
11
+ from processing import *
12
+
13
+
14
+ def process_pkl_files(directory):
15
+ """Find all .pkl files in the directory, extract subject_id, load data, and process it."""
16
+ for filename in os.listdir(directory):
17
+ if filename.endswith(".pkl"):
18
+ filepath = os.path.join(directory, filename)
19
+
20
+ # Extract subject_id from filename
21
+ subject_id = filename.split("_")[0]
22
+
23
+ # Load pkl data
24
+ CG1 = load_data(filepath)
25
+
26
+ # Call the function with formatted parameters
27
+ get_daily_ranging_statistics(CG1, [f"{subject_id}_CG2"], 3)
28
+
29
+
30
+ # Define directory path
31
+ directory_path = "/Users/hannahpiersiak/Desktop/tottags"
32
+
33
+ # Run the function
34
+ process_pkl_files(directory_path)
File without changes