Changeset 200 for trunk/synapse/Puzzlebox
- Timestamp:
- 11/04/10 15:38:28 (12 years ago)
- Location:
- trunk/synapse/Puzzlebox/Synapse
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/synapse/Puzzlebox/Synapse/Interface.py
r199 r200 10 10 11 11 __changelog__ = """\ 12 Last Update: 2010. 09.2112 Last Update: 2010.11.04 13 13 14 14 """ … … 736 736 def exportData(self): 737 737 738 textOutput = self.textEditDebugConsole.toPlainText()739 740 738 #output_file = 'text.synapse' 739 740 (date, localtime) = self.parseTimeStamp(time.time()) 741 742 default_filename = '%s %s.csv' % (date, \ 743 self.lineEditSessionProfile.text()) 741 744 742 745 output_file = QtGui.QFileDialog.getSaveFileName(self, \ 743 746 "Export Synapse Data to File", \ 744 "", \ 745 "Text File (*.txt)") 746 747 default_filename, \ 748 "CSV File (*.csv);;Text File (*.txt)") 749 750 print output_file 751 752 if str(output_file).endswith('.csv'): 753 754 outputData = self.exportDataToCSV() 755 756 757 else: 758 759 outputData = self.textEditDebugConsole.toPlainText() 760 761 747 762 file = open(output_file, 'w') 748 file.write( textOutput)763 file.write(outputData) 749 764 file.close() 765 766 767 ################################################################## 768 769 def exportDataToCSV(self): 770 771 header = 'Date,Time,Delta,Theta,Low Alpha,High Alpha,Low Beta,High Beta,Low Gamma,Mid Gamma,Attention,Meditation,Signal Level\n' 772 773 csv = {} 774 775 for packet in self.packets['signals']: 776 777 if 'rawEeg' in packet.keys(): 778 continue 779 780 if packet['timestamp'] not in csv.keys(): 781 782 print packet 783 timestamp = packet['timestamp'] 784 (date, localtime) = self.parseTimeStamp(timestamp) 785 786 csv[timestamp] = {} 787 csv[timestamp]['Date'] = date 788 csv[timestamp]['Time'] = localtime 789 csv[timestamp]['Delta'] = '' 790 csv[timestamp]['Theta'] = '' 791 csv[timestamp]['Low Alpha'] = '' 792 csv[timestamp]['High Alpha'] = '' 793 csv[timestamp]['Low Beta'] = '' 794 csv[timestamp]['High Beta'] = '' 795 csv[timestamp]['Low Gamma'] = '' 796 csv[timestamp]['Mid Gamma'] = '' 797 csv[timestamp]['Attention'] = '' 798 csv[timestamp]['Meditation'] = '' 799 csv[timestamp]['Signal Level'] = '' 800 801 802 if 'eSense' in packet.keys(): 803 if 'attention' in packet['eSense'].keys(): 804 csv[timestamp]['Attention'] = packet['eSense']['attention'] 805 if 'meditation' in packet['eSense'].keys(): 806 csv[timestamp]['Meditation'] = packet['eSense']['meditation'] 807 808 if 'eegPower' in packet.keys(): 809 if 'delta' in packet['eegPower'].keys(): 810 csv[timestamp]['Delta'] = packet['eegPower']['delta'] 811 if 'theta' in packet['eegPower'].keys(): 812 csv[timestamp]['Theta'] = packet['eegPower']['theta'] 813 if 'lowAlpha' in packet['eegPower'].keys(): 814 csv[timestamp]['Low Alpha'] = packet['eegPower']['lowAlpha'] 815 if 'highAlpha' in packet['eegPower'].keys(): 816 csv[timestamp]['High Alpha'] = packet['eegPower']['highAlpha'] 817 if 'lowBeta' in packet['eegPower'].keys(): 818 csv[timestamp]['Low Beta'] = packet['eegPower']['lowBeta'] 819 if 'highBeta' in packet['eegPower'].keys(): 820 csv[timestamp]['High Beta'] = packet['eegPower']['highBeta'] 821 if 'lowGamma' in packet['eegPower'].keys(): 822 csv[timestamp]['Low Gamma'] = packet['eegPower']['lowGamma'] 823 if 'highGamma' in packet['eegPower'].keys(): 824 csv[timestamp]['Mid Gamma'] = packet['eegPower']['highGamma'] 825 826 if 'poorSignalLevel' in packet.keys(): 827 csv[timestamp]['Signal Level'] = packet['poorSignalLevel'] 828 829 830 output = header 831 832 csv_keys = csv.keys() 833 csv_keys.sort() 834 835 for key in csv_keys: 836 837 row = '%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n' % \ 838 (csv[key]['Date'], \ 839 csv[key]['Time'], \ 840 csv[key]['Delta'], \ 841 csv[key]['Theta'], \ 842 csv[key]['Low Alpha'], \ 843 csv[key]['High Alpha'], \ 844 csv[key]['Low Beta'], \ 845 csv[key]['High Beta'], \ 846 csv[key]['Low Gamma'], \ 847 csv[key]['Mid Gamma'], \ 848 csv[key]['Attention'], \ 849 csv[key]['Meditation'], \ 850 csv[key]['Signal Level']) 851 852 853 output = output + row 854 855 856 return(output) 750 857 751 858 -
trunk/synapse/Puzzlebox/Synapse/Protocol.py
r198 r200 706 706 707 707 708 process_packet['timestamp'] = packet_update['timestamp'] 709 710 708 711 if self.DEBUG > 3: 709 712 print self.data_packet
Note: See TracChangeset
for help on using the changeset viewer.