From bd57e42afc8067c7007c384a09a2cc4959e94094 Mon Sep 17 00:00:00 2001 From: ValentinGhibaudo Date: Tue, 20 Feb 2024 17:47:50 +0100 Subject: [PATCH 1/5] debug cross co example in doc of cardio respi synchro --- examples/example_06_cardio_respiratory_synchronization.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/example_06_cardio_respiratory_synchronization.py b/examples/example_06_cardio_respiratory_synchronization.py index 7df5dc2..d138cc7 100644 --- a/examples/example_06_cardio_respiratory_synchronization.py +++ b/examples/example_06_cardio_respiratory_synchronization.py @@ -155,6 +155,4 @@ ax.legend() -plt.show() - -ax.set_xlim(-0.01, 1.01) \ No newline at end of file +plt.show() \ No newline at end of file From 57508fb95cf225cd2c2ead1dcd3e2a1ef8f1c8dc Mon Sep 17 00:00:00 2001 From: ValentinGhibaudo Date: Tue, 20 Feb 2024 18:00:04 +0100 Subject: [PATCH 2/5] improve doc (typos correction ++) --- examples/example_01_getting_started.py | 35 +++++++++++++------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/examples/example_01_getting_started.py b/examples/example_01_getting_started.py index 1acd67e..e314435 100644 --- a/examples/example_01_getting_started.py +++ b/examples/example_01_getting_started.py @@ -42,14 +42,13 @@ ############################################################################## # -# Analyse respiration +# Analyze respiration # ------------------- # # :py:func:`~physio.compute_respiration` is an easy function to: # -# * preprocess the respiration signal -# * compute cycle -# * compute cycle features +# * preprocess the respiratory signal (resp) +# * compute cycle features (resp_cycles) resp, resp_cycles = physio.compute_respiration(raw_resp, srate) @@ -61,11 +60,11 @@ ############################################################################## # -# repiration cycles and features +# Respiration cycles and features # ------------------------------ # -# resp_cycles is a dataframe containing all respiration cycles as rows and columns. -# It contains features like duration, amplitudes, durations +# resp_cycles is a dataframe containing all respiratory cycles as rows. +# Columns contain features like duration, amplitudes, volumes. # print(resp_cycles.shape) @@ -98,8 +97,8 @@ # # :py:func:`~physio.compute_ecg` is an easy function to: # -# * Preprocess the ECG signal output, which is normalized by default -# * Detect R peaks +# * Preprocess the ECG signal output, which is normalized by default (ecg) +# * Detect R peaks (ecg_peaks) ecg, ecg_peaks = physio.compute_ecg(raw_ecg, srate) @@ -122,10 +121,10 @@ # ECG metrics # ----------- # -# :py:func:`~physio.compute_ecg_metrics` is a simple function to compute temporal based metrics around ECG +# :py:func:`~physio.compute_ecg_metrics` is a simple function to compute time-domain Heart Rate Variability (HRV) metrics. #  # -# We can visualize theses metrics and the RR interval distribution. +# We can visualize these metrics and the RR interval distribution. ecg_metrics = physio.compute_ecg_metrics(ecg_peaks) @@ -150,21 +149,21 @@ # to a cycle template by stretching with linear resampling to a fixed number of # points per cycle. # -# This is helpfull to check if a signal is driven by a cyclic event like respiration. +# This is helpful to explore if features of a signal are driven by a cyclic phenomenon like respiration. #  -# Here, we deform the signal trace by "itself" : the respiration cycle. -# This leads to an average respiration template. +# Here, we deform the signal trace by "itself" : the respiratory cycle. +# This leads to an average respiratory template. # # Importantly, this can be done using one or several segment inside the cycle. -# here we have 3 time per cycle so 2 segments +# here we have 3 times per cycle so 2 segments cycle_times = resp_cycles[['inspi_time', 'expi_time', 'next_inspi_time']].values deformed_resp_1seg = physio.deform_traces_to_cycle_template(resp, times, cycle_times, points_per_cycle=40, segment_ratios=0.4, output_mode='stacked') print(deformed_resp_1seg.shape, cycle_times.shape) -# here we have 2 time per cycle so 1 segment +# here we have 2 times per cycle so 1 segment cycle_times = resp_cycles[['inspi_time', 'next_inspi_time']].values deformed_resp_2seg = physio.deform_traces_to_cycle_template(resp, times, cycle_times, points_per_cycle=40, segment_ratios=None, @@ -183,7 +182,7 @@ # Cyclic deformation on ECG # ------------------------- #  -# Lets use the same for ECG trace +# Let's use the same for ECG trace #  # We can also use a simple vector in this case it is converted a a 1 segment case. @@ -196,7 +195,7 @@ fig, ax = plt.subplots() physio.plot_cyclic_deformation(deformed_ecg, two_cycles=True, ax=ax) -ax.set_title('two ECG cycle avaerage') +ax.set_title('Two ECG cycle averaged') ############################################################################## # From f8645ed0878a75287ef749fdb7bc5a515214e4e2 Mon Sep 17 00:00:00 2001 From: ValentinGhibaudo Date: Tue, 20 Feb 2024 18:11:30 +0100 Subject: [PATCH 3/5] improve doc of respiration example --- examples/example_02_respiration.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/examples/example_02_respiration.py b/examples/example_02_respiration.py index da5e8bd..d44b911 100644 --- a/examples/example_02_respiration.py +++ b/examples/example_02_respiration.py @@ -20,7 +20,7 @@ # ------------------------------------------ # # The fastest way is to use compute_respiration() using a predefined -# parameter presetset. Here is a simple example. +# parameter preset. Here is a simple example. # read data @@ -46,22 +46,31 @@ ax.set_xlim(110, 170) +############################################################################## +#  +# Cycle detection: Default parameters +# ----------------------------------- +#  +# Here are the default parameters : those aiming to process a human airflow signal. +# It is possible to get default parameters dictionnary by calling it with the :py:func:`~physio.get_respiration_parameters` function. + +# this is a nested dict of parameters of every processing step +parameters = physio.get_respiration_parameters('human_airflow') +pprint(parameters) ############################################################################## #  # Cycle detection: Parameters tuning # ----------------------------------- #  -# Here is a simple recipe to change some predefined parameters. -# We change here the length of the smoothing parameter. +# If necessary, it is possible to change the predefined parameters. +# For example, we change here the length of the smoothing parameter. -# get paramseters set -# this is a nested dict of parameter of every step -parameters = physio.get_respiration_parameters('human_airflow') -# lets change on parameter in the structure +# let's change on parameter in the structure ... parameters['smooth']['sigma_ms'] = 100. pprint(parameters) +# ... and use them by providing it to "parameters" resp, resp_cycles = physio.compute_respiration(raw_resp, srate, parameters=parameters) From 51c259c8f6e20dce5f6daee139c8031073e5ebcd Mon Sep 17 00:00:00 2001 From: ValentinGhibaudo Date: Tue, 20 Feb 2024 18:16:07 +0100 Subject: [PATCH 4/5] improve doc of ECG example --- examples/example_03_ecg.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/example_03_ecg.py b/examples/example_03_ecg.py index c776b76..0882bf5 100644 --- a/examples/example_03_ecg.py +++ b/examples/example_03_ecg.py @@ -47,8 +47,8 @@ # Detect ECG R peaks: Parameters tuning # ------------------------------------- #  -# Here is a simple recipe to change some predefined parameters. -# We change here some filtering parameters. +# Here is a simple recipe to change the default parameters. +# We change here some filtering parameters (frequency band, filter type, order of the filter). # get paramseters predefined set for 'human_ecg' # this is a nested dict of parameter of every step @@ -74,7 +74,7 @@ ############################################################################## # -# ECG: compute metrics +# ECG: compute time-domain heart rate variability (HRV) metrics # -------------------- # @@ -87,13 +87,13 @@ # ECG : compute instantaneous rate # -------------------------------- # -# The RR-interval (aka rri) time series is a common tool to analyse the heart rate variability (hrv). -# This is equivalent to computing the instantaneous heart rate. +# The RR-interval (aka rri) time series is a common tool to analyse the heart rate variability (HRV). +# This is equivalent to compute the instantaneous heart rate. # Heart rate [bpm] = 1 / rri * 60 # -# Most people use rri in ms, we feel that use heart rate in bpm is more intuitive. -# With bpm an increase in the curve = heart acceleration. -# With ms an increase in the curve = heart decceleration. +# Most people use rri in ms, we feel that the use of heart rate in bpm is more intuitive. +# With bpm unit, an increase in the curve means heart rate acceleration. +# With ms unit, an increase in the curve means heart rate deceleration. # # Feel free to use the units you prefer (bpm or ms) @@ -125,7 +125,7 @@ ############################################################################## # -# ECG: compute hrv spectrum +# ECG: compute frequency-domain heart rate variability (HRV) metrics # ------------------------- # #  From d939b6d4fcc7980c12ef3f4615197a9523283bb2 Mon Sep 17 00:00:00 2001 From: ValentinGhibaudo Date: Tue, 20 Feb 2024 18:17:19 +0100 Subject: [PATCH 5/5] type of doc RSA example --- examples/example_05_rsa.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_05_rsa.py b/examples/example_05_rsa.py index 5948963..c4f9963 100644 --- a/examples/example_05_rsa.py +++ b/examples/example_05_rsa.py @@ -61,7 +61,7 @@ # This is done with one unique function that returns: # # * One dataframe with all RSA features -# * The cyclic deformed cardiac rate +# * The cyclically deformed cardiac rate points_per_cycle = 50