# Path: cogspaces/datasets/derivative.py
# def fetch_atlas_modl(data_dir=None,
#                      url=None,
#                      resume=True, verbose=1):
#     """Download and load a multi-scale atlas computed using MODL over HCP900.
# 
#     Parameters
#     ----------
#     data_dir: string, optional
#         Path of the data directory. Used to force data storage in a non-
#         standard location. Default: None (meaning: default)
#     url: string, optional
#         Download URL of the dataset. Overwrite the default URL.
#     """
# 
#     if url is None:
#         url = 'http://cogspaces.github.io/assets/data/modl/'
# 
#     data_dir = get_data_dir(data_dir)
#     dataset_name = 'modl'
#     data_dir = _get_dataset_dir(dataset_name, data_dir=data_dir,
#                                 verbose=verbose)
# 
#     keys = ['components_64',
#             'components_128',
#             'components_453_gm',
#             'loadings_128_gm'
#             ]
# 
#     paths = [
#         'components_64.nii.gz',
#         'components_128.nii.gz',
#         'components_453_gm.nii.gz',
#         'loadings_128_gm.npy',
#     ]
#     urls = [url + path for path in paths]
#     files = [(path, url, {}) for path, url in zip(paths, urls)]
# 
#     files = _fetch_files(data_dir, files, resume=resume,
#                          verbose=verbose)
# 
#     params = {key: file for key, file in zip(keys, files)}
# 
#     fdescr = 'Components computed using the MODL package, at various scale,' \
#              'from HCP900 data'
# 
#     params['description'] = fdescr
#     params['data_dir'] = data_dir
# 
#     return Bunch(**params)
# 
# def fetch_mask(data_dir=None, url=None, resume=True, verbose=1):
#     if url is None:
#         url = 'http://cogspaces.github.io/assets/data/hcp_mask.nii.gz'
#     files = [('hcp_mask.nii.gz', url, {})]
# 
#     dataset_name = 'mask'
#     data_dir = get_data_dir(data_dir)
#     dataset_dir = _get_dataset_dir(dataset_name, data_dir=data_dir,
#                                    verbose=verbose)
#     files = _fetch_files(dataset_dir, files, resume=resume,
#                          verbose=verbose)
#     return files[0]


import numpy as np
import torch
from nilearn.input_data import NiftiMasker
from cogspaces.datasets import fetch_atlas_modl, fetch_mask
        module.eval()

        studies = module.classifiers.keys()
        in_features = module.embedder.in_features

        with torch.no_grad():
            classifs = module({study: torch.eye(in_features)
                               for study in studies}, logits=True)
            biases = module({study: torch.zeros((1, in_features))
                             for study in studies}, logits=True)
            classifs = {study: classifs[study] - biases[study]
                        for study in studies}
            classifs = {study: classif - classif.mean(dim=0, keepdim=True)
                        for study, classif in classifs.items()}
        classifs = {study: classif.numpy().T
                    for study, classif in classifs.items()}

    elif config['model']['estimator'] == 'logistic':
        classifs = estimator.coef_
    else:
        raise ValueError('Wrong config file')

    if standard_scaler is not None:
        for study, classif in classifs.items():
            sc = standard_scaler.scs_[study]
            classifs[study] = classif / sc.scale_[None, :]

    if config['data']['reduced']:
        mask = fetch_mask()
        masker = NiftiMasker(mask_img=mask).fit()

# Path: cogspaces/datasets/derivative.py
# def fetch_atlas_modl(data_dir=None,
#                      url=None,
#                      resume=True, verbose=1):
#     """Download and load a multi-scale atlas computed using MODL over HCP900.
# 
#     Parameters
#     ----------
#     data_dir: string, optional
#         Path of the data directory. Used to force data storage in a non-
#         standard location. Default: None (meaning: default)
#     url: string, optional
#         Download URL of the dataset. Overwrite the default URL.
#     """
# 
#     if url is None:
#         url = 'http://cogspaces.github.io/assets/data/modl/'
# 
#     data_dir = get_data_dir(data_dir)
#     dataset_name = 'modl'
#     data_dir = _get_dataset_dir(dataset_name, data_dir=data_dir,
#                                 verbose=verbose)
# 
#     keys = ['components_64',
#             'components_128',
#             'components_453_gm',
#             'loadings_128_gm'
#             ]
# 
#     paths = [
#         'components_64.nii.gz',
#         'components_128.nii.gz',
#         'components_453_gm.nii.gz',
#         'loadings_128_gm.npy',
#     ]
#     urls = [url + path for path in paths]
#     files = [(path, url, {}) for path, url in zip(paths, urls)]
# 
#     files = _fetch_files(data_dir, files, resume=resume,
#                          verbose=verbose)
# 
#     params = {key: file for key, file in zip(keys, files)}
# 
#     fdescr = 'Components computed using the MODL package, at various scale,' \
#              'from HCP900 data'
# 
#     params['description'] = fdescr
#     params['data_dir'] = data_dir
# 
#     return Bunch(**params)
# 
# def fetch_mask(data_dir=None, url=None, resume=True, verbose=1):
#     if url is None:
#         url = 'http://cogspaces.github.io/assets/data/hcp_mask.nii.gz'
#     files = [('hcp_mask.nii.gz', url, {})]
# 
#     dataset_name = 'mask'
#     data_dir = get_data_dir(data_dir)
#     dataset_dir = _get_dataset_dir(dataset_name, data_dir=data_dir,
#                                    verbose=verbose)
#     files = _fetch_files(dataset_dir, files, resume=resume,
#                          verbose=verbose)
#     return files[0]


# Path: cogspaces/report.py
import numpy as np
import torch
from nilearn.input_data import NiftiMasker
from cogspaces.datasets import fetch_atlas_modl, fetch_mask

        module.eval()

        studies = module.classifiers.keys()
        in_features = module.embedder.in_features

        with torch.no_grad():
            classifs = module({study: torch.eye(in_features)
                               for study in studies}, logits=True)
            biases = module({study: torch.zeros((1, in_features))
                             for study in studies}, logits=True)
            classifs = {study: classifs[study] - biases[study]
                        for study in studies}
            classifs = {study: classif - classif.mean(dim=0, keepdim=True)
                        for study, classif in classifs.items()}
        classifs = {study: classif.numpy().T
                    for study, classif in classifs.items()}

    elif config['model']['estimator'] == 'logistic':
        classifs = estimator.coef_
    else:
        raise ValueError('Wrong config file')

    if standard_scaler is not None:
        for study, classif in classifs.items():
            sc = standard_scaler.scs_[study]
            classifs[study] = classif / sc.scale_[None, :]

    if config['data']['reduced']:
        mask = fetch_mask()
        masker = NiftiMasker(mask_img=mask).fit()

        modl_atlas = fetch_atlas_modl()