Repository: nilearn/nilearn

Issue:
update COBRE fetcher
A number of issues were raised with the COBRE preprocessed dataset since its integration:
- First and foremost, the dataset was too big (8 GB)
- Too many steps of the preprocessing had been fixed ("scrubbing", regression of certain confounds, etc) while this could be done easily with nilearn
- also there were some discrepancies between the ids used to name the files and the ids used in the public phenotypic data

I have prepared a new figshare release that addresses these issues:
- fMRI data is now resampled at 6 mm isotropic and encoded with 16 bit integers. Size has dropped to 620 MB.
- Data is now released with minimal preprocessing (motion correction, BOLD-T1, T1-template registration, no smoothing, no regression of confounds, no scrubbing). A spreadsheet (gzipped tabular-separated values) is released for each fMRI dataset, with a fairly comprehensive list of confounds. Those can be grabbed to run regression/scrubbing in nilearn, although some of these operations can also be done independently using nilearn tools. 
- Data come with a consolidated phenotypic_data.tsv.gz file. It includes demographics and diagnostic data, as well as measures of motion with/without scrubbing, that can be used to filter the subjects or match patients/controls based on motion levels. 

The confounds and phenotypic data are described in two separate json files. The files as well as a markdown description of the dataset (README.md) are available here https://figshare.com/articles/COBRE_preprocessed_with_NIAK_0_17_-_lightweight_release/4106844

Note that the registration of all volumes have been checked visually. An interactive report (including registration and motion) is available here
https://simexp.github.io/qc_cobre/registration.html

@KamalakerDadi could you update the cobre fetcher and companion tutorial?



Discussion:
Thanks for the updates and for new light weight data. I will definitely make time to look into this as well work on updating fetcher and companion tutorial. I will get back to you in case I have any doubts/questions.

That sounds great indeed.

> That sounds great indeed.

+1! Pretty awesome.

I'd like to change all our example to use COBRE rather than ABIDE at some
point, as the prediction of phenotype actually somewhat works on COBRE.

I should have double checked the release. Althgouh all files are listed, with the correct size, the download links are broken. I probably messed up with their upload API. I've contacted figshare support, will let you know when it works. 

So this took me much more time than I would have liked, but I finally figured out their API. The collection is now stored here: https://figshare.com/articles/COBRE_preprocessed_with_NIAK_0_17_-_lightweight_release/4197885 I checked and the "download all" works, and files are identical to what I uploaded. So I think it's now ready to go, sorry about the hicup. FYI over my university network I had download  speeds of 500k-1M/sec, so it took a good 15 mns to download the whole collection of ~150 subjects. 

The json file giving the list of download_url is no longer up to date. I think that found the proper request to figshare to get the json with the list of files: https://api.figshare.com/v2/articles/4197885
This should also work https://figshare.com/api/articles/4197885/1/files
That's probably for the version 1 of the API.
Details of the files:
1. list_files.json from new release https://figshare.com/articles/COBRE_preprocessed_with_NIAK_0_17_-_lightweight_release/4197885

the json is invalis because of this text in the beginning of the file:
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Max-Age: 3600
Content-Type: application/json; charset=UTF-8
Date: Fri, 28 Oct 2016 16:53:02 GMT
Server: nginx
Vary: Accept-Encoding
Content-Length: 139992
Connection: keep-alive

and the links to the files are wrong.

2.  “files” file from https://figshare.com/api/articles/4197885/1/files contains the information just of the part of the data
3. from https://api.figshare.com/v2/articles/4197885 has different structure  from previous release data, but is manageable.

Resolving patch:
diff --git a/nilearn/datasets/func.py b/nilearn/datasets/func.py
--- a/nilearn/datasets/func.py
+++ b/nilearn/datasets/func.py
@@ -1537,24 +1537,31 @@ def fetch_megatrawls_netmats(dimensionality=100, timeseries='eigen_regression',
 
 
 def fetch_cobre(n_subjects=10, data_dir=None, url=None, verbose=1):
-    """Fetch COBRE datasets preprocessed using NIAK 0.12.4 pipeline.
+    """Fetch COBRE datasets preprocessed using NIAK 0.17 under CentOS
+    version 6.3 with Octave version 4.0.2 and the Minc toolkit version 0.3.18.
 
-    Downloads and returns preprocessed resting state fMRI datasets and
-    phenotypic information such as demographic, clinical variables,
-    measure of frame displacement FD (an average FD for all the time
+    Downloads and returns COBRE preprocessed resting state fMRI datasets,
+    covariates and phenotypic information such as demographic, clinical
+    variables, measure of frame displacement FD (an average FD for all the time
     frames left after censoring).
 
-    For each subject, this function also returns .mat files which contains
-    all the covariates that have been regressed out of the functional data.
-    The covariates such as motion parameters, mean CSF signal, etc. It also
-    contains a list of time frames that have been removed from the time series
-    by censoring for high motion.
+    Each subject `fmri_XXXXXXX.nii.gz` is a 3D+t nifti volume (150 volumes).
+    WARNING: no confounds were actually regressed from the data, so it can be
+    done interactively by the user who will be able to explore different
+    analytical paths easily.
 
-    NOTE: The number of time samples vary, as some samples have been removed
-    if tagged with excessive motion. This means that data is already time
-    filtered. See output variable 'description' for more details.
+    For each subject, there is `fmri_XXXXXXX.tsv` files which contains the
+    covariates such as motion parameters, mean CSF signal that should to be
+    regressed out of the functional data.
 
-    .. versionadded 0.2.3
+    `keys_confounds.json`: a json file, that describes each variable mentioned
+    in the files `fmri_XXXXXXX.tsv.gz`. It also contains a list of time frames
+    that have been removed from the time series by censoring for high motion.
+
+    `phenotypic_data.tsv` contains the data of clinical variables that
+    explained in `keys_phenotypic_data.json`
+
+    .. versionadded 0.3
 
     Parameters
     ----------
@@ -1581,31 +1588,36 @@ def fetch_cobre(n_subjects=10, data_dir=None, url=None, verbose=1):
 
         - 'func': string list
             Paths to Nifti images.
-        - 'mat_files': string list
-            Paths to .mat files of each subject.
-        - 'phenotypic': ndarray
+        - 'confounds': string list
+            Paths to .tsv files of each subject, confounds.
+        - 'phenotypic': numpy.recarray
             Contains data of clinical variables, sex, age, FD.
         - 'description': data description of the release and references.
+        - 'desc_con': str
+            description of the confounds variables
+        - 'desc_phenotypic': str
+            description of the phenotypic variables.
 
     Notes
     -----
-    More information about datasets structure, See:
-    https://figshare.com/articles/COBRE_preprocessed_with_NIAK_0_12_4/1160600
+    See `more information about datasets structure
+    <https://figshare.com/articles/COBRE_preprocessed_with_NIAK_0_17_-_lightweight_release/4197885>`_
     """
+
     if url is None:
         # Here we use the file that provides URL for all others
-        url = "https://figshare.com/api/articles/1160600/15/files"
-
+        url = 'https://api.figshare.com/v2/articles/4197885'
     dataset_name = 'cobre'
     data_dir = _get_dataset_dir(dataset_name, data_dir=data_dir,
                                 verbose=verbose)
     fdescr = _get_dataset_descr(dataset_name)
 
     # First, fetch the file that references all individual URLs
-    files = _fetch_files(data_dir,
-                         [("files", url + "?offset=0&limit=300", {})],
+    files = _fetch_files(data_dir, [("4197885", url, {})],
                          verbose=verbose)[0]
+
     files = json.load(open(files, 'r'))
+    files = files['files']
     # Index files by name
     files_ = {}
     for f in files:
@@ -1613,27 +1625,24 @@ def fetch_cobre(n_subjects=10, data_dir=None, url=None, verbose=1):
     files = files_
 
     # Fetch the phenotypic file and load it
-    csv_name = 'cobre_model_group.csv'
-    csv_file = _fetch_files(
-        data_dir, [(csv_name, files[csv_name]['downloadUrl'],
-                    {'md5': files[csv_name].get('md5', None),
-                     'move': csv_name})],
+    csv_name_gz = 'phenotypic_data.tsv.gz'
+    csv_name = os.path.splitext(csv_name_gz)[0]
+    csv_file_phen = _fetch_files(
+        data_dir, [(csv_name, files[csv_name_gz]['download_url'],
+                    {'md5': files[csv_name_gz].get('md5', None),
+                     'move': csv_name_gz,
+                     'uncompress': True})],
         verbose=verbose)[0]
 
     # Load file in filename to numpy arrays
-    names = ['id', 'sz', 'age', 'sex', 'fd']
-    csv_array = np.recfromcsv(csv_file, names=names, skip_header=True)
-    # Change dtype of id and condition column
-    csv_array = csv_array.astype(
-        [('id', '|U17'),
-         ('sz', '<i8'),
-         ('age', '<f8'),
-         ('sex', '<i8'),
-         ('fd', '<f8')])
-    csv_array['id'] = np.char.strip(csv_array['id'], '" ')
+    names = ['ID', 'Current Age', 'Gender', 'Handedness', 'Subject Type',
+             'Diagnosis', 'Frames OK', 'FD', 'FD Scrubbed']
+
+    csv_array_phen = np.recfromcsv(csv_file_phen, names=names,
+                                   skip_header=True, delimiter='\t')
 
     # Check number of subjects
-    max_subjects = len(csv_array)
+    max_subjects = len(csv_array_phen)
     if n_subjects is None:
         n_subjects = max_subjects
 
@@ -1641,33 +1650,57 @@ def fetch_cobre(n_subjects=10, data_dir=None, url=None, verbose=1):
         warnings.warn('Warning: there are only %d subjects' % max_subjects)
         n_subjects = max_subjects
 
-    n_sz = int(np.ceil(float(n_subjects) / max_subjects *
-                       csv_array['sz'].sum()))
-    n_ct = int(np.floor(float(n_subjects) / max_subjects *
-                        np.logical_not(csv_array['sz']).sum()))
+    sz_count = list(csv_array_phen['subject_type']).count(b'Patient')
+    ct_count = list(csv_array_phen['subject_type']).count(b'Control')
+
+    n_sz = np.round(float(n_subjects) / max_subjects * sz_count).astype(int)
+    n_ct = np.round(float(n_subjects) / max_subjects * ct_count).astype(int)
 
     # First, restrict the csv files to the adequate number of subjects
-    sz_ids = csv_array[csv_array['sz'] == 1.]['id'][:n_sz]
-    ct_ids = csv_array[csv_array['sz'] == 0.]['id'][:n_ct]
+    sz_ids = csv_array_phen[csv_array_phen['subject_type'] ==
+                            b'Patient']['id'][:n_sz]
+    ct_ids = csv_array_phen[csv_array_phen['subject_type'] ==
+                            b'Control']['id'][:n_ct]
     ids = np.hstack([sz_ids, ct_ids])
-    csv_array = csv_array[np.in1d(csv_array['id'], ids)]
+    csv_array_phen = csv_array_phen[np.in1d(csv_array_phen['id'], ids)]
 
     # Call fetch_files once per subject.
+
     func = []
-    mat = []
+    con = []
     for i in ids:
-        f = 'fmri_' + i + '_session1_run1.nii.gz'
-        m = 'fmri_' + i + '_session1_run1_extra.mat'
-        f, m = _fetch_files(
+        f = 'fmri_00' + str(i) + '.nii.gz'
+        c_gz = 'fmri_00' + str(i) + '.tsv.gz'
+        c = os.path.splitext(c_gz)[0]
+
+        f, c = _fetch_files(
             data_dir,
-            [(f, files[f]['downloadUrl'], {'md5': files[f].get('md5', None),
-                                           'move': f}),
-             (m, files[m]['downloadUrl'], {'md5': files[m].get('md5', None),
-                                           'move': m})
+            [(f, files[f]['download_url'], {'md5': files[f].get('md5', None),
+                                            'move': f}),
+             (c, files[c_gz]['download_url'],
+              {'md5': files[c_gz].get('md5', None),
+               'move': c_gz, 'uncompress': True})
              ],
             verbose=verbose)
         func.append(f)
-        mat.append(m)
-
-    return Bunch(func=func, mat_files=mat, phenotypic=csv_array,
-                 description=fdescr)
+        con.append(c)
+
+    # Fetch the the complementary files
+    keys_con = "keys_confounds.json"
+    keys_phen = "keys_phenotypic_data.json"
+
+    csv_keys_con, csv_keys_phen = _fetch_files(
+        data_dir,
+        [(keys_con, files[keys_con]['download_url'],
+          {'md5': files[keys_con].get('md5', None), 'move': keys_con}),
+         (keys_phen, files[keys_phen]['download_url'],
+         {'md5': files[keys_phen].get('md5', None), 'move': keys_phen})
+         ],
+        verbose=verbose)
+
+    files_keys_con = open(csv_keys_con, 'r').read()
+    files_keys_phen = open(csv_keys_phen, 'r').read()
+
+    return Bunch(func=func, confounds=con, phenotypic=csv_array_phen,
+                 description=fdescr, desc_con=files_keys_con,
+                 desc_phenotypic=files_keys_phen)
diff --git a/nilearn/datasets/utils.py b/nilearn/datasets/utils.py
--- a/nilearn/datasets/utils.py
+++ b/nilearn/datasets/utils.py
@@ -328,8 +328,11 @@ def _uncompress_file(file_, delete_archive=True, verbose=1):
         processed = False
         if zipfile.is_zipfile(file_):
             z = zipfile.ZipFile(file_)
-            z.extractall(data_dir)
+            z.extractall(path=data_dir)
             z.close()
+            if delete_archive:
+                os.remove(file_)
+            file_ = filename
             processed = True
         elif ext == '.gz' or header.startswith(b'\x1f\x8b'):
             import gzip
@@ -344,17 +347,16 @@ def _uncompress_file(file_, delete_archive=True, verbose=1):
             if delete_archive:
                 os.remove(file_)
             file_ = filename
-            filename, ext = os.path.splitext(file_)
             processed = True
         if tarfile.is_tarfile(file_):
             with contextlib.closing(tarfile.open(file_, "r")) as tar:
                 tar.extractall(path=data_dir)
+            if delete_archive:
+                os.remove(file_)
             processed = True
         if not processed:
             raise IOError(
                     "[Uncompress] unknown archive file format: %s" % file_)
-        if delete_archive:
-            os.remove(file_)
         if verbose > 0:
             sys.stderr.write('.. done.\n')
     except Exception as e:
@@ -598,8 +600,8 @@ def _get_dataset_descr(ds_name):
     fname = ds_name
 
     try:
-        with open(os.path.join(module_path, 'description', fname + '.rst'))\
-                as rst_file:
+        with open(os.path.join(module_path, 'description', fname + '.rst'),
+                  'rb') as rst_file:
             descr = rst_file.read()
     except IOError:
         descr = ''


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
@@ -8,6 +8,7 @@
 import numpy as np
 import json
 import nibabel
+import gzip
 from sklearn.utils import check_random_state
 
 from nose import with_setup
@@ -107,14 +108,14 @@ def test_fetch_adhd():
 
     sub1 = [3902469, 7774305, 3699991]
     sub2 = [2014113, 4275075, 1019436,
-            3154996, 3884955,   27034,
-            4134561,   27018, 6115230,
-            27037, 8409791,   27011]
+            3154996, 3884955, 27034,
+            4134561, 27018, 6115230,
+            27037, 8409791, 27011]
     sub3 = [3007585, 8697774, 9750701,
-            10064,   21019,   10042,
+            10064, 21019, 10042,
             10128, 2497695, 4164316,
-            1552181, 4046678,   23012]
-    sub4 = [1679142, 1206380,   23008,
+            1552181, 4046678, 23012]
+    sub4 = [1679142, 1206380, 23008,
             4016887, 1418396, 2950754,
             3994098, 3520880, 1517058,
             9744150, 1562298, 3205761, 3624598]
@@ -374,6 +375,7 @@ def test_fetch_abide_pcp():
                                    quality_checked=False, verbose=0,
                                    derivatives='func_preproc')
 
+
 def test__load_mixed_gambles():
     rng = check_random_state(42)
     n_trials = 48
@@ -471,45 +473,85 @@ def test_fetch_megatrawls_netmats():
 @with_setup(setup_mock, teardown_mock)
 @with_setup(tst.setup_tmpdata, tst.teardown_tmpdata)
 def test_fetch_cobre():
-    ids_sc = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 15, 16, 21, 22, 25,
-              28, 29, 32, 34, 37, 39, 40, 41, 42, 44, 46, 47, 49, 59, 60,
-              64, 71, 72, 73, 75, 77, 78, 79, 80, 81, 82, 84, 85, 88, 89,
-              92, 94, 96, 97, 98, 99, 100, 101, 103, 105, 106, 108, 109, 110,
-              112, 117, 122, 126, 132, 133, 137, 142, 143, 145]
-    ids_con = [13, 14, 17, 18, 19, 20, 23, 24, 26, 27, 30, 31, 33, 35, 36,
-               38, 43, 45, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 61, 62,
-               63, 65, 66, 67, 68, 69, 74, 76, 86, 87, 90, 91, 93, 95, 102,
-               104, 107, 111, 113, 114, 115, 116, 118, 119, 120, 121, 123,
-               124, 125, 127, 128, 129, 130, 131, 134, 135, 136, 138, 139,
-               140, 141, 144, 146, 147]
-    ids_sch = ['szxxx0040%03d' % i for i in ids_sc]
-    ids_cont = ['contxxx0040%03d' % i for i in ids_con]
-    ids = np.asarray(ids_sch + ids_cont, dtype='|U17')
-    sz = np.asarray([i.startswith('s') for i in ids], dtype='<f8')
-    age = np.ones(len(ids), dtype='<f8')
-    sex = np.ones(len(ids), dtype='<f8')
+    ids_n = [40000, 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008,
+             40009, 40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017,
+             40018, 40019, 40020, 40021, 40022, 40023, 40024, 40025, 40026,
+             40027, 40028, 40029, 40030, 40031, 40032, 40033, 40034, 40035,
+             40036, 40037, 40038, 40039, 40040, 40041, 40042, 40043, 40044,
+             40045, 40046, 40047, 40048, 40049, 40050, 40051, 40052, 40053,
+             40054, 40055, 40056, 40057, 40058, 40059, 40060, 40061, 40062,
+             40063, 40064, 40065, 40066, 40067, 40068, 40069, 40071, 40072,
+             40073, 40074, 40075, 40076, 40077, 40078, 40079, 40080, 40081,
+             40082, 40084, 40085, 40086, 40087, 40088, 40089, 40090, 40091,
+             40092, 40093, 40094, 40095, 40096, 40097, 40098, 40099, 40100,
+             40101, 40102, 40103, 40104, 40105, 40106, 40107, 40108, 40109,
+             40110, 40111, 40112, 40113, 40114, 40115, 40116, 40117, 40118,
+             40119, 40120, 40121, 40122, 40123, 40124, 40125, 40126, 40127,
+             40128, 40129, 40130, 40131, 40132, 40133, 40134, 40135, 40136,
+             40137, 40138, 40139, 40140, 40141, 40142, 40143, 40144, 40145,
+             40146, 40147]
+
+    ids = np.asarray(ids_n, dtype='|U17')
+
+    current_age = np.ones(len(ids), dtype='<f8')
+    gender = np.ones(len(ids), dtype='<f8')
+    handedness = np.ones(len(ids), dtype='<f8')
+
+    subject_type = np.empty(len(ids), dtype="S10")
+    subject_type[0:74] = 'Control'
+    subject_type[74:146] = 'Patient'
+    diagnosis = np.ones(len(ids), dtype='<f8')
+    frames_ok = np.ones(len(ids), dtype='<f8')
     fd = np.ones(len(ids), dtype='<f8')
-    csv = np.rec.array([ids, sz, age, sex, fd],
-                       dtype=[('id', '|U17'), ('sz', '<f8'),
-                              ('age', '<f8'), ('sex', '<f8'),
-                              ('fd', '<f8')])
-    tst.mock_fetch_files.add_csv('cobre_model_group.csv', csv)
+    fd_scrubbed = np.ones(len(ids), dtype='<f8')
+
+    csv = np.rec.array([ids, current_age, gender, handedness, subject_type,
+                        diagnosis, frames_ok, fd, fd_scrubbed],
+                       dtype=[('ID', '|U17'), ('Current Age', '<f8'),
+                              ('Gender', '<f8'), ('Handedness', '<f8'),
+                              ('Subject Type', '|U17'), ('Diagnosis', '<f8'),
+                              ('Frames OK', '<f8'), ('FD', '<f8'),
+                              ('FD Scrubbed', '<f8')])
 
     # Create a dummy 'files'
     cobre_dir = os.path.join(tst.tmpdir, 'cobre')
     os.mkdir(cobre_dir)
-    dummy = os.path.join(cobre_dir, 'files')
+
+    # Create the tsv
+    name_f = os.path.join(cobre_dir, 'phenotypic_data.tsv')
+    with open(name_f, 'wb') as f:
+        header = '# {0}\n'.format('\t'.join(csv.dtype.names))
+        f.write(header.encode())
+        np.savetxt(f, csv, delimiter='\t', fmt='%s')
+
+    # create an empty gz file
+    f_in = open(name_f)
+    name_f_gz = os.path.join(cobre_dir, 'phenotypic_data.tsv.gz')
+    f_out = gzip.open(name_f_gz, 'wb')
+    f_out.close()
+    f_in.close()
+
+    dummy = os.path.join(cobre_dir, '4197885')
     dummy_data = []
-    for i in np.hstack([ids_sch, ids_cont]):
+
+    for i in np.hstack(ids_n):
         # Func file
-        f = 'fmri_' + i + '_session1_run1.nii.gz'
-        m = 'fmri_' + i + '_session1_run1_extra.mat'
-        dummy_data.append({'downloadUrl': 'whatever', 'name': f})
-        dummy_data.append({'downloadUrl': 'whatever', 'name': m})
+        f = 'fmri_00' + str(i) + '.nii.gz'
+
+        m = 'fmri_00' + str(i) + '.tsv.gz'
+        dummy_data.append({'download_url': 'whatever', 'name': f})
+        dummy_data.append({'download_url': 'whatever', 'name': m})
 
-    # Add the CSV file
+    # Add the TSV file
     dummy_data.append({
-        'downloadUrl': 'whatever', 'name': 'cobre_model_group.csv'})
+        'download_url': 'whatever', 'name': 'phenotypic_data.tsv.gz'})
+    # Add JSON files
+    dummy_data.append({
+        'download_url': 'whatever', 'name': 'keys_confounds.json'})
+    dummy_data.append({
+        'download_url': 'whatever', 'name': 'keys_phenotypic_data.json'})
+
+    dummy_data = {'files': dummy_data}
     json.dump(dummy_data, open(dummy, 'w'))
     local_url = "file://" + dummy
 
@@ -517,29 +559,28 @@ def test_fetch_cobre():
     cobre_data = func.fetch_cobre(n_subjects=None, data_dir=tst.tmpdir,
                                   url=local_url)
 
-    phenotypic_names = ['description', 'func', 'mat_files', 'phenotypic']
+    phenotypic_names = ['func', 'confounds', 'phenotypic', 'description',
+                        'desc_con', 'desc_phenotypic']
+
     # test length of functional filenames to max 146
     assert_equal(len(cobre_data.func), 146)
-    # test length of corresponding matlab files of same length to max 146
-    assert_equal(len(cobre_data.mat_files), 146)
+    # test length of corresponding confounds files of same length to max 146
+    assert_equal(len(cobre_data.confounds), 146)
     # test return type variables
-    assert_equal(sorted(cobre_data), phenotypic_names)
+    assert_equal(sorted(cobre_data), sorted(phenotypic_names))
     # test functional filenames in a list
     assert_true(isinstance(cobre_data.func, list))
-    # test matlab files in a list
-    assert_true(isinstance(cobre_data.mat_files, list))
-
+    # test confounds files in a list
+    assert_true(isinstance(cobre_data.confounds, list))
     assert_true(isinstance(cobre_data.func[0], _basestring))
     # returned phenotypic data will be an array
     assert_true(isinstance(cobre_data.phenotypic, np.recarray))
-    # data description should not be empty
-    assert_not_equal(cobre_data.description, '')
 
     # Fetch only 30 subjects
     data_30_subjects = func.fetch_cobre(n_subjects=30, url=local_url,
                                         data_dir=tst.tmpdir)
     assert_equal(len(data_30_subjects.func), 30)
-    assert_equal(len(data_30_subjects.mat_files), 30)
+    assert_equal(len(data_30_subjects.confounds), 30)
 
     # Test more than maximum subjects
     test_150_subjects = func.fetch_cobre(n_subjects=150, url=local_url,
diff --git a/nilearn/datasets/tests/test_utils.py b/nilearn/datasets/tests/test_utils.py
--- a/nilearn/datasets/tests/test_utils.py
+++ b/nilearn/datasets/tests/test_utils.py
@@ -278,11 +278,13 @@ def test_uncompress():
     # Create dummy file
     fd, temp = mkstemp()
     os.close(fd)
+
     # Create a zipfile
     dtemp = mkdtemp()
     ztemp = os.path.join(dtemp, 'test.zip')
+    ftemp = 'test'
     with contextlib.closing(zipfile.ZipFile(ztemp, 'w')) as testzip:
-        testzip.write(temp)
+        testzip.writestr(ftemp, 'test')
     datasets.utils._uncompress_file(ztemp, verbose=0)
     assert(os.path.exists(os.path.join(dtemp, temp)))
     shutil.rmtree(dtemp)
@@ -329,6 +331,7 @@ def test_fetch_file_overwrite():
     with open(fil, 'r') as fp:
         assert_equal(fp.read(), 'some content')
 
+    # Overwrite existing file.
     # Overwrite existing file.
     fil = datasets.utils._fetch_file(url='http://foo/', data_dir=tmpdir,
                                      verbose=0, overwrite=True)
@@ -338,7 +341,6 @@ def test_fetch_file_overwrite():
         assert_equal(fp.read(), '')
 
 
-
 @with_setup(setup_mock, teardown_mock)
 @with_setup(setup_tmpdata, teardown_tmpdata)
 def test_fetch_files_overwrite():