frrostbitee

EEG_Discrete FT

Oct 24th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. ##utility file to process the eeg data received in the form of csv format
  2. ##  This file calculated discrete fourier transform of the data
  3.  
  4. import csv
  5. import math
  6. import cmath
  7.  
  8. a_list = []
  9.  
  10. #reading the csv file
  11. file_name = 'EEG_Data.csv'
  12. with open(file_name, 'rt') as cfile:
  13.     spamreader = csv.reader(cfile, delimiter=' ', quotechar='|')
  14.    
  15.     row_count = 0
  16.     for row in spamreader:
  17.         a_list.append( row[0].split(','))
  18.         row_count += 1
  19.  
  20.     #define the value of 'm' as the number of columns in the csv file
  21.     m = 22
  22.     n = row_count
  23.  
  24.     x = [0]*m
  25.     k = -1
  26.     # K : deviation factor, by default equal to -1
  27.     print ("Discrete Fourier transform in the order of colums:")
  28.     for j in range(0,m):
  29.         for i in range(1,n):
  30.             x[j] = x[j] + float(a_list[i][j])*cmath.exp(complex(0.0,-2*math.pi*i*k/n))
  31.         print(x[j]/n)
Add Comment
Please, Sign In to add comment