Calculate aperiodic parameter#
Two method of getting aperiodic parameter
get motor image data#
[4]:
def get_data_example_motor_image():
tmin, tmax = -1., 4.
event_id = dict(hands=2, feet=3)
subject = 1
runs = [6, 10, 14] # motor imagery: hands vs feet
raw_fnames = eegbci.load_data(subject, runs)
raw = concatenate_raws([read_raw_edf(f, preload=True) for f in raw_fnames])
eegbci.standardize(raw) # set channel names
montage = make_standard_montage('standard_1005')
raw.set_montage(montage)
# Apply band-pass filter
raw.filter(7., 30., fir_design='firwin', skip_by_annotation='edge')
events, _ = events_from_annotations(raw, event_id=dict(T1=2, T2=3))
picks = pick_types(raw.info, meg=False, eeg=True, stim=False, eog=False,
exclude='bads')
# Read epochs (train will be done only between 1 and 2s)
# Testing will be done with a running classifier
epochs = Epochs(raw, events, event_id, tmin, tmax, proj=True, picks=picks,
baseline=None, preload=True)
epochs_train = epochs.copy().crop(tmin=1., tmax=2.)
labels = epochs.events[:, -1] - 2
data = epochs.get_data()
print(data.shape)
print(raw.info['sfreq'])
return data, labels
[5]:
data, _ = get_data_example_motor_image()
# 7-channel data are used.
data = data[:,:7,:]
Extracting EDF parameters from C:\Users\15956\mne_data\MNE-eegbci-data\files\eegmmidb\1.0.0\S001\S001R06.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 19999 = 0.000 ... 124.994 secs...
Extracting EDF parameters from C:\Users\15956\mne_data\MNE-eegbci-data\files\eegmmidb\1.0.0\S001\S001R10.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 19999 = 0.000 ... 124.994 secs...
Extracting EDF parameters from C:\Users\15956\mne_data\MNE-eegbci-data\files\eegmmidb\1.0.0\S001\S001R14.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 19999 = 0.000 ... 124.994 secs...
Filtering raw data in 3 contiguous segments
Setting up band-pass filter from 7 - 30 Hz
FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 7.00
- Lower transition bandwidth: 2.00 Hz (-6 dB cutoff frequency: 6.00 Hz)
- Upper passband edge: 30.00 Hz
- Upper transition bandwidth: 7.50 Hz (-6 dB cutoff frequency: 33.75 Hz)
- Filter length: 265 samples (1.656 s)
Used Annotations descriptions: ['T1', 'T2']
Not setting metadata
45 matching events found
No baseline correction applied
0 projection items activated
Using data from preloaded Raw for 45 events and 801 original time points ...
0 bad epochs dropped
(45, 64, 801)
160.0
[6]:
n_epcoh, n_channels, n_samples = data.shape
print(f"data.shape: {n_epcoh} epcoh X {n_channels} channels X {n_samples} samples")
data.shape: 45 epcoh X 7 channels X 801 samples
aperiodic parameter defined by FOOOF#
[7]:
fea1 = Feature(data=data, sfreq=160,selected_funcs=['aperiodic_periodic_offset_exponent_cf'],
funcs_params={"aperiodic_periodic_offset_exponent_cf__sfreq":160,
"aperiodic_periodic_offset_exponent_cf__n":512,
"aperiodic_periodic_offset_exponent_cf__freq_range":[1,40],
"aperiodic_periodic_offset_exponent_cf__method":"welch"})
return description#
[8]:
print(fea1)
45(epochs) x 7(channels) x 2(features)
feature names: ['aperiodic_periodic_offset_exponent_cf0'
'aperiodic_periodic_offset_exponent_cf1']
The Third dimension: [Offset, Exponent]
[9]:
n_epochs, n_channels, n_features = fea1.features.shape
print(n_epochs, n_channels, n_features)
45 7 2
The intercept and slope of PSD#
[11]:
fea2 = Feature(data=data, sfreq=160,selected_funcs=['offset_exponent_cf'],
funcs_params={"offset_exponent_cf__sfreq":160,
"offset_exponent_cf__n":512,
"offset_exponent_cf__freq_range":[1,40],
"offset_exponent_cf__method":"welch"})
print(fea2.features.shape)
(45, 7, 2)
return description#
[12]:
print(fea2)
45(epochs) x 7(channels) x 2(features)
feature names: ['offset_exponent_cf0' 'offset_exponent_cf1']
The Third dimension:[intercept, slope]
[13]:
n_epochs, n_channels, n_features = fea1.features.shape
print(n_epochs, n_channels, n_features)
45 7 2