prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [DOC] improve instructions in "Default Mode Network extraction of ADHD dataset" example
  ### Is there an existing issue for this?
  
  - [X] I have searched the existing issues
  
  ### Describe your proposed suggestion in detail.
  
  It seems the instructions in [this example](https://nilearn.github.io/dev/auto_examples/04_glm_first_level/plot_adhd_dmn.html#default-mode-network-extraction-of-adhd-dataset) need some improvement. There was a confusion mentioned on [NeuroStar](https://neurostars.org/t/why-is-there-glm-for-resting-state-data/25841). After discussing with @Remi-Gau, we concluded that maybe we can add one or two lines saying that in this example we extract the activity of a seed region and then use the extracted signal as regressor in a GLM and this will yield the correlation of each region with the seed region.
  
  ### List any pages that would be impacted.
  
  https://nilearn.github.io/dev/auto_examples/04_glm_first_level/plot_adhd_dmn.html#default-mode-network-extraction-of-adhd-dataset
  
  </issue>
  <code>
  [start of examples/04_glm_first_level/plot_adhd_dmn.py]
  1 """
  2 Default Mode Network extraction of ADHD dataset
  3 ===============================================
  4 
  5 This example shows a full step-by-step workflow of fitting a GLM to data
  6 extracted from a seed on the Posterior Cingulate Cortex and saving the results.
  7 
  8 More specifically:
  9 
  10 1. A sequence of fMRI volumes are loaded.
  11 2. A design matrix with the Posterior Cingulate Cortex seed is defined.
  12 3. A GLM is applied to the dataset (effect/covariance,
  13    then contrast estimation).
  14 4. The Default Mode Network is displayed.
  15 
  16 .. include:: ../../../examples/masker_note.rst
  17 
  18 """
  19 import numpy as np
  20 from nilearn import datasets, plotting
  21 from nilearn.glm.first_level import (
  22     FirstLevelModel,
  23     make_first_level_design_matrix,
  24 )
  25 from nilearn.maskers import NiftiSpheresMasker
  26 
  27 #########################################################################
  28 # Prepare data and analysis parameters
  29 # ------------------------------------
  30 # Prepare the data.
  31 adhd_dataset = datasets.fetch_adhd(n_subjects=1)
  32 
  33 # Prepare timing
  34 t_r = 2.0
  35 slice_time_ref = 0.0
  36 n_scans = 176
  37 
  38 # Prepare seed
  39 pcc_coords = (0, -53, 26)
  40 
  41 #########################################################################
  42 # Estimate contrasts
  43 # ------------------
  44 # Specify the contrasts.
  45 seed_masker = NiftiSpheresMasker(
  46     [pcc_coords],
  47     radius=10,
  48     detrend=True,
  49     standardize="zscore_sample",
  50     low_pass=0.1,
  51     high_pass=0.01,
  52     t_r=2.0,
  53     memory="nilearn_cache",
  54     memory_level=1,
  55     verbose=0,
  56 )
  57 seed_time_series = seed_masker.fit_transform(adhd_dataset.func[0])
  58 frametimes = np.linspace(0, (n_scans - 1) * t_r, n_scans)
  59 design_matrix = make_first_level_design_matrix(
  60     frametimes,
  61     hrf_model="spm",
  62     add_regs=seed_time_series,
  63     add_reg_names=["pcc_seed"],
  64 )
  65 dmn_contrast = np.array([1] + [0] * (design_matrix.shape[1] - 1))
  66 contrasts = {"seed_based_glm": dmn_contrast}
  67 
  68 #########################################################################
  69 # Perform first level analysis
  70 # ----------------------------
  71 # Setup and fit GLM.
  72 first_level_model = FirstLevelModel(t_r=t_r, slice_time_ref=slice_time_ref)
  73 first_level_model = first_level_model.fit(
  74     run_imgs=adhd_dataset.func[0], design_matrices=design_matrix
  75 )
  76 
  77 #########################################################################
  78 # Estimate the contrast.
  79 print("Contrast seed_based_glm computed.")
  80 z_map = first_level_model.compute_contrast(
  81     contrasts["seed_based_glm"], output_type="z_score"
  82 )
  83 
  84 # Saving snapshots of the contrasts
  85 filename = "dmn_z_map.png"
  86 display = plotting.plot_stat_map(
  87     z_map, threshold=3.0, title="Seed based GLM", cut_coords=pcc_coords
  88 )
  89 display.add_markers(
  90     marker_coords=[pcc_coords], marker_color="g", marker_size=300
  91 )
  92 display.savefig(filename)
  93 print(f"Save z-map in '{filename}'.")
  94 
  95 ###########################################################################
  96 # Generating a report
  97 # -------------------
  98 # It can be useful to quickly generate a
  99 # portable, ready-to-view report with most of the pertinent information.
  100 # This is easy to do if you have a fitted model and the list of contrasts,
  101 # which we do here.
  102 from nilearn.reporting import make_glm_report
  103 
  104 report = make_glm_report(
  105     first_level_model,
  106     contrasts=contrasts,
  107     title="ADHD DMN Report",
  108     cluster_threshold=15,
  109     min_distance=8.0,
  110     plot_type="glass",
  111 )
  112 
  113 #########################################################################
  114 # We have several ways to access the report:
  115 
  116 # report  # This report can be viewed in a notebook
  117 # report.save_as_html('report.html')
  118 # report.open_in_browser()
  119
  [end of examples/04_glm_first_level/plot_adhd_dmn.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/examples/04_glm_first_level/plot_adhd_dmn.py b/examples/04_glm_first_level/plot_adhd_dmn.py
  --- a/examples/04_glm_first_level/plot_adhd_dmn.py
  +++ b/examples/04_glm_first_level/plot_adhd_dmn.py
  @@ -2,8 +2,11 @@
   Default Mode Network extraction of ADHD dataset
   ===============================================
   
  -This example shows a full step-by-step workflow of fitting a GLM to data
  +This example shows a full step-by-step workflow of fitting a GLM to signal
   extracted from a seed on the Posterior Cingulate Cortex and saving the results.
  +More precisely, this example shows how to use a signal extracted from a
  +seed region as the regressor in a GLM to determine the correlation
  +of each region in the dataset with the seed region.
   
   More specifically:
   
  @@ -39,9 +42,9 @@
   pcc_coords = (0, -53, 26)
   
   #########################################################################
  -# Estimate contrasts
  -# ------------------
  -# Specify the contrasts.
  +# Extract the seed region's time course
  +# -------------------------------------
  +# Extract the time course of the seed region.
   seed_masker = NiftiSpheresMasker(
       [pcc_coords],
       radius=10,
  @@ -56,6 +59,22 @@
   )
   seed_time_series = seed_masker.fit_transform(adhd_dataset.func[0])
   frametimes = np.linspace(0, (n_scans - 1) * t_r, n_scans)
  +
  +#########################################################################
  +# Plot the time course of the seed region.
  +import matplotlib.pyplot as plt
  +
  +fig = plt.figure(figsize=(9, 3))
  +ax = fig.add_subplot(111)
  +ax.plot(frametimes, seed_time_series, linewidth=2, label="seed region")
  +ax.legend(loc=2)
  +ax.set_title("Time course of the seed region")
  +plt.show()
  +
  +#########################################################################
  +# Estimate contrasts
  +# ------------------
  +# Specify the contrasts.
   design_matrix = make_first_level_design_matrix(
       frametimes,
       hrf_model="spm",
  
verification_info: {"golden_diff": "diff --git a/examples/04_glm_first_level/plot_adhd_dmn.py b/examples/04_glm_first_level/plot_adhd_dmn.py\n--- a/examples/04_glm_first_level/plot_adhd_dmn.py\n+++ b/examples/04_glm_first_level/plot_adhd_dmn.py\n@@ -2,8 +2,11 @@\n Default Mode Network extraction of ADHD dataset\n ===============================================\n \n-This example shows a full step-by-step workflow of fitting a GLM to data\n+This example shows a full step-by-step workflow of fitting a GLM to signal\n extracted from a seed on the Posterior Cingulate Cortex and saving the results.\n+More precisely, this example shows how to use a signal extracted from a\n+seed region as the regressor in a GLM to determine the correlation\n+of each region in the dataset with the seed region.\n \n More specifically:\n \n@@ -39,9 +42,9 @@\n pcc_coords = (0, -53, 26)\n \n #########################################################################\n-# Estimate contrasts\n-# ------------------\n-# Specify the contrasts.\n+# Extract the seed region's time course\n+# -------------------------------------\n+# Extract the time course of the seed region.\n seed_masker = NiftiSpheresMasker(\n     [pcc_coords],\n     radius=10,\n@@ -56,6 +59,22 @@\n )\n seed_time_series = seed_masker.fit_transform(adhd_dataset.func[0])\n frametimes = np.linspace(0, (n_scans - 1) * t_r, n_scans)\n+\n+#########################################################################\n+# Plot the time course of the seed region.\n+import matplotlib.pyplot as plt\n+\n+fig = plt.figure(figsize=(9, 3))\n+ax = fig.add_subplot(111)\n+ax.plot(frametimes, seed_time_series, linewidth=2, label=\"seed region\")\n+ax.legend(loc=2)\n+ax.set_title(\"Time course of the seed region\")\n+plt.show()\n+\n+#########################################################################\n+# Estimate contrasts\n+# ------------------\n+# Specify the contrasts.\n design_matrix = make_first_level_design_matrix(\n     frametimes,\n     hrf_model=\"spm\",\n", "issue": "[DOC] improve instructions in \"Default Mode Network extraction of ADHD dataset\" example\n### Is there an existing issue for this?\r\n\r\n- [X] I have searched the existing issues\r\n\r\n### Describe your proposed suggestion in detail.\r\n\r\nIt seems the instructions in [this example](https://nilearn.github.io/dev/auto_examples/04_glm_first_level/plot_adhd_dmn.html#default-mode-network-extraction-of-adhd-dataset) need some improvement. There was a confusion mentioned on [NeuroStar](https://neurostars.org/t/why-is-there-glm-for-resting-state-data/25841). After discussing with @Remi-Gau, we concluded that maybe we can add one or two lines saying that in this example we extract the activity of a seed region and then use the extracted signal as regressor in a GLM and this will yield the correlation of each region with the seed region.\r\n\r\n### List any pages that would be impacted.\r\n\r\nhttps://nilearn.github.io/dev/auto_examples/04_glm_first_level/plot_adhd_dmn.html#default-mode-network-extraction-of-adhd-dataset\n", "before_files": [{"content": "\"\"\"\nDefault Mode Network extraction of ADHD dataset\n===============================================\n\nThis example shows a full step-by-step workflow of fitting a GLM to data\nextracted from a seed on the Posterior Cingulate Cortex and saving the results.\n\nMore specifically:\n\n1. A sequence of fMRI volumes are loaded.\n2. A design matrix with the Posterior Cingulate Cortex seed is defined.\n3. A GLM is applied to the dataset (effect/covariance,\n   then contrast estimation).\n4. The Default Mode Network is displayed.\n\n.. include:: ../../../examples/masker_note.rst\n\n\"\"\"\nimport numpy as np\nfrom nilearn import datasets, plotting\nfrom nilearn.glm.first_level import (\n    FirstLevelModel,\n    make_first_level_design_matrix,\n)\nfrom nilearn.maskers import NiftiSpheresMasker\n\n#########################################################################\n# Prepare data and analysis parameters\n# ------------------------------------\n# Prepare the data.\nadhd_dataset = datasets.fetch_adhd(n_subjects=1)\n\n# Prepare timing\nt_r = 2.0\nslice_time_ref = 0.0\nn_scans = 176\n\n# Prepare seed\npcc_coords = (0, -53, 26)\n\n#########################################################################\n# Estimate contrasts\n# ------------------\n# Specify the contrasts.\nseed_masker = NiftiSpheresMasker(\n    [pcc_coords],\n    radius=10,\n    detrend=True,\n    standardize=\"zscore_sample\",\n    low_pass=0.1,\n    high_pass=0.01,\n    t_r=2.0,\n    memory=\"nilearn_cache\",\n    memory_level=1,\n    verbose=0,\n)\nseed_time_series = seed_masker.fit_transform(adhd_dataset.func[0])\nframetimes = np.linspace(0, (n_scans - 1) * t_r, n_scans)\ndesign_matrix = make_first_level_design_matrix(\n    frametimes,\n    hrf_model=\"spm\",\n    add_regs=seed_time_series,\n    add_reg_names=[\"pcc_seed\"],\n)\ndmn_contrast = np.array([1] + [0] * (design_matrix.shape[1] - 1))\ncontrasts = {\"seed_based_glm\": dmn_contrast}\n\n#########################################################################\n# Perform first level analysis\n# ----------------------------\n# Setup and fit GLM.\nfirst_level_model = FirstLevelModel(t_r=t_r, slice_time_ref=slice_time_ref)\nfirst_level_model = first_level_model.fit(\n    run_imgs=adhd_dataset.func[0], design_matrices=design_matrix\n)\n\n#########################################################################\n# Estimate the contrast.\nprint(\"Contrast seed_based_glm computed.\")\nz_map = first_level_model.compute_contrast(\n    contrasts[\"seed_based_glm\"], output_type=\"z_score\"\n)\n\n# Saving snapshots of the contrasts\nfilename = \"dmn_z_map.png\"\ndisplay = plotting.plot_stat_map(\n    z_map, threshold=3.0, title=\"Seed based GLM\", cut_coords=pcc_coords\n)\ndisplay.add_markers(\n    marker_coords=[pcc_coords], marker_color=\"g\", marker_size=300\n)\ndisplay.savefig(filename)\nprint(f\"Save z-map in '{filename}'.\")\n\n###########################################################################\n# Generating a report\n# -------------------\n# It can be useful to quickly generate a\n# portable, ready-to-view report with most of the pertinent information.\n# This is easy to do if you have a fitted model and the list of contrasts,\n# which we do here.\nfrom nilearn.reporting import make_glm_report\n\nreport = make_glm_report(\n    first_level_model,\n    contrasts=contrasts,\n    title=\"ADHD DMN Report\",\n    cluster_threshold=15,\n    min_distance=8.0,\n    plot_type=\"glass\",\n)\n\n#########################################################################\n# We have several ways to access the report:\n\n# report  # This report can be viewed in a notebook\n# report.save_as_html('report.html')\n# report.open_in_browser()\n", "path": "examples/04_glm_first_level/plot_adhd_dmn.py"}]}