prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  sklearn.covariance.LedoitWolf or ConnectivityMeasure in plot_adhd_spheres
  `ConnectivityMeasure` can be used here, and its default covariance estimator is `LedoitWolf`from `sklearn.covariance`.
  I also prefer using partial correlations rather than precision, because no need for negating the connections.
  
  
  --- 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/03_connectivity/plot_adhd_spheres.py`
  Content:
  ```
  1 """
  2 Extracting brain signal from spheres
  3 ====================================
  4 
  5 This example extract brain signals from spheres described by the coordinates
  6 of their center in MNI space and a given radius in millimeters. In particular,
  7 this example extracts signals from Default Mode Network regions and compute a
  8 connectome from them.
  9 
  10 """
  11 
  12 ##########################################################################
  13 # Retrieve the dataset
  14 from nilearn import datasets
  15 adhd_dataset = datasets.fetch_adhd(n_subjects=1)
  16 
  17 # print basic information on the dataset
  18 print('First subject functional nifti image (4D) is at: %s' %
  19       adhd_dataset.func[0])  # 4D data
  20 
  21 
  22 ##########################################################################
  23 # Coordinates of Default Mode Network
  24 dmn_coords = [(0, -52, 18), (-46, -68, 32), (46, -68, 32), (1, 50, -5)]
  25 labels = [
  26     'Posterior Cingulate Cortex',
  27     'Left Temporoparietal junction',
  28     'Right Temporoparietal junction',
  29     'Medial prefrontal cortex'
  30 ]
  31 
  32 
  33 ##########################################################################
  34 # Extracts signal from sphere around DMN seeds
  35 from nilearn import input_data
  36 
  37 masker = input_data.NiftiSpheresMasker(
  38     dmn_coords, radius=8,
  39     detrend=True, standardize=True,
  40     low_pass=0.1, high_pass=0.01, t_r=2.5,
  41     memory='nilearn_cache', memory_level=1, verbose=2)
  42 
  43 func_filename = adhd_dataset.func[0]
  44 confound_filename = adhd_dataset.confounds[0]
  45 
  46 time_series = masker.fit_transform(func_filename,
  47                                    confounds=[confound_filename])
  48 
  49 ##########################################################################
  50 # Display time series
  51 import matplotlib.pyplot as plt
  52 for time_serie, label in zip(time_series.T, labels):
  53     plt.plot(time_serie, label=label)
  54 
  55 plt.title('Default Mode Network Time Series')
  56 plt.xlabel('Scan number')
  57 plt.ylabel('Normalized signal')
  58 plt.legend()
  59 plt.tight_layout()
  60 
  61 
  62 ##########################################################################
  63 # Compute precision matrices
  64 from sklearn.covariance import LedoitWolf
  65 cve = LedoitWolf()
  66 cve.fit(time_series)
  67 
  68 
  69 ##########################################################################
  70 # Display connectome
  71 from nilearn import plotting
  72 
  73 plotting.plot_connectome(cve.precision_, dmn_coords,
  74                          title="Default Mode Network Connectivity")
  75 
  76 # Display connectome with hemispheric projections.
  77 # Notice (0, -52, 18) is included in both hemispheres since x == 0.
  78 title = "Connectivity projected on hemispheres"
  79 plotting.plot_connectome(cve.precision_, dmn_coords, title=title,
  80                          display_mode='lyrz')
  81 
  82 plotting.show()
  83
  ```
  --- 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/examples/03_connectivity/plot_adhd_spheres.py b/examples/03_connectivity/plot_adhd_spheres.py
  --- a/examples/03_connectivity/plot_adhd_spheres.py
  +++ b/examples/03_connectivity/plot_adhd_spheres.py
  @@ -60,23 +60,25 @@
   
   
   ##########################################################################
  -# Compute precision matrices
  -from sklearn.covariance import LedoitWolf
  -cve = LedoitWolf()
  -cve.fit(time_series)
  -
  +# Compute partial correlation matrix using object
  +# :class:`nilearn.connectome.ConnectivityMeasure`: Its default covariance
  +# estimator is Ledoit-Wolf, allowing to obtain accurate partial correlations.
  +from nilearn.connectome import ConnectivityMeasure
  +connectivity_measure = ConnectivityMeasure(kind='partial correlation')
  +partial_correlation_matrix = connectivity_measure.fit_transform(
  +    [time_series])[0]
   
   ##########################################################################
   # Display connectome
   from nilearn import plotting
   
  -plotting.plot_connectome(cve.precision_, dmn_coords,
  +plotting.plot_connectome(partial_correlation_matrix, dmn_coords,
                            title="Default Mode Network Connectivity")
   
   # Display connectome with hemispheric projections.
   # Notice (0, -52, 18) is included in both hemispheres since x == 0.
   title = "Connectivity projected on hemispheres"
  -plotting.plot_connectome(cve.precision_, dmn_coords, title=title,
  +plotting.plot_connectome(partial_correlation_matrix, dmn_coords, title=title,
                            display_mode='lyrz')
   
   plotting.show()
  
verification_info: {"golden_diff": "diff --git a/examples/03_connectivity/plot_adhd_spheres.py b/examples/03_connectivity/plot_adhd_spheres.py\n--- a/examples/03_connectivity/plot_adhd_spheres.py\n+++ b/examples/03_connectivity/plot_adhd_spheres.py\n@@ -60,23 +60,25 @@\n \n \n ##########################################################################\n-# Compute precision matrices\n-from sklearn.covariance import LedoitWolf\n-cve = LedoitWolf()\n-cve.fit(time_series)\n-\n+# Compute partial correlation matrix using object\n+# :class:`nilearn.connectome.ConnectivityMeasure`: Its default covariance\n+# estimator is Ledoit-Wolf, allowing to obtain accurate partial correlations.\n+from nilearn.connectome import ConnectivityMeasure\n+connectivity_measure = ConnectivityMeasure(kind='partial correlation')\n+partial_correlation_matrix = connectivity_measure.fit_transform(\n+    [time_series])[0]\n \n ##########################################################################\n # Display connectome\n from nilearn import plotting\n \n-plotting.plot_connectome(cve.precision_, dmn_coords,\n+plotting.plot_connectome(partial_correlation_matrix, dmn_coords,\n                          title=\"Default Mode Network Connectivity\")\n \n # Display connectome with hemispheric projections.\n # Notice (0, -52, 18) is included in both hemispheres since x == 0.\n title = \"Connectivity projected on hemispheres\"\n-plotting.plot_connectome(cve.precision_, dmn_coords, title=title,\n+plotting.plot_connectome(partial_correlation_matrix, dmn_coords, title=title,\n                          display_mode='lyrz')\n \n plotting.show()\n", "issue": "sklearn.covariance.LedoitWolf or ConnectivityMeasure in plot_adhd_spheres\n`ConnectivityMeasure` can be used here, and its default covariance estimator is `LedoitWolf`from `sklearn.covariance`.\nI also prefer using partial correlations rather than precision, because no need for negating the connections.\n\n", "before_files": [{"content": "\"\"\"\nExtracting brain signal from spheres\n====================================\n\nThis example extract brain signals from spheres described by the coordinates\nof their center in MNI space and a given radius in millimeters. In particular,\nthis example extracts signals from Default Mode Network regions and compute a\nconnectome from them.\n\n\"\"\"\n\n##########################################################################\n# Retrieve the dataset\nfrom nilearn import datasets\nadhd_dataset = datasets.fetch_adhd(n_subjects=1)\n\n# print basic information on the dataset\nprint('First subject functional nifti image (4D) is at: %s' %\n      adhd_dataset.func[0])  # 4D data\n\n\n##########################################################################\n# Coordinates of Default Mode Network\ndmn_coords = [(0, -52, 18), (-46, -68, 32), (46, -68, 32), (1, 50, -5)]\nlabels = [\n    'Posterior Cingulate Cortex',\n    'Left Temporoparietal junction',\n    'Right Temporoparietal junction',\n    'Medial prefrontal cortex'\n]\n\n\n##########################################################################\n# Extracts signal from sphere around DMN seeds\nfrom nilearn import input_data\n\nmasker = input_data.NiftiSpheresMasker(\n    dmn_coords, radius=8,\n    detrend=True, standardize=True,\n    low_pass=0.1, high_pass=0.01, t_r=2.5,\n    memory='nilearn_cache', memory_level=1, verbose=2)\n\nfunc_filename = adhd_dataset.func[0]\nconfound_filename = adhd_dataset.confounds[0]\n\ntime_series = masker.fit_transform(func_filename,\n                                   confounds=[confound_filename])\n\n##########################################################################\n# Display time series\nimport matplotlib.pyplot as plt\nfor time_serie, label in zip(time_series.T, labels):\n    plt.plot(time_serie, label=label)\n\nplt.title('Default Mode Network Time Series')\nplt.xlabel('Scan number')\nplt.ylabel('Normalized signal')\nplt.legend()\nplt.tight_layout()\n\n\n##########################################################################\n# Compute precision matrices\nfrom sklearn.covariance import LedoitWolf\ncve = LedoitWolf()\ncve.fit(time_series)\n\n\n##########################################################################\n# Display connectome\nfrom nilearn import plotting\n\nplotting.plot_connectome(cve.precision_, dmn_coords,\n                         title=\"Default Mode Network Connectivity\")\n\n# Display connectome with hemispheric projections.\n# Notice (0, -52, 18) is included in both hemispheres since x == 0.\ntitle = \"Connectivity projected on hemispheres\"\nplotting.plot_connectome(cve.precision_, dmn_coords, title=title,\n                         display_mode='lyrz')\n\nplotting.show()\n", "path": "examples/03_connectivity/plot_adhd_spheres.py"}], "after_files": [{"content": "\"\"\"\nExtracting brain signal from spheres\n====================================\n\nThis example extract brain signals from spheres described by the coordinates\nof their center in MNI space and a given radius in millimeters. In particular,\nthis example extracts signals from Default Mode Network regions and compute a\nconnectome from them.\n\n\"\"\"\n\n##########################################################################\n# Retrieve the dataset\nfrom nilearn import datasets\nadhd_dataset = datasets.fetch_adhd(n_subjects=1)\n\n# print basic information on the dataset\nprint('First subject functional nifti image (4D) is at: %s' %\n      adhd_dataset.func[0])  # 4D data\n\n\n##########################################################################\n# Coordinates of Default Mode Network\ndmn_coords = [(0, -52, 18), (-46, -68, 32), (46, -68, 32), (1, 50, -5)]\nlabels = [\n    'Posterior Cingulate Cortex',\n    'Left Temporoparietal junction',\n    'Right Temporoparietal junction',\n    'Medial prefrontal cortex'\n]\n\n\n##########################################################################\n# Extracts signal from sphere around DMN seeds\nfrom nilearn import input_data\n\nmasker = input_data.NiftiSpheresMasker(\n    dmn_coords, radius=8,\n    detrend=True, standardize=True,\n    low_pass=0.1, high_pass=0.01, t_r=2.5,\n    memory='nilearn_cache', memory_level=1, verbose=2)\n\nfunc_filename = adhd_dataset.func[0]\nconfound_filename = adhd_dataset.confounds[0]\n\ntime_series = masker.fit_transform(func_filename,\n                                   confounds=[confound_filename])\n\n##########################################################################\n# Display time series\nimport matplotlib.pyplot as plt\nfor time_serie, label in zip(time_series.T, labels):\n    plt.plot(time_serie, label=label)\n\nplt.title('Default Mode Network Time Series')\nplt.xlabel('Scan number')\nplt.ylabel('Normalized signal')\nplt.legend()\nplt.tight_layout()\n\n\n##########################################################################\n# Compute partial correlation matrix using object\n# :class:`nilearn.connectome.ConnectivityMeasure`: Its default covariance\n# estimator is Ledoit-Wolf, allowing to obtain accurate partial correlations.\nfrom nilearn.connectome import ConnectivityMeasure\nconnectivity_measure = ConnectivityMeasure(kind='partial correlation')\npartial_correlation_matrix = connectivity_measure.fit_transform(\n    [time_series])[0]\n\n##########################################################################\n# Display connectome\nfrom nilearn import plotting\n\nplotting.plot_connectome(partial_correlation_matrix, dmn_coords,\n                         title=\"Default Mode Network Connectivity\")\n\n# Display connectome with hemispheric projections.\n# Notice (0, -52, 18) is included in both hemispheres since x == 0.\ntitle = \"Connectivity projected on hemispheres\"\nplotting.plot_connectome(partial_correlation_matrix, dmn_coords, title=title,\n                         display_mode='lyrz')\n\nplotting.show()\n", "path": "examples/03_connectivity/plot_adhd_spheres.py"}]}