'''assessNet is a program designed to perform preventative maintenance
on nets used in EEG recordings.
must be run in the directory containing:
exported RedCap session data (csv)
net noise information (xlsx)
warranty information (xlsx)
for orgranization all this information should always be kept in the same directory'''
#bc ┌( ಠ_ಠ)┘@thirdBrainPrograms
import sys
import matplotlib.pyplot as plt
import pandas as pd
#import data at beginning to speed processing
#add your file to be analyzed --> add .csv --> exported from RedCap
#analyzed in four week intervals
sessData = pd.read_csv(r'COBRAHardwareTrackin_DATA_2021-10-21_1606.csv')
#read in the netnoise data --> review in four week intervals
noiseData = pd.read_excel('COBRA_nets.xlsx', sheet_name='WeeklyNetNoise10.18_11.15')
#warranty info
data = pd.read_excel('COBRA_nets.xlsx', sheet_name='WarrantyInfo', nrows=12)
data = data.loc[:, ~data.columns.str.contains('^Unnamed')]
i=data[data['Expired']== 0]
#implement password protection
password = input("Enter a password to unlock the analysis: ")
if password != 'your password here':
sys.exit()
else:
print('\n')
#third brain programs logo
print(' ┌( ಠ_ಠ)┘')
print('\n')
print('WELCOME TO ASSESS-NET!!')
print('\n')
while True:
#session analysis pipeline
#checks for general hardware performance over time for a single net
#pick your cap --> assessNet imports all the session data for a particular EEG net
#for the past four weeks
x = sessData.loc[sessData['cap'] == input('Please enter the three letter cap identifier: ')]
z = x['cap'].to_string(index=False)
print("\n")
print("SESSION")
print("\n")
#checks for first initial net noise stats
print("The session net noise stats for the past four weeks for this cap are:")
print(x['netnoisnum'].to_string(index=False))
print("\n")
#these next three metrics are meant to check net degradation over time
#during the course of the experiment.
#checks the first impendance
print("The first timepoint impedance stats for the past four weeks for this cap are:")
print(x['firstimpbad'].to_string(index=False))
print("\n")
#checks the second impendance
print("The second timepoint impedance stats for the past four weeks for this cap are:")
print(x['secondimpbad'].to_string(index=False))
print("\n")
#checks the third impendance
print("The third timepoint impedance stats for the past four weeks for this cap are:")
print(x['thirdimpbad'].to_string(index=False))
print("\n")
#any bad channels noted in net log?
print("The bad channels for the past four weeks for this cap are:")
print(x['chan'].to_string(index=False))
print("\n")
#results of cumulative weekly testing --> baseline net noise tests
#for the past four weeks
y = noiseData.loc[noiseData['Net'] == z]
print("\n")
print("NET NOISE")
print("\n")
print("The cumulative questionable channels for the past four weeks for this net are: ")
print("\n")
print(y['Cumulative Channels'].to_string(index=False))
print("\n")
print("The cumulative bad channels for the past four weeks for this net are: ")
print("\n")
print(y['Bad Channels'].to_string(index=False))
print("\n")
#todo --> put in the ratio of cumulative channels / 128
#and bad channels / 128 as two pie charts that will
#pop up when the user executes the code for a given net
#get the data
questionableCh = y['Cumulative Count'].to_string(index=False)
badCh = y['Bad Count'].to_string(index=False)
#change to int for chart
questInt = int(questionableCh)
badInt = int(badCh)
goodChannels = 128 - (questInt + badInt)
#create the piechart
pieLabels = ['Number of Questionable Channels : ' + str(questInt), 'Number of Bad Channels: ' + str(badInt), 'Number of Good Channels: ' + str(goodChannels)]
pieData = [questInt, badInt, goodChannels]
plt.pie(pieData, labels = pieLabels)
plt.legend(loc="upper left")
plt.show()
#ask user if they want to get more net stats
anotherNet = input('Would you like to check another net (Yes or No): ')
if anotherNet.lower() == ('no'):
break
else:
continue
#warranty reminder at the end --> reminds the user of nets still
#within the warranty timeframe
print('\n')
print('As a reminder, these nets are still under warranty: ')
print('\n')
print(i.to_string(index=False))