| Type: | Package |
| Title: | Analysis of Work Loops and Other Data from Muscle PhysiologyExperiments |
| Version: | 1.1.4 |
| Description: | Functions for the import, transformation, and analysis of data from muscle physiology experiments. The work loop technique is used to evaluate the mechanical work and power output of muscle. Josephson (1985) <doi:10.1242/jeb.114.1.493> modernized the technique for application in comparative biomechanics. Although our initial motivation was to provide functions to analyze work loop experiment data, as we developed the package we incorporated the ability to analyze data from experiments that are often complementary to work loops. There are currently three supported experiment types: work loops, simple twitches, and tetanus trials. Data can be imported directly from .ddf files or via an object constructor function. Through either method, data can then be cleaned or transformed via methods typically used in studies of muscle physiology. Data can then be analyzed to determine the timing and magnitude of force development and relaxation (for isometric trials) or the magnitude of work, net power, and instantaneous power among other things (for work loops). Although we do not provide plotting functions, all resultant objects are designed to be friendly to visualization via either base-R plotting or 'tidyverse' functions. This package has been peer-reviewed by rOpenSci (v. 1.1.0). |
| URL: | https://docs.ropensci.org/workloopR/,https://github.com/ropensci/workloopR/ |
| BugReports: | https://github.com/ropensci/workloopR/issues/ |
| Imports: | pracma (≥ 2.0.7), signal (≥ 0.7-6) |
| Suggests: | testthat (≥ 2.1.1), knitr, rmarkdown, dplyr, ggplot2,magrittr, purrr, tidyr |
| License: | GPL (≥ 3) |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.1.1.9000 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2021-05-05 01:12:54 UTC; vbali |
| Author: | Vikram B. Baliga |
| Maintainer: | Vikram B. Baliga <vbaliga87@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2021-05-06 08:10:02 UTC |
workloopR: Analysis of Work Loops and Other Data from Muscle Physiology Experiments
Description
Functions for the import, transformation, and analysis of data from muscle physiology experiments. The work loop technique is used to evaluate the mechanical work and power output of muscle. Josephson (1985) <doi:10.1242/jeb.114.1.493> modernized the technique forapplication in comparative biomechanics. Although our initial motivation was to provide functions to analyze work loop experiment data, as we developed the package we incorporated the ability to analyze data from experiments that are often complementary to work loops. There are currently three supported experiment types: work loops, simple twitches, and tetanus trials. Data can be imported directly from .ddf files or via an object constructor function. Through either method, data can then be cleaned or transformed via methods typically used in studies of muscle physiology. Data can then be analyzed to determine the timing and magnitude of force development and relaxation (for isometric trials) or the magnitude of work, net power, and instantaneous power among other things (for work loops). Although we do not provide plotting functions, all resultant objects are designed to be friendly to visualization via either base-R plotting or 'tidyverse' functions.This package has been peer-reviewed by rOpenSci (v. 1.1.0).
Details
Functions for the import, transformation, and analysis of muscle physiologyexperiments. Currently supported experiment types: work loop, simple twitch,and tetanus.
Data that are stored in .ddf format (e.g. generated by Aurora Scientific'sDynamic Muscle Control and Analysis Software) are easily imported viaread_ddf(),read_analyze_wl(), orread_analyze_wl_dir().Doing so generates objects of classmuscle_stim, which are formattedto work nicely with workloopR's core functions. Data that are read from otherfile formats can be constructed intomuscle_stim objects viaas_muscle_stim().
Prior to analyses, data can be transformed or corrected. Transformationalfunctions include gear ratio correction (fix_GR()), position inversion(invert_position()), and subsetting of particular cycles within a workloop experiment (select_cycles()).
Core data analytical functions includeanalyze_workloop() for workloop files andisometric_timing() for twitches.analyze_workloop() computes instantaneous velocity, net work,instantaneous power, and net power for work loop experiments on a per-cyclebasis.isometric_timing() provides summarization of twitch kinetics.
Some functions are readily available for batch processing of files. Theread_analyze_wl_dir() function allows for the batch import, cycleselection, gear ratio correction, and ultimately work & power computation forall work loop experiment files within a specified directory. Theget_wl_metadata() andsummarize_wl_trials() functions organizescanned files by recency (according to their time of last modification:'mtime') and then report work and power output in the order that trials wererun. This ultimately allows for thetime_correct() function to correctfor degradation of the muscle (according to power & work) over time,assuming that the first and final trials are identical in experimentalparameters.
Please feel free to contact either Vikram or Shree with suggestions or codedevelopment requests (see contact info below). We are especially interestedin expanding our data import functions to accommodate file types other than.ddf in future versions of workloopR.
Author(s)
Maintainer: Vikram B. Baligavbaliga87@gmail.com (ORCID)
Authors:
Shreeram Senthivasanshreeramsenthi@gmail.com (ORCID)
Other contributors:
Julia RomanowskaJulia.Romanowska@uib.no (Julia reviewed the package for rOpenSci, see <https://github.com/ropensci/software-review/issues/326/>) [reviewer]
Eric Browneb@ericebrown.com (Eric reviewed the package for rOpenSci, see <https://github.com/ropensci/software-review/issues/326/>) [reviewer]
See Also
Useful links:
Report bugs athttps://github.com/ropensci/workloopR/issues/
Analyze work loop object to compute work and power output
Description
Compute work and power output from a work loop experiment on a per-cyclebasis.
Usage
analyze_workloop(x, simplify = FALSE, GR = 1, M = -1, vel_bf = 0.05, ...)Arguments
x | A |
simplify | Logical. If |
GR | Gear ratio, set to 1 by default |
M | Velocity multiplier, set adjust the sign of velocity. This parametershould generally be either -1 (the default) or 1. |
vel_bf | Critical frequency (scalar) for low-pass filtering of velocityvia |
... | Additional arguments potentially passed down from |
Details
Please note thatselect_cycles() must be run on data prior tousing this function. This function relies on the inputmuscle_stimobject being organized by cycle number.
Themuscle_stim object (x) must be aworkloop,preferably read in by one of our data import functions. Please seedocumentation foras_muscle_stim() if you need to manually constructamuscle_stim object from a non .ddf source.
The gear ratio (GR) and velocity multiplier (M) parameters can help correctfor issues related to the magnitude and sign of data collection. By default,they are set to apply no gear ratio adjustment and to positivize velocity.Instantaneous velocity is often noisy and thevel_bf parameter allowsfor low-pass filtering of velocity data. Seesignal::butter() andsignal::filtfilt() for details of how filtering is achieved.
Please also be careful with units! Se Warning section below.
Value
The function returns alist of classanalyzed_workloopthat provides instantaneous velocity, a smoothed velocity, and computes work,instantaneous power, and net power from a work loop experiment. All data areorganized by the cycle number and important metadata are stored asAttributes.
Within thelist, each entry is labeled by cycle and includes:
Time | Time, in sec |
Position | Length change of the muscle, corrected for gear ratio, in mm |
Force | Force, corrected for gear ratio, in mN |
Stim | When stimulation occurs, on a binary scale |
Cycle | Cycle ID, as a letter |
Inst_velocity | Instantaneous velocity, computed from |
Filt_velocity | Instantaneous velocity, after low-pass filtering, againin meter/sec |
Inst_Power | Instantaneous power, a product of |
Percent_of_Cycle | The percent of that particular cycle which haselapsed |
In addition, the following information is stored in theanalyzed_workloop object's attributes:
stimulus_frequency | Frequency at which stimulus pulses occurred |
cycle_frequency | Frequency of oscillations (assuming sine wavetrajectory) |
total_cycles | Total number of oscillatory cycles (assuming sine wavetrajectory) that the muscle experienced. |
cycle_def | Specifies what part of the cycle is understood as thebeginning and end. There are currently three options:'lo' for L0-to-L0;'p2p' for peak-to-peak; and't2t' for trough-to-trough |
amplitude | Amplitude of length change (assuming sine wavetrajectory) |
phase | Phase of the oscillatory cycle (in percent) at which stimulationoccurred. Somewhat experimental, please use with caution |
position_inverted | Logical; whether position inversion has beenapplied) |
units | The units of measurement for each column in the object afterrunning this function. See Warning |
sample_frequency | Frequency at which samples were collected |
header | Additional information from the header |
units_table | Units from each Channel of the original ddf file |
protocol_table | Protocol in tabular format; taken from the originalddf file |
stim_table | Specific info on stimulus protocol; taken from the originalddf file |
stimulus_pulses | Number of sequential pulses within a stimulationtrain |
stimulus_offset | Timing offset at which stimulus began |
gear_ratio | Gear ratio applied by this function |
file_id | File name |
mtime | Time at which file was last modified |
retained_cycles | Which cycles were retained, as numerics |
summary | Simple table showing work (in J) and net power (in W) for eachcycle |
Warning
Most systems we have encountered record Position data in millimetersand Force in millinewtons, and therefore this function assumes data arerecorded in those units. Through a series of internal conversions, thisfunction computes velocity in meters/sec, work in Joules, and power inWatts. If your raw data do not originate in millimeters and millinewtons,please transform your data accordingly and ignore what you see in theattributeunits.
Author(s)
Vikram B. Baliga and Shreeram Senthivasan
References
Josephson RK. 1985. Mechanical Power output from Striated Muscleduring Cyclic Contraction. Journal of Experimental Biology 114: 493-512.
See Also
read_ddf,read_analyze_wl,select_cycles
Other data analyses:isometric_timing(),read_analyze_wl_dir(),read_analyze_wl()
Other workloop functions:fix_GR(),get_wl_metadata(),invert_position(),read_analyze_wl_dir(),read_analyze_wl(),select_cycles(),summarize_wl_trials(),time_correct()
Examples
library(workloopR)# import the workloop.ddf file included in workloopRwl_dat <-read_ddf(system.file("extdata", "workloop.ddf", package = 'workloopR'), phase_from_peak = TRUE)# select cycles 3 through 5 via the peak-to-peak definitionwl_selected <- select_cycles(wl_dat, cycle_def = "p2p", keep_cycles = 3:5)# run the analysis function and get the full objectwl_analyzed <- analyze_workloop(wl_selected, GR = 2)# print methods give a short summaryprint(wl_analyzed)# summary provides a bit more detailsummary(wl_analyzed)# run the analysis but get the simplified versionwl_analyzed_simple <- analyze_workloop(wl_selected, simplify = TRUE, GR = 2)Create your own muscle_stim object
Description
For use when data are not stored in .ddf format and you would liketo create amuscle_stim object that can be used by other workloopRfunctions.
Usage
as_muscle_stim(x, type, sample_frequency, ...)Arguments
x | A |
type | Experiment type; must be one of: "workloop", "tetanus", or"twitch." |
sample_frequency | Numeric value of the frequency at which samples wererecorded; must be in Hz. Please format as numeric, e.g. |
... | Additional arguments that can be passed in as attributes. SeeDetails. |
Details
muscle_stim objects, which are required by (nearly) allworkloopR functions, are automatically created viaread_ddf(). Shouldyou have data that are stored in a format other than .ddf, use this functionto create your own object of classmuscle_stim.
The inputx must be adata.frame that contains time seriesof numeric data collected from an experiment. Each row must correspond to asample, and these columns (exact title matches) must be included:
"Time" - time, recorded in seconds
"Position" - instantaneous position of the muscle,preferably in millimeters
"Force" - force, preferably in millinewtons
"Stim" - whether stimulation has occurred. All entries must be either 0 (nostimulus) or 1 (stimulus occurrence).
Additional arguments can be provided via.... For all experimenttypes, the following attributes are appropriate:
"units","header", "units_table","protocol_table", "stim_table","stimulus_pulses", "stimulus_offset","stimulus_width", "gear_ratio","file_id", or "mtime".
Please ensure that further attributes are appropriate to your experimenttype.
For workloops, these include:"stimulus_frequency", "cycle_frequency","total_cycles", "cycle_def","amplitude", "phase",and "position_inverted"
For twitches or tetanic trials:"stimulus_frequency", and "stimulus_length"
Value
An object of classworkloop,twitch, ortetanus,all of which inherit classmuscle_stim. These objects behave likedata.frames in most situations but also store metadata from the ddfas attributes.
Themuscle_stim object's columns contain:
Time | Time |
Position | Length change of the muscle, uncorrected for gear ratio |
Force | Force, uncorrected for gear ratio |
Stim | When stimulation occurs, on a binary scale |
In addition, the following information is stored in thedata.frame'sattributes:
sample_frequency | Frequency at which samples were collected |
pulses | Number of sequential pulses within a stimulation train |
total_cycles_lo | Total number of oscillatory cycles (assuming sinewave trajectory) that the muscle experienced. Cycles are defined with respectto initial muscle length (L0-to-L0 as opposed to peak-to-peak). |
amplitude | amplitude of length change (again, assuming sine wavetrajectory) |
cycle_frequency | Frequency of oscillations (again, assuming sine wavetrajectory) |
units | The units of measurement for each column in the |
Author(s)
Shreeram Senthivasan
See Also
Other data import functions:get_wl_metadata(),read_analyze_wl_dir(),read_analyze_wl(),read_ddf_dir(),read_ddf()
Examples
library(workloopR)# import the workloop.ddf file included in workloopRwl_dat <-read_ddf(system.file("extdata", "workloop.ddf", package = 'workloopR'))Adjust for the gear ratio of a motor arm
Description
Fix a discrepancy between the gear ratio of the motor arm used and the gearratio recorded by software.
Usage
fix_GR(x, GR = 1)Arguments
x | A |
GR | Gear ratio, set to 1 by default |
Details
Themuscle_stim object can be of any type, includingworkloop,twitch, ortetanus.
If you have manually constructed the object viaas_muscle_stim(),themuscle_stim object should have columns as follows:Position: length change of the muscle;Force: force
Value
An object of the same class(es) as the input (x). The functionwill multiplyPosition by (1/GR) and multiplyForce by GR,returning an object with new values in$Position and$Force.Other columns and attributes are welcome and will simply be passed onunchanged into the resulting object.
Author(s)
Vikram B. Baliga
See Also
analyze_workloop,read_analyze_wl,read_analyze_wl_dir
Other data transformations:invert_position(),select_cycles()
Other workloop functions:analyze_workloop(),get_wl_metadata(),invert_position(),read_analyze_wl_dir(),read_analyze_wl(),select_cycles(),summarize_wl_trials(),time_correct()
Other twitch functions:invert_position(),isometric_timing()
Other tetanus functions:invert_position()
Examples
library(workloopR)# import the workloop.ddf file included in workloopRwl_dat <-read_ddf(system.file("extdata", "workloop.ddf", package = 'workloopR'), phase_from_peak = TRUE)# apply a gear ratio correction of 2# this will multiply Force by 2 and divide Position by 2wl_fixed <- fix_GR(wl_dat, GR = 2)# quick check:max(wl_fixed$Force) / max(wl_dat$Force) # 5592.578 / 2796.289 = 2max(wl_fixed$Position) / max(wl_dat$Position) # 1.832262 / 3.664524 = 0.5Get file info for a sequence of experiment files
Description
Grab metadata from files stored in the same folder (e.g. a sequence of trialsin an experiment).
Usage
get_wl_metadata(file_path, pattern = "*.ddf")Arguments
file_path | Path where files are stored. Should be in the same folder. |
pattern | Regex pattern for identifying relevant files in the file_path. |
Details
If several files (e.g. successive trials from one experiment) arestored in one folder, use this function to obtain metadata in a listformat. Runsfile.info() from base R to extract info from files.
This function is not truly considered to be part of the batch analysispipeline;seeread_analyze_wl_dir() for a similar function that notonly grabs metadata but also imports & analyzes files. Instead,get_wl_metadata() is meant to be a handy function to investigatemetadata issues that arise if runningread_analyze_wl_dir() goes awry.
Unlikeread_analyze_wl_dir(), this function does not necessarily needfiles to all be work loops. Any file type is welcome (as long as the Regexpattern argument makes sense).
Value
Either adata.frame (if a single file is supplied) or alist ofdata.frames (if a list of files is supplied), withinformation as supplied fromfile.info().
Author(s)
Vikram B. Baliga
See Also
Other data import functions:as_muscle_stim(),read_analyze_wl_dir(),read_analyze_wl(),read_ddf_dir(),read_ddf()
Other workloop functions:analyze_workloop(),fix_GR(),invert_position(),read_analyze_wl_dir(),read_analyze_wl(),select_cycles(),summarize_wl_trials(),time_correct()
Other batch analyses:read_analyze_wl_dir(),summarize_wl_trials(),time_correct()
Examples
library(workloopR)# get file info for files included with workloopRwl_meta <- get_wl_metadata(system.file("extdata/wl_duration_trials", package = 'workloopR'))Invert the position data
Description
Multiply instantaneous position by -1.
Usage
invert_position(x)Arguments
x | A |
Details
Themuscle_stim object can be of any type, includingworkloop,twitch, ortetanus.
If you have manually constructed the object viaas_muscle_stim(),themuscle_stim object should have a column entitledPosition.Other columns and attributes are welcome and will be passed along unchanged.
Value
Aworkloop object with inverted position. Theposition_inverted attribute is set toTRUE and all others areretained.
Author(s)
Vikram B. Baliga
See Also
Other data transformations:fix_GR(),select_cycles()
Other workloop functions:analyze_workloop(),fix_GR(),get_wl_metadata(),read_analyze_wl_dir(),read_analyze_wl(),select_cycles(),summarize_wl_trials(),time_correct()
Other twitch functions:fix_GR(),isometric_timing()
Other tetanus functions:fix_GR()
Examples
library(workloopR)# import the workloop.ddf file included in workloopRwl_dat <-read_ddf(system.file("extdata", "workloop.ddf", package = 'workloopR'), phase_from_peak = TRUE)# invert the sign of Positionwl_fixed <- invert_position(wl_dat)# quick check:max(wl_fixed$Position) / min(wl_dat$Position) # -1Compute timing and magnitude of force in isometric trials
Description
Calculate timing and magnitude of force at stimulation, peak force, andvarious parts of the rising (force development) and relaxation (falling)phases of the twitch.
Usage
isometric_timing(x, rising = c(10, 90), relaxing = c(90, 50))Arguments
x | A |
rising | Set points of the rising phase to be described.By default: 10% and 90%. |
relaxing | Set points of the relaxation phase to be described.By default: 90% and 50%. |
Details
Thedata.frame (x) must have time series data organized incolumns. Generally, it is preferred that you use amuscle_stim objectimported byread_ddf().
Therising andrelaxing arguments allow for the user to supplynumeric vectors of any length. By default, these arguments arerising = c(10, 90) andrelaxing = c(90, 50). Numbers in eachof these correspond to percent values and capture time and force at thatpercent of the corresponding curve. These values can be replaced by thosethat the user specifies and do not necessarily need to have length = 2. Butplease note that 0 and 100 should not be used, e.g.rising = seq(10, 90, 5) works, butrising = seq(0, 100, 5)does not.
Value
Adata.frame with the following metrics as columns:
file_ID | File ID |
time_stim | Time between beginning of data collection and whenstimulation occurs |
force_stim | Magnitude of force at the onset of stimulation |
time_peak | Absolute time of peak force, i.e. time between beginning ofdata collection and when peak force occurs |
force_peak | Magnitude of peak force |
time_rising_X | Time between beginning of data collection and X% offorce development |
force_rising_X | Magnitude of force at X% of force development |
time_relaxing_X | Time between beginning of data collection and X% offorce relaxation |
force_relaxing_X | Magnitude of force at X% of relaxation |
Author(s)
Vikram B. Baliga
References
Ahn AN, and Full RJ. 2002. A motor and a brake: two leg extensormuscles acting at the same joint manage energy differently in a runninginsect. Journal of Experimental Biology 205, 379-389.
See Also
Other data analyses:analyze_workloop(),read_analyze_wl_dir(),read_analyze_wl()
Other twitch functions:fix_GR(),invert_position()
Examples
library(workloopR)# import the twitch.ddf file included in workloopRtwitch_dat <-read_ddf(system.file("extdata", "twitch.ddf", package = 'workloopR'))# run isometric_timing() to get info on twitch kinetics# we'll use different set points than the defaultsanalyze_twitch <- isometric_timing(twitch_dat, rising = c(25, 50, 75), relaxing = c(75, 50, 25))# see the resultsanalyze_twitchAll-in-one import function for work loop files
Description
read_analyze_wl() is an all-in-one function to read in a work loopfile, select cycles, and compute work and power output.
Usage
read_analyze_wl(file_name, ...)Arguments
file_name | A .ddf file that contains data from asingle workloop experiment |
... | Additional arguments to be passed to |
Details
Please be careful with units! See Warnings below. This functioncombinesread_ddf() withselect_cycles() and then ultimatelyanalyze_workloop() into one handy function.
As detailed in these three functions, possible arguments include:cycle_def - used to specify which part of the cycle is understood asthe beginning and end. There are currently three options: 'lo' for L0-to-L0;'p2p' for peak-to-peak; and 't2t' for trough-to-troughbworth_order - Filter order for low-pass filtering ofPositionviasignal::butter prior to finding peak lengths. Default: 2.bworth_freq - Critical frequency (scalar) for low-pass filtering ofPosition viasignal::butter prior to finding peak lengths.Default: 0.05.keep_cycles - Which cycles should be retained. Default: 4:6.GR - Gear ratio. Default: 1.M - Velocity multiplier used to positivize velocity; should be either-1 or 1. Default: -1.vel_bf - Critical frequency (scalar) for low-pass filtering ofvelocity viasignal::butter. Default: 0.05.
The gear ratio (GR) and velocity multiplier (M) parameters can help correctfor issues related to the magnitude and sign of data collection. Bydefault, they are set to apply no gear ratio adjustment and to positivizevelocity. Instantaneous velocity is often noisy and thevel_bfparameter allows for low-pass filtering of velocity data. Seesignal::butter() andsignal::filtfilt() for details of howfiltering is achieved.
Value
The function returns alist of classanalyzed_workloopthat provides instantaneous velocity, a smoothed velocity, and computes work,instantaneous power, and net power from a work loop experiment. All data areorganized by the cycle number and important metadata are stored asAttributes.
Within thelist, each entry is labeled by cycle and includes:
Time | Time, in sec |
Position | Length change of the muscle, corrected for gear ratio, in mm |
Force | Force, corrected for gear ratio, in mN |
Stim | When stimulation occurs, on a binary scale |
Cycle | Cycle ID, as a letter |
Inst_velocity | Instantaneous velocity, computed from |
Filt_velocity | Instantaneous velocity, after low-pass filtering, againin meter/sec |
Inst_Power | Instantaneous power, a product of |
Percent_of_Cycle | The percent of that particular cycle which haselapsed |
In addition, the following information is stored in theanalyzed_workloop object's attributes:
stimulus_frequency | Frequency at which stimulus pulses occurred |
cycle_frequency | Frequency of oscillations (assuming sine wavetrajectory) |
total_cycles | Total number of oscillatory cycles (assuming sine wavetrajectory) that the muscle experienced. |
cycle_def | Specifies what part of the cycle is understood as thebeginning and end. There are currently three options:'lo' for L0-to-L0;'p2p' for peak-to-peak; and't2t' for trough-to-trough |
amplitude | Amplitude of length change (assuming sine wavetrajectory) |
phase | Phase of the oscillatory cycle (in percent) at which stimulationoccurred. Somewhat experimental, please use with caution |
position_inverted | Logical; whether position inversion has beenapplied) |
units | The units of measurement for each column in the object afterrunning this function. See Warning |
sample_frequency | Frequency at which samples were collected |
header | Additional information from the header |
units_table | Units from each Channel of the original ddf file |
protocol_table | Protocol in tabular format; taken from the originalddf file |
stim_table | Specific info on stimulus protocol; taken from the originalddf file |
stimulus_pulses | Number of sequential pulses within a stimulationtrain |
stimulus_offset | Timing offset at which stimulus began |
gear_ratio | Gear ratio applied by this function |
file_id | File name |
mtime | Time at which file was last modified |
retained_cycles | Which cycles were retained, as numerics |
summary | Simple table showing work (in J) and net power (in W) for eachcycle |
Warning
Most systems we have encountered record Position data in millimetersand Force in millinewtons, and therefore this function assumes data arerecorded in those units. Through a series of internal conversions, thisfunction computes velocity in meters/sec, work in Joules, and power inWatts. If your raw data do not originate in millimeters and millinewtons,please transform your data accordingly and ignore what you see in theattributeunits.
Author(s)
Vikram B. Baliga
References
Josephson RK. 1985. Mechanical Power output from Striated Muscleduring Cyclic Contraction. Journal of Experimental Biology 114: 493-512.
See Also
read_ddf,select_cyclesanalyze_workloop
Other data analyses:analyze_workloop(),isometric_timing(),read_analyze_wl_dir()
Other data import functions:as_muscle_stim(),get_wl_metadata(),read_analyze_wl_dir(),read_ddf_dir(),read_ddf()
Other workloop functions:analyze_workloop(),fix_GR(),get_wl_metadata(),invert_position(),read_analyze_wl_dir(),select_cycles(),summarize_wl_trials(),time_correct()
Examples
library(workloopR)# import the workloop.ddf file included in workloopR and analyze with# a gear ratio correction of 2 and cycle definition of peak-to-peakwl_dat <- read_analyze_wl(system.file("extdata", "workloop.ddf", package = 'workloopR'), phase_from_peak = TRUE, GR = 2, cycle_def = "p2p")Read and analyze work loop files from a directory
Description
All-in-one function to import multiple workloop .ddf files from a directory,sort them by mtime, analyze them, and store the resulting objects in anordered list.
Usage
read_analyze_wl_dir(file_path, pattern = "*.ddf", sort_by = "mtime", ...)Arguments
file_path | Directory in which files are located |
pattern | Regular expression used to specify files of interest. Defaultsto all .ddf files within file_path |
sort_by | Metadata by which files should be sorted to be in the correctrun order. Defaults to |
... | Additional arguments to be passed to |
Details
Work loop data files will be imported and then arranged in the orderin which they were run (assuming run order is reflected inmtime).Chiefly used in conjunction withsummarize_wl_trials() andtime_correct() if time correction is desired.
Value
A list containinganalyzed_workloop objects, one for each file that isimported and subsequently analyzed. The list is sorted according to thesort_by parameter, which by default uses the time of last modificationof each file's contents (mtime).
Warning
Most systems we have encountered record Position data in millimetersand Force in millinewtons, and therefore this function assumes data arerecorded in those units. Through a series of internal conversions, thisfunction computes velocity in meters/sec, work in Joules, and power inWatts. If your raw data do not originate in millimeters and millinewtons,please transform your data accordingly and ignore what you see in theattributeunits.
Author(s)
Shreeram Senthivasan
References
Josephson RK. 1985. Mechanical Power output from Striated Muscleduring Cyclic Contraction. Journal of Experimental Biology 114: 493-512.
See Also
read_analyze_wl,get_wl_metadata,summarize_wl_trials,time_correct
Other data analyses:analyze_workloop(),isometric_timing(),read_analyze_wl()
Other data import functions:as_muscle_stim(),get_wl_metadata(),read_analyze_wl(),read_ddf_dir(),read_ddf()
Other workloop functions:analyze_workloop(),fix_GR(),get_wl_metadata(),invert_position(),read_analyze_wl(),select_cycles(),summarize_wl_trials(),time_correct()
Other batch analyses:get_wl_metadata(),summarize_wl_trials(),time_correct()
Examples
library(workloopR)# batch read and analyze files included with workloopRanalyzed_wls <- read_analyze_wl_dir(system.file("extdata/wl_duration_trials", package = 'workloopR'), phase_from_peak = TRUE, cycle_def = "p2p", keep_cycles = 2:4)Import work loop or isometric data from .ddf files
Description
read_ddf reads in workloop, twitch, or tetanus experiment data from.ddf files.
Usage
read_ddf( file_name, file_id = NA, rename_cols = list(c(2, 3), c("Position", "Force")), skip_cols = 4:11, phase_from_peak = FALSE, ...)Arguments
file_name | A .ddf file that contains data from a single workloop,twitch, or tetanus experiment |
file_id | A string identifying the experiment. The file name is used bydefault. |
rename_cols | List consisting of a vector of indices of columns torename and a vector of new column names. See Details. |
skip_cols | Numeric vector of column indices to skip. See Details. |
phase_from_peak | Logical, indicating whether percent phase ofstimulation should be recorded relative to peak length or relative to L0(default) |
... | Additional arguments passed to/from other functions that workwith |
Details
Read in a .ddf file that contains data from an experiment. Ifposition and force do not correspond to columns 2 and 3 (respectively),replace "2" and "3" withinrename_cols accordingly. Similarly,skip_cols = 4:11 should be adjusted if more than 11 columns arepresent and/or columns 4:11 contain important data.
Please note that there is no correction for gear ratio or furthermanipulation of data. Seefix_GR to adjust gear ratio. Gear ratio canalso be adjusted prior to analyses within theanalyze_workloop()function, the data import all-in-one functionread_analyze_wl(), orthe batch analysis all-in-oneread_analyze_wl_dir().
Please also note that organization of data within the .ddf file is assumed toconform to that used by Aurora Scientific's Dynamic Muscle Control andAnalysis Software. YMMV if using a .ddf file from another source. Theas_muscle_stim() function can be used to generatemuscle_stimobjects if data are imported via another function. Please feel free tocontact us with any issues or requests.
Value
An object of classworkloop,twitch, ortetanus,all of which inherit classmuscle_stim. These objects behave likedata.frames in most situations but also store metadata from the ddfas attributes.
Themuscle_stim object's columns contain:
Time | Time |
Position | Length change of the muscle, uncorrected for gear ratio |
Force | Force, uncorrected for gear ratio |
Stim | When stimulation occurs, on a binary scale |
In addition, the following information is stored in thedata.frame'sattributes:
sample_frequency | Frequency at which samples were collected |
pulses | Number of sequential pulses within a stimulation train |
total_cycles_lo | Total number of oscillatory cycles (assuming sinewave trajectory) that the muscle experienced. Cycles are defined with respectto initial muscle length (L0-to-L0 as opposed to peak-to-peak). |
amplitude | amplitude of length change (again, assuming sine wavetrajectory) |
cycle_frequency | Frequency of oscillations (again, assuming sine wavetrajectory) |
units | The units of measurement for each column in the |
Author(s)
Vikram B. Baliga and Shreeram Senthivasan
See Also
Other data import functions:as_muscle_stim(),get_wl_metadata(),read_analyze_wl_dir(),read_analyze_wl(),read_ddf_dir()
Examples
library(workloopR)# import the workloop.ddf file included in workloopRwl_dat <-read_ddf(system.file("extdata", "workloop.ddf", package = 'workloopR'), phase_from_peak = TRUE)Import a batch of work loop or isometric data files from a directory
Description
Usesread_ddf() to read in workloop, twitch, or tetanus experimentdata from multiple .ddf files.
Usage
read_ddf_dir(file_path, pattern = "*.ddf", sort_by = "mtime", ...)Arguments
file_path | Path where files are stored. Should be in the same folder. |
pattern | Regex pattern for identifying relevant files in the file_path. |
sort_by | Metadata by which files should be sorted to be in the correctrun order. Defaults to |
... | Additional arguments to be passed to |
Details
Read in a .ddf file that contains data from an experiment. Ifposition and force do not correspond to columns 2 and 3 (respectively),replace "2" and "3" withinrename_cols accordingly. Similarly,skip_cols = 4:11 should be adjusted if more than 11 columns arepresent and/or columns 4:11 contain important data.
Please note that there is no correction for gear ratio or furthermanipulation of data. Seefix_GR to adjust gear ratio. Gear ratio canalso be adjusted prior to analyses within theanalyze_workloop()function, the data import all-in-one functionread_analyze_wl(), orthe batch analysis all-in-oneread_analyze_wl_dir().
Please also note that organization of data within the .ddf file is assumed toconform to that used by Aurora Scientific's Dynamic Muscle Control andAnalysis Software. YMMV if using a .ddf file from another source. Theas_muscle_stim() function can be used to generatemuscle_stimobjects if data are imported via another function. Please feel free tocontact us with any issues or requests.
Value
A list of objects of classworkloop,twitch, ortetanus, all of which inherit classmuscle_stim. These objectsbehave likedata.frames in most situations but also store metadatafrom the ddf as attributes.
Eachmuscle_stim object's columns contain:
Time | Time |
Position | Length change of the muscle, uncorrected for gear ratio |
Force | Force, uncorrected for gear ratio |
Stim | When stimulation occurs, on a binary scale |
In addition, the following information is stored in eachdata.frame'sattributes:
sample_frequency | Frequency at which samples were collected |
pulses | Number of sequential pulses within a stimulation train |
total_cycles_lo | Total number of oscillatory cycles (assuming sinewave trajectory) that the muscle experienced. Cycles are defined with respectto initial muscle length (L0-to-L0 as opposed to peak-to-peak). |
amplitude | amplitude of length change (again, assuming sine wavetrajectory) |
cycle_frequency | Frequency of oscillations (again, assuming sine wavetrajectory) |
units | The units of measurement for each column in the |
Author(s)
Vikram B. Baliga and Shreeram Senthivasan
See Also
Other data import functions:as_muscle_stim(),get_wl_metadata(),read_analyze_wl_dir(),read_analyze_wl(),read_ddf()
Examples
library(workloopR)# import a set of twitch .ddf files included in workloopRworkloop_dat <-read_ddf_dir(system.file("extdata/wl_duration_trials", package = 'workloopR'))Select cycles from a work loop object
Description
Retain data from a work loop experiment based on position cycle
Usage
select_cycles( x, cycle_def, keep_cycles = 4:6, bworth_order = 2, bworth_freq = 0.05, ...)Arguments
x | A |
cycle_def | A string specifying how cycles should be defined; one of:"lo", "p2p", or "t2t". See Details more info |
keep_cycles | The indices of the cycles to keep. Include 0 to keep dataidentified as being outside complete cycles |
bworth_order | Filter order for low-pass filtering of |
bworth_freq | Critical frequency (scalar) for low-pass filtering of |
... | Additional arguments passed to/from other functions that make useof |
Details
select_cycles() subsets data from a workloop trial byposition cycle. Thecycle_def argument is used to specify which partof the cycle is understood as the beginning and end. There are currentlythree options:
'lo' for L0-to-L0;
'p2p' for peak-to-peak; and
't2t' for trough-to-trough
Peaks are identified usingpracma::findpeaks(). L0 points on therising edge are found by finding the midpoints between troughs and thefollowing peak. However the first and last extrema and L0 points may bemisidentified by this method. Please plot yourPosition cycles toensure the edge cases are identified correctly.
Thekeep_cycles argument is used to determine which cycles (asdefined bycycle_def should be retained in the final dataset. Zerois the index assigned to all data points that are determined to be outsidea complete cycle.
Themuscle_stim object (x) must be aworkloop,preferably read in by one of our data import functions. Please seedocumentation foras_muscle_stim() if you need to manually constructamuscle_stim object from another source.
Value
Aworkloop object with rows subsetted by the chosen positioncycles. ACycle column is appended to denote which cycle each timepoint is associated with. Finally, all attributes from the inputworkloop object are retained and one new attribute is added torecord which cycles from the original data were retained.
Author(s)
Vikram B. Baliga and Shreeram Senthivasan
See Also
analyze_workloop,read_analyze_wl,read_analyze_wl_dir
Other data transformations:fix_GR(),invert_position()
Other workloop functions:analyze_workloop(),fix_GR(),get_wl_metadata(),invert_position(),read_analyze_wl_dir(),read_analyze_wl(),summarize_wl_trials(),time_correct()
Examples
library(workloopR)# import the workloop.ddf file included in workloopRwl_dat <-read_ddf(system.file("extdata", "workloop.ddf", package = 'workloopR'), phase_from_peak = TRUE)# select cycles 3 through 5 via the peak-to-peak definitionwl_selected <- select_cycles(wl_dat, cycle_def = "p2p", keep_cycles = 3:5)# are the cycles of (approximately) the same length?summary(as.factor(wl_selected$Cycle))Summarize work loop files
Description
Summarize important info from work loop files stored in the same folder(e.g. a sequence of trials in an experiment) including experimentalparameters, run order, andmtime.
Usage
summarize_wl_trials(wl_list)Arguments
wl_list | List of |
Details
If several files (e.g. successive trials from one experiment) arestored in one folder, use this function to obtain summary stats andmetadata and other parameters. This function requires a list ofanalyze_workloop objects, which can be readily obtained by firstrunningread_analyze_wl_dir() on a specified directory.
Value
Adata.frame of information about the collection of workloop files.Columns include:
File_ID | Name of the file |
Cycle_Frequency | Frequency of Position change |
Amplitude | amplitude of Position change |
Phase | Phase of the oscillatory cycle (in percent) at whichstimulation occurred. Somewhat experimental, please use with caution |
Stimulus_Pulses | Number of stimulation pulses |
mtime | Time at which file's contents were last changed ( |
Mean_Work | Mean work output from the selected cycles |
Mean_Power | Net power output from the selected cycles |
Author(s)
Vikram B. Baliga and Shreeram Senthivasan
References
Josephson RK. 1985. Mechanical Power output from Striated Muscleduring Cyclic Contraction. Journal of Experimental Biology 114: 493-512.
See Also
read_analyze_wl_dir,get_wl_metadata,time_correct
Other workloop functions:analyze_workloop(),fix_GR(),get_wl_metadata(),invert_position(),read_analyze_wl_dir(),read_analyze_wl(),select_cycles(),time_correct()
Other batch analyses:get_wl_metadata(),read_analyze_wl_dir(),time_correct()
Examples
library(workloopR)# batch read and analyze files included with workloopRanalyzed_wls <- read_analyze_wl_dir(system.file("extdata/wl_duration_trials", package = 'workloopR'), phase_from_peak = TRUE, cycle_def = "p2p", keep_cycles = 2:4 )# now summarizesummarized_wls <- summarize_wl_trials(analyzed_wls)Time correction for work loop experiments
Description
Correct for potential degradation of muscle over time.
Usage
time_correct(x)Arguments
x | A |
Details
This function assumes that across a batch of successive trials, thestimulation parameters for the first and final trials are identical. If not,DO NOT USE. Decline in power output is therefore assumed to be a linearfunction of time. Accordingly, the difference between the final and firsttrial's (absolute) power output is used to 'correct' trials that occur inbetween, with explicit consideration of run order and time elapsed (viamtime). A similar correction procedure is applied to work.
Value
Adata.frame that additionally contains:
Time_Corrected_Work | Time corrected work output, transformed from |
Time_Corrected_Power | Time corrected net power output, transformedfrom |
And new attributes:
power_difference | Difference in mass-specific net power outputbetween the final and first trials. |
time_difference | Difference in mtime between the final and firsttrials. |
time_correction_rate | Overall rate; |
Author(s)
Vikram B. Baliga and Shreeram Senthivasan
See Also
Other workloop functions:analyze_workloop(),fix_GR(),get_wl_metadata(),invert_position(),read_analyze_wl_dir(),read_analyze_wl(),select_cycles(),summarize_wl_trials()
Other batch analyses:get_wl_metadata(),read_analyze_wl_dir(),summarize_wl_trials()
Examples
library(workloopR)# batch read and analyze files included with workloopRanalyzed_wls <- read_analyze_wl_dir(system.file("extdata/wl_duration_trials", package = 'workloopR'), phase_from_peak = TRUE, cycle_def = "p2p", keep_cycles = 2:4)# now summarizesummarized_wls <- summarize_wl_trials(analyzed_wls)# mtimes within the package are not accurate, so we'll supply# our own vector of mtimessummarized_wls$mtime <- read.csv( system.file( "extdata/wl_duration_trials/ddfmtimes.csv", package="workloopR"))$mtime# now time correcttimecor_wls <- time_correct(summarized_wls)timecor_wlsApproximate the definite integral via the trapezoidal rule
Description
Mostly meant for internal use in our analysis functions, but made availablefor other use cases. Accordingly, it does not strictly rely on objects ofclassmuscle_stim.
Usage
trapezoidal_integration(x, f)Arguments
x | a variable, e.g. vector of positions |
f | integrand, e.g. vector of forces |
Details
In the functionsanalyze_workloop(),read_analyze_wl(), andread_analyze_wl_dir(), work is calculated as the differencebetween the integral of the upper curve and the integral of the lower curveof a work loop.
Value
A numerical value indicating the value of the integral.
Author(s)
Vikram B. Baliga
References
Atkinson, Kendall E. (1989), An Introduction to NumericalAnalysis (2nd ed.), New York: John Wiley & Sons
See Also
analyze_workloop,read_analyze_wl,read_analyze_wl_dir
Examples
# create a circle centered at (x = 10, y = 20) with radius 2t <- seq(0, 2 * pi, length = 1000)coords <- t(rbind(10 + sin(t) * 2, 20 + cos(t) * 2))# use the function to get the areatrapezoidal_integration(coords[, 1], coords[, 2])# does it match (pi * r^2)?3.14159265358 * (2^2) # very close