rapidtide 3.1__py3-none-any.whl → 3.1.1__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/OrthoImageItem.py +4 -4
- rapidtide/_version.py +3 -3
- rapidtide/calccoherence.py +4 -4
- rapidtide/calcnullsimfunc.py +2 -5
- rapidtide/calcsimfunc.py +1 -4
- rapidtide/correlate.py +130 -127
- rapidtide/data/examples/src/testfmri +41 -9
- rapidtide/data/examples/src/testhappy +8 -8
- rapidtide/dlfilter.py +21 -22
- rapidtide/dlfiltertorch.py +18 -19
- rapidtide/filter.py +4 -4
- rapidtide/fit.py +18 -18
- rapidtide/happy_supportfuncs.py +84 -82
- rapidtide/helper_classes.py +2 -2
- rapidtide/io.py +88 -83
- rapidtide/linfitfiltpass.py +30 -49
- rapidtide/makelaggedtcs.py +11 -16
- rapidtide/maskutil.py +30 -14
- rapidtide/miscmath.py +2 -2
- rapidtide/patchmatch.py +10 -11
- rapidtide/peakeval.py +1 -3
- rapidtide/ppgproc.py +3 -3
- rapidtide/qualitycheck.py +2 -2
- rapidtide/refinedelay.py +12 -3
- rapidtide/refineregressor.py +20 -29
- rapidtide/scripts/showxcorr_legacy.py +7 -7
- rapidtide/scripts/stupidramtricks.py +15 -17
- rapidtide/simFuncClasses.py +2 -2
- rapidtide/simfuncfit.py +27 -41
- rapidtide/tests/test_cleanregressor.py +1 -2
- rapidtide/tests/test_fullrunhappy_v3.py +11 -5
- rapidtide/tests/test_fullrunhappy_v4.py +9 -1
- rapidtide/tests/test_getparsers.py +11 -3
- rapidtide/tests/test_refinedelay.py +0 -1
- rapidtide/tests/test_simroundtrip.py +8 -0
- rapidtide/tests/test_stcorrelate.py +3 -1
- rapidtide/util.py +6 -6
- rapidtide/voxelData.py +1 -1
- rapidtide/wiener.py +122 -16
- rapidtide/wiener2.py +3 -3
- rapidtide/workflows/applyppgproc.py +33 -15
- rapidtide/workflows/calcSimFuncMap.py +11 -22
- rapidtide/workflows/ccorrica.py +4 -2
- rapidtide/workflows/cleanregressor.py +6 -11
- rapidtide/workflows/delayvar.py +8 -13
- rapidtide/workflows/fitSimFuncMap.py +2 -9
- rapidtide/workflows/happy.py +6 -6
- rapidtide/workflows/happy_parser.py +36 -25
- rapidtide/workflows/pairproc.py +10 -2
- rapidtide/workflows/pixelcomp.py +1 -2
- rapidtide/workflows/rankimage.py +1 -1
- rapidtide/workflows/rapidtide.py +98 -63
- rapidtide/workflows/refineDelayMap.py +7 -6
- rapidtide/workflows/refineRegressor.py +6 -16
- rapidtide/workflows/regressfrommaps.py +9 -6
- rapidtide/workflows/retrolagtcs.py +5 -7
- rapidtide/workflows/retroregress.py +11 -17
- rapidtide/workflows/roisummarize.py +11 -10
- rapidtide/workflows/showarbcorr.py +2 -2
- rapidtide/workflows/showxcorrx.py +6 -6
- rapidtide/workflows/simdata.py +31 -31
- rapidtide/workflows/spatialmi.py +0 -1
- rapidtide/workflows/tidepool.py +6 -4
- {rapidtide-3.1.dist-info → rapidtide-3.1.1.dist-info}/METADATA +8 -7
- {rapidtide-3.1.dist-info → rapidtide-3.1.1.dist-info}/RECORD +69 -70
- rapidtide/wiener_doc.py +0 -255
- {rapidtide-3.1.dist-info → rapidtide-3.1.1.dist-info}/WHEEL +0 -0
- {rapidtide-3.1.dist-info → rapidtide-3.1.1.dist-info}/entry_points.txt +0 -0
- {rapidtide-3.1.dist-info → rapidtide-3.1.1.dist-info}/licenses/LICENSE +0 -0
- {rapidtide-3.1.dist-info → rapidtide-3.1.1.dist-info}/top_level.txt +0 -0
rapidtide/wiener.py
CHANGED
|
@@ -28,21 +28,68 @@ def _procOneVoxelWiener(
|
|
|
28
28
|
vox: int,
|
|
29
29
|
lagtc: NDArray,
|
|
30
30
|
inittc: NDArray,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
rt_floattype: np.dtype = np.float64,
|
|
32
|
+
) -> tuple[int, float, float, float, float, NDArray, NDArray, NDArray]:
|
|
33
|
+
"""
|
|
34
|
+
Perform Wiener filter processing on a single voxel time series.
|
|
35
|
+
|
|
36
|
+
This function applies a Wiener filter to remove the lagged component from
|
|
37
|
+
the initial time course, returning both the filtered and unfiltered results
|
|
38
|
+
along with fitting statistics.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
vox : int
|
|
43
|
+
Voxel index identifier
|
|
44
|
+
lagtc : NDArray
|
|
45
|
+
Lagged time course data (input signal)
|
|
46
|
+
inittc : NDArray
|
|
47
|
+
Initial time course data (target signal)
|
|
48
|
+
rt_floattype : np.dtype, optional
|
|
49
|
+
Rapidtide float type for output arrays, default is np.float64
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
tuple[int, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, NDArray]
|
|
54
|
+
A tuple containing:
|
|
55
|
+
- vox (int): Input voxel index
|
|
56
|
+
- intercept (NDArray): Regression intercept term
|
|
57
|
+
- sqrt_R2 (NDArray): Square root of coefficient of determination
|
|
58
|
+
- R2 (NDArray): Coefficient of determination
|
|
59
|
+
- fitcoff (NDArray): Fitting coefficient
|
|
60
|
+
- ratio (NDArray): Ratio of slope to intercept
|
|
61
|
+
- datatoremove (NDArray): Data to be removed (filtered signal)
|
|
62
|
+
- residual (NDArray): Residual signal (unfiltered data)
|
|
63
|
+
|
|
64
|
+
Notes
|
|
65
|
+
-----
|
|
66
|
+
This function uses maximum likelihood regression to estimate the relationship
|
|
67
|
+
between lagged and initial time courses, then applies the Wiener filter
|
|
68
|
+
to remove the lagged component from the initial signal.
|
|
69
|
+
|
|
70
|
+
Examples
|
|
71
|
+
--------
|
|
72
|
+
>>> import numpy as np
|
|
73
|
+
>>> lagtc = np.array([1.0, 2.0, 3.0, 4.0])
|
|
74
|
+
>>> inittc = np.array([2.0, 4.0, 6.0, 8.0])
|
|
75
|
+
>>> result = _procOneVoxelWiener(0, lagtc, inittc)
|
|
76
|
+
>>> print(result[0]) # voxel index
|
|
77
|
+
0
|
|
78
|
+
>>> print(result[4]) # fitting coefficient
|
|
79
|
+
2.0
|
|
80
|
+
"""
|
|
34
81
|
thefit, R2 = tide_fit.mlregress(lagtc, inittc)
|
|
35
|
-
fitcoff =
|
|
36
|
-
datatoremove =
|
|
82
|
+
fitcoff = thefit[0, 1]
|
|
83
|
+
datatoremove = (fitcoff * lagtc).astype(rt_floattype)
|
|
37
84
|
return (
|
|
38
85
|
vox,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
86
|
+
thefit[0, 0],
|
|
87
|
+
np.sqrt(R2),
|
|
88
|
+
R2,
|
|
42
89
|
fitcoff,
|
|
43
|
-
|
|
90
|
+
thefit[0, 1] / thefit[0, 0],
|
|
44
91
|
datatoremove,
|
|
45
|
-
|
|
92
|
+
(inittc - datatoremove).astype(rt_floattype),
|
|
46
93
|
)
|
|
47
94
|
|
|
48
95
|
|
|
@@ -55,10 +102,71 @@ def wienerpass(
|
|
|
55
102
|
wienerdeconv: NDArray,
|
|
56
103
|
wpeak: NDArray,
|
|
57
104
|
resampref_y: NDArray,
|
|
58
|
-
|
|
59
|
-
rt_floattype: str = "float64",
|
|
105
|
+
rt_floattype: np.dtype = np.float64,
|
|
60
106
|
) -> int:
|
|
61
|
-
|
|
107
|
+
"""
|
|
108
|
+
Perform Wiener deconvolution on fMRI data voxels.
|
|
109
|
+
|
|
110
|
+
This function applies Wiener deconvolution to each voxel in the fMRI data
|
|
111
|
+
based on the provided lagged time course and threshold. It supports both
|
|
112
|
+
single-threaded and multi-threaded processing depending on the configuration
|
|
113
|
+
in `optiondict`.
|
|
114
|
+
|
|
115
|
+
Parameters
|
|
116
|
+
----------
|
|
117
|
+
numspatiallocs : int
|
|
118
|
+
Number of spatial locations (voxels) in the fMRI data.
|
|
119
|
+
fmri_data : NDArray
|
|
120
|
+
2D array of fMRI data with shape (numspatiallocs, timepoints).
|
|
121
|
+
threshval : float
|
|
122
|
+
Threshold value for masking voxels based on mean signal intensity.
|
|
123
|
+
lagtc : NDArray
|
|
124
|
+
2D array of lagged time courses with shape (numspatiallocs, timepoints).
|
|
125
|
+
optiondict : dict
|
|
126
|
+
Dictionary containing processing options including:
|
|
127
|
+
- 'nprocs': number of processors to use (default: 1)
|
|
128
|
+
- 'showprogressbar': whether to show progress bar (default: True)
|
|
129
|
+
- 'mp_chunksize': chunk size for multiprocessing (default: 10)
|
|
130
|
+
wienerdeconv : NDArray
|
|
131
|
+
Wiener deconvolution kernel or filter.
|
|
132
|
+
wpeak : NDArray
|
|
133
|
+
Peak values associated with the Wiener deconvolution.
|
|
134
|
+
resampref_y : NDArray
|
|
135
|
+
Resampled reference signal for filtering.
|
|
136
|
+
rt_floattype : np.dtype, optional
|
|
137
|
+
Data type for floating-point numbers, default is `np.float64`.
|
|
138
|
+
|
|
139
|
+
Returns
|
|
140
|
+
-------
|
|
141
|
+
int
|
|
142
|
+
Total number of voxels processed.
|
|
143
|
+
|
|
144
|
+
Notes
|
|
145
|
+
-----
|
|
146
|
+
- Voxels are masked based on their mean signal intensity exceeding `threshval`.
|
|
147
|
+
- If `nprocs` > 1, multiprocessing is used to process voxels in parallel.
|
|
148
|
+
- The function modifies global variables such as `meanvalue`, `rvalue`, etc.,
|
|
149
|
+
which are assumed to be defined in the outer scope.
|
|
150
|
+
|
|
151
|
+
Examples
|
|
152
|
+
--------
|
|
153
|
+
>>> import numpy as np
|
|
154
|
+
>>> fmri_data = np.random.rand(100, 50)
|
|
155
|
+
>>> lagtc = np.random.rand(100, 50)
|
|
156
|
+
>>> optiondict = {'nprocs': 4, 'showprogressbar': True, 'mp_chunksize': 5}
|
|
157
|
+
>>> result = wienerpass(
|
|
158
|
+
... numspatiallocs=100,
|
|
159
|
+
... fmri_data=fmri_data,
|
|
160
|
+
... threshval=0.1,
|
|
161
|
+
... lagtc=lagtc,
|
|
162
|
+
... optiondict=optiondict,
|
|
163
|
+
... wienerdeconv=np.array([1, 2, 1]),
|
|
164
|
+
... wpeak=np.array([0.5]),
|
|
165
|
+
... resampref_y=np.array([1, 1, 1])
|
|
166
|
+
... )
|
|
167
|
+
>>> print(result)
|
|
168
|
+
100
|
|
169
|
+
"""
|
|
62
170
|
rt_floattype = rt_floattype
|
|
63
171
|
inputshape = np.shape(fmri_data)
|
|
64
172
|
themask = np.where(np.mean(fmri_data, axis=1) > threshval, 1, 0)
|
|
@@ -80,7 +188,6 @@ def wienerpass(
|
|
|
80
188
|
val,
|
|
81
189
|
lagtc[val, :],
|
|
82
190
|
fmri_data[val, :],
|
|
83
|
-
rt_floatset=rt_floatset,
|
|
84
191
|
rt_floattype=rt_floattype,
|
|
85
192
|
)
|
|
86
193
|
)
|
|
@@ -132,8 +239,7 @@ def wienerpass(
|
|
|
132
239
|
vox,
|
|
133
240
|
lagtc[vox, :],
|
|
134
241
|
inittc,
|
|
135
|
-
|
|
136
|
-
t_floattype=rt_floattype,
|
|
242
|
+
rt_floattype=rt_floattype,
|
|
137
243
|
)
|
|
138
244
|
volumetotal += 1
|
|
139
245
|
|
rapidtide/wiener2.py
CHANGED
|
@@ -153,9 +153,9 @@ def wiener_deconvolution(signal: NDArray, kernel: NDArray, lambd: float) -> NDAr
|
|
|
153
153
|
|
|
154
154
|
Parameters
|
|
155
155
|
----------
|
|
156
|
-
signal :
|
|
156
|
+
signal : NDArray
|
|
157
157
|
Input signal to be deconvolved, assumed to be 1D.
|
|
158
|
-
kernel :
|
|
158
|
+
kernel : NDArray
|
|
159
159
|
Convolution kernel (point spread function), assumed to be 1D.
|
|
160
160
|
lambd : float
|
|
161
161
|
Regularization parameter (signal-to-noise ratio). Higher values
|
|
@@ -163,7 +163,7 @@ def wiener_deconvolution(signal: NDArray, kernel: NDArray, lambd: float) -> NDAr
|
|
|
163
163
|
|
|
164
164
|
Returns
|
|
165
165
|
-------
|
|
166
|
-
|
|
166
|
+
NDArray
|
|
167
167
|
Deconvolved signal with same length as input signal.
|
|
168
168
|
|
|
169
169
|
Notes
|
|
@@ -17,9 +17,11 @@
|
|
|
17
17
|
#
|
|
18
18
|
#
|
|
19
19
|
import argparse
|
|
20
|
-
from typing import Any
|
|
20
|
+
from typing import Any, Tuple
|
|
21
21
|
|
|
22
|
+
import matplotlib.pyplot as plt
|
|
22
23
|
import numpy as np
|
|
24
|
+
from numpy.typing import NDArray
|
|
23
25
|
|
|
24
26
|
import rapidtide.filter as tide_filt
|
|
25
27
|
import rapidtide.ppgproc as tide_ppg
|
|
@@ -133,7 +135,23 @@ def _get_parser() -> Any:
|
|
|
133
135
|
return parser
|
|
134
136
|
|
|
135
137
|
|
|
136
|
-
def procppg(
|
|
138
|
+
def procppg(
|
|
139
|
+
args: Any,
|
|
140
|
+
) -> Tuple[
|
|
141
|
+
dict,
|
|
142
|
+
NDArray,
|
|
143
|
+
NDArray,
|
|
144
|
+
NDArray,
|
|
145
|
+
NDArray,
|
|
146
|
+
NDArray,
|
|
147
|
+
NDArray,
|
|
148
|
+
NDArray,
|
|
149
|
+
NDArray,
|
|
150
|
+
NDArray,
|
|
151
|
+
NDArray,
|
|
152
|
+
NDArray,
|
|
153
|
+
NDArray,
|
|
154
|
+
]:
|
|
137
155
|
"""
|
|
138
156
|
Process PPG (Photoplethysmography) signal using a combination of filtering,
|
|
139
157
|
heart rate extraction, and signal quality assessment techniques.
|
|
@@ -171,27 +189,27 @@ def procppg(args: Any) -> None:
|
|
|
171
189
|
A tuple containing:
|
|
172
190
|
- ppginfo : dict
|
|
173
191
|
Dictionary with various performance metrics and computed features
|
|
174
|
-
- peak_indices :
|
|
192
|
+
- peak_indices : NDArray
|
|
175
193
|
Indices of detected peaks in the filtered signal
|
|
176
|
-
- rri :
|
|
194
|
+
- rri : NDArray
|
|
177
195
|
Inter-beat intervals (RRIs) derived from peak detection
|
|
178
|
-
- hr_waveform_from_peaks :
|
|
196
|
+
- hr_waveform_from_peaks : NDArray
|
|
179
197
|
Heart rate waveform computed from peaks
|
|
180
|
-
- hr_times :
|
|
198
|
+
- hr_times : NDArray
|
|
181
199
|
Time points for heart rate estimates
|
|
182
|
-
- hr_values :
|
|
200
|
+
- hr_values : NDArray
|
|
183
201
|
Heart rate values (FFT-based)
|
|
184
|
-
- filtered_ekf :
|
|
202
|
+
- filtered_ekf : NDArray
|
|
185
203
|
Signal filtered using Extended Kalman Filter
|
|
186
|
-
- ekf_heart_rates :
|
|
204
|
+
- ekf_heart_rates : NDArray
|
|
187
205
|
Heart rate estimates from EKF
|
|
188
|
-
- cardiacfromfmri_qual_times :
|
|
206
|
+
- cardiacfromfmri_qual_times : NDArray
|
|
189
207
|
Time points for quality scores from raw fMRI signal
|
|
190
|
-
- cardiacfromfmri_qual_scores :
|
|
208
|
+
- cardiacfromfmri_qual_scores : NDArray
|
|
191
209
|
Quality scores for raw fMRI signal
|
|
192
|
-
- dlfiltered_qual_times :
|
|
210
|
+
- dlfiltered_qual_times : NDArray
|
|
193
211
|
Time points for quality scores from DL-filtered signal
|
|
194
|
-
- dlfiltered_qual_scores :
|
|
212
|
+
- dlfiltered_qual_scores : NDArray
|
|
195
213
|
Quality scores for DL-filtered signal
|
|
196
214
|
|
|
197
215
|
Notes
|
|
@@ -348,7 +366,7 @@ def procppg(args: Any) -> None:
|
|
|
348
366
|
ax6.set_title("Heart Rate Extraction")
|
|
349
367
|
ax6.legend(loc="upper right")
|
|
350
368
|
ax6.grid(True, alpha=0.3)
|
|
351
|
-
ax6.set_ylim(
|
|
369
|
+
ax6.set_ylim((40.0, 110.0))
|
|
352
370
|
|
|
353
371
|
# Plot 7: Signal quality assessment
|
|
354
372
|
ax7 = fig.add_subplot(gs[thissubfig, 0])
|
|
@@ -372,7 +390,7 @@ def procppg(args: Any) -> None:
|
|
|
372
390
|
ax7.set_title("Signal Quality Assessment (0=Poor, 1=Excellent)")
|
|
373
391
|
ax7.legend(loc="upper right")
|
|
374
392
|
ax7.grid(True, alpha=0.3)
|
|
375
|
-
ax7.set_ylim(
|
|
393
|
+
ax7.set_ylim((0.0, 1.0))
|
|
376
394
|
|
|
377
395
|
plt.tight_layout()
|
|
378
396
|
plt.show()
|
|
@@ -41,10 +41,9 @@ def makeRIPTiDeRegressors(
|
|
|
41
41
|
chunksize: int = 1000,
|
|
42
42
|
targetstep: float = 2.5,
|
|
43
43
|
edgepad: int = 0,
|
|
44
|
-
|
|
45
|
-
rt_floattype: str = "float64",
|
|
44
|
+
rt_floattype: np.dtype = np.float64,
|
|
46
45
|
debug: bool = False,
|
|
47
|
-
) ->
|
|
46
|
+
) -> Tuple[NDArray, NDArray]:
|
|
48
47
|
"""
|
|
49
48
|
Generate regressors for RIPTiDe (Regressors for Inverse Temporal Deconvolution).
|
|
50
49
|
|
|
@@ -77,20 +76,18 @@ def makeRIPTiDeRegressors(
|
|
|
77
76
|
Target step size (in seconds) between lags (default is 2.5).
|
|
78
77
|
edgepad : int, optional
|
|
79
78
|
Number of padding steps at the beginning and end of the lag range (default is 0).
|
|
80
|
-
|
|
79
|
+
rt_floattype : np.dtype, optional
|
|
81
80
|
Data type for the regressor matrix (default is np.float64).
|
|
82
|
-
rt_floattype : str, optional
|
|
83
|
-
String representation of the float data type (default is "float64").
|
|
84
81
|
debug : bool, optional
|
|
85
82
|
If True, print debug information during execution (default is False).
|
|
86
83
|
|
|
87
84
|
Returns
|
|
88
85
|
-------
|
|
89
|
-
tuple of (
|
|
86
|
+
tuple of (NDArray, NDArray)
|
|
90
87
|
A tuple containing:
|
|
91
|
-
- regressorset :
|
|
88
|
+
- regressorset : NDArray
|
|
92
89
|
The computed regressor matrix of shape (num_lags, num_timepoints).
|
|
93
|
-
- delaystouse :
|
|
90
|
+
- delaystouse : NDArray
|
|
94
91
|
The array of delay values used for regressor generation.
|
|
95
92
|
|
|
96
93
|
Notes
|
|
@@ -102,7 +99,6 @@ def makeRIPTiDeRegressors(
|
|
|
102
99
|
Examples
|
|
103
100
|
--------
|
|
104
101
|
>>> import numpy as np
|
|
105
|
-
>>> from some_module import makeRIPTiDeRegressors
|
|
106
102
|
>>> fmri_data = np.random.rand(100, 50)
|
|
107
103
|
>>> regressors, delays = makeRIPTiDeRegressors(
|
|
108
104
|
... initial_fmri_x=fmri_data,
|
|
@@ -134,7 +130,7 @@ def makeRIPTiDeRegressors(
|
|
|
134
130
|
print(f"{delaystouse=}, {len(delaystouse)}")
|
|
135
131
|
print(f"{len(initial_fmri_x)}")
|
|
136
132
|
|
|
137
|
-
regressorset = np.zeros((len(delaystouse), len(initial_fmri_x)), dtype=
|
|
133
|
+
regressorset = np.zeros((len(delaystouse), len(initial_fmri_x)), dtype=rt_floattype)
|
|
138
134
|
|
|
139
135
|
dummy = tide_makelagged.makelaggedtcs(
|
|
140
136
|
lagtcgenerator,
|
|
@@ -147,7 +143,6 @@ def makeRIPTiDeRegressors(
|
|
|
147
143
|
alwaysmultiproc=alwaysmultiproc,
|
|
148
144
|
showprogressbar=showprogressbar,
|
|
149
145
|
chunksize=chunksize,
|
|
150
|
-
rt_floatset=rt_floatset,
|
|
151
146
|
rt_floattype=rt_floattype,
|
|
152
147
|
debug=debug,
|
|
153
148
|
)
|
|
@@ -201,12 +196,11 @@ def calcSimFunc(
|
|
|
201
196
|
interptype: str = "univariate",
|
|
202
197
|
showprogressbar: bool = True,
|
|
203
198
|
chunksize: int = 1000,
|
|
204
|
-
|
|
205
|
-
rt_floattype: str = "float64",
|
|
199
|
+
rt_floattype: np.dtype = np.float64,
|
|
206
200
|
mklthreads: int = 1,
|
|
207
201
|
threaddebug: bool = False,
|
|
208
202
|
debug: bool = False,
|
|
209
|
-
) ->
|
|
203
|
+
) -> str:
|
|
210
204
|
"""
|
|
211
205
|
Compute similarity metrics (correlation, mutual information, or RIPtiDe) between fMRI data and a reference time series.
|
|
212
206
|
|
|
@@ -301,10 +295,8 @@ def calcSimFunc(
|
|
|
301
295
|
Whether to show a progress bar. Default is True.
|
|
302
296
|
chunksize : int, optional
|
|
303
297
|
Size of chunks for processing. Default is 1000.
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
rt_floattype : str, optional
|
|
307
|
-
String representation of floating-point type. Default is 'float64'.
|
|
298
|
+
rt_floattype : np.dtype, optional
|
|
299
|
+
Rapidtide floating-point data type. Default is np.float64.
|
|
308
300
|
mklthreads : int, optional
|
|
309
301
|
Number of threads for Intel MKL. Default is 1.
|
|
310
302
|
threaddebug : bool, optional
|
|
@@ -400,7 +392,6 @@ def calcSimFunc(
|
|
|
400
392
|
interptype=interptype,
|
|
401
393
|
showprogressbar=showprogressbar,
|
|
402
394
|
chunksize=chunksize,
|
|
403
|
-
rt_floatset=rt_floatset,
|
|
404
395
|
rt_floattype=rt_floattype,
|
|
405
396
|
debug=debug,
|
|
406
397
|
)
|
|
@@ -425,7 +416,6 @@ def calcSimFunc(
|
|
|
425
416
|
interptype=interptype,
|
|
426
417
|
showprogressbar=showprogressbar,
|
|
427
418
|
chunksize=chunksize,
|
|
428
|
-
rt_floatset=rt_floatset,
|
|
429
419
|
rt_floattype=rt_floattype,
|
|
430
420
|
debug=debug,
|
|
431
421
|
)
|
|
@@ -452,7 +442,6 @@ def calcSimFunc(
|
|
|
452
442
|
showprogressbar=showprogressbar,
|
|
453
443
|
verbose=(LGR is not None),
|
|
454
444
|
chunksize=chunksize,
|
|
455
|
-
rt_floatset=rt_floatset,
|
|
456
445
|
rt_floattype=rt_floattype,
|
|
457
446
|
debug=debug,
|
|
458
447
|
)
|
rapidtide/workflows/ccorrica.py
CHANGED
|
@@ -320,9 +320,11 @@ def ccorrica(args: Any) -> None:
|
|
|
320
320
|
zeropadding=0,
|
|
321
321
|
displayplots=args.debug,
|
|
322
322
|
)
|
|
323
|
-
thepxcorr = pearsonr(
|
|
323
|
+
thepxcorr = pearsonr(
|
|
324
|
+
reformdata[component1, :] / tclen, reformdata[component2, :]
|
|
325
|
+
).statistic
|
|
324
326
|
outputdata[component1, component2, 0, :] = thexcorr
|
|
325
|
-
outputpdata[component1, component2, 0, :] = thepxcorr
|
|
327
|
+
outputpdata[component1, component2, 0, :] = thepxcorr
|
|
326
328
|
(
|
|
327
329
|
maxindex,
|
|
328
330
|
maxlag,
|
|
@@ -56,8 +56,7 @@ def cleanregressor(
|
|
|
56
56
|
respdelete: bool = False,
|
|
57
57
|
displayplots: bool = False,
|
|
58
58
|
debug: bool = False,
|
|
59
|
-
rt_floattype:
|
|
60
|
-
rt_floatset: Any = np.float64,
|
|
59
|
+
rt_floattype: np.dtype = np.float64,
|
|
61
60
|
) -> Tuple[
|
|
62
61
|
NDArray,
|
|
63
62
|
NDArray,
|
|
@@ -131,20 +130,18 @@ def cleanregressor(
|
|
|
131
130
|
If True, display plots during processing. Default is False.
|
|
132
131
|
debug : bool, optional
|
|
133
132
|
If True, print debugging information. Default is False.
|
|
134
|
-
rt_floattype :
|
|
135
|
-
|
|
136
|
-
rt_floatset : Any, optional
|
|
137
|
-
Float type setting for real-time processing. Default is np.float64.
|
|
133
|
+
rt_floattype : np.dtype, optional
|
|
134
|
+
Float type setting for rapidtide processing. Default is np.float64.
|
|
138
135
|
|
|
139
136
|
Returns
|
|
140
137
|
-------
|
|
141
138
|
tuple
|
|
142
139
|
A tuple containing:
|
|
143
|
-
- cleaned_resampref_y :
|
|
140
|
+
- cleaned_resampref_y : NDArray
|
|
144
141
|
Cleaned resampled reference signal.
|
|
145
|
-
- cleaned_referencetc :
|
|
142
|
+
- cleaned_referencetc : NDArray
|
|
146
143
|
Cleaned reference time course.
|
|
147
|
-
- cleaned_nonosreferencetc :
|
|
144
|
+
- cleaned_nonosreferencetc : NDArray
|
|
148
145
|
Cleaned non-oversampled reference signal.
|
|
149
146
|
- despeckle_thresh : float
|
|
150
147
|
Updated despeckle threshold.
|
|
@@ -214,7 +211,6 @@ def cleanregressor(
|
|
|
214
211
|
print(f"\t{check_autocorrelation=}")
|
|
215
212
|
print(f"\t{displayplots=}")
|
|
216
213
|
print(f"\t{rt_floattype=}")
|
|
217
|
-
print(f"\t{rt_floatset=}")
|
|
218
214
|
|
|
219
215
|
# check the regressor for periodic components in the passband
|
|
220
216
|
dolagmod = True
|
|
@@ -262,7 +258,6 @@ def cleanregressor(
|
|
|
262
258
|
despeckle_thresh=despeckle_thresh,
|
|
263
259
|
lthreshval=lthreshval,
|
|
264
260
|
fixdelay=fixdelay,
|
|
265
|
-
rt_floatset=rt_floatset,
|
|
266
261
|
rt_floattype=rt_floattype,
|
|
267
262
|
)
|
|
268
263
|
tide_io.writebidstsv(
|
rapidtide/workflows/delayvar.py
CHANGED
|
@@ -30,7 +30,6 @@ import numpy as np
|
|
|
30
30
|
from numpy.typing import NDArray
|
|
31
31
|
from scipy.stats import pearsonr
|
|
32
32
|
from sklearn.decomposition import PCA
|
|
33
|
-
from tf_keras.src.dtensor.integration_test_utils import train_step
|
|
34
33
|
|
|
35
34
|
import rapidtide.filter as tide_filt
|
|
36
35
|
import rapidtide.io as tide_io
|
|
@@ -483,19 +482,15 @@ def delayvar(args: Any) -> None:
|
|
|
483
482
|
sys.exit()
|
|
484
483
|
|
|
485
484
|
if therunoptions["internalprecision"] == "double":
|
|
486
|
-
rt_floattype =
|
|
487
|
-
rt_floatset = np.float64
|
|
485
|
+
rt_floattype = np.float64
|
|
488
486
|
else:
|
|
489
|
-
rt_floattype =
|
|
490
|
-
rt_floatset = np.float32
|
|
487
|
+
rt_floattype = np.float32
|
|
491
488
|
|
|
492
489
|
# set the output precision
|
|
493
490
|
if therunoptions["outputprecision"] == "double":
|
|
494
|
-
rt_outfloattype =
|
|
495
|
-
rt_outfloatset = np.float64
|
|
491
|
+
rt_outfloattype = np.float64
|
|
496
492
|
else:
|
|
497
|
-
rt_outfloattype =
|
|
498
|
-
rt_outfloatset = np.float32
|
|
493
|
+
rt_outfloattype = np.float32
|
|
499
494
|
therunoptions["saveminimumsLFOfiltfiles"] = args.saveminimumsLFOfiltfiles
|
|
500
495
|
|
|
501
496
|
# read the fmri input files
|
|
@@ -960,7 +955,7 @@ def delayvar(args: Any) -> None:
|
|
|
960
955
|
# pcadata = np.mean(reduceddata, axis=0)
|
|
961
956
|
pcadata = thefit.components_[0]
|
|
962
957
|
averagedata = np.mean(windoweddelayoffset, axis=0)
|
|
963
|
-
thepxcorr = pearsonr(averagedata, pcadata)
|
|
958
|
+
thepxcorr = pearsonr(averagedata, pcadata).statistic
|
|
964
959
|
LGR.info(f"pca/avg correlation = {thepxcorr}")
|
|
965
960
|
if thepxcorr > 0.0:
|
|
966
961
|
systemiccomp = 1.0 * pcadata
|
|
@@ -1102,21 +1097,21 @@ def delayvar(args: Any) -> None:
|
|
|
1102
1097
|
"systemicsLFOfitmean",
|
|
1103
1098
|
"info",
|
|
1104
1099
|
None,
|
|
1105
|
-
|
|
1100
|
+
"Constant coefficient for systemic filter",
|
|
1106
1101
|
),
|
|
1107
1102
|
(
|
|
1108
1103
|
systemicfitcoeff[:, 0],
|
|
1109
1104
|
"systemiccoffEV0",
|
|
1110
1105
|
"info",
|
|
1111
1106
|
None,
|
|
1112
|
-
|
|
1107
|
+
"Coefficient 0 for systemic filter",
|
|
1113
1108
|
),
|
|
1114
1109
|
(
|
|
1115
1110
|
systemicfitcoeff[:, 1],
|
|
1116
1111
|
"systemiccoffEV1",
|
|
1117
1112
|
"info",
|
|
1118
1113
|
None,
|
|
1119
|
-
|
|
1114
|
+
"Coefficient 1 for systemic filter",
|
|
1120
1115
|
),
|
|
1121
1116
|
]
|
|
1122
1117
|
if reduceddata is not None:
|
|
@@ -70,8 +70,7 @@ def fitSimFunc(
|
|
|
70
70
|
TimingLGR: Any,
|
|
71
71
|
simplefit: bool = False,
|
|
72
72
|
upsampfac: int = 8,
|
|
73
|
-
|
|
74
|
-
rt_floattype: str = "float64",
|
|
73
|
+
rt_floattype: np.dtype = np.float64,
|
|
75
74
|
) -> NDArray | None:
|
|
76
75
|
"""
|
|
77
76
|
Perform similarity function fitting and time lag estimation for fMRI data.
|
|
@@ -160,10 +159,8 @@ def fitSimFunc(
|
|
|
160
159
|
If True, perform simple fitting using upsampling. Default is False.
|
|
161
160
|
upsampfac : int, optional
|
|
162
161
|
Upsampling factor for simple fitting. Default is 8.
|
|
163
|
-
|
|
162
|
+
rt_floattype : np.dtype, optional
|
|
164
163
|
Real-time floating-point data type. Default is np.float64.
|
|
165
|
-
rt_floattype : str, optional
|
|
166
|
-
Real-time floating-point type as string. Default is "float64".
|
|
167
164
|
|
|
168
165
|
Returns
|
|
169
166
|
-------
|
|
@@ -218,7 +215,6 @@ def fitSimFunc(
|
|
|
218
215
|
... TimingLGR,
|
|
219
216
|
... simplefit=False,
|
|
220
217
|
... upsampfac=8,
|
|
221
|
-
... rt_floatset=np.float64,
|
|
222
218
|
... rt_floattype="float64",
|
|
223
219
|
... )
|
|
224
220
|
"""
|
|
@@ -243,7 +239,6 @@ def fitSimFunc(
|
|
|
243
239
|
interptype=optiondict["interptype"],
|
|
244
240
|
showprogressbar=optiondict["showprogressbar"],
|
|
245
241
|
chunksize=optiondict["mp_chunksize"],
|
|
246
|
-
rt_floatset=rt_floatset,
|
|
247
242
|
rt_floattype=rt_floattype,
|
|
248
243
|
)
|
|
249
244
|
tide_util.enablemkl(optiondict["mklthreads"], debug=optiondict["threaddebug"])
|
|
@@ -318,7 +313,6 @@ def fitSimFunc(
|
|
|
318
313
|
chunksize=optiondict["mp_chunksize"],
|
|
319
314
|
despeckle_thresh=optiondict["despeckle_thresh"],
|
|
320
315
|
initiallags=initlags,
|
|
321
|
-
rt_floatset=rt_floatset,
|
|
322
316
|
rt_floattype=rt_floattype,
|
|
323
317
|
)
|
|
324
318
|
tide_util.enablemkl(optiondict["mklthreads"], debug=optiondict["threaddebug"])
|
|
@@ -386,7 +380,6 @@ def fitSimFunc(
|
|
|
386
380
|
chunksize=optiondict["mp_chunksize"],
|
|
387
381
|
despeckle_thresh=optiondict["despeckle_thresh"],
|
|
388
382
|
initiallags=initlags,
|
|
389
|
-
rt_floatset=rt_floatset,
|
|
390
383
|
rt_floattype=rt_floattype,
|
|
391
384
|
)
|
|
392
385
|
tide_util.enablemkl(
|
rapidtide/workflows/happy.py
CHANGED
|
@@ -66,17 +66,17 @@ def happy_main(argparsingfunc: Any) -> None:
|
|
|
66
66
|
Command line arguments containing processing options
|
|
67
67
|
infodict : dict
|
|
68
68
|
Dictionary containing processing information including shared memory settings
|
|
69
|
-
fmri_data :
|
|
69
|
+
fmri_data : NDArray
|
|
70
70
|
4D fMRI data array (x, y, z, time)
|
|
71
|
-
mask :
|
|
71
|
+
mask : NDArray
|
|
72
72
|
3D mask array indicating valid voxels
|
|
73
|
-
projmask_byslice :
|
|
73
|
+
projmask_byslice : NDArray
|
|
74
74
|
2D mask array for each slice indicating valid projection locations
|
|
75
|
-
cardphasevals :
|
|
75
|
+
cardphasevals : NDArray
|
|
76
76
|
2D array of cardiac phase values for each slice and timepoint
|
|
77
|
-
rawapp_byslice :
|
|
77
|
+
rawapp_byslice : NDArray
|
|
78
78
|
3D array of raw cardiac signals for each slice and timepoint
|
|
79
|
-
outphases :
|
|
79
|
+
outphases : NDArray
|
|
80
80
|
Array of cardiac phases
|
|
81
81
|
timepoints : int
|
|
82
82
|
Number of timepoints in the fMRI data
|