rapidtide 3.0.7.1__py3-none-any.whl → 3.0.9__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.
- rapidtide/RapidtideDataset.py +1 -1
- rapidtide/_version.py +3 -3
- rapidtide/calcnullsimfunc.py +1 -3
- rapidtide/data/examples/src/test_findmaxlag.py +1 -1
- rapidtide/data/examples/src/testfmri +19 -7
- rapidtide/data/examples/src/testnewrefine +0 -23
- rapidtide/fMRIData_class.py +29 -52
- rapidtide/fit.py +4 -4
- rapidtide/happy_supportfuncs.py +1 -1
- rapidtide/helper_classes.py +0 -1099
- rapidtide/linfitfiltpass.py +82 -4
- rapidtide/makelaggedtcs.py +10 -0
- rapidtide/refinedelay.py +11 -20
- rapidtide/refineregressor.py +1 -1
- rapidtide/resample.py +8 -8
- rapidtide/simFuncClasses.py +1132 -0
- rapidtide/simfuncfit.py +30 -30
- rapidtide/stats.py +5 -2
- rapidtide/tests/.coveragerc +6 -0
- rapidtide/tests/cleanposttest +1 -1
- rapidtide/tests/runlocaltest +2 -2
- rapidtide/tests/test_cleanregressor.py +3 -3
- rapidtide/tests/test_congrid.py +1 -1
- rapidtide/tests/test_corrpass.py +3 -3
- rapidtide/tests/test_delayestimation.py +9 -8
- rapidtide/tests/test_findmaxlag.py +2 -2
- rapidtide/tests/test_fullrunrapidtide_v3.py +2 -1
- rapidtide/tests/test_fullrunrapidtide_v8.py +66 -0
- rapidtide/tests/test_getparsers.py +14 -6
- rapidtide/tests/test_io.py +2 -6
- rapidtide/tests/test_nullcorr.py +3 -3
- rapidtide/tests/test_refinedelay.py +20 -5
- rapidtide/tidepoolTemplate_alt.py +1 -1
- rapidtide/util.py +7 -0
- rapidtide/voxelData.py +3 -6
- rapidtide/workflows/calcSimFuncMap.py +271 -0
- rapidtide/workflows/cleanregressor.py +2 -2
- rapidtide/workflows/delayvar.py +45 -59
- rapidtide/workflows/fitSimFuncMap.py +427 -0
- rapidtide/workflows/happy.py +1 -1
- rapidtide/workflows/rapidtide.py +499 -877
- rapidtide/workflows/rapidtide_parser.py +26 -38
- rapidtide/workflows/refineDelayMap.py +138 -0
- rapidtide/{RegressorRefiner.py → workflows/refineRegressor.py} +200 -28
- rapidtide/workflows/regressfrommaps.py +38 -30
- rapidtide/workflows/retrolagtcs.py +5 -6
- rapidtide/workflows/retroregress.py +73 -191
- rapidtide/workflows/showarbcorr.py +2 -2
- rapidtide/workflows/showxcorrx.py +5 -5
- rapidtide/workflows/tidepool.py +5 -5
- {rapidtide-3.0.7.1.dist-info → rapidtide-3.0.9.dist-info}/METADATA +2 -2
- {rapidtide-3.0.7.1.dist-info → rapidtide-3.0.9.dist-info}/RECORD +56 -52
- rapidtide/workflows/delayestimation.py +0 -483
- {rapidtide-3.0.7.1.dist-info → rapidtide-3.0.9.dist-info}/WHEEL +0 -0
- {rapidtide-3.0.7.1.dist-info → rapidtide-3.0.9.dist-info}/entry_points.txt +0 -0
- {rapidtide-3.0.7.1.dist-info → rapidtide-3.0.9.dist-info}/licenses/LICENSE +0 -0
- {rapidtide-3.0.7.1.dist-info → rapidtide-3.0.9.dist-info}/top_level.txt +0 -0
rapidtide/linfitfiltpass.py
CHANGED
|
@@ -91,10 +91,12 @@ def linfitfiltpass(
|
|
|
91
91
|
filtereddata,
|
|
92
92
|
nprocs=1,
|
|
93
93
|
alwaysmultiproc=False,
|
|
94
|
+
voxelspecific=True,
|
|
94
95
|
confoundregress=False,
|
|
96
|
+
coefficientsonly=False,
|
|
95
97
|
procbyvoxel=True,
|
|
96
98
|
showprogressbar=True,
|
|
97
|
-
|
|
99
|
+
chunksize=1000,
|
|
98
100
|
rt_floatset=np.float64,
|
|
99
101
|
rt_floattype="float64",
|
|
100
102
|
verbose=True,
|
|
@@ -141,7 +143,7 @@ def linfitfiltpass(
|
|
|
141
143
|
|
|
142
144
|
# process and send the data
|
|
143
145
|
if procbyvoxel:
|
|
144
|
-
if confoundregress:
|
|
146
|
+
if confoundregress or (not voxelspecific):
|
|
145
147
|
outQ.put(
|
|
146
148
|
_procOneRegressionFitItem(
|
|
147
149
|
val,
|
|
@@ -162,7 +164,7 @@ def linfitfiltpass(
|
|
|
162
164
|
)
|
|
163
165
|
)
|
|
164
166
|
else:
|
|
165
|
-
if confoundregress:
|
|
167
|
+
if confoundregress or (not voxelspecific):
|
|
166
168
|
outQ.put(
|
|
167
169
|
_procOneRegressionFitItem(
|
|
168
170
|
val,
|
|
@@ -196,7 +198,7 @@ def linfitfiltpass(
|
|
|
196
198
|
indexaxis=indexaxis,
|
|
197
199
|
procunit=procunit,
|
|
198
200
|
showprogressbar=showprogressbar,
|
|
199
|
-
chunksize=
|
|
201
|
+
chunksize=chunksize,
|
|
200
202
|
)
|
|
201
203
|
|
|
202
204
|
# unpack the data
|
|
@@ -207,6 +209,18 @@ def linfitfiltpass(
|
|
|
207
209
|
r2value[voxel[0]] = voxel[3]
|
|
208
210
|
filtereddata[voxel[0], :] = voxel[7]
|
|
209
211
|
itemstotal += 1
|
|
212
|
+
elif coefficientsonly:
|
|
213
|
+
for voxel in data_out:
|
|
214
|
+
meanvalue[voxel[0]] = voxel[1]
|
|
215
|
+
rvalue[voxel[0]] = voxel[2]
|
|
216
|
+
r2value[voxel[0]] = voxel[3]
|
|
217
|
+
if theevs.ndim > 1:
|
|
218
|
+
fitcoeff[voxel[0], :] = voxel[4]
|
|
219
|
+
fitNorm[voxel[0], :] = voxel[5]
|
|
220
|
+
else:
|
|
221
|
+
fitcoeff[voxel[0]] = voxel[4]
|
|
222
|
+
fitNorm[voxel[0]] = voxel[5]
|
|
223
|
+
itemstotal += 1
|
|
210
224
|
else:
|
|
211
225
|
for voxel in data_out:
|
|
212
226
|
meanvalue[voxel[0]] = voxel[1]
|
|
@@ -227,6 +241,18 @@ def linfitfiltpass(
|
|
|
227
241
|
r2value[timepoint[0]] = timepoint[3]
|
|
228
242
|
filtereddata[:, timepoint[0]] = timepoint[7]
|
|
229
243
|
itemstotal += 1
|
|
244
|
+
elif coefficientsonly:
|
|
245
|
+
for timepoint in data_out:
|
|
246
|
+
meanvalue[timepoint[0]] = timepoint[1]
|
|
247
|
+
rvalue[timepoint[0]] = timepoint[2]
|
|
248
|
+
r2value[timepoint[0]] = timepoint[3]
|
|
249
|
+
if theevs.ndim > 1:
|
|
250
|
+
fitcoeff[:, timepoint[0]] = timepoint[4]
|
|
251
|
+
fitNorm[:, timepoint[0]] = timepoint[5]
|
|
252
|
+
else:
|
|
253
|
+
fitcoeff[timepoint[0]] = timepoint[4]
|
|
254
|
+
fitNorm[timepoint[0]] = timepoint[5]
|
|
255
|
+
itemstotal += 1
|
|
230
256
|
else:
|
|
231
257
|
for timepoint in data_out:
|
|
232
258
|
meanvalue[timepoint[0]] = timepoint[1]
|
|
@@ -271,6 +297,41 @@ def linfitfiltpass(
|
|
|
271
297
|
rt_floatset=rt_floatset,
|
|
272
298
|
rt_floattype=rt_floattype,
|
|
273
299
|
)
|
|
300
|
+
elif coefficientsonly:
|
|
301
|
+
if voxelspecific:
|
|
302
|
+
(
|
|
303
|
+
dummy,
|
|
304
|
+
meanvalue[vox],
|
|
305
|
+
rvalue[vox],
|
|
306
|
+
r2value[vox],
|
|
307
|
+
fitcoeff[vox],
|
|
308
|
+
fitNorm[vox],
|
|
309
|
+
dummy,
|
|
310
|
+
dummy,
|
|
311
|
+
) = _procOneRegressionFitItem(
|
|
312
|
+
vox,
|
|
313
|
+
theevs[vox, :],
|
|
314
|
+
thedata,
|
|
315
|
+
rt_floatset=rt_floatset,
|
|
316
|
+
rt_floattype=rt_floattype,
|
|
317
|
+
)
|
|
318
|
+
else:
|
|
319
|
+
(
|
|
320
|
+
dummy,
|
|
321
|
+
meanvalue[vox],
|
|
322
|
+
rvalue[vox],
|
|
323
|
+
r2value[vox],
|
|
324
|
+
fitcoeff[vox],
|
|
325
|
+
fitNorm[vox],
|
|
326
|
+
dummy,
|
|
327
|
+
dummy,
|
|
328
|
+
) = _procOneRegressionFitItem(
|
|
329
|
+
vox,
|
|
330
|
+
theevs,
|
|
331
|
+
thedata,
|
|
332
|
+
rt_floatset=rt_floatset,
|
|
333
|
+
rt_floattype=rt_floattype,
|
|
334
|
+
)
|
|
274
335
|
else:
|
|
275
336
|
(
|
|
276
337
|
dummy,
|
|
@@ -315,6 +376,23 @@ def linfitfiltpass(
|
|
|
315
376
|
rt_floatset=rt_floatset,
|
|
316
377
|
rt_floattype=rt_floattype,
|
|
317
378
|
)
|
|
379
|
+
elif coefficientsonly:
|
|
380
|
+
(
|
|
381
|
+
dummy,
|
|
382
|
+
meanvalue[timepoint],
|
|
383
|
+
rvalue[timepoint],
|
|
384
|
+
r2value[timepoint],
|
|
385
|
+
fitcoeff[timepoint],
|
|
386
|
+
fitNorm[timepoint],
|
|
387
|
+
dummy,
|
|
388
|
+
dummy,
|
|
389
|
+
) = _procOneRegressionFitItem(
|
|
390
|
+
timepoint,
|
|
391
|
+
theevs[:, timepoint],
|
|
392
|
+
thedata,
|
|
393
|
+
rt_floatset=rt_floatset,
|
|
394
|
+
rt_floattype=rt_floattype,
|
|
395
|
+
)
|
|
318
396
|
else:
|
|
319
397
|
(
|
|
320
398
|
dummy,
|
rapidtide/makelaggedtcs.py
CHANGED
|
@@ -71,7 +71,14 @@ def makelaggedtcs(
|
|
|
71
71
|
chunksize=1000,
|
|
72
72
|
rt_floatset=np.float64,
|
|
73
73
|
rt_floattype="float64",
|
|
74
|
+
debug=False,
|
|
74
75
|
):
|
|
76
|
+
if debug:
|
|
77
|
+
print("makelaggedtcs: Starting")
|
|
78
|
+
print(f"\t{lagtc.shape=}")
|
|
79
|
+
print(f"\t{lagtimes.shape=}")
|
|
80
|
+
print(f"\t{timeaxis.shape=}")
|
|
81
|
+
|
|
75
82
|
inputshape = lagtc.shape
|
|
76
83
|
voxelargs = [
|
|
77
84
|
lagtcgenerator,
|
|
@@ -110,4 +117,7 @@ def makelaggedtcs(
|
|
|
110
117
|
if LGR is not None:
|
|
111
118
|
LGR.info("garbage collected")
|
|
112
119
|
|
|
120
|
+
if debug:
|
|
121
|
+
print("makelaggedtcs: End\n\n")
|
|
122
|
+
|
|
113
123
|
return volumetotal
|
rapidtide/refinedelay.py
CHANGED
|
@@ -282,18 +282,6 @@ def ratiotodelay(theratio, offset=0.0, debug=False):
|
|
|
282
282
|
closestindex = offsetindex
|
|
283
283
|
closestoffset = funcoffsets[closestindex]
|
|
284
284
|
distance = np.fabs(funcoffsets[closestindex] - offset)
|
|
285
|
-
"""if (maplimits[0] < theratio < maplimits[1]) and (
|
|
286
|
-
distance < (funcoffsets[1] - funcoffsets[0]) / 2
|
|
287
|
-
):
|
|
288
|
-
return (
|
|
289
|
-
ratiotooffsetfunc[closestindex](theratio) + (offset - closestoffset),
|
|
290
|
-
closestoffset,
|
|
291
|
-
)
|
|
292
|
-
else:
|
|
293
|
-
return (
|
|
294
|
-
0.0,
|
|
295
|
-
closestoffset,
|
|
296
|
-
)"""
|
|
297
285
|
|
|
298
286
|
if theratio < maplimits[0]:
|
|
299
287
|
return (
|
|
@@ -302,7 +290,7 @@ def ratiotodelay(theratio, offset=0.0, debug=False):
|
|
|
302
290
|
)
|
|
303
291
|
elif theratio > maplimits[1]:
|
|
304
292
|
return (
|
|
305
|
-
ratiotooffsetfunc[closestindex](maplimits[1]),
|
|
293
|
+
ratiotooffsetfunc[closestindex](maplimits[1]) - (offset - closestoffset),
|
|
306
294
|
closestoffset,
|
|
307
295
|
)
|
|
308
296
|
else:
|
|
@@ -371,12 +359,12 @@ def getderivratios(
|
|
|
371
359
|
if endtr is None:
|
|
372
360
|
endtr = fmri_data_valid.shape[1]
|
|
373
361
|
if debug:
|
|
374
|
-
print("getderivratios")
|
|
375
|
-
print(f"{fitNorm.shape=}")
|
|
376
|
-
print(f"{fitcoeff.shape=}")
|
|
377
|
-
print(f"{regressderivs=}")
|
|
378
|
-
print(f"{starttr=}")
|
|
379
|
-
print(f"{endtr=}")
|
|
362
|
+
print("getderivratios: Starting")
|
|
363
|
+
print(f"\t{fitNorm.shape=}")
|
|
364
|
+
print(f"\t{fitcoeff.shape=}")
|
|
365
|
+
print(f"\t{regressderivs=}")
|
|
366
|
+
print(f"\t{starttr=}")
|
|
367
|
+
print(f"\t{endtr=}")
|
|
380
368
|
|
|
381
369
|
voxelsprocessed_regressionfilt, regressorset, evset = tide_regressfrommaps.regressfrommaps(
|
|
382
370
|
fmri_data_valid[:, starttr:endtr],
|
|
@@ -403,9 +391,10 @@ def getderivratios(
|
|
|
403
391
|
nprocs_makelaggedtcs=optiondict["nprocs_makelaggedtcs"],
|
|
404
392
|
nprocs_regressionfilt=optiondict["nprocs_regressionfilt"],
|
|
405
393
|
regressderivs=regressderivs,
|
|
406
|
-
|
|
394
|
+
chunksize=optiondict["mp_chunksize"],
|
|
407
395
|
showprogressbar=optiondict["showprogressbar"],
|
|
408
396
|
alwaysmultiproc=optiondict["alwaysmultiproc"],
|
|
397
|
+
coefficientsonly=True,
|
|
409
398
|
debug=debug,
|
|
410
399
|
)
|
|
411
400
|
|
|
@@ -418,6 +407,8 @@ def getderivratios(
|
|
|
418
407
|
for i in range(regressderivs):
|
|
419
408
|
regressderivratios[i, :] = np.nan_to_num(fitcoeff[:, i + 1] / fitcoeff[:, 0])
|
|
420
409
|
|
|
410
|
+
if debug:
|
|
411
|
+
print("getderivratios: End\n\n")
|
|
421
412
|
return regressderivratios, rvalue
|
|
422
413
|
|
|
423
414
|
|
rapidtide/refineregressor.py
CHANGED
|
@@ -590,7 +590,7 @@ def dorefine(
|
|
|
590
590
|
sys.exit()
|
|
591
591
|
LGR.info(
|
|
592
592
|
f"Using {len(thefit.components_)} component(s), accounting for "
|
|
593
|
-
+ f"{100.0 * np.cumsum(thefit.explained_variance_ratio_)[len(thefit.components_) - 1]}% of the variance"
|
|
593
|
+
+ f"{100.0 * np.cumsum(thefit.explained_variance_ratio_)[len(thefit.components_) - 1]:.2f}% of the variance"
|
|
594
594
|
)
|
|
595
595
|
reduceddata = thefit.inverse_transform(thefit.transform(refinevoxels))
|
|
596
596
|
if debug:
|
rapidtide/resample.py
CHANGED
|
@@ -597,7 +597,7 @@ def arbresample(
|
|
|
597
597
|
return resampled
|
|
598
598
|
|
|
599
599
|
|
|
600
|
-
def upsample(inputdata, Fs_init, Fs_higher, method="univariate", intfac=False, debug=False):
|
|
600
|
+
def upsample(inputdata, Fs_init, Fs_higher, method="univariate", intfac=False, dofilt=True, debug=False):
|
|
601
601
|
starttime = time.time()
|
|
602
602
|
if Fs_higher <= Fs_init:
|
|
603
603
|
print("upsample: target frequency must be higher than initial frequency")
|
|
@@ -607,19 +607,19 @@ def upsample(inputdata, Fs_init, Fs_higher, method="univariate", intfac=False, d
|
|
|
607
607
|
orig_x = np.linspace(0.0, (1.0 / Fs_init) * len(inputdata), num=len(inputdata), endpoint=False)
|
|
608
608
|
endpoint = orig_x[-1] - orig_x[0]
|
|
609
609
|
ts_higher = 1.0 / Fs_higher
|
|
610
|
-
numresamppts = int(endpoint // ts_higher + 1)
|
|
611
610
|
if intfac:
|
|
612
611
|
numresamppts = int(Fs_higher // Fs_init) * len(inputdata)
|
|
613
612
|
else:
|
|
614
613
|
numresamppts = int(endpoint // ts_higher + 1)
|
|
615
614
|
upsampled_x = np.arange(0.0, ts_higher * numresamppts, ts_higher)
|
|
616
615
|
upsampled_y = doresample(orig_x, inputdata, upsampled_x, method=method)
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
616
|
+
if dofilt:
|
|
617
|
+
initfilter = tide_filt.NoncausalFilter(
|
|
618
|
+
filtertype="arb", transferfunc="trapezoidal", debug=debug
|
|
619
|
+
)
|
|
620
|
+
stopfreq = np.min([1.1 * Fs_init / 2.0, Fs_higher / 2.0])
|
|
621
|
+
initfilter.setfreqs(0.0, 0.0, Fs_init / 2.0, stopfreq)
|
|
622
|
+
upsampled_y = initfilter.apply(Fs_higher, upsampled_y)
|
|
623
623
|
if debug:
|
|
624
624
|
print("upsampling took", time.time() - starttime, "seconds")
|
|
625
625
|
return upsampled_y
|