{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n# Shifting time-scale in evoked data\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Author: Mainak Jas \n#\n# License: BSD-3-Clause\n# Copyright the MNE-Python contributors." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n\nimport mne\nfrom mne.datasets import sample\n\nprint(__doc__)\n\ndata_path = sample.data_path()\nmeg_path = data_path / \"MEG\" / \"sample\"\nfname = meg_path / \"sample_audvis-ave.fif\"\n\n# Reading evoked data\ncondition = \"Left Auditory\"\nevoked = mne.read_evokeds(fname, condition=condition, baseline=(None, 0), proj=True)\n\npicks = [\"MEG 2332\"]\n\n# Create subplots\nf, (ax1, ax2, ax3) = plt.subplots(3)\nevoked.plot(\n exclude=[],\n picks=picks,\n axes=ax1,\n titles=dict(grad=\"Before time shifting\"),\n time_unit=\"s\",\n)\n\n# Apply relative time-shift of 500 ms\nevoked.shift_time(0.5, relative=True)\n\nevoked.plot(\n exclude=[],\n picks=picks,\n axes=ax2,\n titles=dict(grad=\"Relative shift: 500 ms\"),\n time_unit=\"s\",\n)\n\n# Apply absolute time-shift of 500 ms\nevoked.shift_time(0.5, relative=False)\n\nevoked.plot(\n exclude=[],\n picks=picks,\n axes=ax3,\n titles=dict(grad=\"Absolute shift: 500 ms\"),\n time_unit=\"s\",\n)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.2" } }, "nbformat": 4, "nbformat_minor": 0 }