#!/bin/sh

# Data columns:
# 1. Subject number
# 2. pos
# 3. SOA
# 4. IDD
# 5. ACCuracy
# 6. Condition: 1 2 3 4
#  Condition 1 is slow TTTT
#  Condition 4 is fast TDTDTD
#  Condition 2 is slow TDTDTDT?
#  Condition 3 is fast TTTT?


# Fast  TTTT TDTDT
# Slow  TTTT TDTDTD

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

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

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

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

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

 echo -e "\f Raw accuracy  critical comparison1\n" >> results.txt
 cat "dataoutComplete.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && ($6==4 || $6 ==1) {print $1,$2,$6, $5}' \
 | anova sub pos condition t1corr >> results.txt

 echo -e "\f Raw accuracy  critical comparison2\n" >> results.txt
 cat "dataoutComplete.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && ($6==2 || $6 ==1) {print $1,$2,$6, $5}' \
 | anova sub pos condition t1corr >> results.txt

echo -e "\f T1 conditional analysis\n" >> results.txt
 cat "dataoutComplete.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $2 > 1 && $6 ==1 && $7< 2{print $1,$2, $7, $5}' \
 | anova sub pos T1cond t1corr >> results.txt

 echo -e "\f T1conditional analysis with all factors\n" >> results.txt
 cat "dataoutComplete.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $3>0&& $2 > 1 &&$7 <2 {print $1, $2,$3,$4, $7, $5}' \
 | anova sub pos SOA IDD T1cond t1corr >> results.txt


echo -e "\f T1 T2 conditional analysis\n" >> results.txt
 cat "dataoutComplete.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1!=9 && $2 > 2 && $6 ==1 && $7 !=1{print $1,$2, $7, $5}' \
 | anova sub pos T1cond t1corr >> results.txt


 echo -e "\f analysis of T3 and T4 with no condition\n" >> results.txt
 cat "dataoutComplete.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $3>0&& $2 > 2 &&$7 ==0 {print $1, $2,$6, $5}' \
 | anova sub pos trialtype t1corr>> results.txt


 echo -e "\f analysis of T3 and T4 with T1^T2\n" >> results.txt
 cat "dataoutComplete.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1!=9 && $3>0&& $2 > 2 &&$7 ==2 {print $1, $2,$6, $5}' \
 | anova sub pos trialtype t1corr>> results.txt


 echo -e "\f analysis of T2 T3 and T4 with T1\n" >> results.txt
 cat "dataoutComplete.txt" | tr "\r" "\n" | \
 awk -F "\t" '$3>0&& $2 > 1 &&$7 ==1 {print $1, $2,$6, $5}' \
 | anova sub pos trialtype t1corr>> results.txt



