Skip to content

Commit

Permalink
improve doc (typos correction ++)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinGhibaudo committed Feb 20, 2024
1 parent bd57e42 commit 57508fb
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions examples/example_01_getting_started.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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,
Expand All @@ -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.

Expand All @@ -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')

##############################################################################
#
Expand Down

0 comments on commit 57508fb

Please sign in to comment.