Measurement of stimulus-induced changes in activity in the brain is critical to the advancement of neuroscience. Scientists use a range of methods, including electrode implantation, surface (scalp) electrode placement, and optical imaging, to gather data capturing underlying signals of interest in the brain. These data are usually corrupted by artifacts, complicating interpretation of the signal; in the context of optical imaging, two primary sources of corruption are the heartbeat and respiration cycles. We introduce a new linear state-space framework which uses the Kalman filter to remove these artifacts from optical imaging data. The method relies on a likelihood-based analysis under the specification of a formal statistical model, and allows for corrections to the signal based on auxiliary measurements of quantities closely related to the sources of contamination, such as physiological processes. Furthermore, the likelihood-based modeling framework allows us to perform goodness-of-fit testing and to perform formal hypothesis testing on parameters of interest. Working with data collected by our collaborators, we demonstrate the method on data collected in an optical imaging study of a cat's brain.