rapidtide 3.0a7__py3-none-any.whl → 3.0a8__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.
@@ -85,7 +85,11 @@ def _get_parser():
85
85
  )
86
86
  parser.add_argument(
87
87
  "--dataset",
88
- help="Use this dataset (skip initial selection step)",
88
+ nargs="*",
89
+ help=(
90
+ "Use this dataset root name (skip initial selection step). The root name is the entire path "
91
+ "to the rapidtide output data (including the underscore) that precedes 'desc-maxtime_map.nii.gz'"
92
+ ),
89
93
  dest="datafileroot",
90
94
  default=None,
91
95
  )
@@ -118,7 +122,6 @@ def _get_parser():
118
122
 
119
123
 
120
124
  def selectFile():
121
- global datafileroot
122
125
  mydialog = QtWidgets.QFileDialog()
123
126
  if pyqtversion == 5:
124
127
  options = mydialog.Options()
@@ -134,6 +137,7 @@ def selectFile():
134
137
  datafileroot = str(lagfilename[:bidsstartloc])
135
138
  else:
136
139
  datafileroot = str(lagfilename[: lagfilename.find("lagtimes.nii.gz")])
140
+ return datafileroot
137
141
 
138
142
 
139
143
  class xyztlocation(QtWidgets.QWidget):
@@ -456,6 +460,47 @@ class xyztlocation(QtWidgets.QWidget):
456
460
  self.movieTimer.start(int(self.frametime))
457
461
 
458
462
 
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
+
459
504
  def logstatus(thetextbox, thetext):
460
505
  if pyqtversion == 5:
461
506
  thetextbox.moveCursor(QtGui.QTextCursor.End)
@@ -695,7 +740,7 @@ def updateRegressorSpectrum():
695
740
 
696
741
 
697
742
  def calcAtlasStats():
698
- global overlays, datafileroot, atlasstats, averagingmode, currentdataset
743
+ global overlays, atlasstats, averagingmode, currentdataset
699
744
  global atlasaveragingdone
700
745
  print("in calcAtlasStats")
701
746
  methodlist = ["mean", "median", "std", "MAD", "CoV"]
@@ -742,7 +787,7 @@ def calcAtlasStats():
742
787
  df = pd.DataFrame(data=d)
743
788
  df = df[cols]
744
789
  df.to_csv(
745
- datafileroot + currentdataset.atlasname + "_" + thestat + ".txt",
790
+ currentdataset.fileroot + currentdataset.atlasname + "_" + thestat + ".txt",
746
791
  sep="\t",
747
792
  index=False,
748
793
  )
@@ -752,7 +797,7 @@ def calcAtlasStats():
752
797
 
753
798
 
754
799
  def updateAtlasStats():
755
- global overlays, datafileroot, atlasstats, averagingmode, currentdataset
800
+ global overlays, atlasstats, averagingmode, currentdataset
756
801
  print("in updateAtlasStats")
757
802
  if "atlas" in overlays and (averagingmode is not None):
758
803
  for idx, themap in enumerate(currentdataset.loadedfuncmaps):
@@ -1091,6 +1136,38 @@ def overlay_radioButton_08_clicked(enabled):
1091
1136
  overlay_radioButton_clicked(7, enabled)
1092
1137
 
1093
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)
1169
+
1170
+
1094
1171
  def overlay_radioButton_clicked(which, enabled):
1095
1172
  global imageadj, overlays, currentdataset, panetomap, ui, overlaybuttons
1096
1173
  global currentloc, atlasaveragingdone
@@ -1261,7 +1338,7 @@ def updateOrthoImages():
1261
1338
  global maps
1262
1339
  global panetomap
1263
1340
  global ui
1264
- global mainwin, orthoimages
1341
+ global mainwin, orthoimagedict
1265
1342
  global currentloc
1266
1343
  # global updateTimecoursePlot
1267
1344
  global xdim, ydim, zdim
@@ -1270,8 +1347,8 @@ def updateOrthoImages():
1270
1347
 
1271
1348
  for thismap in panetomap:
1272
1349
  if thismap != "":
1273
- orthoimages[thismap].setXYZpos(currentloc.xpos, currentloc.ypos, currentloc.zpos)
1274
- orthoimages[thismap].setTpos(currentloc.tpos)
1350
+ orthoimagedict[thismap].setXYZpos(currentloc.xpos, currentloc.ypos, currentloc.zpos)
1351
+ orthoimagedict[thismap].setTpos(currentloc.tpos)
1275
1352
  mainwin.setMap(overlays[currentdataset.focusmap])
1276
1353
  mainwin.setTpos(currentloc.tpos)
1277
1354
  mainwin.updateAllViews()
@@ -1288,6 +1365,7 @@ def printfocusvals():
1288
1365
  "\n\nValues at location "
1289
1366
  + "{0},{1},{2}".format(currentloc.xpos, currentloc.ypos, currentloc.zpos),
1290
1367
  )
1368
+ indentstring = " "
1291
1369
  for key in overlays:
1292
1370
  # print(key, overlays[key].report)
1293
1371
  if key != "mnibrainmask":
@@ -1299,7 +1377,7 @@ def printfocusvals():
1299
1377
  if key != "atlas":
1300
1378
  if key != "failimage":
1301
1379
  outstring = (
1302
- "\t"
1380
+ indentstring
1303
1381
  + str(overlays[key].label.ljust(26))
1304
1382
  + str(":")
1305
1383
  + "{:.3f}".format(round(focusval, 3))
@@ -1310,7 +1388,7 @@ def printfocusvals():
1310
1388
  if simfuncFitter is not None:
1311
1389
  failstring = simfuncFitter.diagnosefail(np.uint32(focusval))
1312
1390
  outstring = (
1313
- "\t"
1391
+ indentstring
1314
1392
  + str(overlays[key].label.ljust(26))
1315
1393
  + str(":\n\t ")
1316
1394
  + failstring.replace(", ", "\n\t ")
@@ -1318,7 +1396,7 @@ def printfocusvals():
1318
1396
  logstatus(ui.logOutput, outstring)
1319
1397
  else:
1320
1398
  outstring = (
1321
- "\t"
1399
+ indentstring
1322
1400
  + str(overlays[key].label.ljust(26))
1323
1401
  + str(":")
1324
1402
  + str(currentdataset.atlaslabels[int(focusval) - 1])
@@ -1368,6 +1446,294 @@ def pass4_radioButton_clicked(enabled):
1368
1446
  updateRegressorSpectrum()
1369
1447
 
1370
1448
 
1449
+ def activatedataset(
1450
+ currentdataset, ui, win, defaultdict, overlayGraphicsViews, verbosity=0, doinit=False
1451
+ ):
1452
+ global regressors, overlays
1453
+ global mainwin
1454
+ global xdim, ydim, zdim, tdim, xpos, ypos, zpos, tpos
1455
+ global timeaxis
1456
+ global usecorrout
1457
+ global orthoimagedict
1458
+
1459
+ print("getting regressors")
1460
+ regressors = currentdataset.getregressors()
1461
+
1462
+ print("getting overlays")
1463
+ overlays = currentdataset.getoverlays()
1464
+ try:
1465
+ test = overlays["corrout"].display_state
1466
+ except KeyError:
1467
+ usecorrout = False
1468
+
1469
+ # activate the appropriate regressor radio buttons
1470
+ print("activating radio buttons")
1471
+ if "prefilt" in regressors.keys():
1472
+ ui.prefilt_radioButton.setDisabled(False)
1473
+ ui.prefilt_radioButton.show()
1474
+ else:
1475
+ ui.prefilt_radioButton.setDisabled(True)
1476
+ ui.prefilt_radioButton.hide()
1477
+ if "postfilt" in regressors.keys():
1478
+ ui.postfilt_radioButton.setDisabled(False)
1479
+ ui.postfilt_radioButton.show()
1480
+ else:
1481
+ ui.postfilt_radioButton.setDisabled(True)
1482
+ ui.postfilt_radioButton.hide()
1483
+ if "pass1" in regressors.keys():
1484
+ ui.pass1_radioButton.setDisabled(False)
1485
+ ui.pass1_radioButton.show()
1486
+ else:
1487
+ ui.pass1_radioButton.setDisabled(True)
1488
+ ui.pass1_radioButton.hide()
1489
+ if "pass2" in regressors.keys():
1490
+ ui.pass2_radioButton.setDisabled(False)
1491
+ ui.pass2_radioButton.show()
1492
+ else:
1493
+ ui.pass2_radioButton.setDisabled(True)
1494
+ ui.pass2_radioButton.hide()
1495
+ if "pass3" in regressors.keys():
1496
+ ui.pass3_radioButton.setDisabled(False)
1497
+ ui.pass3_radioButton.setText("Pass " + regressors["pass3"].label[4:])
1498
+ ui.pass3_radioButton.show()
1499
+ else:
1500
+ ui.pass3_radioButton.setDisabled(True)
1501
+ ui.pass3_radioButton.setText("")
1502
+ ui.pass3_radioButton.hide()
1503
+ if "pass4" in regressors.keys():
1504
+ ui.pass4_radioButton.setDisabled(False)
1505
+ ui.pass4_radioButton.setText("Pass " + regressors["pass4"].label[4:])
1506
+ ui.pass4_radioButton.show()
1507
+ else:
1508
+ ui.pass4_radioButton.setDisabled(True)
1509
+ ui.pass4_radioButton.setText("")
1510
+ ui.pass4_radioButton.hide()
1511
+
1512
+ win.setWindowTitle("TiDePool - " + currentdataset.fileroot[:-1])
1513
+
1514
+ # read in the significance distribution
1515
+ if os.path.isfile(currentdataset.fileroot + "sigfit.txt"):
1516
+ sighistfitname = currentdataset.fileroot + "sigfit.txt"
1517
+ else:
1518
+ sighistfitname = None
1519
+
1520
+ # This is currently very broken, so it's disabled
1521
+ # if sighistfitname is not None:
1522
+ # thepcts = np.array([0.95, 0.99, 0.995, 0.999])
1523
+ # thervals = tide_stats.rfromp(sighistfitname, thepcts)
1524
+ # tide_stats.printthresholds(thepcts, thervals, 'Crosscorrelation significance thresholds from data:')
1525
+
1526
+ # set the background image
1527
+ if "anatomic" in overlays:
1528
+ bgmap = "anatomic"
1529
+ else:
1530
+ bgmap = None
1531
+
1532
+ # set up the timecourse plot window
1533
+ print("setting up timecourse plot window")
1534
+ xpos = int(currentdataset.xdim) // 2
1535
+ ypos = int(currentdataset.ydim) // 2
1536
+ zpos = int(currentdataset.zdim) // 2
1537
+ if usecorrout:
1538
+ timeaxis = (
1539
+ np.linspace(
1540
+ 0.0,
1541
+ overlays["corrout"].tdim * overlays["corrout"].tr,
1542
+ num=overlays["corrout"].tdim,
1543
+ endpoint=False,
1544
+ )
1545
+ + overlays["corrout"].toffset
1546
+ )
1547
+ else:
1548
+ timeaxis = (
1549
+ np.linspace(
1550
+ 0.0,
1551
+ overlays[currentdataset.focusmap].tdim * overlays[currentdataset.focusmap].tr,
1552
+ num=overlays[currentdataset.focusmap].tdim,
1553
+ endpoint=False,
1554
+ )
1555
+ + overlays[currentdataset.focusmap].toffset
1556
+ )
1557
+ tpos = 0
1558
+
1559
+ # set position and scale of images
1560
+ print("setting position and scale of images")
1561
+ lg_imgsize = 256.0
1562
+ sm_imgsize = 32.0
1563
+ xfov = currentdataset.xdim * currentdataset.xsize
1564
+ yfov = currentdataset.ydim * currentdataset.ysize
1565
+ zfov = currentdataset.zdim * currentdataset.zsize
1566
+ maxfov = np.max([xfov, yfov, zfov])
1567
+ # scalefacx = (lg_imgsize / maxfov) * currentdataset.xsize
1568
+ # scalefacy = (lg_imgsize / maxfov) * currentdataset.ysize
1569
+ # scalefacz = (lg_imgsize / maxfov) * currentdataset.zsize
1570
+
1571
+ if verbosity > 1:
1572
+ print("setting overlay defaults")
1573
+ for themap in currentdataset.allloadedmaps + currentdataset.loadedfuncmasks:
1574
+ overlays[themap].setLUT(
1575
+ defaultdict[themap]["colormap"], alpha=LUT_alpha, endalpha=LUT_endalpha
1576
+ )
1577
+ overlays[themap].setisdisplayed(defaultdict[themap]["display"])
1578
+ overlays[themap].setLabel(defaultdict[themap]["label"])
1579
+ if verbosity > 1:
1580
+ print("done setting overlay defaults")
1581
+
1582
+ if verbosity > 1:
1583
+ print("setting geometric masks")
1584
+ if "geommask" in overlays:
1585
+ thegeommask = overlays["geommask"].data
1586
+ if verbosity > 1:
1587
+ print("setting geometric mask")
1588
+ else:
1589
+ thegeommask = None
1590
+ if verbosity > 1:
1591
+ print("setting geometric mask to None")
1592
+
1593
+ for theoverlay in currentdataset.loadedfuncmaps:
1594
+ overlays[theoverlay].setGeomMask(thegeommask)
1595
+ if verbosity > 1:
1596
+ print("done setting geometric masks")
1597
+
1598
+ if verbosity > 1:
1599
+ print("setting functional masks")
1600
+ print(currentdataset.loadedfuncmaps)
1601
+ for theoverlay in currentdataset.loadedfuncmaps:
1602
+ if theoverlay != "failimage":
1603
+ if "p_lt_0p050_mask" in overlays and False: # disable this BBF 2/8/18
1604
+ overlays[theoverlay].setFuncMask(overlays["p_lt_0p050_mask"].data)
1605
+ ui.setMask_Button.setText("p<0.05")
1606
+ else:
1607
+ overlays[theoverlay].setFuncMask(overlays["lagmask"].data)
1608
+ ui.setMask_Button.setText("Valid mask")
1609
+ if verbosity > 1:
1610
+ print("done setting functional masks")
1611
+
1612
+ if "anatomic" in overlays:
1613
+ overlays["anatomic"].setFuncMask(None)
1614
+ overlays["anatomic"].setGeomMask(None)
1615
+
1616
+ if "atlas" in overlays:
1617
+ overlays["atlas"].setGeomMask(thegeommask)
1618
+ overlays["atlas"].setFuncMask(overlays["atlasmask"].data)
1619
+
1620
+ if verbosity > 0:
1621
+ for theoverlay in overlays:
1622
+ overlays[theoverlay].summarize()
1623
+
1624
+ if verbosity > 1:
1625
+ print("focusmap is:", currentdataset.focusmap, "bgmap is:", bgmap)
1626
+ if doinit:
1627
+ if bgmap is None:
1628
+ mainwin = OrthoImageItem(
1629
+ overlays[currentdataset.focusmap],
1630
+ ui.main_graphicsView_ax,
1631
+ ui.main_graphicsView_cor,
1632
+ ui.main_graphicsView_sag,
1633
+ imgsize=lg_imgsize,
1634
+ enableMouse=True,
1635
+ verbose=verbosity,
1636
+ )
1637
+ else:
1638
+ mainwin = OrthoImageItem(
1639
+ overlays[currentdataset.focusmap],
1640
+ ui.main_graphicsView_ax,
1641
+ ui.main_graphicsView_cor,
1642
+ ui.main_graphicsView_sag,
1643
+ bgmap=overlays[bgmap],
1644
+ imgsize=lg_imgsize,
1645
+ enableMouse=True,
1646
+ verbose=verbosity,
1647
+ )
1648
+ else:
1649
+ mainwin.setMap(overlays[currentdataset.focusmap])
1650
+
1651
+ if verbosity > 1:
1652
+ print("loading panes")
1653
+ availablepanes = len(overlayGraphicsViews)
1654
+ numnotloaded = 0
1655
+ numloaded = 0
1656
+ if doinit:
1657
+ orthoimagedict = {}
1658
+ for idx, themap in enumerate(currentdataset.dispmaps):
1659
+ if overlays[themap].display_state:
1660
+ if (numloaded > availablepanes - 1) or (
1661
+ (numloaded > availablepanes - 2) and (themap != "corrout")
1662
+ ):
1663
+ if verbosity > 1:
1664
+ print("skipping map ", themap, "(", idx, "): out of display panes")
1665
+ numnotloaded += 1
1666
+ else:
1667
+ if verbosity > 1:
1668
+ print("loading map ", themap, "(", idx, ") into pane ", numloaded)
1669
+ if bgmap is None:
1670
+ loadpane(
1671
+ overlays[themap],
1672
+ numloaded,
1673
+ overlayGraphicsViews,
1674
+ overlaybuttons,
1675
+ panetomap,
1676
+ orthoimagedict,
1677
+ sm_imgsize=sm_imgsize,
1678
+ )
1679
+ else:
1680
+ loadpane(
1681
+ overlays[themap],
1682
+ numloaded,
1683
+ overlayGraphicsViews,
1684
+ overlaybuttons,
1685
+ panetomap,
1686
+ orthoimagedict,
1687
+ bgmap=overlays[bgmap],
1688
+ sm_imgsize=sm_imgsize,
1689
+ )
1690
+ numloaded += 1
1691
+ else:
1692
+ if verbosity > 1:
1693
+ print("not loading map ", themap, "(", idx, "): display_state is False")
1694
+ else:
1695
+ print(orthoimagedict)
1696
+ if verbosity > 1:
1697
+ print("done loading panes")
1698
+ if numnotloaded > 0:
1699
+ print("WARNING:", numnotloaded, "maps could not be loaded - not enough panes")
1700
+
1701
+
1702
+ def loadpane(
1703
+ themap,
1704
+ thepane,
1705
+ view,
1706
+ button,
1707
+ panemap,
1708
+ orthoimagedict,
1709
+ bgmap=None,
1710
+ sm_imgsize=32.0,
1711
+ ):
1712
+ if themap.display_state:
1713
+ if bgmap is None:
1714
+ orthoimagedict[themap.name] = OrthoImageItem(
1715
+ themap,
1716
+ view[thepane],
1717
+ view[thepane],
1718
+ view[thepane],
1719
+ button=button[thepane],
1720
+ imgsize=sm_imgsize,
1721
+ verbose=verbosity,
1722
+ )
1723
+ else:
1724
+ orthoimagedict[themap.name] = OrthoImageItem(
1725
+ themap,
1726
+ view[thepane],
1727
+ view[thepane],
1728
+ view[thepane],
1729
+ button=button[thepane],
1730
+ bgmap=bgmap,
1731
+ imgsize=sm_imgsize,
1732
+ verbose=verbosity,
1733
+ )
1734
+ panemap[thepane] = themap.name
1735
+
1736
+
1371
1737
  def tidepool(args):
1372
1738
  global vLine
1373
1739
  global ui, win
@@ -1376,18 +1742,19 @@ def tidepool(args):
1376
1742
  global maps
1377
1743
  global roi
1378
1744
  global overlays, regressors, regressorfilterlimits, regressorsimcalclimits, loadedfuncmaps, atlasstats, averagingmode
1379
- global mainwin, orthoimages, overlaybuttons, panetomap
1745
+ global mainwin, orthoimagedict, overlaybuttons, panetomap
1380
1746
  global img_colorbar, LUT_alpha, LUT_endalpha
1381
1747
  global lg_imgsize, scalefacx, scalefacy, scalefacz
1382
1748
  global xdim, ydim, zdim, tdim, xpos, ypos, zpos, tpos
1383
1749
  global xsize, ysize, zsize, tr
1384
1750
  global timeaxis
1751
+ global usecorrout
1385
1752
  global buttonisdown
1386
1753
  global imageadj
1387
1754
  global harvestcolormaps
1388
- global datafileroot
1389
1755
  global atlasaveragingdone
1390
- global currentdataset
1756
+ global currentdataset, thesubjects, whichsubject
1757
+ global defaultdict, overlayGraphicsViews
1391
1758
  global verbosity
1392
1759
  global simfuncFitter
1393
1760
  global simfunc_ax, simfuncCurve, simfuncfitCurve, simfuncTLine, simfuncPeakMarker, simfuncCurvePoint, simfuncCaption
@@ -1427,7 +1794,7 @@ def tidepool(args):
1427
1794
  import rapidtide.tidepoolTemplate_qt6 as uiTemplate
1428
1795
 
1429
1796
  verbosity = args.verbose
1430
- print(f"verbosity: {args.verbose}")
1797
+ print(f"verbosity: {verbosity}")
1431
1798
 
1432
1799
  anatname = args.anatname
1433
1800
  if anatname is not None:
@@ -1441,11 +1808,10 @@ def tidepool(args):
1441
1808
  else:
1442
1809
  geommaskname = None
1443
1810
 
1444
- datafileroot = args.datafileroot
1445
- if datafileroot is not None:
1446
- print("using ", datafileroot, " as the root file name ")
1447
- else:
1448
- datafileroot = ""
1811
+ datafileroots = []
1812
+ if args.datafileroot is not None:
1813
+ print("using ", args.datafileroot, " as the root file name list")
1814
+ datafileroots = args.datafileroot
1449
1815
 
1450
1816
  if args.offsettime is not None:
1451
1817
  forceoffset = True
@@ -1469,16 +1835,32 @@ def tidepool(args):
1469
1835
  # make the main window
1470
1836
  app = QtWidgets.QApplication([])
1471
1837
  print("setting up output window")
1472
- win = QtWidgets.QMainWindow()
1838
+ win = KeyPressWindow()
1839
+ win.sigKeyPress.connect(keyPressed)
1840
+ # win = QtWidgets.QMainWindow()
1473
1841
  ui = uiTemplate.Ui_MainWindow()
1474
1842
  ui.setupUi(win)
1475
1843
  win.show()
1476
1844
  win.setWindowTitle("TiDePool")
1477
1845
 
1846
+ """"# create the menu bar
1847
+ print("creating menu bar")
1848
+ menuBar = win.menuBar()
1849
+ fileMenu = QtWidgets.QMenu(win)
1850
+ if pyqtversion == 5:
1851
+ qactionfunc = QtWidgets.QAction
1852
+ else:
1853
+ qactionfunc = QtGui.QAction
1854
+ sel_open = qactionfunc("Open", win)
1855
+ sel_open.triggered.connect(selectFile())
1856
+ fileMenu.addAction(sel_open)
1857
+ win.setMenuBar(menuBar)
1858
+ print("done creating menu bar")"""
1859
+
1478
1860
  # get inputfile root name if necessary
1479
- if datafileroot == "":
1480
- selectFile()
1481
- if datafileroot == "":
1861
+ if len(datafileroots) == 0:
1862
+ datafileroots.append(selectFile())
1863
+ if len(datafileroots) == 0:
1482
1864
  print("No input file specified - exiting.")
1483
1865
  sys.exit()
1484
1866
 
@@ -1583,13 +1965,13 @@ def tidepool(args):
1583
1965
  },
1584
1966
  "lagtimes": {
1585
1967
  "colormap": gen_viridis_state(),
1586
- "label": "Lag times",
1968
+ "label": "Lag time",
1587
1969
  "display": True,
1588
1970
  "funcmask": "p_lt_0p050_mask",
1589
1971
  },
1590
1972
  "lagtimesrefined": {
1591
1973
  "colormap": gen_viridis_state(),
1592
- "label": "Refineed lag times",
1974
+ "label": "Refined lag time",
1593
1975
  "display": True,
1594
1976
  "funcmask": "p_lt_0p050_mask",
1595
1977
  },
@@ -1619,7 +2001,7 @@ def tidepool(args):
1619
2001
  },
1620
2002
  "R2": {
1621
2003
  "colormap": gen_thermal_state(),
1622
- "label": "R2",
2004
+ "label": "Fit R2",
1623
2005
  "display": True,
1624
2006
  "funcmask": "p_lt_0p050_mask",
1625
2007
  },
@@ -1667,8 +2049,8 @@ def tidepool(args):
1667
2049
  },
1668
2050
  "neglog10p": {
1669
2051
  "colormap": gen_thermal_state(),
1670
- "label": "Correlation fit significance",
1671
- "display": True,
2052
+ "label": "Correlation fit -log10p",
2053
+ "display": False,
1672
2054
  "funcmask": "None",
1673
2055
  },
1674
2056
  "delayoffset": {
@@ -1735,14 +2117,10 @@ def tidepool(args):
1735
2117
  ui.overlay_radioButton_07,
1736
2118
  ui.overlay_radioButton_08,
1737
2119
  ]
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)
2120
+ for i in range(len(overlaybuttons)):
2121
+ clickfunc = globals()[f"overlay_radioButton_{str(i + 1).zfill(2)}_clicked"]
2122
+ overlaybuttons[i].clicked.connect(clickfunc)
2123
+
1746
2124
  for button in overlaybuttons:
1747
2125
  button.setDisabled(True)
1748
2126
  button.hide()
@@ -1824,10 +2202,12 @@ def tidepool(args):
1824
2202
  # read in all the datasets
1825
2203
  thesubjects = []
1826
2204
 
1827
- thesubjects.append(
1828
- RapidtideDataset(
2205
+ print("loading datasets...")
2206
+ for thisdatafileroot in datafileroots:
2207
+ print("Loading", thisdatafileroot)
2208
+ thissubject = RapidtideDataset(
1829
2209
  "main",
1830
- datafileroot,
2210
+ thisdatafileroot,
1831
2211
  anatname=anatname,
1832
2212
  geommaskname=geommaskname,
1833
2213
  userise=userise,
@@ -1836,250 +2216,23 @@ def tidepool(args):
1836
2216
  forcetr=forcetr,
1837
2217
  forceoffset=forceoffset,
1838
2218
  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
1912
- )
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,
1920
- )
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
- )
2002
- 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
2219
  verbose=verbosity,
2026
2220
  )
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
- )
2038
-
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
2076
- 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")
2221
+ if len(thesubjects) > 0:
2222
+ # check to see that the dimensions match
2223
+ pass
2224
+ thesubjects.append(thissubject)
2225
+ 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
+ )
2083
2236
 
2084
2237
  # wire up the display range controls
2085
2238
  ui.resetDispLimits_Button.clicked.connect(resetDispLimits)