#! /usr/bin/gawk -f # Last edited on 2017-09-19 09:23:43 by jstolfi BEGIN \ { # User must define (with "-v") {phase} as 0 or 1. # Reads from stdin a log produced by {nmeeg_split_e128_gh2013}. # Extracts from it the length (frame count) of phase {phase} # (0 = fixation, 1 = stimulus) of each run and writes to # stdout a histogram of those lengths. split("", nr); ntmin = 999999; brmin = -1; # Min length and its blockrun ID. ntmax = -1; brmax = -1; # Max length and its blockrun ID. nruns = 0; # Number of runs detected. br = -1; phase = phase + 0; } /^blockrun = / \ { br = $3; next; } /^ phase *[01]* [=]/ \ { ph = $2 + 0; nt = $5 + 0; if (ph != phase) { next; } if (nt < ntmin) { ntmin = nt; brmin = br; } if (nt > ntmax) { ntmax = nt; brmax = br; } nr[nt]++; br = -1; next; } // \ { next; } END \ { printf "min length %d at blockrun %d\n", ntmin, brmin > "/dev/stderr"; printf "max length %d at blockrun %d\n", ntmax, brmax > "/dev/stderr"; for (nt = ntmin; nt <= ntmax; nt++) { if (nr[nt]+0 == 0) { printf "%5d %5s\n", nt, "."; } else { printf "%5d %5d\n", nt, nr[nt]; } } }