Browse Source

업데이트 'README.md'

Hio-Been Han 4 years ago
parent
commit
fbb14125cf
1 changed files with 46 additions and 44 deletions
  1. 46 44
      README.md

+ 46 - 44
README.md

@@ -35,7 +35,7 @@ Raw EEG data are saved in EEGLAB dataset format (*.set). Below are the list of f
     
 **d) Example python/matlab scripts**
 
-    [data_description.ipynb, data_description.py (written and tested on Python 3 environment)
+    [data_description.ipynb (written and tested on Google COLAB - Python 3 environment)
     
     
 <br>
@@ -128,12 +128,12 @@ meta
 
 ### 1-3. Data loading and dimensionality check
 
-Each _*.fdt_ file is consisted of different number of trials. To load dataset, a function *get_eeg_data()* is defined below. To maintain original dimensionality order (cf. channel-time-trial in EEGLAB of Matlab), *np.moveaxis* was applied. 
+Each _*.fdt_ file is consisted of different number of trials. To load dataset, a function *get_eeg_data()* is defined below. To maintain original dimensionality order (cf. channel-time-trial in EEGLAB of Matlab), *np.moveaxis()* was applied. 
 
 
 ```python
 # Demo 1-3. Data loading and dimensionality check
-from mne.io import read_epochs_eeglab as loadeeg
+from -mne.io import read_epochs_eeglab as loadeeg
 import numpy as np
 def get_eeg_data(dataset_idx, CAL=1e-6):
   f_name = '%s%srawdata/%s'%(dir_origin,dir_dataset,meta.file_name[dataset_idx])
@@ -272,7 +272,7 @@ def plot_multichan( x, y, spacing = 3000, figsize = (10,10), ch_names = EEG.ch_n
 ```
   
   
-Using *plot_multichan()* function, example single-trial EEG trace can be visaulized as follow.
+Using *plot_multichan()* function, example single-trial EEG trace can be visualized as follow.
 
 ```
 # Demo 2-2b. Visualization of raw EEG time trace
@@ -302,44 +302,45 @@ plt.title('Condition #%d: %s (n=%d)'%(targetCondition, condNames[targetCondition
 
 ### 2-4. ERP in frequency domain
 
-As the sensory stimuli used in this experiment was 40 Hz click train, one can easily see the 40 Hz evoked (steady-state) response in the time-domain ERP. Through 
+To calculate the amplitude of 40-Hz auditory steady-state response, fast Fourier transform can be applied as follow. 
 
 ```python
-# Demo 2-4. Time- and frequency-domain visualization of grand-averaged ERP
-from numpy.fft import fft
-def fft_half(x, Fs=2000): return fft(x)[:int(len(x)/2)]/len(x), np.linspace(0,Fs/2,len(x)/2)
+# Demo2-4.Time- and frequency-domain visualization of ERP
+fromnumpy.fftimportfft
+deffft_half(x,Fs=2000):returnfft(x)[:int(len(x)/2)]/len(x),np.linspace(0,Fs/2,len(x)/2)
 
-plt.figure(figsize=(14,8))
-
-erp = np.nanmean(EEG.data[:,:,np.where((EEG.events[:,2])==2)[0]],2)
-ac_erp = np.mean(erp[:36,],0)
-ac_erp_fft,freq = fft_half(ac_erp)
+# Get ERP in frequency domain
+erp=np.nanmean(EEG.data[:,:,np.where((EEG.events[:,2])==2)[0]],2)
+ac_erp=np.mean(erp[:36,],0)
+ac_erp_fft,freq=fft_half(ac_erp)
 
-# Plot time-domain signal
+# Plot time-domain ERP
+plt.figure(figsize=(14,8))
 plt.subplot(2,1,1)
-plt.plot( EEG.times, ac_erp, linewidth=.5 )
+plt.plot(EEG.times,ac_erp,linewidth=.5)
 plt.xlim((-.8,1.8))
-plt.xlabel('Time (sec)')
-plt.ylabel('Amplitude (mV)')
-plt.title('ERP signal in time domain')
+plt.xlabel(‘Time(sec)’)
+plt.ylabel(‘Amplitude(mV)’)
+plt.title(‘ERPsignalintimedomain’)
 plt.gca().set_facecolor((1,1,1))
 
-# Plot frequency-domain signal
+# Plot frequency-domain ERP
 plt.subplot(2,1,2)
-plt.plot( freq, np.abs(ac_erp_fft), linewidth=1 )
+plt.plot(freq,np.abs(ac_erp_fft),linewidth=1)
 plt.xlim((0,80))
-plt.xlabel('Freq (Hz)')
-plt.ylabel('Amplitude (mV/Hz)')
-plt.title('ERP signal in frequency domain')
+plt.xlabel(‘Freq(Hz)’)
+plt.ylabel(‘Amplitude(mV/Hz)’)
+plt.title(‘ERPsignalinfrequencydomain’)
 plt.gca().set_facecolor((1,1,1))
 
-plt.subplots_adjust(wspace=.3, hspace=.5)
+plt.subplots_adjust(wspace=.3,hspace=.5)
+
 ```
 
 
 ### 2-5. ERP in time-frequency domain
 
-Applying fast fourier-transform with moving temporal window, ERP signal can be drawn in time-frequency domain. To calculate spectrogram, a function *get_spectrogram()* is defined.
+Applying fast Fourier transform with moving temporal window, ERP signal can be drawn in time-frequency domain. To calculate spectrogram, a function *get_spectrogram()* is defined.
 
 ```python
 # Demo 2-5. Visualize frequency components in ERP
@@ -573,11 +574,10 @@ def plot_topo2d(data, clim=(-15,25), montage_file='%s%smontage.csv'%(dir_origin,
 
 **Optional) Bad channel identification**
  
-Before drawing power topography, researchers usually eliminate bad channel data. Here, simple bad channel identification method is considered using channel correlation. Data from the bad channels identified here will be ignored and replaced by median hereafter.
+In typical EEG recordings, large amplitude signals coming from bad channel usually be a problem. To prevent this, researchers usually eliminate bad channel data before drawing power topography. Here, simple bad channel identification method is implemented using channel correlation. Data from the bad channels identified here will be ignored and replaced by median value hereafter.
 
 ```python
 # Demo 3-1b. Identification of bad-channel using correlation
-""" Bad-channel selection (correlation based) """
 from scipy.stats import ttest_1samp as ttest
 
 ga_erp = np.nanmean(EEG.data[:36,:,:],2)
@@ -606,7 +606,7 @@ print('\nLow-correlated (bad) channels: %s'%(bad_channels))
 
 ### 3-2. Time-course of raw voltage topography
 
-Input data of EEG topography can be defined by any mean; voltage, band-limited power, instantaneous phase, and so on. In this example, spatial distribution of raw voltage at specific time point is drawn. For better understanding of the data, ERP time traces at frontal and parietal area are also drawn.
+Input data of EEG topography can be defined by any mean; voltage, band-limited power, instantaneous angle, and so on. In this example, spatial distribution of raw voltage at specific time point is drawn. For better understanding of the data, ERP time traces at frontal and parietal area are also drawn.
 
 ```python
 # Demo 3-2. Raw voltage topography
@@ -624,29 +624,29 @@ for targetCondition in conditions:
   plt.subplot(len(conditions),1,np.where(np.array(conditions)==targetCondition)[0]+1)
   color_f = (.68,.210,.27) # Custom color value
   color_p = (.01,.457,.74)
-  plt.grid('off')
-  plt.plot((0,0),(-30,45), '--', linewidth = 1, color = (.8,.8,.8))
-  plt.plot((-.2,1), (0,0), '--', linewidth = 1, color = (.8,.8,.8))
+  plt.grid(‘off’)
+  plt.plot((0,0),(-30,45), ‘—‘, linewidth = 1, color = (.8,.8,.8))
+  plt.plot((-.2,1), (0,0), ‘—‘, linewidth = 1, color = (.8,.8,.8))
   plt.plot( EEG.times, frontal_erp,  color= color_f)
   plt.plot( EEG.times, parietal_erp, color= color_p)
-  plt.xlabel('Time (msec)')
+  plt.xlabel(‘Time (msec)’)
   plt.xlim((-.2,1))
   plt.ylim((-30,45))
-  plt.axis('off')
+  plt.axis(‘off’)
   plt.gca().set_facecolor((1,1,1))
-  plt.text( -.1, 27, 'Frontal', ha='center', weight='bold', fontsize=12, color=color_f )
-  plt.text( -.1, 20,'Parietal', ha='center', weight='bold', fontsize=12, color=color_p )
-  plt.title('%s'%condNames[targetCondition-1])
+  plt.text( -.1, 27, ‘Frontal’, ha=‘center’, weight=‘bold’, fontsize=12, color=color_f )
+  plt.text( -.1, 20,’Parietal’, ha=‘center’, weight=‘bold’, fontsize=12, color=color_p )
+  plt.title(‘%s’%condNames[targetCondition-1])
   
   # Calculate topography data 
   t_slice = [  (.005, .025), (.0250, .0550), (.200, .210),(.502, .512), (.925, .935)  ]  
   y_mark = [-20, 33, 10, 5, 10]
-  colors = ['r','g','b','c','m'] # color marker
+  colors = [‘r’,’g’,’b’,’c’,’m’] # color marker
   topos = []
   for tIdx in range(len(t_slice)):
     x_start, x_end, y_pos = t_slice[tIdx][0], t_slice[tIdx][1], y_mark[tIdx]
     idx_start, idx_end = np.where(EEG.times==x_start)[0][0], np.where(EEG.times==x_end)[0][0]
-    plt.plot( EEG.times[[idx_start,idx_end]], [y_pos, y_pos], colors[tIdx]+'|-')
+    plt.plot( EEG.times[[idx_start,idx_end]], [y_pos, y_pos], colors[tIdx]+’|-‘)
     topo_in = np.mean( erp[:36,idx_start:idx_end],1 )
     # bad-channel replacement
     topo_in[bad_channels] = np.median( topo_in.flatten() ) 
@@ -692,20 +692,20 @@ targetCondition = 6 # = Auditory sound only
 trialIdx = np.where((EEG.events[:,2])==targetCondition)[0]
 erp = np.mean(EEG.data[:,:,trialIdx],2)
 period = [ (-.5,0.), (0.,.5), (.5, 1.), (1.,1.5) ] # time in second
-periodName = ['Pre-stim', 'Stim (Early)', 'Stim (Late)', 'Post-stim'];
+periodName = [‘Pre-stim’, ‘Stim (Early)’, ‘Stim (Late)’, ‘Post-stim’];
 freq = 40 # Hz
 plt.figure(figsize=(15,3))
 for periodIdx in range(len(period)):
   tIdx = (EEG.times>period[periodIdx][0]) & (EEG.times<=period[periodIdx][1])
   
   # Calculate power & Substitute bad-channel value
-  power = band_power(erp[:36,tIdx], np.array([-2,2])+freq, EEG.info['sfreq'])
+  power = band_power(erp[:36,tIdx], np.array([-2,2])+freq, EEG.info[‘sfreq’])
   power[bad_channels]= np.median(power.flatten())
   
   # Draw
   plt.subplot(1,len(period),periodIdx+1)
   plot_topo2d(power, clim=(0,3) )
-  plt.title('%s, t = [%.1f, %.1f]s'%(periodName[periodIdx],period[periodIdx][0],period[periodIdx][1]))
+  plt.title(‘%s, t = [%.1f, %.1f]s’%(periodName[periodIdx],period[periodIdx][0],period[periodIdx][1]))
 
 ```
 
@@ -725,13 +725,15 @@ for targetCondition in conditions:
   erp = np.mean(EEG.data[:,:,trialIdx],2)
   
   # Calculate power & Substitute bad-channel value
-  power = band_power(erp[:36,tIdx], np.array([-2,2])+freq, EEG.info['sfreq'])
+  power = band_power(erp[:36,tIdx], np.array([-2,2])+freq, EEG.info[‘sfreq’])
   power[bad_channels]= np.median(power.flatten())
   
   # Draw
   plt.subplot(1,len(conditions),np.where(np.array(conditions)==targetCondition)[0]+1)
   plot_topo2d(power, clim=(0,7) )
-  plt.title('%s'%condNames[targetCondition-1])
-  if targetCondition is not conditions[0]: plt.ylabel('')
+  plt.title(‘%s’%condNames[targetCondition-1])
+  if targetCondition is not conditions[0]: plt.ylabel(‘’)
 ```
+<br>
 
+Enjoy!