-
Notifications
You must be signed in to change notification settings - Fork 37
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
EXA add conditioned activation plot in multi_csc example #19
base: master
Are you sure you want to change the base?
Conversation
this_info['events'] = events | ||
|
||
plot_epochs_of_selected_atoms(cdl, z_hat, X, this_info, t_lim, idx_atoms, | ||
channel=channel, align=False) |
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.
what are the different colors in the third subplot? do you show both the activations and reconstructed signal?
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.
Third row:
- Dots are the activations, same colors as fourth row (the dot is not the activation onset but the time at its maximum absolute value).
- Reds and Blues are the reconstructed signals, same colormap and vmin/vmax as first row.
Codecov Report
@@ Coverage Diff @@
## master #19 +/- ##
==========================================
- Coverage 81.75% 81.51% -0.23%
==========================================
Files 23 23
Lines 2290 2299 +9
==========================================
+ Hits 1872 1874 +2
- Misses 418 425 +7 |
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 need to make sure that API page is up to date:
https://alphacsc.github.io/api.html
any public function in an example should be in the API page
# but displays the signal reconstructed using the two selected atoms. Colored | ||
# dots are present where each atom is activated. The last row depicts | ||
# histograms of activations for the selected atoms. | ||
from alphacsc.viz.epoch import plot_epochs_of_selected_atoms |
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.
from alphacsc.viz.epoch import plot_epochs_of_selected_atoms | |
from alphacsc.viz import plot_epochs_of_selected_atoms |
# select the atoms to plot | ||
idx_atoms = [6, 30] | ||
|
||
this_info = deepcopy(info) |
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_info = deepcopy(info) | |
this_info = info.copy() |
should work
@@ -222,7 +222,10 @@ | |||
|
|||
from alphacsc.utils.signal import fast_hilbert | |||
from alphacsc.viz.epoch import plot_evoked_surrogates |
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.
from alphacsc.viz.epoch import plot_evoked_surrogates | |
from alphacsc.viz import plot_evoked_surrogates |
should work
|
||
def plot_epochs_of_selected_atoms(model, z_hat, X_full, info, t_lim, | ||
idx_atoms, channel=None, | ||
align=False): |
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.
can you add a docstring
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.
Some comments! this looks nice overall! Thanks @TomDLT :)
# corresponds to a column. Then we pick the channel with the largest absolute | ||
# value in the spatial map of selected atoms. The top row displays the raw | ||
# timecourses on this channel, aligned on the event onsets, and ordered by | ||
# minimum raw value. The second row plots the average evoked timesourse, |
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.
# minimum raw value. The second row plots the average evoked timesourse, | |
# minimum raw value. The second row plots the average evoked time-course, |
Also, you seem to be aligning based on the pred
value and not on the raw value. something like:
# ... The top row displays the raw
# time-courses on this channel, aligned on the event onsets, and ordered by
# the localization of the minimum value of the signal reconstructed with the
# two selected atoms.
# value in the spatial map of selected atoms. The top row displays the raw | ||
# timecourses on this channel, aligned on the event onsets, and ordered by | ||
# minimum raw value. The second row plots the average evoked timesourse, | ||
# either on the raw signal or on the signal reconstructed using the two |
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.
# either on the raw signal or on the signal reconstructed using the two | |
# for both the raw signal and the signal reconstructed using the two |
# but displays the signal reconstructed using the two selected atoms. Colored | ||
# dots are present where each atom is activated. The last row depicts | ||
# histograms of activations for the selected atoms. | ||
from alphacsc.viz.epoch import plot_epochs_of_selected_atoms |
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 think we should add a comments on the usefulness of this representation. This captures some kind of latency in the signal and can be used to re-align the epochs before computing the evoked response?
|
||
def plot_epochs_of_selected_atoms(model, z_hat, X_full, info, t_lim, | ||
idx_atoms, channel=None, | ||
align=False): |
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.
A small docstring? :)
ax.title.set_color(color) | ||
|
||
# plot the event onsets in black | ||
ax = axes[2 * ii, jj] |
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.
already done
ax = axes[2 * ii, jj] |
ax.legend() | ||
ax.grid(True) | ||
|
||
# plot the activations distributions |
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.
Maybe do not put it in the for-loop
v_k_1 = np.r_[[1], v_k][None] | ||
z_k = z_hat[:, kk:kk + 1] | ||
X_k = construct_X_multi(z_k, v_k_1, n_channels=1)[0, 0] | ||
X_k = sources[kk] |
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.
Neat!
@@ -264,6 +264,34 @@ | |||
print("\rDisplayed {} atoms".format(len(plotted_atoms)).rjust(40)) | |||
fig.tight_layout() | |||
|
|||
############################################################################### | |||
# Here is a different visualization of the atoms correlated with the event |
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.
# Here is a different visualization of the atoms correlated with the event | |
# Here is a different visualization of some atoms correlated with the event |
Here I add the event-related activation figure in the multi CSC example.
It is not as cool as the one we discussed, since this set of parameter does not decompose the ERP for events 3-4 into two atoms (see below).