rapidtide 3.0a12__py3-none-any.whl → 3.0a13__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.
Files changed (62) hide show
  1. cloud/gmscalc-HCPYA +1 -1
  2. cloud/rapidtide-HCPYA +3 -3
  3. rapidtide/Colortables.py +10 -10
  4. rapidtide/DerivativeDelay.py +211 -0
  5. rapidtide/{Refiner.py → RegressorRefiner.py} +1 -1
  6. rapidtide/__init__.py +2 -1
  7. rapidtide/_version.py +1 -1
  8. rapidtide/data/examples/src/test_mlregressallt.py +32 -17
  9. rapidtide/data/examples/src/testalign +1 -1
  10. rapidtide/data/examples/src/testboth +1 -1
  11. rapidtide/data/examples/src/testcifti +11 -0
  12. rapidtide/data/examples/src/testdelayvar +13 -0
  13. rapidtide/data/examples/src/testfmri +1 -0
  14. rapidtide/data/examples/src/testglmfilt +8 -6
  15. rapidtide/data/examples/src/testhappy +1 -1
  16. rapidtide/data/examples/src/testnewrefine +11 -11
  17. rapidtide/data/examples/src/testnoiseamp +2 -2
  18. rapidtide/data/examples/src/testretro +16 -7
  19. rapidtide/data/examples/src/testretrolagtcs +1 -1
  20. rapidtide/dlfilter.py +0 -1
  21. rapidtide/fit.py +41 -9
  22. rapidtide/happy_supportfuncs.py +5 -0
  23. rapidtide/io.py +13 -2
  24. rapidtide/{glmpass.py → linfitfiltpass.py} +21 -19
  25. rapidtide/refinedelay.py +96 -58
  26. rapidtide/resample.py +3 -0
  27. rapidtide/scripts/{retroglm.py → delayvar.py} +2 -2
  28. rapidtide/scripts/{glmfilt.py → linfitfilt.py} +2 -2
  29. rapidtide/scripts/retroregress.py +28 -0
  30. rapidtide/scripts/stupidramtricks.py +9 -7
  31. rapidtide/simfuncfit.py +1 -1
  32. rapidtide/tests/cleanposttest +21 -0
  33. rapidtide/tests/test_delayestimation.py +3 -3
  34. rapidtide/tests/test_fastresampler.py +1 -2
  35. rapidtide/tests/test_fullrunhappy_v1.py +1 -1
  36. rapidtide/tests/test_fullrunhappy_v2.py +1 -1
  37. rapidtide/tests/test_fullrunrapidtide_v1.py +2 -2
  38. rapidtide/tests/test_fullrunrapidtide_v3.py +1 -1
  39. rapidtide/tests/test_fullrunrapidtide_v5.py +1 -1
  40. rapidtide/tests/test_fullrunrapidtide_v6.py +11 -11
  41. rapidtide/tests/{test_glmpass.py → test_linfitfiltpass.py} +9 -9
  42. rapidtide/tests/test_motionregress.py +3 -3
  43. rapidtide/tests/test_refinedelay.py +12 -12
  44. rapidtide/tidepoolTemplate_alt_qt6.py +172 -45
  45. rapidtide/tidepoolTemplate_big_qt6.py +196 -53
  46. rapidtide/tidepoolTemplate_qt6.py +150 -39
  47. rapidtide/workflows/delayvar.py +1048 -0
  48. rapidtide/workflows/happy.py +37 -11
  49. rapidtide/workflows/happy_parser.py +4 -4
  50. rapidtide/workflows/{glmfilt.py → linfitfilt.py} +4 -4
  51. rapidtide/workflows/rapidtide.py +235 -171
  52. rapidtide/workflows/rapidtide_parser.py +103 -86
  53. rapidtide/workflows/{glmfrommaps.py → regressfrommaps.py} +28 -26
  54. rapidtide/workflows/retrolagtcs.py +12 -12
  55. rapidtide/workflows/{retroglm.py → retroregress.py} +158 -141
  56. {rapidtide-3.0a12.dist-info → rapidtide-3.0a13.dist-info}/METADATA +3 -2
  57. {rapidtide-3.0a12.dist-info → rapidtide-3.0a13.dist-info}/RECORD +61 -56
  58. {rapidtide-3.0a12.dist-info → rapidtide-3.0a13.dist-info}/WHEEL +1 -1
  59. {rapidtide-3.0a12.dist-info → rapidtide-3.0a13.dist-info}/entry_points.txt +3 -2
  60. rapidtide/data/examples/src/testoutputsize +0 -45
  61. {rapidtide-3.0a12.dist-info → rapidtide-3.0a13.dist-info/licenses}/LICENSE +0 -0
  62. {rapidtide-3.0a12.dist-info → rapidtide-3.0a13.dist-info}/top_level.txt +0 -0
@@ -30,10 +30,10 @@ from tqdm import tqdm
30
30
  import rapidtide.correlate as tide_corr
31
31
  import rapidtide.filter as tide_filt
32
32
  import rapidtide.fit as tide_fit
33
- import rapidtide.glmpass as tide_glmpass
34
33
  import rapidtide.happy_supportfuncs as happy_support
35
34
  import rapidtide.helper_classes as tide_classes
36
35
  import rapidtide.io as tide_io
36
+ import rapidtide.linfitfiltpass as tide_linfitfiltpass
37
37
  import rapidtide.maskutil as tide_mask
38
38
  import rapidtide.miscmath as tide_math
39
39
  import rapidtide.resample as tide_resample
@@ -157,8 +157,8 @@ def happy_main(argparsingfunc):
157
157
  args.mklthreads = mklmaxthreads
158
158
  mkl.set_num_threads(args.mklthreads)
159
159
 
160
- # if we are going to do a glm, make sure we are generating app matrix
161
- if (args.dotemporalglm or args.dospatialglm) and args.cardcalconly:
160
+ # if we are going to do noise regression, make sure we are generating app matrix
161
+ if (args.dotemporalregression or args.dospatialregression) and args.cardcalconly:
162
162
  print("doing glm fit requires phase projection - setting cardcalconly to False")
163
163
  args.cardcalconly = False
164
164
 
@@ -244,7 +244,7 @@ def happy_main(argparsingfunc):
244
244
  order=args.motfilt_order,
245
245
  )
246
246
  (motionregressors, motionregressorlabels, filtereddata, confoundr2) = (
247
- tide_glmpass.confoundregress(
247
+ tide_linfitfiltpass.confoundregress(
248
248
  confoundregressors,
249
249
  confoundregressorlabels,
250
250
  fmri_data[validprojvoxels, :],
@@ -438,6 +438,14 @@ def happy_main(argparsingfunc):
438
438
  append=False,
439
439
  debug=args.debug,
440
440
  )
441
+ tide_io.writebidstsv(
442
+ outputroot + "_desc-sliceresrespfromfmri_timeseries",
443
+ respfromfmri_sliceres,
444
+ slicesamplerate,
445
+ columns=["respfromfmri"],
446
+ append=False,
447
+ debug=args.debug,
448
+ )
441
449
 
442
450
  # stash away a copy of the waveform if we need it later
443
451
  raw_cardfromfmri_sliceres = np.array(cardfromfmri_sliceres)
@@ -471,6 +479,14 @@ def happy_main(argparsingfunc):
471
479
  append=True,
472
480
  debug=args.debug,
473
481
  )
482
+ tide_io.writebidstsv(
483
+ outputroot + "_desc-sliceresrespfromfmri_timeseries",
484
+ respfromfmri_sliceres * (1.0 - thebadcardpts),
485
+ slicesamplerate,
486
+ columns=["respfromfmri_censored"],
487
+ append=False,
488
+ debug=args.debug,
489
+ )
474
490
  peakfreq_bold = happy_support.getcardcoeffs(
475
491
  (1.0 - thebadcardpts) * cardiacwaveform,
476
492
  slicesamplerate,
@@ -1370,11 +1386,14 @@ def happy_main(argparsingfunc):
1370
1386
  )
1371
1387
  wavedelay = np.zeros((xsize, ysize, numslices), dtype=np.float64)
1372
1388
  wavedelay_byslice = wavedelay.reshape((xsize * ysize, numslices))
1389
+ wavedelayCOM = np.zeros((xsize, ysize, numslices), dtype=np.float64)
1390
+ wavedelayCOM_byslice = wavedelayCOM.reshape((xsize * ysize, numslices))
1373
1391
  waveamp = np.zeros((xsize, ysize, numslices), dtype=np.float64)
1374
1392
  waveamp_byslice = waveamp.reshape((xsize * ysize, numslices))
1375
1393
  else:
1376
1394
  thecorrfunc *= 0.0
1377
1395
  wavedelay *= 0.0
1396
+ wavedelayCOM *= 0.0
1378
1397
  waveamp *= 0.0
1379
1398
 
1380
1399
  # now project the data
@@ -1455,6 +1474,10 @@ def happy_main(argparsingfunc):
1455
1474
  waveamp_byslice[theloc, theslice] = np.fabs(
1456
1475
  thecorrfunc_byslice[theloc, theslice, maxloc]
1457
1476
  )
1477
+ wavedelayCOM_byslice[theloc, theslice] = happy_support.theCOM(
1478
+ thealiasedcorrx[corrstartloc : correndloc + 1],
1479
+ np.fabs(thecorrfunc_byslice[theloc, theslice, :]),
1480
+ )
1458
1481
  else:
1459
1482
  corrected_rawapp_byslice[validlocs, theslice, :] = rawapp_byslice[
1460
1483
  validlocs, theslice, :
@@ -1543,15 +1566,18 @@ def happy_main(argparsingfunc):
1543
1566
  theheader["pixdim"][4] = thealiasedcorrx[1] - thealiasedcorrx[0]
1544
1567
  corrfuncfilename = outputroot + "_desc-corrfunc_info"
1545
1568
  wavedelayfilename = outputroot + "_desc-wavedelay_map"
1569
+ wavedelayCOMfilename = outputroot + "_desc-wavedelayCOM_map"
1546
1570
  waveampfilename = outputroot + "_desc-waveamp_map"
1547
1571
  bidsdict = bidsbasedict.copy()
1548
1572
  tide_io.writedicttojson(bidsdict, waveampfilename + ".json")
1549
1573
  bidsdict["Units"] = "second"
1550
1574
  tide_io.writedicttojson(bidsdict, corrfuncfilename + ".json")
1551
1575
  tide_io.writedicttojson(bidsdict, wavedelayfilename + ".json")
1576
+ tide_io.writedicttojson(bidsdict, wavedelayCOMfilename + ".json")
1552
1577
  tide_io.savetonifti(thecorrfunc, theheader, corrfuncfilename)
1553
1578
  theheader["dim"][4] = 1
1554
1579
  tide_io.savetonifti(wavedelay, theheader, wavedelayfilename)
1580
+ tide_io.savetonifti(wavedelayCOM, theheader, wavedelayCOMfilename)
1555
1581
  tide_io.savetonifti(waveamp, theheader, waveampfilename)
1556
1582
 
1557
1583
  # make and save a voxel intensity histogram
@@ -1678,7 +1704,7 @@ def happy_main(argparsingfunc):
1678
1704
  )
1679
1705
 
1680
1706
  # now generate aliased cardiac signals and regress them out of the data
1681
- if args.dotemporalglm or args.dospatialglm:
1707
+ if args.dotemporalregression or args.dospatialregression:
1682
1708
  # generate the signals
1683
1709
  timings.append(["Cardiac signal regression started", time.time(), None, None])
1684
1710
  tide_util.logmem("before cardiac regression")
@@ -1721,15 +1747,15 @@ def happy_main(argparsingfunc):
1721
1747
  validlocs = np.where(mask > 0)[0]
1722
1748
  numvalidspatiallocs = len(validlocs)
1723
1749
  threshval = 0.0
1724
- if args.dospatialglm:
1750
+ if args.dospatialregression:
1725
1751
  meanvals = np.zeros(timepoints, dtype=np.float64)
1726
1752
  rvals = np.zeros(timepoints, dtype=np.float64)
1727
1753
  r2vals = np.zeros(timepoints, dtype=np.float64)
1728
1754
  fitcoffs = np.zeros(timepoints, dtype=np.float64)
1729
1755
  fitNorm = np.zeros(timepoints, dtype=np.float64)
1730
1756
  datatoremove = 0.0 * fmri_data
1731
- print("Running spatial glm on", timepoints, "timepoints")
1732
- tide_glmpass.glmpass(
1757
+ print("Running spatial regression on", timepoints, "timepoints")
1758
+ tide_linfitfiltpass.linfitfiltpass(
1733
1759
  timepoints,
1734
1760
  fmri_data[validlocs, :],
1735
1761
  threshval,
@@ -1781,15 +1807,15 @@ def happy_main(argparsingfunc):
1781
1807
  ]
1782
1808
  )
1783
1809
 
1784
- if args.dotemporalglm:
1810
+ if args.dotemporalregression:
1785
1811
  meanvals = np.zeros(numspatiallocs, dtype=np.float64)
1786
1812
  rvals = np.zeros(numspatiallocs, dtype=np.float64)
1787
1813
  r2vals = np.zeros(numspatiallocs, dtype=np.float64)
1788
1814
  fitcoffs = np.zeros(numspatiallocs, dtype=np.float64)
1789
1815
  fitNorm = np.zeros(numspatiallocs, dtype=np.float64)
1790
1816
  datatoremove = 0.0 * fmri_data
1791
- print("Running temporal glm on", numvalidspatiallocs, "voxels")
1792
- tide_glmpass.glmpass(
1817
+ print("Running temporal regression on", numvalidspatiallocs, "voxels")
1818
+ tide_linfitfiltpass.linfitfiltpass(
1793
1819
  numvalidspatiallocs,
1794
1820
  fmri_data[validlocs, :],
1795
1821
  threshval,
@@ -443,15 +443,15 @@ def _get_parser():
443
443
  # Output processing
444
444
  output_proc = parser.add_argument_group("Output processing")
445
445
  output_proc.add_argument(
446
- "--spatialglm",
447
- dest="dospatialglm",
446
+ "--spatialregression",
447
+ dest="dospatialregression",
448
448
  action="store_true",
449
449
  help="Generate framewise cardiac signal maps and filter them out of the input data. ",
450
450
  default=False,
451
451
  )
452
452
  output_proc.add_argument(
453
- "--temporalglm",
454
- dest="dotemporalglm",
453
+ "--temporalregression",
454
+ dest="dotemporalregression",
455
455
  action="store_true",
456
456
  help="Generate voxelwise aliased synthetic cardiac regressors and filter them out of the input data. ",
457
457
  default=False,
@@ -28,10 +28,10 @@ from rapidtide.workflows.parser_funcs import is_valid_file
28
28
 
29
29
  def _get_parser():
30
30
  """
31
- Argument parser for glmfilt
31
+ Argument parser for linfitfilt
32
32
  """
33
33
  parser = argparse.ArgumentParser(
34
- prog="glmfilt",
34
+ prog="linfitfilt",
35
35
  description="Fits and removes the effect of voxel specific and/or global regressors.",
36
36
  allow_abbrev=False,
37
37
  )
@@ -76,7 +76,7 @@ def _get_parser():
76
76
  return parser
77
77
 
78
78
 
79
- def glmfilt(inputfile, numskip, outputroot, evfilename, datamaskname, saveall=True):
79
+ def linfitfilt(inputfile, numskip, outputroot, evfilename, datamaskname, saveall=True):
80
80
  # initialize some variables
81
81
  evdata = []
82
82
  evisnifti = []
@@ -245,7 +245,7 @@ def main():
245
245
  _get_parser().print_help()
246
246
  raise
247
247
 
248
- glmfilt(
248
+ linfitfilt(
249
249
  args["inputfile"],
250
250
  args["numskip"],
251
251
  args["outputroot"],