/
Introduction-to-workloopR.html
334 lines (309 loc) · 30.5 KB
/
Introduction-to-workloopR.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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!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.0">
<title>Introduction to workloopR • workloopR</title>
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.1/css/all.min.css" integrity="sha256-PbSmjxuVAzJ6FPvNYsrXygfGhNJYyZ2GktDbkMBqQZg=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.1/css/v4-shims.min.css" integrity="sha256-A6jcAdwFD48VMjlI3GDxUd+eCQa7/KWy6G9oe/ovaPA=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><meta property="og:title" content="Introduction to workloopR">
<meta property="og:description" content="">
<meta name="twitter:card" content="summary">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-article">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">workloopR</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.0.1.9000</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fas fa fas fa-home fa-lg"></span>
</a>
</li>
<li>
<a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Vignettes
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/Introduction-to-workloopR.html">Introduction to workloopR</a>
</li>
<li>
<a href="../articles/non-ddf-sources.html">Importing data from non .ddf sources</a>
</li>
<li>
<a href="../articles/Calculating-twitch-kinetics.html">Working with isometric experiments</a>
</li>
<li>
<a href="../articles/Analyzing-workloops.html">Analyzing work loop experiments</a>
</li>
<li>
<a href="../articles/batch-processing.html">Batch processing</a>
</li>
<li>
<a href="../articles/Plotting-workloopR.html">Plotting data in workloopR</a>
</li>
</ul>
</li>
<li>
<a href="../news/index.html">Changelog</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/vbaliga/workloopR">
<span class="fab fa fab fa-github fa-lg"></span>
</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container -->
</div>
<!--/.navbar -->
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1>Introduction to workloopR</h1>
<h4 class="author">Vikram B. Baliga</h4>
<h4 class="date">2019-10-21</h4>
<small class="dont-index">Source: <a href="https://github.com/vbaliga/workloopR/blob/master/vignettes/Introduction-to-workloopR.Rmd"><code>vignettes/Introduction-to-workloopR.Rmd</code></a></small>
<div class="hidden name"><code>Introduction-to-workloopR.Rmd</code></div>
</div>
<div id="welcome-to-workloopr" class="section level2">
<h2 class="hasAnchor">
<a href="#welcome-to-workloopr" class="anchor"></a>Welcome to workloopR</h2>
<p>In this vignette, we’ll provide an overview of core functions in <code>workloopR</code>. Other vignettes within the package give more details with respect to specific use-cases. Examples with code can also be found within each function’s Help doc.</p>
<p><code>workloopR</code> (pronounced “work looper”) provides functions for the import, transformation, and analysis of muscle physiology experiments. As you may have guessed, the initial motivation was to provide functions to analyze work loop experiments in R, but we have expanded this goal to cover additional types of experiments that are often involved in work loop procedures. There are three currently supported experiment types: work loop, simple twitch, and tetanus.</p>
</div>
<div id="analytical-pipelines" class="section level2">
<h2 class="hasAnchor">
<a href="#analytical-pipelines" class="anchor"></a>Analytical pipelines</h2>
<p>To cut to the chase, <code>workloopR</code> offers the ability to import, transform, and then analyze a data file. For example, with a work loop file:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(workloopR)</a>
<a class="sourceLine" id="cb1-2" title="2"></a>
<a class="sourceLine" id="cb1-3" title="3"><span class="co">## import the workloop.ddf file included in workloopR</span></a>
<a class="sourceLine" id="cb1-4" title="4">wl_dat <-<span class="kw"><a href="../reference/read_ddf.html">read_ddf</a></span>(<span class="kw"><a href="https://rdrr.io/r/base/system.file.html">system.file</a></span>(<span class="st">"extdata"</span>, <span class="st">"workloop.ddf"</span>, </a>
<a class="sourceLine" id="cb1-5" title="5"> <span class="dt">package =</span> <span class="st">'workloopR'</span>),</a>
<a class="sourceLine" id="cb1-6" title="6"> <span class="dt">phase_from_peak =</span> <span class="ot">TRUE</span>)</a>
<a class="sourceLine" id="cb1-7" title="7"></a>
<a class="sourceLine" id="cb1-8" title="8"><span class="co">## select cycles 3 through 5 using a peak-to-peak definition</span></a>
<a class="sourceLine" id="cb1-9" title="9">wl_selected <-<span class="st"> </span><span class="kw"><a href="../reference/select_cycles.html">select_cycles</a></span>(wl_dat, <span class="dt">cycle_def =</span> <span class="st">"p2p"</span>, <span class="dt">keep_cycles =</span> <span class="dv">3</span><span class="op">:</span><span class="dv">5</span>)</a>
<a class="sourceLine" id="cb1-10" title="10"></a>
<a class="sourceLine" id="cb1-11" title="11"><span class="co">## run the analysis function and get the full object</span></a>
<a class="sourceLine" id="cb1-12" title="12">wl_analyzed <-<span class="st"> </span><span class="kw"><a href="../reference/analyze_workloop.html">analyze_workloop</a></span>(wl_selected, <span class="dt">GR =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb1-13" title="13"><span class="co">## for brevity, the print() method for this object produces a simple output</span></a>
<a class="sourceLine" id="cb1-14" title="14">wl_analyzed</a>
<a class="sourceLine" id="cb1-15" title="15"><span class="co">#> File ID: workloop.ddf</span></a>
<a class="sourceLine" id="cb1-16" title="16"><span class="co">#> Cycles: 3 cycles kept out of 6</span></a>
<a class="sourceLine" id="cb1-17" title="17"><span class="co">#> Mean Work: 0.00308 J</span></a>
<a class="sourceLine" id="cb1-18" title="18"><span class="co">#> Mean Power: 0.08474 W</span></a>
<a class="sourceLine" id="cb1-19" title="19"><span class="co">## but see the structure for the full output, e.g.</span></a>
<a class="sourceLine" id="cb1-20" title="20"><span class="co">#str(wl_analyzed)</span></a>
<a class="sourceLine" id="cb1-21" title="21"></a>
<a class="sourceLine" id="cb1-22" title="22"><span class="co">## or run the analysis but get the simplified version</span></a>
<a class="sourceLine" id="cb1-23" title="23">wl_analyzed_simple <-<span class="st"> </span><span class="kw"><a href="../reference/analyze_workloop.html">analyze_workloop</a></span>(wl_selected, <span class="dt">simplify =</span> <span class="ot">TRUE</span>, <span class="dt">GR =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb1-24" title="24">wl_analyzed_simple</a>
<a class="sourceLine" id="cb1-25" title="25"><span class="co">#> Cycle Work Net_Power</span></a>
<a class="sourceLine" id="cb1-26" title="26"><span class="co">#> a A 0.002785397 0.07639783</span></a>
<a class="sourceLine" id="cb1-27" title="27"><span class="co">#> b B 0.003147250 0.08661014</span></a>
<a class="sourceLine" id="cb1-28" title="28"><span class="co">#> c C 0.003305744 0.09122522</span></a></code></pre></div>
<p>Batch processing of files within a directory (e.g. successive trials of an experiment) is also readily achieved:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1"><span class="co">## batch read and analyze files included with workloopR</span></a>
<a class="sourceLine" id="cb2-2" title="2">analyzed_wls <-<span class="st"> </span><span class="kw"><a href="../reference/read_analyze_wl_dir.html">read_analyze_wl_dir</a></span>(<span class="kw"><a href="https://rdrr.io/r/base/system.file.html">system.file</a></span>(<span class="st">"extdata/wl_duration_trials"</span>,</a>
<a class="sourceLine" id="cb2-3" title="3"> <span class="dt">package =</span> <span class="st">'workloopR'</span>),</a>
<a class="sourceLine" id="cb2-4" title="4"> <span class="dt">cycle_def =</span> <span class="st">"p2p"</span>,</a>
<a class="sourceLine" id="cb2-5" title="5"> <span class="dt">keep_cycles =</span> <span class="dv">2</span><span class="op">:</span><span class="dv">4</span>,</a>
<a class="sourceLine" id="cb2-6" title="6"> <span class="dt">phase_from_peak =</span> <span class="ot">TRUE</span></a>
<a class="sourceLine" id="cb2-7" title="7"> )</a>
<a class="sourceLine" id="cb2-8" title="8"></a>
<a class="sourceLine" id="cb2-9" title="9"><span class="co">## now summarize</span></a>
<a class="sourceLine" id="cb2-10" title="10">summarized_wls <-<span class="st"> </span><span class="kw"><a href="../reference/summarize_wl_trials.html">summarize_wl_trials</a></span>(analyzed_wls)</a>
<a class="sourceLine" id="cb2-11" title="11">summarized_wls</a>
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#> File_ID Cycle_Frequency Amplitude Phase Stimulus_Pulses</span></a>
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#> 1 01_4pulse.ddf 28 3.15 -24.36 4</span></a>
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#> 2 02_2pulse.ddf 28 3.15 -24.64 2</span></a>
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#> 3 03_6pulse.ddf 28 3.15 -24.92 6</span></a>
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#> 4 04_4pulse.ddf 28 3.15 -24.64 4</span></a>
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#> Stimulus_Frequency mtime Mean_Work Mean_Power</span></a>
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#> 1 300 1571713114 0.0028362363 0.078967198</span></a>
<a class="sourceLine" id="cb2-19" title="19"><span class="co">#> 2 300 1571713114 0.0009686570 0.026247519</span></a>
<a class="sourceLine" id="cb2-20" title="20"><span class="co">#> 3 300 1571713114 -0.0001310863 -0.004017894</span></a>
<a class="sourceLine" id="cb2-21" title="21"><span class="co">#> 4 300 1571713114 0.0024082708 0.066959552</span></a></code></pre></div>
<p>Sections below will give more specific overviews.</p>
</div>
<div id="data-import" class="section level2">
<h2 class="hasAnchor">
<a href="#data-import" class="anchor"></a>Data import</h2>
<p>Data that are stored in .ddf format (e.g. generated by Aurora Scientific’s Dynamic Muscle Control and Analysis Software) are easily imported via the function <code><a href="../reference/read_ddf.html">read_ddf()</a></code>. Two additional all-in-one functions (<code><a href="../reference/read_analyze_wl.html">read_analyze_wl()</a></code> and <code><a href="../reference/read_analyze_wl_dir.html">read_analyze_wl_dir()</a></code>) also import data and subsequently transform and analyze them. More on those functions later!</p>
<p>Importing via these functions generates objects of class <code>muscle_stim</code>, which are formatted to work nicely with <code>workloopR</code>’s core functions and help with error checking procedures throughout the package. <code>muscle_stim</code> objects are organized to store time-series data for Time, Position, Force, and Stimulation in a <code>data.frame</code> and also store core metadata and experimental parameters as Attributes.</p>
<p>We’ll provide a quick example using data that are included within the package.</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(workloopR)</a>
<a class="sourceLine" id="cb3-2" title="2"></a>
<a class="sourceLine" id="cb3-3" title="3"><span class="co">## import the workloop.ddf file included in workloopR</span></a>
<a class="sourceLine" id="cb3-4" title="4">wl_dat <-<span class="kw"><a href="../reference/read_ddf.html">read_ddf</a></span>(<span class="kw"><a href="https://rdrr.io/r/base/system.file.html">system.file</a></span>(<span class="st">"extdata"</span>, <span class="st">"workloop.ddf"</span>, </a>
<a class="sourceLine" id="cb3-5" title="5"> <span class="dt">package =</span> <span class="st">'workloopR'</span>),</a>
<a class="sourceLine" id="cb3-6" title="6"> <span class="dt">phase_from_peak =</span> <span class="ot">TRUE</span>)</a>
<a class="sourceLine" id="cb3-7" title="7"></a>
<a class="sourceLine" id="cb3-8" title="8"><span class="co">## muscle_stim objects have their own print() and summary() S3 methods</span></a>
<a class="sourceLine" id="cb3-9" title="9"><span class="co">## for example:</span></a>
<a class="sourceLine" id="cb3-10" title="10"><span class="kw"><a href="https://rdrr.io/r/base/summary.html">summary</a></span>(wl_dat) <span class="co"># some handy info about the imported file</span></a>
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#> # Workloop Data: 3 channels recorded over 0.3244s</span></a>
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#> </span></a>
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#> File ID: workloop.ddf</span></a>
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#> Mod Time (mtime): 2019-10-21 19:58:33</span></a>
<a class="sourceLine" id="cb3-15" title="15"><span class="co">#> Sample Frequency: 10000Hz</span></a>
<a class="sourceLine" id="cb3-16" title="16"><span class="co">#> </span></a>
<a class="sourceLine" id="cb3-17" title="17"><span class="co">#> data.frame Columns: </span></a>
<a class="sourceLine" id="cb3-18" title="18"><span class="co">#> Position (mm)</span></a>
<a class="sourceLine" id="cb3-19" title="19"><span class="co">#> Force (mN)</span></a>
<a class="sourceLine" id="cb3-20" title="20"><span class="co">#> Stim (TTL)</span></a>
<a class="sourceLine" id="cb3-21" title="21"><span class="co">#> </span></a>
<a class="sourceLine" id="cb3-22" title="22"><span class="co">#> Stimulus Offset: 0.012s</span></a>
<a class="sourceLine" id="cb3-23" title="23"><span class="co">#> Stimulus Frequency: 300Hz</span></a>
<a class="sourceLine" id="cb3-24" title="24"><span class="co">#> Stimulus Width: 0.2ms</span></a>
<a class="sourceLine" id="cb3-25" title="25"><span class="co">#> Stimulus Pulses: 4</span></a>
<a class="sourceLine" id="cb3-26" title="26"><span class="co">#> Gear Ratio: 1</span></a>
<a class="sourceLine" id="cb3-27" title="27"><span class="co">#> </span></a>
<a class="sourceLine" id="cb3-28" title="28"><span class="co">#> Cycle Frequency: 28Hz</span></a>
<a class="sourceLine" id="cb3-29" title="29"><span class="co">#> Total Cycles (L0-to-L0): 6</span></a>
<a class="sourceLine" id="cb3-30" title="30"><span class="co">#> Amplitude: 3.15mm</span></a>
<a class="sourceLine" id="cb3-31" title="31"></a>
<a class="sourceLine" id="cb3-32" title="32"><span class="co">## see the first few rows of data stored within</span></a>
<a class="sourceLine" id="cb3-33" title="33"><span class="kw"><a href="https://rdrr.io/r/utils/head.html">head</a></span>(wl_dat)</a>
<a class="sourceLine" id="cb3-34" title="34"><span class="co">#> # Workloop Data: 3 channels recorded over 6e-04s</span></a>
<a class="sourceLine" id="cb3-35" title="35"><span class="co">#> File ID: workloop.ddf</span></a>
<a class="sourceLine" id="cb3-36" title="36"><span class="co">#> </span></a>
<a class="sourceLine" id="cb3-37" title="37"><span class="co">#> Time Position Force Stim</span></a>
<a class="sourceLine" id="cb3-38" title="38"><span class="co">#> 1 1e-04 0.503939 304.8715 0</span></a>
<a class="sourceLine" id="cb3-39" title="39"><span class="co">#> 2 2e-04 0.506197 305.5165 0</span></a>
<a class="sourceLine" id="cb3-40" title="40"><span class="co">#> 3 3e-04 0.505552 304.8715 0</span></a>
<a class="sourceLine" id="cb3-41" title="41"><span class="co">#> 4 4e-04 0.506197 304.3875 0</span></a>
<a class="sourceLine" id="cb3-42" title="42"><span class="co">#> 5 5e-04 0.505229 305.1940 0</span></a>
<a class="sourceLine" id="cb3-43" title="43"><span class="co">#> 6 6e-04 0.506842 305.0330 0</span></a></code></pre></div>
<div id="attributes" class="section level3">
<h3 class="hasAnchor">
<a href="#attributes" class="anchor"></a>Attributes</h3>
<p>Again, important object metadata and experimental parameters are stored as attributes. We make extensive use of attributes throughout the package and most functions will update at least one attribute after completion. So please see this feature of your <code>muscle_stim</code> objects for important info!</p>
<p>You can use <code>attributes</code> on an object itself (e.g. <code><a href="https://rdrr.io/r/base/attributes.html">attributes(wl_dat)</a></code>), but we’ll avoid doing so because the printout can be pretty lengthy.</p>
<p>Instead, let’s just look at a couple interesting ones.</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="co">## names(attributes(x) gives a list of all the attributes' names</span></a>
<a class="sourceLine" id="cb4-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/names.html">names</a></span>(<span class="kw"><a href="https://rdrr.io/r/base/attributes.html">attributes</a></span>(wl_dat))</a>
<a class="sourceLine" id="cb4-3" title="3"><span class="co">#> [1] "names" "class" "row.names" </span></a>
<a class="sourceLine" id="cb4-4" title="4"><span class="co">#> [4] "stimulus_frequency" "cycle_frequency" "total_cycles" </span></a>
<a class="sourceLine" id="cb4-5" title="5"><span class="co">#> [7] "cycle_def" "amplitude" "phase" </span></a>
<a class="sourceLine" id="cb4-6" title="6"><span class="co">#> [10] "position_inverted" "units" "sample_frequency" </span></a>
<a class="sourceLine" id="cb4-7" title="7"><span class="co">#> [13] "header" "units_table" "protocol_table" </span></a>
<a class="sourceLine" id="cb4-8" title="8"><span class="co">#> [16] "stim_table" "stimulus_pulses" "stimulus_offset" </span></a>
<a class="sourceLine" id="cb4-9" title="9"><span class="co">#> [19] "stimulus_width" "gear_ratio" "file_id" </span></a>
<a class="sourceLine" id="cb4-10" title="10"><span class="co">#> [22] "mtime"</span></a>
<a class="sourceLine" id="cb4-11" title="11"></a>
<a class="sourceLine" id="cb4-12" title="12"><span class="co">## take a look at the stimulation protocol</span></a>
<a class="sourceLine" id="cb4-13" title="13"><span class="kw"><a href="https://rdrr.io/r/base/attr.html">attr</a></span>(wl_dat, <span class="st">"protocol_table"</span>)</a>
<a class="sourceLine" id="cb4-14" title="14"><span class="co">#> Wait.s Then.action On.port Units Parameters</span></a>
<a class="sourceLine" id="cb4-15" title="15"><span class="co">#> 1 0.00 Stimulus-Train Stimulator .012, 300, 0.2, 4, 28 NA</span></a>
<a class="sourceLine" id="cb4-16" title="16"><span class="co">#> 2 0.01 Sine Wave Length Out 28,3.15,6 NA</span></a>
<a class="sourceLine" id="cb4-17" title="17"><span class="co">#> 3 0.00 Stimulus-Train Stimulator 0,0,0,0,0 NA</span></a>
<a class="sourceLine" id="cb4-18" title="18"><span class="co">#> 4 0.10 Stop NA</span></a>
<a class="sourceLine" id="cb4-19" title="19"></a>
<a class="sourceLine" id="cb4-20" title="20"><span class="co">## at what frequency were cyclic changes to Position performed?</span></a>
<a class="sourceLine" id="cb4-21" title="21"><span class="kw"><a href="https://rdrr.io/r/base/attr.html">attr</a></span>(wl_dat, <span class="st">"cycle_frequency"</span>)</a>
<a class="sourceLine" id="cb4-22" title="22"><span class="co">#> [1] 28</span></a>
<a class="sourceLine" id="cb4-23" title="23"></a>
<a class="sourceLine" id="cb4-24" title="24"><span class="co">## at what frequency were data recorded?</span></a>
<a class="sourceLine" id="cb4-25" title="25"><span class="kw"><a href="https://rdrr.io/r/base/attr.html">attr</a></span>(wl_dat, <span class="st">"sample_frequency"</span>)</a>
<a class="sourceLine" id="cb4-26" title="26"><span class="co">#> [1] 10000</span></a></code></pre></div>
</div>
</div>
<div id="data-from-files-that-are-not-of--ddf-format" class="section level2">
<h2 class="hasAnchor">
<a href="#data-from-files-that-are-not-of--ddf-format" class="anchor"></a>Data from files that are not of .ddf format</h2>
<p>Data that are read from other file formats can be constructed into <code>muscle_stim</code> objects via <code><a href="../reference/as_muscle_stim.html">as_muscle_stim()</a></code>. Should you need to do this, please refer to our vignette “Importing data from non .ddf sources” for an overview.</p>
</div>
<div id="transformations-and-corrections-to-data" class="section level2">
<h2 class="hasAnchor">
<a href="#transformations-and-corrections-to-data" class="anchor"></a>Transformations and corrections to data</h2>
<p>Prior to analyses, data can be transformed or corrected. Transformational functions include gear ratio correction (<code><a href="../reference/fix_GR.html">fix_GR()</a></code>) and position inversion (<code><a href="../reference/invert_position.html">invert_position()</a></code>). The core idea behind these two functions is to correct issues related to data acquisition.</p>
<p>For example, to apply a gear ratio correction of 2:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" title="1"><span class="co">## this multiples Force by 2</span></a>
<a class="sourceLine" id="cb5-2" title="2"><span class="co">## and multiplies Position by (1/2)</span></a>
<a class="sourceLine" id="cb5-3" title="3">wl_fixed <-<span class="st"> </span><span class="kw"><a href="../reference/fix_GR.html">fix_GR</a></span>(wl_dat, <span class="dt">GR =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb5-4" title="4"></a>
<a class="sourceLine" id="cb5-5" title="5"><span class="co"># quick check:</span></a>
<a class="sourceLine" id="cb5-6" title="6"><span class="kw"><a href="https://rdrr.io/r/base/Extremes.html">max</a></span>(wl_fixed<span class="op">$</span>Force)<span class="op">/</span><span class="kw"><a href="https://rdrr.io/r/base/Extremes.html">max</a></span>(wl_dat<span class="op">$</span>Force) <span class="co">#5592.578 / 2796.289 = 2</span></a>
<a class="sourceLine" id="cb5-7" title="7"><span class="co">#> [1] 2</span></a>
<a class="sourceLine" id="cb5-8" title="8"><span class="kw"><a href="https://rdrr.io/r/base/Extremes.html">max</a></span>(wl_fixed<span class="op">$</span>Position)<span class="op">/</span><span class="kw"><a href="https://rdrr.io/r/base/Extremes.html">max</a></span>(wl_dat<span class="op">$</span>Position) <span class="co">#1.832262 / 3.664524 = 0.5</span></a>
<a class="sourceLine" id="cb5-9" title="9"><span class="co">#> [1] 0.5</span></a></code></pre></div>
<div id="a-particularly-important-transformation---select_cycles" class="section level3">
<h3 class="hasAnchor">
<a href="#a-particularly-important-transformation---select_cycles" class="anchor"></a>A particularly important transformation - <code>select_cycles()</code>
</h3>
<p>Another ‘transformational’ function is <code><a href="../reference/select_cycles.html">select_cycles()</a></code>, which subsets cycles within a work loop experiment. This is a necessary step prior to analyses of work loop data: data are labeled by cycle for use with <code><a href="../reference/analyze_workloop.html">analyze_workloop()</a></code>.</p>
</div>
</div>
<div id="data-analytical-functions" class="section level2">
<h2 class="hasAnchor">
<a href="#data-analytical-functions" class="anchor"></a>Data analytical functions</h2>
<p>Core analytical functions include <code><a href="../reference/analyze_workloop.html">analyze_workloop()</a></code> for work loop files and <code><a href="../reference/isometric_timing.html">isometric_timing()</a></code> for twitches. <code><a href="../reference/analyze_workloop.html">analyze_workloop()</a></code> computes instantaneous velocity, net work, instantaneous power, and net power for work loop experiments on a per-cycle basis. <code><a href="../reference/isometric_timing.html">isometric_timing()</a></code> provides summarization of twitch kinetics.</p>
<p>To see more details about these functions, please refer to “Analyzing work loop experiments in workloopR” for work loop analyses and “Working with twitch files in workloopR” for twitches.</p>
<p>Some functions are readily available for batch processing of files. The <code><a href="../reference/read_analyze_wl_dir.html">read_analyze_wl_dir()</a></code> function allows for the batch import, cycle selection, gear ratio correction, and ultimately work & power computation for all work loop experiment files within a specified directory. The <code><a href="../reference/get_wl_metadata.html">get_wl_metadata()</a></code> and <code><a href="../reference/summarize_wl_trials.html">summarize_wl_trials()</a></code> functions organize scanned files by recency (according to their time of last modification: ‘mtime’) and then report work and power output in the order that trials were run.</p>
<p>This ultimately allows for the <code><a href="../reference/time_correct.html">time_correct()</a></code> function to correct for degradation of the muscle (according to power & work) over time, assuming that the first and final trials are identical in experimental parameters. If these parameters are not identical, we advise against using this function.</p>
</div>
<div id="thanks-for-reading" class="section level2">
<h2 class="hasAnchor">
<a href="#thanks-for-reading" class="anchor"></a>Thanks for reading!</h2>
<p>Please feel free to contact either Vikram or Shree with suggestions or code development requests. We are especially interested in expanding our data import functions to accommodate file types other than .ddf in future versions of <code>workloopR</code>.</p>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<div id="tocnav">
<h2 class="hasAnchor">
<a href="#tocnav" class="anchor"></a>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#welcome-to-workloopr">Welcome to workloopR</a></li>
<li><a href="#analytical-pipelines">Analytical pipelines</a></li>
<li><a href="#data-import">Data import</a></li>
<li><a href="#data-from-files-that-are-not-of--ddf-format">Data from files that are not of .ddf format</a></li>
<li><a href="#transformations-and-corrections-to-data">Transformations and corrections to data</a></li>
<li><a href="#data-analytical-functions">Data analytical functions</a></li>
<li><a href="#thanks-for-reading">Thanks for reading!</a></li>
</ul>
</div>
</div>
</div>
<footer><div class="copyright">
<p>Developed by <a href="https://www.vikram-baliga.com/">Vikram B. Baliga</a>, Shreeram Senthivasan.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.4.1.9000.</p>
</div>
</footer>
</div>
</body>
</html>