- "# .. note::\n#\n# For cropped decoding, the above training setup is mathematically\n# identical to sampling crops in your dataset, pushing them through the\n# network and training directly on the individual crops. At the same time,\n# the above training setup is much faster as it avoids redundant\n# computations by using dilated convolutions, see our paper\n# `Deep learning with convolutional neural networks for EEG decoding and visualization <https://arxiv.org/abs/1703.05051>`_. # noqa: E501\n# However, the two setups are only mathematically identical in case (1)\n# your network does not use any padding or only left padding and\n# (2) your loss function leads\n# to the same gradients when using the averaged output. The first is true\n# for our shallow and deep ConvNet models and the second is true for the\n# log-softmax outputs and negative log likelihood loss that is typically\n# used for classification in PyTorch.\n#\n\n# Loading and preprocessing the dataset\n# -------------------------------------\n#\n# Loading and preprocessing stays the same as in the `Trialwise decoding\n# tutorial <./plot_bcic_iv_2a_moabb_trial.html>`__.\n\nfrom braindecode.datasets import MOABBDataset\n\nsubject_id = 3\ndataset = MOABBDataset(dataset_name=\"BNCI2014001\", subject_ids=[subject_id])\n\nfrom braindecode.preprocessing import (\n exponential_moving_standardize, preprocess, Preprocessor, scale)\n\nlow_cut_hz = 4. # low cut frequency for filtering\nhigh_cut_hz = 38. # high cut frequency for filtering\n# Parameters for exponential moving standardization\nfactor_new = 1e-3\ninit_block_size = 1000\n\npreprocessors = [\n Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors\n Preprocessor(scale, factor=1e6, apply_on_array=True), # Convert from V to uV\n Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter\n Preprocessor(exponential_moving_standardize, # Exponential moving standardization\n factor_new=factor_new, init_block_size=init_block_size)\n]\n\n# Transform the data\npreprocess(dataset, preprocessors)"
0 commit comments