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
WIP: added colors option to grow_labels #8519
Conversation
can you update a test? |
mne/label.py
Outdated
else: | ||
# use specified colors | ||
label_colors = colors |
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.
There is no guarantee or check that label_colors
is the right size. I think you had the right approach before, namely to do:
label_colors = np.empty((len(labels), 3))
label_colors[:] = colors
This guarantees that whatever colors
is, it can broadcast and you will end up with label_colors
of the right shape.
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.
Fine by me, but _n_colors() (label.py) returns array, shape (n, 4).
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.
Then you can do label_colors = np.ones((len(labels), 4)); label_colors[:, :3] = label_colors
if you want. I doubt anyone wants an alpha < 1
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.
Then you can do
label_colors = np.ones((len(labels), 4)); label_colors[:, :3] = label_colors
if you want. I doubt anyone wants an alpha < 1
I'm now allowing four columns and added info about RGB/alpha values to doc-string.
LGTM -- can you update |
else: | ||
# use specified colors | ||
label_colors = np.empty((len(labels), 4)) | ||
label_colors[:] = colors |
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.
label_colors = np.array(colors)
seems easier and equivalent.
also do you test somewhere that len(colors) == len(labels)
?
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.
No it's not equivalent. The point of doing the np.empty
is that
- It allows broadcasting like
colors=0.
if you don't care about the color they can all beblacktransparent, orcolor=(1, 0, 0, 1)
to make them all red, and - It automatically makes sure
len(labels) == len(colors)
EDIT: in other words, we let NumPy do the sanity checking for us by using np.empty
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.
ok then. +1 for MRG if CIs are green.
thx @olafhauk !
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.
colors
can also be of shape (, 4) (one color for all labels). I amended doc-string and added checks/tests.
46c3704
to
daed8ce
Compare
mne/source_space.py
Outdated
@@ -3197,3 +3197,110 @@ def _get_src_nn(s, use_cps=True, vertices=None): | |||
else: | |||
nn = s['nn'][vertices, :] | |||
return nn | |||
|
|||
|
|||
def vertex_depth(inst, info=None, picks=None, trans=None, mode='dist', |
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.
Errant push of vertex_depth
?
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.
Oh no.
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 never know what to do about the codecov errors. Otherwise I think it's fine now.
Thx @olafhauk ! |
Closes #8517
What does this implement/fix?
Added
colors
option to mne.grow_label() to avoid error message for large number of seeds.Additional information