New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MRG] Dictionary learning + nilearn.decomposition refactoring #693
[MRG] Dictionary learning + nilearn.decomposition refactoring #693
Conversation
1f41aa0
to
40ddf78
Compare
n_components = 10 | ||
|
||
dict_learning = DictLearning(n_components=n_components, smoothing_fwhm=6., | ||
memory="nilearn_cache", memory_level=5, verbose=2, random_state=0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memory_level=5, verbose=2, random_state=0 makes it a bit frightening to users. I think that @GaelVaroquaux already raised this issue. Couldn't we rely on defaults ? If not, this couls mean that the defaults are not well chosen...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to put memory_level=2 to have good performance (reuse masking from initialization in dictionary learning). I could make it the default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just did
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a943057
to
3e0683c
Compare
===================================================== | ||
|
||
An example applying dictionary learning to resting-state data. This example applies it | ||
to 10 subjects of the ADHD200 datasets. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You say 10 and later you fetch 20.
if not hasattr(imgs, '__iter__'): | ||
imgs = [imgs] | ||
imgs = list(_iter_check_niimg(imgs, atleast_4d='True', memory=memory, | ||
memory_level=memory_level)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely not a good idea. You will waste a lot of memory here if you load everything instead of iterating over it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely not a good idea. You will waste a lot of memory here if you
load everything instead of iterating over it.
My PR to this branch solves this problem, to the cost of doing things a
bit more manually. However, I think that we should accept this cost, in
order to merge this PR for the release. We should later inspect our
loading / checking code to see what is the best way to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's as simple as removing list
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- imgs = list(_iter_check_niimg(imgs, atleast_4d='True', memory=memory,
memory_level=memory_level))
It's as simple as removing list here.
No, that wasn't enough to limit the memory explosion, it just delayed it.
I suspect that images spanned by the iterator were not properly garbage
collected. But it does require investigation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No beacuse we iterate twice. I was stupid to add this list() though. Reviewing Gaël PR now
@GaelVaroquaux it should not fail if provided with images with different size isn't it ? |
@GaelVaroquaux it should not fail if provided with images with different size
isn't it ? n_voxels is based on mask_img size
Good point, the masker does a lot to make it work.
|
To answer you about the design flaw, I listed it in my big |
To answer you about the design flaw, I listed it in my big refactoring
issue. I suggest that we merge and take a closer look afterward.
Absolutely!
|
@@ -70,11 +74,11 @@ Finally, we can plot the map for different ICA components separately: | |||
.. literalinclude:: ../../examples/connectivity/plot_canica_resting_state.py | |||
:start-after: # Finally, we plot the map for each ICA component separately | |||
|
|||
.. |left_img| image:: ../auto_examples/connectivity/images/sphx_glr_plot_canica_resting_state_003.png | |||
.. |left_img| image:: ../_images/sphx_glr_plot_canica_resting_state_003.png |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably don't want to change this link.
Hmmm it looks like this needs a rebase on master. Maybe you'll get a few URL fixes by @mrahim for free. |
a2c54da
to
7af3a07
Compare
A rebase never comes for free ;) |
|
||
.. literalinclude:: ../../examples/connectivity/plot_compare_resting_state_decomposition.py | ||
:start-after: # Dictionary learning | ||
:end-before:# CanICA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Genuine error in CircleCI, it looks like you need a space after the :
Try to run the doc generation with make html-strict and you'll be able to reproduce the error and possibly find other problems.
A rebase never comes for free ;)
Quote of the week!
|
@@ -70,11 +74,11 @@ Finally, we can plot the map for different ICA components separately: | |||
.. literalinclude:: ../../examples/connectivity/plot_canica_resting_state.py | |||
:start-after: # Finally, we plot the map for each ICA component separately | |||
|
|||
.. |left_img| image:: ../auto_examples/connectivity/images/sphx_glr_plot_canica_resting_state_003.png | |||
.. |left_img| image:: ../auto_examples/connectivity/plot_canica_resting_state_003.png |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably shouldn't change this link
Merging this one. I opened issues regarding initialization documentation and broken links. Feel free to open issues if problems remain if I missed them. |
…n_mask [MRG] Dictionary learning + nilearn.decomposition refactoring
Yipi!!!! Sent from my phone. Please forgive brevity and mis spelling On Dec 8, 2015, 09:44, at 09:44, Alexandre Abraham notifications@github.com wrote:
|
Congrats ! |
Decomposition estimators (
DictLearning
/MultiPCA
) now inherit aDecompositionEstimator
.Loading of data is made through a
PCAMultiNiftiMasker
, which loads data from files and compress it.Potentially, the function check_masker could solve issue #688, as it factorizes the input checking of estimator to which you provide either a masker or parameters for a mask. It is tuned to be able to use
PCAMultiNiftiMasker