The simple tasks that a person performs throughout the day is controlled by the relationship between a large number of neurons in different regions of the brain; therefore, a complete interpretation of the functioning mechanisms in the brain need simultaneously records many activities of the brain with the cellular resolution. However current electrophysiological methods for recording electrical signals of neurons, such as electrode arrays, do not have this capability and can only include a small subset of neurons. One challenge in neuroscience studies is the comprehensive measurement of neuronal activity in humans or animals. One ways to overcome this problem is two-photon calcium imaging technique that can capture a large number of neurons with cellular resolution. However, the main drawbacks of this technique are the imaging frame rate, which is slower than of firing rate of the neuronal cells and low signal-to-noise ratio. Because of its invasiveness two-photon calcium imaging, it does not use for humans. so, for studying with this method we used animals with the brain-like structure of a human brain, for example mouse. As recent advances in calcium sensing technologies facilitate simultaneously imaging action potentials in neuronal populations, complementary analytical tools must also be developed to maximize the utility of this experimental paradigm; therefore, because of nonlinear relation between calcium imaging data and spiking data, providing a model for neural encoding seems necessary. In this research, we present a generative model including nonlinear functions, linear filter, spiking model and calcium kinetics model as evolution function, and a model for transformthe calcium kinetics to the fluorescence trace as observation function to encode calcium imaging data. Also, due to the spike-frequency adaptation that can cause neural coding failure, we use Morris-Lecar model with adaptation currents for spiking model. In order to estimate the parameters of the generative model, we use VB-Laplace method. Finally, the encoding model used for encoding the angle and curvature of mouse whisker in the barrel cortex during a pole localization task that result 42\\% of barrel cortex neurons encoding mouse whisker data. Because a large part of the brain’s activity is thought to be internally generated and, hence, quantifying stimulus response relationships alone does not fully describe brain dynamics; therefore, in this research, we use extended transfer entropy for extraction of neuronal connections. We will try to improve the presented neural encoding model by use the three neurons with more connection. The results indicate a better estimate of the spike rate of barrel cortex neurons in the calcium imaging data. Calcium Imaging , Generative Model , Spike Frequency Adaptation , Transfer Entropy