Skip to content

Conversation

@hoechenberger
Copy link
Member

@hoechenberger hoechenberger commented Feb 15, 2020

What does this implement/fix?

The changes in this PR enable the user to retrieve the number of completed ICA iterations via ICA.n_iter_ after ICA.fit() has been called. Currently only works with FastICA and Picard (will always be None for Infomax)

@codecov
Copy link

codecov bot commented Feb 15, 2020

Codecov Report

Merging #7328 into master will increase coverage by 0.03%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #7328      +/-   ##
==========================================
+ Coverage   89.88%   89.92%   +0.03%     
==========================================
  Files         450      450              
  Lines       81264    81437     +173     
  Branches    12918    12942      +24     
==========================================
+ Hits        73046    73230     +184     
+ Misses       5396     5386      -10     
+ Partials     2822     2821       -1     

@hoechenberger
Copy link
Member Author

hoechenberger commented Feb 15, 2020

Tests are failing bc picard is not installed on the CI system. I see the other tests typically omit picard – why's that?

@larsoner
Copy link
Member

See how _skip_check_picard is used

@hoechenberger
Copy link
Member Author

See how _skip_check_picard is used

Yep I did see that, what's the particular reason picard tests are omitted so often?

@larsoner
Copy link
Member

It shouldn't be that often on CIs. Just one Travis run (minimal dependencies). But we need to see the check anywhere it will be used

@hoechenberger
Copy link
Member Author

@larsoner ok thanks, should all be good now

@larsoner
Copy link
Member

Feel free to rebase or merge now that #7329 is in, then all methods can all have n_iter_

@hoechenberger
Copy link
Member Author

@larsoner Rebased and squashed commits.

@larsoner
Copy link
Member

Looks like it might disappear during I/O round trip, can you check?

@hoechenberger
Copy link
Member Author

@larsoner I don't have permission to restart CI, could you please restart the one failing Travis job?

@larsoner
Copy link
Member

Don't worry about that run, it's failing in master and is in the process of being fixed in #7325 / #7330 / #7333.

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still want to see a test that asserts that n_iter_ exists and is not None after I/O round-trip

@hoechenberger
Copy link
Member Author

hoechenberger commented Feb 17, 2020

Still want to see a test that asserts that n_iter_ exists and is not None after I/O round-trip

Oh now I understand, thought you were referring to something CI-related when you first brought this up. You want me to add a test showing that saving to and loading from disk preserves the new attribute, right? I hadn't thought about that and I'm quite certain it does not. Need to look into this.

@hoechenberger
Copy link
Member Author

hoechenberger commented Feb 17, 2020

@larsoner
ICA.save() raises when called on an un-fitted instance:

if self.current_fit == 'unfitted':
raise RuntimeError('No fit available. Please first fit ICA')

I therefore don't understand why _write_ica(), which is invoked by save(), checks if the attributes that are supposed to be created / existing during fitting actually exist; and if they don't, simply writes out None – I mean, this should never happen, since we'd raise if not fitted. And if one of these attributes is non-existent after a fit, there clearly must be a bug somewhere.

n_samples = getattr(ica, 'n_samples_', None)
ica_misc = {'n_samples_': (None if n_samples is None else int(n_samples)),
'labels_': getattr(ica, 'labels_', None),
'method': getattr(ica, 'method', None)}

@larsoner
Copy link
Member

I therefore don't understand why _write_ica(), which is invoked by save(), checks if the attributes that are supposed to be created / existing during fitting actually exist; and if they don't, simply writes out None – I mean, this should never happen, since we'd raise if not fitted. And if one of these attributes is non-existent after a fit, there clearly must be a bug somewhere.

I'm not sure why this is done. Is it a sticking point for this PR?

In any case, we do want to make it so that objects that were made in MNE 0.19 and earlier can still be read. If it's not clear what you need to do to write out and verify n_iter_ let me know and I can look

@hoechenberger
Copy link
Member Author

Is it a sticking point for this PR?

No, not at all. I just happened to see this code and thought, oh, that looks kinda odd :)
Will try to implement the writing of n_iter_ in a similar way now, though, for the sake of consistency

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1 for merge once the relevant tests pass.

I expect some unrelated failures due to NumPy wheels and also what should be fixed by #7335

@larsoner larsoner merged commit 6c0df72 into mne-tools:master Feb 18, 2020
@larsoner
Copy link
Member

Thanks @hoechenberger

AdoNunes pushed a commit to AdoNunes/mne-python that referenced this pull request Apr 6, 2020
* Expose number of ICA iterations as ICA.n_iter_

* Write attribute to disk during ICA.save()

* Remove whitespaces
AdoNunes pushed a commit to AdoNunes/mne-python that referenced this pull request Apr 6, 2020
* Expose number of ICA iterations as ICA.n_iter_

* Write attribute to disk during ICA.save()

* Remove whitespaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants