-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconvert_to_emotiv.sh
More file actions
executable file
·33 lines (29 loc) · 1014 Bytes
/
convert_to_emotiv.sh
File metadata and controls
executable file
·33 lines (29 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
## Convert_to_emotiv.sh
## ---------------------------------------------------------------- ##
## (c) 2016, Andrea Stocco
## University of Washington,
## Seattle, WA 98195
## Email: stocco@uw.edu
## ---------------------------------------------------------------- ##
## Converts EDF-style data to Emotiv-like datasets for EEG. The
## Emotiv format used at CCDL is already ready for analysis in R.
## ---------------------------------------------------------------- ##
for file in "$@"; do
echo "Processing file $file"
if [ -e header.txt ]; then
# If we have a header file, then we write it into
# the temp file
cat header.txt >> file.tmp
fi
# First we count the lines in the file
n=`grep -v "%" $1 | wc | awk '{print $1}'`
echo $n
# Remove the first 5 seconds (@ 256Hz)
l=$((n - 1280))
echo $l
# Write the last (N-5) seconds of recording on temp file
grep -v "%" ${file} | tail -${l} | tr ',' '\t' >> file.tmp
# Overwrite the original file
mv file.tmp $file
done