Skip to content

Commit

Permalink
Version 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mivade authored Jul 6, 2018
2 parents 62a9d0e + 0e75d6b commit 57d3f66
Show file tree
Hide file tree
Showing 22 changed files with 856 additions and 324 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
Changes
=======

Version 0.7.0
-------------

**2018-07-06**

User-facing changes:

* Localization and montage numbers are now converted to integers instead of
being strings (#91)
* Fixed loading of montage data for subjects with a montage number other than
0 (#95)
* Added preliminary support for loading ltp data (#97)

Other changes:

* CI testing updated to use an environment variable to specify what Python
version to run (#93)
* Test data gets written to a temporary directory instead of polluting the
``cmlreaders.test.data`` package (#96)
* Reader classes are automatically discovered instead of having to specify them
in ``cmlreaders/readers/__init__.py`` (#99)


Version 0.6.0
-------------

Expand Down
2 changes: 1 addition & 1 deletion cmlreaders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
from .readers import * # noqa
from .cmlreader import CMLReader # noqa

__version__ = '0.6.0'
__version__ = '0.7.0'
version_info = namedtuple("VersionInfo", "major,minor,patch")(*__version__.split('.'))
63 changes: 40 additions & 23 deletions docs/html/_modules/cmlreaders/cmlreader.html

Large diffs are not rendered by default.

316 changes: 316 additions & 0 deletions docs/html/_modules/cmlreaders/convert.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@


<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">

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

<title>cmlreaders.convert &mdash; CML Data Readers 0.7.0 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/theme_overrides.css" type="text/css" />
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />


<script src="../../_static/js/modernizr.min.js"></script>

</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"> CML Data Readers



</a>




<div class="version">
0.7
</div>




<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"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../data_guide.html">Data Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../getting_started.html">Getting Started with CML Readers</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api.html">API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev.html">Developer’s Guide</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">CML Data Readers</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">Docs</a> &raquo;</li>

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

<li>cmlreaders.convert</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 cmlreaders.convert</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">typing</span> <span class="k">import</span> <span class="n">List</span><span class="p">,</span> <span class="n">Optional</span><span class="p">,</span> <span class="n">Tuple</span><span class="p">,</span> <span class="n">Union</span>
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>


<div class="viewcode-block" id="milliseconds_to_samples"><a class="viewcode-back" href="../../api.html#cmlreaders.convert.milliseconds_to_samples">[docs]</a><span class="k">def</span> <span class="nf">milliseconds_to_samples</span><span class="p">(</span><span class="n">millis</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span>
<span class="n">sample_rate</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="nb">int</span><span class="p">:</span>
<span class="sd">&quot;&quot;&quot;Covert times in milliseconds to number of samples.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> millis</span>
<span class="sd"> Time in ms.</span>
<span class="sd"> sample_rate</span>
<span class="sd"> Sample rate in samples per second.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> Number of samples.</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="nb">int</span><span class="p">(</span><span class="n">sample_rate</span> <span class="o">*</span> <span class="n">millis</span> <span class="o">/</span> <span class="mf">1000.</span><span class="p">)</span></div>


<div class="viewcode-block" id="samples_to_milliseconds"><a class="viewcode-back" href="../../api.html#cmlreaders.convert.samples_to_milliseconds">[docs]</a><span class="k">def</span> <span class="nf">samples_to_milliseconds</span><span class="p">(</span><span class="n">samples</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span>
<span class="n">sample_rate</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]:</span>
<span class="sd">&quot;&quot;&quot;Convert samples to milliseconds.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> samples</span>
<span class="sd"> Number of samples.</span>
<span class="sd"> sample_rate</span>
<span class="sd"> Sample rate in samples per second.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> Samples converted to milliseconds.</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="mi">1000</span> <span class="o">*</span> <span class="n">samples</span> <span class="o">/</span> <span class="n">sample_rate</span></div>


<div class="viewcode-block" id="milliseconds_to_events"><a class="viewcode-back" href="../../api.html#cmlreaders.convert.milliseconds_to_events">[docs]</a><span class="k">def</span> <span class="nf">milliseconds_to_events</span><span class="p">(</span><span class="n">onsets</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]],</span>
<span class="n">sample_rate</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
<span class="sd">&quot;&quot;&quot;Take times and produce a minimal events :class:`pd.DataFrame` to load</span>
<span class="sd"> EEG data with.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> onsets</span>
<span class="sd"> Onset times in ms.</span>
<span class="sd"> sample_rate</span>
<span class="sd"> Sample rate in samples per second.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> events</span>
<span class="sd"> A :class:`pd.DataFrame` with ``eegoffset`` as the only column.</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">samples</span> <span class="o">=</span> <span class="p">[</span><span class="n">milliseconds_to_samples</span><span class="p">(</span><span class="n">onset</span><span class="p">,</span> <span class="n">sample_rate</span><span class="p">)</span> <span class="k">for</span> <span class="n">onset</span> <span class="ow">in</span> <span class="n">onsets</span><span class="p">]</span>
<span class="k">return</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">({</span><span class="s2">&quot;eegoffset&quot;</span><span class="p">:</span> <span class="n">samples</span><span class="p">})</span></div>


<div class="viewcode-block" id="events_to_epochs"><a class="viewcode-back" href="../../api.html#cmlreaders.convert.events_to_epochs">[docs]</a><span class="k">def</span> <span class="nf">events_to_epochs</span><span class="p">(</span><span class="n">events</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">,</span> <span class="n">rel_start</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">rel_stop</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span>
<span class="n">sample_rate</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span>
<span class="n">basenames</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">List</span><span class="p">[</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">]]:</span>
<span class="sd">&quot;&quot;&quot;Convert events to epochs.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> events</span>
<span class="sd"> Events to read.</span>
<span class="sd"> rel_start</span>
<span class="sd"> Start time relative to events in ms.</span>
<span class="sd"> rel_stop</span>
<span class="sd"> Stop time relative to events in ms.</span>
<span class="sd"> sample_rate</span>
<span class="sd"> Sample rate in Hz.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> epochs</span>
<span class="sd"> A list of tuples giving absolute start and stop times in number of</span>
<span class="sd"> samples.</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">rel_start</span> <span class="o">=</span> <span class="n">milliseconds_to_samples</span><span class="p">(</span><span class="n">rel_start</span><span class="p">,</span> <span class="n">sample_rate</span><span class="p">)</span>
<span class="n">rel_stop</span> <span class="o">=</span> <span class="n">milliseconds_to_samples</span><span class="p">(</span><span class="n">rel_stop</span><span class="p">,</span> <span class="n">sample_rate</span><span class="p">)</span>
<span class="n">offsets</span> <span class="o">=</span> <span class="n">events</span><span class="o">.</span><span class="n">eegoffset</span><span class="o">.</span><span class="n">values</span>
<span class="k">if</span> <span class="n">basenames</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">eegfiles</span> <span class="o">=</span> <span class="n">events</span><span class="o">.</span><span class="n">eegfile</span><span class="o">.</span><span class="n">values</span>
<span class="n">epochs</span> <span class="o">=</span> <span class="p">[(</span><span class="n">offset</span> <span class="o">+</span> <span class="n">rel_start</span><span class="p">,</span> <span class="n">offset</span> <span class="o">+</span> <span class="n">rel_stop</span><span class="p">,</span>
<span class="n">basenames</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">eegfile</span><span class="p">))</span>
<span class="k">for</span> <span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">eegfile</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">offsets</span><span class="p">,</span> <span class="n">eegfiles</span><span class="p">)]</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">epochs</span> <span class="o">=</span> <span class="p">[(</span><span class="n">offset</span> <span class="o">+</span> <span class="n">rel_start</span><span class="p">,</span> <span class="n">offset</span> <span class="o">+</span> <span class="n">rel_stop</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="k">for</span> <span class="n">offset</span> <span class="ow">in</span> <span class="n">offsets</span><span class="p">]</span>
<span class="k">return</span> <span class="n">epochs</span></div>
</pre></div>

</div>

</div>
<footer>


<hr/>

<div role="contentinfo">
<p>
&copy; Copyright 2018.

</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/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">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'0.7.0',
LANGUAGE:'None',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>





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


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

</body>
</html>
Loading

0 comments on commit 57d3f66

Please sign in to comment.