#!/bin/sh

# Data columns:
# 1. Subject number
# 2. pos
# 3. lag
# 4. ignore
# 5. ACCuracy
#6  T conditional

echo > results.txt
 echo -e "\f Raw accuracy\n" >> results.txt
 cat "dataoutUnCond.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $3>0 {print $1, $2,$3, $5}' \
 | anova sub pos lag t1corr >> results.txt


 echo -e "\f T4 analysis \n" >> results.txt
 cat "dataoutUnCond.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $2 ==4 {print $1,  $3, $5}' \
 | anova sub lag t4corrr >> results.txt


 echo -e "\f T4 analysis contingent on T1 \n" >> results.txt
 cat "dataoutcombined.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $2 ==4 &&$6< 2 {print $1,  $3, $6,$5}' \
 | anova sub lag T1cond t4corrr >> results.txt


 echo -e "\f T4 analysis contingent on T1 at lag 1 \n" >> results.txt
 cat "dataoutcombined.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $2==4 &&$6< 2 &&$3==1 {print $1, $6,$5}' \
 | anova sub T1cond t4corrr >> results.txt

 echo -e "\f T4 analysis contingent on T1 & T2 at lag 1 \n" >> results.txt
 cat "dataoutcombined.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $2==4 &&$6!=1 &&$3==1{print $1,   $6,$5}' \
 | anova sub  T1cond t4corrr >> results.txt


 echo -e "\f T3 and T4 contingent on T1 and T2\n" >> results.txt
 cat "dataoutcombined.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $2>2 &&$6!=1{print $1, $2, $3,  $6,$5}' \
 | anova sub pos lag T1cond t4corrr >> results.txt


 echo -e "\f T2 T3 and T4 contingent on T1 and T2\n" >> results.txt
 cat "dataoutcombined.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $2>1 &&$6!=2{print $1, $2, $3,  $6,$5}' \
 | anova sub pos lag T1cond t4corrr >> results.txt

