Repository: mne-tools/mne-python

Issue:
'Opt' button doesn't do anything in plot_raw
When I plot a Raw object with `plot`, there is a little box in the bottom left called `Opt`. Whenever I click it, nothing seems to happen. I looked into the code and it seems like this is supposed to bring up an options box of some kind. Does this work for other people? Maybe it's because I'm calling the function from an ipython notebook? Does it only work on certain graphics engines?



Discussion:
It might only work for the Qt backend, not sure

Hmm, I believe that I'm using Qt...

On Fri, Apr 24, 2015 at 3:53 PM, Eric Larson notifications@github.com
wrote:

> It might only work for the Qt backend, not sure
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/mne-tools/mne-python/issues/2020#issuecomment-96089767
> .

you might need to be in "interactive mode", can you try from a standard Python terminal with `plt.ion()` called?

I've tried calling `plt.ion` both in the ipython notebook, as well as from an ipython session in the terminal. These are after calling `plt.switch_backend('Qt4Agg')`. If I put the code into a python script and run it, then a window pops up but immediately closes...

I just ran this on OSX 64-bit Anaconda Python, and it worked fine:

```
>>> import matplotlib.pyplot as plt
>>> plt.ion()
>>> import mne
>>> data_path = mne.datasets.sample.data_path()
>>> raw = mne.io.Raw(data_path + '/MEG/sample/sample_audvis_raw.fif')
>>> raw.plot()
<matplotlib.figure.Figure object at 0x105f457d0>
>>>
```

Clicking "opt" brought up another window with a SSP selection. I can try it on Linux system Python on Monday, but I'm pretty sure it works there, too.

Maybe the window that appears is falling behind the original one for you?

Ah - do you need to have MEG information in there in order for that button
to work? I've just been creating Raw objects from random data using
RawArray.

On Fri, Apr 24, 2015 at 7:21 PM, Eric Larson notifications@github.com
wrote:

> Maybe the window that appears is falling behind the original one for you?
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/mne-tools/mne-python/issues/2020#issuecomment-96121826
> .

You might need projectors, yeah. It would be great to have a PR that greys out the button text if no projs are available!

(FWIW projectors can be for MEG or EEG data, but using the `*Array` functions you'd probably end up with them only by using our preproc functions.)

OK cool - at some point I'd like to improve the raw plotting anyway, so
maybe that's something to put on the to-do list. If there's ever an MNE
code sprint that I can attend, that'd be a fun thing to work on. I really
like how EEG-lab lets you change the scales of things on the fly, change
window size, etc.

On Fri, Apr 24, 2015 at 7:47 PM, Eric Larson notifications@github.com
wrote:

> (FWIW projectors can be for MEG or EEG data, but using the *Array
> functions you'd probably end up with them only by using our preproc
> functions.)
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/mne-tools/mne-python/issues/2020#issuecomment-96122670
> .

Yeah, I think there's an issue for that. The problem with waiting for an `mne` sprint is that @agramfort is in Europe so he tends to host them over there :)

Fair enough... Maybe we can have a mne West sprint!
On Apr 24, 2015 7:52 PM, "Eric Larson" notifications@github.com wrote:

> Yeah, I think there's an issue for that. The problem with waiting for an
> mne sprint is that @agramfort https://github.com/agramfort is in Europe
> so he tends to host them over there :)
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/mne-tools/mne-python/issues/2020#issuecomment-96122796
> .

> Yeah, I think there's an issue for that. The problem with waiting for an
> mne sprint is that @agramfort https://github.com/agramfort is in Europe
> so he tends to host them over there :)
> 
> if you take my role i.e. write the grants to host them in the US I'd be
> happy to join :)

@choldgraf the EEGLAB scaling stuff is btw. something we plan to implement in this year's google summer of code, also an improved epoch viewer.

sounds good @dengemann, this would certainly be helpful. Perhaps I can do something to help when I am visiting in July!

@Eric89GXL what kind of MNE userbase do you guys have up in Seattle? I wonder if there are pots of money at the UW / UCB institutes for Data Science for stuff like this...

There are a number of people using it at ILABS, but I haven't really looked into getting money from the data science centers. If you have time to look, I'm happy to help out or talk to people locally.

Cool - I will keep an eye open here at Berkeley. I know that the Berkeley
Institute for Data Science (BIDS) has a physical space w/ lots of breakout
rooms etc. It's pretty nice and they're pretty open to people utilizing it
for open source projects (e.g., the ipython team hangs out there pretty
frequently).

On Mon, Apr 27, 2015 at 7:16 AM, Eric Larson notifications@github.com
wrote:

> There are a number of people using it at ILABS, but I haven't really
> looked into getting money from the data science centers. If you have time
> to look, I'm happy to help out or talk to people locally.
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/mne-tools/mne-python/issues/2020#issuecomment-96670946
> .

@Eric89GXL you should have a chat with @jakevdp at UW

@choldgraf you should do the same with @fperez at UCB

just doing data science match making on github... :)

Actually -- @jakevdp or @fperez do you know of a good resource for hosting a ~2GB public dataset? We need to allow maintainers from multiple institutions (UW, Telecom ParisTech, MGH, etc.) to have ownership / modification permissions, and up-time is important. Do you have any experience with hosting services at UW or elsewhere (e.g., Amazon)? We would strongly prefer a free solution :)

Didn't github just release a "Large File Storage" service [1]? I think 1GB
is free so this would be higher than that, but might be relevant.

Chris

[1] https://git-lfs.github.com/

On Mon, Apr 27, 2015 at 11:12 AM, Eric Larson notifications@github.com
wrote:

> Actually -- @jakevdp https://github.com/jakevdp or @fperez
> https://github.com/fperez do you know of a good resource for hosting a
> ~2GB public dataset? We need to allow maintainers from multiple
> institutions (UW, Telecom ParisTech, MGH, etc.) to have ownership /
> modification permissions, and up-time is important. Do you have any
> experience with hosting services at UW or elsewhere (e.g., Amazon)? We
> would strongly prefer a free solution :)
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/mne-tools/mne-python/issues/2020#issuecomment-96764227
> .

Random followup - I just chatted with some folks at BIDS here at UC Berkeley and they said that we could almost certainly get a room for a few days for a code sprint, possibly funding for some food etc as well but we'd need to look into that further.

@agramfort in your experience what kinds of resources are necessary in order to put on a code sprint? Perhaps having something over here on the west coast is more possible than thought.

if you fly people over you need travel money and housing.

FYI for the sprint this summer we asked for 15k€ and we hope to be able to
fly people from europe and a few from the US

OK cool, that was my main question (about travel + lodging). I think something like BIDS can easily help with the lighter side of things, but stuff like lodging (unless that means staying on friends' couches) and stuff like travel (unless that means walking up and down the west coast ;) ) would take more to set up. 

Still might be possible, but maybe @Eric89GXL and I can just keep it in mind in the coming months. If flights across the Atlantic are an issue we could always do a simulcast or something, and conduct two sessions separately.

ok. Let's hope the french economy allows us to travel you guys over here :)


Resolving patch:
diff --git a/mne/io/proj.py b/mne/io/proj.py
--- a/mne/io/proj.py
+++ b/mne/io/proj.py
@@ -478,8 +478,8 @@ def make_projector(projs, ch_names, bads=[], include_active=True):
 
             # If there is something to pick, pickit
             if len(sel) > 0:
-                for v in range(p['data']['nrow']):
-                    vecs[sel, nvec + v] = p['data']['data'][v, vecsel].T
+                nrow = p['data']['nrow']
+                vecs[sel, nvec:nvec + nrow] = p['data']['data'][:, vecsel].T
 
             # Rescale for better detection of small singular values
             for v in range(p['data']['nrow']):
diff --git a/mne/viz/raw.py b/mne/viz/raw.py
--- a/mne/viz/raw.py
+++ b/mne/viz/raw.py
@@ -22,10 +22,11 @@
 
 def _plot_update_raw_proj(params, bools):
     """Helper only needs to be called when proj is changed"""
-    inds = np.where(bools)[0]
-    params['info']['projs'] = [copy.deepcopy(params['projs'][ii])
-                               for ii in inds]
-    params['proj_bools'] = bools
+    if bools is not None:
+        inds = np.where(bools)[0]
+        params['info']['projs'] = [copy.deepcopy(params['projs'][ii])
+                                   for ii in inds]
+        params['proj_bools'] = bools
     params['projector'], _ = setup_proj(params['info'], add_eeg_ref=False,
                                         verbose=False)
     _update_raw_data(params)
@@ -142,9 +143,9 @@ def f(x, y):
         params['ax_vertline'].set_data(x, np.array(params['ax'].get_ylim()))
         params['ax_hscroll_vertline'].set_data(x, np.array([0., 1.]))
         params['vertline_t'].set_text('%0.3f' % x[0])
-    event.canvas.draw()
     # update deep-copied info to persistently draw bads
     params['info']['bads'] = bads
+    _plot_update_raw_proj(params, None)
 
 
 def _mouse_click(event, params):
@@ -364,7 +365,7 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=None,
         'original' plots in the order of ch_names, array gives the
         indices to use in plotting.
     show_options : bool
-        If True, a dialog for options related to projecion is shown.
+        If True, a dialog for options related to projection is shown.
     title : str | None
         The title of the window. If None, and either the filename of the
         raw object or '<unknown>' will be displayed as title.
@@ -571,7 +572,8 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=None,
     # plot event_line first so it's in the back
     event_lines = [ax.plot([np.nan], color=event_color[ev_num])[0]
                    for ev_num in sorted(event_color.keys())]
-    lines = [ax.plot([np.nan])[0] for _ in range(n_ch)]
+    lines = [ax.plot([np.nan], antialiased=False, linewidth=0.5)[0]
+             for _ in range(n_ch)]
     ax.set_yticklabels(['X' * max([len(ch) for ch in info['ch_names']])])
     vertline_color = (0., 0.75, 0.)
     params['ax_vertline'] = ax.plot([0, 0], ylim, color=vertline_color,
@@ -591,9 +593,11 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=None,
                                  event_color=event_color, offsets=offsets)
 
     # set up callbacks
-    opt_button = mpl.widgets.Button(ax_button, 'Opt')
-    callback_option = partial(_toggle_options, params=params)
-    opt_button.on_clicked(callback_option)
+    opt_button = None
+    if len(raw.info['projs']) > 0:
+        opt_button = mpl.widgets.Button(ax_button, 'Proj')
+        callback_option = partial(_toggle_options, params=params)
+        opt_button.on_clicked(callback_option)
     callback_key = partial(_plot_raw_onkey, params=params)
     fig.canvas.mpl_connect('key_press_event', callback_key)
     callback_scroll = partial(_plot_raw_onscroll, params=params)


Test patch: