diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/EDA-Artifact-Detection-Script.py b/EDA-Artifact-Detection-Script.py index 13f0432..e77fc3b 100755 --- a/EDA-Artifact-Detection-Script.py +++ b/EDA-Artifact-Detection-Script.py @@ -11,7 +11,7 @@ matplotlib.rcParams['ps.useafm'] = True matplotlib.rcParams['pdf.use14corefonts'] = True -matplotlib.rcParams['text.usetex'] = True +matplotlib.rcParams['text.usetex'] = False def getWaveletData(data): @@ -29,7 +29,7 @@ def getWaveletData(data): # Create wavelet dataframes oneSecond = pd.date_range(start=startTime, periods=len(data), freq='1s') - halfSecond = pd.date_range(start=startTime, periods=len(data), freq='500L') + halfSecond = pd.date_range(start=startTime, periods=len(data), freq='500ms') # Compute wavelets cA_n, cD_3, cD_2, cD_1 = pywt.wavedec(data['EDA'], 'Haar', level=3) #3 = 1Hz, 2 = 2Hz, 1=4Hz @@ -109,10 +109,10 @@ def getFeatures(data,w1,wH): all_feat = np.hstack([statFeat,waveletFeat]) - if np.Inf in all_feat: + if np.inf in all_feat: print("Inf") - if np.NaN in all_feat: + if np.nan in all_feat: print("NaN") return list(all_feat) @@ -308,7 +308,7 @@ def plotData(data,labels,classifierList,filteredPlot=0,secondsPlot=0): plt.legend(['Raw SC','Filtered SC'],loc=0) # Label and Title each subplot - plt.ylabel('$\mu$S') + plt.ylabel(chr(956) + "S") plt.title(key) # Only include x axis label on final subplot diff --git a/load_files.py b/load_files.py index 789a296..da8a41f 100644 --- a/load_files.py +++ b/load_files.py @@ -99,7 +99,7 @@ def _loadSingleFile_E4(filepath,list_of_columns, expected_sample_rate,freq): # Get the startTime and sample rate startTime = pd.to_datetime(float(data.columns.values[0]),unit="s") - sampleRate = float(data.iloc[0][0]) + sampleRate = float(data.iloc[0].iloc[0]) data = data[data.index!=0] data.index = data.index-1 @@ -116,17 +116,17 @@ def _loadSingleFile_E4(filepath,list_of_columns, expected_sample_rate,freq): def loadData_E4(filepath): # Load EDA data - eda_data = _loadSingleFile_E4(os.path.join(filepath,'EDA.csv'),["EDA"],4,"250L") + eda_data = _loadSingleFile_E4(os.path.join(filepath,'EDA.csv'),["EDA"],4,"250ms") # Get the filtered data using a low-pass butterworth filter (cutoff:1hz, fs:8hz, order:6) eda_data['filtered_eda'] = butter_lowpass_filter(eda_data['EDA'], 1.0, 8, 6) # Load ACC data - acc_data = _loadSingleFile_E4(os.path.join(filepath,'ACC.csv'),["AccelX","AccelY","AccelZ"],32,"31250U") + acc_data = _loadSingleFile_E4(os.path.join(filepath,'ACC.csv'),["AccelX","AccelY","AccelZ"],32,"31250us") # Scale the accelometer to +-2g acc_data[["AccelX","AccelY","AccelZ"]] = acc_data[["AccelX","AccelY","AccelZ"]]/64.0 # Load Temperature data - temperature_data = _loadSingleFile_E4(os.path.join(filepath,'TEMP.csv'),["Temp"],4,"250L") + temperature_data = _loadSingleFile_E4(os.path.join(filepath,'TEMP.csv'),["Temp"],4,"250ms") data = eda_data.join(acc_data, how='outer') data = data.join(temperature_data, how='outer') @@ -229,17 +229,17 @@ def interpolateDataTo8Hz(data,sample_rate,startTime): if sample_rate<8: # Upsample by linear interpolation if sample_rate==2: - data.index = pd.date_range(start=startTime, periods=len(data), freq='500L') + data.index = pd.date_range(start=startTime, periods=len(data), freq='500ms') elif sample_rate==4: - data.index = pd.date_range(start=startTime, periods=len(data), freq='250L') - data = data.resample("125L").mean() + data.index = pd.date_range(start=startTime, periods=len(data), freq='250ms') + data = data.resample("125ms").mean() else: if sample_rate>8: # Downsample idx_range = list(range(0,len(data))) # TODO: double check this one data = data.iloc[idx_range[0::int(int(sample_rate)/8)]] # Set the index to be 8Hz - data.index = pd.date_range(start=startTime, periods=len(data), freq='125L') + data.index = pd.date_range(start=startTime, periods=len(data), freq='125ms') # Interpolate all empty values data = interpolateEmptyValues(data) diff --git a/requirements.txt b/requirements.txt index 8ba778e..e463dff 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -numpy==1.16.2 -scipy==1.2.1 -pandas==0.24.1 -scikit-learn==0.20.3 -matplotlib>=2.1.2 -PyWavelets==1.0.2 \ No newline at end of file +numpy==2.2.0 +scipy==1.14.1 +pandas==2.2.3 +scikit-learn==1.5.2 +matplotlib>=3.9.3 +PyWavelets==1.8.0 \ No newline at end of file