Skip to content

Conversation

@stfnrpplngr
Copy link
Contributor

I'm not sure whether this is a bug, just observed the following.
Plotting the time-locked sources doing an ICA, results in different labelling clicking on the components' lines:
incorrect_labelling

Changing the proposed line in _export_info() solves the problem:
correct_labeling

EMG channels were missing for the create_info function
Added emg channel type for use in the create_info function
During ICA, plotting of sources results in different labelling
@agramfort
Copy link
Member

we keep getting these bug reports about channel names that don't correspond to indices.

when we write ICA #001 it corresponds to the indices but when the channel names named ICA001 start with 1 to match the convention of EEG channels that start with 1.

is this really worth changing?

@codecov-io
Copy link

codecov-io commented Jun 15, 2017

Codecov Report

Merging #4320 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #4320      +/-   ##
==========================================
+ Coverage   84.42%   84.42%   +<.01%     
==========================================
  Files         346      346              
  Lines       62897    62897              
  Branches     9672     9672              
==========================================
+ Hits        53099    53103       +4     
+ Misses       7118     7115       -3     
+ Partials     2680     2679       -1

@larsoner
Copy link
Member

larsoner commented Jun 15, 2017 via email

@agramfort
Copy link
Member

agramfort commented Jun 15, 2017 via email

@larsoner
Copy link
Member

Thanks for being the final straw @stfnrpplngr, closing this as dup of #3889 where we'll continue discussion

@larsoner
Copy link
Member

Reopened because this is already along the lines of the right fix. @stfnrpplngr 3 more things are necessary to get this in:

  1. Update ICA tutorials
  2. Add the option to use old / bad naming style (like what's done in ICA get sources named w/ zero based indices #1622) w/deprecation cycle to move to the new / good naming style
  3. Updating any tests

Do you have time to look into these? We're happy to walk you through them if you want to learn how.

@larsoner larsoner added this to the 0.15 milestone Jun 15, 2017
@stfnrpplngr
Copy link
Contributor Author

If someone could walk me through, that would be great.

@larsoner
Copy link
Member

For (1), look through these to see if there is any mention of numbering differences:

Also look through #3633, #2019, #2000, #1622 to see if they mention updating docs anywhere else that we could fix.

For (2), you'd add a channel_start=None argument to ICA constructor and in __init__ do:

if channel_start is None:
    channel_start = 1
    warn('channel_start will default to 1 in 0.15, but change to 0 in 0.16. Set it explicitly to avoid this warning', DeprecationWarning)
if channel_start not in (0, 1):
    raise ValueError('channel_start must be 0 or 1, got %s' % (channel_start,))

For (3) run nosetests mne/preprocessing/tests/test_ica.py and ensure they pass. Run the two examples referenced above and compare the outputs to those from the current dev build. Push changes to your PR and see if the CIs (Travis, AppVeyor, and CircleCI) are happy.

@larsoner
Copy link
Member

larsoner commented Aug 8, 2017

@stfnrpplngr do you have time to give it a try, or should someone else take over?

Adjusting the naming of sources to the naming in ica.plot_components()
Adding channel_start argument and deprecation warning

Suggested changes regarding pull request
raw = mne.io.read_raw_fif(raw_fname, preload=True)
# 1Hz high pass is often helpful for fitting ICA
raw.filter(1., 40., n_jobs=2, fir_design='firwin')
raw.filter(1, 40, n_jobs=2) # 1Hz high pass is often helpful for fitting ICA
Copy link
Member

Choose a reason for hiding this comment

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

revert

Sorry, this probably happened updating from the master branch
@stfnrpplngr
Copy link
Contributor Author

@larsoner would you mind having a look on it again?

DeprecationWarning)
if channel_start not in (0, 1):
raise ValueError('channel_start must be 0 or 1, got %s' %
(channel_start,))
Copy link
Member

Choose a reason for hiding this comment

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

do we actually really need a parameter for this? Or is the plan to remove it after the deprecation cycle?

Copy link
Member

Choose a reason for hiding this comment

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

See suggestion above

#4320 (comment)

But maybe we don't need the cycle and can just make the API change

Copy link
Member

Choose a reason for hiding this comment

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

I'd opt for not deprecating. We could even twitter vote ... Let's just get it right once.

Copy link
Member

Choose a reason for hiding this comment

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

IIRC that simple change is what @stfnrpplngr had as the commit two months ago. :(

Sorry for the back and forth @stfnrpplngr, but can you change it just to use the index (no need for the param / deprecation I suggested before)? Other than that, the other thing I see is that doc/whats_new.rst needs to be updated in the API section saying that the ICA labeling now starts from 0.

ch_info = info['chs'] = []
for ii in range(self.n_components_):
this_source = 'ICA %03d' % (ii + 1)
this_source = 'ICA %03d' % (ii)
Copy link
Member

Choose a reason for hiding this comment

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

we could really just make clear that these are the indices. We have a similari issue in #4049 and should solve it consistently.

Copy link
Member

Choose a reason for hiding this comment

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

yes maybe using the # sign

so "ICA #1" is clear that it's index 0?

Copy link
Member

Choose a reason for hiding this comment

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

I'd rather do [0] than #1. But earlier you seemed happy with the current implementation...

@dengemann
Copy link
Member

dengemann commented Aug 14, 2017 via email

@larsoner
Copy link
Member

I don't feel strongly either way, @stfnrpplngr feel free to revert to the simpler way or keep the current deprecation, up to you. Then we need doc/whats_new.rst update and we should be good

@stfnrpplngr
Copy link
Contributor Author

I would like to keep it containing the deprecation warning hopefully guaranteeing less confusion on the user site. The doc/whats_new.rst has been changed.

@agramfort
Copy link
Member

so now the plan is to have ICA 000 as first ica channel? to everything is zero indexed?

@larsoner
Copy link
Member

so now the plan is to have ICA 000 as first ica channel? to everything is zero indexed?

Yep

n_pca_components=None, noise_cov=None, random_state=None,
method='fastica', fit_params=None, max_iter=200,
verbose=None): # noqa: D102
verbose=None, channel_start=None): # noqa: D102
Copy link
Member

Choose a reason for hiding this comment

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

add channel_start before verbose, and also document it

@agramfort
Copy link
Member

agramfort commented Aug 22, 2017 via email

API
~~~

- Add ``channel_start`` parameter in :func:`mne.preprocessing.ica` to make explicit that ICA component labelling starts from 1 in 0.15, default will change to 0 in 0.16 by `Stefan Repplinger`_ and `Eric Larson`_
Copy link
Member

Choose a reason for hiding this comment

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

over indented

@agramfort
Copy link
Member

agramfort commented Aug 22, 2017 via email

@larsoner
Copy link
Member

With no deprecation? That's okay with me I guess, and it sounded like @dengemann thought it was overkill, too.

@stfnrpplngr I'll close this, cherry-pick your commits (there are a couple that do what we want) and open a new PR. Thanks for the fix and iterations!

@larsoner larsoner closed this Aug 22, 2017
@larsoner
Copy link
Member

yes maybe using the # sign

so "ICA #1" is clear that it's index 0?

BTW this suggestion is the opposite of how it works in ICA viz currently. "ICA #000" is index 0. Just more evidence that our current scheme is unintuitive.

@stfnrpplngr stfnrpplngr deleted the patch-3 branch December 1, 2017 14:48
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.

5 participants