The utilization of contextual information was studied for the analysis of fMRI data. The approach consisted of two phases: computation of a statistical parametric map and activation detection by contextual clustering. The iterative clustering algorithm presented in this work is based on Besag's ICM algorithm. Our contribution has been to apply and evaluate the ICM in the context of hypothesis testing and statistical parametric maps. The results indicate that the power of the developed contextual algorithm is superior to that of conventional voxel-by-voxel thresholding of a statistical parametric map. Although fMRI data were used to test the algorithm, the construction of the algorithm is general and it can be used to detect objects with unknown distribution from a known background distribution in other similar problems as well.