Removing Artifacts from EEG Recorded within MR Scanner by Dynamical Template State Space Approach