Skip to content

Commit

Permalink
add load example
Browse files Browse the repository at this point in the history
  • Loading branch information
SheinaG committed May 3, 2023
1 parent 9bf1709 commit 0b43736
Show file tree
Hide file tree
Showing 14 changed files with 369 additions and 2 deletions.
Binary file modified docs/build/.doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/.doctrees/pecg.doctree
Binary file not shown.
3 changes: 2 additions & 1 deletion docs/build/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
<div itemprop="articleBody">

<h1>All modules for which code is available</h1>
<ul><li><a href="pecg/Preprocessing.html">pecg.Preprocessing</a></li>
<ul><li><a href="pecg/Example.html">pecg.Example</a></li>
<li><a href="pecg/Preprocessing.html">pecg.Preprocessing</a></li>
<li><a href="pecg/ecg/Biomarkers.html">pecg.ecg.Biomarkers</a></li>
<li><a href="pecg/ecg/FiducialPoints.html">pecg.ecg.FiducialPoints</a></li>
</ul>
Expand Down
246 changes: 246 additions & 0 deletions docs/build/_modules/pecg/Example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@


<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>pecg.Example &mdash; pecg documentation</title>



<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />










<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->


<script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/sphinx_highlight.js"></script>

<script type="text/javascript" src="../../_static/js/theme.js"></script>


<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>

<body class="wy-body-for-nav">


<div class="wy-grid-for-nav">

<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >



<a href="../../index.html" class="icon icon-home"> pecg




<img src="../../_static/logo.png" class="logo" alt="Logo"/>

</a>







<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>


</div>


<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">






<p class="caption" role="heading"><span class="caption-text">PECG API REFERENCE:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../pecg.html">pecg package</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../tutorials/pecg_analysis.html">ECG morphological analysis</a></li>
</ul>



</div>

</div>
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">


<nav class="wy-nav-top" aria-label="top navigation">

<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">pecg</a>

</nav>


<div class="wy-nav-content">

<div class="rst-content">



















<div role="navigation" aria-label="breadcrumbs navigation">

<ul class="wy-breadcrumbs">

<li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>

<li><a href="../index.html">Module code</a> &raquo;</li>

<li>pecg.Example</li>


<li class="wy-breadcrumbs-aside">

</li>

</ul>


<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<h1>Source code for pecg.Example</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">wfdb</span>


<div class="viewcode-block" id="load_example"><a class="viewcode-back" href="../../pecg.html#pecg.Example.load_example">[docs]</a><span class="k">def</span> <span class="nf">load_example</span><span class="p">(</span><span class="n">ecg_type</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> The load_example function loads an ECG signal from the PhysioNet open source datasets. There are three types of ECG</span>
<span class="sd"> that might be downloded: longe single lead ECG, &#39;12-lead&#39; and a Holter with two channels.</span>
<span class="sd"> </span>
<span class="sd"> :param ecg_type: The type of the signal that you would like download: &#39;single-lead&#39;, &#39;12-lead&#39; and &#39;Holter&#39;.</span>
<span class="sd"> :return:</span>
<span class="sd"> * signal: the ECG signal as a ndarray, with shape (L, N) when L is the number of channels or leads and N is the number of samples.</span>
<span class="sd"> * fs: The sampling frequency of the signal [Hz].</span>


<span class="sd"> .. code-block:: python</span>

<span class="sd"> import pecg</span>
<span class="sd"> from pecg.Example import load_example</span>
<span class="sd"> signal, fs = load_example(ecg_type=&#39;12-lead&#39;)</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">ecg_type</span> <span class="o">==</span> <span class="s1">&#39;Holter&#39;</span><span class="p">:</span>
<span class="n">signal</span><span class="p">,</span> <span class="n">fields</span> <span class="o">=</span> <span class="n">wfdb</span><span class="o">.</span><span class="n">rdsamp</span><span class="p">(</span><span class="s1">&#39;100&#39;</span><span class="p">,</span> <span class="n">pn_dir</span><span class="o">=</span><span class="s1">&#39;mitdb&#39;</span><span class="p">)</span>

<span class="k">if</span> <span class="n">ecg_type</span> <span class="o">==</span> <span class="s1">&#39;12-lead&#39;</span><span class="p">:</span>
<span class="n">signal</span><span class="p">,</span> <span class="n">fields</span> <span class="o">=</span> <span class="n">wfdb</span><span class="o">.</span><span class="n">rdsamp</span><span class="p">(</span><span class="s1">&#39;JS00001&#39;</span><span class="p">,</span> <span class="n">pn_dir</span><span class="o">=</span><span class="s1">&#39;ecg-arrhythmia/WFDBRecords/01/010&#39;</span><span class="p">)</span>

<span class="k">if</span> <span class="n">ecg_type</span> <span class="o">==</span> <span class="s1">&#39;single-lead&#39;</span><span class="p">:</span>
<span class="n">signal</span><span class="p">,</span> <span class="n">fields</span> <span class="o">=</span> <span class="n">wfdb</span><span class="o">.</span><span class="n">rdsamp</span><span class="p">(</span><span class="s1">&#39;a01&#39;</span><span class="p">,</span> <span class="n">pn_dir</span><span class="o">=</span><span class="s1">&#39;apnea-ecg&#39;</span><span class="p">)</span>

<span class="n">signal</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="n">signal</span><span class="p">)</span>

<span class="k">return</span> <span class="n">signal</span><span class="p">,</span> <span class="n">fields</span><span class="p">[</span><span class="s1">&#39;fs&#39;</span><span class="p">]</span></div>



<span class="n">a</span> <span class="o">=</span> <span class="mi">5</span>
</pre></div>

</div>

</div>
<footer>

<hr/>

<div role="contentinfo">
<p>
&#169; Copyright 2021, Sheina.

</p>
</div>



Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a

<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>

provided by <a href="https://readthedocs.org">Read the Docs</a>.

</footer>
</div>
</div>

</section>

</div>


<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>






</body>
</html>
9 changes: 9 additions & 0 deletions docs/build/_sources/pecg.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ pecg.Preprocessing
:undoc-members:
:show-inheritance:

pecg.Example
--------------------------

.. automodule:: pecg.Example
:members:
:undoc-members:
:show-inheritance:



Module contents
---------------
Expand Down
18 changes: 18 additions & 0 deletions docs/build/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ <h1 id="index">Index</h1>
| <a href="#F"><strong>F</strong></a>
| <a href="#I"><strong>I</strong></a>
| <a href="#J"><strong>J</strong></a>
| <a href="#L"><strong>L</strong></a>
| <a href="#M"><strong>M</strong></a>
| <a href="#N"><strong>N</strong></a>
| <a href="#P"><strong>P</strong></a>
Expand Down Expand Up @@ -221,6 +222,14 @@ <h2 id="J">J</h2>
</ul></td>
</tr></table>

<h2 id="L">L</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="pecg.html#pecg.Example.load_example">load_example() (in module pecg.Example)</a>
</li>
</ul></td>
</tr></table>

<h2 id="M">M</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand All @@ -235,6 +244,8 @@ <h2 id="M">M</h2>
<li><a href="pecg.ecg.html#module-pecg.ecg.Biomarkers">pecg.ecg.Biomarkers</a>
</li>
<li><a href="pecg.ecg.html#module-pecg.ecg.FiducialPoints">pecg.ecg.FiducialPoints</a>
</li>
<li><a href="pecg.html#module-pecg.Example">pecg.Example</a>
</li>
<li><a href="pecg.html#module-pecg.Preprocessing">pecg.Preprocessing</a>
</li>
Expand Down Expand Up @@ -281,6 +292,13 @@ <h2 id="P">P</h2>

<ul>
<li><a href="pecg.ecg.html#module-pecg.ecg.FiducialPoints">module</a>
</li>
</ul></li>
<li>
pecg.Example

<ul>
<li><a href="pecg.html#module-pecg.Example">module</a>
</li>
</ul></li>
<li>
Expand Down
4 changes: 4 additions & 0 deletions docs/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ <h2>Documentation<a class="headerlink" href="#documentation" title="Permalink to
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pecg.html#module-pecg.Example">pecg.Example</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pecg.html#pecg.Example.load_example"><code class="docutils literal notranslate"><span class="pre">load_example()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pecg.html#module-pecg">Module contents</a></li>
</ul>
</li>
Expand Down
5 changes: 5 additions & 0 deletions docs/build/modules.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<p class="caption" role="heading"><span class="caption-text">PECG API REFERENCE:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="pecg.html">pecg package</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorials/pecg_analysis.html">ECG morphological analysis</a></li>
</ul>


Expand Down Expand Up @@ -186,6 +187,10 @@ <h1>pecg<a class="headerlink" href="#pecg" title="Permalink to this heading">¶<
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pecg.html#module-pecg.Example">pecg.Example</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pecg.html#pecg.Example.load_example"><code class="docutils literal notranslate"><span class="pre">load_example()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pecg.html#module-pecg">Module contents</a></li>
</ul>
</li>
Expand Down
Binary file modified docs/build/objects.inv
Binary file not shown.
32 changes: 32 additions & 0 deletions docs/build/pecg.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,14 @@
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#module-pecg.Example">pecg.Example</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#pecg.Example.load_example"><code class="docutils literal notranslate"><span class="pre">load_example()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#module-pecg">Module contents</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="tutorials/pecg_analysis.html">ECG morphological analysis</a></li>
</ul>


Expand Down Expand Up @@ -279,6 +284,33 @@ <h1>pecg package<a class="headerlink" href="#pecg-package" title="Permalink to t

</dd></dl>

</div>
<div class="section" id="module-pecg.Example">
<span id="pecg-example"></span><h2>pecg.Example<a class="headerlink" href="#module-pecg.Example" title="Permalink to this heading"></a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="pecg.Example.load_example">
<span class="sig-prename descclassname"><span class="pre">pecg.Example.</span></span><span class="sig-name descname"><span class="pre">load_example</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ecg_type:</span> <span class="pre">str</span> <span class="pre">=</span> <span class="pre">'')</span> <span class="pre">-&gt;</span> <span class="pre">(&lt;built-in</span> <span class="pre">function</span> <span class="pre">array&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">&lt;class</span> <span class="pre">'int'&gt;</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pecg/Example.html#load_example"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pecg.Example.load_example" title="Permalink to this definition"></a></dt>
<dd><p>The load_example function loads an ECG signal from the PhysioNet open source datasets. There are three types of ECG
that might be downloded: longe single lead ECG, ‘12-lead’ and a Holter with two channels.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>ecg_type</strong> – The type of the signal that you would like download: ‘single-lead’, ‘12-lead’ and ‘Holter’.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><ul class="simple">
<li><p>signal: the ECG signal as a ndarray, with shape (L, N) when L is the number of channels or leads and N is the number of samples.</p></li>
<li><p>fs: The sampling frequency of the signal [Hz].</p></li>
</ul>
</p>
</dd>
</dl>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">pecg</span>
<span class="kn">from</span> <span class="nn">pecg.Example</span> <span class="kn">import</span> <span class="n">load_example</span>
<span class="n">signal</span><span class="p">,</span> <span class="n">fs</span> <span class="o">=</span> <span class="n">load_example</span><span class="p">(</span><span class="n">ecg_type</span><span class="o">=</span><span class="s1">&#39;12-lead&#39;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="module-pecg">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-pecg" title="Permalink to this heading"></a></h2>
Expand Down

0 comments on commit 0b43736

Please sign in to comment.