Recording of the local field potentials(LFPs) and calcium signal is strongly influenced by external stimuli. However, stimulation artifacts are difficult to isolate from the signal. Current studies generally screen out trial segments with high stimulus amplitude. To keep more information of the traces, We propose a method to remove the negative effects of deep brain stimulation (DBS) on LFPs, this method performs well in dealing with periodic artifacts with high amplitude, large pulse width and high stimulation frequency, which may also alleviate artifacts of neuronal calcium signaling trajectories introduced during imaging.