Surface NMR processing and inversion GUI
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

akvoGUI.py 60KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357
  1. #/usr/bin/env python
  2. import sys
  3. #import readline
  4. try:
  5. from akvo.gui.main_ui import Ui_MainWindow
  6. uicerr = False
  7. except: # Fallback
  8. from akvo.gui.mainui import Ui_MainWindow
  9. uicerr = """
  10. USING THE DEFAULT GUI FILES, AKVO MAY NOT WORK CORRECTLY!
  11. See INSTALL.txt for details regarding GUI configuration
  12. if you are encountering problems.
  13. Clicking ignore will prevent this warning from showing
  14. each time you launch Akvo.
  15. """
  16. import matplotlib
  17. #matplotlib.use("QT4Agg")
  18. from PyQt5 import QtCore, QtGui, QtWidgets
  19. import numpy as np
  20. import time
  21. import os
  22. from copy import deepcopy
  23. from matplotlib.backends.backend_qt4 import NavigationToolbar2QT #as NavigationToolbar
  24. import datetime, time
  25. from akvo.tressel import mrsurvey
  26. #from akvo.lemma import pyLemmaCore # Looking ahead!
  27. import pkg_resources # part of setuptools
  28. version = pkg_resources.require("Akvo")[0].version
  29. import yaml
  30. # Writes out numpy arrays into Eigen vectors as serialized by Lemma
  31. class MatrixXr(yaml.YAMLObject):
  32. yaml_tag = u'MatrixXr'
  33. def __init__(self, rows, cols, data):
  34. self.rows = rows
  35. self.cols = cols
  36. self.data = np.zeros((rows,cols))
  37. def __repr__(self):
  38. return "%s(rows=%r, cols=%r, data=%r)" % (self.__class__.__name__, self.rows, self.cols, self.data)
  39. class VectorXr(yaml.YAMLObject):
  40. yaml_tag = r'VectorXr'
  41. def __init__(self, array):
  42. self.size = np.shape(array)[0]
  43. self.data = array.tolist()
  44. def __repr__(self):
  45. # Converts to numpy array on import
  46. return "np.array(%r)" % (self.data)
  47. from collections import OrderedDict
  48. #def represent_ordereddict(dumper, data):
  49. # print("representing IN DA HOUSE!!!!!!!!!!!!!!!!!!!!!")
  50. # value = []
  51. # for item_key, item_value in data.items():
  52. # node_key = dumper.represent_data(item_key)
  53. # node_value = dumper.represent_data(item_value)
  54. # value.append((node_key, node_value))
  55. # return yaml.nodes.MappingNode(u'tag:yaml.org,2002:map', value)
  56. #yaml.add_representer(OrderedDict, represent_ordereddict)
  57. def setup_yaml():
  58. """ https://stackoverflow.com/a/8661021 """
  59. represent_dict_order = lambda self, data: self.represent_mapping('tag:yaml.org,2002:map', data.items())
  60. yaml.add_representer(OrderedDict, represent_dict_order)
  61. setup_yaml()
  62. class AkvoYamlNode(yaml.YAMLObject):
  63. yaml_tag = u'AkvoData'
  64. def __init__(self):
  65. self.Akvo_VERSION = version
  66. self.Import = OrderedDict() # {}
  67. self.Processing = OrderedDict()
  68. #def __init__(self, node):
  69. # self.Akvo_VERSION = node["version"]
  70. # self.Import = OrderedDict( node["Import"] ) # {}
  71. # self.Processing = OrderedDict( node["Processing"] )
  72. def __repr__(self):
  73. return "%s(name=%r, Akvo_VESION=%r, Import=%r, Processing=%r)" % (
  74. #self.__class__.__name__, self.Akvo_VERSION, self.Import, self.Processing )
  75. self.__class__.__name__, self.Akvo_VERSION, self.Import, OrderedDict(self.Processing) )
  76. #self.__class__.__name__, self.Akvo_VERSION, self.Import, OrderedDict(self.Processing))
  77. try:
  78. import thread
  79. except ImportError:
  80. import _thread as thread #Py3K compatibility
  81. class MyPopup(QtWidgets.QWidget):
  82. def __init__(self, name):
  83. super().__init__()
  84. self.name = name
  85. self.initUI()
  86. def initUI(self):
  87. lblName = QtWidgets.QLabel(self.name, self)
  88. class ApplicationWindow(QtWidgets.QMainWindow):
  89. def __init__(self):
  90. QtWidgets.QMainWindow.__init__(self)
  91. self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
  92. akvohome = os.path.expanduser("~") + "/.akvo"
  93. if not os.path.exists(akvohome):
  94. os.makedirs(akvohome)
  95. self.ui = Ui_MainWindow()
  96. self.ui.setupUi(self)
  97. if uicerr != False and not os.path.exists(akvohome+"/pyuic-warned"):
  98. reply = QtGui.QMessageBox.warning(self, 'Warning', uicerr, QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ignore)
  99. if reply == 1024: # "0x400" in hex
  100. pass
  101. elif reply == 1048576: # "0x100000" in hex
  102. warn = open( akvohome+"/pyuic-warned" ,"w" )
  103. warn.write("Gui files were not compiled locally using pyuic! Further warnings have been supressed")
  104. warn.close()
  105. self.RAWDataProc = None
  106. self.YamlNode = AkvoYamlNode()
  107. # initialise some stuff
  108. self.ui.lcdNumberTauPulse2.setEnabled(0)
  109. self.ui.lcdNumberTauPulse1.setEnabled(0)
  110. self.ui.lcdNumberNuTx.setEnabled(0)
  111. self.ui.lcdNumberTuneuF.setEnabled(0)
  112. self.ui.lcdNumberSampFreq.setEnabled(0)
  113. self.ui.lcdNumberTauDelay.setEnabled(0)
  114. self.ui.lcdNumberNQ.setEnabled(0)
  115. #MAK 20170126: add in a list to hold processing steps
  116. self.logText = []
  117. ####################
  118. # Make connections #
  119. ####################
  120. # Menu items
  121. self.ui.actionOpen_GMR.triggered.connect(self.openGMRRAWDataset)
  122. self.ui.actionSave_Preprocessed_Dataset.triggered.connect(self.SavePreprocess)
  123. self.ui.actionExport_Preprocessed_Dataset.triggered.connect(self.ExportPreprocess)
  124. self.ui.actionExport_Preprocessed_Dataset.setEnabled(False)
  125. self.ui.actionOpen_Preprocessed_Dataset.triggered.connect(self.OpenPreprocess)
  126. self.ui.actionAboutAkvo.triggered.connect(self.about)
  127. # Buttons
  128. # #QtCore.QObject.connect(self.ui.fullWorkflowPushButton, QtCore.SIGNAL("clicked()"), self.preprocess )
  129. self.ui.loadDataPushButton.pressed.connect(self.loadRAW)
  130. self.ui.sumDataGO.pressed.connect( self.sumDataChans )
  131. self.ui.bandPassGO.pressed.connect( self.bandPassFilter )
  132. self.ui.filterDesignPushButton.pressed.connect( self.designFilter )
  133. self.ui.fdDesignPushButton.pressed.connect( self.designFDFilter )
  134. self.ui.downSampleGO.pressed.connect( self.downsample )
  135. self.ui.windowFilterGO.pressed.connect( self.windowFilter )
  136. # self.ui.despikeGO.pressed.connect( self.despikeFilter ) # use smart stack instead
  137. self.ui.adaptGO.pressed.connect( self.adaptFilter )
  138. self.ui.adaptFDGO.pressed.connect( self.adaptFilterFD )
  139. self.ui.qdGO.pressed.connect( self.quadDet )
  140. self.ui.gateIntegrateGO.pressed.connect( self.gateIntegrate )
  141. self.ui.calcQGO.pressed.connect( self.calcQ )
  142. self.ui.FDSmartStackGO.pressed.connect( self.FDSmartStack )
  143. self.ui.harmonicGO.pressed.connect( self.harmonicModel )
  144. self.ui.plotQD.setEnabled(False)
  145. self.ui.plotQD.pressed.connect( self.plotQD )
  146. self.ui.plotGI.setEnabled(False)
  147. self.ui.plotGI.pressed.connect( self.plotGI )
  148. # hide header info box
  149. #self.ui.headerFileBox.setVisible(False)
  150. self.ui.headerFileBox.clicked.connect( self.headerBoxShrink )
  151. self.ui.headerBox2.setVisible(False)
  152. # Clean up the tab widget
  153. self.ui.actionPreprocessing.triggered.connect(self.addPreProc)
  154. self.ui.actionModelling.triggered.connect(self.addModelling)
  155. self.ui.actionInversion.triggered.connect(self.addInversion)
  156. # tabs
  157. #self.ui.ProcTabs.tabCloseRequested.connect( self.closeTabs )
  158. #self.ui.ProcTabs.tabBar().setTabButton(7, QtWidgets.QTabBar.RightSide,None)
  159. self.ui.ProcTabs.removeTab(4)
  160. self.ui.ProcTabs.removeTab(4)
  161. self.ui.ProcTabs.removeTab(4)
  162. self.ui.ProcTabs.removeTab(4)
  163. #self.ui.LoadTab.close( )
  164. # Add progressbar to statusbar
  165. self.ui.barProgress = QtWidgets.QProgressBar()
  166. self.ui.statusbar.addPermanentWidget(self.ui.barProgress, 0);
  167. self.ui.barProgress.setMaximumSize(100, 16777215);
  168. self.ui.barProgress.hide();
  169. self.ui.mplwidget_navigator.setCanvas(self.ui.mplwidget)
  170. #self.ui.mplwidget_navigator_2.setCanvas(self.ui.mplwidget)
  171. ##########################################################################
  172. # Loop Table
  173. self.ui.loopTableWidget.setRowCount(80)
  174. self.ui.loopTableWidget.setColumnCount(6)
  175. self.ui.loopTableWidget.setHorizontalHeaderLabels( ["ch. tag", \
  176. "Northing [m]","Easting [m]","Height [m]", "Radius","Tx"] )
  177. for ir in range(0, self.ui.loopTableWidget.rowCount() ):
  178. for ic in range(1, self.ui.loopTableWidget.columnCount() ):
  179. pCell = QtWidgets.QTableWidgetItem()
  180. #pCell.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
  181. pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable
  182. pCell.setBackground( QtGui.QColor("lightgrey").lighter(110) )
  183. self.ui.loopTableWidget.setItem(ir, ic, pCell)
  184. self.ui.loopTableWidget.cellChanged.connect(self.loopCellChanged)
  185. #self.ui.loopTableWidget.cellPressed.connect(self.loopCellChanged)
  186. self.ui.loopTableWidget.itemClicked.connect(self.loopCellClicked)
  187. #self.ui.loopTableWidget.cellPressed.connect(self.loopCellClicked)
  188. self.ui.loopTableWidget.setDragDropOverwriteMode(False)
  189. self.ui.loopTableWidget.setDragEnabled(False)
  190. #self.ui.loopTableWidget.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
  191. self.loops = {}
  192. ##########################################################################
  193. # layer Table
  194. self.ui.layerTableWidget.setRowCount(80)
  195. self.ui.layerTableWidget.setColumnCount(3)
  196. self.ui.layerTableWidget.setHorizontalHeaderLabels( [r"top [m]", r"bottom [m]", "σ [ Ωm]" ] )
  197. # do we want this
  198. self.ui.layerTableWidget.setDragDropOverwriteMode(False)
  199. self.ui.layerTableWidget.setDragEnabled(True)
  200. self.ui.layerTableWidget.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
  201. pCell = QtWidgets.QTableWidgetItem()
  202. pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable
  203. pCell.setBackground( QtGui.QColor("lightgrey").lighter(110) )
  204. self.ui.layerTableWidget.setItem(0, 1, pCell)
  205. for ir in range(1, self.ui.layerTableWidget.rowCount() ):
  206. for ic in range(0, self.ui.layerTableWidget.columnCount() ):
  207. pCell = QtWidgets.QTableWidgetItem()
  208. #pCell.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
  209. pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable
  210. pCell.setBackground( QtGui.QColor("lightgrey").lighter(110) )
  211. self.ui.layerTableWidget.setItem(ir, ic, pCell)
  212. self.ui.layerTableWidget.cellChanged.connect(self.sigmaCellChanged)
  213. def closeTabs(self):
  214. #self.ui.ProcTabs.removeTab(idx)
  215. self.ui.ProcTabs.clear( )
  216. def addPreProc(self):
  217. if self.ui.actionPreprocessing.isChecked():
  218. self.ui.actionModelling.setChecked(False)
  219. self.ui.actionInversion.setChecked(False)
  220. self.ui.ProcTabs.clear( )
  221. self.ui.ProcTabs.insertTab( 0, self.ui.LoadTab, "Load" )
  222. self.ui.ProcTabs.insertTab( 1, self.ui.NCTab, "NC" )
  223. self.ui.ProcTabs.insertTab( 2, self.ui.QCTab, "QC" )
  224. self.ui.ProcTabs.insertTab( 3, self.ui.METATab, "META" )
  225. self.ui.ProcTabs.insertTab( 4, self.ui.LogTab, "Log" )
  226. else:
  227. self.ui.ProcTabs.removeTab(0)
  228. self.ui.ProcTabs.removeTab(0)
  229. self.ui.ProcTabs.removeTab(0)
  230. self.ui.ProcTabs.removeTab(0)
  231. def addModelling(self):
  232. if self.ui.actionModelling.isChecked():
  233. self.ui.actionPreprocessing.setChecked(False)
  234. self.ui.actionInversion.setChecked(False)
  235. self.ui.ProcTabs.clear( )
  236. self.ui.ProcTabs.insertTab( 0, self.ui.KernTab, "Kernel" )
  237. self.ui.ProcTabs.insertTab( 1, self.ui.ModelTab, "Modelling" )
  238. self.ui.ProcTabs.insertTab( 2, self.ui.LogTab, "Log" )
  239. else:
  240. self.ui.ProcTabs.removeTab(0)
  241. self.ui.ProcTabs.removeTab(0)
  242. def addInversion(self, idx):
  243. if self.ui.actionInversion.isChecked():
  244. self.ui.actionPreprocessing.setChecked(False)
  245. self.ui.actionModelling.setChecked(False)
  246. self.ui.ProcTabs.clear( )
  247. self.ui.ProcTabs.insertTab( 0, self.ui.InvertTab, "Inversion" )
  248. self.ui.ProcTabs.insertTab( 1, self.ui.AppraiseTab, "Appraisal" )
  249. self.ui.ProcTabs.insertTab( 2, self.ui.LogTab, "Log" )
  250. else:
  251. self.ui.ProcTabs.removeTab(0)
  252. self.ui.ProcTabs.removeTab(0)
  253. def headerBoxShrink(self):
  254. #self.ui.headerFileBox.setVisible(False)
  255. if self.ui.headerFileBox.isChecked( ):
  256. #self.ui.headerFileBox.setMinimumSize(460,250)
  257. self.ui.headerBox2.setVisible(True)
  258. else:
  259. #self.ui.headerFileBox.setMinimumSize(460,50)
  260. self.ui.headerBox2.setVisible(False)
  261. def sigmaCellChanged(self):
  262. self.ui.layerTableWidget.cellChanged.disconnect(self.sigmaCellChanged)
  263. # TODO consider building the model whenever this is called. Would be nice to be able to
  264. # do that. Would require instead dist of T2 I guess.
  265. jj = self.ui.layerTableWidget.currentColumn()
  266. ii = self.ui.layerTableWidget.currentRow()
  267. val = "class 'NoneType'>"
  268. try:
  269. val = eval (str( self.ui.layerTableWidget.item(ii, jj).text() ))
  270. except:
  271. #if jj != 0:
  272. # Error = QtWidgets.QMessageBox()
  273. # Error.setWindowTitle("Error!")
  274. # Error.setText("Non-numeric value encountered")
  275. self.ui.layerTableWidget.cellChanged.connect(self.sigmaCellChanged)
  276. return
  277. if jj == 1:
  278. #item.setFlags(QtCore.Qt.ItemIsEnabled)
  279. pCell = self.ui.layerTableWidget.item(ii, jj)
  280. pCell.setBackground( QtGui.QColor("white"))
  281. pCell = self.ui.layerTableWidget.item(ii+1, jj-1)
  282. if str(type(pCell)) == "<class 'NoneType'>":
  283. pCell = QtWidgets.QTableWidgetItem()
  284. pCell.setFlags(QtCore.Qt.ItemIsEnabled)
  285. self.ui.layerTableWidget.setItem(ii+1, jj-1, pCell)
  286. if ii == 0:
  287. pCell.setText(str(val))
  288. #pCell3 = self.ui.layerTableWidget.item(ii+1, jj)
  289. #print ("setting", ii, jj, type(pCell3))
  290. #print ( "setting", ii, jj, type(pCell3))
  291. #pCell3.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
  292. #pCell3.setFlags( QtCore.Qt.ItemIsEditable )
  293. elif ii > 0:
  294. val2 = eval (str( self.ui.layerTableWidget.item(ii-1, jj).text() ))
  295. #print ("val2", val2, val, type(val))
  296. #if str(type(pCell)) == "<class 'NoneType'>":
  297. if type(val) == str or val > val2:
  298. pCell.setText(str(val))
  299. else:
  300. Error = QtWidgets.QMessageBox()
  301. Error.setWindowTitle("Error!")
  302. Error.setText("Non-increasing layer detected")
  303. Error.setDetailedText("Each layer interface must be below the one above it.")
  304. Error.exec_()
  305. pCell2 = self.ui.layerTableWidget.item(ii, jj)
  306. pCell2.setText(str(""))
  307. self.ui.layerTableWidget.cellChanged.connect(self.sigmaCellChanged)
  308. return
  309. # enable next layer
  310. pCell4 = self.ui.layerTableWidget.item(ii+1, jj)
  311. pCell4.setBackground( QtGui.QColor("lightblue") ) #.lighter(110))
  312. pCell4.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
  313. pCell5 = self.ui.layerTableWidget.item(ii+1, jj+1)
  314. pCell5.setBackground( QtGui.QColor("white"))
  315. pCell5.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
  316. print("ii", ii, "jj", jj)
  317. if ii == 0 and jj == 0:
  318. pCell = self.ui.layerTableWidget.item(0, 1)
  319. pCell.setBackground( QtGui.QColor("lightblue")) #.lighter(110) )
  320. pCell.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
  321. self.ui.layerTableWidget.cellChanged.connect(self.sigmaCellChanged)
  322. def loopCellClicked(self, item):
  323. print("checkstate", item.checkState(),item.row())
  324. #self.ui.loopTableWidget.itemClicked.disconnect(self.loopCellClicked)
  325. jj = item.column()
  326. ii = item.row()
  327. tp = type(self.ui.loopTableWidget.item(ii, 0))
  328. print("tp", tp, ii, jj)
  329. if str(tp) == "<class 'NoneType'>":
  330. return
  331. #print("Clicked", ii, jj)
  332. if jj == 5 and self.ui.loopTableWidget.item(ii, 0).text() in self.loops.keys():
  333. #print("jj=5")
  334. self.loops[ self.ui.loopTableWidget.item(ii, 0).text() ]["Tx"] = self.ui.loopTableWidget.item(ii, 5).checkState()
  335. # update surrogates
  336. print("updating surrogates")
  337. for point in self.loops[ self.ui.loopTableWidget.item(ii, 0).text() ]["points"][1:]:
  338. pCell = self.ui.loopTableWidget.item(point, 5)
  339. if self.ui.loopTableWidget.item(ii, 5).checkState():
  340. pCell.setCheckState(QtCore.Qt.Checked);
  341. else:
  342. pCell.setCheckState(QtCore.Qt.Unchecked);
  343. #print( "loops", self.loops[ self.ui.loopTableWidget.item(ii, 0).text() ]["Tx"])
  344. #self.ui.loopTableWidget.itemClicked.connect(self.loopCellClicked)
  345. def loopCellChanged(self):
  346. self.ui.loopTableWidget.cellChanged.disconnect(self.loopCellChanged)
  347. jj = self.ui.loopTableWidget.currentColumn()
  348. ii = self.ui.loopTableWidget.currentRow()
  349. if jj == 0 and len( self.ui.loopTableWidget.item(ii, jj).text().strip()) == 0:
  350. for jjj in range(jj+1,jj+6):
  351. pCell = self.ui.loopTableWidget.item(ii, jjj)
  352. pCell.setBackground( QtGui.QColor("white") )
  353. pCell.setFlags( QtCore.Qt.NoItemFlags | QtCore.Qt.ItemIsUserCheckable ) # not selectable
  354. elif jj == 0 and len( self.ui.loopTableWidget.item(ii, jj).text().strip() ): # ch. tag modified
  355. for jjj in range(jj+1,jj+5):
  356. pCell = self.ui.loopTableWidget.item(ii, jjj)
  357. pCell.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
  358. pCell.setBackground( QtGui.QColor("lightblue") )
  359. if self.ui.loopTableWidget.item(ii, jj).text() not in self.loops.keys():
  360. # This is a new loop ID
  361. self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ] = {}
  362. self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ]["Tx"] = self.ui.loopTableWidget.item(ii, 5).checkState()
  363. self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ]["points"] = [ii]
  364. # Transmitter cell
  365. pCell = self.ui.loopTableWidget.item(ii, jj+5)
  366. pCell.setCheckState(QtCore.Qt.Unchecked)
  367. pCell.setFlags( QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled )
  368. pCell.setBackground( QtGui.QColor("lightblue") )
  369. else:
  370. # This is an existing loop ID
  371. self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ]["points"].append( ii )
  372. pCell = self.ui.loopTableWidget.item(ii, jj+5)
  373. pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable
  374. if self.loops[ self.ui.loopTableWidget.item(ii, 0).text() ]["Tx"]:
  375. pCell.setCheckState(QtCore.Qt.Checked);
  376. else:
  377. pCell.setCheckState(QtCore.Qt.Unchecked);
  378. #pCell.setFlags( )
  379. pCell.setBackground( QtGui.QColor("lightblue") )
  380. self.plotLoops()
  381. self.ui.loopTableWidget.cellChanged.connect(self.loopCellChanged)
  382. def plotLoops(self):
  383. print("Plotting loopz")
  384. self.ui.mplwidget.reAxH(1)
  385. #self.ui.mplwidget.ax1.clear()
  386. #self.ui.mplwidget.ax2.clear()
  387. nor = dict()
  388. eas = dict()
  389. dep = dict()
  390. for ii in range( self.ui.loopTableWidget.rowCount() ):
  391. for jj in range( self.ui.loopTableWidget.columnCount() ):
  392. tp = type(self.ui.loopTableWidget.item(ii, jj))
  393. if str(tp) == "<class 'NoneType'>":
  394. pass
  395. elif not len(self.ui.loopTableWidget.item(ii, jj).text()):
  396. pass
  397. else:
  398. if jj == 0:
  399. idx = self.ui.loopTableWidget.item(ii, 0).text()
  400. if idx not in nor.keys():
  401. nor[idx] = list()
  402. eas[idx] = list()
  403. dep[idx] = list()
  404. if jj == 1:
  405. nor[idx].append( eval(self.ui.loopTableWidget.item(ii, 1).text()) )
  406. elif jj == 2:
  407. eas[idx].append( eval(self.ui.loopTableWidget.item(ii, 2).text()) )
  408. elif jj == 3:
  409. dep[idx].append( eval(self.ui.loopTableWidget.item(ii, 3).text()) )
  410. for ii in nor.keys():
  411. try:
  412. self.ui.mplwidget.ax1.plot( np.array(nor[ii]), np.array(eas[ii]) )
  413. except:
  414. pass
  415. #self.ui.mplwidget.figure.axes().set
  416. self.ui.mplwidget.ax1.set_aspect('equal') #, adjustable='box')
  417. self.ui.mplwidget.draw()
  418. def about(self):
  419. # TODO proper popup with info
  420. #self.w = MyPopup("""About Akvo \n
  421. # Akvo is an open source project developed primarily by Trevor Irons.
  422. #""")
  423. #self.w.setGeometry(100, 100, 400, 200)
  424. #self.w.show()
  425. # Just a splash screen for now
  426. logo = pkg_resources.resource_filename(__name__, 'akvo_about.png')
  427. pixmap = QtGui.QPixmap(logo)
  428. self.splash = QtWidgets.QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint)
  429. self.splash.show()
  430. def connectGMRDataProcessor(self):
  431. self.RAWDataProc = mrsurvey.GMRDataProcessor()
  432. self.RAWDataProc.progressTrigger.connect(self.updateProgressBar)
  433. self.RAWDataProc.enableDSPTrigger.connect(self.enableDSP)
  434. self.RAWDataProc.doneTrigger.connect(self.doneStatus)
  435. self.RAWDataProc.updateProcTrigger.connect(self.updateProc)
  436. def openGMRRAWDataset(self):
  437. """ Opens a GMR header file
  438. """
  439. try:
  440. with open('.gmr.last.path') as f:
  441. fpath = f.readline()
  442. pass
  443. except IOError as e:
  444. fpath = '.'
  445. self.headerstr = QtWidgets.QFileDialog.getOpenFileName(self, 'Open File', fpath)[0] # arg2 = File Type 'All Files (*)'
  446. self.ui.headerFileTextBrowser.clear()
  447. self.ui.headerFileTextBrowser.append(self.headerstr)
  448. if len(self.headerstr) == 0:
  449. return
  450. # clear the processing log
  451. self.ui.logTextBrowser.clear()
  452. self.logText = [] #MAK 20170126
  453. path,filen=os.path.split(str(self.headerstr))
  454. f = open('.gmr.last.path', 'w')
  455. f.write( str(self.headerstr) ) # prompt last file
  456. self.connectGMRDataProcessor()
  457. self.RAWDataProc.readHeaderFile(str(self.headerstr))
  458. # If we got this far, enable all the widgets
  459. self.ui.lcdNumberTauPulse1.setEnabled(True)
  460. self.ui.lcdNumberNuTx.setEnabled(True)
  461. self.ui.lcdNumberTuneuF.setEnabled(True)
  462. self.ui.lcdNumberSampFreq.setEnabled(True)
  463. self.ui.lcdNumberNQ.setEnabled(True)
  464. self.ui.headerFileBox.setEnabled(True)
  465. self.ui.headerFileBox.setChecked( True )
  466. self.ui.headerBox2.setVisible(True)
  467. self.ui.inputRAWParametersBox.setEnabled(True)
  468. self.ui.loadDataPushButton.setEnabled(True)
  469. # make plots as you import the dataset
  470. self.ui.plotImportCheckBox.setEnabled(True)
  471. self.ui.plotImportCheckBox.setChecked(True)
  472. # Update info from the header into the GUI
  473. self.ui.pulseTypeTextBrowser.clear()
  474. self.ui.pulseTypeTextBrowser.append(self.RAWDataProc.pulseType)
  475. self.ui.lcdNumberNuTx.display(self.RAWDataProc.transFreq)
  476. self.ui.lcdNumberTauPulse1.display(1e3*self.RAWDataProc.pulseLength[0])
  477. self.ui.lcdNumberTuneuF.display(self.RAWDataProc.TuneCapacitance)
  478. self.ui.lcdNumberSampFreq.display(self.RAWDataProc.samp)
  479. self.ui.lcdNumberNQ.display(self.RAWDataProc.nPulseMoments)
  480. self.ui.DeadTimeSpinBox.setValue(1e3*self.RAWDataProc.deadTime)
  481. self.ui.CentralVSpinBox.setValue( self.RAWDataProc.transFreq )
  482. if self.RAWDataProc.pulseType != "FID":
  483. self.ui.lcdNumberTauPulse2.setEnabled(1)
  484. self.ui.lcdNumberTauPulse2.display(1e3*self.RAWDataProc.pulseLength[1])
  485. self.ui.lcdNumberTauDelay.setEnabled(1)
  486. self.ui.lcdNumberTauDelay.display(1e3*self.RAWDataProc.interpulseDelay)
  487. self.ui.FIDProcComboBox.clear()
  488. if self.RAWDataProc.pulseType == "4PhaseT1":
  489. self.ui.FIDProcComboBox.insertItem(0, "Pulse 1")
  490. self.ui.FIDProcComboBox.insertItem(1, "Pulse 2")
  491. self.ui.FIDProcComboBox.insertItem(2, "Both")
  492. self.ui.FIDProcComboBox.setCurrentIndex (1)
  493. elif self.RAWDataProc.pulseType == "FID":
  494. self.ui.FIDProcComboBox.insertItem(0, "Pulse 1")
  495. self.ui.FIDProcComboBox.setCurrentIndex (0)
  496. def ExportPreprocess(self):
  497. """ This method export to YAML
  498. """
  499. try:
  500. with open('.akvo.last.yaml.path') as f:
  501. fpath = f.readline()
  502. pass
  503. except IOError as e:
  504. fpath = '.'
  505. fdir = os.path.dirname(fpath)
  506. # Pickle the preprocessed data dictionary
  507. SaveStr = QtWidgets.QFileDialog.getSaveFileName(self, "Save as", fdir, r"Processed data (*.yaml)")[0]
  508. spath,filen=os.path.split(str(SaveStr))
  509. f = open('.akvo.last.yaml.path', 'w')
  510. f.write( str(spath) ) # prompt last file
  511. INFO = {}
  512. INFO["headerstr"] = str(self.headerstr)
  513. INFO["pulseType"] = self.RAWDataProc.pulseType
  514. INFO["transFreq"] = self.RAWDataProc.transFreq.tolist()
  515. INFO["pulseLength"] = self.RAWDataProc.pulseLength.tolist()
  516. INFO["TuneCapacitance"] = self.RAWDataProc.TuneCapacitance.tolist()
  517. #INFO["samp"] = self.RAWDataProc.samp
  518. INFO["nPulseMoments"] = self.RAWDataProc.nPulseMoments
  519. #INFO["deadTime"] = self.RAWDataProc.deadTime
  520. INFO["processed"] = "Akvo v. 1.0, on " + time.strftime("%d/%m/%Y")
  521. # Pulse current info
  522. ip = 0
  523. INFO["Pulses"] = {}
  524. for pulse in self.RAWDataProc.DATADICT["PULSES"]:
  525. qq = []
  526. qv = []
  527. for ipm in range(self.RAWDataProc.DATADICT["nPulseMoments"]):
  528. #for istack in self.RAWDataProc.DATADICT["stacks"]:
  529. # print ("stack q", self.RAWDataProc.DATADICT[pulse]["Q"][ipm,istack-1])
  530. qq.append(np.mean( self.RAWDataProc.DATADICT[pulse]["Q"][ipm,:]) )
  531. qv.append(np.std( self.RAWDataProc.DATADICT[pulse]["Q"][ipm,:]/self.RAWDataProc.pulseLength[ip] ))
  532. INFO["Pulses"][pulse] = {}
  533. INFO["Pulses"][pulse]["units"] = "A"
  534. INFO["Pulses"][pulse]["current"] = VectorXr(np.array(qq)/self.RAWDataProc.pulseLength[ip])
  535. INFO["Pulses"][pulse]["variance"] = VectorXr(np.array(qv))
  536. ip += 1
  537. # Data
  538. if self.RAWDataProc.gated == True:
  539. INFO["Gated"] = {}
  540. INFO["Gated"]["abscissa units"] = "ms"
  541. INFO["Gated"]["data units"] = "nT"
  542. for pulse in self.RAWDataProc.DATADICT["PULSES"]:
  543. INFO["Gated"][pulse] = {}
  544. INFO["Gated"][pulse]["abscissa"] = VectorXr( self.RAWDataProc.GATEDABSCISSA )
  545. INFO["Gated"][pulse]["windows"] = VectorXr( self.RAWDataProc.GATEDWINDOW )
  546. for ichan in self.RAWDataProc.DATADICT[pulse]["chan"]:
  547. INFO["Gated"][pulse]["Chan. " + str(ichan)] = {}
  548. INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] = VectorXr( np.std(self.RAWDataProc.GATED[ichan]["NR"], axis=0) )
  549. for ipm in range(self.RAWDataProc.DATADICT["nPulseMoments"]):
  550. INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " CA"] = VectorXr(self.RAWDataProc.GATED[ichan]["CA"][ipm])
  551. INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " RE"] = VectorXr(self.RAWDataProc.GATED[ichan]["RE"][ipm])
  552. INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " IM"] = VectorXr(self.RAWDataProc.GATED[ichan]["IM"][ipm])
  553. #INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " IP"] = VectorXr(self.RAWDataProc.GATED[ichan]["IP"][ipm])
  554. #INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " NR"] = VectorXr(self.RAWDataProc.GATED[ichan]["NR"][ipm])
  555. #INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " STD" ] = VectorXr(self.RAWDataProc.GATED[ichan]["SIGMA"][ipm])
  556. # we have gated data
  557. # Window edges
  558. # Window centres
  559. with open(SaveStr, 'w') as outfile:
  560. #for line in self.logText:
  561. # outfile.write(line+"\n")
  562. yaml.dump(self.YamlNode, outfile)
  563. yaml.dump(INFO, outfile, default_flow_style=False)
  564. def SavePreprocess(self):
  565. #if "Saved" not in self.YamlNode.Processing.keys():
  566. # self.YamlNode.Processing["Saved"] = []
  567. #self.YamlNode.Processing["Saved"].append(datetime.datetime.now().isoformat())
  568. #self.Log()
  569. import pickle, os
  570. try:
  571. with open('.akvo.last.path') as f:
  572. fpath = f.readline()
  573. pass
  574. except IOError as e:
  575. fpath = '.'
  576. fdir = os.path.dirname(fpath)
  577. # Pickle the preprocessed data dictionary
  578. SaveStr = QtWidgets.QFileDialog.getSaveFileName(self, "Save as", fdir, r"Pickle (*.dmp)")
  579. print(SaveStr)
  580. spath,filen=os.path.split(str(SaveStr[0]))
  581. f = open('.akvo.last.path', 'w')
  582. f.write( str(spath) ) # prompt last file
  583. save = open(SaveStr[0], 'wb')
  584. # Add some extra info
  585. INFO = {}
  586. INFO["pulseType"] = self.RAWDataProc.pulseType
  587. INFO["transFreq"] = self.RAWDataProc.transFreq
  588. INFO["pulseLength"] = self.RAWDataProc.pulseLength
  589. INFO["TuneCapacitance"] = self.RAWDataProc.TuneCapacitance
  590. INFO["samp"] = self.RAWDataProc.samp
  591. INFO["nPulseMoments"] = self.RAWDataProc.nPulseMoments
  592. INFO["deadTime"] = self.RAWDataProc.deadTime
  593. INFO["transFreq"] = self.RAWDataProc.transFreq
  594. INFO["headerstr"] = str(self.headerstr)
  595. INFO["log"] = yaml.dump( self.YamlNode ) #self.logText #MAK 20170127
  596. self.RAWDataProc.DATADICT["INFO"] = INFO
  597. pickle.dump(self.RAWDataProc.DATADICT, save)
  598. save.close()
  599. # Export XML file suitable for USGS ScienceBase Data Release
  600. def ExportXML(self):
  601. """ This is a filler function for use by USGS collaborators
  602. """
  603. return 42
  604. def OpenPreprocess(self):
  605. import pickle
  606. try:
  607. with open('.akvo.last.path') as f:
  608. fpath = f.readline()
  609. pass
  610. except IOError as e:
  611. fpath = '.'
  612. #filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Open File', '.')
  613. fpath = QtWidgets.QFileDialog.getOpenFileName(self, 'Open preprocessed file', fpath, r"Pickle Files (*.dmp)")[0]
  614. f = open('.akvo.last.path', 'w')
  615. f.write( str(fpath) ) # prompt last file
  616. self.ui.logTextBrowser.clear()
  617. self.logText = []
  618. if len(fpath) == 0:
  619. return
  620. pfile = open(fpath,'rb')
  621. unpickle = pickle.Unpickler(pfile)
  622. self.connectGMRDataProcessor()
  623. self.RAWDataProc.DATADICT = unpickle.load()
  624. # This line causes Akvo to crash, if the header file is no longer there. We don't need to load the
  625. # file. TODO, need to disable "Load Data" in Load command though, as that is no longer possible.
  626. #self.RAWDataProc.readHeaderFile(self.RAWDataProc.DATADICT["INFO"]["headerstr"])
  627. self.headerstr = self.RAWDataProc.DATADICT["INFO"]["headerstr"]
  628. self.RAWDataProc.pulseType = self.RAWDataProc.DATADICT["INFO"]["pulseType"]
  629. self.RAWDataProc.transFreq = self.RAWDataProc.DATADICT["INFO"]["transFreq"]
  630. self.RAWDataProc.pulseLength = self.RAWDataProc.DATADICT["INFO"]["pulseLength"]
  631. self.RAWDataProc.TuneCapacitance = self.RAWDataProc.DATADICT["INFO"]["TuneCapacitance"]
  632. self.RAWDataProc.samp = self.RAWDataProc.DATADICT["INFO"]["samp"]
  633. self.RAWDataProc.nPulseMoments = self.RAWDataProc.DATADICT["INFO"]["nPulseMoments"]
  634. self.RAWDataProc.deadTime = self.RAWDataProc.DATADICT["INFO"]["deadTime"]
  635. self.RAWDataProc.transFreq = self.RAWDataProc.DATADICT["INFO"]["transFreq"]
  636. self.RAWDataProc.dt = 1./self.RAWDataProc.samp
  637. self.dataChan = self.RAWDataProc.DATADICT[ self.RAWDataProc.DATADICT["PULSES"][0] ]["chan"]
  638. # Keep backwards compatibility with prior saved pickles???
  639. #self.ui.logTextBrowser.clear()
  640. #self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False) )
  641. #for a in self.logText:
  642. # self.ui.logTextBrowser.append(str(a))
  643. #self.ui.logTextBrowser
  644. #self.ui.logTextBrowser.clear()
  645. #print ( self.RAWDataProc.DATADICT["INFO"]["log"] )
  646. self.logText = self.RAWDataProc.DATADICT["INFO"]["log"] # YAML
  647. self.YamlNode = AkvoYamlNode( ) #self.logText )
  648. self.YamlNode.Akvo_VERSION = (yaml.load( self.logText )).Akvo_VERSION
  649. self.YamlNode.Import = OrderedDict((yaml.load( self.logText )).Import)
  650. self.YamlNode.Processing = OrderedDict((yaml.load( self.logText )).Processing)
  651. #self.YamlNode.Akvo_VERSION = 2 #yaml.load( self.logText )["Akvo_VERSION"] #, Loader=yaml.RoundTripLoader) # offending line!
  652. #self.YamlNode = AkvoYamlNode( self.logText ) # offending line!
  653. #print("import type", type( self.YamlNode.Processing ))
  654. self.Log()
  655. #self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False) )
  656. #except KeyError:
  657. # pass
  658. # Remove "Saved" and "Loaded" from processing flow
  659. #if "Loaded" not in self.YamlNode.Processing.keys():
  660. # self.YamlNode.Processing["Loaded"] = []
  661. #self.YamlNode.Processing["Loaded"].append(datetime.datetime.now().isoformat())
  662. #self.Log()
  663. # If we got this far, enable all the widgets
  664. self.ui.lcdNumberTauPulse1.setEnabled(True)
  665. self.ui.lcdNumberNuTx.setEnabled(True)
  666. self.ui.lcdNumberTuneuF.setEnabled(True)
  667. self.ui.lcdNumberSampFreq.setEnabled(True)
  668. self.ui.lcdNumberNQ.setEnabled(True)
  669. self.ui.headerFileBox.setEnabled(True)
  670. self.ui.headerFileBox.setChecked( False )
  671. #self.ui.headerBox2.setVisible(True)
  672. self.ui.inputRAWParametersBox.setEnabled(True)
  673. self.ui.loadDataPushButton.setEnabled(True)
  674. # make plots as you import the dataset
  675. self.ui.plotImportCheckBox.setEnabled(True)
  676. self.ui.plotImportCheckBox.setChecked(True)
  677. # Update info from the header into the GUI
  678. self.ui.pulseTypeTextBrowser.clear()
  679. self.ui.pulseTypeTextBrowser.append(self.RAWDataProc.pulseType)
  680. self.ui.lcdNumberNuTx.display(self.RAWDataProc.transFreq)
  681. self.ui.lcdNumberTauPulse1.display(1e3*self.RAWDataProc.pulseLength[0])
  682. self.ui.lcdNumberTuneuF.display(self.RAWDataProc.TuneCapacitance)
  683. self.ui.lcdNumberSampFreq.display(self.RAWDataProc.samp)
  684. self.ui.lcdNumberNQ.display(self.RAWDataProc.nPulseMoments)
  685. self.ui.DeadTimeSpinBox.setValue(1e3*self.RAWDataProc.deadTime)
  686. self.ui.CentralVSpinBox.setValue( self.RAWDataProc.transFreq )
  687. if self.RAWDataProc.pulseType != "FID":
  688. self.ui.lcdNumberTauPulse2.setEnabled(1)
  689. self.ui.lcdNumberTauPulse2.display(1e3*self.RAWDataProc.pulseLength[1])
  690. self.ui.lcdNumberTauDelay.setEnabled(1)
  691. self.ui.lcdNumberTauDelay.display(1e3*self.RAWDataProc.interpulseDelay)
  692. self.ui.FIDProcComboBox.clear()
  693. if self.RAWDataProc.pulseType == "4PhaseT1":
  694. self.ui.FIDProcComboBox.insertItem(0, "Pulse 1") #, const QVariant & userData = QVariant() )
  695. self.ui.FIDProcComboBox.insertItem(1, "Pulse 2") #, const QVariant & userData = QVariant() )
  696. self.ui.FIDProcComboBox.insertItem(2, "Both") #, const QVariant & userData = QVariant() )
  697. if len( self.RAWDataProc.DATADICT["PULSES"]) == 2:
  698. self.ui.FIDProcComboBox.setCurrentIndex (2)
  699. elif self.RAWDataProc.DATADICT["PULSES"][0] == "Pulse 1":
  700. self.ui.FIDProcComboBox.setCurrentIndex (0)
  701. else:
  702. self.ui.FIDProcComboBox.setCurrentIndex (1)
  703. elif self.RAWDataProc.pulseType == "FID":
  704. self.ui.FIDProcComboBox.insertItem(0, "Pulse 1") #, const QVariant & userData = QVariant() )
  705. self.ui.FIDProcComboBox.setCurrentIndex (0)
  706. # QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("updateProgress(int)"), self.updateProgressBar)
  707. # QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("enableDSP()"), self.enableDSP)
  708. # QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("doneStatus()"), self.doneStatus)
  709. self.RAWDataProc.progressTrigger.connect(self.updateProgressBar)
  710. self.RAWDataProc.enableDSPTrigger.connect(self.enableDSP)
  711. self.RAWDataProc.doneTrigger.connect(self.doneStatus)
  712. self.enableAll()
  713. def loadRAW(self):
  714. #################################################
  715. # Check to make sure we are ready to process
  716. # Header
  717. if self.RAWDataProc == None:
  718. err_msg = "You need to load a header first."
  719. reply = QtGui.QMessageBox.critical(self, 'Error',
  720. err_msg) #, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
  721. return
  722. # Stacks
  723. try:
  724. self.procStacks = np.array(eval(str("np.r_["+self.ui.stacksLineEdit.text())+"]"))
  725. except:
  726. err_msg = "You need to set your stacks correctly.\n" + \
  727. "This should be a Python Numpy interpretable list\n" + \
  728. "of stack indices. For example 1:24 or 1:4,8:24"
  729. QtGui.QMessageBox.critical(self, 'Error', err_msg)
  730. return
  731. # Data Channels
  732. #Chan = np.arange(0,9,1)
  733. try:
  734. self.dataChan = np.array(eval(str("np.r_["+self.ui.dataChanLineEdit.text())+"]"))
  735. except:
  736. #QMessageBox messageBox;
  737. #messageBox.critical(0,"Error","An error has occured !");
  738. #messageBox.setFixedSize(500,200);
  739. #quit_msg = "Are you sure you want to exit the program?"
  740. #reply = QtGui.QMessageBox.question(self, 'Message',
  741. # quit_msg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
  742. err_msg = "You need to set your data channels correctly.\n" + \
  743. "This should be a Python Numpy interpretable list\n" + \
  744. "of indices. For example 1 or 1:3 or 1:3 5\n\n" + \
  745. "valid GMR data channels fall between 1 and 8. Note that\n" +\
  746. "1:3 is not inclusive of 3 and is the same as 1,2 "
  747. reply = QtGui.QMessageBox.critical(self, 'Error',
  748. err_msg) #, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
  749. return
  750. #############################
  751. # Reference Channels
  752. # TODO make sure no overlap between data and ref channels
  753. self.refChan = np.array( () )
  754. if str(self.ui.refChanLineEdit.text()): # != "none":
  755. try:
  756. self.refChan = np.array(eval(str("np.r_["+self.ui.refChanLineEdit.text())+"]"))
  757. except:
  758. err_msg = "You need to set your reference channels correctly.\n" + \
  759. "This should be a Python Numpy interpretable list\n" + \
  760. "of indices. For example 1 or 1:3 or 1:3 5\n\n" + \
  761. "valid GMR data channels fall between 1 and 8. Note that\n" +\
  762. "1:3 is not inclusive of 3 and is the same as 1,2 "
  763. QtGui.QMessageBox.critical(self, 'Error', err_msg)
  764. return
  765. #####################################################
  766. # Load data
  767. self.lock("loading RAW GMR dataset")
  768. if self.RAWDataProc.pulseType == "FID":
  769. self.procThread = thread.start_new_thread(self.RAWDataProc.loadFIDData, \
  770. (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
  771. str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
  772. 1e-3 * self.ui.DeadTimeSpinBox.value( ), self.ui.plotImportCheckBox.isChecked() )) #, self))
  773. elif self.RAWDataProc.pulseType == "4PhaseT1":
  774. self.procThread = thread.start_new_thread(self.RAWDataProc.load4PhaseT1Data, \
  775. (str(self.headerstr), self.procStacks, self.dataChan, self.refChan, \
  776. str(self.ui.FIDProcComboBox.currentText()), self.ui.mplwidget, \
  777. 1e-3 * self.ui.DeadTimeSpinBox.value( ), self.ui.plotImportCheckBox.isChecked() )) #, self))
  778. self.YamlNode.Import["GMR Header"] = self.headerstr
  779. self.YamlNode.Import["opened"] = datetime.datetime.now().isoformat()
  780. self.YamlNode.Import["pulse Type"] = str(self.RAWDataProc.pulseType)
  781. self.YamlNode.Import["stacks"] = self.procStacks.tolist()
  782. self.YamlNode.Import["data channels"] = self.dataChan.tolist()
  783. self.YamlNode.Import["reference channels"] = self.refChan.tolist()
  784. self.YamlNode.Import["pulse records"] = str(self.ui.FIDProcComboBox.currentText())
  785. self.YamlNode.Import["instrument dead time"] = (1e-3 * self.ui.DeadTimeSpinBox.value( ))
  786. self.Log ( )
  787. # should be already done
  788. # QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("updateProgress(int)"), self.updateProgressBar)
  789. # QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("enableDSP()"), self.enableDSP)
  790. # QtCore.QObject.connect(self.RAWDataProc, QtCore.SIGNAL("doneStatus()"), self.doneStatus)
  791. #self.ui.ProcessedBox.setEnabled(True)
  792. self.ui.lcdNumberFID1Length.setEnabled(1)
  793. self.ui.lcdNumberFID2Length.setEnabled(1)
  794. self.ui.lcdNumberResampFreq.setEnabled(1)
  795. self.ui.lcdTotalDeadTime.setEnabled(1)
  796. self.ui.lcdTotalDeadTime.display( self.ui.DeadTimeSpinBox.value( ) )
  797. #self.ui.lcdNumberFID1Length.display(0)
  798. #self.ui.lcdNumberFID2Length.display(0)
  799. #self.ui.lcdNumberResampFreq.display( self.RAWDataProc.samp )
  800. self.mpl_toolbar = NavigationToolbar2QT(self.ui.mplwidget, self.ui.mplwidget)
  801. self.ui.mplwidget.draw()
  802. def Log(self):
  803. #for line in yaml.dump(self.YamlNode, default_flow_style=False):
  804. #for line in nlogText:
  805. # self.ui.logTextBrowser.append( line )
  806. # self.logText.append( line )
  807. self.ui.logTextBrowser.clear()
  808. self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False) )
  809. def disable(self):
  810. self.ui.BandPassBox.setEnabled(False)
  811. self.ui.downSampleGroupBox.setEnabled(False)
  812. self.ui.windowFilterGroupBox.setEnabled(False)
  813. # self.ui.despikeGroupBox.setEnabled(False)
  814. self.ui.adaptBox.setEnabled(False)
  815. self.ui.adaptFDBox.setEnabled(False)
  816. self.ui.qCalcGroupBox.setEnabled(False)
  817. self.ui.FDSmartStackGroupBox.setEnabled(False)
  818. self.ui.sumDataBox.setEnabled(False)
  819. self.ui.qdGroupBox.setEnabled(False)
  820. self.ui.gateBox.setEnabled(False)
  821. def enableAll(self):
  822. self.enableDSP()
  823. self.enableQC()
  824. def enableDSP(self):
  825. # Bandpass filter
  826. self.ui.BandPassBox.setEnabled(True)
  827. self.ui.BandPassBox.setChecked(True)
  828. self.ui.bandPassGO.setEnabled(False) # need to design first
  829. self.ui.plotBP.setEnabled(True)
  830. self.ui.plotBP.setChecked(True)
  831. # downsample
  832. self.ui.downSampleGroupBox.setEnabled(True)
  833. self.ui.downSampleGroupBox.setChecked(True)
  834. # window
  835. self.ui.windowFilterGroupBox.setEnabled(True)
  836. self.ui.windowFilterGroupBox.setChecked(True)
  837. # Despike
  838. # self.ui.despikeGroupBox.setEnabled(True)
  839. # self.ui.despikeGroupBox.setChecked(False)
  840. # Adaptive filtering
  841. self.ui.adaptBox.setEnabled(True)
  842. self.ui.adaptBox.setChecked(True)
  843. # FD Adaptive filtering
  844. self.ui.adaptFDBox.setEnabled(True)
  845. self.ui.adaptFDBox.setChecked(True)
  846. # sum group box
  847. try:
  848. if len(self.dataChan) > 1:
  849. self.ui.sumDataBox.setEnabled(True)
  850. self.ui.sumDataBox.setChecked(True)
  851. except:
  852. pass
  853. # Quadrature Detect
  854. self.ui.qdGroupBox.setEnabled(True)
  855. self.ui.qdGroupBox.setChecked(True)
  856. self.enableQC()
  857. def enableQC(self):
  858. # Q calc
  859. self.ui.qCalcGroupBox.setEnabled(True)
  860. self.ui.qCalcGroupBox.setChecked(True)
  861. # FD SmartStack
  862. self.ui.FDSmartStackGroupBox.setEnabled(True)
  863. self.ui.FDSmartStackGroupBox.setChecked(True)
  864. # Quadrature detect
  865. try:
  866. for pulse in self.RAWDataProc.DATADICT["PULSES"]:
  867. np.shape(self.RAWDataProc.DATADICT[pulse]["Q"])
  868. self.RAWDataProc.DATADICT["stack"]
  869. self.ui.qdGroupBox.setEnabled(True)
  870. self.ui.qdGroupBox.setChecked(True)
  871. except:
  872. self.ui.qdGroupBox.setEnabled(False)
  873. self.ui.qdGroupBox.setChecked(False)
  874. # Gating
  875. try:
  876. self.RAWDataProc.DATADICT["CA"]
  877. self.ui.gateBox.setEnabled(True)
  878. self.ui.gateBox.setChecked(True)
  879. except:
  880. self.ui.gateBox.setEnabled(False)
  881. self.ui.gateBox.setChecked(False)
  882. def despikeFilter(self):
  883. self.lock("despike filter")
  884. thread.start_new_thread(self.RAWDataProc.despike, \
  885. (self.ui.windowSpinBox.value(), \
  886. self.ui.thresholdSpinBox.value(), \
  887. str(self.ui.replComboBox.currentText()), \
  888. self.ui.rollOnSpinBox.value(), \
  889. self.ui.despikeInterpWinSpinBox.value(),
  890. self.ui.mplwidget))
  891. def calcQ(self):
  892. if "Calc Q" not in self.YamlNode.Processing.keys():
  893. #print("In CalcQ", yaml.dump(self.YamlNode.Processing) )
  894. self.YamlNode.Processing["Calc Q"] = True
  895. #print( yaml.dump(self.YamlNode.Processing) )
  896. self.Log()
  897. else:
  898. err_msg = "Q values have already been calculated"
  899. reply =QtWidgets.QMessageBox.critical(self, 'Error',
  900. err_msg)
  901. return
  902. self.lock("pulse moment calculation")
  903. thread.start_new_thread(self.RAWDataProc.effectivePulseMoment, \
  904. (self.ui.CentralVSpinBox.value(), \
  905. self.ui.mplwidget))
  906. def harmonicModel(self):
  907. self.lock("harmonic noise modelling")
  908. thread.start_new_thread(self.RAWDataProc.harmonicModel, \
  909. (self.ui.f0Spin.value(), \
  910. self.ui.mplwidget))
  911. def FDSmartStack(self):
  912. if "TD stack" not in self.YamlNode.Processing.keys():
  913. self.YamlNode.Processing["TD stack"] = {}
  914. self.YamlNode.Processing["TD stack"]["outlier"] = str( self.ui.outlierTestCB.currentText() )
  915. self.YamlNode.Processing["TD stack"]["cutoff"] = str( self.ui.MADCutoff.value() )
  916. self.Log()
  917. else:
  918. err_msg = "TD noise cancellation has already been applied!"
  919. reply =QtWidgets.QMessageBox.critical(self, 'Error',
  920. err_msg)
  921. return
  922. self.lock("time-domain smart stack")
  923. thread.start_new_thread(self.RAWDataProc.TDSmartStack, \
  924. (str(self.ui.outlierTestCB.currentText()), \
  925. self.ui.MADCutoff.value(),
  926. self.ui.mplwidget))
  927. def adaptFilter(self):
  928. if "TD noise cancellation" not in self.YamlNode.Processing.keys():
  929. self.YamlNode.Processing["TD noise cancellation"] = {}
  930. self.YamlNode.Processing["TD noise cancellation"]["n_Taps"] = str(self.ui.MTapsSpinBox.value())
  931. self.YamlNode.Processing["TD noise cancellation"]["lambda"] = str(self.ui.adaptLambdaSpinBox.value())
  932. self.YamlNode.Processing["TD noise cancellation"]["truncate"] = str(self.ui.adaptTruncateSpinBox.value())
  933. self.YamlNode.Processing["TD noise cancellation"]["mu"] = str(self.ui.adaptMuSpinBox.value())
  934. self.YamlNode.Processing["TD noise cancellation"]["PCA"] = str(self.ui.PCAComboBox.currentText())
  935. self.Log()
  936. else:
  937. err_msg = "TD noise cancellation has already been applied!"
  938. reply =QtWidgets.QMessageBox.critical(self, 'Error', err_msg)
  939. #return
  940. self.lock("TD noise cancellation filter")
  941. thread.start_new_thread(self.RAWDataProc.adaptiveFilter, \
  942. (self.ui.MTapsSpinBox.value(), \
  943. self.ui.adaptLambdaSpinBox.value(), \
  944. self.ui.adaptTruncateSpinBox.value(), \
  945. self.ui.adaptMuSpinBox.value(), \
  946. str(self.ui.PCAComboBox.currentText()), \
  947. self.ui.mplwidget))
  948. def sumDataChans(self):
  949. if "Data sum" not in self.YamlNode.Processing.keys():
  950. self.YamlNode.Processing["Data sum"] = True
  951. self.Log()
  952. else:
  953. err_msg = "Data channels have already been summed!"
  954. reply =QtWidgets.QMessageBox.critical(self, 'Error',
  955. err_msg)
  956. return
  957. self.lock("Summing data channels")
  958. self.dataChan = [self.dataChan[0]]
  959. self.ui.sumDataBox.setEnabled(False)
  960. thread.start_new_thread( self.RAWDataProc.sumData, ( self.ui.mplwidget, 7 ) )
  961. def adaptFilterFD(self):
  962. self.lock("FD noise cancellation filter")
  963. thread.start_new_thread(self.RAWDataProc.adaptiveFilterFD, \
  964. (str(self.ui.windowTypeComboBox.currentText()), \
  965. self.ui.windowBandwidthSpinBox.value(), \
  966. self.ui.CentralVSpinBox.value(), \
  967. self.ui.mplwidget))
  968. def bandPassFilter(self):
  969. if "Bandpass filter" not in self.YamlNode.Processing.keys():
  970. self.YamlNode.Processing["Bandpass filter"] = {}
  971. self.YamlNode.Processing["Bandpass filter"]["central_nu"] = str(self.ui.CentralVSpinBox.value())
  972. self.YamlNode.Processing["Bandpass filter"]["passband"] = str(self.ui.passBandSpinBox.value())
  973. self.YamlNode.Processing["Bandpass filter"]["stopband"] = str(self.ui.stopBandSpinBox.value())
  974. self.YamlNode.Processing["Bandpass filter"]["gpass"] = str(self.ui.gpassSpinBox.value())
  975. self.YamlNode.Processing["Bandpass filter"]["gstop"] = str(self.ui.gstopSpinBox.value())
  976. self.YamlNode.Processing["Bandpass filter"]["type"] = str(self.ui.fTypeComboBox.currentText())
  977. self.Log()
  978. else:
  979. err_msg = "Bandpass filter has already been applied!"
  980. reply =QtWidgets.QMessageBox.critical(self, 'Error',
  981. err_msg)
  982. return
  983. self.lock("bandpass filter")
  984. nv = self.ui.lcdTotalDeadTime.value( ) + self.ui.lcdNumberFTauDead.value()
  985. self.ui.lcdTotalDeadTime.display( nv )
  986. thread.start_new_thread(self.RAWDataProc.bandpassFilter, \
  987. (self.ui.mplwidget, 0, self.ui.plotBP.isChecked() ))
  988. def downsample(self):
  989. self.lock("resampling")
  990. if "Resample" not in self.YamlNode.Processing.keys():
  991. self.YamlNode.Processing["Resample"] = {}
  992. self.YamlNode.Processing["Resample"]["downsample factor"] = []
  993. self.YamlNode.Processing["Resample"]["truncate length"] = []
  994. self.YamlNode.Processing["Resample"]["downsample factor"].append( str(self.ui.downSampleSpinBox.value() ) )
  995. self.YamlNode.Processing["Resample"]["truncate length"].append( str( self.ui.truncateSpinBox.value() ) )
  996. self.Log( )
  997. thread.start_new_thread(self.RAWDataProc.downsample, \
  998. (self.ui.truncateSpinBox.value(), \
  999. self.ui.downSampleSpinBox.value(),
  1000. self.ui.mplwidget))
  1001. def quadDet(self):
  1002. if "Quadrature detection" not in self.YamlNode.Processing.keys():
  1003. self.YamlNode.Processing["Quadrature detection"] = {}
  1004. self.YamlNode.Processing["Quadrature detection"]["trim"] = str( self.ui.trimSpin.value() )
  1005. self.Log()
  1006. else:
  1007. err_msg = "Quadrature detection has already been done!"
  1008. reply =QtWidgets.QMessageBox.critical(self, 'Error',
  1009. err_msg)
  1010. return
  1011. self.lock("quadrature detection")
  1012. thread.start_new_thread(self.RAWDataProc.quadDet, \
  1013. (self.ui.trimSpin.value(), int(self.ui.QDType.currentIndex()), self.ui.mplwidget))
  1014. self.ui.plotQD.setEnabled(True)
  1015. def plotQD(self):
  1016. self.lock("plot QD")
  1017. thread.start_new_thread(self.RAWDataProc.plotQuadDet, \
  1018. (self.ui.trimSpin.value(), int(self.ui.QDType.currentIndex()), self.ui.mplwidget))
  1019. def gateIntegrate(self):
  1020. if "Gate integrate" not in self.YamlNode.Processing.keys():
  1021. self.YamlNode.Processing["Gate integrate"] = {}
  1022. self.YamlNode.Processing["Gate integrate"]["gpd"] = str(self.ui.GPDspinBox.value( ) )
  1023. self.Log()
  1024. self.lock("gate integration")
  1025. thread.start_new_thread(self.RAWDataProc.gateIntegrate, \
  1026. (self.ui.GPDspinBox.value(), self.ui.trimSpin.value(), self.ui.mplwidget))
  1027. self.ui.actionExport_Preprocessed_Dataset.setEnabled(True)
  1028. self.ui.plotGI.setEnabled(True)
  1029. def plotGI(self):
  1030. self.lock("plot gate integrate")
  1031. thread.start_new_thread(self.RAWDataProc.plotGateIntegrate, \
  1032. (self.ui.GPDspinBox.value(), self.ui.trimSpin.value(), \
  1033. self.ui.QDType_2.currentIndex(), self.ui.mplwidget))
  1034. def designFilter(self):
  1035. [bord, fe] = self.RAWDataProc.designFilter( \
  1036. self.ui.CentralVSpinBox.value(), \
  1037. self.ui.passBandSpinBox.value(), \
  1038. self.ui.stopBandSpinBox.value(), \
  1039. self.ui.gpassSpinBox.value(), \
  1040. self.ui.gstopSpinBox.value(), \
  1041. str(self.ui.fTypeComboBox.currentText()),
  1042. self.ui.mplwidget)
  1043. self.ui.lcdNumberFilterOrder.display(bord)
  1044. self.ui.lcdNumberFTauDead.display(1e3*fe)
  1045. #self.ui.lcdNumberFilterOrder.display(bord)
  1046. self.ui.bandPassGO.setEnabled(1)
  1047. # self.ui.lcdNumberTauPulse2.display(1e3*self.RAWDataProc.pulseLength[1])
  1048. def windowFilter(self):
  1049. if "Window filter" not in self.YamlNode.Processing.keys():
  1050. self.YamlNode.Processing["Window filter"] = {}
  1051. self.YamlNode.Processing["Window filter"]["type"] = str(self.ui.windowTypeComboBox.currentText())
  1052. self.YamlNode.Processing["Window filter"]["width"] = str(self.ui.windowBandwidthSpinBox.value())
  1053. self.YamlNode.Processing["Window filter"]["centre"] = str(self.ui.CentralVSpinBox.value() )
  1054. self.Log()
  1055. else:
  1056. err_msg = "FD window has already been applied!"
  1057. reply =QtWidgets.QMessageBox.critical(self, 'Error',
  1058. err_msg)
  1059. return
  1060. self.lock("window filter")
  1061. thread.start_new_thread(self.RAWDataProc.windowFilter, \
  1062. (str(self.ui.windowTypeComboBox.currentText()), \
  1063. self.ui.windowBandwidthSpinBox.value(), \
  1064. self.ui.CentralVSpinBox.value(), \
  1065. self.ui.mplwidget))
  1066. def designFDFilter(self):
  1067. # thread.start_new_thread(self.RAWDataProc.computeWindow, ( \
  1068. # "Pulse 1",
  1069. # self.ui.windowBandwidthSpinBox.value(), \
  1070. # self.ui.CentralVSpinBox.value(), \
  1071. # str(self.ui.windowTypeComboBox.currentText()), \
  1072. # self.ui.mplwidget ))
  1073. a,b,c,d,dead = self.RAWDataProc.computeWindow( \
  1074. "Pulse 1",
  1075. self.ui.windowBandwidthSpinBox.value(), \
  1076. self.ui.CentralVSpinBox.value(), \
  1077. str(self.ui.windowTypeComboBox.currentText()), \
  1078. self.ui.mplwidget )
  1079. self.ui.lcdWinDead.display(dead)
  1080. def updateProgressBar(self, percent):
  1081. self.ui.barProgress.setValue(percent)
  1082. def updateProc(self):
  1083. if str(self.ui.FIDProcComboBox.currentText()) == "Pulse 1":
  1084. self.ui.lcdNumberFID1Length.display(self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0])
  1085. elif str(self.ui.FIDProcComboBox.currentText()) == "Pulse 2":
  1086. self.ui.lcdNumberFID2Length.display(self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][0])
  1087. else:
  1088. self.ui.lcdNumberFID1Length.display(self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0])
  1089. self.ui.lcdNumberFID2Length.display(self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][0])
  1090. self.ui.lcdNumberResampFreq.display( self.RAWDataProc.samp )
  1091. def doneStatus(self): # unlocks GUI
  1092. self.ui.statusbar.clearMessage ( )
  1093. self.ui.barProgress.hide()
  1094. self.updateProc()
  1095. self.enableAll()
  1096. def lock(self, string):
  1097. self.ui.statusbar.showMessage ( string )
  1098. self.ui.barProgress.show()
  1099. self.ui.barProgress.setValue(0)
  1100. self.disable()
  1101. def unlock(self):
  1102. self.ui.statusbar.clearMessage ( )
  1103. self.ui.barProgress.hide()
  1104. self.enableAll()
  1105. def done(self):
  1106. self.ui.statusbar.showMessage ( "" )
  1107. ################################################################
  1108. ################################################################
  1109. # Boiler plate main function
  1110. import pkg_resources
  1111. from pkg_resources import resource_string
  1112. import matplotlib.image as mpimg
  1113. import matplotlib.pyplot as plt
  1114. def main():
  1115. # splash screen logo
  1116. logo = pkg_resources.resource_filename(__name__, 'akvo.png')
  1117. logo2 = pkg_resources.resource_filename(__name__, 'akvo2.png')
  1118. qApp = QtWidgets.QApplication(sys.argv)
  1119. ssplash = False
  1120. if ssplash:
  1121. pixmap = QtGui.QPixmap(logo)
  1122. splash = QtWidgets.QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint)
  1123. splash.show()
  1124. aw = ApplicationWindow()
  1125. img=mpimg.imread(logo)
  1126. for ax in [ aw.ui.mplwidget ]:
  1127. ax.fig.clear()
  1128. subplot = ax.fig.add_subplot(111)
  1129. #ax.fig.patch.set_facecolor( None )
  1130. #ax.fig.patch.set_alpha( .0 )
  1131. subplot.imshow(img)
  1132. subplot.xaxis.set_major_locator(plt.NullLocator())
  1133. subplot.yaxis.set_major_locator(plt.NullLocator())
  1134. ax.draw()
  1135. if ssplash:
  1136. splash.showMessage("Loading modules")
  1137. splash.finish(aw)
  1138. #time.sleep(1)
  1139. aw.setWindowTitle("Akvo v"+str(version))
  1140. aw.show()
  1141. qApp.setWindowIcon(QtGui.QIcon(logo2))
  1142. sys.exit(qApp.exec_())
  1143. if __name__ == "__main__":
  1144. main()