scripting to filter and comptue derivatives for codebooks, training