Noninvasive measurement techniques like EEG (electroencephalography) or MEG (magnetoencephalography) provide a good time resolution but suffer of a lack of spatial resolution. Source reconstruction is a solution for increasing the spatial resolution. It requires to solve an ill-posed inverse problem where the challenge is to restrict the source space, making a compromise between smooth and sparse constraints. We propose a model that introduces a piecewise latent process to ensure local homogeneity and global sparsity of the source. The method is developed in a Bayesian framework and the source reconstruction is expressed as the minimum mean square error, computed with a Markov Chain Monte Carlo algorithm. In addition to the source reconstruction, the method also provides a segmented solution that can be relevant for classification issues. The main contribution is the novel application of such a probabilistic model and its comparison with existing approaches. We apply the method on simulated EEG recordings and show the positive influence of the latent process.