In addition to functional localization and integration, the problem of determining whether the data encode some information about the mental state of the subject, and if so, how this information is represented has become an important research agenda in functional neuroimaging. Multivariate classifiers, commonly used for brain state decoding, are restricted to simple experimental paradigms with a fixed number of alternatives and are limited in their representation of the temporal dimension of the task. Moreover, they learn a mapping from the data to experimental conditions and therefore do not explain the intrinsic patterns in the data. In this paper, we present a data-driven approach to building a spatio-temporal representation of mental processes using a state-space formalism, without reference to experimental conditions. Efficient Monte Carlo algorithms for estimating the parameters of the model along with a method for model-size selection are developed. The advantages of such a model in determining the mental-state of the subject over pattern classifiers are demonstrated using an fMRI study of mental arithmetic.