circaPy 0.1.6.dev1__py3-none-any.whl → 0.1.6.dev3__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.
- circaPy/activity.py +2 -2
- circaPy/episodes.py +4 -4
- circaPy/periodogram.py +6 -6
- circaPy/plots.py +3 -3
- {circapy-0.1.6.dev1.dist-info → circapy-0.1.6.dev3.dist-info}/METADATA +3 -1
- {circapy-0.1.6.dev1.dist-info → circapy-0.1.6.dev3.dist-info}/RECORD +8 -8
- {circapy-0.1.6.dev1.dist-info → circapy-0.1.6.dev3.dist-info}/WHEEL +0 -0
- {circapy-0.1.6.dev1.dist-info → circapy-0.1.6.dev3.dist-info}/licenses/LICENSE +0 -0
circaPy/activity.py
CHANGED
|
@@ -328,7 +328,7 @@ def calculate_IS(data):
|
|
|
328
328
|
|
|
329
329
|
|
|
330
330
|
@prep.validate_input
|
|
331
|
-
def calculate_TV(data,
|
|
331
|
+
def calculate_TV(data, col=0):
|
|
332
332
|
r"""
|
|
333
333
|
Calculates Timepoint Variability
|
|
334
334
|
|
|
@@ -363,7 +363,7 @@ def calculate_TV(data, subject_no=0):
|
|
|
363
363
|
The TV value ranges from 0 to 1, lower is more stable.
|
|
364
364
|
"""
|
|
365
365
|
# select the data
|
|
366
|
-
curr_data = data.iloc[:,
|
|
366
|
+
curr_data = data.iloc[:, col]
|
|
367
367
|
|
|
368
368
|
# calculate mean
|
|
369
369
|
mean_data = calculate_mean_activity(curr_data)
|
circaPy/episodes.py
CHANGED
|
@@ -19,7 +19,7 @@ import circaPy.preprocessing as prep
|
|
|
19
19
|
|
|
20
20
|
@prep.validate_input
|
|
21
21
|
def find_episodes(
|
|
22
|
-
data,
|
|
22
|
+
data, col=0, min_length="1s", max_interruption="0s", *args, **kwargs
|
|
23
23
|
):
|
|
24
24
|
"""
|
|
25
25
|
Identifies episodes in a time series of activity data for a specific subject,
|
|
@@ -31,7 +31,7 @@ def find_episodes(
|
|
|
31
31
|
data : pd.DataFrame
|
|
32
32
|
The activity data for multiple subjects, where each column represents
|
|
33
33
|
a subject's activity over time, and the index is a time-based index.
|
|
34
|
-
|
|
34
|
+
col : int, optional
|
|
35
35
|
The column index of the subject to analyze. Default is 0.
|
|
36
36
|
min_length : str or pandas.Timedelta, optional
|
|
37
37
|
The minimum duration for an episode to be included in the results.
|
|
@@ -62,13 +62,13 @@ def find_episodes(
|
|
|
62
62
|
... "Subject 1": np.random.choice([0, 1], size=100, p=[0.8, 0.2]),
|
|
63
63
|
... "Subject 2": np.random.choice([0, 1], size=100, p=[0.7, 0.3]),
|
|
64
64
|
... }, index=index)
|
|
65
|
-
>>> find_episodes(data,
|
|
65
|
+
>>> find_episodes(data, col=0, min_length="3s", max_interruption="2s")
|
|
66
66
|
2024-01-01 00:00:15 7.0
|
|
67
67
|
2024-01-01 00:00:45 5.0
|
|
68
68
|
dtype: float64
|
|
69
69
|
"""
|
|
70
70
|
# select single column
|
|
71
|
-
curr_data = data.iloc[:,
|
|
71
|
+
curr_data = data.iloc[:, col]
|
|
72
72
|
|
|
73
73
|
# Determine the threshold for episode identification
|
|
74
74
|
zero_data = curr_data == 0
|
circaPy/periodogram.py
CHANGED
|
@@ -9,7 +9,7 @@ import circaPy.preprocessing as prep
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@prep.validate_input
|
|
12
|
-
def lomb_scargle_period(data,
|
|
12
|
+
def lomb_scargle_period(data, col=0, low_period=20, high_period=30, **kwargs):
|
|
13
13
|
"""
|
|
14
14
|
Calculates the Lomb-Scargle periodogram for a single column in a DataFrame.
|
|
15
15
|
|
|
@@ -18,7 +18,7 @@ def lomb_scargle_period(data, subject_no=0, low_period=20, high_period=30, **kwa
|
|
|
18
18
|
data : pd.DataFrame
|
|
19
19
|
Input DataFrame with time-series data. The index represents time, and
|
|
20
20
|
the columns contain observations.
|
|
21
|
-
|
|
21
|
+
col : int, optional
|
|
22
22
|
The positional index of the column to analyze. Default is 0.
|
|
23
23
|
low_period : float, optional
|
|
24
24
|
The shortest period to search for, in hours. Default is 20.
|
|
@@ -42,7 +42,7 @@ def lomb_scargle_period(data, subject_no=0, low_period=20, high_period=30, **kwa
|
|
|
42
42
|
Raises
|
|
43
43
|
------
|
|
44
44
|
IndexError
|
|
45
|
-
If `
|
|
45
|
+
If `col` is out of the valid range for the DataFrame columns.
|
|
46
46
|
ValueError
|
|
47
47
|
If `low_period` is greater than or equal to `high_period`.
|
|
48
48
|
|
|
@@ -58,9 +58,9 @@ def lomb_scargle_period(data, subject_no=0, low_period=20, high_period=30, **kwa
|
|
|
58
58
|
contains only NaNs.
|
|
59
59
|
"""
|
|
60
60
|
# Ensure the positional index is valid
|
|
61
|
-
if
|
|
61
|
+
if col < 0 or col >= len(data.columns):
|
|
62
62
|
raise IndexError(
|
|
63
|
-
f"Invalid
|
|
63
|
+
f"Invalid col {col}. Must be between 0 and"
|
|
64
64
|
f"{len(data.columns) - 1}."
|
|
65
65
|
)
|
|
66
66
|
|
|
@@ -80,7 +80,7 @@ def lomb_scargle_period(data, subject_no=0, low_period=20, high_period=30, **kwa
|
|
|
80
80
|
freq_hours = 1 / (freq * 3600)
|
|
81
81
|
|
|
82
82
|
# Prepare observations
|
|
83
|
-
observations = data.iloc[:,
|
|
83
|
+
observations = data.iloc[:, col].values
|
|
84
84
|
observation_times = np.arange(len(data)) * sample_freq
|
|
85
85
|
|
|
86
86
|
# Check if all NaN
|
circaPy/plots.py
CHANGED
|
@@ -14,7 +14,7 @@ import circaPy.preprocessing as prep
|
|
|
14
14
|
@prep.plot_kwarg_decorator
|
|
15
15
|
def plot_actogram(
|
|
16
16
|
data,
|
|
17
|
-
|
|
17
|
+
col=0,
|
|
18
18
|
light_col=-1,
|
|
19
19
|
ylim=[0, 120],
|
|
20
20
|
fig=False,
|
|
@@ -37,7 +37,7 @@ def plot_actogram(
|
|
|
37
37
|
columns for each subject and one column for the light levels.
|
|
38
38
|
WRONG - currently expecting list of dataframes, one for each animal
|
|
39
39
|
and single column for each day
|
|
40
|
-
|
|
40
|
+
col : int
|
|
41
41
|
which column number to plot, defaults to 0
|
|
42
42
|
light_col : int
|
|
43
43
|
which columns contains light information, defaults to -1
|
|
@@ -80,7 +80,7 @@ def plot_actogram(
|
|
|
80
80
|
raise ValueError("Input Dataframe is empty. Cannot plot actogram")
|
|
81
81
|
|
|
82
82
|
# select the correct data to plot for activity and light
|
|
83
|
-
col_data = data.columns[
|
|
83
|
+
col_data = data.columns[col]
|
|
84
84
|
ldr_col = data.columns[light_col]
|
|
85
85
|
data_plot = data.loc[:, col_data].copy()
|
|
86
86
|
data_light = data.loc[:, ldr_col].copy()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: circaPy
|
|
3
|
-
Version: 0.1.6.
|
|
3
|
+
Version: 0.1.6.dev3
|
|
4
4
|
Summary: For analysing circadian activity data
|
|
5
5
|
Project-URL: Homepage, https://github.com/A-Fisk/circaPy
|
|
6
6
|
Project-URL: Issues, https://github.com/A-Fisk/circaPy/issues
|
|
@@ -29,6 +29,8 @@ CircaPy is a python module for circadian analysis of activity data.
|
|
|
29
29
|
It was developed using laboratory
|
|
30
30
|
rodents data but is applicable across species and monitoring devices.
|
|
31
31
|
|
|
32
|
+
Full documentation is available at [circapy.readthedocs.io](https://circapy.readthedocs.io)
|
|
33
|
+
|
|
32
34
|
A limited version is available as an [interactive
|
|
33
35
|
website](https://circapywebsite.streamlit.app/)
|
|
34
36
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
circaPy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
circaPy/activity.py,sha256=
|
|
3
|
-
circaPy/episodes.py,sha256=
|
|
4
|
-
circaPy/periodogram.py,sha256=
|
|
5
|
-
circaPy/plots.py,sha256=
|
|
2
|
+
circaPy/activity.py,sha256=I1B6zSlz_kpxRaaGv2h-PdjrOym0HNRhzhGlwiMKMf4,12530
|
|
3
|
+
circaPy/episodes.py,sha256=lzvwNv763ECskGZ2VqLiP4EfT8p6yYJKDvnHL5ZGHEA,15354
|
|
4
|
+
circaPy/periodogram.py,sha256=oIWOl30aokq5YZPU2EM7NZNQUvRN8DWCtg_-OmfSyz0,4308
|
|
5
|
+
circaPy/plots.py,sha256=G8YSb9p1bAekvhN0XqEaWsA5gXZyiBVKuLiIgvQ48wA,12688
|
|
6
6
|
circaPy/preprocessing.py,sha256=WNmeNdOU83sdP9qC8Cj4Od42OjRqR48dlaJQd2OZb6E,9696
|
|
7
7
|
circaPy/sleep_process.py,sha256=vMNFNRx__qls_eCaCEM374RWqvo2bAUNocbIjF5gbnk,2521
|
|
8
8
|
circaPy/.idea/actigraphy_analysis.iml,sha256=6GnoPxQ6gF69BtdpKK3mmgHwqmzJglmUa9iI5jVDo6c,398
|
|
@@ -10,7 +10,7 @@ circaPy/.idea/misc.xml,sha256=d8VH1GDzWGVVZo58O51-wfPY_Il-rQ9exolep12oV74,219
|
|
|
10
10
|
circaPy/.idea/modules.xml,sha256=ELB75pyQII1uEhIxCoEuFJWB5wlJfhAAuDpZkYE5xxU,290
|
|
11
11
|
circaPy/.idea/vcs.xml,sha256=JpBk9bpzB9zTGgO1xpBpizRCwPACTBNYNhVC9J9VCa4,183
|
|
12
12
|
circaPy/.idea/workspace.xml,sha256=2Tgp-vpRFqxCebvXxnPuUCfbcshS26qZ-5jMneikRpM,4178
|
|
13
|
-
circapy-0.1.6.
|
|
14
|
-
circapy-0.1.6.
|
|
15
|
-
circapy-0.1.6.
|
|
16
|
-
circapy-0.1.6.
|
|
13
|
+
circapy-0.1.6.dev3.dist-info/METADATA,sha256=w8iv9FCQ-tDtFZEX7r2WPuyvL2ifBU6tLBQFLjwTTEI,2968
|
|
14
|
+
circapy-0.1.6.dev3.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
15
|
+
circapy-0.1.6.dev3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
16
|
+
circapy-0.1.6.dev3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|