Skip to content

Conversation

@choldgraf
Copy link
Contributor

This is a first-pass PR at adding auto-scaling functionality for plotting raw / epoched data. The basic change is to include a "compute_scalings" function in the viz.utils module. This takes a scalings dictionary, and for any value that is 'auto', it will use the data instance provided to auto-calculate the scaling. Alternatively you can supply only the string "auto" and it'll auto-compute for all channel types in the data. Then it goes on to plotting as normal.

There are some weird things that I did to make iterating through channel types easier (e.g., I've got a hard-coded list of channel types but maybe that exists elsewhere, I also wrote a function to return a list of the channel type for all channels, as well as a dictionary of channel type: ixs, but maybe that's already been done elsewhere?)

Suggestions etc are welcome! Here's the basic idea of what this does:

scalings_def = dict(eeg='auto', grad='auto')
scalings_raw = mne.viz.utils.compute_scalings(scalings_def, raw)
scalings_ep = mne.viz.utils.compute_scalings(scalings_def, epochs)
scalings_all = mne.viz.utils.compute_scalings('auto', raw)
print('{}\n\n{}\n\n{}\n\n{}'.format(scalings_def, scalings_raw, scalings_ep, scalings_all))
{'eeg': 'auto', 'grad': 'auto'}

{'eeg': 7.1589975858543653e-05, 'grad': 1.928710961556987e-11}

{'eeg': 3.6195661505710243e-05, 'grad': 3.506747202830885e-11}

{'ecg': None, 'bio': None, 'emg': None, 'stim': 0.0, 'eog': 1.7976379496076333e-05, 'ref_meg': None, 'resp': None, 'misc': None, 'seeg': None, 'chpi': None, 'mag': 1.3265991686001318e-12, 'syst': None, 'eeg': 7.1589975858543653e-05, 'grad': 1.928710961556987e-11, 'ias': None, 'exci': None}

originally comes from #2253

mne/viz/utils.py Outdated

_channel_types = ['eeg', 'seeg', 'eog', 'ecg', 'emg', 'ref_meg', 'stim',
'resp', 'misc', 'chpi', 'syst', 'ias', 'exci', 'bio']
_meg_types = ['mag', 'grad']
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be (already?) in mne.channels?

@agramfort
Copy link
Member

have a look at the _picks_by_type function in pick.py and maybe _PICK_TYPES_DATA_DICT, _PICK_TYPES_KEYS and _DATA_CH_TYPES_SPLIT in pick.py

@choldgraf choldgraf force-pushed the add_plot_auto_scale branch from 22e9f42 to 31b68c0 Compare April 30, 2016 17:25
@coveralls
Copy link

coveralls commented Apr 30, 2016

Coverage Status

Coverage decreased (-0.1%) to 90.704% when pulling 31b68c0 on choldgraf:add_plot_auto_scale into 199c8e9 on mne-tools:master.

@choldgraf choldgraf force-pushed the add_plot_auto_scale branch 4 times, most recently from 5538cd7 to 9ceb761 Compare April 30, 2016 21:32
@choldgraf
Copy link
Contributor Author

Think I addressed people's comments. Using percentile now instead of absolute median deviation, also updated dictionaries to be 2.6 compatible

@choldgraf
Copy link
Contributor Author

Also hanging participle has been fixed @kingjr, I'll make sure to bring my copy of Strunk and White for my next PR :)

@coveralls
Copy link

coveralls commented Apr 30, 2016

Coverage Status

Coverage decreased (-0.1%) to 90.698% when pulling 9ceb761 on choldgraf:add_plot_auto_scale into 199c8e9 on mne-tools:master.

@coveralls
Copy link

coveralls commented Apr 30, 2016

Coverage Status

Coverage increased (+0.0004%) to 90.808% when pulling 9ceb761 on choldgraf:add_plot_auto_scale into 199c8e9 on mne-tools:master.

@coveralls
Copy link

coveralls commented Apr 30, 2016

Coverage Status

Coverage increased (+0.006%) to 90.814% when pulling 9ceb761 on choldgraf:add_plot_auto_scale into 199c8e9 on mne-tools:master.

@coveralls
Copy link

coveralls commented Apr 30, 2016

Coverage Status

Coverage increased (+0.005%) to 90.812% when pulling 9ceb761 on choldgraf:add_plot_auto_scale into 199c8e9 on mne-tools:master.

@choldgraf
Copy link
Contributor Author

(LMK if there's anything else you'd like me to change here)

@kingjr
Copy link
Member

kingjr commented May 3, 2016

+1 to merge on my side

mne/viz/utils.py Outdated
return fig


def compute_scalings(scalings, inst):
Copy link
Member

Choose a reason for hiding this comment

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

make private

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@larsoner
Copy link
Member

larsoner commented May 3, 2016

Otherwise LGTM

@choldgraf
Copy link
Contributor Author

just made edits from above and included the 100mb size max etc, let me know if that looks OK. I'll try to find an example to show this now, and will create a change to whatsnew etc next

@choldgraf choldgraf force-pushed the add_plot_auto_scale branch from f8eeeda to 9297b5a Compare May 4, 2016 20:54
@choldgraf
Copy link
Contributor Author

ok - also rebased onto master, updated whats new / a doc, and push that. There was an example showing plotting from raw array data, which is a good use case for this PR. That said, I think it'd be great to have an actual "visualization tutorial", maybe a project for the summer? Once these PRs are taken care of (including the CFC one), I'd like to help build some documentation along those lines.

@coveralls
Copy link

coveralls commented May 4, 2016

Coverage Status

Coverage increased (+0.01%) to 90.837% when pulling 77c68f4 on choldgraf:add_plot_auto_scale into 767d84b on mne-tools:master.

@coveralls
Copy link

coveralls commented May 4, 2016

Coverage Status

Coverage increased (+0.004%) to 90.839% when pulling 9297b5a on choldgraf:add_plot_auto_scale into 0271393 on mne-tools:master.

@coveralls
Copy link

coveralls commented May 4, 2016

Coverage Status

Coverage increased (+0.002%) to 90.837% when pulling 9297b5a on choldgraf:add_plot_auto_scale into 0271393 on mne-tools:master.

@agramfort
Copy link
Member

agramfort commented May 5, 2016 via email

@choldgraf
Copy link
Contributor Author

ah that's great - I'll add tomorrow

On Wed, May 4, 2016 at 11:36 PM, Alexandre Gramfort <
notifications@github.com> wrote:

there is now tutorials for viz see:

http://martinos.org/mne/dev/tutorials.html

and for Raw

http://martinos.org/mne/dev/auto_tutorials/plot_visualize_raw.html

can you add a note there?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#3198 (comment)

@choldgraf choldgraf force-pushed the add_plot_auto_scale branch from 9297b5a to 9241afb Compare May 6, 2016 00:18
@choldgraf
Copy link
Contributor Author

looking at this now - I realized that I didn't see it before because there are two tutorials folders...one in doc, and the other in the main mne_python folder. I added in a sentence about it in the raw plotting tutorial. Is that enough? (also rebased onto master)

@larsoner
Copy link
Member

larsoner commented May 6, 2016

Argh, it does seem like the ones in doc/tutorials should be moved to tutorials. @agramfort is that right?

@coveralls
Copy link

coveralls commented May 6, 2016

Coverage Status

Coverage increased (+0.007%) to 90.841% when pulling 9241afb on choldgraf:add_plot_auto_scale into 2134e8e on mne-tools:master.

@choldgraf
Copy link
Contributor Author

Is that something you'd like me to take care of in this PR?

@larsoner
Copy link
Member

larsoner commented May 6, 2016 via email

@choldgraf
Copy link
Contributor Author

ok cool, will hold off on doing anything else in this PR until somebody
tells me to :)

On Thu, May 5, 2016 at 7:24 PM, Eric Larson notifications@github.com
wrote:

No, that should probably be separate


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#3198 (comment)


- Add option for ``first_samp`` in :func:`mne.make_fixed_length_events` by `Jon Houck`_

- Add ability to auto-scale channel types for `mne.viz.plot_raw` and `mne.viz.plot_epochs` and corresponding object plotting methods by `Chris Holdgraf`_
Copy link
Member

Choose a reason for hiding this comment

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

:func: in front (see other lines above for examples)

Copy link
Member

Choose a reason for hiding this comment

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

+1 then +1 for merge

@agramfort
Copy link
Member

Argh, it does seem like the ones in doc/tutorials should be moved to
tutorials. @agramfort https://github.com/agramfort is that right?

the files in doc/tutorials are in rst format.

the files in tutorials are python files that are rendered with sphinx
gallery.

it's on purpose.

@larsoner
Copy link
Member

larsoner commented May 6, 2016

it's on purpose.

Why not have one or the other? I don't see any reason why these couldn't be made into proper Python tutorials:

https://github.com/mne-tools/mne-python/blob/master/doc/tutorials/report.rst
https://github.com/mne-tools/mne-python/blob/master/doc/tutorials/seven_stories_about_mne.rst

The only one that seems like it can't is the MNE command-line tools one, and we can move that elsewhere.

@larsoner
Copy link
Member

larsoner commented May 6, 2016

At the very least I think we should just move those files to the root doc directory, and get rid of the doc/tutorials directory -- it's confusing to have that, and one at the repo root.

@larsoner
Copy link
Member

larsoner commented May 6, 2016

I'll fix the :func: in master -- thanks @choldgraf!

@larsoner
Copy link
Member

larsoner commented May 6, 2016

Merged by rebase with minor fix

@larsoner larsoner closed this May 6, 2016
@larsoner
Copy link
Member

larsoner commented May 6, 2016

After going to edit the doc, I see what you're saying @agramfort, I'm going to leave it alone :)

@choldgraf
Copy link
Contributor Author

wahoo! thanks all

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.

7 participants