Chrono plotter

This class includes the following methods:

chrono_plotter.actogram_bar(protocol, first_hour=0, save_folder=None, save_suffix='', adjust_figure=[1, 0.95, 0.85, 0.2, 0.05], norm_value=None, format='png', x_label='HOURS', labels_fontsize=[14, 12, 12], ticks_fontsize=[8, 8])

Plot the actogram of the protocol in a bar plot

Parameters:
  • protocol (read_protocol) – Protocol object to be vizualized

  • first_hour (int) – First hour of the day to be plotted, if different from 0, the actogram is shifted, defaults to 0

  • save_folder (str) – Path to save the folder if it is None, the plot is just shown, defaults to None

  • adjust_figure (list) – List with the parameters to adjust the figure [column_height, rigth, top, bottom, left], defaults to [1, 0.95, 0.85, 0.2, 0.05]

  • norm_value – List with the minimum and maximum values to be used in to y axis limits (it is used when the data have nan valuesa and the data variabilty is too high), defaults to None

  • format (str) – Format to save the figure (png or svg), defaults to ‘png’

  • x_label (str) – Label of the x axis, defaults to ‘HOURS’

  • labels_fontsize (list) – List with the fontsize of the labels [title, x_label, y_label], defaults to [14, 12, 12]

  • ticks_fontsize (list) – List with the fontsize of the ticks [x_ticks, y_ticks], defaults to [12, 10, 10]

Save_suffix:

Suffix to add to the file name, defaults to ‘’

chrono_plotter.actogram_colormap(protocol, first_hour=0, unit_of_measurement='Amplitude', save_folder=None, save_suffix='', adjust_figure=[1, 0.95, 0.85, 0.2, 0.05], norm_color=None, format='png', x_label='HOURS', labels_fontsize=[14, 12, 12], ticks_fontsize=[8, 8])

Plot the actogram of the protocol in a colormap

Parameters:
  • protocol (read_protocol) – Protocol object to be vizualized

  • first_hour (int) – First hour of the day to be plotted, if different from 0, the actogram is shifted, defaults to 0

  • unit_of_measurement (str) – Unit of measurement of the protocol, defaults to “Amplitude”. This is used to label the colorbar

  • save_folder (str) – Path to save the folder if it is None, the plot is just shown, defaults to None

  • adjust_figure (list) – List with the parameters to adjust the figure [column_height, rigth, top, bottom, left], defaults to [1, 0.95, 0.85, 0.2, 0.05]

  • norm_color (list) – List with the minimum and maximum values to be used in the colormap, defaults to [33, 40]

  • format (str) – Format to save the figure (png or svg), defaults to ‘png’

  • x_label (str) – Label of the x axis, defaults to ‘HOURS’

  • labels_fontsize (list) – List with the fontsize of the labels [title, x_label, y_label], defaults to [14, 12, 12]

  • ticks_fontsize (list) – List with the fontsize of the ticks [x_ticks, y_ticks], defaults to [12, 10, 10]

Save_suffix:

Suffix to add to the file name, defaults to ‘’

chrono_plotter.data_periodogram(protocol, time_shape='continuous', method='periodogram', max_period=48, unit_of_measurement='Unit', save_folder=None, save_suffix='', format='png', x_label='PERIOD (HOUR)', labels_fontsize=[14, 12, 12], ticks_fontsize=[10, 10])

Plot the periodogram of the protocol

Parameters:
  • protocol (read_protocol) – Protocol object to be vizualized

  • time_shape (str) – Time shape to be used, can be ‘continuous’, ‘median’ or ‘mean’, defaults to ‘continuous’. If ‘continuous’, the periodogram is calculated using the whole protocol data, if ‘median’ or ‘mean’, the periodogram is calculates using the median or mean of the data per day

  • method (str) – Method to be used to calculate the periodogram, can be ‘periodogram’ or ‘welch’, defaults to ‘periodogram’

  • max_period (int) – Maximum period to be plotted, defaults to 48

  • unit_of_measurement (str) – Unit of measurement of the protocol, defaults to “Unit”. This is used to label the y axis

  • save_folder (str) – Path to save the folder if it is None, the plot is just shown, defaults to None

  • format (str) – Format to save the figure (png or svg), defaults to ‘png’

  • x_label (str) – Label of the x axis, defaults to ‘PERIOD (HOUR)’

  • labels_fontsize (list) – List with the fontsize of the labels [title, x_label, y_label], defaults to [14, 12, 12]

  • ticks_fontsize (list) – List with the fontsize of the ticks [x_ticks, y_ticks], defaults to [10, 10]

Save_suffix:

Suffix to add to the file name, defaults to ‘’

chrono_plotter.mean_time_series(protocol, labels=['Mean Time Series', 'Samples', 'Amplitude'])

Plot the mean time series of the protocol

Parameters:
  • protocol (read_protocol) – Protocol object to be vizualized

  • labels (list) – List with the labels of the plot [title, x_label, y_label], defaults to [‘Mean Time Series’, ‘Time (Days)’, ‘Amplitude’]

chrono_plotter.model_over_signal(protocol, best_models, position='head', mv_avg_window=1, save_folder=None, save_suffix='', format='png', y_label='AMPLITUDE', labels_fontsize=[10, 8, 8], ticks_fontsize=[6, 6])

Plot the cosinor model and the protocol data to each stage. Can be used to compare the cosinor model to the signal.

Parameters:
  • protocol (read_protocol) – Protocol object to be vizualized

  • best_models (pandas.DataFrame) – Cosinor model parameters (output of the fit_cosinor function)

  • position (str) – Position of the data to be plotted, can be ‘head’ or ‘tail’, defaults to ‘head’. If ‘tail’, the last part of the data is plotted inverted (first point is the last point of the data, the second point is the penultimate point of the data, etc.)

  • mv_avg_window (int) – Window size to apply a moving average to the data, defaults to 1. If 1, no moving average is applied.

  • save_folder (str) – Path to save the folder if it is None, the plot is just shown, defaults to None

  • format (str) – Format to save the figure (png or svg), defaults to ‘png’

  • y_label (str) – Label of the y axis, defaults to ‘AMPLITUDE’

  • labels_fontsize (list) – List with the fontsize of the labels [title, x_label, y_label], defaults to [14, 12, 12]

  • ticks_fontsize (list) – List with the fontsize of the ticks [x_ticks, y_ticks], defaults to [10, 10]

Save_suffix:

Suffix to add to the file name, defaults to ‘’

chrono_plotter.model_overview(protocol, best_models, only_significant=False, save_folder=None, save_suffix='', format='png', labels_fontsize=[14, 12, 12], ticks_fontsize=[10, 10])

Plots the cosinor model pariod and acrophase for each protocol satage. This function is used to plot the results of the fit_cosinor function.

Parameters:
  • protocol (read_protocol) – Protocol object to be vizualized

  • best_models (pandas.DataFrame) – The cosinor model parameters (output of the fit_cosinor function)

  • only_significant (bool) – If True, only the significant days are plotted, defaults to False

  • save_folder (str) – Path to save the folder if it is None, the plot is just shown, defaults to None

  • format (str) – Format to save the figure (png or svg), defaults to ‘png’

  • labels_fontsize (list) – List with the fontsize of the labels [title, x_label, y_label], defaults to [14, 12, 12]

  • ticks_fontsize (list) – List with the fontsize of the ticks [x_ticks, y_ticks], defaults to [10, 10]

Save_suffix:

Suffix to add to the file name, defaults to ‘’

chrono_plotter.model_overview_detailed(protocol, best_models_fixed, only_significant=False, save_folder=None, save_suffix='', format='png', labels_fontsize=[14, 12, 12], ticks_fontsize=[10, 10])

Plot the cosinor period and acrophase for each day of the protocol. This function is used to plot the results of the fit_cosinor_fixed_period function. In this case, acrophase (and the others parameters) are calculated fixing the period calculated to each stage.

Parameters:
  • protocol (read_protocol) – Protocol object to be vizualized

  • best_models_fixed (pandas.DataFrame) – Cosinor model parameters per day (output of the fit_cosinor_fixed_period function)

  • only_significant (bool) – If True, only the significant days are plotted, defaults to False

  • save_folder (str) – Path to save the folder if it is None, the plot is just shown, defaults to None

  • format (str) – Format to save the figure (png or svg), defaults to ‘png’

  • labels_fontsize (list) – List with the fontsize of the labels [title, x_label, y_label], defaults to [14, 12, 12]

  • ticks_fontsize (list) – List with the fontsize of the ticks [x_ticks, y_ticks], defaults to [10, 10]

Save_suffix:

Suffix to add to the file name, defaults to ‘’

chrono_plotter.model_per_day(protocol, best_models_per_day, day_window, only_significant=False, save_folder=None, save_suffix='', format='png')

Plot the cosinor model parameters per day. This function is used to plot the results of the fit_cosinor_per_day function. In this case, parameters are calculated every day (with a moving window or not).

Parameters:
  • protocol (read_protocol) – Protocol object to be vizualized

  • best_models_per_day (pandas.DataFrame) – Cosinor model parameters per day (output of the fit_cosinor_fixed_period function)

  • day_window (int) – Window size to apply a moving average to the data, defaults to 1. If 1, no moving average is applied.

  • only_significant (bool) – If True, only the significant days are plotted, defaults to False

  • save_folder (str) – Path to save the folder if it is None, the plot is just shown, defaults to None

  • format (str) – Format to save the figure (png or svg), defaults to ‘png’

Save_suffix:

Suffix to add to the file name, defaults to ‘’

chrono_plotter.time_serie(protocol, labels=['Time Series', 'Time (Days)', 'Amplitude'], color='midnightblue', save_folder=None, save_suffix='', format='png', labels_fontsize=[14, 12, 12], ticks_fontsize=[10, 10])

Plot the time series of the protocol

Parameters:
  • protocol (read_protocol) – Protocol object to be vizualized

  • labels (list) – List with the labels of the plot [title, x_label, y_label], defaults to [‘Time Series’, ‘Time (Days)’, ‘Amplitude’]

  • color (str) – Color of the plot, defaults to ‘midnightblue’

  • save_folder (str) – Path to save the folder if it is None, the plot is just shown, defaults to None

  • format (str) – Format to save the figure (png or svg), defaults to ‘png’

  • labels_fontsize (list) – List with the fontsize of the labels [title, x_label, y_label], defaults to [14, 12, 12]

  • ticks_fontsize (list) – List with the fontsize of the ticks [x_ticks, y_ticks], defaults to [12, 10, 10]

Save_suffix:

Suffix to add to the file name, defaults to ‘’

chrono_plotter.time_serie_sum_per_day(protocol, labels=['Sum of Time Series Per Day', 'Time (Days)', 'Amplitude'], color='midnightblue', save_folder=None, save_suffix='', format='png', labels_fontsize=[14, 12, 12], ticks_fontsize=[10, 10])

Plot the time series of the protocol

Parameters:
  • protocol (read_protocol) – Protocol object to be vizualized

  • labels (list) – List with the labels of the plot [title, x_label, y_label], defaults to [‘Sum of Time Series Per Day’, ‘Time (Days)’, ‘Amplitude’]

  • color (str) – Color of the plot, defaults to ‘midnightblue’

  • save_folder (str) – Path to save the folder if it is None, the plot is just shown, defaults to None

  • format (str) – Format to save the figure (png or svg), defaults to ‘png’

  • labels_fontsize (list) – List with the fontsize of the labels [title, x_label, y_label], defaults to [14, 12, 12]

  • ticks_fontsize (list) – List with the fontsize of the ticks [x_ticks, y_ticks], defaults to [12, 10, 10]

Save_suffix:

Suffix to add to the file name, defaults to ‘’