Hi Julie,
Sorry for all the messages. There is an issue with the way you compute the good time chunks for the quality metrics. First it seems you cannot have discontinuous time chunks. But even aside from that there is a bug. If you, e.g., have 4 time chunks and the first one is deemed bad, then currently your code will also drop the last time chunk.
Cheers
Laurenz