#!/bin/sh

# Data columns:
# 1. Subject number
# 2. pos
# 3. IDD
# 4. ignore
# 5. ACCuracy
#6.  first or second episode
#7 conditional analysis or not




echo > resultscondt1.txt 
 echo -e "\f IDD 2_distractors\n" >> resultscondt1.txt
 cat "dataoutcombined.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $3==2  && $2>1 &&$7< 2{print $1, $2, $7,$5}' \
 | anova sub pos T1cond t1corr >> resultscondt1.txt

 echo -e "\f IDD 1_Episodes\n" >> resultscondt1.txt
 cat "dataoutcombined.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $3==1 && $2>1 &&$7< 2{print $1, $2, $7,$5}' \
 | anova sub pos T1cond t1corr >> resultscondt1.txt

 echo -e "\f IDD 1_Episodes FIRSTEPISODE\n" >> resultscondt1.txt
 cat "dataoutcombined.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $3==1 && $2>1 && $2<4 &&$7< 2{print $1, $2, $7,$5}' \
 | anova sub pos T1cond t1corr >> resultscondt1.txt

 echo -e "\f IDD 1_Episodes FIRSTEPISODE T1 and T2\n" >> resultscondt1.txt
 cat "dataoutcombined.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $3==1 && $2>2 && $2<4 &&$7!=1{print $1, $7,$5}' \
 | anova sub T1cond t1corr >> resultscondt1.txt


 echo -e "\f IDD 1_Episodes FIRSTEPISODE T1 and T2  with Pos\n" >> resultscondt1.txt
 cat "dataoutcombined.txt" | tr "\r" "\n" | \
 awk -F "\t" '$2>2 &&$7!=1{print $1,$2,$3, $7,$5}' \
 | anova sub pos IDD T1cond t1corr >> resultscondt1.txt
 

echo -e "\f IDD 1_Episodes FIRSTEPISODE T1 Cond  with Pos\n" >> resultscondt1.txt
 cat "dataoutcombined.txt" | tr "\r" "\n" | \
 awk -F "\t" '$2>1 &&$7!=2{print $1,$2,$3, $7,$5}' \
 | anova sub pos IDD T1cond t1corr >> resultscondt1.txt




 echo -e "\f IDD as a factor Raw vs T1 cond\n" >> resultscondt1.txt
 cat "dataoutcombined.txt" | tr "\r" "\n" | \
 awk -F "\t" '$1>0 && $3> 0  && $2>1 &&$7< 2{print $1,$2, $3, $7,$5}' \
 | anova sub pos IDD T1cond t1corr >> resultscondt1.txt



