Modified from the R package from Rozenholc, Pouzat and Lieury https://cran.r-project.org/web/packages/DynClust/ . It's a two stage denoising/clustering method for 2D/3D + time images. Data is supposed to be normally distributed with known variance -- the value of the variance can be set per voxel (an addition to the original R code).