-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MRG: fill_value in ReceptiveField #4543
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
Conversation
|
I realize now why this "bug" never showed up. We have In any case, I need to still fix the TDR bug. |
|
Found and fixed a bug in the Laplacian calculations and updated the tutorial. Also made it easier if, in the future, we want to supply an arbitrary connectivity/adjacency matrix (instead of assuming |
|
Updated tutorial here (yes I know I need to fix the |
|
+1 to fix xlim |
Codecov Report
@@ Coverage Diff @@
## master #4543 +/- ##
==========================================
- Coverage 80.9% 80.68% -0.22%
==========================================
Files 349 349
Lines 65441 65568 +127
Branches 10158 10171 +13
==========================================
- Hits 52945 52904 -41
- Misses 9566 9709 +143
- Partials 2930 2955 +25 |
|
Okay this is ready for review/merge from my end. Should have it for 0.15 as it contains a couple small but important bug fixes. |
|
+1 for MRG when CIs are green. Thx a lot @larsoner for hunting these bugs ! |
|
@choldgraf @nbara any interest in reviewing? |
tutorials/plot_receptive_field.py
Outdated
| for ii, (rf_lap, rf, i_alpha) in enumerate(zip(models_lap, models, alphas)): | ||
| ax = plt.subplot2grid([3, len(alphas)], [0, ii], 1, 1) | ||
| ax.pcolormesh(times, rf_lap.feature_names, rf_lap.coef_[0], **kwargs) | ||
| ax.set(xticks=[], yticks=[]) |
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.
white spaces are still visible in example, so I'm assuming this needs to be
ax.set(xticks=[], yticks=[], xlim=times[[0, -1]])
|
Woah this is quite the code cleanup! It's looking really nice! I didn't spot anything else, but I'll let @choldgraf give the +1 as he would know better than me anyway. |
|
Glad the code is readable enough, it was a nightmare to figure out why they weren't giving equivalent results! |
|
Updated example with fixed bounds here |
choldgraf
left a comment
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.
Whoah! This is way more complex than I was expecting. I kinda feel like you solved multiple problems in this PR other than just the mean_value issue, no? Either way, this looks like a great improvement...a few small comments
| 'download_section_examples': False, | ||
| 'thumbnail_size': (160, 112), | ||
| } | ||
| 'min_reported_time': 1., |
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.
are we using sphinx-gallery master?
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.
yes :)
| fill_mean=self.fit_intercept) | ||
| X = _reshape_for_est(X) | ||
| # Concat times + epochs | ||
| if y is not None: |
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 confirming that you want y is not None to be inside the if statement, since before it was outside the if statement
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.
Yep, TimeDelayingRidge is now epochs-aware
mne/decoding/receptive_field.py
Outdated
| Parameters | ||
| ---------- | ||
| X : array, shape (n_times[, n_epochs], n_features) | ||
| X : array, shape (n_times[, n_epochs][, n_features]) |
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.
I was thinking to require at the least (n_times, n_features) to avoid confusion about what the extra dimension means. E.g., if we allow for just (n_times, n_epochs) AND (n_times, n_features), how do we know which the user wants if they give a 2D input?
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.
The code does already actually, I'll update the docstring
| delayed : array, shape(n_times[, n_epochs][, n_features], n_delays) | ||
| The delayed data. It has the same shape as X, with an extra dimension | ||
| created at ``newaxis`` that corresponds to each delay. | ||
| appended to the end. |
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.
yeah this seems like a better way of doing it, I agree.
| # all negative | ||
| smin, smax = -2, -1 | ||
| X_del = _delay_time_series(X, smin, smax, 1.) | ||
| X_del.shape = (X.shape[0], -1) |
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.
Any chance you could add some comments here so that it'll be easier for somebody else to debug?
| x_xt = _compute_corrs(X, np.zeros((X.shape[0], 1)), -smax, -smin + 1)[0] | ||
| assert_allclose(x_xt, expected) | ||
|
|
||
| # even worse |
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.
and, e.g., what you mean by "slightly harder" and "even worse"?
|
|
||
| def _compute_corrs(X, y, smin, smax): | ||
| """Compute the auto- and cross-correlations.""" | ||
| """Compute auto- and cross-correlations.""" |
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 relates to #3884
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.
Yep, and the changes here actually make it easier to use either pipeline interchangeably if we want to do so at some point
| Parameters | ||
| ---------- | ||
| X : array, shape (n_samples, n_features) | ||
| X : array, shape (n_samples[, n_epochs], n_features) |
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.
there's a docstring discrepancy between here and _delay_time_series...that OK?
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.
(referring to [n_features])
|
@choldgraf comments addressed, let me know if you're happy (or just hit "approve") |
choldgraf
left a comment
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.
(pending travis being happy)
|
thx @larsoner |
|
seriously, this was a way better PR than I would have put together :-) |
This code:
fill_valuelogic for the delayingLaplacian, simultaneously making it easier in the future to do Laplacian of arbitrary neighbors (instead of justgrid_to_graph)