We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
doc build fails because of mne (main)
> ImportError: cannot import name 'psd_welch' from 'mne.time_frequency' (/home/circleci/mne_bids_env/lib/python3.9/site-packages/mne/time_frequency/__init__.py)


https://app.circleci.com/pipelines/github/mne-tools/mne-bids/4820/workflows/813d1bc7-3b45-463b-af0e-3d5ddab39dc7/jobs/6961

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `examples/convert_nirs_to_bids.py`
Content:
```
1 """
2 ====================================
3 13. Convert NIRS data to BIDS format
4 ====================================
5 
6 In this example, we use MNE-BIDS to create a BIDS-compatible directory of NIRS
7 data. Specifically, we will follow these steps:
8 
9 1. Download some NIRS data
10 
11 2. Load the data, extract information, and save it in a new BIDS directory.
12 
13 3. Check the result and compare it with the standard.
14 
15 4. Cite ``mne-bids``.
16 
17 .. currentmodule:: mne_bids
18 
19 """  # noqa: E501
20 
21 # Authors: Robert Luke <code@robertluke.net>
22 #
23 # License: BSD-3-Clause
24 
25 # %%
26 # We are importing everything we need for this example:
27 import os.path as op
28 import pathlib
29 import shutil
30 
31 import mne
32 import mne_nirs  # For convenient downloading of example data
33 
34 from mne_bids import write_raw_bids, BIDSPath, print_dir_tree
35 from mne_bids.stats import count_events
36 
37 # %%
38 # Download the data
39 # -----------------
40 #
41 # First, we need some data to work with. We will use the
42 # `Finger Tapping Dataset <https://github.com/rob-luke/BIDS-NIRS-Tapping>`_
43 # available on GitHub.
44 # We will use the MNE-NIRS package which includes convenient functions to
45 # download openly available datasets.
46 
47 data_dir = pathlib.Path(mne_nirs.datasets.fnirs_motor_group.data_path())
48 
49 # Let's see whether the data has been downloaded using a quick visualization
50 # of the directory tree.
51 print_dir_tree(data_dir)
52 
53 # %%
54 # The data are already in BIDS format. However, we will just use one of the
55 # SNIRF files and demonstrate how this could be used to generate a new BIDS
56 # compliant dataset from this single file.
57 
58 # Specify file to use as input to BIDS generation process
59 file_path = data_dir / "sub-01" / "nirs" / "sub-01_task-tapping_nirs.snirf"
60 
61 # %%
62 # Convert to BIDS
63 # ---------------
64 #
65 # Let's start with loading the data and updating the annotations.
66 # We are reading the data using MNE-Python's ``io`` module and the
67 # :func:`mne.io.read_raw_snirf` function.
68 # Note that we must use the ``preload=False`` parameter, which is the default
69 # in MNE-Python.
70 # It prevents the data from being loaded and modified when converting to BIDS.
71 
72 # Load the data
73 raw = mne.io.read_raw_snirf(file_path, preload=False)
74 raw.info['line_freq'] = 50  # specify power line frequency as required by BIDS
75 
76 # Sanity check, show the optode positions
77 raw.plot_sensors()
78 
79 # %%
80 # I also like to rename the annotations to something meaningful and
81 # set the duration of each stimulus
82 
83 trigger_info = {'1.0': 'Control',
84                 '2.0': 'Tapping/Left',
85                 '3.0': 'Tapping/Right'}
86 raw.annotations.rename(trigger_info)
87 raw.annotations.set_durations(5.0)
88 
89 
90 # %%
91 # With these steps, we have everything to start a new BIDS directory using
92 # our data.
93 #
94 # To do that, we can use :func:`write_raw_bids`
95 #
96 # Generally, :func:`write_raw_bids` tries to extract as much
97 # meta data as possible from the raw data and then formats it in a BIDS
98 # compatible way. :func:`write_raw_bids` takes a bunch of inputs, most of
99 # which are however optional. The required inputs are:
100 #
101 # * :code:`raw`
102 # * :code:`bids_basename`
103 # * :code:`bids_root`
104 #
105 # ... as you can see in the docstring:
106 print(write_raw_bids.__doc__)
107 
108 # zero padding to account for >100 subjects in this dataset
109 subject_id = '01'
110 
111 # define a task name and a directory where to save the data to
112 task = 'Tapping'
113 bids_root = data_dir.with_name(data_dir.name + '-bids')
114 print(bids_root)
115 
116 # %%
117 # To ensure the output path doesn't contain any leftover files from previous
118 # tests and example runs, we simply delete it.
119 #
120 # .. warning:: Do not delete directories that may contain important data!
121 #
122 
123 if op.exists(bids_root):
124     shutil.rmtree(bids_root)
125 
126 # %%
127 # The data contains annotations; which will be converted to events
128 # automatically by MNE-BIDS when writing the BIDS data:
129 
130 print(raw.annotations)
131 
132 # %%
133 # Finally, let's write the BIDS data!
134 
135 bids_path = BIDSPath(subject=subject_id, task=task, root=bids_root)
136 write_raw_bids(raw, bids_path, overwrite=True)
137 
138 # %%
139 # What does our fresh BIDS directory look like?
140 print_dir_tree(bids_root)
141 
142 # %%
143 # Finally let's get an overview of the events on the whole dataset
144 
145 counts = count_events(bids_root)
146 counts
147 
148 # %%
149 # We can see that MNE-BIDS wrote several important files related to subject 1
150 # for us:
151 #
152 # * ``optodes.tsv`` containing the optode coordinates and
153 #   ``coordsystem.json``, which contains the metadata about the optode
154 #   coordinates.
155 # * The actual SNIRF data file (with a proper BIDS name) and an accompanying
156 #   ``*_nirs.json`` file that contains metadata about the NIRS recording.
157 # * The ``*scans.json`` file lists all data recordings with their acquisition
158 #   date. This file becomes more handy once there are multiple sessions and
159 #   recordings to keep track of.
160 # * And finally, ``channels.tsv`` and ``events.tsv`` which contain even further
161 #   metadata.
162 #
163 # Next to the subject specific files, MNE-BIDS also created several experiment
164 # specific files. However, we will not go into detail for them in this example.
165 #
166 # Cite mne-bids
167 # -------------
168 # After a lot of work was done by MNE-BIDS, it's fair to cite the software
169 # when preparing a manuscript and/or a dataset publication.
170 #
171 # We can see that the appropriate citations are already written in the
172 # ``README`` file.
173 #
174 # If you are preparing a manuscript, please make sure to also cite MNE-BIDS
175 # there.
176 readme = op.join(bids_root, 'README')
177 with open(readme, 'r', encoding='utf-8-sig') as fid:
178     text = fid.read()
179 print(text)
180 
181 
182 # %%
183 # Now it's time to manually check the BIDS directory and the meta files to add
184 # all the information that MNE-BIDS could not infer. For instance, you must
185 # describe Authors.
186 #
187 # Remember that there is a convenient javascript tool to validate all your BIDS
188 # directories called the "BIDS-validator", available as a web version and a
189 # command line tool:
190 #
191 # Web version: https://bids-standard.github.io/bids-validator/
192 #
193 # Command line tool: https://www.npmjs.com/package/bids-validator
194
```
--- 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()

```

diff --git a/examples/convert_nirs_to_bids.py b/examples/convert_nirs_to_bids.py
--- a/examples/convert_nirs_to_bids.py
+++ b/examples/convert_nirs_to_bids.py
@@ -29,7 +29,7 @@
 import shutil
 
 import mne
-import mne_nirs  # For convenient downloading of example data
+from mne_nirs import datasets  # For convenient downloading of example data
 
 from mne_bids import write_raw_bids, BIDSPath, print_dir_tree
 from mne_bids.stats import count_events
@@ -44,7 +44,7 @@
 # We will use the MNE-NIRS package which includes convenient functions to
 # download openly available datasets.
 
-data_dir = pathlib.Path(mne_nirs.datasets.fnirs_motor_group.data_path())
+data_dir = pathlib.Path(datasets.fnirs_motor_group.data_path())
 
 # Let's see whether the data has been downloaded using a quick visualization
 # of the directory tree.

{"golden_diff": "diff --git a/examples/convert_nirs_to_bids.py b/examples/convert_nirs_to_bids.py\n--- a/examples/convert_nirs_to_bids.py\n+++ b/examples/convert_nirs_to_bids.py\n@@ -29,7 +29,7 @@\n import shutil\n \n import mne\n-import mne_nirs  # For convenient downloading of example data\n+from mne_nirs import datasets  # For convenient downloading of example data\n \n from mne_bids import write_raw_bids, BIDSPath, print_dir_tree\n from mne_bids.stats import count_events\n@@ -44,7 +44,7 @@\n # We will use the MNE-NIRS package which includes convenient functions to\n # download openly available datasets.\n \n-data_dir = pathlib.Path(mne_nirs.datasets.fnirs_motor_group.data_path())\n+data_dir = pathlib.Path(datasets.fnirs_motor_group.data_path())\n \n # Let's see whether the data has been downloaded using a quick visualization\n # of the directory tree.\n", "issue": "doc build fails because of mne (main)\n> ImportError: cannot import name 'psd_welch' from 'mne.time_frequency' (/home/circleci/mne_bids_env/lib/python3.9/site-packages/mne/time_frequency/__init__.py)\r\n\r\n\r\nhttps://app.circleci.com/pipelines/github/mne-tools/mne-bids/4820/workflows/813d1bc7-3b45-463b-af0e-3d5ddab39dc7/jobs/6961\n", "before_files": [{"content": "\"\"\"\n====================================\n13. Convert NIRS data to BIDS format\n====================================\n\nIn this example, we use MNE-BIDS to create a BIDS-compatible directory of NIRS\ndata. Specifically, we will follow these steps:\n\n1. Download some NIRS data\n\n2. Load the data, extract information, and save it in a new BIDS directory.\n\n3. Check the result and compare it with the standard.\n\n4. Cite ``mne-bids``.\n\n.. currentmodule:: mne_bids\n\n\"\"\"  # noqa: E501\n\n# Authors: Robert Luke <code@robertluke.net>\n#\n# License: BSD-3-Clause\n\n# %%\n# We are importing everything we need for this example:\nimport os.path as op\nimport pathlib\nimport shutil\n\nimport mne\nimport mne_nirs  # For convenient downloading of example data\n\nfrom mne_bids import write_raw_bids, BIDSPath, print_dir_tree\nfrom mne_bids.stats import count_events\n\n# %%\n# Download the data\n# -----------------\n#\n# First, we need some data to work with. We will use the\n# `Finger Tapping Dataset <https://github.com/rob-luke/BIDS-NIRS-Tapping>`_\n# available on GitHub.\n# We will use the MNE-NIRS package which includes convenient functions to\n# download openly available datasets.\n\ndata_dir = pathlib.Path(mne_nirs.datasets.fnirs_motor_group.data_path())\n\n# Let's see whether the data has been downloaded using a quick visualization\n# of the directory tree.\nprint_dir_tree(data_dir)\n\n# %%\n# The data are already in BIDS format. However, we will just use one of the\n# SNIRF files and demonstrate how this could be used to generate a new BIDS\n# compliant dataset from this single file.\n\n# Specify file to use as input to BIDS generation process\nfile_path = data_dir / \"sub-01\" / \"nirs\" / \"sub-01_task-tapping_nirs.snirf\"\n\n# %%\n# Convert to BIDS\n# ---------------\n#\n# Let's start with loading the data and updating the annotations.\n# We are reading the data using MNE-Python's ``io`` module and the\n# :func:`mne.io.read_raw_snirf` function.\n# Note that we must use the ``preload=False`` parameter, which is the default\n# in MNE-Python.\n# It prevents the data from being loaded and modified when converting to BIDS.\n\n# Load the data\nraw = mne.io.read_raw_snirf(file_path, preload=False)\nraw.info['line_freq'] = 50  # specify power line frequency as required by BIDS\n\n# Sanity check, show the optode positions\nraw.plot_sensors()\n\n# %%\n# I also like to rename the annotations to something meaningful and\n# set the duration of each stimulus\n\ntrigger_info = {'1.0': 'Control',\n                '2.0': 'Tapping/Left',\n                '3.0': 'Tapping/Right'}\nraw.annotations.rename(trigger_info)\nraw.annotations.set_durations(5.0)\n\n\n# %%\n# With these steps, we have everything to start a new BIDS directory using\n# our data.\n#\n# To do that, we can use :func:`write_raw_bids`\n#\n# Generally, :func:`write_raw_bids` tries to extract as much\n# meta data as possible from the raw data and then formats it in a BIDS\n# compatible way. :func:`write_raw_bids` takes a bunch of inputs, most of\n# which are however optional. The required inputs are:\n#\n# * :code:`raw`\n# * :code:`bids_basename`\n# * :code:`bids_root`\n#\n# ... as you can see in the docstring:\nprint(write_raw_bids.__doc__)\n\n# zero padding to account for >100 subjects in this dataset\nsubject_id = '01'\n\n# define a task name and a directory where to save the data to\ntask = 'Tapping'\nbids_root = data_dir.with_name(data_dir.name + '-bids')\nprint(bids_root)\n\n# %%\n# To ensure the output path doesn't contain any leftover files from previous\n# tests and example runs, we simply delete it.\n#\n# .. warning:: Do not delete directories that may contain important data!\n#\n\nif op.exists(bids_root):\n    shutil.rmtree(bids_root)\n\n# %%\n# The data contains annotations; which will be converted to events\n# automatically by MNE-BIDS when writing the BIDS data:\n\nprint(raw.annotations)\n\n# %%\n# Finally, let's write the BIDS data!\n\nbids_path = BIDSPath(subject=subject_id, task=task, root=bids_root)\nwrite_raw_bids(raw, bids_path, overwrite=True)\n\n# %%\n# What does our fresh BIDS directory look like?\nprint_dir_tree(bids_root)\n\n# %%\n# Finally let's get an overview of the events on the whole dataset\n\ncounts = count_events(bids_root)\ncounts\n\n# %%\n# We can see that MNE-BIDS wrote several important files related to subject 1\n# for us:\n#\n# * ``optodes.tsv`` containing the optode coordinates and\n#   ``coordsystem.json``, which contains the metadata about the optode\n#   coordinates.\n# * The actual SNIRF data file (with a proper BIDS name) and an accompanying\n#   ``*_nirs.json`` file that contains metadata about the NIRS recording.\n# * The ``*scans.json`` file lists all data recordings with their acquisition\n#   date. This file becomes more handy once there are multiple sessions and\n#   recordings to keep track of.\n# * And finally, ``channels.tsv`` and ``events.tsv`` which contain even further\n#   metadata.\n#\n# Next to the subject specific files, MNE-BIDS also created several experiment\n# specific files. However, we will not go into detail for them in this example.\n#\n# Cite mne-bids\n# -------------\n# After a lot of work was done by MNE-BIDS, it's fair to cite the software\n# when preparing a manuscript and/or a dataset publication.\n#\n# We can see that the appropriate citations are already written in the\n# ``README`` file.\n#\n# If you are preparing a manuscript, please make sure to also cite MNE-BIDS\n# there.\nreadme = op.join(bids_root, 'README')\nwith open(readme, 'r', encoding='utf-8-sig') as fid:\n    text = fid.read()\nprint(text)\n\n\n# %%\n# Now it's time to manually check the BIDS directory and the meta files to add\n# all the information that MNE-BIDS could not infer. For instance, you must\n# describe Authors.\n#\n# Remember that there is a convenient javascript tool to validate all your BIDS\n# directories called the \"BIDS-validator\", available as a web version and a\n# command line tool:\n#\n# Web version: https://bids-standard.github.io/bids-validator/\n#\n# Command line tool: https://www.npmjs.com/package/bids-validator\n", "path": "examples/convert_nirs_to_bids.py"}], "after_files": [{"content": "\"\"\"\n====================================\n13. Convert NIRS data to BIDS format\n====================================\n\nIn this example, we use MNE-BIDS to create a BIDS-compatible directory of NIRS\ndata. Specifically, we will follow these steps:\n\n1. Download some NIRS data\n\n2. Load the data, extract information, and save it in a new BIDS directory.\n\n3. Check the result and compare it with the standard.\n\n4. Cite ``mne-bids``.\n\n.. currentmodule:: mne_bids\n\n\"\"\"  # noqa: E501\n\n# Authors: Robert Luke <code@robertluke.net>\n#\n# License: BSD-3-Clause\n\n# %%\n# We are importing everything we need for this example:\nimport os.path as op\nimport pathlib\nimport shutil\n\nimport mne\nfrom mne_nirs import datasets  # For convenient downloading of example data\n\nfrom mne_bids import write_raw_bids, BIDSPath, print_dir_tree\nfrom mne_bids.stats import count_events\n\n# %%\n# Download the data\n# -----------------\n#\n# First, we need some data to work with. We will use the\n# `Finger Tapping Dataset <https://github.com/rob-luke/BIDS-NIRS-Tapping>`_\n# available on GitHub.\n# We will use the MNE-NIRS package which includes convenient functions to\n# download openly available datasets.\n\ndata_dir = pathlib.Path(datasets.fnirs_motor_group.data_path())\n\n# Let's see whether the data has been downloaded using a quick visualization\n# of the directory tree.\nprint_dir_tree(data_dir)\n\n# %%\n# The data are already in BIDS format. However, we will just use one of the\n# SNIRF files and demonstrate how this could be used to generate a new BIDS\n# compliant dataset from this single file.\n\n# Specify file to use as input to BIDS generation process\nfile_path = data_dir / \"sub-01\" / \"nirs\" / \"sub-01_task-tapping_nirs.snirf\"\n\n# %%\n# Convert to BIDS\n# ---------------\n#\n# Let's start with loading the data and updating the annotations.\n# We are reading the data using MNE-Python's ``io`` module and the\n# :func:`mne.io.read_raw_snirf` function.\n# Note that we must use the ``preload=False`` parameter, which is the default\n# in MNE-Python.\n# It prevents the data from being loaded and modified when converting to BIDS.\n\n# Load the data\nraw = mne.io.read_raw_snirf(file_path, preload=False)\nraw.info['line_freq'] = 50  # specify power line frequency as required by BIDS\n\n# Sanity check, show the optode positions\nraw.plot_sensors()\n\n# %%\n# I also like to rename the annotations to something meaningful and\n# set the duration of each stimulus\n\ntrigger_info = {'1.0': 'Control',\n                '2.0': 'Tapping/Left',\n                '3.0': 'Tapping/Right'}\nraw.annotations.rename(trigger_info)\nraw.annotations.set_durations(5.0)\n\n\n# %%\n# With these steps, we have everything to start a new BIDS directory using\n# our data.\n#\n# To do that, we can use :func:`write_raw_bids`\n#\n# Generally, :func:`write_raw_bids` tries to extract as much\n# meta data as possible from the raw data and then formats it in a BIDS\n# compatible way. :func:`write_raw_bids` takes a bunch of inputs, most of\n# which are however optional. The required inputs are:\n#\n# * :code:`raw`\n# * :code:`bids_basename`\n# * :code:`bids_root`\n#\n# ... as you can see in the docstring:\nprint(write_raw_bids.__doc__)\n\n# zero padding to account for >100 subjects in this dataset\nsubject_id = '01'\n\n# define a task name and a directory where to save the data to\ntask = 'Tapping'\nbids_root = data_dir.with_name(data_dir.name + '-bids')\nprint(bids_root)\n\n# %%\n# To ensure the output path doesn't contain any leftover files from previous\n# tests and example runs, we simply delete it.\n#\n# .. warning:: Do not delete directories that may contain important data!\n#\n\nif op.exists(bids_root):\n    shutil.rmtree(bids_root)\n\n# %%\n# The data contains annotations; which will be converted to events\n# automatically by MNE-BIDS when writing the BIDS data:\n\nprint(raw.annotations)\n\n# %%\n# Finally, let's write the BIDS data!\n\nbids_path = BIDSPath(subject=subject_id, task=task, root=bids_root)\nwrite_raw_bids(raw, bids_path, overwrite=True)\n\n# %%\n# What does our fresh BIDS directory look like?\nprint_dir_tree(bids_root)\n\n# %%\n# Finally let's get an overview of the events on the whole dataset\n\ncounts = count_events(bids_root)\ncounts\n\n# %%\n# We can see that MNE-BIDS wrote several important files related to subject 1\n# for us:\n#\n# * ``optodes.tsv`` containing the optode coordinates and\n#   ``coordsystem.json``, which contains the metadata about the optode\n#   coordinates.\n# * The actual SNIRF data file (with a proper BIDS name) and an accompanying\n#   ``*_nirs.json`` file that contains metadata about the NIRS recording.\n# * The ``*scans.json`` file lists all data recordings with their acquisition\n#   date. This file becomes more handy once there are multiple sessions and\n#   recordings to keep track of.\n# * And finally, ``channels.tsv`` and ``events.tsv`` which contain even further\n#   metadata.\n#\n# Next to the subject specific files, MNE-BIDS also created several experiment\n# specific files. However, we will not go into detail for them in this example.\n#\n# Cite mne-bids\n# -------------\n# After a lot of work was done by MNE-BIDS, it's fair to cite the software\n# when preparing a manuscript and/or a dataset publication.\n#\n# We can see that the appropriate citations are already written in the\n# ``README`` file.\n#\n# If you are preparing a manuscript, please make sure to also cite MNE-BIDS\n# there.\nreadme = op.join(bids_root, 'README')\nwith open(readme, 'r', encoding='utf-8-sig') as fid:\n    text = fid.read()\nprint(text)\n\n\n# %%\n# Now it's time to manually check the BIDS directory and the meta files to add\n# all the information that MNE-BIDS could not infer. For instance, you must\n# describe Authors.\n#\n# Remember that there is a convenient javascript tool to validate all your BIDS\n# directories called the \"BIDS-validator\", available as a web version and a\n# command line tool:\n#\n# Web version: https://bids-standard.github.io/bids-validator/\n#\n# Command line tool: https://www.npmjs.com/package/bids-validator\n", "path": "examples/convert_nirs_to_bids.py"}]}