I don't think this matters much, but you're calculating the per channel std without the global mean you precalculated. (donkey.lua line 193). This is incorrect, but assuming you wanted to do it like this, you could collapsed the mean and std loop into a single one instead of doing two. The proper way would be to calculate the std using the previously calculated mean. However, I don't think this will change much in practice.
you are right, does not matter much in practice but it's wrong. if you do a PR, will welcome it, but wont fix it myself. I've moved on to a more compact 400 line version that I wrote, which I like a bit more.
I don't think this matters much, but you're calculating the per channel std without the global mean you precalculated. (donkey.lua line 193). This is incorrect, but assuming you wanted to do it like this, you could collapsed the mean and std loop into a single one instead of doing two. The proper way would be to calculate the std using the previously calculated mean. However, I don't think this will change much in practice.