rapidtide 3.0a8__py3-none-any.whl → 3.0a10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,19 +23,19 @@ A simple GUI for looking at the results of a rapidtide analysis
23
23
  import argparse
24
24
  import os
25
25
  import sys
26
+ from functools import partial
26
27
 
27
28
  import numpy as np
28
29
  import pandas as pd
29
30
  import pyqtgraph as pg
30
31
  from nibabel.affines import apply_affine
31
32
  from pyqtgraph.Qt import QtCore, QtGui, QtWidgets
32
- from statsmodels.robust.scale import mad
33
33
 
34
34
  import rapidtide.util as tide_util
35
35
  from rapidtide.Colortables import *
36
36
  from rapidtide.helper_classes import SimilarityFunctionFitter
37
37
  from rapidtide.OrthoImageItem import OrthoImageItem
38
- from rapidtide.RapidtideDataset import RapidtideDataset
38
+ from rapidtide.RapidtideDataset import RapidtideDataset, check_rt_spatialmatch
39
39
  from rapidtide.workflows.atlasaverage import summarizevoxels
40
40
 
41
41
  try:
@@ -103,11 +103,12 @@ def _get_parser():
103
103
  "--maskname", help="Set geometric mask image", dest="geommaskname", default=None
104
104
  )
105
105
  parser.add_argument(
106
- "--oldstyle",
107
- help="Use the old style layout",
108
- dest="compact",
109
- action="store_false",
110
- default=True,
106
+ "--uistyle",
107
+ action="store",
108
+ type=str,
109
+ choices=["normal", "old", "big"],
110
+ help="Set the window layout style. Default is 'normal'.",
111
+ default="normal",
111
112
  )
112
113
  parser.add_argument(
113
114
  "--verbosity",
@@ -115,13 +116,99 @@ def _get_parser():
115
116
  dest="verbose",
116
117
  metavar="VERBOSITY",
117
118
  type=int,
118
- default=1,
119
+ default=0,
120
+ )
121
+ parser.add_argument(
122
+ "--ignoredimmatch",
123
+ help="Do not check to see if dataset sizes match",
124
+ dest="ignoredimmatch",
125
+ action="store_true",
126
+ default=False,
119
127
  )
120
128
 
121
129
  return parser
122
130
 
123
131
 
124
- def selectFile():
132
+ def addDataset(
133
+ thisdatafileroot,
134
+ anatname=None,
135
+ geommaskname=None,
136
+ userise=False,
137
+ usecorrout=True,
138
+ useatlas=False,
139
+ forcetr=False,
140
+ forceoffset=False,
141
+ offsettime=0.0,
142
+ ignoredimmatch=False,
143
+ ):
144
+ global currentdataset, thesubjects, whichsubject, datafileroots
145
+ global verbosity
146
+
147
+ print("Loading", thisdatafileroot)
148
+ thissubject = RapidtideDataset(
149
+ "main",
150
+ thisdatafileroot,
151
+ anatname=anatname,
152
+ geommaskname=geommaskname,
153
+ userise=userise,
154
+ usecorrout=usecorrout,
155
+ useatlas=useatlas,
156
+ forcetr=forcetr,
157
+ forceoffset=forceoffset,
158
+ offsettime=offsettime,
159
+ verbose=verbosity,
160
+ )
161
+ if len(thesubjects) > 0:
162
+ # check to see that the dimensions match
163
+ dimmatch, sizematch, spacematch, affinematch = check_rt_spatialmatch(
164
+ thissubject, thesubjects[0]
165
+ )
166
+ if dimmatch or ignoredimmatch:
167
+ thesubjects.append(thissubject)
168
+ else:
169
+ print(f"dataset {thisdatafileroot} does not match loaded data - skipping")
170
+ else:
171
+ thesubjects.append(thissubject)
172
+
173
+ # list the datasets
174
+ for idx, subject in enumerate(thesubjects):
175
+ print(f"subject {idx}: {subject.fileroot}")
176
+
177
+
178
+ def updateFileMenu():
179
+ global thesubjects, whichsubject
180
+ global fileMenu, sel_open
181
+ global sel_files
182
+
183
+ if pyqtversion == 5:
184
+ qactionfunc = QtWidgets.QAction
185
+ else:
186
+ qactionfunc = QtGui.QAction
187
+
188
+ # scrub file menu
189
+ if sel_files is not None:
190
+ for sel_file in sel_files:
191
+ fileMenu.removeAction(sel_file)
192
+ del sel_file
193
+
194
+ # now build it back
195
+ if len(thesubjects) > 0:
196
+ sel_files = []
197
+ for idx, subject in enumerate(thesubjects):
198
+ if idx == whichsubject:
199
+ indicator = "\u2714 "
200
+ else:
201
+ indicator = " "
202
+ sel_files.append(qactionfunc(indicator + subject.fileroot, win))
203
+ sel_files[-1].triggered.connect(partial(selectDataset, idx))
204
+ fileMenu.addAction(sel_files[-1])
205
+
206
+
207
+ def datasetPicker():
208
+ global currentdataset, thesubjects, whichsubject, datafileroots
209
+ global ui, win, defaultdict, overlagGraphicsViews
210
+ global verbosity
211
+
125
212
  mydialog = QtWidgets.QFileDialog()
126
213
  if pyqtversion == 5:
127
214
  options = mydialog.Options()
@@ -137,7 +224,36 @@ def selectFile():
137
224
  datafileroot = str(lagfilename[:bidsstartloc])
138
225
  else:
139
226
  datafileroot = str(lagfilename[: lagfilename.find("lagtimes.nii.gz")])
140
- return datafileroot
227
+ datafileroots.append(datafileroot)
228
+ addDataset(datafileroots[-1])
229
+ whichsubject = len(thesubjects) - 1
230
+ selectDataset(whichsubject)
231
+
232
+ # update the file menu
233
+ updateFileMenu()
234
+
235
+
236
+ def selectDataset(thesubject):
237
+ global currentdataset, thesubjects, whichsubject, datafileroots
238
+ global ui, win, defaultdict, overlagGraphicsViews
239
+ global verbosity, uiinitialized
240
+
241
+ whichsubject = thesubject
242
+ if uiinitialized:
243
+ thesubjects[whichsubject].setfocusregressor(currentdataset.focusregressor)
244
+ thesubjects[whichsubject].setfocusmap(currentdataset.focusmap)
245
+ currentdataset = thesubjects[whichsubject]
246
+ activateDataset(
247
+ currentdataset,
248
+ ui,
249
+ win,
250
+ defaultdict,
251
+ overlayGraphicsViews,
252
+ verbosity=verbosity,
253
+ )
254
+
255
+ # update the file menu
256
+ updateFileMenu()
141
257
 
142
258
 
143
259
  class xyztlocation(QtWidgets.QWidget):
@@ -305,10 +421,17 @@ class xyztlocation(QtWidgets.QWidget):
305
421
  # print('resetting T spinbox values')
306
422
  if self.TPosSpinBox is not None:
307
423
  self.TPosSpinBox.setValue(self.tpos)
424
+ self.TPosSpinBox.setRange(0, self.tdim - 1)
308
425
  if self.TCoordSpinBox is not None:
309
426
  self.TCoordSpinBox.setValue(self.tcoord)
427
+ tllcoord = self.tr2real(0)
428
+ tulcoord = self.tr2real(self.tdim - 1)
429
+ tmin = np.min([tllcoord, tulcoord])
430
+ tmax = np.max([tllcoord, tulcoord])
431
+ self.TCoordSpinBox.setRange(tmin, tmax)
310
432
  if self.TimeSlider is not None:
311
433
  self.TimeSlider.setValue((self.tpos))
434
+ self.TimeSlider.setRange(0, self.tdim - 1)
312
435
  # print('done resetting T spinbox values')
313
436
  self.updatedT.emit()
314
437
 
@@ -340,6 +463,8 @@ class xyztlocation(QtWidgets.QWidget):
340
463
  self.updateXYZValues(emitsignal=emitsignal)
341
464
 
342
465
  def setTpos(self, tpos):
466
+ if tpos > self.tdim:
467
+ tpos = self.tdim
343
468
  if self.tpos != tpos:
344
469
  self.tpos = tpos
345
470
  self.tcoord = self.tr2real(self.tpos)
@@ -460,48 +585,7 @@ class xyztlocation(QtWidgets.QWidget):
460
585
  self.movieTimer.start(int(self.frametime))
461
586
 
462
587
 
463
- class KeyPressWindow(QtWidgets.QMainWindow):
464
- sigKeyPress = QtCore.pyqtSignal(object)
465
-
466
- def __init__(self, *args, **kwargs):
467
- super().__init__(*args, **kwargs)
468
-
469
- def keyPressEvent(self, ev):
470
- self.sigKeyPress.emit(ev)
471
-
472
-
473
- def keyPressed(evt):
474
- global currentsubject, thesubjects, whichsubject
475
- global defaultdict, overlayGraphicsViews
476
- numsubjects = len(thesubjects)
477
- if evt.key() == QtCore.Qt.Key.Key_Up:
478
- whichsubject = (whichsubject + 1) % numsubjects
479
- print("Key_Up")
480
- elif evt.key() == QtCore.Qt.Key.Key_Down:
481
- whichsubject = (whichsubject - 1) % numsubjects
482
- print("Key_Down")
483
- elif evt.key() == QtCore.Qt.Key.Key_Left:
484
- whichsubject = (whichsubject - 1) % numsubjects
485
- print("Key_Left")
486
- elif evt.key() == QtCore.Qt.Key.Key_Right:
487
- whichsubject = (whichsubject + 1) % numsubjects
488
- print("Key_Right")
489
- else:
490
- print(evt.key())
491
- print(f"subject number set to {whichsubject}")
492
- currentdataset = thesubjects[whichsubject]
493
- """activatedataset(
494
- currentdataset,
495
- ui,
496
- win,
497
- defaultdict,
498
- overlayGraphicsViews,
499
- verbosity=verbosity,
500
- doinit=False,
501
- )"""
502
-
503
-
504
- def logstatus(thetextbox, thetext):
588
+ def logStatus(thetextbox, thetext):
505
589
  if pyqtversion == 5:
506
590
  thetextbox.moveCursor(QtGui.QTextCursor.End)
507
591
  thetextbox.insertPlainText(thetext + "\n")
@@ -707,6 +791,8 @@ def updateRegressor():
707
791
  size = [upperlim - lowerlim, tctop - tcbottom]
708
792
  therectangle = RectangleItem(bottomleft, size)
709
793
  regressor_ax.addItem(therectangle)
794
+ else:
795
+ print("currentdataset.focusregressor is None!")
710
796
 
711
797
 
712
798
  def updateRegressorSpectrum():
@@ -831,7 +917,7 @@ def updateAveragingMode():
831
917
  print("in updateAveragingMode")
832
918
  if ("atlas" in overlays) and (not atlasaveragingdone):
833
919
  calcAtlasStats()
834
- set_atlasmask()
920
+ setAtlasMask()
835
921
  if ("atlas" in overlays) and False:
836
922
  updateAtlasStats()
837
923
  if averagingmode is not None:
@@ -898,7 +984,7 @@ def MAD_radioButton_clicked(enabled):
898
984
  updateAveragingMode()
899
985
 
900
986
 
901
- def transparency_checkbox_clicked():
987
+ def transparencyCheckboxClicked():
902
988
  global LUT_alpha, LUT_endalpha, ui, overlays, currentdataset
903
989
  global verbosity
904
990
 
@@ -994,178 +1080,57 @@ def rainbow_radioButton_clicked(enabled):
994
1080
  updateLUT()
995
1081
 
996
1082
 
997
- def set_atlasmask():
998
- global overlays, loadedfuncmaps, ui, currentdataset
999
- print("Using all defined atlas regions as functional mask")
1000
- ui.setMask_Button.setText("Valid mask")
1001
- for themap in currentdataset.loadedfuncmaps:
1002
- overlays[themap].setFuncMask(overlays["atlasmask"].data)
1003
- updateUI(callingfunc="set_atlasmask", orthoimages=True, histogram=True)
1004
-
1005
-
1006
- def set_lagmask():
1007
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1008
- print("Using valid fit points as functional mask")
1009
- ui.setMask_Button.setText("Valid mask")
1010
- for themap in currentdataset.loadedfuncmaps:
1011
- overlays[themap].setFuncMask(overlays["lagmask"].data)
1012
- atlasaveragingdone = False
1013
- updateAveragingMode()
1014
- updateUI(callingfunc="set_lagmask()", orthoimages=True, histogram=True)
1015
-
1016
-
1017
- def set_refinemask():
1018
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1019
- print("Voxel refinement mask")
1020
- ui.setMask_Button.setText("Refine mask")
1021
- for themap in currentdataset.loadedfuncmaps:
1022
- overlays[themap].setFuncMask(overlays["refinemask"].data)
1023
- atlasaveragingdone = False
1024
- updateAveragingMode()
1025
- updateUI(callingfunc="set_refinemask", orthoimages=True, histogram=True)
1026
-
1027
-
1028
- def set_meanmask():
1029
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1030
- print("Mean regressor seed mask")
1031
- ui.setMask_Button.setText("Mean mask")
1032
- for themap in currentdataset.loadedfuncmaps:
1033
- overlays[themap].setFuncMask(overlays["meanmask"].data)
1034
- atlasaveragingdone = False
1035
- updateAveragingMode()
1036
- updateUI(callingfunc="set_meanmask", orthoimages=True, histogram=True)
1037
-
1038
-
1039
- def set_preselectmask():
1040
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1041
- print("Preselected mean regressor seed mask")
1042
- ui.setMask_Button.setText("Preselect mask")
1043
- for themap in currentdataset.loadedfuncmaps:
1044
- overlays[themap].setFuncMask(overlays["preselectmask"].data)
1045
- atlasaveragingdone = False
1046
- updateAveragingMode()
1047
- updateUI(callingfunc="set_preselectmask", orthoimages=True, histogram=True)
1048
-
1049
-
1050
- def set_nomask():
1083
+ def setMask(maskname):
1051
1084
  global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1052
- print("disabling functional mask")
1053
- ui.setMask_Button.setText("No Mask")
1054
- for themap in currentdataset.loadedfuncmaps:
1055
- overlays[themap].setFuncMask(None)
1056
- atlasaveragingdone = False
1057
- updateAveragingMode()
1058
- updateUI(callingfunc="set_nomask", orthoimages=True, histogram=True)
1059
-
1060
-
1061
- def set_0p05():
1062
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1063
- print("setting functional mask to p<0.05")
1064
- ui.setMask_Button.setText("p<0.05")
1065
- # overlays['jit_mask'] = tide_stats.makepmask(overlays['lagstrengths'], 0.05, sighistfit, onesided=True)
1066
- for themap in currentdataset.loadedfuncmaps:
1067
- overlays[themap].setFuncMask(overlays["p_lt_0p050_mask"].data)
1068
- # overlays[themap].setFuncMask(overlays['jit_mask'].data)
1069
- atlasaveragingdone = False
1070
- updateAveragingMode()
1071
- updateUI(callingfunc="set_0p05", orthoimages=True, histogram=True)
1072
-
1073
-
1074
- def set_0p01():
1075
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1076
- print("setting functional mask to p<0.01")
1077
- ui.setMask_Button.setText("p<0.01")
1078
- for themap in currentdataset.loadedfuncmaps:
1079
- overlays[themap].setFuncMask(overlays["p_lt_0p010_mask"].data)
1080
- atlasaveragingdone = False
1081
- updateAveragingMode()
1082
- updateUI(callingfunc="set_0p01", orthoimages=True, histogram=True)
1083
-
1084
-
1085
- def set_0p005():
1086
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1087
- print("setting functional mask to p<0.005")
1088
- ui.setMask_Button.setText("p<0.005")
1085
+ maskinfodicts = {}
1086
+ maskinfodicts["nomask"] = {
1087
+ "msg": "Disabling functional mask",
1088
+ "label": "No mask",
1089
+ }
1090
+ maskinfodicts["meanmask"] = {
1091
+ "msg": "Mean regressor seed mask",
1092
+ "label": "Mean mask",
1093
+ }
1094
+ maskinfodicts["lagmask"] = {
1095
+ "msg": "Using valid fit points as functional mask",
1096
+ "label": "Valid mask",
1097
+ }
1098
+ maskinfodicts["brainmask"] = {
1099
+ "msg": "Externally provided brain mask",
1100
+ "label": "Brain mask",
1101
+ }
1102
+ maskinfodicts["refinemask"] = {
1103
+ "msg": "Voxel refinement mask",
1104
+ "label": "Refine mask",
1105
+ }
1106
+ maskinfodicts["preselectmask"] = {
1107
+ "msg": "Preselected mean regressor seed mask",
1108
+ "label": "Preselect mask",
1109
+ }
1110
+ for pval in [0.05, 0.01, 0.005, 0.001]:
1111
+ maskinfodicts[f"p_lt_{(str(pval) + '0').replace('.','p')[0:5]}_mask"] = {
1112
+ "msg": f"Setting functional mask to p<{str(pval)}",
1113
+ "label": f"p<{str(pval)}",
1114
+ }
1115
+ print(maskinfodicts[maskname]["msg"])
1116
+ ui.setMask_Button.setText(maskinfodicts[maskname]["label"])
1089
1117
  for themap in currentdataset.loadedfuncmaps:
1090
- overlays[themap].setFuncMask(overlays["p_lt_0p005_mask"].data)
1118
+ if maskname == "nomask":
1119
+ overlays[themap].setFuncMask(None)
1120
+ else:
1121
+ overlays[themap].setFuncMask(overlays[maskname].data)
1091
1122
  atlasaveragingdone = False
1092
1123
  updateAveragingMode()
1093
- updateUI(callingfunc="set_0p005", orthoimages=True, histogram=True)
1124
+ updateUI(callingfunc=f"setMask({maskname})", orthoimages=True, histogram=True)
1094
1125
 
1095
1126
 
1096
- def set_0p001():
1097
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1098
- print("setting functional mask to p<0.001")
1099
- ui.setMask_Button.setText("p<0.001")
1127
+ def setAtlasMask():
1128
+ global overlays, loadedfuncmaps, ui, currentdataset
1129
+ print("Using all defined atlas regions as functional mask")
1130
+ ui.setMask_Button.setText("Valid mask")
1100
1131
  for themap in currentdataset.loadedfuncmaps:
1101
- overlays[themap].setFuncMask(overlays["p_lt_0p001_mask"].data)
1102
- atlasaveragingdone = False
1103
- updateAveragingMode()
1104
- updateUI(callingfunc="set_0p001", orthoimages=True, histogram=True)
1105
-
1106
-
1107
- def overlay_radioButton_01_clicked(enabled):
1108
- overlay_radioButton_clicked(0, enabled)
1109
-
1110
-
1111
- def overlay_radioButton_02_clicked(enabled):
1112
- overlay_radioButton_clicked(1, enabled)
1113
-
1114
-
1115
- def overlay_radioButton_03_clicked(enabled):
1116
- overlay_radioButton_clicked(2, enabled)
1117
-
1118
-
1119
- def overlay_radioButton_04_clicked(enabled):
1120
- overlay_radioButton_clicked(3, enabled)
1121
-
1122
-
1123
- def overlay_radioButton_05_clicked(enabled):
1124
- overlay_radioButton_clicked(4, enabled)
1125
-
1126
-
1127
- def overlay_radioButton_06_clicked(enabled):
1128
- overlay_radioButton_clicked(5, enabled)
1129
-
1130
-
1131
- def overlay_radioButton_07_clicked(enabled):
1132
- overlay_radioButton_clicked(6, enabled)
1133
-
1134
-
1135
- def overlay_radioButton_08_clicked(enabled):
1136
- overlay_radioButton_clicked(7, enabled)
1137
-
1138
-
1139
- def overlay_radioButton_09_clicked(enabled):
1140
- overlay_radioButton_clicked(8, enabled)
1141
-
1142
-
1143
- def overlay_radioButton_10_clicked(enabled):
1144
- overlay_radioButton_clicked(9, enabled)
1145
-
1146
-
1147
- def overlay_radioButton_11_clicked(enabled):
1148
- overlay_radioButton_clicked(10, enabled)
1149
-
1150
-
1151
- def overlay_radioButton_12_clicked(enabled):
1152
- overlay_radioButton_clicked(11, enabled)
1153
-
1154
-
1155
- def overlay_radioButton_13_clicked(enabled):
1156
- overlay_radioButton_clicked(12, enabled)
1157
-
1158
-
1159
- def overlay_radioButton_14_clicked(enabled):
1160
- overlay_radioButton_clicked(13, enabled)
1161
-
1162
-
1163
- def overlay_radioButton_15_clicked(enabled):
1164
- overlay_radioButton_clicked(14, enabled)
1165
-
1166
-
1167
- def overlay_radioButton_16_clicked(enabled):
1168
- overlay_radioButton_clicked(15, enabled)
1132
+ overlays[themap].setFuncMask(overlays["atlasmask"].data)
1133
+ updateUI(callingfunc="setAtlasMask", orthoimages=True, histogram=True)
1169
1134
 
1170
1135
 
1171
1136
  def overlay_radioButton_clicked(which, enabled):
@@ -1181,6 +1146,8 @@ def overlay_radioButton_clicked(which, enabled):
1181
1146
  currentdataset.setfocusmap(panetomap[which] + "_atlasstat")
1182
1147
  else:
1183
1148
  currentdataset.setfocusmap(panetomap[which])
1149
+ thedispmin = overlays[currentdataset.focusmap].dispmin
1150
+ thedispmax = overlays[currentdataset.focusmap].dispmax
1184
1151
  if verbosity > 1:
1185
1152
  print("currentdataset.focusmap set to ", currentdataset.focusmap)
1186
1153
  if overlays[currentdataset.focusmap].lut_state == gen_gray_state():
@@ -1207,7 +1174,9 @@ def overlay_radioButton_clicked(which, enabled):
1207
1174
  overlays[currentdataset.focusmap].tr,
1208
1175
  overlays[currentdataset.focusmap].toffset,
1209
1176
  )
1210
-
1177
+ overlays[currentdataset.focusmap].dispmin = thedispmin
1178
+ overlays[currentdataset.focusmap].dispmax = thedispmax
1179
+ updateDispLimits()
1211
1180
  updateUI(
1212
1181
  callingfunc="overlay_radioButton_clicked",
1213
1182
  histogram=True,
@@ -1360,7 +1329,7 @@ def printfocusvals():
1360
1329
  global ui, overlays, currentdataset
1361
1330
  global currentloc
1362
1331
  global simfuncFitter
1363
- logstatus(
1332
+ logStatus(
1364
1333
  ui.logOutput,
1365
1334
  "\n\nValues at location "
1366
1335
  + "{0},{1},{2}".format(currentloc.xpos, currentloc.ypos, currentloc.zpos),
@@ -1382,7 +1351,7 @@ def printfocusvals():
1382
1351
  + str(":")
1383
1352
  + "{:.3f}".format(round(focusval, 3))
1384
1353
  )
1385
- logstatus(ui.logOutput, outstring)
1354
+ logStatus(ui.logOutput, outstring)
1386
1355
  else:
1387
1356
  if focusval > 0.0:
1388
1357
  if simfuncFitter is not None:
@@ -1393,7 +1362,7 @@ def printfocusvals():
1393
1362
  + str(":\n\t ")
1394
1363
  + failstring.replace(", ", "\n\t ")
1395
1364
  )
1396
- logstatus(ui.logOutput, outstring)
1365
+ logStatus(ui.logOutput, outstring)
1397
1366
  else:
1398
1367
  outstring = (
1399
1368
  indentstring
@@ -1401,65 +1370,39 @@ def printfocusvals():
1401
1370
  + str(":")
1402
1371
  + str(currentdataset.atlaslabels[int(focusval) - 1])
1403
1372
  )
1404
- logstatus(ui.logOutput, outstring)
1405
-
1406
-
1407
- def prefilt_radioButton_clicked(enabled):
1408
- global currentdataset
1409
- currentdataset.setfocusregressor("prefilt")
1410
- updateRegressor()
1411
- updateRegressorSpectrum()
1373
+ logStatus(ui.logOutput, outstring)
1412
1374
 
1413
1375
 
1414
- def postfilt_radioButton_clicked(enabled):
1376
+ def regressor_radioButton_clicked(theregressor, enabled):
1415
1377
  global currentdataset
1416
- currentdataset.setfocusregressor("postfilt")
1378
+ currentdataset.setfocusregressor(theregressor)
1417
1379
  updateRegressor()
1418
1380
  updateRegressorSpectrum()
1419
1381
 
1420
1382
 
1421
- def pass1_radioButton_clicked(enabled):
1422
- global currentdataset
1423
- currentdataset.setfocusregressor("pass1")
1424
- updateRegressor()
1425
- updateRegressorSpectrum()
1426
-
1427
-
1428
- def pass2_radioButton_clicked(enabled):
1429
- global currentdataset
1430
- currentdataset.setfocusregressor("pass2")
1431
- updateRegressor()
1432
- updateRegressorSpectrum()
1433
-
1434
-
1435
- def pass3_radioButton_clicked(enabled):
1436
- global currentdataset
1437
- currentdataset.setfocusregressor("pass3")
1438
- updateRegressor()
1439
- updateRegressorSpectrum()
1440
-
1441
-
1442
- def pass4_radioButton_clicked(enabled):
1443
- global currentdataset
1444
- currentdataset.setfocusregressor("pass4")
1445
- updateRegressor()
1446
- updateRegressorSpectrum()
1447
-
1448
-
1449
- def activatedataset(
1450
- currentdataset, ui, win, defaultdict, overlayGraphicsViews, verbosity=0, doinit=False
1451
- ):
1383
+ def activateDataset(currentdataset, ui, win, defaultdict, overlayGraphicsViews, verbosity=0):
1452
1384
  global regressors, overlays
1453
1385
  global mainwin
1454
1386
  global xdim, ydim, zdim, tdim, xpos, ypos, zpos, tpos
1455
1387
  global timeaxis
1456
1388
  global usecorrout
1457
1389
  global orthoimagedict
1390
+ global panesinitialized, uiinitialized
1391
+ global currentloc
1392
+
1393
+ if uiinitialized:
1394
+ currentloc.xdim = currentdataset.xdim
1395
+ currentloc.ydim = currentdataset.ydim
1396
+ currentloc.xdim = currentdataset.zdim
1397
+ currentloc.tdim = currentdataset.tdim
1398
+ currentloc.setTpos(currentloc.tpos)
1458
1399
 
1459
- print("getting regressors")
1400
+ if verbosity > 1:
1401
+ print("getting regressors")
1460
1402
  regressors = currentdataset.getregressors()
1461
1403
 
1462
- print("getting overlays")
1404
+ if verbosity > 1:
1405
+ print("getting overlays")
1463
1406
  overlays = currentdataset.getoverlays()
1464
1407
  try:
1465
1408
  test = overlays["corrout"].display_state
@@ -1467,7 +1410,8 @@ def activatedataset(
1467
1410
  usecorrout = False
1468
1411
 
1469
1412
  # activate the appropriate regressor radio buttons
1470
- print("activating radio buttons")
1413
+ if verbosity > 1:
1414
+ print("activating radio buttons")
1471
1415
  if "prefilt" in regressors.keys():
1472
1416
  ui.prefilt_radioButton.setDisabled(False)
1473
1417
  ui.prefilt_radioButton.show()
@@ -1530,7 +1474,8 @@ def activatedataset(
1530
1474
  bgmap = None
1531
1475
 
1532
1476
  # set up the timecourse plot window
1533
- print("setting up timecourse plot window")
1477
+ if verbosity > 1:
1478
+ print("setting up timecourse plot window")
1534
1479
  xpos = int(currentdataset.xdim) // 2
1535
1480
  ypos = int(currentdataset.ydim) // 2
1536
1481
  zpos = int(currentdataset.zdim) // 2
@@ -1557,7 +1502,8 @@ def activatedataset(
1557
1502
  tpos = 0
1558
1503
 
1559
1504
  # set position and scale of images
1560
- print("setting position and scale of images")
1505
+ if verbosity > 1:
1506
+ print("setting position and scale of images")
1561
1507
  lg_imgsize = 256.0
1562
1508
  sm_imgsize = 32.0
1563
1509
  xfov = currentdataset.xdim * currentdataset.xsize
@@ -1623,7 +1569,7 @@ def activatedataset(
1623
1569
 
1624
1570
  if verbosity > 1:
1625
1571
  print("focusmap is:", currentdataset.focusmap, "bgmap is:", bgmap)
1626
- if doinit:
1572
+ if not panesinitialized:
1627
1573
  if bgmap is None:
1628
1574
  mainwin = OrthoImageItem(
1629
1575
  overlays[currentdataset.focusmap],
@@ -1648,12 +1594,12 @@ def activatedataset(
1648
1594
  else:
1649
1595
  mainwin.setMap(overlays[currentdataset.focusmap])
1650
1596
 
1651
- if verbosity > 1:
1652
- print("loading panes")
1653
1597
  availablepanes = len(overlayGraphicsViews)
1598
+ if verbosity > 0:
1599
+ print(f"loading {availablepanes} available panes")
1654
1600
  numnotloaded = 0
1655
1601
  numloaded = 0
1656
- if doinit:
1602
+ if not panesinitialized:
1657
1603
  orthoimagedict = {}
1658
1604
  for idx, themap in enumerate(currentdataset.dispmaps):
1659
1605
  if overlays[themap].display_state:
@@ -1661,11 +1607,15 @@ def activatedataset(
1661
1607
  (numloaded > availablepanes - 2) and (themap != "corrout")
1662
1608
  ):
1663
1609
  if verbosity > 1:
1664
- print("skipping map ", themap, "(", idx, "): out of display panes")
1610
+ print(
1611
+ f"skipping map {themap}({idx}): out of display panes ({numloaded=}, {availablepanes=})"
1612
+ )
1665
1613
  numnotloaded += 1
1666
1614
  else:
1667
1615
  if verbosity > 1:
1668
- print("loading map ", themap, "(", idx, ") into pane ", numloaded)
1616
+ print(
1617
+ f"loading map {themap}=({idx}) into pane {numloaded} of {availablepanes}"
1618
+ )
1669
1619
  if bgmap is None:
1670
1620
  loadpane(
1671
1621
  overlays[themap],
@@ -1687,17 +1637,37 @@ def activatedataset(
1687
1637
  bgmap=overlays[bgmap],
1688
1638
  sm_imgsize=sm_imgsize,
1689
1639
  )
1690
- numloaded += 1
1640
+ numloaded += 1
1691
1641
  else:
1692
1642
  if verbosity > 1:
1693
1643
  print("not loading map ", themap, "(", idx, "): display_state is False")
1694
1644
  else:
1695
- print(orthoimagedict)
1645
+ for thismap in panetomap:
1646
+ if thismap != "":
1647
+ try:
1648
+ orthoimagedict[thismap].setMap(overlays[thismap])
1649
+ except KeyError:
1650
+ pass
1696
1651
  if verbosity > 1:
1697
1652
  print("done loading panes")
1698
1653
  if numnotloaded > 0:
1699
1654
  print("WARNING:", numnotloaded, "maps could not be loaded - not enough panes")
1700
1655
 
1656
+ # record that we've been through once
1657
+ panesinitialized = True
1658
+
1659
+ if uiinitialized:
1660
+ # update the windows
1661
+ updateUI(
1662
+ callingfunc="activateDataset",
1663
+ orthoimages=True,
1664
+ histogram=True,
1665
+ )
1666
+
1667
+ # update the regressor
1668
+ updateRegressor()
1669
+ updateRegressorSpectrum()
1670
+
1701
1671
 
1702
1672
  def loadpane(
1703
1673
  themap,
@@ -1737,8 +1707,9 @@ def loadpane(
1737
1707
  def tidepool(args):
1738
1708
  global vLine
1739
1709
  global ui, win
1710
+ global fileMenu, sel_open, sel_files
1740
1711
  global movierunning
1741
- global focusmap, bgmap
1712
+ global focusmap, bgmap, focusregressor
1742
1713
  global maps
1743
1714
  global roi
1744
1715
  global overlays, regressors, regressorfilterlimits, regressorsimcalclimits, loadedfuncmaps, atlasstats, averagingmode
@@ -1753,9 +1724,10 @@ def tidepool(args):
1753
1724
  global imageadj
1754
1725
  global harvestcolormaps
1755
1726
  global atlasaveragingdone
1756
- global currentdataset, thesubjects, whichsubject
1727
+ global currentdataset, thesubjects, whichsubject, datafileroots
1757
1728
  global defaultdict, overlayGraphicsViews
1758
1729
  global verbosity
1730
+ global panesinitialized, uiinitialized
1759
1731
  global simfuncFitter
1760
1732
  global simfunc_ax, simfuncCurve, simfuncfitCurve, simfuncTLine, simfuncPeakMarker, simfuncCurvePoint, simfuncCaption
1761
1733
 
@@ -1781,15 +1753,23 @@ def tidepool(args):
1781
1753
  tpos = 0
1782
1754
  verbosity = 0
1783
1755
  simfuncFitter = None
1756
+ datafileroots = []
1757
+ panesinitialized = False
1758
+ uiinitialized = False
1759
+ sel_files = None
1784
1760
 
1785
1761
  if pyqtversion == 5:
1786
- if args.compact:
1762
+ if args.uistyle == "normal":
1787
1763
  import rapidtide.tidepoolTemplate_alt as uiTemplate
1764
+ elif args.uistyle == "big":
1765
+ import rapidtide.tidepoolTemplate_big as uiTemplate
1788
1766
  else:
1789
1767
  import rapidtide.tidepoolTemplate as uiTemplate
1790
1768
  else:
1791
- if args.compact:
1769
+ if args.uistyle == "normal":
1792
1770
  import rapidtide.tidepoolTemplate_alt_qt6 as uiTemplate
1771
+ elif args.uistyle == "big":
1772
+ import rapidtide.tidepoolTemplate_big_qt6 as uiTemplate
1793
1773
  else:
1794
1774
  import rapidtide.tidepoolTemplate_qt6 as uiTemplate
1795
1775
 
@@ -1808,7 +1788,6 @@ def tidepool(args):
1808
1788
  else:
1809
1789
  geommaskname = None
1810
1790
 
1811
- datafileroots = []
1812
1791
  if args.datafileroot is not None:
1813
1792
  print("using ", args.datafileroot, " as the root file name list")
1814
1793
  datafileroots = args.datafileroot
@@ -1835,34 +1814,25 @@ def tidepool(args):
1835
1814
  # make the main window
1836
1815
  app = QtWidgets.QApplication([])
1837
1816
  print("setting up output window")
1838
- win = KeyPressWindow()
1839
- win.sigKeyPress.connect(keyPressed)
1840
- # win = QtWidgets.QMainWindow()
1817
+ win = QtWidgets.QMainWindow()
1841
1818
  ui = uiTemplate.Ui_MainWindow()
1842
1819
  ui.setupUi(win)
1843
1820
  win.show()
1844
1821
  win.setWindowTitle("TiDePool")
1845
1822
 
1846
- """"# create the menu bar
1823
+ # create the menu bar
1847
1824
  print("creating menu bar")
1848
1825
  menuBar = win.menuBar()
1849
- fileMenu = QtWidgets.QMenu(win)
1826
+ fileMenu = menuBar.addMenu("File")
1850
1827
  if pyqtversion == 5:
1851
1828
  qactionfunc = QtWidgets.QAction
1852
1829
  else:
1853
1830
  qactionfunc = QtGui.QAction
1854
- sel_open = qactionfunc("Open", win)
1855
- sel_open.triggered.connect(selectFile())
1831
+ sel_open = qactionfunc("Add dataset...", win)
1832
+ sel_open.triggered.connect(datasetPicker)
1856
1833
  fileMenu.addAction(sel_open)
1857
- win.setMenuBar(menuBar)
1858
- print("done creating menu bar")"""
1859
-
1860
- # get inputfile root name if necessary
1861
- if len(datafileroots) == 0:
1862
- datafileroots.append(selectFile())
1863
- if len(datafileroots) == 0:
1864
- print("No input file specified - exiting.")
1865
- sys.exit()
1834
+ fileMenu.addSeparator()
1835
+ print("done creating menu bar")
1866
1836
 
1867
1837
  # wire up the ortho image windows for mouse interaction
1868
1838
  vb_colorbar = pg.ViewBox(enableMouse=False)
@@ -1890,6 +1860,10 @@ def tidepool(args):
1890
1860
  if harvestcolormaps:
1891
1861
  ui.largeimage_horizontalLayout.addWidget(imageadj)
1892
1862
 
1863
+ if args.uistyle == "big":
1864
+ extramaps = True
1865
+ else:
1866
+ extramaps = False
1893
1867
  defaultdict = {
1894
1868
  "lagmask": {
1895
1869
  "colormap": gen_gray_state(),
@@ -1921,6 +1895,12 @@ def tidepool(args):
1921
1895
  "display": False,
1922
1896
  "funcmask": None,
1923
1897
  },
1898
+ "brainmask": {
1899
+ "colormap": gen_gray_state(),
1900
+ "label": "Brain mask",
1901
+ "display": False,
1902
+ "funcmask": None,
1903
+ },
1924
1904
  "p_lt_0p050_mask": {
1925
1905
  "colormap": gen_gray_state(),
1926
1906
  "label": "p<0.05",
@@ -1996,12 +1976,42 @@ def tidepool(args):
1996
1976
  "MTT": {
1997
1977
  "colormap": gen_spectrum_state(),
1998
1978
  "label": "MTT",
1999
- "display": True,
1979
+ "display": extramaps,
2000
1980
  "funcmask": "p_lt_0p050_mask",
2001
1981
  },
2002
1982
  "R2": {
2003
1983
  "colormap": gen_thermal_state(),
2004
- "label": "Fit R2",
1984
+ "label": "GLM Fit R2",
1985
+ "display": extramaps,
1986
+ "funcmask": "p_lt_0p050_mask",
1987
+ },
1988
+ "CoV": {
1989
+ "colormap": gen_thermal_state(),
1990
+ "label": "Coefficient of variation",
1991
+ "display": True,
1992
+ "funcmask": "p_lt_0p050_mask",
1993
+ },
1994
+ "confoundR2": {
1995
+ "colormap": gen_thermal_state(),
1996
+ "label": "Confound Fit R2",
1997
+ "display": extramaps,
1998
+ "funcmask": "p_lt_0p050_mask",
1999
+ },
2000
+ "varBefore": {
2001
+ "colormap": gen_thermal_state(),
2002
+ "label": "LFO variance before GLM",
2003
+ "display": extramaps,
2004
+ "funcmask": "p_lt_0p050_mask",
2005
+ },
2006
+ "varAfter": {
2007
+ "colormap": gen_thermal_state(),
2008
+ "label": "LFO variance after GLM",
2009
+ "display": extramaps,
2010
+ "funcmask": "p_lt_0p050_mask",
2011
+ },
2012
+ "varChange": {
2013
+ "colormap": gen_thermal_state(),
2014
+ "label": "LFO variance decrease %",
2005
2015
  "display": True,
2006
2016
  "funcmask": "p_lt_0p050_mask",
2007
2017
  },
@@ -2014,7 +2024,7 @@ def tidepool(args):
2014
2024
  "fitNorm": {
2015
2025
  "colormap": gen_thermal_state(),
2016
2026
  "label": "fitNorm",
2017
- "display": True,
2027
+ "display": False,
2018
2028
  "funcmask": "p_lt_0p050_mask",
2019
2029
  },
2020
2030
  "gaussout": {
@@ -2026,7 +2036,7 @@ def tidepool(args):
2026
2036
  "failimage": {
2027
2037
  "colormap": gen_spectrum_state(),
2028
2038
  "label": "Fit failure reason",
2029
- "display": False,
2039
+ "display": extramaps,
2030
2040
  "funcmask": None,
2031
2041
  },
2032
2042
  "anatomic": {
@@ -2050,7 +2060,7 @@ def tidepool(args):
2050
2060
  "neglog10p": {
2051
2061
  "colormap": gen_thermal_state(),
2052
2062
  "label": "Correlation fit -log10p",
2053
- "display": False,
2063
+ "display": extramaps,
2054
2064
  "funcmask": "None",
2055
2065
  },
2056
2066
  "delayoffset": {
@@ -2105,7 +2115,7 @@ def tidepool(args):
2105
2115
  ui.rainbow_radioButton.clicked.connect(rainbow_radioButton_clicked)
2106
2116
 
2107
2117
  # wire up the transparency checkbox
2108
- ui.transparency_checkBox.stateChanged.connect(transparency_checkbox_clicked)
2118
+ ui.transparency_checkBox.stateChanged.connect(transparencyCheckboxClicked)
2109
2119
 
2110
2120
  overlaybuttons = [
2111
2121
  ui.overlay_radioButton_01,
@@ -2117,8 +2127,19 @@ def tidepool(args):
2117
2127
  ui.overlay_radioButton_07,
2118
2128
  ui.overlay_radioButton_08,
2119
2129
  ]
2130
+ if args.uistyle == "big":
2131
+ overlaybuttons += [
2132
+ ui.overlay_radioButton_09,
2133
+ ui.overlay_radioButton_10,
2134
+ ui.overlay_radioButton_11,
2135
+ ui.overlay_radioButton_12,
2136
+ ui.overlay_radioButton_13,
2137
+ ui.overlay_radioButton_14,
2138
+ ui.overlay_radioButton_15,
2139
+ ui.overlay_radioButton_16,
2140
+ ]
2120
2141
  for i in range(len(overlaybuttons)):
2121
- clickfunc = globals()[f"overlay_radioButton_{str(i + 1).zfill(2)}_clicked"]
2142
+ clickfunc = partial(overlay_radioButton_clicked, i)
2122
2143
  overlaybuttons[i].clicked.connect(clickfunc)
2123
2144
 
2124
2145
  for button in overlaybuttons:
@@ -2135,7 +2156,17 @@ def tidepool(args):
2135
2156
  ui.overlay_graphicsView_07,
2136
2157
  ui.overlay_graphicsView_08,
2137
2158
  ]
2138
-
2159
+ if args.uistyle == "big":
2160
+ overlayGraphicsViews += [
2161
+ ui.overlay_graphicsView_09,
2162
+ ui.overlay_graphicsView_10,
2163
+ ui.overlay_graphicsView_11,
2164
+ ui.overlay_graphicsView_12,
2165
+ ui.overlay_graphicsView_13,
2166
+ ui.overlay_graphicsView_14,
2167
+ ui.overlay_graphicsView_15,
2168
+ ui.overlay_graphicsView_16,
2169
+ ]
2139
2170
  panetomap = []
2140
2171
 
2141
2172
  for theview in overlayGraphicsViews:
@@ -2143,40 +2174,56 @@ def tidepool(args):
2143
2174
  theview.hide()
2144
2175
 
2145
2176
  # define things for the popup mask menu
2146
- popMenu = QtWidgets.QMenu(win)
2177
+ popMaskMenu = QtWidgets.QMenu(win)
2147
2178
  if pyqtversion == 5:
2148
2179
  qactionfunc = QtWidgets.QAction
2149
2180
  else:
2150
2181
  qactionfunc = QtGui.QAction
2151
2182
  sel_nomask = qactionfunc("No mask", win)
2152
- sel_nomask.triggered.connect(set_nomask)
2153
2183
  sel_lagmask = qactionfunc("Valid fit", win)
2154
- sel_lagmask.triggered.connect(set_lagmask)
2184
+ sel_brainmask = qactionfunc("Externally provided brain mask", win)
2155
2185
  sel_refinemask = qactionfunc("Voxels used in refine", win)
2156
2186
  sel_meanmask = qactionfunc("Voxels used in mean regressor calculation", win)
2157
2187
  sel_preselectmask = qactionfunc(
2158
2188
  "Voxels chosen for the mean regressor calculation in the preselect pass", win
2159
2189
  )
2160
- sel_refinemask.triggered.connect(set_refinemask)
2161
- sel_meanmask.triggered.connect(set_meanmask)
2162
- sel_preselectmask.triggered.connect(set_preselectmask)
2163
2190
  sel_0p05 = qactionfunc("p<0.05", win)
2164
- sel_0p05.triggered.connect(set_0p05)
2165
2191
  sel_0p01 = qactionfunc("p<0.01", win)
2166
- sel_0p01.triggered.connect(set_0p01)
2167
2192
  sel_0p005 = qactionfunc("p<0.005", win)
2168
- sel_0p005.triggered.connect(set_0p005)
2169
2193
  sel_0p001 = qactionfunc("p<0.001", win)
2170
- sel_0p001.triggered.connect(set_0p001)
2171
- popMenu.addAction(sel_nomask)
2194
+
2195
+ sel_nomask.triggered.connect(partial(setMask, "nomask"))
2196
+ sel_lagmask.triggered.connect(partial(setMask, "lagmask"))
2197
+ sel_brainmask.triggered.connect(partial(setMask, "brainmask"))
2198
+ sel_refinemask.triggered.connect(partial(setMask, "refinemask"))
2199
+ sel_meanmask.triggered.connect(partial(setMask, "meanmask"))
2200
+ sel_preselectmask.triggered.connect(partial(setMask, "preselectmask"))
2201
+ sel_0p05.triggered.connect(partial(setMask, "p_lt_0p050_mask"))
2202
+ sel_0p01.triggered.connect(partial(setMask, "p_lt_0p010_mask"))
2203
+ sel_0p005.triggered.connect(partial(setMask, "p_lt_0p005_mask"))
2204
+ sel_0p001.triggered.connect(partial(setMask, "p_lt_0p001_mask"))
2205
+ popMaskMenu.addAction(sel_nomask)
2172
2206
  numspecial = 0
2173
2207
 
2174
- def on_context_menu(point):
2208
+ # configure the mask selection popup menu
2209
+ def on_mask_context_menu(point):
2175
2210
  # show context menu
2176
- popMenu.exec(ui.setMask_Button.mapToGlobal(point))
2211
+ popMaskMenu.exec(ui.setMask_Button.mapToGlobal(point))
2177
2212
 
2178
2213
  ui.setMask_Button.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu)
2179
- ui.setMask_Button.customContextMenuRequested.connect(on_context_menu)
2214
+ ui.setMask_Button.customContextMenuRequested.connect(on_mask_context_menu)
2215
+
2216
+ # configure the file selection popup menu
2217
+ def on_file_context_menu(point):
2218
+ # show context menu
2219
+ popMaskMenu.exec(ui.setFile_Button.mapToGlobal(point))
2220
+
2221
+ try:
2222
+ ui.setFile_Button.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu)
2223
+ ui.setFile_Button.customContextMenuRequested.connect(on_file_context_menu)
2224
+ setfilebuttonexists = True
2225
+ except AttributeError:
2226
+ setfilebuttonexists = False
2180
2227
 
2181
2228
  # wire up the regressor selection radio buttons
2182
2229
  regressorbuttons = [
@@ -2187,13 +2234,12 @@ def tidepool(args):
2187
2234
  ui.pass3_radioButton,
2188
2235
  ui.pass4_radioButton,
2189
2236
  ]
2190
-
2191
- ui.prefilt_radioButton.clicked.connect(prefilt_radioButton_clicked)
2192
- ui.postfilt_radioButton.clicked.connect(postfilt_radioButton_clicked)
2193
- ui.pass1_radioButton.clicked.connect(pass1_radioButton_clicked)
2194
- ui.pass2_radioButton.clicked.connect(pass2_radioButton_clicked)
2195
- ui.pass3_radioButton.clicked.connect(pass3_radioButton_clicked)
2196
- ui.pass4_radioButton.clicked.connect(pass4_radioButton_clicked)
2237
+ ui.prefilt_radioButton.clicked.connect(partial(regressor_radioButton_clicked, "prefilt"))
2238
+ ui.postfilt_radioButton.clicked.connect(partial(regressor_radioButton_clicked, "postfilt"))
2239
+ ui.pass1_radioButton.clicked.connect(partial(regressor_radioButton_clicked, "pass1"))
2240
+ ui.pass2_radioButton.clicked.connect(partial(regressor_radioButton_clicked, "pass2"))
2241
+ ui.pass3_radioButton.clicked.connect(partial(regressor_radioButton_clicked, "pass3"))
2242
+ ui.pass4_radioButton.clicked.connect(partial(regressor_radioButton_clicked, "pass4"))
2197
2243
 
2198
2244
  for thebutton in regressorbuttons:
2199
2245
  thebutton.setDisabled(True)
@@ -2201,38 +2247,41 @@ def tidepool(args):
2201
2247
 
2202
2248
  # read in all the datasets
2203
2249
  thesubjects = []
2204
-
2205
- print("loading datasets...")
2206
- for thisdatafileroot in datafileroots:
2207
- print("Loading", thisdatafileroot)
2208
- thissubject = RapidtideDataset(
2209
- "main",
2210
- thisdatafileroot,
2211
- anatname=anatname,
2212
- geommaskname=geommaskname,
2213
- userise=userise,
2214
- usecorrout=usecorrout,
2215
- useatlas=useatlas,
2216
- forcetr=forcetr,
2217
- forceoffset=forceoffset,
2218
- offsettime=offsettime,
2219
- verbose=verbosity,
2220
- )
2221
- if len(thesubjects) > 0:
2222
- # check to see that the dimensions match
2223
- pass
2224
- thesubjects.append(thissubject)
2225
2250
  whichsubject = 0
2226
- currentdataset = thesubjects[whichsubject]
2227
- activatedataset(
2228
- currentdataset,
2229
- ui,
2230
- win,
2231
- defaultdict,
2232
- overlayGraphicsViews,
2233
- verbosity=verbosity,
2234
- doinit=True,
2235
- )
2251
+ if len(datafileroots) > 0:
2252
+ print("loading prespecified datasets...")
2253
+ for thisdatafileroot in datafileroots:
2254
+ addDataset(
2255
+ thisdatafileroot,
2256
+ anatname=anatname,
2257
+ geommaskname=geommaskname,
2258
+ userise=userise,
2259
+ usecorrout=usecorrout,
2260
+ useatlas=useatlas,
2261
+ forcetr=forcetr,
2262
+ forceoffset=forceoffset,
2263
+ offsettime=offsettime,
2264
+ ignoredimmatch=args.ignoredimmatch,
2265
+ )
2266
+ currentdataset = thesubjects[whichsubject]
2267
+ activateDataset(
2268
+ currentdataset,
2269
+ ui,
2270
+ win,
2271
+ defaultdict,
2272
+ overlayGraphicsViews,
2273
+ verbosity=verbosity,
2274
+ )
2275
+ # update the file menu
2276
+ updateFileMenu()
2277
+ else:
2278
+ # get inputfile root name if necessary
2279
+ datasetPicker()
2280
+
2281
+ # check to see that something is loaded
2282
+ if len(thesubjects) == 0:
2283
+ print("No input datasets specified - exiting.")
2284
+ sys.exit()
2236
2285
 
2237
2286
  # wire up the display range controls
2238
2287
  ui.resetDispLimits_Button.clicked.connect(resetDispLimits)
@@ -2334,29 +2383,32 @@ def tidepool(args):
2334
2383
  if verbosity > 1:
2335
2384
  print("loadedfuncmasks", currentdataset.loadedfuncmasks)
2336
2385
  if len(currentdataset.loadedfuncmasks) > 0:
2337
- popMenu.addSeparator()
2386
+ popMaskMenu.addSeparator()
2338
2387
  if "lagmask" in currentdataset.loadedfuncmasks:
2339
- popMenu.addAction(sel_lagmask)
2388
+ popMaskMenu.addAction(sel_lagmask)
2389
+ numspecial += 1
2390
+ if "brainmask" in currentdataset.loadedfuncmasks:
2391
+ popMaskMenu.addAction(sel_brainmask)
2340
2392
  numspecial += 1
2341
2393
  if "refinemask" in currentdataset.loadedfuncmasks:
2342
- popMenu.addAction(sel_refinemask)
2394
+ popMaskMenu.addAction(sel_refinemask)
2343
2395
  numspecial += 1
2344
2396
  if "meanmask" in currentdataset.loadedfuncmasks:
2345
- popMenu.addAction(sel_meanmask)
2397
+ popMaskMenu.addAction(sel_meanmask)
2346
2398
  numspecial += 1
2347
2399
  if "preselectmask" in currentdataset.loadedfuncmasks:
2348
- popMenu.addAction(sel_preselectmask)
2400
+ popMaskMenu.addAction(sel_preselectmask)
2349
2401
  numspecial += 1
2350
2402
  if numspecial > 0:
2351
- popMenu.addSeparator()
2403
+ popMaskMenu.addSeparator()
2352
2404
  if "p_lt_0p050_mask" in currentdataset.loadedfuncmasks:
2353
- popMenu.addAction(sel_0p05)
2405
+ popMaskMenu.addAction(sel_0p05)
2354
2406
  if "p_lt_0p010_mask" in currentdataset.loadedfuncmasks:
2355
- popMenu.addAction(sel_0p01)
2407
+ popMaskMenu.addAction(sel_0p01)
2356
2408
  if "p_lt_0p005_mask" in currentdataset.loadedfuncmasks:
2357
- popMenu.addAction(sel_0p005)
2409
+ popMaskMenu.addAction(sel_0p005)
2358
2410
  if "p_lt_0p001_mask" in currentdataset.loadedfuncmasks:
2359
- popMenu.addAction(sel_0p001)
2411
+ popMaskMenu.addAction(sel_0p001)
2360
2412
 
2361
2413
  # initialize the location picker
2362
2414
  global currentloc
@@ -2395,12 +2447,14 @@ def tidepool(args):
2395
2447
  # timecourse_ax.enableAutoRange()
2396
2448
 
2397
2449
  # select the first pane
2398
- overlay_radioButton_01_clicked(True)
2450
+ overlay_radioButton_clicked(0, True)
2399
2451
 
2400
2452
  # have to do this after the windows are created
2401
2453
  imageadj.sigGradientChanged.connect(updateLUT)
2402
2454
 
2403
2455
  updateUI(callingfunc="main thread", orthoimages=True, focusvals=True)
2404
2456
  updateRegressor()
2457
+ updateRegressorSpectrum()
2458
+ uiinitialized = True
2405
2459
 
2406
2460
  QtWidgets.QApplication.instance().exec()