Analyzing the frequency of worm thrashing over time and creating the frequency matrix and annotation file
Description
This function analyzes the frequency of worm thrashing over time for the files returned by the Tracker program and then combined the frequency of all files into a matrix and extracted genotype information from tracker file names to create annotation file.
Arguments
inputPath 

outputPath 

method 
The function provides four different counting methods:
"FFT" (Fast Fourier Transform), "Extrema", "PeakDet" (peak delta)
and "RT+GP" (Get Peaks plus Racetrack Filter) and the users can
select one of them to output the corresponding frequency matrix.
The default outputted 
Threshold 

DeltaPeakDt 

MinFrameBtwnMax 

MinDelta 

longPeriod 

AvWindowSize 

fps 

ZP_Length 

WindowSize 

MaxCompWin 

minTime 

maxTime 

Details
The createFrequencyMatrix function outputs six files:
1. outputDescription_createFrequencyMatrix.html
contains a summary of
all output files.
2. XFig.jpg
is the image of scatter plot of one animal plotted as
"Frequency vs Time(min)" with all four counting methods overlaid.
"X" of "XFig.jpg" represents the input file names.
3. XFigSub.jpg
is the same as XFig.jpg
except counting methods
are broken up into four different plots. This is very helpful in checking through
a video to make sure that Tracker tracked the worm properly. Bad contrast can be
a problem with Tracker missing the worm and these files help to identify troublesome
videos for retracking or discarding.
4. XFreq.csv
is the CSV file of raw data organized by column,
where column one represents frequency as counted by FFT, column two represents
frequency calculated by Extrema, column three represents frequency calculated by
PeakDt, column four represents frequency as counted by RT+GP and column five
represents time in seconds.
5. frequencyMatrix.txt
is a TXT file which contains the information of frequencyMatrix
.
6. annotationfile.txt
is a TXT file which contains the information of annotation
.
Value
The createFrequencyMatrix function returns a list object which contains the following information:
frequencyMatrix 

annotation 

Note
The worm frequency analysis script in this function is converted from matlab script coded by Katherine Fleming and Paul Fleming.
Author(s)
Jing Wang and Andrew Hardaway
See Also
SwimR
Examples
1 2 3 4 5 6  inputPath < system.file("extdata","trackerFiles",package="SwimR")
outputPath < getwd()
freMat < createFrequencyMatrix(inputPath, outputPath, method = "Extrema",
Threshold = 0.6, DeltaPeakDt = 1.6, MinFrameBtwnMax = 4, MinDelta = 2.5, longPeriod = 5,
AvWindowSize = 10, fps = 15, ZP_Length = 100, WindowSize = 30, MaxCompWin = 2, minTime = 0,
maxTime = 600)
