Objective. Functional near-infrared spectroscopy (fNIRS) is an emerging non-invasive brain imaging technique that measures brain activities by using near-infrared light of 650-950 nm wavelength. The major advantages of fNIRS are its low cost, portability, and good temporal resolution as a plausible solution to real-time imaging. Recent research has shown the great potential of fNIRS as a tool for brain-computer interfaces. Approach. This paper presents the first novel technique for fNIRS-based modelling of brain activities using the linear parameter-varying (LPV) method and adaptive signal processing. The output signal of each channel is assumed to be an output of an LPV system with unknown coefficients that are optimally estimated by the affine projection algorithm. The parameter vector is assumed to be Gaussian. Main results. The general linear model (GLM) is very popular and is a commonly used method for the analysis of functional MRI data, but it has certain limitations in the case of optical signals. The proposed model is more efficient in the sense that it allows the user to define more states. Moreover, unlike most previous models, it is online. The present results, showing improvement, were verified by random finger-tapping tasks in extensive experiments. We used 24 states, which can be reduced or increased depending on the cost of computation and requirements. Significance. The t-statistics were employed to determine the activation maps and to verify the significance of the results. Comparison of the proposed technique and two existing GLM-based algorithms shows an improvement in the estimation of haemodynamic response. Additionally, the convergence of the proposed algorithm is shown by error reduction in consecutive iterations. © 2013 IOP Publishing Ltd.