rapidtide 3.0a11__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.
- cloud/gmscalc-HCPYA +1 -1
- cloud/rapidtide-HCPYA +3 -3
- rapidtide/Colortables.py +10 -10
- rapidtide/DerivativeDelay.py +211 -0
- rapidtide/RegressorRefiner.py +464 -0
- rapidtide/__init__.py +2 -1
- rapidtide/_version.py +1 -1
- rapidtide/data/examples/src/test_mlregressallt.py +32 -17
- rapidtide/data/examples/src/testalign +1 -1
- rapidtide/data/examples/src/testboth +1 -1
- rapidtide/data/examples/src/testcifti +11 -0
- rapidtide/data/examples/src/testdelayvar +13 -0
- rapidtide/data/examples/src/testfmri +3 -124
- rapidtide/data/examples/src/testglmfilt +8 -6
- rapidtide/data/examples/src/testhappy +1 -1
- rapidtide/data/examples/src/testinitdelay +19 -0
- rapidtide/data/examples/src/testnewrefine +49 -0
- rapidtide/data/examples/src/testnoiseamp +2 -2
- rapidtide/data/examples/src/testrefineonly +22 -0
- rapidtide/data/examples/src/testretro +16 -7
- rapidtide/data/examples/src/testretrolagtcs +1 -1
- rapidtide/dlfilter.py +0 -1
- rapidtide/fit.py +41 -9
- rapidtide/happy_supportfuncs.py +5 -0
- rapidtide/io.py +13 -2
- rapidtide/{glmpass.py → linfitfiltpass.py} +29 -20
- rapidtide/refinedelay.py +133 -55
- rapidtide/refineregressor.py +38 -24
- rapidtide/resample.py +3 -0
- rapidtide/scripts/{retroglm.py → delayvar.py} +2 -2
- rapidtide/scripts/{glmfilt.py → linfitfilt.py} +2 -2
- rapidtide/scripts/retroregress.py +28 -0
- rapidtide/scripts/stupidramtricks.py +9 -7
- rapidtide/simfuncfit.py +1 -1
- rapidtide/tests/cleanposttest +21 -0
- rapidtide/tests/test_delayestimation.py +3 -3
- rapidtide/tests/test_fastresampler.py +1 -2
- rapidtide/tests/test_fullrunhappy_v1.py +1 -1
- rapidtide/tests/test_fullrunhappy_v2.py +1 -1
- rapidtide/tests/test_fullrunrapidtide_v1.py +2 -2
- rapidtide/tests/test_fullrunrapidtide_v3.py +1 -1
- rapidtide/tests/test_fullrunrapidtide_v5.py +1 -1
- rapidtide/tests/test_fullrunrapidtide_v6.py +11 -11
- rapidtide/tests/{test_glmpass.py → test_linfitfiltpass.py} +9 -9
- rapidtide/tests/test_motionregress.py +3 -3
- rapidtide/tests/test_refinedelay.py +12 -12
- rapidtide/tidepoolTemplate.py +1 -0
- rapidtide/tidepoolTemplate.ui +1 -0
- rapidtide/tidepoolTemplate_alt.py +5 -4
- rapidtide/tidepoolTemplate_alt.ui +3 -2
- rapidtide/tidepoolTemplate_alt_qt6.py +177 -49
- rapidtide/tidepoolTemplate_big.py +1 -0
- rapidtide/tidepoolTemplate_big.ui +1 -0
- rapidtide/tidepoolTemplate_big_qt6.py +197 -53
- rapidtide/tidepoolTemplate_qt6.py +151 -39
- rapidtide/workflows/delayvar.py +1048 -0
- rapidtide/workflows/happy.py +37 -11
- rapidtide/workflows/happy_parser.py +4 -4
- rapidtide/workflows/{glmfilt.py → linfitfilt.py} +4 -4
- rapidtide/workflows/parser_funcs.py +10 -2
- rapidtide/workflows/rapidtide.py +388 -452
- rapidtide/workflows/rapidtide_parser.py +129 -90
- rapidtide/workflows/{glmfrommaps.py → regressfrommaps.py} +28 -26
- rapidtide/workflows/retrolagtcs.py +12 -12
- rapidtide/workflows/{retroglm.py → retroregress.py} +243 -141
- rapidtide/workflows/tidepool.py +2 -2
- {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/METADATA +3 -2
- {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/RECORD +72 -63
- {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/WHEEL +1 -1
- {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/entry_points.txt +3 -2
- rapidtide/data/examples/src/testoutputsize +0 -45
- {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info/licenses}/LICENSE +0 -0
- {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/top_level.txt +0 -0
rapidtide/workflows/happy.py
CHANGED
|
@@ -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
|
|
161
|
-
if (args.
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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
|
|
1732
|
-
|
|
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.
|
|
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
|
|
1792
|
-
|
|
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
|
-
"--
|
|
447
|
-
dest="
|
|
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
|
-
"--
|
|
454
|
-
dest="
|
|
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
|
|
31
|
+
Argument parser for linfitfilt
|
|
32
32
|
"""
|
|
33
33
|
parser = argparse.ArgumentParser(
|
|
34
|
-
prog="
|
|
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
|
|
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
|
-
|
|
248
|
+
linfitfilt(
|
|
249
249
|
args["inputfile"],
|
|
250
250
|
args["numskip"],
|
|
251
251
|
args["outputroot"],
|
|
@@ -83,7 +83,7 @@ def invert_float(parser, arg):
|
|
|
83
83
|
return arg
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
def is_float(parser, arg):
|
|
86
|
+
def is_float(parser, arg, minval=None, maxval=None):
|
|
87
87
|
"""
|
|
88
88
|
Check if argument is float or auto.
|
|
89
89
|
"""
|
|
@@ -92,6 +92,10 @@ def is_float(parser, arg):
|
|
|
92
92
|
arg = float(arg)
|
|
93
93
|
except parser.error:
|
|
94
94
|
parser.error('Value {0} is not a float or "auto"'.format(arg))
|
|
95
|
+
if minval is not None and arg < minval:
|
|
96
|
+
parser.error("Value {0} is smaller than {1}".format(arg, minval))
|
|
97
|
+
if maxval is not None and arg > maxval:
|
|
98
|
+
parser.error("Value {0} is larger than {1}".format(arg, maxval))
|
|
95
99
|
|
|
96
100
|
return arg
|
|
97
101
|
|
|
@@ -115,7 +119,7 @@ def is_valid_file_or_float(parser, arg):
|
|
|
115
119
|
return arg
|
|
116
120
|
|
|
117
121
|
|
|
118
|
-
def is_int(parser, arg):
|
|
122
|
+
def is_int(parser, arg, minval=None, maxval=None):
|
|
119
123
|
"""
|
|
120
124
|
Check if argument is int or auto.
|
|
121
125
|
"""
|
|
@@ -124,6 +128,10 @@ def is_int(parser, arg):
|
|
|
124
128
|
arg = int(arg)
|
|
125
129
|
except parser.error:
|
|
126
130
|
parser.error('Value {0} is not an int or "auto"'.format(arg))
|
|
131
|
+
if minval is not None and arg < minval:
|
|
132
|
+
parser.error("Value {0} is smaller than {1}".format(arg, minval))
|
|
133
|
+
if maxval is not None and arg > maxval:
|
|
134
|
+
parser.error("Value {0} is larger than {1}".format(arg, maxval))
|
|
127
135
|
|
|
128
136
|
return arg
|
|
129
137
|
|