Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TomDLT
Copy link
Collaborator

@TomDLT TomDLT commented Jun 11, 2019

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).

Figure_3

this_info['events'] = events

plot_epochs_of_selected_atoms(cdl, z_hat, X, this_info, t_lim, idx_atoms,
channel=channel, align=False)
Copy link
Member

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?

Copy link
Collaborator Author

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-io
Copy link

Codecov Report

Merging #19 into master will decrease coverage by 0.23%.
The diff coverage is 11.11%.

@@            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

Copy link
Collaborator

@agramfort agramfort left a 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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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):
Copy link
Collaborator

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

Copy link
Contributor

@tomMoral tomMoral left a 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,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# 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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# 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
Copy link
Contributor

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):
Copy link
Contributor

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]
Copy link
Contributor

Choose a reason for hiding this comment

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

already done

Suggested change
ax = axes[2 * ii, jj]

ax.legend()
ax.grid(True)

# plot the activations distributions
Copy link
Contributor

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]
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Here is a different visualization of the atoms correlated with the event
# Here is a different visualization of some atoms correlated with the event

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.

None yet

5 participants