-
Notifications
You must be signed in to change notification settings - Fork 0
/
parseEP.pl
executable file
·54 lines (44 loc) · 1.53 KB
/
parseEP.pl
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env perl
use strict;
use warnings;
#use Getopt::Std;
#use v5.14;
######
#
# Make the txt log file into something R can handle
#
#####
#my @keys = qw/trial location masterlist.Cycle Running Correct Procedure Level iXEtePos masterlist.Sample Latency masterlist Score/;
my @keys = qw/trial location Correct Procedure iXEtePos masterlist.Sample Latency masterlist Score/;
if( !$ARGV[0] ) { die "useage $0 EPlogfile.txt\n";}
my $logfile = $ARGV[0];
#my $logfile = ($ARGV[0] || "/mnt/B/bea_res/Data/Tasks/BarsBehavioral/Basic/10872/20131129/Raw/EPrime/Behavioral Value Bars with scoring - v. 1-10872-1.txt");
#my $logfile = "/mnt/B/bea_res/Data/Tasks/BarsBehavioral/Basic/10872/20131129/Raw/EPrime/Behavioral Value Bars with scoring - v. 1-10872-1.txt";
my $logfh;
open $logfh, $logfile or die "cannot open $logfile";
my %rec;
$rec{$_}="" for @keys;
my $s=0; # should we be pulling values (started?)
my $t=0; # what trial are we on
#header
print join("\t", @keys),"\n";
while(<$logfh>){
chomp while chomp;
# done logging if at the end of the frame
if(m/LogFrame End/){
# only print and increment if we are in master list and is a reward type (not fix)
if($rec{'Procedure'} !~ m/fix|done|catch/i && $rec{'Running'} eq 'masterlist'){
$rec{'trial'}=++$t;
print join("\t",@rec{@keys}), "\n"
}
# clear out the hash
$rec{$_}="" for @keys;
}
# key:value into perl hash
if(m/\W*(.*):\W*([a-zA-Z0-9]+)/ and $s){
$rec{$1}="$2";
#print "\t\t$1 -- $2\n"
}
# should start logging on next line
$s=1 if m/LogFrame Start/;
}