Created
August 15, 2016 11:31
-
-
Save kaichogami/f7339102caae6a3fc7c7c753e4521a76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Compare time taken by original Xdawn and refactored Xdawn.""" | |
import time | |
import mne | |
from mne.datasets import sample | |
from mne.preprocessing import Xdawn, XdawnTransformer | |
# Initalize parameters for epochs | |
data_path = sample.data_path() | |
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif' | |
raw = mne.io.fiff.Raw(raw_fname, preload=True) | |
events = mne.find_events(raw) | |
baseline = (None, 0) | |
tmin, tmax = -0.1, 0.3 | |
picks = mne.pick_types(raw.info, meg=False, eeg=True, stim=False, eog=False, | |
exclude='bads') | |
event_id = dict(aud_l=1, aud_r=2, vis_l=3, vis_r=4) | |
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=False, | |
picks=picks, baseline=None, preload=True, | |
add_eeg_ref=False, verbose=False) | |
if __name__ == '__main__': | |
print("Time taken to intiliaze and fit Xdawn") | |
start = time.time() | |
xd = Xdawn() | |
xd.fit(epochs) | |
print(time.time() - start) | |
print("time taken to initlize and fit Xdawntransformer") | |
X = epochs.get_data() | |
start = time.time() | |
xdt = XdawnTransformer() | |
xdt.fit(X) | |
print(time.time() - start) | |
print("Time taken to transform Xdawn") | |
start = time.time() | |
xd.transform(epochs) | |
print(time.time() - start) | |
print("Time taken to transform Xdawntransformer") | |
start = time.time() | |
xdt.transform(X) | |
print(time.time() - start) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment