prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  ENH: Allow retrieval of GFP
  #2538 added the ability to plot GFPs. Currently, the GFP is [only temporarily calculated for plotting](https://github.com/Eric89GXL/mne-python/blob/7f8c69bae49041bb4f0507539ccda1bda7f0b394/mne/viz/evoked.py#L397), and the user has no easy way to access the data. 
  
   In our EEG workflow, we typically calculate GFPs for every single participant and condition, and average conditions across participants for plotting; or we compute statistics based on the GFP differences. It is therefore highly important for us to have easy access to the GFPs. We resorted to doing the calculations manually based on `Evoked.data`, but this is cumbersome as one has to "leave" the MNE sphere and implement the operations by hand via NumPy and/or Pandas -- which is not easy for beginners and error-prone, as Pandas by default [uses the unbiased estimator](http://stackoverflow.com/questions/24984178/different-std-in-pandas-vs-numpy) for standard deviation and NumPy doesn't.
  
  I can try to implement a GFP function, but I would need assistance in doing so. I don't really know where to start or where to put that code: should it be a method of the `Evoked` class? Potentially exposed as a property, so it could be accessed via `Evoked.gfp`? Or should it be an entirely new class? Would it have to have its own plotting method? etc. pp. Any help and suggestions would be greatly appreciated.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `tutorials/plot_object_evoked.py`
  Content:
  ```
  1 """
  2 .. _tut_evoked_objects:
  3 
  4 The :class:`Evoked <mne.Evoked>` data structure: evoked/averaged data
  5 =====================================================================
  6 
  7 The :class:`Evoked <mne.Evoked>` data structure is mainly used for storing
  8 averaged data over trials. In MNE the evoked objects are usually created by
  9 averaging epochs data with :func:`mne.Epochs.average`.
  10 """
  11 
  12 import os.path as op
  13 
  14 import mne
  15 
  16 ###############################################################################
  17 # Here for convenience we read the evoked dataset from a file.
  18 data_path = mne.datasets.sample.data_path()
  19 fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')
  20 evokeds = mne.read_evokeds(fname, baseline=(None, 0), proj=True)
  21 print(evokeds)
  22 
  23 ###############################################################################
  24 # Notice that the reader function returned a list of evoked instances. This is
  25 # because you can store multiple categories into a single file. Here we have
  26 # categories of
  27 # ``['Left Auditory', 'Right Auditory', 'Left Visual', 'Right Visual']``.
  28 # We can also use ``condition`` parameter to read in only one category.
  29 evoked = mne.read_evokeds(fname, condition='Left Auditory')
  30 evoked.apply_baseline((None, 0)).apply_proj()
  31 print(evoked)
  32 
  33 ###############################################################################
  34 # If you're gone through the tutorials of raw and epochs datasets, you're
  35 # probably already familiar with the :class:`Info <mne.Info>` attribute.
  36 # There is nothing new or special with the ``evoked.info``. All the relevant
  37 # info is still there.
  38 print(evoked.info)
  39 print(evoked.times)
  40 
  41 ###############################################################################
  42 # The evoked data structure also contains some new attributes easily
  43 # accessible:
  44 print(evoked.nave)  # Number of averaged epochs.
  45 print(evoked.first)  # First time sample.
  46 print(evoked.last)  # Last time sample.
  47 print(evoked.comment)  # Comment on dataset. Usually the condition.
  48 print(evoked.kind)  # Type of data, either average or standard_error.
  49 
  50 ###############################################################################
  51 # The data is also easily accessible. Since the evoked data arrays are usually
  52 # much smaller than raw or epochs datasets, they are preloaded into the memory
  53 # when the evoked object is constructed. You can access the data as a numpy
  54 # array.
  55 data = evoked.data
  56 print(data.shape)
  57 
  58 ###############################################################################
  59 # The data is arranged in an array of shape `(n_channels, n_times)`. Notice
  60 # that unlike epochs, evoked object does not support indexing. This means that
  61 # to access the data of a specific channel you must use the data array
  62 # directly.
  63 print('Data from channel {0}:'.format(evoked.ch_names[10]))
  64 print(data[10])
  65 
  66 ###############################################################################
  67 # If you want to import evoked data from some other system and you have it in a
  68 # numpy array you can use :class:`mne.EvokedArray` for that. All you need is
  69 # the data and some info about the evoked data. For more information, see
  70 # :ref:`tut_creating_data_structures`.
  71 evoked = mne.EvokedArray(data, evoked.info, tmin=evoked.times[0])
  72 evoked.plot(time_unit='s')
  73 
  74 ###############################################################################
  75 # To write an evoked dataset to a file, use the :meth:`mne.Evoked.save` method.
  76 # To save multiple categories to a single file, see :func:`mne.write_evokeds`.
  77
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/tutorials/plot_object_evoked.py b/tutorials/plot_object_evoked.py
  --- a/tutorials/plot_object_evoked.py
  +++ b/tutorials/plot_object_evoked.py
  @@ -8,9 +8,11 @@
   averaged data over trials. In MNE the evoked objects are usually created by
   averaging epochs data with :func:`mne.Epochs.average`.
   """
  +# sphinx_gallery_thumbnail_number = 2
   
   import os.path as op
   
  +import matplotlib.pyplot as plt
   import mne
   
   ###############################################################################
  @@ -63,6 +65,16 @@
   print('Data from channel {0}:'.format(evoked.ch_names[10]))
   print(data[10])
   
  +###############################################################################
  +# In the same vein, we can quickly extract (and, e.g., plot) the GFP as the
  +# standard deviation across channels, here shown just for EEG.
  +
  +gfp = evoked.copy().pick_types(eeg=True, meg=False).data.std(axis=0)
  +fig, ax = plt.subplots(1)
  +ax.plot(evoked.times, gfp / 1e6)  # scale to uV
  +ax.set(xlabel='Time (sec)', ylabel='GFP (uV)')
  +fig.tight_layout()
  +
   ###############################################################################
   # If you want to import evoked data from some other system and you have it in a
   # numpy array you can use :class:`mne.EvokedArray` for that. All you need is
  
verification_info: {"golden_diff": "diff --git a/tutorials/plot_object_evoked.py b/tutorials/plot_object_evoked.py\n--- a/tutorials/plot_object_evoked.py\n+++ b/tutorials/plot_object_evoked.py\n@@ -8,9 +8,11 @@\n averaged data over trials. In MNE the evoked objects are usually created by\n averaging epochs data with :func:`mne.Epochs.average`.\n \"\"\"\n+# sphinx_gallery_thumbnail_number = 2\n \n import os.path as op\n \n+import matplotlib.pyplot as plt\n import mne\n \n ###############################################################################\n@@ -63,6 +65,16 @@\n print('Data from channel {0}:'.format(evoked.ch_names[10]))\n print(data[10])\n \n+###############################################################################\n+# In the same vein, we can quickly extract (and, e.g., plot) the GFP as the\n+# standard deviation across channels, here shown just for EEG.\n+\n+gfp = evoked.copy().pick_types(eeg=True, meg=False).data.std(axis=0)\n+fig, ax = plt.subplots(1)\n+ax.plot(evoked.times, gfp / 1e6)  # scale to uV\n+ax.set(xlabel='Time (sec)', ylabel='GFP (uV)')\n+fig.tight_layout()\n+\n ###############################################################################\n # If you want to import evoked data from some other system and you have it in a\n # numpy array you can use :class:`mne.EvokedArray` for that. All you need is\n", "issue": "ENH: Allow retrieval of GFP\n#2538 added the ability to plot GFPs. Currently, the GFP is [only temporarily calculated for plotting](https://github.com/Eric89GXL/mne-python/blob/7f8c69bae49041bb4f0507539ccda1bda7f0b394/mne/viz/evoked.py#L397), and the user has no easy way to access the data. \r\n\r\n In our EEG workflow, we typically calculate GFPs for every single participant and condition, and average conditions across participants for plotting; or we compute statistics based on the GFP differences. It is therefore highly important for us to have easy access to the GFPs. We resorted to doing the calculations manually based on `Evoked.data`, but this is cumbersome as one has to \"leave\" the MNE sphere and implement the operations by hand via NumPy and/or Pandas -- which is not easy for beginners and error-prone, as Pandas by default [uses the unbiased estimator](http://stackoverflow.com/questions/24984178/different-std-in-pandas-vs-numpy) for standard deviation and NumPy doesn't.\r\n\r\nI can try to implement a GFP function, but I would need assistance in doing so. I don't really know where to start or where to put that code: should it be a method of the `Evoked` class? Potentially exposed as a property, so it could be accessed via `Evoked.gfp`? Or should it be an entirely new class? Would it have to have its own plotting method? etc. pp. Any help and suggestions would be greatly appreciated.\n", "before_files": [{"content": "\"\"\"\n.. _tut_evoked_objects:\n\nThe :class:`Evoked <mne.Evoked>` data structure: evoked/averaged data\n=====================================================================\n\nThe :class:`Evoked <mne.Evoked>` data structure is mainly used for storing\naveraged data over trials. In MNE the evoked objects are usually created by\naveraging epochs data with :func:`mne.Epochs.average`.\n\"\"\"\n\nimport os.path as op\n\nimport mne\n\n###############################################################################\n# Here for convenience we read the evoked dataset from a file.\ndata_path = mne.datasets.sample.data_path()\nfname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')\nevokeds = mne.read_evokeds(fname, baseline=(None, 0), proj=True)\nprint(evokeds)\n\n###############################################################################\n# Notice that the reader function returned a list of evoked instances. This is\n# because you can store multiple categories into a single file. Here we have\n# categories of\n# ``['Left Auditory', 'Right Auditory', 'Left Visual', 'Right Visual']``.\n# We can also use ``condition`` parameter to read in only one category.\nevoked = mne.read_evokeds(fname, condition='Left Auditory')\nevoked.apply_baseline((None, 0)).apply_proj()\nprint(evoked)\n\n###############################################################################\n# If you're gone through the tutorials of raw and epochs datasets, you're\n# probably already familiar with the :class:`Info <mne.Info>` attribute.\n# There is nothing new or special with the ``evoked.info``. All the relevant\n# info is still there.\nprint(evoked.info)\nprint(evoked.times)\n\n###############################################################################\n# The evoked data structure also contains some new attributes easily\n# accessible:\nprint(evoked.nave)  # Number of averaged epochs.\nprint(evoked.first)  # First time sample.\nprint(evoked.last)  # Last time sample.\nprint(evoked.comment)  # Comment on dataset. Usually the condition.\nprint(evoked.kind)  # Type of data, either average or standard_error.\n\n###############################################################################\n# The data is also easily accessible. Since the evoked data arrays are usually\n# much smaller than raw or epochs datasets, they are preloaded into the memory\n# when the evoked object is constructed. You can access the data as a numpy\n# array.\ndata = evoked.data\nprint(data.shape)\n\n###############################################################################\n# The data is arranged in an array of shape `(n_channels, n_times)`. Notice\n# that unlike epochs, evoked object does not support indexing. This means that\n# to access the data of a specific channel you must use the data array\n# directly.\nprint('Data from channel {0}:'.format(evoked.ch_names[10]))\nprint(data[10])\n\n###############################################################################\n# If you want to import evoked data from some other system and you have it in a\n# numpy array you can use :class:`mne.EvokedArray` for that. All you need is\n# the data and some info about the evoked data. For more information, see\n# :ref:`tut_creating_data_structures`.\nevoked = mne.EvokedArray(data, evoked.info, tmin=evoked.times[0])\nevoked.plot(time_unit='s')\n\n###############################################################################\n# To write an evoked dataset to a file, use the :meth:`mne.Evoked.save` method.\n# To save multiple categories to a single file, see :func:`mne.write_evokeds`.\n", "path": "tutorials/plot_object_evoked.py"}], "after_files": [{"content": "\"\"\"\n.. _tut_evoked_objects:\n\nThe :class:`Evoked <mne.Evoked>` data structure: evoked/averaged data\n=====================================================================\n\nThe :class:`Evoked <mne.Evoked>` data structure is mainly used for storing\naveraged data over trials. In MNE the evoked objects are usually created by\naveraging epochs data with :func:`mne.Epochs.average`.\n\"\"\"\n# sphinx_gallery_thumbnail_number = 2\n\nimport os.path as op\n\nimport matplotlib.pyplot as plt\nimport mne\n\n###############################################################################\n# Here for convenience we read the evoked dataset from a file.\ndata_path = mne.datasets.sample.data_path()\nfname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')\nevokeds = mne.read_evokeds(fname, baseline=(None, 0), proj=True)\nprint(evokeds)\n\n###############################################################################\n# Notice that the reader function returned a list of evoked instances. This is\n# because you can store multiple categories into a single file. Here we have\n# categories of\n# ``['Left Auditory', 'Right Auditory', 'Left Visual', 'Right Visual']``.\n# We can also use ``condition`` parameter to read in only one category.\nevoked = mne.read_evokeds(fname, condition='Left Auditory')\nevoked.apply_baseline((None, 0)).apply_proj()\nprint(evoked)\n\n###############################################################################\n# If you're gone through the tutorials of raw and epochs datasets, you're\n# probably already familiar with the :class:`Info <mne.Info>` attribute.\n# There is nothing new or special with the ``evoked.info``. All the relevant\n# info is still there.\nprint(evoked.info)\nprint(evoked.times)\n\n###############################################################################\n# The evoked data structure also contains some new attributes easily\n# accessible:\nprint(evoked.nave)  # Number of averaged epochs.\nprint(evoked.first)  # First time sample.\nprint(evoked.last)  # Last time sample.\nprint(evoked.comment)  # Comment on dataset. Usually the condition.\nprint(evoked.kind)  # Type of data, either average or standard_error.\n\n###############################################################################\n# The data is also easily accessible. Since the evoked data arrays are usually\n# much smaller than raw or epochs datasets, they are preloaded into the memory\n# when the evoked object is constructed. You can access the data as a numpy\n# array.\ndata = evoked.data\nprint(data.shape)\n\n###############################################################################\n# The data is arranged in an array of shape `(n_channels, n_times)`. Notice\n# that unlike epochs, evoked object does not support indexing. This means that\n# to access the data of a specific channel you must use the data array\n# directly.\nprint('Data from channel {0}:'.format(evoked.ch_names[10]))\nprint(data[10])\n\n###############################################################################\n# In the same vein, we can quickly extract (and, e.g., plot) the GFP as the\n# standard deviation across channels, here shown just for EEG.\n\ngfp = evoked.copy().pick_types(eeg=True, meg=False).data.std(axis=0)\nfig, ax = plt.subplots(1)\nax.plot(evoked.times, gfp / 1e6)  # scale to uV\nax.set(xlabel='Time (sec)', ylabel='GFP (uV)')\nfig.tight_layout()\n\n###############################################################################\n# If you want to import evoked data from some other system and you have it in a\n# numpy array you can use :class:`mne.EvokedArray` for that. All you need is\n# the data and some info about the evoked data. For more information, see\n# :ref:`tut_creating_data_structures`.\nevoked = mne.EvokedArray(data, evoked.info, tmin=evoked.times[0])\nevoked.plot(time_unit='s')\n\n###############################################################################\n# To write an evoked dataset to a file, use the :meth:`mne.Evoked.save` method.\n# To save multiple categories to a single file, see :func:`mne.write_evokeds`.\n", "path": "tutorials/plot_object_evoked.py"}]}