Sleep analysis
Find lengths of bouts of sleep
# break down a specimens sleep into bout duration and type
bout_df = df.sleep_bout_analysis()
output:
duration asleep t
id
2019-08-02_14-21-23_021d6b|01 60.0 True 86400.0
2019-08-02_14-21-23_021d6b|01 900.0 False 86460.0
... ... ... ...
2020-08-07_12-23-10_172d50|05 240.0 True 430980.0
2020-08-07_12-23-10_172d50|05 120.0 False 431760.0
2020-08-07_12-23-10_172d50|05 60.0 True 431880.0
# have the data returned in a format ready to be made into a histogram
hist_df = df.sleep_bout_analysis(as_hist = True, max_bins = 30, bin_size = 1, time_immobile = 5, asleep = True)
output:
bins count prob
id
2019-08-02_14-21-23_021d6b|01 60 0 0.000000
2019-08-02_14-21-23_021d6b|01 120 179 0.400447
2019-08-02_14-21-23_021d6b|01 180 92 0.205817
... ... ... ...
2020-08-07_12-23-10_172d50|05 1620 1 0.002427
2020-08-07_12-23-10_172d50|05 1680 0 0.000000
2020-08-07_12-23-10_172d50|05 1740 0 0.000000
# max bins is the largest bout you want to include
# bin_size is the what length runs together, i.e. 5 would find all bouts between factors of 5 minutes
# time_immobile is the time in minutes sleep was defined as prior. This removes anything that is small than this as produced by error previously.
# if alseep is True (the default) the return data frame will be for asleep bouts, change to False for one for awake boutsPlotting a histogram of sleep_bout_analysis

Find bouts of sleep
Sleep download functions as methods
Last updated