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

Issue:
test_mask_reducer failing on circle CI
testing the mask reducer from nilearn.decompositions.base sometimes fails on circleCI, e.g.
https://travis-ci.org/nilearn/nilearn/builds/583674961?utm_source=github_status&utm_medium=notification

the process gets a SIGABRT

could be due to the recent unvendoring of joblib, although this error started more recently

so far I haven't been able to reproduce this locally


Discussion:
actually it seems to be due to an issue with intel openmp 2019.5:

https://github.com/ContinuumIO/anaconda-issues/issues/11294

https://github.com/scikit-learn/scikit-learn/pull/15020/files

and here is the fix used by scikit-learn:

https://github.com/scikit-learn/scikit-learn/blob/6bd8df099f37205864eab1759f77b6070577f6e7/sklearn/__init__.py#L63

Resolving patch:
diff --git a/nilearn/__init__.py b/nilearn/__init__.py
--- a/nilearn/__init__.py
+++ b/nilearn/__init__.py
@@ -35,11 +35,17 @@
 import gzip
 import sys
 import warnings
+import os
 
 from distutils.version import LooseVersion
 
 from .version import _check_module_dependencies, __version__
 
+# Workaround issue discovered in intel-openmp 2019.5:
+# https://github.com/ContinuumIO/anaconda-issues/issues/11294
+#
+# see also https://github.com/scikit-learn/scikit-learn/pull/15020
+os.environ.setdefault("KMP_INIT_AT_FORK", "FALSE")
 
 def _py2_deprecation_warning():
     py2_warning = ('Python2 support is deprecated and will be removed in '


Test patch:
Repository: nilearn/nilearn

Issue:
expose useful _plot_img_with_bg kwargs explicitly in plotting.plot_img
`plotting.plot_img` helpfully forwards kwargs, and in particular `bg_img`, to
`plotting.img_plotting._plot_img_with_bg`.

However the docstring says kwargs are passed to `pyplot.imshow`.

I would suggest exposing important arguments such as vmin, vmax and bg_img
explicitly in the function signature.

note that this example:

http://nilearn.github.io/auto_examples/02_decoding/plot_haxby_searchlight.html#sphx-glr-auto-examples-02-decoding-plot-haxby-searchlight-py

uses the `bg_img` kwarg


Discussion:
+1

> +1

then I'll open a PR


Resolving patch:
diff --git a/nilearn/plotting/img_plotting.py b/nilearn/plotting/img_plotting.py
--- a/nilearn/plotting/img_plotting.py
+++ b/nilearn/plotting/img_plotting.py
@@ -232,7 +232,8 @@ def _crop_colorbar(cbar, cbar_vmin, cbar_vmax):
 def plot_img(img, cut_coords=None, output_file=None, display_mode='ortho',
              figure=None, axes=None, title=None, threshold=None,
              annotate=True, draw_cross=True, black_bg=False, colorbar=False,
-             resampling_interpolation='continuous', **kwargs):
+             resampling_interpolation='continuous',
+             bg_img=None, vmin=None, vmax=None, **kwargs):
     """ Plot cuts of a given image (by default Frontal, Axial, and Lateral)
 
         Parameters
@@ -290,6 +291,14 @@ def plot_img(img, cut_coords=None, output_file=None, display_mode='ortho',
             space. Can be "continuous" (default) to use 3rd-order spline
             interpolation, or "nearest" to use nearest-neighbor mapping.
             "nearest" is faster but can be noisier in some cases.
+        bg_img : Niimg-like object, optional
+            See http://nilearn.github.io/manipulating_images/input_output.html
+            The background image that the ROI/mask will be plotted on top of.
+            If nothing is specified, no background image is plotted.
+        vmin : float, optional
+            lower bound of the colormap. If `None`, the min of the image is used.
+        vmax : float, optional
+            upper bound of the colormap. If `None`, the max of the image is used.
         kwargs: extra keyword arguments, optional
             Extra keyword arguments passed to matplotlib.pyplot.imshow
     """  # noqa: E501
@@ -300,7 +309,8 @@ def plot_img(img, cut_coords=None, output_file=None, display_mode='ortho',
         threshold=threshold, annotate=annotate,
         draw_cross=draw_cross,
         resampling_interpolation=resampling_interpolation,
-        black_bg=black_bg, colorbar=colorbar, **kwargs)
+        black_bg=black_bg, colorbar=colorbar,
+        bg_img=bg_img, vmin=vmin, vmax=vmax, **kwargs)
 
     return display
 


Test patch:
Repository: nilearn/nilearn

Issue:
import htmldocument in js_plotting_utils
HTMLDocument has moved from js_plotting_utils to reporting. We should probably import it in its former module for backward compatibility


Discussion:
Good catch. Should attend to this before releasing. Will do.

Resolving patch:
diff --git a/nilearn/plotting/js_plotting_utils.py b/nilearn/plotting/js_plotting_utils.py
--- a/nilearn/plotting/js_plotting_utils.py
+++ b/nilearn/plotting/js_plotting_utils.py
@@ -12,6 +12,9 @@
 import numpy as np
 from matplotlib import cm as mpl_cm
 
+# included here for backward compatibility
+from nilearn.reporting.html_document import (
+    HTMLDocument, set_max_img_views_before_warning,)  # noqa
 from .._utils.extmath import fast_abs_percentile
 from .._utils.param_validation import check_threshold
 from .. import surface


Test patch:
diff --git a/nilearn/plotting/tests/test_js_plotting_utils.py b/nilearn/plotting/tests/test_js_plotting_utils.py
--- a/nilearn/plotting/tests/test_js_plotting_utils.py
+++ b/nilearn/plotting/tests/test_js_plotting_utils.py
@@ -309,3 +309,8 @@ def test_to_color_strings():
     colors = ['#0000ffff', '#ff0000ab', '#7f7f7f00']
     as_str = js_plotting_utils.to_color_strings(colors)
     assert as_str == ['#0000ff', '#ff0000', '#7f7f7f']
+
+
+def test_import_html_document_from_js_plotting():
+    from nilearn.plotting.js_plotting_utils import (
+        HTMLDocument, set_max_img_views_before_warning)  #noqa
Repository: nilearn/nilearn

Issue:
remove is_valid from default neurovault filters?
by default the neurovault fetcher ignores images that have their `is_valid` metadata field cleared. I'm not sure what sets this, but some useful collections such as hcp (id 4337) seem to not be "valid".

should we remove this filter?


Discussion:
I think so.

Resolving patch:
diff --git a/nilearn/datasets/neurovault.py b/nilearn/datasets/neurovault.py
--- a/nilearn/datasets/neurovault.py
+++ b/nilearn/datasets/neurovault.py
@@ -2080,13 +2080,12 @@ def basic_image_terms():
     true:
 
         - It is not in MNI space.
-        - Its metadata field "is_valid" is cleared.
         - It is thresholded.
         - Its map type is one of "ROI/mask", "anatomical", or "parcellation".
         - Its image type is "atlas"
 
     """
-    return {'not_mni': False, 'is_valid': True, 'is_thresholded': False,
+    return {'not_mni': False, 'is_thresholded': False,
             'map_type': NotIn('ROI/mask', 'anatomical', 'parcellation'),
             'image_type': NotEqual('atlas')}
 


Test patch:
Repository: nilearn/nilearn

Issue:
Pip installing Nilearn 0.6.0a0 in Py2 envs
Not sure why, installing Nilearn 06.0a0 in a Python2environment does not raise an error. This is strange, since the wheels I build this time are not universal and I removed Python 2 tags. Maybe something was overlooked? Will look at this.


Discussion:
It seems that `setup.cfg` has the configuration option set to always build universal wheels, which is what created this problem. I will change the option and create a new wheel to test. Question is whether to release a new alpha or not for this, or defer it until the beta which I expect to be released in about a month.

Resolving patch:
diff --git a/nilearn/version.py b/nilearn/version.py
--- a/nilearn/version.py
+++ b/nilearn/version.py
@@ -21,7 +21,7 @@
 # Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
 # 'X.Y.dev0' is the canonical version of 'X.Y.dev'
 #
-__version__ = '0.6.0a'
+__version__ = '0.6.0b'
 
 _NILEARN_INSTALL_MSG = 'See %s for installation information.' % (
     'http://nilearn.github.io/introduction.html#installation')
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -96,4 +96,6 @@ def is_installing():
                         'nilearn.datasets.tests.data': ['*.*'],
                         'nilearn.datasets.description': ['*.rst'],
                         'nilearn.reporting.data.html': ['*.html']},
-          install_requires=install_requires,)
+          install_requires=install_requires,
+          python_requires='>=3.5',
+          )


Test patch:
Repository: nilearn/nilearn

Issue:
Strange comment in ICA example
This is the comment:
# XXX: must get the code to run for more than 1 subject
And this is the link to the example:
https://nilearn.github.io/auto_examples/05_advanced/plot_ica_resting_state.html

The comment appears to relate to an internal todo rather than comment/instruction to users.


Discussion:

Resolving patch:
diff --git a/examples/05_advanced/plot_ica_resting_state.py b/examples/05_advanced/plot_ica_resting_state.py
--- a/examples/05_advanced/plot_ica_resting_state.py
+++ b/examples/05_advanced/plot_ica_resting_state.py
@@ -23,9 +23,7 @@
 #####################################################################
 # Load movie watching dataset
 from nilearn import datasets
-# Here we use only single subject to get faster-running code. For better
-# results, simply increase this number
-# XXX: must get the code to run for more than 1 subject
+# Here we use only single subject to get faster-running code.
 dataset = datasets.fetch_development_fmri(n_subjects=1)
 func_filename = dataset.func[0]
 
@@ -45,10 +43,6 @@
                      mask_strategy='epi', standardize=True)
 data_masked = masker.fit_transform(func_filename)
 
-# Concatenate all the subjects
-# fmri_data = np.concatenate(data_masked, axis=1)
-fmri_data = data_masked
-
 
 #####################################################################
 # Apply ICA


Test patch:
Repository: nilearn/nilearn

Issue:
Add Binder links to examples
<!--
Hi! 
If you have: 
 -1 Questions about how to use Nilearn or 
 -2 Need analysis suggestions & recommendations?

A bunch of fMRI researchers hang out at Neurostars (http://neurostars.org/). 
Post those questions there. 
Add the tag `nilearn` (we get an email from Neurostars if you do).

Posting them here makes life more complicated for the Nilearn developers.  
-->

<!-- 
For the Feature Request,
Include the following:
------------------------
What would you like changed/added and why?
What would be the benefit? Does the change make something easier to use?
Clarifies something?
If it is a new feature, what is the benefit? 
-->

I just noticed that the sklearn documentation includes Binder links (for example, [here](https://scikit-learn.org/stable/auto_examples/linear_model/plot_lasso_and_elasticnet.html#sphx-glr-auto-examples-linear-model-plot-lasso-and-elasticnet-py)). It'd be great to have these in Nilearn as well, so users could run our examples on Binder !

I can open a PR if that's of interest :smile_cat: I'll plan to build off https://github.com/scikit-learn/scikit-learn/pull/11221 and a few updates that it looks like have been [merged since then](https://github.com/scikit-learn/scikit-learn/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aclosed+binder).



Discussion:
DO IT DO IT DO IT DO IT
No opinion on that, since I'm not using Binder, but if people like it, I'm fine with it.
+1. Go for it. Sphinx-gallery has support for this (if you struggle understand the sphinx-gallery docs on this, please submit PR/suggestions on how to improve it).

Thanks!!!!

Resolving patch:
diff --git a/doc/conf.py b/doc/conf.py
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -302,7 +302,18 @@
     'backreferences_dir': os.path.join('modules', 'generated'),
     'reference_url': {'nilearn': None},
     'junit': '../test-results/sphinx-gallery/junit.xml',
+    'examples_dirs': '../examples',
+    'gallery_dirs': 'auto_examples',
+    'binder': {
+        'org': 'nilearn',
+        'repo': 'nilearn.github.io',
+        'binderhub_url': 'https://mybinder.org',
+        'branch': 'master',
+        'dependencies': ['../requirements-build-docs.txt',
+                         'binder/requirements.txt'],
+        'notebooks_dir': 'examples'
     }
+}
 
 # Get rid of spurious warnings due to some interaction between
 # autosummary and numpydoc. See
@@ -310,6 +321,7 @@
 # details
 numpydoc_show_class_members = False
 
+
 def touch_example_backreferences(app, what, name, obj, options, lines):
     # generate empty examples files, so that we don't get
     # inclusion errors if there are no examples for a class / module


Test patch:
Repository: nilearn/nilearn

Issue:
Deprecate fetch_nyu_rest
This dataset is not preprocessed, and it leads to people doing mistakes. We don't use it in our examples. We should deprecate it.

Related to #330


Discussion:
Anyone watching the repo interesting in working on this one? It's an easy one.
Maybe @danjgale would be interested ?
Thanks for the tag @emdupre. Pretty swamped right now, but I *am* interested. Just not sure what kind of timeline I can give for it
> Thanks for the tag @emdupre. Pretty swamped right now, but I am interested.

No huge hurry!

Thanks a lot!



Resolving patch:
diff --git a/nilearn/datasets/func.py b/nilearn/datasets/func.py
--- a/nilearn/datasets/func.py
+++ b/nilearn/datasets/func.py
@@ -250,6 +250,9 @@ def fetch_nyu_rest(n_subjects=None, sessions=[1], data_dir=None, resume=True,
                    verbose=1):
     """Download and loads the NYU resting-state test-retest dataset.
 
+    NOTE: This function is deprecated and will be removed in the 0.8.x
+    release, due to lack of preprocessing.
+
     Parameters
     ----------
     n_subjects: int, optional
@@ -325,6 +328,10 @@ def fetch_nyu_rest(n_subjects=None, sessions=[1], data_dir=None, resume=True,
           F.X. Castellanos, M.P. Milham
 
     """
+    warnings.warn("fetch_nyu_rest has been deprecated and will "
+                  "be removed in the 0.8.x release.",
+                  VisibleDeprecationWarning, stacklevel=2)
+
     fa1 = 'http://www.nitrc.org/frs/download.php/1071/NYU_TRT_session1a.tar.gz'
     fb1 = 'http://www.nitrc.org/frs/download.php/1072/NYU_TRT_session1b.tar.gz'
     fa2 = 'http://www.nitrc.org/frs/download.php/1073/NYU_TRT_session2a.tar.gz'


Test patch:
diff --git a/nilearn/datasets/tests/test_func.py b/nilearn/datasets/tests/test_func.py
--- a/nilearn/datasets/tests/test_func.py
+++ b/nilearn/datasets/tests/test_func.py
@@ -134,7 +134,9 @@ def test_fetch_haxby(tmp_path, request_mocker):
 
 def test_fetch_nyu_rest(tmp_path, request_mocker):
     # First session, all subjects
-    nyu = func.fetch_nyu_rest(data_dir=str(tmp_path), verbose=0)
+    with pytest.warns(np.VisibleDeprecationWarning,
+                      match='fetch_nyu_rest has been deprecated'):
+        nyu = func.fetch_nyu_rest(data_dir=str(tmp_path), verbose=0)
     assert len(tst.mock_url_request.urls) == 2
     assert len(nyu.func) == 25
     assert len(nyu.anat_anon) == 25
@@ -143,8 +145,11 @@ def test_fetch_nyu_rest(tmp_path, request_mocker):
 
     # All sessions, 12 subjects
     tst.mock_url_request.reset()
-    nyu = func.fetch_nyu_rest(data_dir=str(tmp_path), sessions=[1, 2, 3],
-                              n_subjects=12, verbose=0)
+    with pytest.warns(np.VisibleDeprecationWarning,
+                      match='fetch_nyu_rest has been deprecated'):
+        nyu = func.fetch_nyu_rest(data_dir=str(tmp_path), 
+                                  sessions=[1, 2, 3],
+                                  n_subjects=12, verbose=0)
     # Session 1 has already been downloaded
     assert len(tst.mock_url_request.urls) == 2
     assert len(nyu.func) == 36
Repository: nilearn/nilearn

Issue:
plot_surf_stat_map fails for maps provided as path to files
`load_surf_data` should be used to load the map before passing it to `_get_colorbar_and_data_ranges`. docstring says passing a path is supported

reproduce with:
```
from nilearn import datasets, plotting

fsavg = datasets.fetch_surf_fsaverage()
plotting.plot_surf_stat_map(fsavg["infl_left"], fsavg["sulc_left"])
```


Discussion:

Resolving patch:
diff --git a/nilearn/plotting/surf_plotting.py b/nilearn/plotting/surf_plotting.py
--- a/nilearn/plotting/surf_plotting.py
+++ b/nilearn/plotting/surf_plotting.py
@@ -574,13 +574,15 @@ def plot_surf_stat_map(surf_mesh, stat_map, bg_map=None,
     nilearn.plotting.plot_surf: For brain surface visualization.
     """
 
+    loaded_stat_map = load_surf_data(stat_map)
+
     # Call _get_colorbar_and_data_ranges to derive symmetric vmin, vmax
     # And colorbar limits depending on symmetric_cbar settings
     cbar_vmin, cbar_vmax, vmin, vmax = _get_colorbar_and_data_ranges(
-        stat_map, vmax, symmetric_cbar, kwargs)
+        loaded_stat_map, vmax, symmetric_cbar, kwargs)
 
     display = plot_surf(
-        surf_mesh, surf_map=stat_map, bg_map=bg_map, hemi=hemi, view=view,
+        surf_mesh, surf_map=loaded_stat_map, bg_map=bg_map, hemi=hemi, view=view,
         avg_method='mean', threshold=threshold, cmap=cmap, colorbar=colorbar,
         alpha=alpha, bg_on_data=bg_on_data, darkness=darkness, vmax=vmax,
         vmin=vmin, title=title, output_file=output_file, axes=axes,


Test patch:
Repository: nilearn/nilearn

Issue:
Possible identical design matrix columns with generate_fake_fmri_data_and_design
**Description**

The function `generate_fake_fmri_data_and_design` can return design matrices with identically named columns because these names (letters) are randomly sampled using the numpy `choice`  function which does sampling with replacement by default:

https://github.com/nilearn/nilearn/blob/55e3f26dbd9fc6e89516e5f37e8aae23ec6086a9/nilearn/_utils/data_gen.py#L344

This is causing the recently added test `test_high_level_glm_different_design_matrices_formulas` to fail in a random fashion because it computes contrast of the form "a-a" (see current master failure for instance...).

**Proposed fix**

Do sampling without replacement to avoid this.


Discussion:

Resolving patch:
diff --git a/nilearn/_utils/data_gen.py b/nilearn/_utils/data_gen.py
--- a/nilearn/_utils/data_gen.py
+++ b/nilearn/_utils/data_gen.py
@@ -341,7 +341,9 @@ def generate_fake_fmri_data_and_design(shapes, rk=3, affine=np.eye(4)):
         data = np.random.randn(*shape)
         data[1:-1, 1:-1, 1:-1] += 100
         fmri_data.append(Nifti1Image(data, affine))
-        columns = np.random.choice(list(string.ascii_lowercase), size=rk)
+        columns = np.random.choice(list(string.ascii_lowercase),
+                                   size=rk,
+                                   replace=False)
         design_matrices.append(pd.DataFrame(np.random.randn(shape[3], rk),
                                             columns=columns))
     mask = Nifti1Image((np.random.rand(*shape[:3]) > .5).astype(np.int8),


Test patch:
Repository: nilearn/nilearn

Issue:
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getiterator'
With Python 3.9+:

```python
from nilearn.datasets import fetch_atlas_aal
aal = fetch_atlas_aal()
```
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nicolas/anaconda3/envs/py39/lib/python3.9/site-packages/nilearn/datasets/atlas.py", line 804, in fetch_atlas_aal
    for label in root.getiterator('label'):
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getiterator'
```

See discussion on [Neurostars](https://neurostars.org/t/mapping-voxel-number-to-brain-region/18422/4).


Discussion:

Resolving patch:
diff --git a/nilearn/datasets/atlas.py b/nilearn/datasets/atlas.py
--- a/nilearn/datasets/atlas.py
+++ b/nilearn/datasets/atlas.py
@@ -795,13 +795,12 @@ def fetch_atlas_aal(version='SPM12', data_dir=None, url=None, resume=True,
                                           verbose=verbose)
 
     fdescr = _get_dataset_descr(dataset_name)
-
     # We return the labels contained in the xml file as a dictionary
     xml_tree = xml.etree.ElementTree.parse(labels_file)
     root = xml_tree.getroot()
     labels = []
     indices = []
-    for label in root.getiterator('label'):
+    for label in root.iter('label'):
         indices.append(label.find('index').text)
         labels.append(label.find('name').text)
 


Test patch:
Repository: nilearn/nilearn

Issue:
Use bibtex in nilearn/decoding
Convert references in `nilearn/decoding/decoder.py` to use footcite / footbibliography 
See #2759 


Discussion:
keen to work on this
Thanks @Craskermasker !

Resolving patch:
diff --git a/nilearn/decoding/decoder.py b/nilearn/decoding/decoder.py
--- a/nilearn/decoding/decoder.py
+++ b/nilearn/decoding/decoder.py
@@ -1092,7 +1092,7 @@ class FREMRegressor(_BaseDecoder):
     FREM uses an implicit spatial regularization through fast clustering and
     aggregates a high number of estimators trained on various splits of the
     training set, thus returning a very robust decoder at a lower computational
-    cost than other spatially regularized methods.[1]_.
+    cost than other spatially regularized methods :footcite:`HOYOSIDROBO2018160`.
 
     Parameters
     -----------
@@ -1205,10 +1205,7 @@ class FREMRegressor(_BaseDecoder):
 
     References
     ----------
-    * A. Hoyos-Idrobo, G. Varoquaux, J. Kahn and B. Thirion, "FReM –
-      scalable and stable decoding with fast regularized ensemble of models"
-      in NeuroImage, Elsevier, 2017  pp.1-16, 11 October 2017.
-      https://hal.archives-ouvertes.fr/hal-01615015/
+    .. footbibliography::
 
     See Also
     ------------
@@ -1247,7 +1244,7 @@ class FREMClassifier(_BaseDecoder):
     FREM uses an implicit spatial regularization through fast clustering and
     aggregates a high number of estimators trained on various splits of the
     training set, thus returning a very robust decoder at a lower computational
-    cost than other spatially regularized methods.[1]_.
+    cost than other spatially regularized methods :footcite:`HOYOSIDROBO2018160`.
 
     Parameters
     -----------
@@ -1361,10 +1358,7 @@ class FREMClassifier(_BaseDecoder):
 
     References
     ----------
-    * A. Hoyos-Idrobo, G. Varoquaux, J. Kahn and B. Thirion, "FReM –
-      scalable and stable decoding with fast regularized ensemble of models"
-      in NeuroImage, Elsevier, 2017  pp.1-16, 11 October 2017.
-      https://hal.archives-ouvertes.fr/hal-01615015/
+    .. footbibliography::
 
     See Also
     ------------


Test patch:
Repository: nilearn/nilearn

Issue:
Use bibtex in nilearn/plotting
Convert references in `nilearn/plotting/img_plotting.py` to use footcite / footbibliography.
See #2759 


Discussion:
I'd like to take care of this one as my first contribution. Thanks!

Resolving patch:
diff --git a/nilearn/plotting/img_plotting.py b/nilearn/plotting/img_plotting.py
--- a/nilearn/plotting/img_plotting.py
+++ b/nilearn/plotting/img_plotting.py
@@ -1979,16 +1979,14 @@ def plot_carpet(img, mask_img=None, mask_labels=None,
 
     Notes
     -----
-    This figure was originally developed in [1]_.
+    This figure was originally developed in :footcite:`POWER2017150`.
 
     In cases of long acquisitions (>800 volumes), the data will be downsampled
     to have fewer than 800 volumes before being plotted.
 
     References
     ----------
-    .. [1] Power, J. D. (2017). A simple but useful way to assess fMRI scan
-            qualities. Neuroimage, 154, 150-158. doi:
-            https://doi.org/10.1016/j.neuroimage.2016.08.009
+    .. footbibliography::
 
     """
     img = _utils.check_niimg_4d(img, dtype='auto')


Test patch: