Repository: nilearn/nilearn

Issue:
Dataset Error with Nilearn Tutorial:  8.1.3. 3D and 4D niimgs: handling and visualizing
Hi Nilearn Experts,

Working through the Tutorials currently on: 8.1.3. 3D and 4D niimgs: handling and visualizing. Seems like the line:

rsn = datasets.fetch_atlas_smith_2009()['rsn10']

Is not downloading the correct file- this download resulted in a 3KB file that cannot be opened in FSLview instead of a larger 4D file.

Upon later calling rsn with this command: print(image.load_img(rsn).shape) I receive the error below.

Thanks,
Aki

---

ImageFileError                            Traceback (most recent call last)
<ipython-input-61-869ff9e7d33e> in <module>()
      1 #!pwd
----> 2 print(image.load_img(rsn).shape)
      3 #nib.load(rsn).get_data().shape
      4 #hello = 2
      5 #print(hello)

/Users/Aki/.local/lib/python2.7/site-packages/nilearn/image/image.pyc in load_img(img, wildcards, dtype)
    899         that the returned object has get_data() and get_affine() methods.
    900     """
--> 901     return check_niimg(img, wildcards=wildcards, dtype=dtype)

/Users/Aki/.local/lib/python2.7/site-packages/nilearn/_utils/niimg_conversions.pyc in check_niimg(niimg, ensure_ndim, atleast_4d, dtype, return_iterator, wildcards)
    269 
    270     # Otherwise, it should be a filename or a SpatialImage, we load it
--> 271     niimg = load_niimg(niimg, dtype=dtype)
    272 
    273     if ensure_ndim == 3 and len(niimg.shape) == 4 and niimg.shape[3] == 1:

/Users/Aki/.local/lib/python2.7/site-packages/nilearn/_utils/niimg.pyc in load_niimg(niimg, dtype)
     98     if isinstance(niimg, _basestring):
     99         # data is a filename, we load it
--> 100         niimg = nibabel.load(niimg)
    101     elif not isinstance(niimg, nibabel.spatialimages.SpatialImage):
    102         raise TypeError("Data given cannot be loaded because it is"

/Users/Aki/.local/lib/python2.7/site-packages/nibabel/loadsave.pyc in load(filename, **kwargs)
     46 
     47     raise ImageFileError('Cannot work out file type of "%s"' %
---> 48                          filename)
     49 
     50 

ImageFileError: Cannot work out file type of "/Users/Aki/nilearn_data/smith_2009/PNAS_Smith09_rsn10.nii.gz"



Discussion:
Hey Aki,

Most of the time, this error is due to the fact that the file was downloaded on a website that requires authentication. So, what is downloaded is the login page of the network. You can check that by opening the file with your favorite text editor.

Let me know if it is the case. If so, I will add a check in Nilearn to circumvent it.

s/website/network/ (I cannot edit comment on my phone)

May be we should fetch from nitrc mirror='nitrc' ?

+1

On Tue, Oct 11, 2016 at 06:23:48AM -0700, KamalakerDadi wrote:

> May be we should fetch from nitrc mirror='nitrc' ?
> 
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub, or mute the thread.*

## 

```
Gael Varoquaux
Researcher, INRIA Parietal
NeuroSpin/CEA Saclay , Bat 145, 91191 Gif-sur-Yvette France
Phone:  ++ 33-1-69-08-79-68
http://gael-varoquaux.info            http://twitter.com/GaelVaroquaux
```

Thanks Alex,

You're right- Looks like it downloaded the webpage- first few lines are pasted below-

Thanks,
Aki

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<TITLE>BrainMap + RSNs</TITLE></HEAD><BODY>

<STYLE TYPE="text/css">BODY { background: white ; font-family: 'Arial'}</STYLE>

<br><hr>
<img align=right width="30%" src="bm.jpg" /> 

<H2>Correspondence between BrainMap and Resting-FMRI ICA components</H2>

A collaboration between FMRIB, Oxford and RIC, San Antonio<br>


Resolving patch:
diff --git a/nilearn/datasets/atlas.py b/nilearn/datasets/atlas.py
--- a/nilearn/datasets/atlas.py
+++ b/nilearn/datasets/atlas.py
@@ -418,11 +418,11 @@ def fetch_atlas_smith_2009(data_dir=None, mirror='origin', url=None,
     Notes
     -----
     For more information about this dataset's structure:
-    http://www.fmrib.ox.ac.uk/analysis/brainmap+rsns/
+    http://www.fmrib.ox.ac.uk/datasets/brainmap+rsns/
     """
     if url is None:
         if mirror == 'origin':
-            url = "http://www.fmrib.ox.ac.uk/analysis/brainmap+rsns/"
+            url = "http://www.fmrib.ox.ac.uk/datasets/brainmap+rsns/"
         elif mirror == 'nitrc':
             url = [
                     'https://www.nitrc.org/frs/download.php/7730/',


Test patch: