I think that would work.

Out of curiosity, how does this routine handle blocks of nans?  And is there interest in increasing the size of the filter window?