rapidtide 3.0a7__py3-none-any.whl → 3.0a9__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,6 +23,7 @@ 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
@@ -35,7 +36,7 @@ import rapidtide.util as tide_util
35
36
  from rapidtide.Colortables import *
36
37
  from rapidtide.helper_classes import SimilarityFunctionFitter
37
38
  from rapidtide.OrthoImageItem import OrthoImageItem
38
- from rapidtide.RapidtideDataset import RapidtideDataset
39
+ from rapidtide.RapidtideDataset import RapidtideDataset, check_rt_spatialmatch
39
40
  from rapidtide.workflows.atlasaverage import summarizevoxels
40
41
 
41
42
  try:
@@ -85,7 +86,11 @@ def _get_parser():
85
86
  )
86
87
  parser.add_argument(
87
88
  "--dataset",
88
- help="Use this dataset (skip initial selection step)",
89
+ nargs="*",
90
+ help=(
91
+ "Use this dataset root name (skip initial selection step). The root name is the entire path "
92
+ "to the rapidtide output data (including the underscore) that precedes 'desc-maxtime_map.nii.gz'"
93
+ ),
89
94
  dest="datafileroot",
90
95
  default=None,
91
96
  )
@@ -99,11 +104,12 @@ def _get_parser():
99
104
  "--maskname", help="Set geometric mask image", dest="geommaskname", default=None
100
105
  )
101
106
  parser.add_argument(
102
- "--oldstyle",
103
- help="Use the old style layout",
104
- dest="compact",
105
- action="store_false",
106
- default=True,
107
+ "--uistyle",
108
+ action="store",
109
+ type=str,
110
+ choices=["normal", "old", "big"],
111
+ help="Set the window layout style. Default is 'normal'.",
112
+ default="normal",
107
113
  )
108
114
  parser.add_argument(
109
115
  "--verbosity",
@@ -111,14 +117,20 @@ def _get_parser():
111
117
  dest="verbose",
112
118
  metavar="VERBOSITY",
113
119
  type=int,
114
- default=1,
120
+ default=0,
121
+ )
122
+ parser.add_argument(
123
+ "--ignoredimmatch",
124
+ help="Do not check to see if dataset sizes match",
125
+ dest="ignoredimmatch",
126
+ action="store_true",
127
+ default=False,
115
128
  )
116
129
 
117
130
  return parser
118
131
 
119
132
 
120
133
  def selectFile():
121
- global datafileroot
122
134
  mydialog = QtWidgets.QFileDialog()
123
135
  if pyqtversion == 5:
124
136
  options = mydialog.Options()
@@ -134,6 +146,7 @@ def selectFile():
134
146
  datafileroot = str(lagfilename[:bidsstartloc])
135
147
  else:
136
148
  datafileroot = str(lagfilename[: lagfilename.find("lagtimes.nii.gz")])
149
+ return datafileroot
137
150
 
138
151
 
139
152
  class xyztlocation(QtWidgets.QWidget):
@@ -456,6 +469,76 @@ class xyztlocation(QtWidgets.QWidget):
456
469
  self.movieTimer.start(int(self.frametime))
457
470
 
458
471
 
472
+ """class KeyPressWindow(QtWidgets.QMainWindow):
473
+ sigKeyPress = QtCore.pyqtSignal(object)
474
+
475
+ def __init__(self, *args, **kwargs):
476
+ super().__init__(*args, **kwargs)
477
+
478
+ def keyPressEvent(self, ev):
479
+ self.sigKeyPress.emit(ev)"""
480
+
481
+
482
+ def nextFileButtonPressed():
483
+ global currentdataset, thesubjects, whichsubject
484
+ global defaultdict, overlayGraphicsViews
485
+ numsubjects = len(thesubjects)
486
+ whichsubject = (whichsubject + 1) % numsubjects
487
+ print(f"subject number set to {whichsubject}")
488
+ thesubjects[whichsubject].setfocusregressor(currentdataset.focusregressor)
489
+ thesubjects[whichsubject].setfocusmap(currentdataset.focusmap)
490
+ currentdataset = thesubjects[whichsubject]
491
+ activatedataset(
492
+ currentdataset,
493
+ ui,
494
+ win,
495
+ defaultdict,
496
+ overlayGraphicsViews,
497
+ verbosity=verbosity,
498
+ doinit=False,
499
+ )
500
+ updateRegressor()
501
+ updateRegressorSpectrum()
502
+ updateUI(
503
+ callingfunc="nextFileButtonPressed",
504
+ orthoimages=True,
505
+ histogram=True,
506
+ focusvals=True,
507
+ )
508
+
509
+
510
+ """def keyPressed(evt):
511
+ global currentsubject, thesubjects, whichsubject
512
+ global defaultdict, overlayGraphicsViews
513
+ numsubjects = len(thesubjects)
514
+ if evt.key() == QtCore.Qt.Key.Key_F:
515
+ whichsubject = (whichsubject + 1) % numsubjects
516
+ print("Key_Up")
517
+ elif evt.key() == QtCore.Qt.Key.Key_B:
518
+ whichsubject = (whichsubject - 1) % numsubjects
519
+ print("Key_Down")
520
+ elif evt.key() == QtCore.Qt.Key.Key_Left:
521
+ whichsubject = (whichsubject - 1) % numsubjects
522
+ print("Key_Left")
523
+ elif evt.key() == QtCore.Qt.Key.Key_Right:
524
+ whichsubject = (whichsubject + 1) % numsubjects
525
+ print("Key_Right")
526
+ else:
527
+ print(evt.key())
528
+ print(f"subject number set to {whichsubject}")
529
+ currentdataset = thesubjects[whichsubject]
530
+ activatedataset(
531
+ currentdataset,
532
+ ui,
533
+ win,
534
+ defaultdict,
535
+ overlayGraphicsViews,
536
+ verbosity=verbosity,
537
+ doinit=False,
538
+ )
539
+ updateOrthoImages()"""
540
+
541
+
459
542
  def logstatus(thetextbox, thetext):
460
543
  if pyqtversion == 5:
461
544
  thetextbox.moveCursor(QtGui.QTextCursor.End)
@@ -662,6 +745,8 @@ def updateRegressor():
662
745
  size = [upperlim - lowerlim, tctop - tcbottom]
663
746
  therectangle = RectangleItem(bottomleft, size)
664
747
  regressor_ax.addItem(therectangle)
748
+ else:
749
+ print("currentdataset.focusregressor is None!")
665
750
 
666
751
 
667
752
  def updateRegressorSpectrum():
@@ -695,7 +780,7 @@ def updateRegressorSpectrum():
695
780
 
696
781
 
697
782
  def calcAtlasStats():
698
- global overlays, datafileroot, atlasstats, averagingmode, currentdataset
783
+ global overlays, atlasstats, averagingmode, currentdataset
699
784
  global atlasaveragingdone
700
785
  print("in calcAtlasStats")
701
786
  methodlist = ["mean", "median", "std", "MAD", "CoV"]
@@ -742,7 +827,7 @@ def calcAtlasStats():
742
827
  df = pd.DataFrame(data=d)
743
828
  df = df[cols]
744
829
  df.to_csv(
745
- datafileroot + currentdataset.atlasname + "_" + thestat + ".txt",
830
+ currentdataset.fileroot + currentdataset.atlasname + "_" + thestat + ".txt",
746
831
  sep="\t",
747
832
  index=False,
748
833
  )
@@ -752,7 +837,7 @@ def calcAtlasStats():
752
837
 
753
838
 
754
839
  def updateAtlasStats():
755
- global overlays, datafileroot, atlasstats, averagingmode, currentdataset
840
+ global overlays, atlasstats, averagingmode, currentdataset
756
841
  print("in updateAtlasStats")
757
842
  if "atlas" in overlays and (averagingmode is not None):
758
843
  for idx, themap in enumerate(currentdataset.loadedfuncmaps):
@@ -949,146 +1034,53 @@ def rainbow_radioButton_clicked(enabled):
949
1034
  updateLUT()
950
1035
 
951
1036
 
952
- def set_atlasmask():
953
- global overlays, loadedfuncmaps, ui, currentdataset
954
- print("Using all defined atlas regions as functional mask")
955
- ui.setMask_Button.setText("Valid mask")
956
- for themap in currentdataset.loadedfuncmaps:
957
- overlays[themap].setFuncMask(overlays["atlasmask"].data)
958
- updateUI(callingfunc="set_atlasmask", orthoimages=True, histogram=True)
959
-
960
-
961
- def set_lagmask():
962
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
963
- print("Using valid fit points as functional mask")
964
- ui.setMask_Button.setText("Valid mask")
965
- for themap in currentdataset.loadedfuncmaps:
966
- overlays[themap].setFuncMask(overlays["lagmask"].data)
967
- atlasaveragingdone = False
968
- updateAveragingMode()
969
- updateUI(callingfunc="set_lagmask()", orthoimages=True, histogram=True)
970
-
971
-
972
- def set_refinemask():
973
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
974
- print("Voxel refinement mask")
975
- ui.setMask_Button.setText("Refine mask")
976
- for themap in currentdataset.loadedfuncmaps:
977
- overlays[themap].setFuncMask(overlays["refinemask"].data)
978
- atlasaveragingdone = False
979
- updateAveragingMode()
980
- updateUI(callingfunc="set_refinemask", orthoimages=True, histogram=True)
981
-
982
-
983
- def set_meanmask():
984
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
985
- print("Mean regressor seed mask")
986
- ui.setMask_Button.setText("Mean mask")
987
- for themap in currentdataset.loadedfuncmaps:
988
- overlays[themap].setFuncMask(overlays["meanmask"].data)
989
- atlasaveragingdone = False
990
- updateAveragingMode()
991
- updateUI(callingfunc="set_meanmask", orthoimages=True, histogram=True)
992
-
993
-
994
- def set_preselectmask():
995
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
996
- print("Preselected mean regressor seed mask")
997
- ui.setMask_Button.setText("Preselect mask")
998
- for themap in currentdataset.loadedfuncmaps:
999
- overlays[themap].setFuncMask(overlays["preselectmask"].data)
1000
- atlasaveragingdone = False
1001
- updateAveragingMode()
1002
- updateUI(callingfunc="set_preselectmask", orthoimages=True, histogram=True)
1003
-
1004
-
1005
- def set_nomask():
1006
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1007
- print("disabling functional mask")
1008
- ui.setMask_Button.setText("No Mask")
1009
- for themap in currentdataset.loadedfuncmaps:
1010
- overlays[themap].setFuncMask(None)
1011
- atlasaveragingdone = False
1012
- updateAveragingMode()
1013
- updateUI(callingfunc="set_nomask", orthoimages=True, histogram=True)
1014
-
1015
-
1016
- def set_0p05():
1037
+ def set_mask(maskname):
1017
1038
  global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1018
- print("setting functional mask to p<0.05")
1019
- ui.setMask_Button.setText("p<0.05")
1020
- # overlays['jit_mask'] = tide_stats.makepmask(overlays['lagstrengths'], 0.05, sighistfit, onesided=True)
1021
- for themap in currentdataset.loadedfuncmaps:
1022
- overlays[themap].setFuncMask(overlays["p_lt_0p050_mask"].data)
1023
- # overlays[themap].setFuncMask(overlays['jit_mask'].data)
1024
- atlasaveragingdone = False
1025
- updateAveragingMode()
1026
- updateUI(callingfunc="set_0p05", orthoimages=True, histogram=True)
1027
-
1028
-
1029
- def set_0p01():
1030
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1031
- print("setting functional mask to p<0.01")
1032
- ui.setMask_Button.setText("p<0.01")
1033
- for themap in currentdataset.loadedfuncmaps:
1034
- overlays[themap].setFuncMask(overlays["p_lt_0p010_mask"].data)
1035
- atlasaveragingdone = False
1036
- updateAveragingMode()
1037
- updateUI(callingfunc="set_0p01", orthoimages=True, histogram=True)
1038
-
1039
-
1040
- def set_0p005():
1041
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1042
- print("setting functional mask to p<0.005")
1043
- ui.setMask_Button.setText("p<0.005")
1039
+ maskinfodicts = {}
1040
+ maskinfodicts["nomask"] = {
1041
+ "msg": "Disabling functional mask",
1042
+ "label": "No mask",
1043
+ }
1044
+ maskinfodicts["meanmask"] = {
1045
+ "msg": "Mean regressor seed mask",
1046
+ "label": "Mean mask",
1047
+ }
1048
+ maskinfodicts["lagmask"] = {
1049
+ "msg": "Using valid fit points as functional mask",
1050
+ "label": "Valid mask",
1051
+ }
1052
+ maskinfodicts["refinemask"] = {
1053
+ "msg": "Voxel refinement mask",
1054
+ "label": "Refine mask",
1055
+ }
1056
+ maskinfodicts["preselectmask"] = {
1057
+ "msg": "Preselected mean regressor seed mask",
1058
+ "label": "Preselect mask",
1059
+ }
1060
+ for pval in [0.05, 0.01, 0.005, 0.001]:
1061
+ maskinfodicts[f"p_lt_{(str(pval) + '0').replace('.','p')[0:5]}_mask"] = {
1062
+ "msg": f"Setting functional mask to p<{str(pval)}",
1063
+ "label": f"p<{str(pval)}",
1064
+ }
1065
+ print(maskinfodicts[maskname]["msg"])
1066
+ ui.setMask_Button.setText(maskinfodicts[maskname]["label"])
1044
1067
  for themap in currentdataset.loadedfuncmaps:
1045
- overlays[themap].setFuncMask(overlays["p_lt_0p005_mask"].data)
1068
+ if maskname == "nomask":
1069
+ overlays[themap].setFuncMask(None)
1070
+ else:
1071
+ overlays[themap].setFuncMask(overlays[maskname].data)
1046
1072
  atlasaveragingdone = False
1047
1073
  updateAveragingMode()
1048
- updateUI(callingfunc="set_0p005", orthoimages=True, histogram=True)
1074
+ updateUI(callingfunc=f"set_mask({maskname})", orthoimages=True, histogram=True)
1049
1075
 
1050
1076
 
1051
- def set_0p001():
1052
- global overlays, loadedfuncmaps, ui, atlasaveragingdone, currentdataset
1053
- print("setting functional mask to p<0.001")
1054
- ui.setMask_Button.setText("p<0.001")
1077
+ def set_atlasmask():
1078
+ global overlays, loadedfuncmaps, ui, currentdataset
1079
+ print("Using all defined atlas regions as functional mask")
1080
+ ui.setMask_Button.setText("Valid mask")
1055
1081
  for themap in currentdataset.loadedfuncmaps:
1056
- overlays[themap].setFuncMask(overlays["p_lt_0p001_mask"].data)
1057
- atlasaveragingdone = False
1058
- updateAveragingMode()
1059
- updateUI(callingfunc="set_0p001", orthoimages=True, histogram=True)
1060
-
1061
-
1062
- def overlay_radioButton_01_clicked(enabled):
1063
- overlay_radioButton_clicked(0, enabled)
1064
-
1065
-
1066
- def overlay_radioButton_02_clicked(enabled):
1067
- overlay_radioButton_clicked(1, enabled)
1068
-
1069
-
1070
- def overlay_radioButton_03_clicked(enabled):
1071
- overlay_radioButton_clicked(2, enabled)
1072
-
1073
-
1074
- def overlay_radioButton_04_clicked(enabled):
1075
- overlay_radioButton_clicked(3, enabled)
1076
-
1077
-
1078
- def overlay_radioButton_05_clicked(enabled):
1079
- overlay_radioButton_clicked(4, enabled)
1080
-
1081
-
1082
- def overlay_radioButton_06_clicked(enabled):
1083
- overlay_radioButton_clicked(5, enabled)
1084
-
1085
-
1086
- def overlay_radioButton_07_clicked(enabled):
1087
- overlay_radioButton_clicked(6, enabled)
1088
-
1089
-
1090
- def overlay_radioButton_08_clicked(enabled):
1091
- overlay_radioButton_clicked(7, enabled)
1082
+ overlays[themap].setFuncMask(overlays["atlasmask"].data)
1083
+ updateUI(callingfunc="set_atlasmask", orthoimages=True, histogram=True)
1092
1084
 
1093
1085
 
1094
1086
  def overlay_radioButton_clicked(which, enabled):
@@ -1261,7 +1253,7 @@ def updateOrthoImages():
1261
1253
  global maps
1262
1254
  global panetomap
1263
1255
  global ui
1264
- global mainwin, orthoimages
1256
+ global mainwin, orthoimagedict
1265
1257
  global currentloc
1266
1258
  # global updateTimecoursePlot
1267
1259
  global xdim, ydim, zdim
@@ -1270,8 +1262,8 @@ def updateOrthoImages():
1270
1262
 
1271
1263
  for thismap in panetomap:
1272
1264
  if thismap != "":
1273
- orthoimages[thismap].setXYZpos(currentloc.xpos, currentloc.ypos, currentloc.zpos)
1274
- orthoimages[thismap].setTpos(currentloc.tpos)
1265
+ orthoimagedict[thismap].setXYZpos(currentloc.xpos, currentloc.ypos, currentloc.zpos)
1266
+ orthoimagedict[thismap].setTpos(currentloc.tpos)
1275
1267
  mainwin.setMap(overlays[currentdataset.focusmap])
1276
1268
  mainwin.setTpos(currentloc.tpos)
1277
1269
  mainwin.updateAllViews()
@@ -1288,6 +1280,7 @@ def printfocusvals():
1288
1280
  "\n\nValues at location "
1289
1281
  + "{0},{1},{2}".format(currentloc.xpos, currentloc.ypos, currentloc.zpos),
1290
1282
  )
1283
+ indentstring = " "
1291
1284
  for key in overlays:
1292
1285
  # print(key, overlays[key].report)
1293
1286
  if key != "mnibrainmask":
@@ -1299,7 +1292,7 @@ def printfocusvals():
1299
1292
  if key != "atlas":
1300
1293
  if key != "failimage":
1301
1294
  outstring = (
1302
- "\t"
1295
+ indentstring
1303
1296
  + str(overlays[key].label.ljust(26))
1304
1297
  + str(":")
1305
1298
  + "{:.3f}".format(round(focusval, 3))
@@ -1310,7 +1303,7 @@ def printfocusvals():
1310
1303
  if simfuncFitter is not None:
1311
1304
  failstring = simfuncFitter.diagnosefail(np.uint32(focusval))
1312
1305
  outstring = (
1313
- "\t"
1306
+ indentstring
1314
1307
  + str(overlays[key].label.ljust(26))
1315
1308
  + str(":\n\t ")
1316
1309
  + failstring.replace(", ", "\n\t ")
@@ -1318,7 +1311,7 @@ def printfocusvals():
1318
1311
  logstatus(ui.logOutput, outstring)
1319
1312
  else:
1320
1313
  outstring = (
1321
- "\t"
1314
+ indentstring
1322
1315
  + str(overlays[key].label.ljust(26))
1323
1316
  + str(":")
1324
1317
  + str(currentdataset.atlaslabels[int(focusval) - 1])
@@ -1326,68 +1319,332 @@ def printfocusvals():
1326
1319
  logstatus(ui.logOutput, outstring)
1327
1320
 
1328
1321
 
1329
- def prefilt_radioButton_clicked(enabled):
1322
+ def regressor_radioButton_clicked(theregressor, enabled):
1330
1323
  global currentdataset
1331
- currentdataset.setfocusregressor("prefilt")
1324
+ currentdataset.setfocusregressor(theregressor)
1332
1325
  updateRegressor()
1333
1326
  updateRegressorSpectrum()
1334
1327
 
1335
1328
 
1336
- def postfilt_radioButton_clicked(enabled):
1337
- global currentdataset
1338
- currentdataset.setfocusregressor("postfilt")
1339
- updateRegressor()
1340
- updateRegressorSpectrum()
1329
+ def activatedataset(
1330
+ currentdataset, ui, win, defaultdict, overlayGraphicsViews, verbosity=0, doinit=False
1331
+ ):
1332
+ global regressors, overlays
1333
+ global mainwin
1334
+ global xdim, ydim, zdim, tdim, xpos, ypos, zpos, tpos
1335
+ global timeaxis
1336
+ global usecorrout
1337
+ global orthoimagedict
1341
1338
 
1339
+ if verbosity > 1:
1340
+ print("getting regressors")
1341
+ regressors = currentdataset.getregressors()
1342
1342
 
1343
- def pass1_radioButton_clicked(enabled):
1344
- global currentdataset
1345
- currentdataset.setfocusregressor("pass1")
1346
- updateRegressor()
1347
- updateRegressorSpectrum()
1343
+ if verbosity > 1:
1344
+ print("getting overlays")
1345
+ overlays = currentdataset.getoverlays()
1346
+ try:
1347
+ test = overlays["corrout"].display_state
1348
+ except KeyError:
1349
+ usecorrout = False
1348
1350
 
1351
+ # activate the appropriate regressor radio buttons
1352
+ if verbosity > 1:
1353
+ print("activating radio buttons")
1354
+ if "prefilt" in regressors.keys():
1355
+ ui.prefilt_radioButton.setDisabled(False)
1356
+ ui.prefilt_radioButton.show()
1357
+ else:
1358
+ ui.prefilt_radioButton.setDisabled(True)
1359
+ ui.prefilt_radioButton.hide()
1360
+ if "postfilt" in regressors.keys():
1361
+ ui.postfilt_radioButton.setDisabled(False)
1362
+ ui.postfilt_radioButton.show()
1363
+ else:
1364
+ ui.postfilt_radioButton.setDisabled(True)
1365
+ ui.postfilt_radioButton.hide()
1366
+ if "pass1" in regressors.keys():
1367
+ ui.pass1_radioButton.setDisabled(False)
1368
+ ui.pass1_radioButton.show()
1369
+ else:
1370
+ ui.pass1_radioButton.setDisabled(True)
1371
+ ui.pass1_radioButton.hide()
1372
+ if "pass2" in regressors.keys():
1373
+ ui.pass2_radioButton.setDisabled(False)
1374
+ ui.pass2_radioButton.show()
1375
+ else:
1376
+ ui.pass2_radioButton.setDisabled(True)
1377
+ ui.pass2_radioButton.hide()
1378
+ if "pass3" in regressors.keys():
1379
+ ui.pass3_radioButton.setDisabled(False)
1380
+ ui.pass3_radioButton.setText("Pass " + regressors["pass3"].label[4:])
1381
+ ui.pass3_radioButton.show()
1382
+ else:
1383
+ ui.pass3_radioButton.setDisabled(True)
1384
+ ui.pass3_radioButton.setText("")
1385
+ ui.pass3_radioButton.hide()
1386
+ if "pass4" in regressors.keys():
1387
+ ui.pass4_radioButton.setDisabled(False)
1388
+ ui.pass4_radioButton.setText("Pass " + regressors["pass4"].label[4:])
1389
+ ui.pass4_radioButton.show()
1390
+ else:
1391
+ ui.pass4_radioButton.setDisabled(True)
1392
+ ui.pass4_radioButton.setText("")
1393
+ ui.pass4_radioButton.hide()
1349
1394
 
1350
- def pass2_radioButton_clicked(enabled):
1351
- global currentdataset
1352
- currentdataset.setfocusregressor("pass2")
1353
- updateRegressor()
1354
- updateRegressorSpectrum()
1395
+ win.setWindowTitle("TiDePool - " + currentdataset.fileroot[:-1])
1355
1396
 
1397
+ # read in the significance distribution
1398
+ if os.path.isfile(currentdataset.fileroot + "sigfit.txt"):
1399
+ sighistfitname = currentdataset.fileroot + "sigfit.txt"
1400
+ else:
1401
+ sighistfitname = None
1356
1402
 
1357
- def pass3_radioButton_clicked(enabled):
1358
- global currentdataset
1359
- currentdataset.setfocusregressor("pass3")
1360
- updateRegressor()
1361
- updateRegressorSpectrum()
1403
+ # This is currently very broken, so it's disabled
1404
+ # if sighistfitname is not None:
1405
+ # thepcts = np.array([0.95, 0.99, 0.995, 0.999])
1406
+ # thervals = tide_stats.rfromp(sighistfitname, thepcts)
1407
+ # tide_stats.printthresholds(thepcts, thervals, 'Crosscorrelation significance thresholds from data:')
1362
1408
 
1409
+ # set the background image
1410
+ if "anatomic" in overlays:
1411
+ bgmap = "anatomic"
1412
+ else:
1413
+ bgmap = None
1363
1414
 
1364
- def pass4_radioButton_clicked(enabled):
1365
- global currentdataset
1366
- currentdataset.setfocusregressor("pass4")
1367
- updateRegressor()
1368
- updateRegressorSpectrum()
1415
+ # set up the timecourse plot window
1416
+ if verbosity > 1:
1417
+ print("setting up timecourse plot window")
1418
+ xpos = int(currentdataset.xdim) // 2
1419
+ ypos = int(currentdataset.ydim) // 2
1420
+ zpos = int(currentdataset.zdim) // 2
1421
+ if usecorrout:
1422
+ timeaxis = (
1423
+ np.linspace(
1424
+ 0.0,
1425
+ overlays["corrout"].tdim * overlays["corrout"].tr,
1426
+ num=overlays["corrout"].tdim,
1427
+ endpoint=False,
1428
+ )
1429
+ + overlays["corrout"].toffset
1430
+ )
1431
+ else:
1432
+ timeaxis = (
1433
+ np.linspace(
1434
+ 0.0,
1435
+ overlays[currentdataset.focusmap].tdim * overlays[currentdataset.focusmap].tr,
1436
+ num=overlays[currentdataset.focusmap].tdim,
1437
+ endpoint=False,
1438
+ )
1439
+ + overlays[currentdataset.focusmap].toffset
1440
+ )
1441
+ tpos = 0
1442
+
1443
+ # set position and scale of images
1444
+ if verbosity > 1:
1445
+ print("setting position and scale of images")
1446
+ lg_imgsize = 256.0
1447
+ sm_imgsize = 32.0
1448
+ xfov = currentdataset.xdim * currentdataset.xsize
1449
+ yfov = currentdataset.ydim * currentdataset.ysize
1450
+ zfov = currentdataset.zdim * currentdataset.zsize
1451
+ maxfov = np.max([xfov, yfov, zfov])
1452
+ # scalefacx = (lg_imgsize / maxfov) * currentdataset.xsize
1453
+ # scalefacy = (lg_imgsize / maxfov) * currentdataset.ysize
1454
+ # scalefacz = (lg_imgsize / maxfov) * currentdataset.zsize
1455
+
1456
+ if verbosity > 1:
1457
+ print("setting overlay defaults")
1458
+ for themap in currentdataset.allloadedmaps + currentdataset.loadedfuncmasks:
1459
+ overlays[themap].setLUT(
1460
+ defaultdict[themap]["colormap"], alpha=LUT_alpha, endalpha=LUT_endalpha
1461
+ )
1462
+ overlays[themap].setisdisplayed(defaultdict[themap]["display"])
1463
+ overlays[themap].setLabel(defaultdict[themap]["label"])
1464
+ if verbosity > 1:
1465
+ print("done setting overlay defaults")
1466
+
1467
+ if verbosity > 1:
1468
+ print("setting geometric masks")
1469
+ if "geommask" in overlays:
1470
+ thegeommask = overlays["geommask"].data
1471
+ if verbosity > 1:
1472
+ print("setting geometric mask")
1473
+ else:
1474
+ thegeommask = None
1475
+ if verbosity > 1:
1476
+ print("setting geometric mask to None")
1477
+
1478
+ for theoverlay in currentdataset.loadedfuncmaps:
1479
+ overlays[theoverlay].setGeomMask(thegeommask)
1480
+ if verbosity > 1:
1481
+ print("done setting geometric masks")
1482
+
1483
+ if verbosity > 1:
1484
+ print("setting functional masks")
1485
+ print(currentdataset.loadedfuncmaps)
1486
+ for theoverlay in currentdataset.loadedfuncmaps:
1487
+ if theoverlay != "failimage":
1488
+ if "p_lt_0p050_mask" in overlays and False: # disable this BBF 2/8/18
1489
+ overlays[theoverlay].setFuncMask(overlays["p_lt_0p050_mask"].data)
1490
+ ui.setMask_Button.setText("p<0.05")
1491
+ else:
1492
+ overlays[theoverlay].setFuncMask(overlays["lagmask"].data)
1493
+ ui.setMask_Button.setText("Valid mask")
1494
+ if verbosity > 1:
1495
+ print("done setting functional masks")
1496
+
1497
+ if "anatomic" in overlays:
1498
+ overlays["anatomic"].setFuncMask(None)
1499
+ overlays["anatomic"].setGeomMask(None)
1500
+
1501
+ if "atlas" in overlays:
1502
+ overlays["atlas"].setGeomMask(thegeommask)
1503
+ overlays["atlas"].setFuncMask(overlays["atlasmask"].data)
1504
+
1505
+ if verbosity > 0:
1506
+ for theoverlay in overlays:
1507
+ overlays[theoverlay].summarize()
1508
+
1509
+ if verbosity > 1:
1510
+ print("focusmap is:", currentdataset.focusmap, "bgmap is:", bgmap)
1511
+ if doinit:
1512
+ if bgmap is None:
1513
+ mainwin = OrthoImageItem(
1514
+ overlays[currentdataset.focusmap],
1515
+ ui.main_graphicsView_ax,
1516
+ ui.main_graphicsView_cor,
1517
+ ui.main_graphicsView_sag,
1518
+ imgsize=lg_imgsize,
1519
+ enableMouse=True,
1520
+ verbose=verbosity,
1521
+ )
1522
+ else:
1523
+ mainwin = OrthoImageItem(
1524
+ overlays[currentdataset.focusmap],
1525
+ ui.main_graphicsView_ax,
1526
+ ui.main_graphicsView_cor,
1527
+ ui.main_graphicsView_sag,
1528
+ bgmap=overlays[bgmap],
1529
+ imgsize=lg_imgsize,
1530
+ enableMouse=True,
1531
+ verbose=verbosity,
1532
+ )
1533
+ else:
1534
+ mainwin.setMap(overlays[currentdataset.focusmap])
1535
+
1536
+ if verbosity > 1:
1537
+ print("loading panes")
1538
+ availablepanes = len(overlayGraphicsViews)
1539
+ numnotloaded = 0
1540
+ numloaded = 0
1541
+ if doinit:
1542
+ orthoimagedict = {}
1543
+ for idx, themap in enumerate(currentdataset.dispmaps):
1544
+ if overlays[themap].display_state:
1545
+ if (numloaded > availablepanes - 1) or (
1546
+ (numloaded > availablepanes - 2) and (themap != "corrout")
1547
+ ):
1548
+ if verbosity > 1:
1549
+ print("skipping map ", themap, "(", idx, "): out of display panes")
1550
+ numnotloaded += 1
1551
+ else:
1552
+ if verbosity > 1:
1553
+ print("loading map ", themap, "(", idx, ") into pane ", numloaded)
1554
+ if bgmap is None:
1555
+ loadpane(
1556
+ overlays[themap],
1557
+ numloaded,
1558
+ overlayGraphicsViews,
1559
+ overlaybuttons,
1560
+ panetomap,
1561
+ orthoimagedict,
1562
+ sm_imgsize=sm_imgsize,
1563
+ )
1564
+ else:
1565
+ loadpane(
1566
+ overlays[themap],
1567
+ numloaded,
1568
+ overlayGraphicsViews,
1569
+ overlaybuttons,
1570
+ panetomap,
1571
+ orthoimagedict,
1572
+ bgmap=overlays[bgmap],
1573
+ sm_imgsize=sm_imgsize,
1574
+ )
1575
+ numloaded += 1
1576
+ else:
1577
+ if verbosity > 1:
1578
+ print("not loading map ", themap, "(", idx, "): display_state is False")
1579
+ else:
1580
+ for thismap in panetomap:
1581
+ if thismap != "":
1582
+ try:
1583
+ orthoimagedict[thismap].setMap(overlays[thismap])
1584
+ except KeyError:
1585
+ pass
1586
+ if verbosity > 1:
1587
+ print("done loading panes")
1588
+ if numnotloaded > 0:
1589
+ print("WARNING:", numnotloaded, "maps could not be loaded - not enough panes")
1590
+
1591
+
1592
+ def loadpane(
1593
+ themap,
1594
+ thepane,
1595
+ view,
1596
+ button,
1597
+ panemap,
1598
+ orthoimagedict,
1599
+ bgmap=None,
1600
+ sm_imgsize=32.0,
1601
+ ):
1602
+ if themap.display_state:
1603
+ if bgmap is None:
1604
+ orthoimagedict[themap.name] = OrthoImageItem(
1605
+ themap,
1606
+ view[thepane],
1607
+ view[thepane],
1608
+ view[thepane],
1609
+ button=button[thepane],
1610
+ imgsize=sm_imgsize,
1611
+ verbose=verbosity,
1612
+ )
1613
+ else:
1614
+ orthoimagedict[themap.name] = OrthoImageItem(
1615
+ themap,
1616
+ view[thepane],
1617
+ view[thepane],
1618
+ view[thepane],
1619
+ button=button[thepane],
1620
+ bgmap=bgmap,
1621
+ imgsize=sm_imgsize,
1622
+ verbose=verbosity,
1623
+ )
1624
+ panemap[thepane] = themap.name
1369
1625
 
1370
1626
 
1371
1627
  def tidepool(args):
1372
1628
  global vLine
1373
1629
  global ui, win
1374
1630
  global movierunning
1375
- global focusmap, bgmap
1631
+ global focusmap, bgmap, focusregressor
1376
1632
  global maps
1377
1633
  global roi
1378
1634
  global overlays, regressors, regressorfilterlimits, regressorsimcalclimits, loadedfuncmaps, atlasstats, averagingmode
1379
- global mainwin, orthoimages, overlaybuttons, panetomap
1635
+ global mainwin, orthoimagedict, overlaybuttons, panetomap
1380
1636
  global img_colorbar, LUT_alpha, LUT_endalpha
1381
1637
  global lg_imgsize, scalefacx, scalefacy, scalefacz
1382
1638
  global xdim, ydim, zdim, tdim, xpos, ypos, zpos, tpos
1383
1639
  global xsize, ysize, zsize, tr
1384
1640
  global timeaxis
1641
+ global usecorrout
1385
1642
  global buttonisdown
1386
1643
  global imageadj
1387
1644
  global harvestcolormaps
1388
- global datafileroot
1389
1645
  global atlasaveragingdone
1390
- global currentdataset
1646
+ global currentdataset, thesubjects, whichsubject
1647
+ global defaultdict, overlayGraphicsViews
1391
1648
  global verbosity
1392
1649
  global simfuncFitter
1393
1650
  global simfunc_ax, simfuncCurve, simfuncfitCurve, simfuncTLine, simfuncPeakMarker, simfuncCurvePoint, simfuncCaption
@@ -1416,18 +1673,22 @@ def tidepool(args):
1416
1673
  simfuncFitter = None
1417
1674
 
1418
1675
  if pyqtversion == 5:
1419
- if args.compact:
1676
+ if args.uistyle == "normal":
1420
1677
  import rapidtide.tidepoolTemplate_alt as uiTemplate
1678
+ elif args.uistyle == "big":
1679
+ import rapidtide.tidepoolTemplate_big as uiTemplate
1421
1680
  else:
1422
1681
  import rapidtide.tidepoolTemplate as uiTemplate
1423
1682
  else:
1424
- if args.compact:
1683
+ if args.uistyle == "normal":
1425
1684
  import rapidtide.tidepoolTemplate_alt_qt6 as uiTemplate
1685
+ elif args.uistyle == "big":
1686
+ import rapidtide.tidepoolTemplate_big_qt6 as uiTemplate
1426
1687
  else:
1427
1688
  import rapidtide.tidepoolTemplate_qt6 as uiTemplate
1428
1689
 
1429
1690
  verbosity = args.verbose
1430
- print(f"verbosity: {args.verbose}")
1691
+ print(f"verbosity: {verbosity}")
1431
1692
 
1432
1693
  anatname = args.anatname
1433
1694
  if anatname is not None:
@@ -1441,11 +1702,10 @@ def tidepool(args):
1441
1702
  else:
1442
1703
  geommaskname = None
1443
1704
 
1444
- datafileroot = args.datafileroot
1445
- if datafileroot is not None:
1446
- print("using ", datafileroot, " as the root file name ")
1447
- else:
1448
- datafileroot = ""
1705
+ datafileroots = []
1706
+ if args.datafileroot is not None:
1707
+ print("using ", args.datafileroot, " as the root file name list")
1708
+ datafileroots = args.datafileroot
1449
1709
 
1450
1710
  if args.offsettime is not None:
1451
1711
  forceoffset = True
@@ -1469,16 +1729,32 @@ def tidepool(args):
1469
1729
  # make the main window
1470
1730
  app = QtWidgets.QApplication([])
1471
1731
  print("setting up output window")
1732
+ # win = KeyPressWindow()
1733
+ # win.sigKeyPress.connect(keyPressed)
1472
1734
  win = QtWidgets.QMainWindow()
1473
1735
  ui = uiTemplate.Ui_MainWindow()
1474
1736
  ui.setupUi(win)
1475
1737
  win.show()
1476
1738
  win.setWindowTitle("TiDePool")
1477
1739
 
1740
+ """"# create the menu bar
1741
+ print("creating menu bar")
1742
+ menuBar = win.menuBar()
1743
+ fileMenu = QtWidgets.QMenu(win)
1744
+ if pyqtversion == 5:
1745
+ qactionfunc = QtWidgets.QAction
1746
+ else:
1747
+ qactionfunc = QtGui.QAction
1748
+ sel_open = qactionfunc("Open", win)
1749
+ sel_open.triggered.connect(selectFile())
1750
+ fileMenu.addAction(sel_open)
1751
+ win.setMenuBar(menuBar)
1752
+ print("done creating menu bar")"""
1753
+
1478
1754
  # get inputfile root name if necessary
1479
- if datafileroot == "":
1480
- selectFile()
1481
- if datafileroot == "":
1755
+ if len(datafileroots) == 0:
1756
+ datafileroots.append(selectFile())
1757
+ if len(datafileroots) == 0:
1482
1758
  print("No input file specified - exiting.")
1483
1759
  sys.exit()
1484
1760
 
@@ -1583,13 +1859,13 @@ def tidepool(args):
1583
1859
  },
1584
1860
  "lagtimes": {
1585
1861
  "colormap": gen_viridis_state(),
1586
- "label": "Lag times",
1862
+ "label": "Lag time",
1587
1863
  "display": True,
1588
1864
  "funcmask": "p_lt_0p050_mask",
1589
1865
  },
1590
1866
  "lagtimesrefined": {
1591
1867
  "colormap": gen_viridis_state(),
1592
- "label": "Refineed lag times",
1868
+ "label": "Refined lag time",
1593
1869
  "display": True,
1594
1870
  "funcmask": "p_lt_0p050_mask",
1595
1871
  },
@@ -1619,7 +1895,7 @@ def tidepool(args):
1619
1895
  },
1620
1896
  "R2": {
1621
1897
  "colormap": gen_thermal_state(),
1622
- "label": "R2",
1898
+ "label": "Fit R2",
1623
1899
  "display": True,
1624
1900
  "funcmask": "p_lt_0p050_mask",
1625
1901
  },
@@ -1667,8 +1943,8 @@ def tidepool(args):
1667
1943
  },
1668
1944
  "neglog10p": {
1669
1945
  "colormap": gen_thermal_state(),
1670
- "label": "Correlation fit significance",
1671
- "display": True,
1946
+ "label": "Correlation fit -log10p",
1947
+ "display": False,
1672
1948
  "funcmask": "None",
1673
1949
  },
1674
1950
  "delayoffset": {
@@ -1735,14 +2011,21 @@ def tidepool(args):
1735
2011
  ui.overlay_radioButton_07,
1736
2012
  ui.overlay_radioButton_08,
1737
2013
  ]
1738
- overlaybuttons[0].clicked.connect(overlay_radioButton_01_clicked)
1739
- overlaybuttons[1].clicked.connect(overlay_radioButton_02_clicked)
1740
- overlaybuttons[2].clicked.connect(overlay_radioButton_03_clicked)
1741
- overlaybuttons[3].clicked.connect(overlay_radioButton_04_clicked)
1742
- overlaybuttons[4].clicked.connect(overlay_radioButton_05_clicked)
1743
- overlaybuttons[5].clicked.connect(overlay_radioButton_06_clicked)
1744
- overlaybuttons[6].clicked.connect(overlay_radioButton_07_clicked)
1745
- overlaybuttons[7].clicked.connect(overlay_radioButton_08_clicked)
2014
+ if args.uistyle == "big":
2015
+ overlaybuttons += [
2016
+ ui.overlay_radioButton_09,
2017
+ ui.overlay_radioButton_10,
2018
+ ui.overlay_radioButton_11,
2019
+ ui.overlay_radioButton_12,
2020
+ ui.overlay_radioButton_13,
2021
+ ui.overlay_radioButton_14,
2022
+ ui.overlay_radioButton_15,
2023
+ ui.overlay_radioButton_16,
2024
+ ]
2025
+ for i in range(len(overlaybuttons)):
2026
+ clickfunc = partial(overlay_radioButton_clicked, i)
2027
+ overlaybuttons[i].clicked.connect(clickfunc)
2028
+
1746
2029
  for button in overlaybuttons:
1747
2030
  button.setDisabled(True)
1748
2031
  button.hide()
@@ -1757,7 +2040,17 @@ def tidepool(args):
1757
2040
  ui.overlay_graphicsView_07,
1758
2041
  ui.overlay_graphicsView_08,
1759
2042
  ]
1760
-
2043
+ if args.uistyle == "big":
2044
+ overlayGraphicsViews += [
2045
+ ui.overlay_graphicsView_09,
2046
+ ui.overlay_graphicsView_10,
2047
+ ui.overlay_graphicsView_11,
2048
+ ui.overlay_graphicsView_12,
2049
+ ui.overlay_graphicsView_13,
2050
+ ui.overlay_graphicsView_14,
2051
+ ui.overlay_graphicsView_15,
2052
+ ui.overlay_graphicsView_16,
2053
+ ]
1761
2054
  panetomap = []
1762
2055
 
1763
2056
  for theview in overlayGraphicsViews:
@@ -1771,25 +2064,26 @@ def tidepool(args):
1771
2064
  else:
1772
2065
  qactionfunc = QtGui.QAction
1773
2066
  sel_nomask = qactionfunc("No mask", win)
1774
- sel_nomask.triggered.connect(set_nomask)
1775
2067
  sel_lagmask = qactionfunc("Valid fit", win)
1776
- sel_lagmask.triggered.connect(set_lagmask)
1777
2068
  sel_refinemask = qactionfunc("Voxels used in refine", win)
1778
2069
  sel_meanmask = qactionfunc("Voxels used in mean regressor calculation", win)
1779
2070
  sel_preselectmask = qactionfunc(
1780
2071
  "Voxels chosen for the mean regressor calculation in the preselect pass", win
1781
2072
  )
1782
- sel_refinemask.triggered.connect(set_refinemask)
1783
- sel_meanmask.triggered.connect(set_meanmask)
1784
- sel_preselectmask.triggered.connect(set_preselectmask)
1785
2073
  sel_0p05 = qactionfunc("p<0.05", win)
1786
- sel_0p05.triggered.connect(set_0p05)
1787
2074
  sel_0p01 = qactionfunc("p<0.01", win)
1788
- sel_0p01.triggered.connect(set_0p01)
1789
2075
  sel_0p005 = qactionfunc("p<0.005", win)
1790
- sel_0p005.triggered.connect(set_0p005)
1791
2076
  sel_0p001 = qactionfunc("p<0.001", win)
1792
- sel_0p001.triggered.connect(set_0p001)
2077
+
2078
+ sel_nomask.triggered.connect(partial(set_mask, "nomask"))
2079
+ sel_lagmask.triggered.connect(partial(set_mask, "lagmask"))
2080
+ sel_refinemask.triggered.connect(partial(set_mask, "refinemask"))
2081
+ sel_meanmask.triggered.connect(partial(set_mask, "meanmask"))
2082
+ sel_preselectmask.triggered.connect(partial(set_mask, "preselectmask"))
2083
+ sel_0p05.triggered.connect(partial(set_mask, "p_lt_0p050_mask"))
2084
+ sel_0p01.triggered.connect(partial(set_mask, "p_lt_0p010_mask"))
2085
+ sel_0p005.triggered.connect(partial(set_mask, "p_lt_0p005_mask"))
2086
+ sel_0p001.triggered.connect(partial(set_mask, "p_lt_0p001_mask"))
1793
2087
  popMenu.addAction(sel_nomask)
1794
2088
  numspecial = 0
1795
2089
 
@@ -1809,13 +2103,12 @@ def tidepool(args):
1809
2103
  ui.pass3_radioButton,
1810
2104
  ui.pass4_radioButton,
1811
2105
  ]
1812
-
1813
- ui.prefilt_radioButton.clicked.connect(prefilt_radioButton_clicked)
1814
- ui.postfilt_radioButton.clicked.connect(postfilt_radioButton_clicked)
1815
- ui.pass1_radioButton.clicked.connect(pass1_radioButton_clicked)
1816
- ui.pass2_radioButton.clicked.connect(pass2_radioButton_clicked)
1817
- ui.pass3_radioButton.clicked.connect(pass3_radioButton_clicked)
1818
- ui.pass4_radioButton.clicked.connect(pass4_radioButton_clicked)
2106
+ ui.prefilt_radioButton.clicked.connect(partial(regressor_radioButton_clicked, "prefilt"))
2107
+ ui.postfilt_radioButton.clicked.connect(partial(regressor_radioButton_clicked, "postfilt"))
2108
+ ui.pass1_radioButton.clicked.connect(partial(regressor_radioButton_clicked, "pass1"))
2109
+ ui.pass2_radioButton.clicked.connect(partial(regressor_radioButton_clicked, "pass2"))
2110
+ ui.pass3_radioButton.clicked.connect(partial(regressor_radioButton_clicked, "pass3"))
2111
+ ui.pass4_radioButton.clicked.connect(partial(regressor_radioButton_clicked, "pass4"))
1819
2112
 
1820
2113
  for thebutton in regressorbuttons:
1821
2114
  thebutton.setDisabled(True)
@@ -1824,10 +2117,12 @@ def tidepool(args):
1824
2117
  # read in all the datasets
1825
2118
  thesubjects = []
1826
2119
 
1827
- thesubjects.append(
1828
- RapidtideDataset(
2120
+ print("loading datasets...")
2121
+ for thisdatafileroot in datafileroots:
2122
+ print("Loading", thisdatafileroot)
2123
+ thissubject = RapidtideDataset(
1829
2124
  "main",
1830
- datafileroot,
2125
+ thisdatafileroot,
1831
2126
  anatname=anatname,
1832
2127
  geommaskname=geommaskname,
1833
2128
  userise=userise,
@@ -1836,250 +2131,37 @@ def tidepool(args):
1836
2131
  forcetr=forcetr,
1837
2132
  forceoffset=forceoffset,
1838
2133
  offsettime=offsettime,
1839
- verbose=args.verbose,
1840
- )
1841
- )
1842
- currentdataset = thesubjects[-1]
1843
- print("loading datasets...")
1844
-
1845
- print("getting regressors")
1846
- regressors = currentdataset.getregressors()
1847
-
1848
- print("getting overlays")
1849
- overlays = currentdataset.getoverlays()
1850
- try:
1851
- test = overlays["corrout"].display_state
1852
- except KeyError:
1853
- usecorrout = False
1854
-
1855
- # activate the appropriate regressor radio buttons
1856
- print("activating radio buttons")
1857
- if "prefilt" in regressors.keys():
1858
- ui.prefilt_radioButton.setDisabled(False)
1859
- ui.prefilt_radioButton.show()
1860
- if "postfilt" in regressors.keys():
1861
- ui.postfilt_radioButton.setDisabled(False)
1862
- ui.postfilt_radioButton.show()
1863
- if "pass1" in regressors.keys():
1864
- ui.pass1_radioButton.setDisabled(False)
1865
- ui.pass1_radioButton.show()
1866
- if "pass2" in regressors.keys():
1867
- ui.pass2_radioButton.setDisabled(False)
1868
- ui.pass2_radioButton.show()
1869
- if "pass3" in regressors.keys():
1870
- ui.pass3_radioButton.setDisabled(False)
1871
- ui.pass3_radioButton.setText("Pass " + regressors["pass3"].label[4:])
1872
- ui.pass3_radioButton.show()
1873
- if "pass4" in regressors.keys():
1874
- ui.pass4_radioButton.setDisabled(False)
1875
- ui.pass4_radioButton.setText("Pass " + regressors["pass4"].label[4:])
1876
- ui.pass4_radioButton.show()
1877
-
1878
- win.setWindowTitle("TiDePool - " + datafileroot[:-1])
1879
-
1880
- # read in the significance distribution
1881
- if os.path.isfile(datafileroot + "sigfit.txt"):
1882
- sighistfitname = datafileroot + "sigfit.txt"
1883
- else:
1884
- sighistfitname = None
1885
-
1886
- # This is currently very broken, so it's disabled
1887
- # if sighistfitname is not None:
1888
- # thepcts = np.array([0.95, 0.99, 0.995, 0.999])
1889
- # thervals = tide_stats.rfromp(sighistfitname, thepcts)
1890
- # tide_stats.printthresholds(thepcts, thervals, 'Crosscorrelation significance thresholds from data:')
1891
-
1892
- # set the background image
1893
- if "anatomic" in overlays:
1894
- bgmap = "anatomic"
1895
- else:
1896
- bgmap = None
1897
-
1898
- # set up the timecourse plot window
1899
- print("setting up timecourse plot window")
1900
- xpos = int(currentdataset.xdim) // 2
1901
- ypos = int(currentdataset.ydim) // 2
1902
- zpos = int(currentdataset.zdim) // 2
1903
- if usecorrout:
1904
- timeaxis = (
1905
- np.linspace(
1906
- 0.0,
1907
- overlays["corrout"].tdim * overlays["corrout"].tr,
1908
- num=overlays["corrout"].tdim,
1909
- endpoint=False,
1910
- )
1911
- + overlays["corrout"].toffset
2134
+ verbose=verbosity,
1912
2135
  )
1913
- else:
1914
- timeaxis = (
1915
- np.linspace(
1916
- 0.0,
1917
- overlays[currentdataset.focusmap].tdim * overlays[currentdataset.focusmap].tr,
1918
- num=overlays[currentdataset.focusmap].tdim,
1919
- endpoint=False,
2136
+ if len(thesubjects) > 0:
2137
+ # check to see that the dimensions match
2138
+ dimmatch, sizematch, spacematch, affinematch = check_rt_spatialmatch(
2139
+ thissubject, thesubjects[0]
1920
2140
  )
1921
- + overlays[currentdataset.focusmap].toffset
1922
- )
1923
- tpos = 0
1924
-
1925
- # set position and scale of images
1926
- print("setting position and scale of images")
1927
- lg_imgsize = 256.0
1928
- sm_imgsize = 32.0
1929
- xfov = currentdataset.xdim * currentdataset.xsize
1930
- yfov = currentdataset.ydim * currentdataset.ysize
1931
- zfov = currentdataset.zdim * currentdataset.zsize
1932
- maxfov = np.max([xfov, yfov, zfov])
1933
- scalefacx = (lg_imgsize / maxfov) * currentdataset.xsize
1934
- scalefacy = (lg_imgsize / maxfov) * currentdataset.ysize
1935
- scalefacz = (lg_imgsize / maxfov) * currentdataset.zsize
1936
-
1937
- if verbosity > 1:
1938
- print("setting overlay defaults")
1939
- for themap in currentdataset.allloadedmaps + currentdataset.loadedfuncmasks:
1940
- overlays[themap].setLUT(
1941
- defaultdict[themap]["colormap"], alpha=LUT_alpha, endalpha=LUT_endalpha
1942
- )
1943
- overlays[themap].setisdisplayed(defaultdict[themap]["display"])
1944
- overlays[themap].setLabel(defaultdict[themap]["label"])
1945
- if verbosity > 1:
1946
- print("done setting overlay defaults")
1947
-
1948
- if verbosity > 1:
1949
- print("setting geometric masks")
1950
- if "geommask" in overlays:
1951
- thegeommask = overlays["geommask"].data
1952
- if verbosity > 1:
1953
- print("setting geometric mask")
1954
- else:
1955
- thegeommask = None
1956
- if verbosity > 1:
1957
- print("setting geometric mask to None")
1958
-
1959
- for theoverlay in currentdataset.loadedfuncmaps:
1960
- overlays[theoverlay].setGeomMask(thegeommask)
1961
- if verbosity > 1:
1962
- print("done setting geometric masks")
1963
-
1964
- if verbosity > 1:
1965
- print("setting functional masks")
1966
- print(currentdataset.loadedfuncmaps)
1967
- for theoverlay in currentdataset.loadedfuncmaps:
1968
- if theoverlay != "failimage":
1969
- if "p_lt_0p050_mask" in overlays and False: # disable this BBF 2/8/18
1970
- overlays[theoverlay].setFuncMask(overlays["p_lt_0p050_mask"].data)
1971
- ui.setMask_Button.setText("p<0.05")
1972
- else:
1973
- overlays[theoverlay].setFuncMask(overlays["lagmask"].data)
1974
- ui.setMask_Button.setText("Valid mask")
1975
- if verbosity > 1:
1976
- print("done setting functional masks")
1977
-
1978
- if "anatomic" in overlays:
1979
- overlays["anatomic"].setFuncMask(None)
1980
- overlays["anatomic"].setGeomMask(None)
1981
-
1982
- if "atlas" in overlays:
1983
- overlays["atlas"].setGeomMask(thegeommask)
1984
- overlays["atlas"].setFuncMask(overlays["atlasmask"].data)
1985
-
1986
- if args.verbose > 0:
1987
- for theoverlay in overlays:
1988
- overlays[theoverlay].summarize()
1989
-
1990
- def loadpane(themap, thepane, view, button, panemap, orthoimages, bgmap=None):
1991
- if themap.display_state:
1992
- if bgmap is None:
1993
- orthoimages[themap.name] = OrthoImageItem(
1994
- themap,
1995
- view[thepane],
1996
- view[thepane],
1997
- view[thepane],
1998
- button=button[thepane],
1999
- imgsize=sm_imgsize,
2000
- verbose=verbosity,
2001
- )
2141
+ if dimmatch or args.ignoredimmatch:
2142
+ thesubjects.append(thissubject)
2002
2143
  else:
2003
- orthoimages[themap.name] = OrthoImageItem(
2004
- themap,
2005
- view[thepane],
2006
- view[thepane],
2007
- view[thepane],
2008
- button=button[thepane],
2009
- bgmap=bgmap,
2010
- imgsize=sm_imgsize,
2011
- verbose=verbosity,
2012
- )
2013
- panemap[thepane] = themap.name
2014
-
2015
- if verbosity > 1:
2016
- print("focusmap is:", currentdataset.focusmap, "bgmap is:", bgmap)
2017
- if bgmap is None:
2018
- mainwin = OrthoImageItem(
2019
- overlays[currentdataset.focusmap],
2020
- ui.main_graphicsView_ax,
2021
- ui.main_graphicsView_cor,
2022
- ui.main_graphicsView_sag,
2023
- imgsize=lg_imgsize,
2024
- enableMouse=True,
2025
- verbose=verbosity,
2026
- )
2027
- else:
2028
- mainwin = OrthoImageItem(
2029
- overlays[currentdataset.focusmap],
2030
- ui.main_graphicsView_ax,
2031
- ui.main_graphicsView_cor,
2032
- ui.main_graphicsView_sag,
2033
- bgmap=overlays[bgmap],
2034
- imgsize=lg_imgsize,
2035
- enableMouse=True,
2036
- verbose=verbosity,
2037
- )
2144
+ print(f"dataset {thisdatafileroot} does not match loaded data - skipping")
2145
+ else:
2146
+ thesubjects.append(thissubject)
2147
+ whichsubject = 0
2148
+ currentdataset = thesubjects[whichsubject]
2149
+ activatedataset(
2150
+ currentdataset,
2151
+ ui,
2152
+ win,
2153
+ defaultdict,
2154
+ overlayGraphicsViews,
2155
+ verbosity=verbosity,
2156
+ doinit=True,
2157
+ )
2038
2158
 
2039
- orthoimages = {}
2040
- if verbosity > 1:
2041
- print("loading panes")
2042
- availablepanes = len(overlayGraphicsViews)
2043
- numnotloaded = 0
2044
- numloaded = 0
2045
- for idx, themap in enumerate(currentdataset.dispmaps):
2046
- if overlays[themap].display_state:
2047
- if (numloaded > availablepanes - 1) or (
2048
- (numloaded > availablepanes - 2) and (themap != "corrout")
2049
- ):
2050
- if verbosity > 1:
2051
- print("skipping map ", themap, "(", idx, "): out of display panes")
2052
- numnotloaded += 1
2053
- else:
2054
- if verbosity > 1:
2055
- print("loading map ", themap, "(", idx, ") into pane ", numloaded)
2056
- if bgmap is None:
2057
- loadpane(
2058
- overlays[themap],
2059
- numloaded,
2060
- overlayGraphicsViews,
2061
- overlaybuttons,
2062
- panetomap,
2063
- orthoimages,
2064
- )
2065
- else:
2066
- loadpane(
2067
- overlays[themap],
2068
- numloaded,
2069
- overlayGraphicsViews,
2070
- overlaybuttons,
2071
- panetomap,
2072
- orthoimages,
2073
- bgmap=overlays[bgmap],
2074
- )
2075
- numloaded += 1
2159
+ for thebutton in [ui.nextFile_Button]:
2160
+ if len(thesubjects) == 1:
2161
+ thebutton.setDisabled(True)
2162
+ thebutton.hide()
2076
2163
  else:
2077
- if verbosity > 1:
2078
- print("not loading map ", themap, "(", idx, "): display_state is False")
2079
- if verbosity > 1:
2080
- print("done loading panes")
2081
- if numnotloaded > 0:
2082
- print("WARNING:", numnotloaded, "maps could not be loaded - not enough panes")
2164
+ thebutton.clicked.connect(nextFileButtonPressed)
2083
2165
 
2084
2166
  # wire up the display range controls
2085
2167
  ui.resetDispLimits_Button.clicked.connect(resetDispLimits)
@@ -2242,7 +2324,7 @@ def tidepool(args):
2242
2324
  # timecourse_ax.enableAutoRange()
2243
2325
 
2244
2326
  # select the first pane
2245
- overlay_radioButton_01_clicked(True)
2327
+ overlay_radioButton_clicked(0, True)
2246
2328
 
2247
2329
  # have to do this after the windows are created
2248
2330
  imageadj.sigGradientChanged.connect(updateLUT)