Chrono rhythm

This class includes the following methods:

chrono_rhythm.cbt_cycles(protocol, resample_to='1H', resample_method='sum', monving_average_window=3, std_multiplier=1, minimal_peak_distance=10, minimal_peak_distance_method='default', plot_adjustment_lines=False, save_folder=None, save_suffix='', format='png', labels=['', 'Time (Hours)', 'Measurement'], labels_fontsize=[14, 12, 12], ticks_fontsize=[10, 10])

Get the CBT cycles

Parameters:
  • protocol (protocol) – The protocol to get the CBT cycles

  • resample_to (str) – The time to resample the data to, defaults to ‘1H’

  • resample_method (str) – The method to resample the data, defaults to ‘sum’

  • monving_average_window (int) – The window for the moving average, defaults to 3

  • std_multiplier (int) – The standard deviation multiplier to detect peaks, defaults to 1

  • minimal_peak_distance – The minimal peak distance to detect peaks, defaults to 10. If a peak is detected

within this distance, the peak with the highest value is considered :type minimal_peak_distance: int :param minimal_peak_distance_method: The method to use to detect the minimal peak distance, defaults to ‘default’. If default, the peak detected within the minimal peak distance with the highest value is considered. If ‘sequential’, the first peak detected within the minimal peak distance is considered. :type minimal_peak_distance_method: str :param plot_adjustment_lines: If True, plot the adjustment lines, defaults to False :type plot_adjustment_lines: bool :param save_folder: The folder to save the data, defaults to None :type save_folder: str :param save_suffix: The suffix to save the data, defaults to ‘’ :type save_suffix: str :param format: The format to save the data, defaults to ‘png’ :type format: str :param labels: The labels for the plot, defaults to [‘’, ‘Time (Hours)’, ‘Measurement’] :type labels: list :param labels_fontsize: The fontsize for the labels, defaults to [14, 12, 12] :type labels_fontsize: list :param ticks_fontsize: The fontsize for the ticks, defaults to [10, 10] :type ticks_fontsize: list

chrono_rhythm.colect_data_per_day(protocol, days_to_save='all', save_folder=None, save_suffix='')

Colect data per day

Parameters:
  • protocol (protocol) – The protocol to colect the data per day

  • days_to_save (list) – The days to save the data, defaults to ‘all’

  • save_folder (str) – The folder to save the data, defaults to None

  • save_suffix (str) – The suffix to add to the save file, defaults to ‘’

chrono_rhythm.data_series_each_day(protocol)
chrono_rhythm.delta_between_periods(protocol, interval_1, intervale_2, save_folder=None, save_suffix='')

Get the delta between two periods

Parameters:
  • protocol (protocol) – The protocol to get the delta between the two periods

  • interval_1 (list) – The first interval

  • intervale_2 (list) – The second interval

Returns:

The delta between the two periods

Return type:

float

chrono_rhythm.derivate_acrophase(best_models_per_day)
chrono_rhythm.fit_cosinor(protocol, dict=None, save_folder=None, save_suffix='')

Fit cosinor model to the data using the CosinorPy library.

Parameters:
  • protocol (int) – The protocol to fit the cosinor model to, if 0, the average of all protocols is used, defaults to 1

  • dict (dict) – A dictionary containing the parameters to fit the cosinor model with keys: record_type, time_shape, time_window, step, start_time, end_time, n_components. If None, the default values are used, defaults to None

  • save (bool) – If True, the cosinor model is saved in the cosinor_models folder, defaults to True

Returns:

Dataframe containing the cosinor model parameters

Return type:

pandas.DataFrame

chrono_rhythm.fit_cosinor_fixed_period(protocol, best_models, save_folder=None, save_suffix='')

Plot the cosinor period and acrophase for each day of the protocol

Parameters:

best_models_per_day (dict) – The best models per day (output of the function get_cosinor_per_day)

chrono_rhythm.fit_cosinor_per_day(protocol, dict=None, plot=False, save_folder=None, save_suffix='')

Fits a cosinor model to the data for each day of the protocol

Parameters:
  • protocol (int) – The protocol to fit the cosinor model parameters for, if 0, the average of all protocols is used, defaults to 1

  • dict (dict) – A dictionary containing the parameters to fit the cosinor model with keys: record_type, time_shape, time_window, step, start_time, end_time, n_components. If None, the default values are used, defaults to None

chrono_rhythm.positive_rad(rad)

Convert a radian value to a positive value between 0 and 2pi

Parameters:

rad (float) – Radian value

Returns:

Positive radian value

Return type:

float

chrono_rhythm.total_activity_per_day(protocol, save_folder=None, save_suffix='')