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

ENH: add corrmap. #1985

Closed
wants to merge 66 commits into from
Closed

ENH: add corrmap. #1985

wants to merge 66 commits into from

Conversation

dengemann
Copy link
Member

Taking over #1795

@dengemann dengemann mentioned this pull request Apr 20, 2015
sim_i_o = np.abs(np.corrcoef(target, newtarget)[1, 0])

return newtarget, median_corr_with_target, sim_i_o, max_corrs
except IndexError:
Copy link
Member

Choose a reason for hiding this comment

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

Is there a more elegant way to do this? a problem with try/except over a bunch of lines is that sometimes you end up hitting an unintended error. It's also not clear from the code where or why an IndexError would occur, so it's also harder for the next person to deal with.

Copy link
Member Author

Choose a reason for hiding this comment

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

I know ... tried to brainwash @jona-sassenhagen but he was very resistant so far.

Copy link
Member

Choose a reason for hiding this comment

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

I understand the "it's easier to ask for forgiveness then for permission" mentality, but it's not clear in this code what the forgiveness would even be for, which makes it difficult to understand. I think it's typically applied to a single or a couple lines of code. Looking at these ~10 lines of code deeper I still can't figure out where to expect an indexing error, which is not a good sign.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. let's figure it out :)

@larsoner
Copy link
Member

Other than my comments, LGTM, but I don't really know much about the ICA code

@dengemann
Copy link
Member Author

deleted comment, wrong issue.

@agramfort
Copy link
Member

agramfort commented Apr 20, 2015 via email

@larsoner larsoner added this to the 0.9 milestone Apr 20, 2015
@larsoner
Copy link
Member

@agramfort #1795, the PR that this one superceded, was marked for 0.9 so I think yeah he wants it for the release

@dengemann
Copy link
Member Author

do you want this merged for the release?

let's try to do that.

@larsoner
Copy link
Member

@dengemann don't forget about this one

@dengemann
Copy link
Member Author

I'm hesitating / thinking about moving this to 0.10. Let me see how this weeks schedule develops (unless @jona-sassenhagen want's to complete it). At this stage it's more important though to fix bugs than adding new features.

@jona-sassenhagen
Copy link
Contributor

Is there anything major missing? I wouldn't stress it being a .9 feature, but I'd like to have it merged so the people I work with have an easier time using it :)

@dengemann
Copy link
Member Author

Is there anything major missing? I wouldn't stress it being a .9 feature, but I'd like to have it merged so the people I work with have an easier time using it :)

Nope just addressing the comments.

  • move nested functions to private functions at the module level
  • remove try catch blocks

@dengemann
Copy link
Member Author

and some minor points.

@jona-sassenhagen
Copy link
Contributor

I have a bit of time now, I'll try to get at least one of the big two

@jona-sassenhagen
Copy link
Contributor

that is, this week, not right now :)

@larsoner
Copy link
Member

I'll just do it now, they're my gripes anyway :)

@jona-sassenhagen
Copy link
Contributor

better still!

@dengemann
Copy link
Member Author

@Eric89GXL you do have push access. Feel free to work on my PR.

@larsoner
Copy link
Member

done, @dengemann and/or @jona-sassenhagen please have a look. I got rid of the try/excepts other than the one I thought made sense (the read_meas_info one is a good example of the ask for forgiveness principle IMO) by checking for failure conditions. Note that this is also a better approach because it avoided a spewing of numpy warnings in some cases before hitting the eventual ValueError.

@@ -933,7 +935,10 @@ def find_bads_ecg(self, inst, ch_name=None, threshold=None,
raise ValueError('Method "%s" not supported.' % method)
# sort indices by scores
ecg_idx = ecg_idx[np.abs(scores[ecg_idx]).argsort()[::-1]]
return list(ecg_idx), scores
if not hasattr(self, 'labels_'):
self.labels_ = {}
Copy link
Member

Choose a reason for hiding this comment

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

{} -> dict()

it's more explicit

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0%) to 90.29% when pulling 0ca2a34 on dengemann:patch-3 into 6b08e27 on mne-tools:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0%) to 90.29% when pulling 0ca2a34 on dengemann:patch-3 into 6b08e27 on mne-tools:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.83%) to 88.46% when pulling 0ca2a34 on dengemann:patch-3 into 6b08e27 on mne-tools:master.

used (via .add_artist). Defaults to True.
contours : int | False | None
The number of contour lines to draw. If 0, no contours will be drawn.

Copy link
Member

Choose a reason for hiding this comment

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

rm empty line

@wmvanvliet
Copy link
Contributor

the current implementation breaks if there are more then 20 IC's being plotted:

/Users/rodin/BRU/mne-python/mne/preprocessing/ica.py in _plot_corrmap(data, subjs, indices, ch_type, ica, label, show, outlines, layout, cmap, contours)
   2189         figs = [_plot_corrmap(data[k:k + p], subjs[k:k + p],
   2190                 indices[k:k + p], ch_type, ica, label)
-> 2191                 for k in range(0, n_components, p)]
   2192         return figs
   2193     elif np.isscalar(picks):

TypeError: _plot_corrmap() takes exactly 11 arguments (6 given)

"""Customized ica.plot_components for corrmap"""
import matplotlib.pyplot as plt

title = 'Detected components of type ' + label
Copy link
Contributor

Choose a reason for hiding this comment

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

Label defaults to None and should stay None for dry runs, in which case we get an error here.

@larsoner
Copy link
Member

@dengemann should we move this to 0.10, or do you have time to finish it?

@jona-sassenhagen
Copy link
Contributor

Would it help if I made proposals/PRs for the problems noted by @wmvanvliet and I?

@dengemann
Copy link
Member Author

As said before please take over if you have time.

On 29 Apr 2015, at 13:23, jona-sassenhagen notifications@github.com wrote:

Would it help if I made proposals/PRs for the problems noted by @wmvanvliet and I?


Reply to this email directly or view it on GitHub.

@larsoner larsoner mentioned this pull request May 12, 2015
@agramfort
Copy link
Member

I would move this to 0.10... but you can object...

@jona-sassenhagen
Copy link
Contributor

@agramfort I think this is basically done.

@jona-sassenhagen
Copy link
Contributor

I have a PR addressing the problems noted by wmvanvliet and I.

@larsoner
Copy link
Member

After that is merged it will need a rebase, too

@larsoner
Copy link
Member

@dengemann if you are swamped I can merge the PR into your branch and rebase

@agramfort
Copy link
Member

agramfort commented May 12, 2015 via email

@dengemann
Copy link
Member Author

Agreed. Let's move slowly, test it extensivel, and keep it on master for
now.

2015-05-12 21:59 GMT+02:00 Alexandre Gramfort notifications@github.com:

my 0.5 concern is that I don't know if this method is what we should
advertise and it's currently the best we can offer. The problem when adding
code to a package is that it never goes away so we need to think twice...


Reply to this email directly or view it on GitHub
#1985 (comment)
.

@jona-sassenhagen
Copy link
Contributor

On master instead of release? Fine with me.

@dengemann, I'm up for a massive test comparing different ICA and IC identification mechanisms on many data sets ...

@agramfort
Copy link
Member

agramfort commented May 12, 2015 via email

@dengemann
Copy link
Member Author

I meant merge it to 0.10 master once it's open and once we're happy.

2015-05-12 22:13 GMT+02:00 Alexandre Gramfort notifications@github.com:

I would vote not to merge this to master before someone does an big
validation like you proposed. If we merge to master it will be released in
the following release


Reply to this email directly or view it on GitHub
#1985 (comment)
.

@dengemann dengemann modified the milestones: 0.10, 0.9 May 12, 2015
@jona-sassenhagen
Copy link
Contributor

I've finally fixed the stuff that went broke in the meantime with updates on master (e.g. giving everything a show keyword destroyed the plotting), should I make a new PR or PR to @dengemann 's repo?..

@agramfort
Copy link
Member

agramfort commented May 16, 2015 via email

@jona-sassenhagen
Copy link
Contributor

Close for #2104?

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.

6 participants