This shouldn't be too difficult with the 3dcalc command or the 3dmerge command. 3dmerge has options for thresholding and clustering. When you say each slice, how is this different from thresholding on each voxel?
With 3dmerge, use the -1thresh and -1clust options.
3dmerge -1thresh 0.5 -1clust 2 200 -1tindex 4 -prefix cl_thr -doall dataset+orig
Here the threshold is applied to allow only voxels over a value of 0.5 from sub-brick 4 with clusters of radius of at least 2mm and a volume of 200 ul.