{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n# Getting started with mne.Report\n\n:class:`mne.Report` is a way to create interactive HTML summaries of your data.\nThese reports can show many different visualizations for one or multiple participants.\nA common use case is creating diagnostic summaries to check data\nquality at different stages in the processing pipeline. The report can show\nthings like plots of data before and after each preprocessing step, epoch\nrejection statistics, MRI slices with overlaid BEM shells, all the way up to\nplots of estimated cortical activity.\n\nCompared to a Jupyter notebook, :class:`mne.Report` is easier to deploy, as the\nHTML pages it generates are self-contained and do not require a running Python\nenvironment. However, it is less flexible as you can't change code and re-run\nsomething directly within the browser. This tutorial covers the basics of\nbuilding a report. As usual, we will start by importing the modules and data we need:\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Authors: The MNE-Python contributors.\n# License: BSD-3-Clause\n# Copyright the MNE-Python contributors." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import tempfile\nfrom pathlib import Path\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport scipy.ndimage\n\nimport mne\n\ndata_path = Path(mne.datasets.sample.data_path(verbose=False))\nsample_dir = data_path / \"MEG\" / \"sample\"\nsubjects_dir = data_path / \"subjects\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The basic process for creating an HTML report is to instantiate the\n:class:`~mne.Report` class and then use one or more of its many methods to\nadd content, one element at a time.\n\nYou may also use the :meth:`~mne.Report.parse_folder` method to select\nparticular files to include in the report. But more on that later.\n\n.. sidebar: Viewing the report\n\n On successful creation of the report, the :meth:`~mne.Report.save` method\n will open the HTML in a new tab in your browser. To disable this, use the\n ``open_browser=False`` parameter of :meth:`~mne.Report.save`.\n\n## Adding `~mne.io.Raw` data\n\nRaw data can be added via the :meth:`mne.Report.add_raw` method. It can\noperate with a path to a raw file and `~mne.io.Raw` objects, and will\nproduce \u2013 among other output \u2013 a slider that allows you to scrub through 10\nequally-spaced 1-second segments of the data:\n\n
In the following example, we crop the raw data to 60 seconds merely to\n speed up processing; this is not usually recommended!
:meth:`mne.Report.add_ica` only works with fitted ICAs.
In the following example, we request a small number of ICA components\n to estimate, set the threshold for assuming ICA convergence to a very\n liberal value, and only visualize 2 of the components. All of this is\n done to largely reduce the processing time of this tutorial, and is\n usually **not** recommended for an actual data analysis.
We have the following hypothesis:
\nBelow we show several plots and tests of the data.
\n\"\"\"\n\nreport.add_html(title=\"Hypothesis\", html=my_html)\nreport.save(\"report_add_html.html\", overwrite=True)" ] } ], "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 }