We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Choose better affine constant for plotting test data
At the time I was "just" refactoring code and started adding fixtures when doing so. So I did not have a close look at the exact content.

Digging into this now I realize we may have some inconsistency.

```python
from nilearn.plotting.img_plotting import MNI152TEMPLATE
mni_affine = MNI152TEMPLATE.get_affine()
print(mni_affine)
```

gives
```
[[   2.    0.    0.  -98.]
 [   0.    2.    0. -134.]
 [   0.    0.    2.  -72.]
 [   0.    0.    0.    1.]]
```

which does not quite match that in conf.py

```python
MNI_AFFINE = np.array(
    [
        [-2.0, 0.0, 0.0, 90.0],
        [0.0, 2.0, 0.0, -126.0],
        [0.0, 0.0, 2.0, -72.0],
        [0.0, 0.0, 0.0, 1.0],
    ]
)
```

_Originally posted by @Remi-Gau in https://github.com/nilearn/nilearn/issues/3172#issuecomment-1662060133_
            

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `nilearn/conftest.py`
Content:
```
1 """Configuration and extra fixtures for pytest."""
2 import nibabel
3 import numpy as np
4 import pytest
5 from nibabel import Nifti1Image
6 
7 from nilearn import image
8 
9 # we need to import these fixtures even if not used in this module
10 from nilearn.datasets._testing import request_mocker  # noqa: F401
11 from nilearn.datasets._testing import temp_nilearn_data_dir  # noqa: F401
12 
13 collect_ignore = ["datasets/data/convert_templates.py"]
14 
15 
16 try:
17     import matplotlib  # noqa: F401
18 except ImportError:
19     collect_ignore.extend(["plotting", "reporting"])
20     matplotlib = None
21 
22 
23 def pytest_configure(config):
24     """Use Agg so that no figures pop up."""
25     if matplotlib is not None:
26         matplotlib.use("Agg", force=True)
27 
28 
29 @pytest.fixture(autouse=True)
30 def no_int64_nifti(monkeypatch):
31     """Prevent creating or writing a Nift1Image containing 64-bit ints.
32 
33     It is easy to create such images by mistake because Numpy uses int64 by
34     default, but tools like FSL fail to read them and Nibabel will refuse to
35     write them in the future.
36 
37     For tests that do need to manipulate int64 images, it is always possible to
38     disable this fixture by parametrizing a test to override it:
39 
40     @pytest.mark.parametrize("no_int64_nifti", [None])
41     def test_behavior_when_user_provides_int64_img():
42         # ...
43 
44     But by default it is used automatically so that Nilearn doesn't create such
45     images by mistake.
46 
47     """
48     forbidden_types = (np.int64, np.uint64)
49     error_msg = (
50         "Creating or saving an image containing 64-bit ints is forbidden."
51     )
52 
53     to_filename = nibabel.nifti1.Nifti1Image.to_filename
54 
55     def checked_to_filename(img, filename):
56         assert image.get_data(img).dtype not in forbidden_types, error_msg
57         return to_filename(img, filename)
58 
59     monkeypatch.setattr(
60         "nibabel.nifti1.Nifti1Image.to_filename", checked_to_filename
61     )
62 
63     init = nibabel.nifti1.Nifti1Image.__init__
64 
65     def checked_init(self, dataobj, *args, **kwargs):
66         assert dataobj.dtype not in forbidden_types, error_msg
67         return init(self, dataobj, *args, **kwargs)
68 
69     monkeypatch.setattr("nibabel.nifti1.Nifti1Image.__init__", checked_init)
70 
71 
72 @pytest.fixture(autouse=True)
73 def close_all():
74     """Close all matplotlib figures."""
75     yield
76     if matplotlib is not None:
77         import matplotlib.pyplot as plt
78 
79         plt.close("all")  # takes < 1 us so just always do it
80 
81 
82 MNI_AFFINE = np.array(
83     [
84         [-2.0, 0.0, 0.0, 90.0],
85         [0.0, 2.0, 0.0, -126.0],
86         [0.0, 0.0, 2.0, -72.0],
87         [0.0, 0.0, 0.0, 1.0],
88     ]
89 )
90 
91 
92 @pytest.fixture()
93 def mni_affine():
94     """Return an affine corresponding to 2mm isotropic MNI template."""
95     return MNI_AFFINE
96 
97 
98 @pytest.fixture()
99 def testdata_3d_for_plotting():
100     """A random 3D image for testing figures."""
101     data_positive = np.zeros((7, 7, 3))
102     rng = np.random.RandomState(42)
103     data_rng = rng.uniform(size=(7, 7, 3))
104     data_positive[1:-1, 2:-1, 1:] = data_rng[1:-1, 2:-1, 1:]
105     img_3d = Nifti1Image(data_positive, MNI_AFFINE)
106     # TODO: return img_3D directly and not a dict
107     return {"img": img_3d}
108 
109 
110 @pytest.fixture()
111 def testdata_4d_for_plotting():
112     """Random 4D images for testing figures for multivolume data."""
113     rng = np.random.RandomState(42)
114     img_4d = Nifti1Image(rng.uniform(size=(7, 7, 3, 10)), MNI_AFFINE)
115     img_4d_long = Nifti1Image(rng.uniform(size=(7, 7, 3, 1777)), MNI_AFFINE)
116     img_mask = Nifti1Image(np.ones((7, 7, 3), dtype="uint8"), MNI_AFFINE)
117     atlas = np.ones((7, 7, 3), dtype="int32")
118     atlas[2:5, :, :] = 2
119     atlas[5:8, :, :] = 3
120     img_atlas = Nifti1Image(atlas, MNI_AFFINE)
121     atlas_labels = {
122         "gm": 1,
123         "wm": 2,
124         "csf": 3,
125     }
126     # TODO: split into several fixtures
127     return {
128         "img_4d": img_4d,
129         "img_4d_long": img_4d_long,
130         "img_mask": img_mask,
131         "img_atlas": img_atlas,
132         "atlas_labels": atlas_labels,
133     }
134
```
--- 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/nilearn/conftest.py b/nilearn/conftest.py
--- a/nilearn/conftest.py
+++ b/nilearn/conftest.py
@@ -81,14 +81,22 @@
 
 MNI_AFFINE = np.array(
     [
-        [-2.0, 0.0, 0.0, 90.0],
-        [0.0, 2.0, 0.0, -126.0],
+        [2.0, 0.0, 0.0, -98.0],
+        [0.0, 2.0, 0.0, -134.0],
         [0.0, 0.0, 2.0, -72.0],
         [0.0, 0.0, 0.0, 1.0],
     ]
 )
 
 
+def _mni_3d_img(affine=MNI_AFFINE):
+    data_positive = np.zeros((7, 7, 3))
+    rng = np.random.RandomState(42)
+    data_rng = rng.rand(7, 7, 3)
+    data_positive[1:-1, 2:-1, 1:] = data_rng[1:-1, 2:-1, 1:]
+    return Nifti1Image(data_positive, affine)
+
+
 @pytest.fixture()
 def mni_affine():
     """Return an affine corresponding to 2mm isotropic MNI template."""
@@ -96,15 +104,9 @@
 
 
 @pytest.fixture()
-def testdata_3d_for_plotting():
-    """A random 3D image for testing figures."""
-    data_positive = np.zeros((7, 7, 3))
-    rng = np.random.RandomState(42)
-    data_rng = rng.uniform(size=(7, 7, 3))
-    data_positive[1:-1, 2:-1, 1:] = data_rng[1:-1, 2:-1, 1:]
-    img_3d = Nifti1Image(data_positive, MNI_AFFINE)
-    # TODO: return img_3D directly and not a dict
-    return {"img": img_3d}
+def mni_3d_img():
+    """Fixture for a random 3D image in MNI space."""
+    return _mni_3d_img()
 
 
 @pytest.fixture()

{"golden_diff": "diff --git a/nilearn/conftest.py b/nilearn/conftest.py\n--- a/nilearn/conftest.py\n+++ b/nilearn/conftest.py\n@@ -81,14 +81,22 @@\n \n MNI_AFFINE = np.array(\n     [\n-        [-2.0, 0.0, 0.0, 90.0],\n-        [0.0, 2.0, 0.0, -126.0],\n+        [2.0, 0.0, 0.0, -98.0],\n+        [0.0, 2.0, 0.0, -134.0],\n         [0.0, 0.0, 2.0, -72.0],\n         [0.0, 0.0, 0.0, 1.0],\n     ]\n )\n \n \n+def _mni_3d_img(affine=MNI_AFFINE):\n+    data_positive = np.zeros((7, 7, 3))\n+    rng = np.random.RandomState(42)\n+    data_rng = rng.rand(7, 7, 3)\n+    data_positive[1:-1, 2:-1, 1:] = data_rng[1:-1, 2:-1, 1:]\n+    return Nifti1Image(data_positive, affine)\n+\n+\n @pytest.fixture()\n def mni_affine():\n     \"\"\"Return an affine corresponding to 2mm isotropic MNI template.\"\"\"\n@@ -96,15 +104,9 @@\n \n \n @pytest.fixture()\n-def testdata_3d_for_plotting():\n-    \"\"\"A random 3D image for testing figures.\"\"\"\n-    data_positive = np.zeros((7, 7, 3))\n-    rng = np.random.RandomState(42)\n-    data_rng = rng.uniform(size=(7, 7, 3))\n-    data_positive[1:-1, 2:-1, 1:] = data_rng[1:-1, 2:-1, 1:]\n-    img_3d = Nifti1Image(data_positive, MNI_AFFINE)\n-    # TODO: return img_3D directly and not a dict\n-    return {\"img\": img_3d}\n+def mni_3d_img():\n+    \"\"\"Fixture for a random 3D image in MNI space.\"\"\"\n+    return _mni_3d_img()\n \n \n @pytest.fixture()\n", "issue": "Choose better affine constant for plotting test data\nAt the time I was \"just\" refactoring code and started adding fixtures when doing so. So I did not have a close look at the exact content.\r\n\r\nDigging into this now I realize we may have some inconsistency.\r\n\r\n```python\r\nfrom nilearn.plotting.img_plotting import MNI152TEMPLATE\r\nmni_affine = MNI152TEMPLATE.get_affine()\r\nprint(mni_affine)\r\n```\r\n\r\ngives\r\n```\r\n[[   2.    0.    0.  -98.]\r\n [   0.    2.    0. -134.]\r\n [   0.    0.    2.  -72.]\r\n [   0.    0.    0.    1.]]\r\n```\r\n\r\nwhich does not quite match that in conf.py\r\n\r\n```python\r\nMNI_AFFINE = np.array(\r\n    [\r\n        [-2.0, 0.0, 0.0, 90.0],\r\n        [0.0, 2.0, 0.0, -126.0],\r\n        [0.0, 0.0, 2.0, -72.0],\r\n        [0.0, 0.0, 0.0, 1.0],\r\n    ]\r\n)\r\n```\r\n\r\n_Originally posted by @Remi-Gau in https://github.com/nilearn/nilearn/issues/3172#issuecomment-1662060133_\r\n            \n", "before_files": [{"content": "\"\"\"Configuration and extra fixtures for pytest.\"\"\"\nimport nibabel\nimport numpy as np\nimport pytest\nfrom nibabel import Nifti1Image\n\nfrom nilearn import image\n\n# we need to import these fixtures even if not used in this module\nfrom nilearn.datasets._testing import request_mocker  # noqa: F401\nfrom nilearn.datasets._testing import temp_nilearn_data_dir  # noqa: F401\n\ncollect_ignore = [\"datasets/data/convert_templates.py\"]\n\n\ntry:\n    import matplotlib  # noqa: F401\nexcept ImportError:\n    collect_ignore.extend([\"plotting\", \"reporting\"])\n    matplotlib = None\n\n\ndef pytest_configure(config):\n    \"\"\"Use Agg so that no figures pop up.\"\"\"\n    if matplotlib is not None:\n        matplotlib.use(\"Agg\", force=True)\n\n\n@pytest.fixture(autouse=True)\ndef no_int64_nifti(monkeypatch):\n    \"\"\"Prevent creating or writing a Nift1Image containing 64-bit ints.\n\n    It is easy to create such images by mistake because Numpy uses int64 by\n    default, but tools like FSL fail to read them and Nibabel will refuse to\n    write them in the future.\n\n    For tests that do need to manipulate int64 images, it is always possible to\n    disable this fixture by parametrizing a test to override it:\n\n    @pytest.mark.parametrize(\"no_int64_nifti\", [None])\n    def test_behavior_when_user_provides_int64_img():\n        # ...\n\n    But by default it is used automatically so that Nilearn doesn't create such\n    images by mistake.\n\n    \"\"\"\n    forbidden_types = (np.int64, np.uint64)\n    error_msg = (\n        \"Creating or saving an image containing 64-bit ints is forbidden.\"\n    )\n\n    to_filename = nibabel.nifti1.Nifti1Image.to_filename\n\n    def checked_to_filename(img, filename):\n        assert image.get_data(img).dtype not in forbidden_types, error_msg\n        return to_filename(img, filename)\n\n    monkeypatch.setattr(\n        \"nibabel.nifti1.Nifti1Image.to_filename\", checked_to_filename\n    )\n\n    init = nibabel.nifti1.Nifti1Image.__init__\n\n    def checked_init(self, dataobj, *args, **kwargs):\n        assert dataobj.dtype not in forbidden_types, error_msg\n        return init(self, dataobj, *args, **kwargs)\n\n    monkeypatch.setattr(\"nibabel.nifti1.Nifti1Image.__init__\", checked_init)\n\n\n@pytest.fixture(autouse=True)\ndef close_all():\n    \"\"\"Close all matplotlib figures.\"\"\"\n    yield\n    if matplotlib is not None:\n        import matplotlib.pyplot as plt\n\n        plt.close(\"all\")  # takes < 1 us so just always do it\n\n\nMNI_AFFINE = np.array(\n    [\n        [-2.0, 0.0, 0.0, 90.0],\n        [0.0, 2.0, 0.0, -126.0],\n        [0.0, 0.0, 2.0, -72.0],\n        [0.0, 0.0, 0.0, 1.0],\n    ]\n)\n\n\n@pytest.fixture()\ndef mni_affine():\n    \"\"\"Return an affine corresponding to 2mm isotropic MNI template.\"\"\"\n    return MNI_AFFINE\n\n\n@pytest.fixture()\ndef testdata_3d_for_plotting():\n    \"\"\"A random 3D image for testing figures.\"\"\"\n    data_positive = np.zeros((7, 7, 3))\n    rng = np.random.RandomState(42)\n    data_rng = rng.uniform(size=(7, 7, 3))\n    data_positive[1:-1, 2:-1, 1:] = data_rng[1:-1, 2:-1, 1:]\n    img_3d = Nifti1Image(data_positive, MNI_AFFINE)\n    # TODO: return img_3D directly and not a dict\n    return {\"img\": img_3d}\n\n\n@pytest.fixture()\ndef testdata_4d_for_plotting():\n    \"\"\"Random 4D images for testing figures for multivolume data.\"\"\"\n    rng = np.random.RandomState(42)\n    img_4d = Nifti1Image(rng.uniform(size=(7, 7, 3, 10)), MNI_AFFINE)\n    img_4d_long = Nifti1Image(rng.uniform(size=(7, 7, 3, 1777)), MNI_AFFINE)\n    img_mask = Nifti1Image(np.ones((7, 7, 3), dtype=\"uint8\"), MNI_AFFINE)\n    atlas = np.ones((7, 7, 3), dtype=\"int32\")\n    atlas[2:5, :, :] = 2\n    atlas[5:8, :, :] = 3\n    img_atlas = Nifti1Image(atlas, MNI_AFFINE)\n    atlas_labels = {\n        \"gm\": 1,\n        \"wm\": 2,\n        \"csf\": 3,\n    }\n    # TODO: split into several fixtures\n    return {\n        \"img_4d\": img_4d,\n        \"img_4d_long\": img_4d_long,\n        \"img_mask\": img_mask,\n        \"img_atlas\": img_atlas,\n        \"atlas_labels\": atlas_labels,\n    }\n", "path": "nilearn/conftest.py"}], "after_files": [{"content": "\"\"\"Configuration and extra fixtures for pytest.\"\"\"\nimport nibabel\nimport numpy as np\nimport pytest\nfrom nibabel import Nifti1Image\n\nfrom nilearn import image\n\n# we need to import these fixtures even if not used in this module\nfrom nilearn.datasets._testing import request_mocker  # noqa: F401\nfrom nilearn.datasets._testing import temp_nilearn_data_dir  # noqa: F401\n\ncollect_ignore = [\"datasets/data/convert_templates.py\"]\n\n\ntry:\n    import matplotlib  # noqa: F401\nexcept ImportError:\n    collect_ignore.extend([\"plotting\", \"reporting\"])\n    matplotlib = None\n\n\ndef pytest_configure(config):\n    \"\"\"Use Agg so that no figures pop up.\"\"\"\n    if matplotlib is not None:\n        matplotlib.use(\"Agg\", force=True)\n\n\n@pytest.fixture(autouse=True)\ndef no_int64_nifti(monkeypatch):\n    \"\"\"Prevent creating or writing a Nift1Image containing 64-bit ints.\n\n    It is easy to create such images by mistake because Numpy uses int64 by\n    default, but tools like FSL fail to read them and Nibabel will refuse to\n    write them in the future.\n\n    For tests that do need to manipulate int64 images, it is always possible to\n    disable this fixture by parametrizing a test to override it:\n\n    @pytest.mark.parametrize(\"no_int64_nifti\", [None])\n    def test_behavior_when_user_provides_int64_img():\n        # ...\n\n    But by default it is used automatically so that Nilearn doesn't create such\n    images by mistake.\n\n    \"\"\"\n    forbidden_types = (np.int64, np.uint64)\n    error_msg = (\n        \"Creating or saving an image containing 64-bit ints is forbidden.\"\n    )\n\n    to_filename = nibabel.nifti1.Nifti1Image.to_filename\n\n    def checked_to_filename(img, filename):\n        assert image.get_data(img).dtype not in forbidden_types, error_msg\n        return to_filename(img, filename)\n\n    monkeypatch.setattr(\n        \"nibabel.nifti1.Nifti1Image.to_filename\", checked_to_filename\n    )\n\n    init = nibabel.nifti1.Nifti1Image.__init__\n\n    def checked_init(self, dataobj, *args, **kwargs):\n        assert dataobj.dtype not in forbidden_types, error_msg\n        return init(self, dataobj, *args, **kwargs)\n\n    monkeypatch.setattr(\"nibabel.nifti1.Nifti1Image.__init__\", checked_init)\n\n\n@pytest.fixture(autouse=True)\ndef close_all():\n    \"\"\"Close all matplotlib figures.\"\"\"\n    yield\n    if matplotlib is not None:\n        import matplotlib.pyplot as plt\n\n        plt.close(\"all\")  # takes < 1 us so just always do it\n\n\nMNI_AFFINE = np.array(\n    [\n        [2.0, 0.0, 0.0, -98.0],\n        [0.0, 2.0, 0.0, -134.0],\n        [0.0, 0.0, 2.0, -72.0],\n        [0.0, 0.0, 0.0, 1.0],\n    ]\n)\n\n\ndef _mni_3d_img(affine=MNI_AFFINE):\n    data_positive = np.zeros((7, 7, 3))\n    rng = np.random.RandomState(42)\n    data_rng = rng.rand(7, 7, 3)\n    data_positive[1:-1, 2:-1, 1:] = data_rng[1:-1, 2:-1, 1:]\n    return Nifti1Image(data_positive, affine)\n\n\n@pytest.fixture()\ndef mni_affine():\n    \"\"\"Return an affine corresponding to 2mm isotropic MNI template.\"\"\"\n    return MNI_AFFINE\n\n\n@pytest.fixture()\ndef mni_3d_img():\n    \"\"\"Fixture for a random 3D image in MNI space.\"\"\"\n    return _mni_3d_img()\n\n\n@pytest.fixture()\ndef testdata_4d_for_plotting():\n    \"\"\"Random 4D images for testing figures for multivolume data.\"\"\"\n    rng = np.random.RandomState(42)\n    img_4d = Nifti1Image(rng.uniform(size=(7, 7, 3, 10)), MNI_AFFINE)\n    img_4d_long = Nifti1Image(rng.uniform(size=(7, 7, 3, 1777)), MNI_AFFINE)\n    img_mask = Nifti1Image(np.ones((7, 7, 3), dtype=\"uint8\"), MNI_AFFINE)\n    atlas = np.ones((7, 7, 3), dtype=\"int32\")\n    atlas[2:5, :, :] = 2\n    atlas[5:8, :, :] = 3\n    img_atlas = Nifti1Image(atlas, MNI_AFFINE)\n    atlas_labels = {\n        \"gm\": 1,\n        \"wm\": 2,\n        \"csf\": 3,\n    }\n    # TODO: split into several fixtures\n    return {\n        \"img_4d\": img_4d,\n        \"img_4d_long\": img_4d_long,\n        \"img_mask\": img_mask,\n        \"img_atlas\": img_atlas,\n        \"atlas_labels\": atlas_labels,\n    }\n", "path": "nilearn/conftest.py"}]}