Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts

Monday, May 20, 2013

Recurrence Quantification Analysis

This page has some wonderful resources for recurrence analysis. One particularly useful resource on this site is the listing of software options for conducting recurrence analysis. After a fair amount of searching, I couldn't find an R package that computed the metrics from a recurrence quantification analysis. The tseriesChaos package provides a function for producing recurrence plots; but, I didn't see anything for quantifying these plots.

After digging through the different software options listed on this site, I tried out and really like the Commandline Recurrence Plots script offered by Norbert Marwan himself.

The script was very easy to setup on my Mac and, by using Rscript it was easy to combine with R code to (a) draw specific chunks of data for different individuals in my dataset; (b) compute and output the recurrence quantification metrics; (c) output the recurrence plot dataset for creating the actual plot; and, (d) producing the plot and creating a dataset of metrics.

I'll clean up, comment, and post the code that I used as soon as I can come up for air.

Wednesday, November 28, 2012

Convert CD tracks to mp3 using ffmpeg

Just a small chunk of code to convert CD tracks (aiff) to mp3 files:


#!/bin/bash
for i in {1..12}
do
  ffmpeg -i ${i}.aiff -f mp3 -acodec libmp3lame -ab 192000 -ar 44100 ${i}.mp3
done



Tuesday, November 13, 2012

Copy files from incrementally-numbered drives

This code moves through drives (attached via USB) that are numbered incrementally and copies the files on the drives to the local hard disk. I'm using this to more quickly pull the data off of a number of Affectiva Q-Sensors, which I connect to my computer with a USB hub.

#!/bin/bash
for i in {1..20}
do
  # Create the directory
  mkdir "./sensor_data/${i}"
  # Check to see if the volume is mounted
  drive="Q${i}"
  if mount|grep $drive;
  then
    echo "${drive} is mounted"
    # move the files over to the directory
    cp -r /Volumes/${drive}/ ./sensor_data/${i}/
  else
    echo "${drive} is NOT mounted"
  fi
done





Sunday, September 23, 2012

Batch convert videos and reduce filesize

*Must have ffmpeg to run the code below
#!/bin/bash
for i in *.MPG
do 
    ffmpeg -i ${i/.*/}.MPG -qscale 2.5 ${i/.*/}.mp4
    # ffmpeg -i $i.MPG -sameq $i.mp4
done