internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: nilearn/nilearn

Issue:
Unclear documentation regarding `min_distance` in `reporting.get_clusters_table`
The method `nilearn.reporting.get_clusters_table` which extracts peak statistics from an image accepts an argument which is `min_distance` described as "minimal distance between subpeaks in mm".

I find this docstring a bit confusing as the minimal distance is applied at the cluster-level and not at the image level. This results in a dataframe where peaks can actually be closer than `min_distance` if they belong to different clusters. 

Maybe this nuance was implied in the use of "subpeaks" instead of "peaks", but my opinion is that it should be a bit more explicit. WDYT?

Relevant portion of code [here](https://github.com/nilearn/nilearn/blob/1607b52458c28953a87bbe6f42448b7b4e30a72f/nilearn/reporting/_get_clusters_table.py#L234)


Discussion:
PR welcome ;-)

Resolving patch:
diff --git a/nilearn/reporting/_get_clusters_table.py b/nilearn/reporting/_get_clusters_table.py
--- a/nilearn/reporting/_get_clusters_table.py
+++ b/nilearn/reporting/_get_clusters_table.py
@@ -154,6 +154,10 @@ def get_clusters_table(stat_img, stat_threshold, cluster_threshold=None,
     min_distance : `float`, optional
         Minimum distance between subpeaks in mm. Default=8mm.
 
+        .. note::
+            If two different clusters are closer than ``min_distance``, it can
+            result in peaks closer than ``min_distance``.
+
     Returns
     -------
     df : `pandas.DataFrame`


Test patch:
Repository: nilearn/nilearn

Issue:
Fix: load_surf_mesh and vol_to_surf offset vertices coords by CRAS
There is offset between Freesurfer coordinate space and orig T1 space named CRAS. The issue misleads [`vol_to_surf`](https://github.com/nilearn/nilearn/blob/4e1ccac93753ffb2eced2d7cbb20d91688d21fab/nilearn/surface/surface.py#L386) when it try to project voxels from volume (.nii file) in T1 space onto surface (.orig, .pial, .white, .sphere, or .inflated) extracted by Freesurfer from the same volume (or at least from the volume in the same T1 space):
we observe some shift between volume and surface
![plot_surf_stat_map-before](https://user-images.githubusercontent.com/1339345/68902720-20f31f80-074a-11ea-93c3-75e16813e888.png)
instead of uniform distribution of voxels intensity near the cortex
![plot_surf_stat_map-after](https://user-images.githubusercontent.com/1339345/68902740-2b151e00-074a-11ea-92a4-362686391875.png)
It is easily solved by CRAS offsetting vertices coords loaded by [`load_surf_mesh`](https://github.com/nilearn/nilearn/blob/4e1ccac93753ffb2eced2d7cbb20d91688d21fab/nilearn/surface/surface.py#L681). It seems this does [not apply to .gii](https://neurostars.org/t/resample-volume-and-surface-to-same-orientation/4069/4) files.



Discussion:

Resolving patch:
diff --git a/nilearn/surface/surface.py b/nilearn/surface/surface.py
--- a/nilearn/surface/surface.py
+++ b/nilearn/surface/surface.py
@@ -813,7 +813,11 @@ def load_surf_mesh(surf_mesh):
         if (surf_mesh.endswith('orig') or surf_mesh.endswith('pial') or
                 surf_mesh.endswith('white') or surf_mesh.endswith('sphere') or
                 surf_mesh.endswith('inflated')):
-            coords, faces = fs.io.read_geometry(surf_mesh)
+            coords, faces, header = fs.io.read_geometry(surf_mesh,
+                                                        read_metadata=True)
+            # See https://github.com/nilearn/nilearn/pull/3235
+            if 'cras' in header:
+                coords += header['cras']
             mesh = Mesh(coordinates=coords, faces=faces)
         elif surf_mesh.endswith('gii'):
             coords, faces = _gifti_img_to_mesh(nibabel.load(surf_mesh))


Test patch:
Repository: nilearn/nilearn

Issue:
URL problem in neurovault.py
<!--Provide a brief description of the bug.--> 
trying to run the example on page : [plot-3d-and-4d-niimg-py](https://nilearn.github.io/stable/auto_examples/plot_3d_and_4d_niimg.html#sphx-glr-auto-examples-plot-3d-and-4d-niimg-py)

I got an error message: 
Could not get batch from http://neurovault.org/api/images/10426

This is because the URL uses http rather than https

<!--Please fill in the following information, to the best of your ability.-->
Nilearn version:

### Expected behavior
the data fetcher should download data from neurovault into ~/nilearn_data 


### Actual behavior
I got an error message: 
Could not get batch from http://neurovault.org/api/images/10426

### Steps and code to reproduce bug


```python
from nilearn import datasets
datasets.fetch_neurovault_motor_task()
```



Discussion:

Resolving patch:
diff --git a/nilearn/datasets/neurovault.py b/nilearn/datasets/neurovault.py
--- a/nilearn/datasets/neurovault.py
+++ b/nilearn/datasets/neurovault.py
@@ -26,10 +26,10 @@
 from ..image import resample_img
 import uuid
 
-_NEUROVAULT_BASE_URL = 'http://neurovault.org/api/'
+_NEUROVAULT_BASE_URL = 'https://neurovault.org/api/'
 _NEUROVAULT_COLLECTIONS_URL = urljoin(_NEUROVAULT_BASE_URL, 'collections/')
 _NEUROVAULT_IMAGES_URL = urljoin(_NEUROVAULT_BASE_URL, 'images/')
-_NEUROSYNTH_FETCH_WORDS_URL = 'http://neurosynth.org/api/decode/'
+_NEUROSYNTH_FETCH_WORDS_URL = 'https://neurosynth.org/api/decode/'
 
 _COL_FILTERS_AVAILABLE_ON_SERVER = ('DOI', 'name', 'owner', 'id')
 _IM_FILTERS_AVAILABLE_ON_SERVER = tuple()


Test patch:
diff --git a/nilearn/datasets/tests/test_neurovault.py b/nilearn/datasets/tests/test_neurovault.py
--- a/nilearn/datasets/tests/test_neurovault.py
+++ b/nilearn/datasets/tests/test_neurovault.py
@@ -248,11 +248,11 @@ def test_append_filters_to_query():
         neurovault._NEUROVAULT_COLLECTIONS_URL,
         {'DOI': 17})
     assert (
-        query == 'http://neurovault.org/api/collections/?DOI=17')
+        query == 'https://neurovault.org/api/collections/?DOI=17')
     query = neurovault._append_filters_to_query(
         neurovault._NEUROVAULT_COLLECTIONS_URL,
         {'id': 40})
-    assert query == 'http://neurovault.org/api/collections/40'
+    assert query == 'https://neurovault.org/api/collections/40'
 
 
 def test_get_batch():
Repository: nilearn/nilearn

Issue:
`_check_second_level_input` does not raise an error when it should
The function `_check_second_level_input` when provided with a list of `FirstLevelModel` objects with the flag `flm_object` set to `False` should raise an error, which is not the case currently:

```python
from nilearn.glm.first_level import FirstLevelModel
from nilearn.glm.second_level.second_level import _check_second_level_input

list_of_flm = [FirstLevelModel()] * 3
_check_second_level_input(list_of_flm, None, flm_object=False, df_object=False)  # No error here
```


Discussion:
Thx for noticing.

Resolving patch:
diff --git a/nilearn/glm/second_level/second_level.py b/nilearn/glm/second_level/second_level.py
--- a/nilearn/glm/second_level/second_level.py
+++ b/nilearn/glm/second_level/second_level.py
@@ -42,7 +42,11 @@ def _check_second_level_input(second_level_input, design_matrix,
             raise ValueError('A second level model requires a list with at'
                              ' least two first level models or niimgs')
         # Check FirstLevelModel objects case
-        if flm_object and isinstance(second_level_input[0], FirstLevelModel):
+        if isinstance(second_level_input[0], FirstLevelModel):
+            if not flm_object:
+                raise ValueError("Contradictory arguments: flm_object is set "
+                                 "to False yet second_level_input is a list "
+                                 "of FirstLevelModel objects")
             models_input = enumerate(second_level_input)
             for model_idx, first_level in models_input:
                 if (first_level.labels_ is None


Test patch:
diff --git a/nilearn/glm/tests/test_second_level.py b/nilearn/glm/tests/test_second_level.py
--- a/nilearn/glm/tests/test_second_level.py
+++ b/nilearn/glm/tests/test_second_level.py
@@ -138,6 +138,12 @@ def test_check_second_level_input():
     with pytest.raises(ValueError,
                        match="second_level_input must be a list"):
         _check_second_level_input(1, None, flm_object=False)
+    with pytest.raises(ValueError,
+                       match="Contradictory arguments: flm_object is set to "
+                             "False yet second_level_input is a list of "
+                             "FirstLevelModel objects"):
+        _check_second_level_input([FirstLevelModel()] * 3, None,
+                                  flm_object=False, df_object=False)
 
 
 def test_check_output_type():
Repository: nilearn/nilearn

Issue:
Test error in scipy `1.9.0rc1`
The test is currently failing with scipy `1.9.0rc1`: See [here](https://github.com/nilearn/nilearn/runs/7067861378?check_suite_focus=true) for example. The failing test is:

https://github.com/nilearn/nilearn/blob/4242c0d03e3fc790b17a1d88ce5a4140633c6b6f/nilearn/decoding/tests/test_decoder.py#L435-L440

failing with error:

```
if Wn.size > 1 and not Wn[0] < Wn[1]:
>           raise ValueError("Wn[0] must be less than Wn[1]")
E           ValueError: Wn[0] must be less than Wn[1]
/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/scipy/signal/_filter_design.py:2468: ValueError
```

The error is due to this check which was added in this PR: https://github.com/scipy/scipy/pull/15886
See also the related issue: https://github.com/scipy/scipy/issues/15773.


Discussion:

Resolving patch:
diff --git a/nilearn/signal.py b/nilearn/signal.py
--- a/nilearn/signal.py
+++ b/nilearn/signal.py
@@ -340,6 +340,20 @@ def butterworth(signals, sampling_rate, low_pass=None, high_pass=None,
 
     if len(critical_freq) == 2:
         btype = 'band'
+        # Inappropriate parameter input might lead to coercion of both
+        # elements of critical_freq to a value just below 1.
+        # Scipy fix now enforces that critical frequencies cannot be equal.
+        # See https://github.com/scipy/scipy/pull/15886. If this is the case,
+        # we return the signals unfiltered.
+        if critical_freq[0] == critical_freq[1]:
+            warnings.warn(
+                'Signals are returned unfiltered because band-pass critical '
+                'frequencies are equal. Please check that inputs for '
+                'sampling_rate, low_pass, and high_pass are valid.')
+            if copy:
+                return signals.copy()
+            else:
+                return signals
     else:
         critical_freq = critical_freq[0]
 


Test patch:
diff --git a/nilearn/tests/test_signal.py b/nilearn/tests/test_signal.py
--- a/nilearn/tests/test_signal.py
+++ b/nilearn/tests/test_signal.py
@@ -178,6 +178,20 @@ def test_butterworth():
     np.testing.assert_almost_equal(out1, out2)
     np.testing.assert_(id(out1) != id(out2))
 
+    # Test check for equal values in critical frequencies
+    sampling = 1
+    low_pass = 2
+    high_pass = 1
+    with pytest.warns(UserWarning,
+                      match='Signals are returned unfiltered because '
+                      'band-pass critical frequencies are equal. '
+                      'Please check that inputs for sampling_rate, '
+                      'low_pass, and high_pass are valid.'):
+        out = nisignal.butterworth(data, sampling,
+                                   low_pass=low_pass, high_pass=high_pass,
+                                   copy=True)
+    assert (out == data).all()
+
 
 def test_standardize():
     rng = np.random.RandomState(42)
Repository: nilearn/nilearn

Issue:
Use bibtex in nilearn/glm
Convert references in

- `nilearn/glm/regression.py`
- `nilearn/glm/thresholding.py`

to use footcite / footbibliography
See #2759


Discussion:

Resolving patch:
diff --git a/nilearn/glm/regression.py b/nilearn/glm/regression.py
--- a/nilearn/glm/regression.py
+++ b/nilearn/glm/regression.py
@@ -128,7 +128,7 @@ def logL(self, beta, Y, nuisance=None):
 
         Given the whitened design matrix, the loglikelihood is evaluated
         at the parameter vector, beta, for the dependent variable, Y
-        and the nuisance parameter, sigma [1]_.
+        and the nuisance parameter, sigma :footcite:`GreeneEconometric`.
 
         Parameters
         ----------
@@ -175,7 +175,7 @@ def logL(self, beta, Y, nuisance=None):
 
         References
         ----------
-        .. [1] W. Green.  "Econometric Analysis," 5th ed., Pearson, 2003.
+        .. footbibliography::
 
         '''
         # This is overwriting an abstract method of LikelihoodModel
@@ -342,7 +342,7 @@ def residuals(self):
     def normalized_residuals(self):
         """Residuals, normalized to have unit length.
 
-        See [1]_ and [2]_.
+        See :footcite:`Montgomery` and :footcite:`GVK393847152`.
 
         Notes
         -----
@@ -356,9 +356,7 @@ def normalized_residuals(self):
 
         References
         ----------
-        .. [1] Montgomery and Peck 3.2.1 p. 68
-
-        .. [2] Davidson and MacKinnon 15.2 p 662
+        .. footbibliography::
 
         """
         return self.residuals * positive_reciprocal(np.sqrt(self.dispersion))
@@ -434,7 +432,7 @@ def residuals(self, Y):
     def normalized_residuals(self, Y):
         """Residuals, normalized to have unit length.
 
-        See [1]_ and [2]_.
+        See :footcite:`Montgomery` and :footcite:`GVK393847152`.
 
         Notes
         -----
@@ -448,9 +446,7 @@ def normalized_residuals(self, Y):
 
         References
         ----------
-        .. [1] Montgomery and Peck 3.2.1 p. 68
-
-        .. [2] Davidson and MacKinnon 15.2 p 662
+        .. footbibliography::
 
         """
         return (self.residuals(Y)
diff --git a/nilearn/glm/thresholding.py b/nilearn/glm/thresholding.py
--- a/nilearn/glm/thresholding.py
+++ b/nilearn/glm/thresholding.py
@@ -112,7 +112,7 @@ def cluster_level_inference(stat_img, mask_img=None,
     """ Report the proportion of active voxels for all clusters
     defined by the input threshold.
 
-    This implements the method described in [1]_.
+    This implements the method described in :footcite:`InferenceRosenblatt`.
 
     Parameters
     ----------
@@ -144,10 +144,7 @@ def cluster_level_inference(stat_img, mask_img=None,
 
     References
     ----------
-    .. [1] Rosenblatt JD, Finos L, Weeda WD, Solari A, Goeman JJ.
-        All-Resolutions Inference for brain imaging.
-        Neuroimage. 2018 Nov 1;181:786-796.
-        doi: 10.1016/j.neuroimage.2018.07.060
+    .. footbibliography::
 
     """
 


Test patch:
Repository: nilearn/nilearn

Issue:
Binder links are broken
When trying to open binder I get a 404 error. This is probably due to the new file structure and cleaning of https://github.com/nilearn/nilearn.github.io in https://github.com/nilearn/nilearn.github.io/pull/3.

I am also curious about how many people find binder useful. In the past I have tried to use it but it was very slow.


Discussion:
> I am also curious about how many people find binder useful.

I personally never use binder 😅 (for `nilearn` or elsewhere).
I do use it when quickly wanting to see whats in a variable in a tutorial...
I use them when teaching: they avoid installation mess in the room. 

On Aug 10, 2022, 17:28, at 17:28, Andrei Foldes ***@***.***> wrote:
>I do use it when quickly wanting to see whats in a variable in a
>tutorial...
>
>-- 
>Reply to this email directly or view it on GitHub:
>https://github.com/nilearn/nilearn/issues/3334#issuecomment-1210872374
>You are receiving this because you are subscribed to this thread.
>
>Message ID: ***@***.***>

I use Binder to quickly showcase small examples ; it would be great to fix these links for the new doc format !
Thanks for the feedback and great to know that it is useful! Working on a solution

Resolving patch:
diff --git a/doc/conf.py b/doc/conf.py
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -338,6 +338,11 @@
     'compound': (_python_doc_base + '/reference/compound_stmts.html#%s', ''),
 }
 
+if 'dev' in release:
+    binder_branch = 'main'
+else:
+    binder_branch = release
+
 sphinx_gallery_conf = {
     'doc_module': 'nilearn',
     'backreferences_dir': os.path.join('modules', 'generated'),
@@ -352,11 +357,11 @@
     'nested_sections': True,
     'binder': {
         'org': 'nilearn',
-        'repo': 'nilearn.github.io',
+        'repo': 'nilearn',
         'binderhub_url': 'https://mybinder.org',
-        'branch': 'main',
-        'dependencies': ['binder/requirements.txt'],
-        'notebooks_dir': 'examples'
+        'branch': binder_branch,
+        'dependencies': './binder/requirements.txt',
+        'use_jupyter_lab': True,
     },
     'default_thumb_file': 'logos/nilearn-desaturate-100.png',
 }


Test patch:
Repository: nilearn/nilearn

Issue:
Spelling Error
<!--Describe your proposed enhancement in detail.-->
I think the authors meant to describe ADHD but have written ADHD as AHDH. It is just a simple spelling or typographic error.
<!--List any pages that would be impacted by the enhancement.-->
### Affected pages
1. https://nilearn.github.io/dev/auto_examples/04_glm_first_level/plot_adhd_dmn.html#sphx-glr-auto-examples-04-glm-first-level-plot-adhd-dmn-py
 2. https://nilearn.github.io/dev/glm/first_level_model.html#fitting-a-first-level-model


Discussion:
@sachin-bsai thanks for noticing! Would you be willing to open a pull request to fix it?
Yeah sure, I will try. If I fail somewhere, I will comment over here.

Resolving patch:
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
@@ -1,4 +1,4 @@
-"""Default Mode Network extraction of AHDH dataset
+"""Default Mode Network extraction of ADHD dataset
 ===============================================
 
 This example shows a full step-by-step workflow of fitting a GLM to data


Test patch:
Repository: nilearn/nilearn

Issue:
Codespell failure on `main`
Codespell failed after the latest merge into main, see https://github.com/nilearn/nilearn/runs/7893268875?check_suite_focus=true
It's not clear to me why this happened in unrelated files, and if codespell is always checking the whole codebase, why did these errors just come up now? 


Discussion:
This might be due to this very recent release https://github.com/codespell-project/codespell/releases
I will just quickly correct those errors in a PR.

Resolving patch:
diff --git a/nilearn/_utils/docs.py b/nilearn/_utils/docs.py
--- a/nilearn/_utils/docs.py
+++ b/nilearn/_utils/docs.py
@@ -368,7 +368,7 @@
 'y', 'z', 'yx', 'xz', 'yz'}, optional
     Choose the direction of the cuts:
 
-        - 'x': sagital
+        - 'x': sagittal
         - 'y': coronal
         - 'z': axial
         - 'ortho': three cuts are performed in orthogonal
diff --git a/nilearn/interfaces/fmriprep/load_confounds_strategy.py b/nilearn/interfaces/fmriprep/load_confounds_strategy.py
--- a/nilearn/interfaces/fmriprep/load_confounds_strategy.py
+++ b/nilearn/interfaces/fmriprep/load_confounds_strategy.py
@@ -86,7 +86,7 @@ def load_confounds_strategy(img_files, denoise_strategy="simple", **kwargs):
           :footcite:`Fox2005`. With the global signal regression, this approach
           can remove confounds without compromising the temporal degrees of
           freedom.
-        - 'srubbing': Load confounds for scrubbing describbed in
+        - 'srubbing': Load confounds for scrubbing described in
           :footcite:`Power2012`. This approach can reliably remove the
           impact of high motion volumes in functional connectome, however, it
           might not be suitable with subjects with high motion (more than 50%


Test patch:
Repository: nilearn/nilearn

Issue:
Update `load_confounds` documentation regarding intercept
<!--Describe your proposed enhancement in detail.-->
The current documentation says an intercept column is added, but the output doesn't generate intercept. 
Originally I thought it's something lost during refactoring, but looks like this is a case of old documentation not being cleaned to reflect the current correct behaviour. 
See https://github.com/SIMEXP/load_confounds/issues/28

Action: remove mentions related to intercept.

<!--List any pages that would be impacted by the enhancement.-->
### Affected pages
https://nilearn.github.io/stable/modules/generated/nilearn.interfaces.fmriprep.load_confounds_strategy.html
https://nilearn.github.io/stable/modules/generated/nilearn.interfaces.fmriprep.load_confounds.html


Discussion:

Resolving patch:
diff --git a/nilearn/interfaces/fmriprep/load_confounds.py b/nilearn/interfaces/fmriprep/load_confounds.py
--- a/nilearn/interfaces/fmriprep/load_confounds.py
+++ b/nilearn/interfaces/fmriprep/load_confounds.py
@@ -233,7 +233,6 @@ def load_confounds(img_files,
     confounds : pandas.DataFrame, or list of
         A reduced version of :term:`fMRIPrep` confounds based on selected
         strategy and flags.
-        An intercept is automatically added to the list of confounds.
         The columns contains the labels of the regressors.
 
     sample_mask : None, numpy.ndarray, or list of
diff --git a/nilearn/interfaces/fmriprep/load_confounds_strategy.py b/nilearn/interfaces/fmriprep/load_confounds_strategy.py
--- a/nilearn/interfaces/fmriprep/load_confounds_strategy.py
+++ b/nilearn/interfaces/fmriprep/load_confounds_strategy.py
@@ -122,7 +122,6 @@ def load_confounds_strategy(img_files, denoise_strategy="simple", **kwargs):
     confounds : pandas.DataFrame, or list of
         A reduced version of :term:`fMRIPrep` confounds based on selected
         strategy and flags.
-        An intercept is automatically added to the list of confounds.
         The columns contains the labels of the regressors.
 
     sample_mask : None, numpy.ndarray, or list of


Test patch:
Repository: nilearn/nilearn

Issue:
Slightly inaccurate docstring of `find_probabilistic_atlas_cut_coords`
<!--Describe your proposed enhancement in detail.-->

Simply replace `label_img` with `maps_img` in the docstring

<!--List any pages that would be impacted by the enhancement.-->
### Affected pages
https://github.com/nilearn/nilearn/blob/main/nilearn/plotting/find_cuts.py


Discussion:

Resolving patch:
diff --git a/nilearn/plotting/find_cuts.py b/nilearn/plotting/find_cuts.py
--- a/nilearn/plotting/find_cuts.py
+++ b/nilearn/plotting/find_cuts.py
@@ -481,7 +481,7 @@ def find_probabilistic_atlas_cut_coords(maps_img):
 
     Parameters
     ----------
-    label_img : 4D Nifti1Image
+    maps_img : 4D Nifti1Image
         A probabilistic brain atlas with probabilistic masks in the fourth
         dimension.
 


Test patch:
Repository: nilearn/nilearn

Issue:
Opening parameter description missing from nilearn.masking.compute_multi_epi_mask documentation
Description of the `opening` parameter is missing from the `nilearn.masking.compute_multi_epi_mask` [documentation](https://nilearn.github.io/stable/modules/generated/nilearn.masking.compute_multi_epi_mask.html?highlight=compute_multi#nilearn.masking.compute_multi_epi_mask).

It is included in the `nilearn.masking.compute_epi_mask` [documentation](https://nilearn.github.io/stable/modules/generated/nilearn.masking.compute_epi_mask.html?highlight=compute_epi_mask).




Discussion:
Thx for raising this. Would you mind opening a PR to fiw this issue ?
Best, 
Not at all!
Thanks

Resolving patch:
diff --git a/nilearn/masking.py b/nilearn/masking.py
--- a/nilearn/masking.py
+++ b/nilearn/masking.py
@@ -337,6 +337,8 @@ def compute_multi_epi_mask(epi_imgs, lower_cutoff=0.2, upper_cutoff=0.85,
         Default=0.85.
     %(connected)s
         Default=True.
+    %(opening)s
+        Default=2.
     exclude_zeros : :obj:`bool`, optional
         Consider zeros as missing values for the computation of the
         threshold. This option is useful if the images have been


Test patch: