You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you're doing bipolar reference on sEEG data with 180 contacts, then it is very slow. Here is an alternative script that does the same in a fraction of second:
importnumpyasnpimportmnefrommne.datasetsimportsampledata_path=sample.data_path()
fname=data_path+'/MEG/sample/sample_audvis-ave.fif'n_picks=30# change to bigger number to see difference in speed# Reading evoked datacondition='Left Auditory'evoked=mne.read_evokeds(fname, condition=condition, baseline=(None, 0),
proj=False)
delevoked.info['projs'][0]
evoked.pick_types(meg=False, eeg=True)
ch_names=evoked.info['ch_names']
evoked.pick_channels(ch_names[:n_picks])
ch_names=ch_names[:n_picks]
anode, cathode=ch_names[1:], ch_names[:-1]
n_channels, n_times=evoked.data.shapen_virtual_channels=len(anode)
virtual_ch_names= [f'{a}-{c}'for (a, c) inzip(anode, cathode)]
multiplier=np.zeros((n_virtual_channels, n_channels))
foridx, (a, c) inenumerate(zip(anode, cathode)):
multiplier[idx, ch_names.index(a)] =1multiplier[idx, ch_names.index(c)] =-1data_rereferenced=multiplier.dot(evoked.data)
evoked_rerefenced=mne.set_bipolar_reference(evoked, anode=anode, cathode=cathode)
picks= [evoked_rerefenced.ch_names.index(ch) forchinvirtual_ch_names]
data_rereferenced_master=evoked_rerefenced.data[picks]
assertnp.allclose(data_rereferenced, data_rereferenced_master)
it seems like this function removes the channel locations. I'm not sure why because it means you can't do any processing downstream. I think the new channel locations should be the channel locations of the cathodes
the docstring has conflicting reports of what is done. First it says "anode minus the cathode", then it says "the 1st anode will be subtracted from the first cathode" which is the opposite
Activity
jasmainak commentedon Jan 8, 2021
Some other issues:
marsipu commentedon Mar 18, 2021
I want to give it a shot (I am still on it, but I haven't found the time yet).