diff --git a/R/utils.R b/R/utils.R index 58eac2ec11bf5b0566af85077c00a7fb447ce32f..c8ccbfe8b1916a10f2577c7c4106fc5e3508555f 100644 --- a/R/utils.R +++ b/R/utils.R @@ -324,7 +324,12 @@ points2img <- function(points, voxel.size, method, channels = NULL, ncpu = 1) { I[,,,c] <- bins$table.freq } } else { - bins <- aws::binning(x = points[,c('x','y','z')], y = NULL, nbins = image.size) + if(length(channels == 1)) { + pts <- points[which(points$channel == channels), c('x','y','z')] + bins <- aws::binning(x = pts, y = NULL, nbins = image.size) + } else { + bins <- aws::binning(x = points[,c('x','y','z')], y = NULL, nbins = image.size) + } I <- array(bins$table.freq, dim = dim(bins$table.freq)) } } else {