SHARE
TWEET

Arduino EEG logger data zoom in script

a guest Jun 9th, 2012 32 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /bin/sh
  2. echo "\n************ \n"
  3. echo "Plots EEG data for a zoomed-in file region\n"
  4. echo "This script expects to be run from within a folder\n containing the LOGGERNN.CSV file from the Arduino."
  5. echo "It expects the pathname of the LOGGERNN.CSV\n file as a command line argument, e.g:"
  6. echo "\t plot.sh LOGGER09.CSV \n"
  7. echo "************ \n"
  8.  
  9. START_MINUTES=00
  10. START_MSEC=00
  11. LENGTH_MINUTES=00
  12. LENGTH_MSEC=00
  13.  
  14. FILE=$1
  15. echo "Using data from" $FILE
  16.  
  17.  
  18. # ask for the offset
  19. echo "\n"
  20. head -n 2 "$FILE"
  21. read -p "What's the offset? (millis value above) " OFFSET
  22. # for testing:
  23. #OFFSET=222
  24. echo "\n"
  25.  
  26.  
  27.  
  28. read -p "How many minutes into the file does the selection start? (msec comes next) " START_MINUTES
  29.  
  30. read -p "How many milliseconds on top of that? " START_MSEC
  31.  
  32. read -p "How many minutes does the selection last? " LENGTH_MINUTES
  33.  
  34. read -p "How many milliseconds on top of that? " LENGTH_MSEC
  35.  
  36.  
  37.  
  38. # calculate starting offset
  39.  
  40. # for testing
  41.  # START_MINUTES=33;START_MSEC=44;OFFSET=55;LENGTH_MINUTES=66;LENGTH_MSEC=77;
  42.  
  43. START_OFFSET=$(( ($START_MINUTES * 60 * 1000) + $START_MSEC + $OFFSET))
  44.  
  45. echo "Using start offset" $START_OFFSET "msec"
  46.  
  47. # calculate ending offset
  48. END_OFFSET=$(( ($LENGTH_MINUTES  * 60 * 1000) + $LENGTH_MSEC + $START_OFFSET))
  49.  
  50. echo "Using end offset" $END_OFFSET "msec"
  51.  
  52. XSIZE=15
  53. YSIZE=4
  54.  
  55. # testing
  56.  
  57. OUTFILE="$FILE-${START_MINUTES}m${START_MSEC}msec_for_${LENGTH_MINUTES}m${LENGTH_MSEC}msec.pdf"
  58.  
  59. echo "Writing output to" $OUTFILE
  60.  
  61. gnuplot -e "file=file='$FILE'; set datafile separator \",\"; set key autotitle columnhead; set yrange [0:1000000]; set y2range [0:100]; set parametric; set label 1 \"File $FILE starting at $START_MINUTES min $START_MSEC msec for duration $LENGTH_MINUTES min $LENGTH_MSEC msec\" at graph 0.5,1.02 center;set xrange [$START_OFFSET:$END_OFFSET]; set terminal pdfcairo color size $XSIZE,$YSIZE; set output '$OUTFILE'; plot for [i=6:13] file using 1:i with lines smooth bezier, file using 1:3 with lines axis x1y2 smooth csplines"
RAW Paste Data
Top