-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
242 lines (217 loc) · 18.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Fast Continuous Wavelet Transform • fCWTr</title>
<script src="deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet">
<script src="deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="deps/font-awesome-6.5.2/css/all.min.css" rel="stylesheet">
<link href="deps/font-awesome-6.5.2/css/v4-shims.min.css" rel="stylesheet">
<script src="deps/headroom-0.11.0/headroom.min.js"></script><script src="deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="deps/search-1.0.0/fuse.min.js"></script><script src="deps/search-1.0.0/mark.min.js"></script><script src="deps/MathJax-3.2.2/tex-chtml.min.js"></script><!-- pkgdown --><script src="pkgdown.js"></script><meta property="og:title" content="Fast Continuous Wavelet Transform">
<meta name="description" content="Enables the usage of the fast continuous wavelet transform, originally implemented in the C++ library fCWT by Lukas Arts. See Arts, P.A. and Van den Broek, E.L. (2022) <doi:10.1038/s43588-021-00183-z> for details.">
<meta property="og:description" content="Enables the usage of the fast continuous wavelet transform, originally implemented in the C++ library fCWT by Lukas Arts. See Arts, P.A. and Van den Broek, E.L. (2022) <doi:10.1038/s43588-021-00183-z> for details.">
<meta property="og:image" content="https://lschneiderbauer.github.io/fCWTr/logo.svg">
</head>
<body>
<a href="#main" class="visually-hidden-focusable">Skip to contents</a>
<nav class="navbar navbar-expand-lg fixed-top bg-light" data-bs-theme="light" aria-label="Site navigation"><div class="container">
<a class="navbar-brand me-2" href="index.html">fCWTr</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">0.3.1</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar" class="collapse navbar-collapse ms-3">
<ul class="navbar-nav me-auto">
<li class="nav-item"><a class="nav-link" href="reference/index.html">Reference</a></li>
<li class="nav-item dropdown">
<button class="nav-link dropdown-toggle" type="button" id="dropdown-articles" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">Articles</button>
<ul class="dropdown-menu" aria-labelledby="dropdown-articles">
<li><a class="dropdown-item" href="articles/sigma.html">Controlling the time/frequency resolution</a></li>
</ul>
</li>
<li class="nav-item"><a class="nav-link" href="news/index.html">Changelog</a></li>
</ul>
<ul class="navbar-nav">
<li class="nav-item"><form class="form-inline" role="search">
<input class="form-control" type="search" name="search-input" id="search-input" autocomplete="off" aria-label="Search site" placeholder="Search for" data-search-index="search.json">
</form></li>
<li class="nav-item"><a class="external-link nav-link" href="https://github.com/lschneiderbauer/fCWTr/" aria-label="GitHub"><span class="fa fab fa-github fa-lg"></span></a></li>
</ul>
</div>
</div>
</nav><div class="container template-home">
<div class="row">
<main id="main" class="col-md-9"><div class="section level1">
<div class="page-header">
<img src="logo.svg" class="logo" alt=""><h1 id="fcwtr-">fCWTr
<a class="anchor" aria-label="anchor" href="#fcwtr-"></a>
</h1>
</div>
<!-- badges: start -->
<!-- badges: end -->
<p>The R package fCWTr wraps the <a href="https://github.com/fastlib/fCWT" class="external-link">fCWT library</a>, a library implementing a <a href="https://en.wikipedia.org/wiki/Continuous_wavelet_transform" class="external-link">continuous wavelet transform</a> with a Morlet wavelet, utilizing the power of <a href="https://www.fftw.org/" class="external-link">fftw</a>, a fast fourier transform implementation. It provides an R-like functional interface and implements common S3 methods for convenience.</p>
<p>See the original paper by Arts, L.P.A., van den Broek, E.L. The fast continuous wavelet transformation (fCWT) for real-time, high-quality, noise-resistant time–frequency analysis. Nat Comput Sci 2, 47–58 (2022). <a href="https://doi.org/10.1038/s43588-021-00183-z" class="external-link uri">https://doi.org/10.1038/s43588-021-00183-z</a></p>
<div class="section level2">
<h2 id="system-dependencies">System dependencies<a class="anchor" aria-label="anchor" href="#system-dependencies"></a>
</h2>
<ul>
<li>R >= 4.1</li>
<li>
<a href="https://www.fftw.org/" class="external-link">fftw</a> library with <a href="https://www.fftw.org/faq/section2.html#singleprec" class="external-link">single-precision support</a> enabled (used by <a href="https://github.com/fastlib/fCWT" class="external-link">fCWT</a>)</li>
<li>Optional: a CPU/compiler supporting the <a href="https://en.wikipedia.org/wiki/Advanced_Vector_Extensions" class="external-link">AVX</a> instruction set</li>
<li>Optional: OpenMP (and fftw built with <a href="https://www.fftw.org/doc/Usage-of-Multi_002dthreaded-FFTW.html" class="external-link">OpenMP support</a>)
<ul>
<li>On Windows, OpenMP support is disabled since rtools’ fftw is compiled without OpenMP support.</li>
<li>On Linux and MacOS the build scripts should automatically detect whether OpenMP support is available.</li>
</ul>
</li>
</ul>
<p>By default, most compiler setups do not make use of AVX to increase portability of the binary. If you are an R user that has a CPU supporting AVX and want to make use of it, you might need to manually enable compiler flags to let R know about it, and install the package from source (so that it gets compiled on your machine). One way to enable the flags is to create a file <code>~/.R/Makevars</code> with the following content:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="ex">CPPFLAGS</span> = <span class="at">-mavx</span></span>
<span id="cb1-2"><a href="#cb1-2" tabindex="-1"></a><span class="ex">CXXFLAGS</span> = <span class="at">-mavx</span></span></code></pre></div>
</div>
<div class="section level2">
<h2 id="installation">Installation<a class="anchor" aria-label="anchor" href="#installation"></a>
</h2>
<p>You can install the latest CRAN release of fCWTr with:</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html" class="external-link">install.packages</a></span><span class="op">(</span><span class="st">"fCWTr"</span><span class="op">)</span></span></code></pre></div>
<p>Alternatively, you can install the development version of fCWTr like so (requiring installed <a href="https://devtools.r-lib.org/" class="external-link">devtools</a> package):</p>
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu">devtools</span><span class="fu">::</span><span class="fu">install_github</span><span class="op">(</span><span class="st">"lschneiderbauer/fCWTr"</span><span class="op">)</span></span></code></pre></div>
<p>Note that the installation process might fail if the package needs to be compiled from source and system requirements are not satisfied. The error message should give you hints, however, on what’s missing on your system.</p>
<ul>
<li>Common confusion: fftw is installed, but compiled without single precision support. Please consult <a href="https://www.fftw.org" class="external-link">fftw.org</a> for help.</li>
</ul>
</div>
<div class="section level2">
<h2 id="example">Example<a class="anchor" aria-label="anchor" href="#example"></a>
</h2>
<p>This is a basic example where the continuous wavelet transform of a sample signal is calculated. The result is inspected and plotted.</p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://lschneiderbauer.github.io/fCWTr/">fCWTr</a></span><span class="op">)</span></span>
<span></span>
<span><span class="co"># A signal encoded in a numeric vector.</span></span>
<span><span class="co"># In this example we use some superimposed sin signals.</span></span>
<span><span class="va">signal</span> <span class="op"><-</span> <span class="va">ts_sin_superpos</span></span>
<span></span>
<span><span class="va">output</span> <span class="op"><-</span></span>
<span> <span class="fu"><a href="reference/fcwt.html">fcwt</a></span><span class="op">(</span></span>
<span> <span class="va">signal</span>,</span>
<span> x_sample_freq <span class="op">=</span> <span class="fu"><a href="reference/u.html">u</a></span><span class="op">(</span><span class="fl">44.1</span>, <span class="st">"kHz"</span><span class="op">)</span>,</span>
<span> sigma <span class="op">=</span> <span class="fl">5</span>,</span>
<span> y_sample_freq <span class="op">=</span> <span class="fu"><a href="reference/u.html">u</a></span><span class="op">(</span><span class="fl">1</span>, <span class="st">"kHz"</span><span class="op">)</span>,</span>
<span> freq_begin <span class="op">=</span> <span class="fu"><a href="reference/u.html">u</a></span><span class="op">(</span><span class="fl">16</span>, <span class="st">"Hz"</span><span class="op">)</span>,</span>
<span> freq_end <span class="op">=</span> <span class="fu"><a href="reference/u.html">u</a></span><span class="op">(</span><span class="fl">2100</span>, <span class="st">"Hz"</span><span class="op">)</span>,</span>
<span> n_freqs <span class="op">=</span> <span class="fl">200</span>,</span>
<span> freq_scale <span class="op">=</span> <span class="st">"linear"</span></span>
<span> <span class="op">)</span></span>
<span></span>
<span><span class="co"># The result is a numeric matrix with time and frequency dimension</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/dim.html" class="external-link">dim</a></span><span class="op">(</span><span class="va">output</span><span class="op">)</span></span>
<span><span class="co">#> [1] 137 200</span></span>
<span></span>
<span><span class="co"># Some meta data is recorded too</span></span>
<span><span class="va">output</span></span>
<span><span class="co">#> _Scalogram_</span></span>
<span><span class="co">#> * (Time/Frequency) dimension: ( 137 , 200 )</span></span>
<span><span class="co">#> * Sampling rate: 1 [kHz]</span></span>
<span><span class="co">#> * Frequency scale: 16 [Hz] - 2100 [Hz], linear</span></span>
<span><span class="co">#> * Time offset: 0 [s] </span></span>
<span><span class="co">#> * Sigma: 5</span></span>
<span><span class="co">#> o Time resolution at 16 [Hz] : 1.25 [1/Hz] </span></span>
<span><span class="co">#> o Time resolution at 2100 [Hz] : 0.00952381 [1/Hz] </span></span>
<span><span class="co">#> o Relative frequency resolution: 0.127324 </span></span>
<span><span class="co">#> * Time/frequency matrix summary</span></span>
<span><span class="co">#> Min. 1st Qu. Median Mean 3rd Qu. Max. NA's </span></span>
<span><span class="co">#> 0.000 0.000 0.000 0.003 0.001 0.064 6671</span></span></code></pre></div>
<p>The result can also be converted into a data frame:</p>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/as.data.frame.html" class="external-link">as.data.frame</a></span><span class="op">(</span><span class="va">output</span><span class="op">)</span> <span class="op">|></span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/utils/head.html" class="external-link">head</a></span><span class="op">(</span><span class="fl">10</span><span class="op">)</span></span>
<span><span class="co">#> time_index time freq value</span></span>
<span><span class="co">#> 1 0 0.000 [s] 2100 [Hz] NA</span></span>
<span><span class="co">#> 2 1 0.001 [s] 2100 [Hz] NA</span></span>
<span><span class="co">#> 3 2 0.002 [s] 2100 [Hz] NA</span></span>
<span><span class="co">#> 4 3 0.003 [s] 2100 [Hz] NA</span></span>
<span><span class="co">#> 5 4 0.004 [s] 2100 [Hz] 5.170488e-05</span></span>
<span><span class="co">#> 6 5 0.005 [s] 2100 [Hz] 2.023599e-05</span></span>
<span><span class="co">#> 7 6 0.006 [s] 2100 [Hz] 7.007858e-06</span></span>
<span><span class="co">#> 8 7 0.007 [s] 2100 [Hz] 2.413503e-06</span></span>
<span><span class="co">#> 9 8 0.008 [s] 2100 [Hz] 1.058135e-06</span></span>
<span><span class="co">#> 10 9 0.009 [s] 2100 [Hz] 6.853825e-07</span></span></code></pre></div>
<p>We can also directly plot the resulting scalogram:</p>
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/graphics/plot.default.html" class="external-link">plot</a></span><span class="op">(</span><span class="va">output</span>, time_unit <span class="op">=</span> <span class="st">"ms"</span><span class="op">)</span></span></code></pre></div>
<p><img src="reference/figures/README-example_plot-1.png" width="100%"></p>
<p>For long sequences, the required memory can exceed your available local memory. In this case it can be useful to reduce the time resolution of the result and process the data in batches. This can be done with <code><a href="reference/fcwt_batch.html">fcwt_batch()</a></code>. In case the batch size is not explicitly provided, some heuristics are used to determine a batch size automatically:</p>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">batch_result</span> <span class="op"><-</span></span>
<span> <span class="fu"><a href="reference/fcwt_batch.html">fcwt_batch</a></span><span class="op">(</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/rep.html" class="external-link">rep</a></span><span class="op">(</span><span class="va">ts_sin_sin</span>, <span class="fl">5</span><span class="op">)</span>,</span>
<span> x_sample_freq <span class="op">=</span> <span class="fu"><a href="reference/u.html">u</a></span><span class="op">(</span><span class="fl">44.1</span>, <span class="st">"kHz"</span><span class="op">)</span>,</span>
<span> y_sample_freq <span class="op">=</span> <span class="fu"><a href="reference/u.html">u</a></span><span class="op">(</span><span class="fl">100</span>, <span class="st">"Hz"</span><span class="op">)</span>,</span>
<span> freq_begin <span class="op">=</span> <span class="fu"><a href="reference/u.html">u</a></span><span class="op">(</span><span class="fl">100</span>, <span class="st">"Hz"</span><span class="op">)</span>,</span>
<span> freq_end <span class="op">=</span> <span class="fu"><a href="reference/u.html">u</a></span><span class="op">(</span><span class="fl">12</span>, <span class="st">"kHz"</span><span class="op">)</span>,</span>
<span> n_freqs <span class="op">=</span> <span class="fl">200</span>,</span>
<span> freq_scale <span class="op">=</span> <span class="st">"linear"</span>,</span>
<span> sigma <span class="op">=</span> <span class="fl">4</span></span>
<span> <span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/plot.default.html" class="external-link">plot</a></span><span class="op">(</span><span class="va">batch_result</span><span class="op">)</span></span></code></pre></div>
<p><img src="reference/figures/README-example_long_df-1.png" width="100%"></p>
<!-- regenerate with devtools::build_readme() -->
</div>
</div>
</main><aside class="col-md-3"><div class="links">
<h2 data-toc-skip>Links</h2>
<ul class="list-unstyled">
<li><a href="https://cloud.r-project.org/package=fCWTr" class="external-link">View on CRAN</a></li>
<li><a href="https://github.com/lschneiderbauer/fCWTr/" class="external-link">Browse source code</a></li>
<li><a href="https://github.com/lschneiderbauer/fCWTr/issues" class="external-link">Report a bug</a></li>
</ul>
</div>
<div class="license">
<h2 data-toc-skip>License</h2>
<ul class="list-unstyled">
<li><a href="LICENSE.html">Full license</a></li>
<li><small>GPL (>= 3)</small></li>
</ul>
</div>
<div class="citation">
<h2 data-toc-skip>Citation</h2>
<ul class="list-unstyled">
<li><a href="authors.html#citation">Citing fCWTr</a></li>
</ul>
</div>
<div class="developers">
<h2 data-toc-skip>Developers</h2>
<ul class="list-unstyled">
<li>Lukas Schneiderbauer <br><small class="roles"> Author, maintainer, copyright holder </small> <a href="https://orcid.org/0000-0002-0975-6803" target="orcid.widget" aria-label="ORCID" class="external-link"><span class="fab fa-orcid orcid" aria-hidden="true"></span></a> </li>
<li><a href="authors.html">More about authors...</a></li>
</ul>
</div>
<div class="dev-status">
<h2 data-toc-skip>Dev status</h2>
<ul class="list-unstyled">
<li><a href="https://github.com/lschneiderbauer/fCWTr/actions/workflows/R-CMD-check.yaml" class="external-link"><img src="https://github.com/lschneiderbauer/fCWTr/actions/workflows/R-CMD-check.yaml/badge.svg" alt="R-CMD-check"></a></li>
<li><a href="https://lifecycle.r-lib.org/articles/stages.html#experimental" class="external-link"><img src="https://img.shields.io/badge/lifecycle-experimental-orange.svg" alt="Lifecycle: experimental"></a></li>
<li><a href="https://CRAN.R-project.org/package=fCWTr" class="external-link"><img src="https://www.r-pkg.org/badges/version/fCWTr" alt="CRAN status"></a></li>
<li><a href="https://app.codecov.io/gh/lschneiderbauer/fcwtr?branch=master" class="external-link"><img src="https://codecov.io/gh/lschneiderbauer/fCWTr/branch/master/graph/badge.svg" alt="Codecov test coverage"></a></li>
</ul>
</div>
</aside>
</div>
<footer><div class="pkgdown-footer-left">
<p>Developed by Lukas Schneiderbauer.</p>
</div>
<div class="pkgdown-footer-right">
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.1.1.</p>
</div>
</footer>
</div>
</body>
</html>