HyPyP icon indicating copy to clipboard operation
HyPyP copied to clipboard

Question related to ICA fit

Open imogenweigall opened this issue 1 year ago • 1 comments

Hi HyPyP team, thank you for your efforts in creating this great package. I have a question regarding your ICA_fit function. I am interested in why this function fits the ICA twice, first excluding bad channels and then a second time including bad channels. The typical recommendation is that bad channels are marked prior to ICA (https://mne.tools/stable/auto_tutorials/preprocessing/15_handling_bad_channels.html). If you could please provide me with further information / help me understand the rationale behind this it would be greatly appreciated.

icas = []
    for epoch in epochs:
        # per subj
        # applying AR to find global rejection threshold
        reject = get_rejection_threshold(epoch, ch_types='eeg')
        # if very long, can change decim value
        print('The rejection dictionary is %s' % reject)
        # fitting ICA on filt_raw after AR
        ica = ICA(n_components=n_components,
                  method=method,
                  fit_params= fit_params,
                  random_state=random_state).fit(epoch)
        # take bad channels into account in ICA fit
        epoch_all_ch = mne.Epochs.copy(epoch)
        epoch_all_ch.info['bads'] = []
        epoch_all_ch.drop_bad(reject=reject, flat=None)
        icas.append(ica.fit(epoch_all_ch)) 

imogenweigall avatar Jul 10 '23 03:07 imogenweigall

Hey there! (Disclaimer: Not a member of the initial team)

I think it's done to ensure robustness to the presence of bad channels, especially where bad channels may only become apparent after running ICA

(Note: After reviewing, we've noted it to be a bug and it will be fixed in the upcoming versions)

etherealsunshine avatar Jul 17 '23 17:07 etherealsunshine