Repository navigation
MRG: Add ICA to Report - #9828
Conversation
| ) | ||
| fig.savefig(output, format=image_format, dpi=fig.get_dpi(), | ||
| bbox_inches='tight', pad_inches=0) | ||
| bbox_inches='tight') |
There was a problem hiding this comment.
This fixes a small layout problem that we see in main
86e8785 to
a9e58b8
Compare
|
@agramfort I'd been struggling with the Circle build for about 2h now, but I hope it will finally pass … In any case, the rest is ready for review. Let's keep our fingers crossed Circle will render something nice to look at 🤞 |
| cov = pick_channels_cov(cov, raw.ch_names) | ||
| events = read_events(events_fname) | ||
| epochs = Epochs(raw=raw, events=events) | ||
| epochs = Epochs(raw=raw, events=events, baseline=None) |
There was a problem hiding this comment.
avoids an ICA warning
| r = Report(title='My Report') | ||
| raw = read_raw_fif(raw_fname) | ||
| raw.pick_channels(raw.ch_names[:6]).crop(0, 10) | ||
| raw.pick_channels(raw.ch_names[:6]).crop(10, None) |
There was a problem hiding this comment.
better suited for epoching; total data duration is approx 20 sec, so we're working with the ~same amount of data as before
There was a problem hiding this comment.
I was about to ask, so thanks for preempting :)
There was a problem hiding this comment.
to be more specific: I believe there were more events in that particular data segment than in the first 10 seconds
| ica_ecg_scores = ica_eog_scores = np.array([3, 0]) | ||
| ica_ecg_evoked = ica_eog_evoked = epochs.average() |
There was a problem hiding this comment.
just faking something to speed up the tests
Were you able to replicate the issue locally with either |
Sorry, I was being imprecise here. I saw Circle fail and then managed to reproduce the doc build failure locally (was Matplotlib backend-dependent), and it took me a considerable amount of time to fix it there before pushing to Circle again :) |
|
Failing CI job is just the usual Azure timeout after passing all tests… |
| <td>{{n_pca_components}}</td> | ||
| </tr> | ||
| <tr> | ||
| <th>Explained variance</th> |
There was a problem hiding this comment.
I find the Explained variance here a bit ambiguous. You have lots of PCA comps and only 60% explained variance. TO me it means it's the explained variance on the PCA limited to 15 ICA components.
There was a problem hiding this comment.
TO me it means it's the explained variance on the PCA limited to 15 ICA components.
Yes that's what it's supposed to mean. Any suggestions on how to make it less ambiguous?
There was a problem hiding this comment.
I could simply move the row up? so that it's directly below the "ICA", but above the "PCA" row?
There was a problem hiding this comment.
Looks like this has not been addressed
There was a problem hiding this comment.
I addressed this by moving the "PCA" row on step down, so the table row order is now "ICA components, Variance explained, Available PCA components", this should reduce the ambiguity
| <td>{{n_components}}</td> | ||
| </tr> | ||
| <tr> | ||
| <th>PCA components used</th> |
There was a problem hiding this comment.
| <th>PCA components used</th> | |
| <th>Available PCA components</th> |
and then we move it below the Explained variance row?
|
@agramfort I believe I have addressed all of your comments here. |
larsoner
left a comment
There was a problem hiding this comment.
I pushed a commit with a spelling fix. Other than some minor stuff and potentially unresolved comments, LGTM!
| from ..preprocessing.ica import _check_start_stop | ||
|
|
||
| if ica.current_fit == 'unfitted': | ||
| raise RuntimeError('You need to fit the ICA first') |
There was a problem hiding this comment.
ideally would have corresponding with pytest.raises in some test
There was a problem hiding this comment.
I've added the proposed test
| r = Report(title='My Report') | ||
| raw = read_raw_fif(raw_fname) | ||
| raw.pick_channels(raw.ch_names[:6]).crop(0, 10) | ||
| raw.pick_channels(raw.ch_names[:6]).crop(10, None) |
There was a problem hiding this comment.
I was about to ask, so thanks for preempting :)
| # XXX TODO We could render ICA components here someday | ||
| # elif _endswith(fname, 'ica') and ica: | ||
| # pass |
There was a problem hiding this comment.
Seems reasonable to add as part of this PR
There was a problem hiding this comment.
Normally yes, but I ran into a non-trivial issue (meaning one that I couldn't resolve to my satisfaction within 15 min) and decided with @agramfort to move on for now. If you don't mind, I'd add this in a future iteration. I'm actually also a bit hesitant to put too much effort into parse_folder as I think it's quite inflexible. And for ICA, you could only provide a subset of the renderings we do with add_ica(), because you don't know which inst to demonstrate the ICA cleaning on etc.. or you'd have to expand the API of parse_folder or Report to allow users to specify one or multiple insts, and this requires discussion … I wanted to avoid all of that, at least for now.
There was a problem hiding this comment.
I've opened an issue so we don't forget about this: #9844
| <td>{{n_pca_components}}</td> | ||
| </tr> | ||
| <tr> | ||
| <th>Explained variance</th> |
There was a problem hiding this comment.
Looks like this has not been addressed
Co-authored-by: Alexandre Gramfort <[email protected]>
|
@larsoner Please merge if you're happy :) |
|
thx @hoechenberger |
|
😍 |

This PR adds
Report.add_ica(), updatesICA.__repr__(), and addsICA._repr_html_()WIP:
ICA._repr_html_()Add toparse_folder()(low prio)