Repository: nilearn/nilearn

Issue:
Is DictLearning correctly implementing Varoquaux et al. 2011?
**Edit**: In my initial search I did not notice #1323, which answers my question

I apologize in advance if this not the right forum for asking general questions about nilearn functions, but I couldn’t find a general mailing list.

I have been trying to use the DictLearning class to identify components of a dataset, as performed in Varoquaux et al. 2011. The algorithm described in that paper identifies subject- and group–level spatial maps. However, DictLearning only estimates a single set of components. Taking a closer look at the code, it appears that the decomposition is performed directly by dict_learning_online from sklearn.decomposition. 

`  self.components_, _ = self._cache(dict_learning_online)(
            data.T, self.n_components, alpha=self.alpha, n_iter=n_iter,
            batch_size=self.batch_size, method=self.method,
            dict_init=dict_init, verbose=max(0, self.verbose - 1),
            random_state=self.random_state, return_code=True, shuffle=True,
            n_jobs=1)`

As far as I can tell from the documentation, dict_learning_online does not implement the “two-level” decomposition described in Varoquaux et al 2011, but rather a mini-batch version of (single-level) dictionary learning.

So am I misunderstanding something or is DictLearning not implementing the algorithm described in Varoquaux et al 2011? Could someone perhaps clarify this for me?

Gael Varoquaux et al. Multi-subject dictionary learning to segment an atlas of brain spontaneous activity Information Processing in Medical Imaging, 2011, pp. 562-573, Lecture Notes in Computer Science



Discussion:
On 30/12/2016 15:26, vbeliveau wrote:
>
> I apologize in advance if this not the right forum for asking general 
> questions about nilearn functions, but I couldn’t find a general 
> mailing list.
>
> I have been trying to use the DictLearning class to identify 
> components of a dataset, as performed in Varoquaux et al. 2011. The 
> algorithm described in that paper identifies subject- and group–level 
> spatial maps. However, DictLearning only estimates a single set of 
> components. Taking a closer look at the code, it appears that the 
> decomposition is performed directly by dict_learning_online from 
> sklearn.decomposition.
>
> |self.components_, _ = self._cache(dict_learning_online)( data.T, 
> self.n_components, alpha=self.alpha, n_iter=n_iter, 
> batch_size=self.batch_size, method=self.method, dict_init=dict_init, 
> verbose=max(0, self.verbose - 1), random_state=self.random_state, 
> return_code=True, shuffle=True, n_jobs=1)|
>
> As far as I can tell from the documentation, dict_learning_online does 
> not implement the “two-level” decomposition described in Varoquaux et 
> al 2011, but rather a mini-batch version of (single-level) dictionary 
> learning.
>
> So am I misunderstanding something or is DictLearning not implementing 
> the algorithm described in Varoquaux et al 2011? Could someone perhaps 
> clarify this for me?
>
No, it is not. Wurrently, we prefer to rely on the Multi-subject model 
og Abraham et al. MICCAI 2013, which haven't integrated yet.
The current code makes it possible to run dictionary learning in 
concatenated mode only.
Best,

Bertrand Thirion

> The current code makes it possible to run dictionary learning in
> concatenated mode only.

The current code is actually fairly close to
http://ieeexplore.ieee.org/abstract/document/7493501

We should change the documentation to make this clear.


Resolving patch:
diff --git a/nilearn/decomposition/dict_learning.py b/nilearn/decomposition/dict_learning.py
--- a/nilearn/decomposition/dict_learning.py
+++ b/nilearn/decomposition/dict_learning.py
@@ -132,11 +132,11 @@ class DictLearning(BaseDecomposition, TransformerMixin):
 
     References
     ----------
-    * Gael Varoquaux et al.
-      Multi-subject dictionary learning to segment an atlas of brain
-      spontaneous activity
-      Information Processing in Medical Imaging, 2011, pp. 562-573,
-      Lecture Notes in Computer Science
+    * Arthur Mensch, Gael Varoquaux, Bertrand Thirion,
+      Compressed online dictionary learning for fast resting-state fMRI
+      decomposition.
+      IEEE 13th International Symposium on Biomedical Imaging (ISBI), 2016.
+      pp. 1282-1285
     """
 
     def __init__(self, n_components=20,


Test patch: