workloopR’s data import functions, such as read_ddf(), are generally geared towards importing data from .ddf files (e.g. those generated by Aurora Scientific’s Dynamic Muscle Control and Analysis Software).

Should your data be stored in another file format, you can use the as_muscle_stim() function to generate your own muscle_stim objects. These muscle_stim objects are used by nearly all other workloopR functions and are formatted in a very specific way. This helps ensure that other functions can interpret data & metadata correctly and also perform internal checks.

Assemble via as_muscle_stim()

It is absolutely crucial that the columns be named “Time”, “Position”, “Force”, and “Stim” (all case-sensitive). Otherwise, as_muscle_stim() will not interpret data correctly.

At minimum, this data.frame, the type of experiment, and the frequency at which data were recorded (sample_frequency, as a numeric) are necessary for as_muscle_stim().

Possible attributes

Here is a list of all possible attributes that can be filled.

To see how each should be formatted, (e.g. which ones take numeric values vs. character vectors…etc)

str(attributes(workloop_dat))
#> List of 22
#>  $ names             : chr [1:4] "Time" "Position" "Force" "Stim"
#>  $ row.names         : int [1:3244] 1 2 3 4 5 6 7 8 9 10 ...
#>  $ stimulus_frequency: int 300
#>  $ cycle_frequency   : int 28
#>  $ total_cycles      : int 6
#>  $ cycle_def         : chr "lo"
#>  $ amplitude         : num 1.57
#>  $ phase             : num -24.9
#>  $ position_inverted : logi FALSE
#>  $ units             : chr [1:4] "s" "mm" "mN" "TTL"
#>  $ sample_frequency  : num 10000
#>  $ header            : chr [1:4] "Sample Frequency (Hz): 10000" "Reference Area: NaN sq. mm" "Reference Force: NaN mN" "Reference Length: NaN mm"
#>  $ units_table       :'data.frame':  10 obs. of  5 variables:
#>   ..$ Channel: chr [1:10] "AI0" "AI1" "AI2" "AI3" ...
#>   ..$ Units  : chr [1:10] "mm" "mN" "TTL" "" ...
#>   ..$ Scale  : num [1:10] 1 500 0.2 0 0 0 0 0 1 500
#>   ..$ Offset : num [1:10] 0 0 0 0 0 0 0 0 0 0
#>   ..$ TADs   : num [1:10] 0 0 0 0 0 0 0 0 0 0
#>  $ protocol_table    :'data.frame':  4 obs. of  5 variables:
#>   ..$ Wait.s     : num [1:4] 0 0.01 0 0.1
#>   ..$ Then.action: chr [1:4] "Stimulus-Train" "Sine Wave" "Stimulus-Train" "Stop"
#>   ..$ On.port    : chr [1:4] "Stimulator" "Length Out" "Stimulator" ""
#>   ..$ Units      : chr [1:4] ".012, 300, 0.2, 4, 28" "28,3.15,6" "0,0,0,0,0" ""
#>   ..$ Parameters : logi [1:4] NA NA NA NA
#>  $ stim_table        :'data.frame':  2 obs. of  5 variables:
#>   ..$ offset         : num [1:2] 0.012 0
#>   ..$ frequency      : int [1:2] 300 0
#>   ..$ width          : num [1:2] 0.2 0
#>   ..$ pulses         : int [1:2] 4 0
#>   ..$ cycle_frequency: int [1:2] 28 0
#>  $ stimulus_pulses   : int 4
#>  $ stimulus_offset   : num 0.012
#>  $ stimulus_width    : num 0.2
#>  $ gear_ratio        : num 2
#>  $ file_id           : chr "workloop.ddf"
#>  $ mtime             : POSIXct[1:1], format: "2019-12-11 23:26:53"
#>  $ class             : chr [1:3] "workloop" "muscle_stim" "data.frame"

Thanks for reading!

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 workloopR.