rapidtide 3.0.11__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/Colortables.py +492 -27
- rapidtide/OrthoImageItem.py +1049 -46
- rapidtide/RapidtideDataset.py +1533 -86
- rapidtide/_version.py +3 -3
- rapidtide/calccoherence.py +196 -29
- rapidtide/calcnullsimfunc.py +188 -40
- rapidtide/calcsimfunc.py +242 -42
- rapidtide/correlate.py +1203 -383
- rapidtide/data/examples/src/testLD +56 -0
- rapidtide/data/examples/src/testalign +1 -1
- rapidtide/data/examples/src/testdelayvar +0 -1
- rapidtide/data/examples/src/testfmri +53 -3
- rapidtide/data/examples/src/testglmfilt +5 -5
- rapidtide/data/examples/src/testhappy +29 -7
- rapidtide/data/examples/src/testppgproc +17 -0
- rapidtide/data/examples/src/testrolloff +11 -0
- rapidtide/data/models/model_cnn_pytorch/best_model.pth +0 -0
- rapidtide/data/models/model_cnn_pytorch/loss.png +0 -0
- rapidtide/data/models/model_cnn_pytorch/loss.txt +1 -0
- rapidtide/data/models/model_cnn_pytorch/model.pth +0 -0
- rapidtide/data/models/model_cnn_pytorch/model_meta.json +68 -0
- rapidtide/decorators.py +91 -0
- rapidtide/dlfilter.py +2226 -110
- rapidtide/dlfiltertorch.py +4842 -0
- rapidtide/externaltools.py +327 -12
- rapidtide/fMRIData_class.py +79 -40
- rapidtide/filter.py +1899 -810
- rapidtide/fit.py +2011 -581
- rapidtide/genericmultiproc.py +93 -18
- rapidtide/happy_supportfuncs.py +2047 -172
- rapidtide/helper_classes.py +584 -43
- rapidtide/io.py +2370 -372
- rapidtide/linfitfiltpass.py +346 -99
- rapidtide/makelaggedtcs.py +210 -24
- rapidtide/maskutil.py +448 -62
- rapidtide/miscmath.py +827 -121
- rapidtide/multiproc.py +210 -22
- rapidtide/patchmatch.py +242 -42
- rapidtide/peakeval.py +31 -31
- rapidtide/ppgproc.py +2203 -0
- rapidtide/qualitycheck.py +352 -39
- rapidtide/refinedelay.py +431 -57
- rapidtide/refineregressor.py +494 -189
- rapidtide/resample.py +671 -185
- rapidtide/scripts/applyppgproc.py +28 -0
- rapidtide/scripts/showxcorr_legacy.py +7 -7
- rapidtide/scripts/stupidramtricks.py +15 -17
- rapidtide/simFuncClasses.py +1052 -77
- rapidtide/simfuncfit.py +269 -69
- rapidtide/stats.py +540 -238
- rapidtide/tests/happycomp +9 -0
- rapidtide/tests/test_cleanregressor.py +1 -2
- rapidtide/tests/test_dlfiltertorch.py +627 -0
- rapidtide/tests/test_findmaxlag.py +24 -8
- rapidtide/tests/test_fullrunhappy_v1.py +0 -2
- rapidtide/tests/test_fullrunhappy_v2.py +0 -2
- rapidtide/tests/test_fullrunhappy_v3.py +11 -4
- rapidtide/tests/test_fullrunhappy_v4.py +10 -2
- rapidtide/tests/test_fullrunrapidtide_v7.py +1 -1
- rapidtide/tests/test_getparsers.py +11 -3
- rapidtide/tests/test_refinedelay.py +0 -1
- rapidtide/tests/test_simroundtrip.py +16 -8
- rapidtide/tests/test_stcorrelate.py +3 -1
- rapidtide/tests/utils.py +9 -8
- rapidtide/tidepoolTemplate.py +142 -38
- rapidtide/tidepoolTemplate_alt.py +165 -44
- rapidtide/tidepoolTemplate_big.py +189 -52
- rapidtide/util.py +1217 -118
- rapidtide/voxelData.py +684 -37
- rapidtide/wiener.py +136 -23
- rapidtide/wiener2.py +113 -7
- rapidtide/workflows/adjustoffset.py +105 -3
- rapidtide/workflows/aligntcs.py +85 -2
- rapidtide/workflows/applydlfilter.py +87 -10
- rapidtide/workflows/applyppgproc.py +540 -0
- rapidtide/workflows/atlasaverage.py +210 -47
- rapidtide/workflows/atlastool.py +100 -3
- rapidtide/workflows/calcSimFuncMap.py +288 -69
- rapidtide/workflows/calctexticc.py +201 -9
- rapidtide/workflows/ccorrica.py +101 -6
- rapidtide/workflows/cleanregressor.py +165 -31
- rapidtide/workflows/delayvar.py +171 -23
- rapidtide/workflows/diffrois.py +81 -3
- rapidtide/workflows/endtidalproc.py +144 -4
- rapidtide/workflows/fdica.py +195 -15
- rapidtide/workflows/filtnifti.py +70 -3
- rapidtide/workflows/filttc.py +74 -3
- rapidtide/workflows/fitSimFuncMap.py +202 -51
- rapidtide/workflows/fixtr.py +73 -3
- rapidtide/workflows/gmscalc.py +113 -3
- rapidtide/workflows/happy.py +801 -199
- rapidtide/workflows/happy2std.py +144 -12
- rapidtide/workflows/happy_parser.py +163 -23
- rapidtide/workflows/histnifti.py +118 -2
- rapidtide/workflows/histtc.py +84 -3
- rapidtide/workflows/linfitfilt.py +117 -4
- rapidtide/workflows/localflow.py +328 -28
- rapidtide/workflows/mergequality.py +79 -3
- rapidtide/workflows/niftidecomp.py +322 -18
- rapidtide/workflows/niftistats.py +174 -4
- rapidtide/workflows/pairproc.py +98 -4
- rapidtide/workflows/pairwisemergenifti.py +85 -2
- rapidtide/workflows/parser_funcs.py +1421 -40
- rapidtide/workflows/physiofreq.py +137 -11
- rapidtide/workflows/pixelcomp.py +207 -5
- rapidtide/workflows/plethquality.py +103 -21
- rapidtide/workflows/polyfitim.py +151 -11
- rapidtide/workflows/proj2flow.py +75 -2
- rapidtide/workflows/rankimage.py +111 -4
- rapidtide/workflows/rapidtide.py +368 -76
- rapidtide/workflows/rapidtide2std.py +98 -2
- rapidtide/workflows/rapidtide_parser.py +109 -9
- rapidtide/workflows/refineDelayMap.py +144 -33
- rapidtide/workflows/refineRegressor.py +675 -96
- rapidtide/workflows/regressfrommaps.py +161 -37
- rapidtide/workflows/resamplenifti.py +85 -3
- rapidtide/workflows/resampletc.py +91 -3
- rapidtide/workflows/retrolagtcs.py +99 -9
- rapidtide/workflows/retroregress.py +176 -26
- rapidtide/workflows/roisummarize.py +174 -5
- rapidtide/workflows/runqualitycheck.py +71 -3
- rapidtide/workflows/showarbcorr.py +149 -6
- rapidtide/workflows/showhist.py +86 -2
- rapidtide/workflows/showstxcorr.py +160 -3
- rapidtide/workflows/showtc.py +159 -3
- rapidtide/workflows/showxcorrx.py +190 -10
- rapidtide/workflows/showxy.py +185 -15
- rapidtide/workflows/simdata.py +264 -38
- rapidtide/workflows/spatialfit.py +77 -2
- rapidtide/workflows/spatialmi.py +250 -27
- rapidtide/workflows/spectrogram.py +305 -32
- rapidtide/workflows/synthASL.py +154 -3
- rapidtide/workflows/tcfrom2col.py +76 -2
- rapidtide/workflows/tcfrom3col.py +74 -2
- rapidtide/workflows/tidepool.py +2971 -130
- rapidtide/workflows/utils.py +19 -14
- rapidtide/workflows/utils_doc.py +293 -0
- rapidtide/workflows/variabilityizer.py +116 -3
- {rapidtide-3.0.11.dist-info → rapidtide-3.1.1.dist-info}/METADATA +10 -8
- {rapidtide-3.0.11.dist-info → rapidtide-3.1.1.dist-info}/RECORD +144 -128
- {rapidtide-3.0.11.dist-info → rapidtide-3.1.1.dist-info}/entry_points.txt +1 -0
- {rapidtide-3.0.11.dist-info → rapidtide-3.1.1.dist-info}/WHEEL +0 -0
- {rapidtide-3.0.11.dist-info → rapidtide-3.1.1.dist-info}/licenses/LICENSE +0 -0
- {rapidtide-3.0.11.dist-info → rapidtide-3.1.1.dist-info}/top_level.txt +0 -0
rapidtide/workflows/rapidtide.py
CHANGED
|
@@ -23,8 +23,10 @@ import platform
|
|
|
23
23
|
import sys
|
|
24
24
|
import warnings
|
|
25
25
|
from pathlib import Path
|
|
26
|
+
from typing import Any, Tuple
|
|
26
27
|
|
|
27
28
|
import numpy as np
|
|
29
|
+
from numpy.typing import NDArray
|
|
28
30
|
from scipy.stats import rankdata
|
|
29
31
|
|
|
30
32
|
import rapidtide.calccoherence as tide_calccoherence
|
|
@@ -65,8 +67,40 @@ LGR = logging.getLogger("GENERAL")
|
|
|
65
67
|
ErrorLGR = logging.getLogger("ERROR")
|
|
66
68
|
TimingLGR = logging.getLogger("TIMING")
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
global rt_floattype
|
|
71
|
+
rt_floattype: np.dtype = np.float64
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def checkforzeromean(thedataset: Any) -> bool:
|
|
75
|
+
"""
|
|
76
|
+
Check if the mean of dataset is zero.
|
|
77
|
+
|
|
78
|
+
Parameters
|
|
79
|
+
----------
|
|
80
|
+
thedataset : array-like
|
|
81
|
+
Input dataset to check for zero mean. Should be array-like structure
|
|
82
|
+
that can be processed by numpy mean and std functions.
|
|
83
|
+
|
|
84
|
+
Returns
|
|
85
|
+
-------
|
|
86
|
+
bool
|
|
87
|
+
True if the mean of standard deviations is greater than the mean of means,
|
|
88
|
+
False otherwise.
|
|
89
|
+
|
|
90
|
+
Notes
|
|
91
|
+
-----
|
|
92
|
+
This function calculates the mean and standard deviation along axis 1,
|
|
93
|
+
then compares the means of these two arrays. The function name suggests
|
|
94
|
+
checking for zero mean, but the implementation actually compares means
|
|
95
|
+
and standard deviations rather than directly checking if mean equals zero.
|
|
96
|
+
|
|
97
|
+
Examples
|
|
98
|
+
--------
|
|
99
|
+
>>> import numpy as np
|
|
100
|
+
>>> data = np.array([[1, 2, 3], [4, 5, 6]])
|
|
101
|
+
>>> checkforzeromean(data)
|
|
102
|
+
False
|
|
103
|
+
"""
|
|
70
104
|
themean = np.mean(thedataset, axis=1)
|
|
71
105
|
thestd = np.std(thedataset, axis=1)
|
|
72
106
|
if np.mean(thestd) > np.mean(themean):
|
|
@@ -75,7 +109,59 @@ def checkforzeromean(thedataset):
|
|
|
75
109
|
return False
|
|
76
110
|
|
|
77
111
|
|
|
78
|
-
def echocancel(
|
|
112
|
+
def echocancel(
|
|
113
|
+
thetimecourse: Any, echooffset: Any, thetimestep: Any, outputname: Any, padtimepoints: Any
|
|
114
|
+
) -> Tuple[NDArray, NDArray, float]:
|
|
115
|
+
"""
|
|
116
|
+
Perform echo cancellation on a timecourse using linear regression.
|
|
117
|
+
|
|
118
|
+
This function applies echo cancellation to a given timecourse by modeling the echo signal
|
|
119
|
+
and subtracting its contribution from the original signal. The echo is shifted in time
|
|
120
|
+
according to `echooffset` and then fitted using maximum likelihood regression. The
|
|
121
|
+
resulting filtered timecourse is saved along with the original and echo components.
|
|
122
|
+
|
|
123
|
+
Parameters
|
|
124
|
+
----------
|
|
125
|
+
thetimecourse : array-like
|
|
126
|
+
The input timecourse data to be processed.
|
|
127
|
+
echooffset : float
|
|
128
|
+
The time offset (in seconds) of the echo signal relative to the input timecourse.
|
|
129
|
+
thetimestep : float
|
|
130
|
+
The time step (in seconds) of the input timecourse.
|
|
131
|
+
outputname : str
|
|
132
|
+
Base name for output files; used to construct filenames for saved results.
|
|
133
|
+
padtimepoints : int
|
|
134
|
+
Number of timepoints to pad during resampling of the echo signal.
|
|
135
|
+
|
|
136
|
+
Returns
|
|
137
|
+
-------
|
|
138
|
+
tuple
|
|
139
|
+
A tuple containing:
|
|
140
|
+
- `outputtimecourse`: The timecourse after echo cancellation.
|
|
141
|
+
- `echofit`: The regression coefficients from fitting the echo signal.
|
|
142
|
+
- `echoR2`: The R-squared value of the echo fit.
|
|
143
|
+
|
|
144
|
+
Notes
|
|
145
|
+
-----
|
|
146
|
+
- The function writes three separate TSV files:
|
|
147
|
+
1. Original timecourse.
|
|
148
|
+
2. Echo signal.
|
|
149
|
+
3. Filtered (echo-cancelled) timecourse.
|
|
150
|
+
- The echo signal is shifted in time using `tide_resample.timeshift`.
|
|
151
|
+
- The echo is zeroed out at the beginning up to the computed shift.
|
|
152
|
+
- The function uses `tide_fit.mlregress` for linear regression fitting.
|
|
153
|
+
|
|
154
|
+
Examples
|
|
155
|
+
--------
|
|
156
|
+
>>> import numpy as np
|
|
157
|
+
>>> timecourse = np.random.rand(100)
|
|
158
|
+
>>> echo_offset = 2.0
|
|
159
|
+
>>> time_step = 1.0
|
|
160
|
+
>>> output_name = "test_output"
|
|
161
|
+
>>> pad_points = 10
|
|
162
|
+
>>> result = echocancel(timecourse, echo_offset, time_step, output_name, pad_points)
|
|
163
|
+
>>> filtered_tc, fit_coeffs, r2 = result
|
|
164
|
+
"""
|
|
79
165
|
tide_io.writebidstsv(
|
|
80
166
|
f"{outputname}_desc-echocancellation_timeseries",
|
|
81
167
|
thetimecourse,
|
|
@@ -114,12 +200,84 @@ def echocancel(thetimecourse, echooffset, thetimestep, outputname, padtimepoints
|
|
|
114
200
|
)
|
|
115
201
|
return outputtimecourse, echofit, echoR2
|
|
116
202
|
|
|
117
|
-
|
|
203
|
+
|
|
204
|
+
def setpassoptions(passdict: Any, optiondict: Any) -> None:
|
|
205
|
+
"""
|
|
206
|
+
Copy key-value pairs from passdict to optiondict.
|
|
207
|
+
|
|
208
|
+
This function updates the optiondict with key-value pairs from passdict,
|
|
209
|
+
effectively passing options from one dictionary to another.
|
|
210
|
+
|
|
211
|
+
Parameters
|
|
212
|
+
----------
|
|
213
|
+
passdict : Any
|
|
214
|
+
Dictionary containing options to be passed
|
|
215
|
+
optiondict : Any
|
|
216
|
+
Dictionary that will receive the options from passdict
|
|
217
|
+
|
|
218
|
+
Returns
|
|
219
|
+
-------
|
|
220
|
+
None
|
|
221
|
+
This function modifies optiondict in-place and returns None
|
|
222
|
+
|
|
223
|
+
Notes
|
|
224
|
+
-----
|
|
225
|
+
This function performs an in-place update of optiondict. Any existing keys
|
|
226
|
+
in optiondict that are also present in passdict will be overwritten with
|
|
227
|
+
the values from passdict.
|
|
228
|
+
|
|
229
|
+
Examples
|
|
230
|
+
--------
|
|
231
|
+
>>> options = {'verbose': True, 'timeout': 30}
|
|
232
|
+
>>> new_options = {'debug': False}
|
|
233
|
+
>>> setpassoptions(options, new_options)
|
|
234
|
+
>>> print(new_options)
|
|
235
|
+
{'debug': False, 'verbose': True, 'timeout': 30}
|
|
236
|
+
"""
|
|
118
237
|
for key, value in passdict.items():
|
|
119
238
|
optiondict[key] = value
|
|
120
239
|
|
|
121
240
|
|
|
122
|
-
def rapidtide_main(argparsingfunc):
|
|
241
|
+
def rapidtide_main(argparsingfunc: Any) -> None:
|
|
242
|
+
"""
|
|
243
|
+
Process fMRI data to perform spatially localized signal-to-noise ratio (sLFO) analysis.
|
|
244
|
+
|
|
245
|
+
This function performs a comprehensive analysis of fMRI data including correlation
|
|
246
|
+
analysis, signal filtering, and various statistical computations to identify and
|
|
247
|
+
remove spatially localized noise components.
|
|
248
|
+
|
|
249
|
+
Parameters
|
|
250
|
+
----------
|
|
251
|
+
None
|
|
252
|
+
|
|
253
|
+
Returns
|
|
254
|
+
-------
|
|
255
|
+
None
|
|
256
|
+
The function performs in-place processing and saves results to files.
|
|
257
|
+
|
|
258
|
+
Notes
|
|
259
|
+
-----
|
|
260
|
+
This function is designed to be called as part of a larger pipeline for fMRI
|
|
261
|
+
preprocessing and analysis. It handles multiple stages including:
|
|
262
|
+
|
|
263
|
+
1. Data initialization and validation
|
|
264
|
+
2. Correlation analysis across spatial locations
|
|
265
|
+
3. Signal filtering and noise removal
|
|
266
|
+
4. Statistical computations and result saving
|
|
267
|
+
5. Timing and logging management
|
|
268
|
+
|
|
269
|
+
Examples
|
|
270
|
+
--------
|
|
271
|
+
>>> process_fmri_data()
|
|
272
|
+
# Processes fMRI data and saves results to output files
|
|
273
|
+
|
|
274
|
+
See Also
|
|
275
|
+
--------
|
|
276
|
+
tide_regressfrommaps : Performs regression analysis on fMRI data
|
|
277
|
+
tide_io : Handles input/output operations for fMRI data
|
|
278
|
+
tide_util : Utility functions for processing fMRI data
|
|
279
|
+
|
|
280
|
+
"""
|
|
123
281
|
optiondict, theprefilter = argparsingfunc
|
|
124
282
|
optiondict["threaddebug"] = False
|
|
125
283
|
|
|
@@ -179,7 +337,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
179
337
|
logger_filename=f"{outputname}_log.txt",
|
|
180
338
|
timing_filename=f"{outputname}_runtimings.tsv",
|
|
181
339
|
memory_filename=f"{outputname}_memusage.tsv",
|
|
182
|
-
|
|
340
|
+
isverbose=optiondict["verbose"],
|
|
183
341
|
debug=optiondict["debug"],
|
|
184
342
|
)
|
|
185
343
|
TimingLGR.info("Start")
|
|
@@ -211,25 +369,21 @@ def rapidtide_main(argparsingfunc):
|
|
|
211
369
|
tide_util.disablenumba()
|
|
212
370
|
|
|
213
371
|
# set the internal precision
|
|
214
|
-
global
|
|
372
|
+
global rt_floattype
|
|
215
373
|
if optiondict["internalprecision"] == "double":
|
|
216
374
|
LGR.debug("setting internal precision to double")
|
|
217
|
-
rt_floattype =
|
|
218
|
-
rt_floatset = np.float64
|
|
375
|
+
rt_floattype = np.float64
|
|
219
376
|
else:
|
|
220
377
|
LGR.debug("setting internal precision to single")
|
|
221
|
-
rt_floattype =
|
|
222
|
-
rt_floatset = np.float32
|
|
378
|
+
rt_floattype = np.float32
|
|
223
379
|
|
|
224
380
|
# set the output precision
|
|
225
381
|
if optiondict["outputprecision"] == "double":
|
|
226
382
|
LGR.debug("setting output precision to double")
|
|
227
|
-
rt_outfloattype =
|
|
228
|
-
rt_outfloatset = np.float64
|
|
383
|
+
rt_outfloattype = np.float64
|
|
229
384
|
else:
|
|
230
385
|
LGR.debug("setting output precision to single")
|
|
231
|
-
rt_outfloattype =
|
|
232
|
-
rt_outfloatset = np.float32
|
|
386
|
+
rt_outfloattype = np.float32
|
|
233
387
|
|
|
234
388
|
# set the number of worker processes if multiprocessing
|
|
235
389
|
if optiondict["nprocs"] < 1:
|
|
@@ -306,6 +460,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
306
460
|
if optiondict["oversampfactor"] < 0:
|
|
307
461
|
optiondict["oversampfactor"] = int(np.max([np.ceil(fmritr / 0.5), 1]))
|
|
308
462
|
LGR.debug(f"oversample factor set to {optiondict['oversampfactor']}")
|
|
463
|
+
# optiondict["prewhitenlags"] *= optiondict["oversampfactor"]
|
|
309
464
|
|
|
310
465
|
oversamptr = fmritr / optiondict["oversampfactor"]
|
|
311
466
|
LGR.verbose(f"fmri data: {timepoints} timepoints, tr = {fmritr}, oversamptr = {oversamptr}")
|
|
@@ -350,6 +505,13 @@ def rapidtide_main(argparsingfunc):
|
|
|
350
505
|
optiondict["osvalidsimcalcend"] = osvalidsimcalcend
|
|
351
506
|
optiondict["simcalcoffset"] = -validsimcalcstart * fmritr
|
|
352
507
|
|
|
508
|
+
####################################################
|
|
509
|
+
# Calculate initial stats
|
|
510
|
+
####################################################
|
|
511
|
+
init_min, init_max, init_mean, init_std, init_median, init_MAD, init_skew, init_kurtosis = (
|
|
512
|
+
tide_stats.fmristats(theinputdata.byvoxel())
|
|
513
|
+
)
|
|
514
|
+
|
|
353
515
|
####################################################
|
|
354
516
|
# Prepare data
|
|
355
517
|
####################################################
|
|
@@ -372,13 +534,13 @@ def rapidtide_main(argparsingfunc):
|
|
|
372
534
|
valslist=optiondict[thisanatomic[1]],
|
|
373
535
|
maskname=thisanatomic[2],
|
|
374
536
|
tolerance=optiondict["spatialtolerance"],
|
|
375
|
-
debug=optiondict["
|
|
537
|
+
debug=optiondict["debug"],
|
|
376
538
|
)
|
|
377
539
|
)
|
|
378
540
|
anatomicmasks[-1] = np.uint16(np.where(anatomicmasks[-1] > 0.1, 1, 0))
|
|
379
541
|
else:
|
|
380
|
-
anatomicmasks.append(
|
|
381
|
-
|
|
542
|
+
anatomicmasks.append(np.uint16(np.ones(nativespaceshape, dtype=np.uint16)))
|
|
543
|
+
|
|
382
544
|
brainmask = anatomicmasks[0]
|
|
383
545
|
graymask = anatomicmasks[1]
|
|
384
546
|
whitemask = anatomicmasks[2]
|
|
@@ -443,7 +605,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
443
605
|
numspatiallocs,
|
|
444
606
|
istext=(theinputdata.filetype == "text"),
|
|
445
607
|
tolerance=optiondict["spatialtolerance"],
|
|
446
|
-
debug=optiondict["
|
|
608
|
+
debug=optiondict["debug"],
|
|
447
609
|
)
|
|
448
610
|
)
|
|
449
611
|
if internalinvbrainmask is not None:
|
|
@@ -462,7 +624,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
462
624
|
numspatiallocs,
|
|
463
625
|
istext=(theinputdata.filetype == "text"),
|
|
464
626
|
tolerance=optiondict["spatialtolerance"],
|
|
465
|
-
debug=optiondict["
|
|
627
|
+
debug=optiondict["debug"],
|
|
466
628
|
)
|
|
467
629
|
if internalinvbrainmask is not None:
|
|
468
630
|
if internalrefineexcludemask is not None:
|
|
@@ -480,7 +642,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
480
642
|
numspatiallocs,
|
|
481
643
|
istext=(theinputdata.filetype == "text"),
|
|
482
644
|
tolerance=optiondict["spatialtolerance"],
|
|
483
|
-
debug=optiondict["
|
|
645
|
+
debug=optiondict["debug"],
|
|
484
646
|
)
|
|
485
647
|
if internalinvbrainmask is not None:
|
|
486
648
|
if internaloffsetexcludemask is not None:
|
|
@@ -502,7 +664,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
502
664
|
valslist=optiondict["corrmaskincludevals"],
|
|
503
665
|
maskname="correlation",
|
|
504
666
|
tolerance=optiondict["spatialtolerance"],
|
|
505
|
-
debug=optiondict["
|
|
667
|
+
debug=optiondict["debug"],
|
|
506
668
|
)
|
|
507
669
|
|
|
508
670
|
corrmask = np.uint16(np.where(thecorrmask > 0, 1, 0).reshape(numspatiallocs))
|
|
@@ -630,7 +792,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
630
792
|
LGR.info("moving fmri data to shared memory")
|
|
631
793
|
TimingLGR.verbose("Start moving fmri_data to shared memory")
|
|
632
794
|
fmri_data_valid, fmri_data_valid_shm = tide_util.numpy2shared(
|
|
633
|
-
fmri_data_valid,
|
|
795
|
+
fmri_data_valid, rt_floattype, name=f"fmri_data_valid_{optiondict['pid']}"
|
|
634
796
|
)
|
|
635
797
|
TimingLGR.verbose("End moving fmri_data to shared memory")
|
|
636
798
|
|
|
@@ -1100,7 +1262,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
1100
1262
|
padlen=int(inputfreq * optiondict["padseconds"]),
|
|
1101
1263
|
debug=optiondict["debug"],
|
|
1102
1264
|
)
|
|
1103
|
-
reference_y =
|
|
1265
|
+
reference_y = (reference_y_filt.real).astype(rt_floattype)
|
|
1104
1266
|
|
|
1105
1267
|
warnings.filterwarnings("ignore", "Casting*")
|
|
1106
1268
|
|
|
@@ -1161,11 +1323,11 @@ def rapidtide_main(argparsingfunc):
|
|
|
1161
1323
|
# save the factor used to normalize the input regressor
|
|
1162
1324
|
optiondict["initialmovingregressornormfac"] = np.std(resampnonosref_y)
|
|
1163
1325
|
|
|
1164
|
-
# prepare the temporal
|
|
1326
|
+
# prepare the temporal masks
|
|
1165
1327
|
if optiondict["tincludemaskname"] is not None:
|
|
1166
1328
|
print("creating temporal include mask")
|
|
1167
1329
|
includetmask_y = tide_mask.maketmask(
|
|
1168
|
-
optiondict["tincludemaskname"], reference_x,
|
|
1330
|
+
optiondict["tincludemaskname"], reference_x, reference_y.astype(rt_floattype) + 0.0
|
|
1169
1331
|
)
|
|
1170
1332
|
else:
|
|
1171
1333
|
includetmask_y = (reference_x * 0.0) + 1.0
|
|
@@ -1174,7 +1336,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
1174
1336
|
excludetmask_y = (
|
|
1175
1337
|
-1.0
|
|
1176
1338
|
* tide_mask.maketmask(
|
|
1177
|
-
optiondict["texcludemaskname"], reference_x,
|
|
1339
|
+
optiondict["texcludemaskname"], reference_x, reference_y.astype(rt_floattype) + 0.0
|
|
1178
1340
|
)
|
|
1179
1341
|
+ 1.0
|
|
1180
1342
|
)
|
|
@@ -1210,6 +1372,9 @@ def rapidtide_main(argparsingfunc):
|
|
|
1210
1372
|
else:
|
|
1211
1373
|
tmaskos_y = None
|
|
1212
1374
|
|
|
1375
|
+
# construct refine temporal masks here
|
|
1376
|
+
optiondict["windowedrefinemasks"] = None
|
|
1377
|
+
|
|
1213
1378
|
(
|
|
1214
1379
|
optiondict["kurtosis_reference_pass1"],
|
|
1215
1380
|
optiondict["kurtosisz_reference_pass1"],
|
|
@@ -1260,7 +1425,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
1260
1425
|
corrpadding=optiondict["corrpadding"],
|
|
1261
1426
|
debug=optiondict["debug"],
|
|
1262
1427
|
)
|
|
1263
|
-
if optiondict["
|
|
1428
|
+
if optiondict["debug"]:
|
|
1264
1429
|
print(
|
|
1265
1430
|
f"calling setreftc during initialization with length {optiondict['oversampfactor'] * validtimepoints}"
|
|
1266
1431
|
)
|
|
@@ -1384,7 +1549,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
1384
1549
|
fitmask = np.zeros(internalvalidspaceshape, dtype="uint16")
|
|
1385
1550
|
failreason = np.zeros(internalvalidspaceshape, dtype="uint32")
|
|
1386
1551
|
R2 = np.zeros(internalvalidspaceshape, dtype=rt_floattype)
|
|
1387
|
-
outmaparray = np.zeros(internalspaceshape, dtype=rt_floattype)
|
|
1552
|
+
outmaparray = np.zeros((internalspaceshape), dtype=rt_floattype)
|
|
1388
1553
|
tide_util.logmem("after main array allocation")
|
|
1389
1554
|
|
|
1390
1555
|
if optiondict["similaritymetric"] == "riptide":
|
|
@@ -1400,7 +1565,6 @@ def rapidtide_main(argparsingfunc):
|
|
|
1400
1565
|
chunksize=optiondict["mp_chunksize"],
|
|
1401
1566
|
nprocs=optiondict["nprocs"],
|
|
1402
1567
|
alwaysmultiproc=optiondict["alwaysmultiproc"],
|
|
1403
|
-
rt_floatset=rt_floatset,
|
|
1404
1568
|
rt_floattype=rt_floattype,
|
|
1405
1569
|
debug=optiondict["debug"],
|
|
1406
1570
|
)
|
|
@@ -1426,25 +1590,25 @@ def rapidtide_main(argparsingfunc):
|
|
|
1426
1590
|
|
|
1427
1591
|
corrout, corrout_shm = tide_util.allocarray(
|
|
1428
1592
|
internalvalidcorrshape,
|
|
1429
|
-
|
|
1593
|
+
rt_floattype,
|
|
1430
1594
|
shared=optiondict["sharedmem"],
|
|
1431
1595
|
name=f"corrout_{optiondict['pid']}",
|
|
1432
1596
|
)
|
|
1433
1597
|
gaussout, gaussout_shm = tide_util.allocarray(
|
|
1434
1598
|
internalvalidcorrshape,
|
|
1435
|
-
|
|
1599
|
+
rt_floattype,
|
|
1436
1600
|
shared=optiondict["sharedmem"],
|
|
1437
1601
|
name=f"gaussout_{optiondict['pid']}",
|
|
1438
1602
|
)
|
|
1439
1603
|
windowout, windowout_shm = tide_util.allocarray(
|
|
1440
1604
|
internalvalidcorrshape,
|
|
1441
|
-
|
|
1605
|
+
rt_floattype,
|
|
1442
1606
|
shared=optiondict["sharedmem"],
|
|
1443
1607
|
name=f"windowout_{optiondict['pid']}",
|
|
1444
1608
|
)
|
|
1445
1609
|
outcorrarray, outcorrarray_shm = tide_util.allocarray(
|
|
1446
1610
|
internalcorrshape,
|
|
1447
|
-
|
|
1611
|
+
rt_floattype,
|
|
1448
1612
|
shared=optiondict["sharedmem"],
|
|
1449
1613
|
name=f"outcorrarray_{optiondict['pid']}",
|
|
1450
1614
|
)
|
|
@@ -1613,6 +1777,8 @@ def rapidtide_main(argparsingfunc):
|
|
|
1613
1777
|
tmask_y=tmask_y,
|
|
1614
1778
|
tmaskos_y=tmaskos_y,
|
|
1615
1779
|
fastresamplerpadtime=optiondict["fastresamplerpadtime"],
|
|
1780
|
+
prewhitenregressor=False,
|
|
1781
|
+
prewhitenlags=optiondict["prewhitenlags"],
|
|
1616
1782
|
debug=optiondict["debug"],
|
|
1617
1783
|
)
|
|
1618
1784
|
|
|
@@ -1674,7 +1840,6 @@ def rapidtide_main(argparsingfunc):
|
|
|
1674
1840
|
interptype=optiondict["interptype"],
|
|
1675
1841
|
showprogressbar=optiondict["showprogressbar"],
|
|
1676
1842
|
chunksize=optiondict["mp_chunksize"],
|
|
1677
|
-
rt_floatset=rt_floatset,
|
|
1678
1843
|
rt_floattype=rt_floattype,
|
|
1679
1844
|
)
|
|
1680
1845
|
tide_util.enablemkl(optiondict["mklthreads"], debug=optiondict["threaddebug"])
|
|
@@ -1713,6 +1878,32 @@ def rapidtide_main(argparsingfunc):
|
|
|
1713
1878
|
"message3": "voxels",
|
|
1714
1879
|
},
|
|
1715
1880
|
)
|
|
1881
|
+
tide_io.writebidstsv(
|
|
1882
|
+
f"{outputname}_desc-oversampledmovingregressor_timeseries",
|
|
1883
|
+
tide_math.stdnormalize(resampref_y),
|
|
1884
|
+
oversampfreq,
|
|
1885
|
+
columns=["pass1_echocancel"],
|
|
1886
|
+
extraheaderinfo={
|
|
1887
|
+
"Description": "The probe regressor used in each pass, at the time resolution used for calculating the similarity function"
|
|
1888
|
+
},
|
|
1889
|
+
append=True,
|
|
1890
|
+
)
|
|
1891
|
+
|
|
1892
|
+
# Preprocessing - prewhitening
|
|
1893
|
+
if optiondict["prewhitenregressor"]:
|
|
1894
|
+
resampref_y = tide_fit.prewhiten(
|
|
1895
|
+
resampref_y, optiondict["prewhitenlags"], debug=optiondict["debug"]
|
|
1896
|
+
)
|
|
1897
|
+
tide_io.writebidstsv(
|
|
1898
|
+
f"{outputname}_desc-oversampledmovingregressor_timeseries",
|
|
1899
|
+
tide_math.stdnormalize(resampref_y),
|
|
1900
|
+
oversampfreq,
|
|
1901
|
+
columns=["pass1_prewhiten"],
|
|
1902
|
+
extraheaderinfo={
|
|
1903
|
+
"Description": "The probe regressor used in each pass, at the time resolution used for calculating the similarity function"
|
|
1904
|
+
},
|
|
1905
|
+
append=True,
|
|
1906
|
+
)
|
|
1716
1907
|
|
|
1717
1908
|
# --------------------- Main pass loop ---------------------
|
|
1718
1909
|
# loop over all passes
|
|
@@ -1801,9 +1992,8 @@ def rapidtide_main(argparsingfunc):
|
|
|
1801
1992
|
respdelete=optiondict["respdelete"],
|
|
1802
1993
|
debug=optiondict["debug"],
|
|
1803
1994
|
rt_floattype=rt_floattype,
|
|
1804
|
-
rt_floatset=rt_floatset,
|
|
1805
1995
|
)
|
|
1806
|
-
if optiondict["
|
|
1996
|
+
if optiondict["debug"]:
|
|
1807
1997
|
print(
|
|
1808
1998
|
f"after cleanregressor: {len(referencetc)=}, {len(cleaned_referencetc)=}, {osvalidsimcalcstart=}, {osvalidsimcalcend=}, {lagmininpts=}, {lagmaxinpts=}"
|
|
1809
1999
|
)
|
|
@@ -1827,7 +2017,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
1827
2017
|
f"{outputname}_options_pregetnull_pass" + str(thepass) + ".json",
|
|
1828
2018
|
)
|
|
1829
2019
|
theCorrelator.setlimits(lagmininpts, lagmaxinpts)
|
|
1830
|
-
if optiondict["
|
|
2020
|
+
if optiondict["debug"]:
|
|
1831
2021
|
print(
|
|
1832
2022
|
f"calling setreftc prior to significance estimation with length {len(cleaned_resampref_y)}"
|
|
1833
2023
|
)
|
|
@@ -1854,8 +2044,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
1854
2044
|
showprogressbar=optiondict["showprogressbar"],
|
|
1855
2045
|
chunksize=optiondict["mp_chunksize"],
|
|
1856
2046
|
permutationmethod=optiondict["permutationmethod"],
|
|
1857
|
-
|
|
1858
|
-
rt_floattype="float64",
|
|
2047
|
+
rt_floattype=np.float64,
|
|
1859
2048
|
)
|
|
1860
2049
|
tide_util.enablemkl(optiondict["mklthreads"], debug=optiondict["threaddebug"])
|
|
1861
2050
|
|
|
@@ -1999,10 +2188,9 @@ def rapidtide_main(argparsingfunc):
|
|
|
1999
2188
|
interptype=optiondict["interptype"],
|
|
2000
2189
|
showprogressbar=optiondict["showprogressbar"],
|
|
2001
2190
|
chunksize=optiondict["mp_chunksize"],
|
|
2002
|
-
rt_floatset=rt_floatset,
|
|
2003
2191
|
rt_floattype=rt_floattype,
|
|
2004
2192
|
threaddebug=optiondict["threaddebug"],
|
|
2005
|
-
debug=optiondict["
|
|
2193
|
+
debug=optiondict["debug"],
|
|
2006
2194
|
)
|
|
2007
2195
|
if optiondict["similaritymetric"] == "riptide":
|
|
2008
2196
|
optiondict["despeckle_passes"] = 0
|
|
@@ -2069,8 +2257,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
2069
2257
|
LGR,
|
|
2070
2258
|
TimingLGR,
|
|
2071
2259
|
simplefit=(optiondict["similaritymetric"] == "riptide"),
|
|
2072
|
-
|
|
2073
|
-
rt_floattype="float64",
|
|
2260
|
+
rt_floattype=np.float64,
|
|
2074
2261
|
)
|
|
2075
2262
|
|
|
2076
2263
|
# Step 2b - refine delay (optional)
|
|
@@ -2122,7 +2309,6 @@ def rapidtide_main(argparsingfunc):
|
|
|
2122
2309
|
maxdelay=optiondict["maxdelay"],
|
|
2123
2310
|
numpoints=optiondict["numpoints"],
|
|
2124
2311
|
histlen=optiondict["histlen"],
|
|
2125
|
-
rt_floatset=rt_floatset,
|
|
2126
2312
|
rt_floattype=rt_floattype,
|
|
2127
2313
|
debug=optiondict["debug"],
|
|
2128
2314
|
)
|
|
@@ -2147,7 +2333,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
2147
2333
|
cifti_hdr=theinputdata.cifti_hdr,
|
|
2148
2334
|
)
|
|
2149
2335
|
|
|
2150
|
-
# Step
|
|
2336
|
+
# Step 2c - make a rank order map
|
|
2151
2337
|
timepercentile = (
|
|
2152
2338
|
100.0 * (rankdata(lagtimes, method="dense") - 1) / (numvalidspatiallocs - 1)
|
|
2153
2339
|
)
|
|
@@ -2189,7 +2375,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
2189
2375
|
or optiondict["initregressorpreselect"]
|
|
2190
2376
|
or optiondict["dofinalrefine"]
|
|
2191
2377
|
):
|
|
2192
|
-
|
|
2378
|
+
resampref_y, resampnonosref_y, stoprefining, refinestopreason, genlagtc = (
|
|
2193
2379
|
tide_refineRegressor.refineRegressor(
|
|
2194
2380
|
LGR,
|
|
2195
2381
|
TimingLGR,
|
|
@@ -2216,8 +2402,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
2216
2402
|
outputname,
|
|
2217
2403
|
nativefmrishape,
|
|
2218
2404
|
bidsbasedict,
|
|
2219
|
-
|
|
2220
|
-
rt_floattype="float64",
|
|
2405
|
+
rt_floattype=np.float64,
|
|
2221
2406
|
)
|
|
2222
2407
|
)
|
|
2223
2408
|
# End of main pass loop
|
|
@@ -2284,19 +2469,19 @@ def rapidtide_main(argparsingfunc):
|
|
|
2284
2469
|
# now allocate the arrays needed for the coherence calculation
|
|
2285
2470
|
coherencefunc, coherencefunc_shm = tide_util.allocarray(
|
|
2286
2471
|
internalvalidcoherenceshape,
|
|
2287
|
-
|
|
2472
|
+
rt_outfloattype,
|
|
2288
2473
|
shared=optiondict["sharedmem"],
|
|
2289
2474
|
name=f"coherencefunc_{optiondict['pid']}",
|
|
2290
2475
|
)
|
|
2291
2476
|
coherencepeakval, coherencepeakval_shm = tide_util.allocarray(
|
|
2292
2477
|
numvalidspatiallocs,
|
|
2293
|
-
|
|
2478
|
+
rt_outfloattype,
|
|
2294
2479
|
shared=optiondict["sharedmem"],
|
|
2295
2480
|
name=f"coherencepeakval_{optiondict['pid']}",
|
|
2296
2481
|
)
|
|
2297
2482
|
coherencepeakfreq, coherencepeakfreq_shm = tide_util.allocarray(
|
|
2298
2483
|
numvalidspatiallocs,
|
|
2299
|
-
|
|
2484
|
+
rt_outfloattype,
|
|
2300
2485
|
shared=optiondict["sharedmem"],
|
|
2301
2486
|
name=f"coherencepeakfreq_{optiondict['pid']}",
|
|
2302
2487
|
)
|
|
@@ -2360,13 +2545,13 @@ def rapidtide_main(argparsingfunc):
|
|
|
2360
2545
|
# now allocate the arrays needed for Wiener deconvolution
|
|
2361
2546
|
wienerdeconv, wienerdeconv_shm = tide_util.allocarray(
|
|
2362
2547
|
internalvalidspaceshape,
|
|
2363
|
-
|
|
2548
|
+
rt_outfloattype,
|
|
2364
2549
|
shared=optiondict["sharedmem"],
|
|
2365
2550
|
name=f"wienerdeconv_{optiondict['pid']}",
|
|
2366
2551
|
)
|
|
2367
2552
|
wpeak, wpeak_shm = tide_util.allocarray(
|
|
2368
2553
|
internalvalidspaceshape,
|
|
2369
|
-
|
|
2554
|
+
rt_outfloattype,
|
|
2370
2555
|
shared=optiondict["sharedmem"],
|
|
2371
2556
|
name=f"wpeak_{optiondict['pid']}",
|
|
2372
2557
|
)
|
|
@@ -2387,7 +2572,6 @@ def rapidtide_main(argparsingfunc):
|
|
|
2387
2572
|
wienerdeconv,
|
|
2388
2573
|
wpeak,
|
|
2389
2574
|
resampref_y,
|
|
2390
|
-
rt_floatset=rt_floatset,
|
|
2391
2575
|
rt_floattype=rt_floattype,
|
|
2392
2576
|
)
|
|
2393
2577
|
TimingLGR.info(
|
|
@@ -2450,7 +2634,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
2450
2634
|
|
|
2451
2635
|
if optiondict["docvrmap"]:
|
|
2452
2636
|
# percent normalize the fmri data
|
|
2453
|
-
LGR.info("
|
|
2637
|
+
LGR.info("normalizing data for CVR map")
|
|
2454
2638
|
themean = np.mean(fmri_data_valid, axis=1)
|
|
2455
2639
|
fmri_data_valid /= themean[:, None]
|
|
2456
2640
|
|
|
@@ -2471,7 +2655,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
2471
2655
|
TimingLGR.info("Start moving fmri_data to shared memory")
|
|
2472
2656
|
fmri_data_valid, fmri_data_valid_shm = tide_util.numpy2shared(
|
|
2473
2657
|
fmri_data_valid,
|
|
2474
|
-
|
|
2658
|
+
rt_floattype,
|
|
2475
2659
|
name=f"fmri_data_valid_regressionfilt_{optiondict['pid']}",
|
|
2476
2660
|
)
|
|
2477
2661
|
TimingLGR.info("End moving fmri_data to shared memory")
|
|
@@ -2587,11 +2771,56 @@ def rapidtide_main(argparsingfunc):
|
|
|
2587
2771
|
maxdelay=optiondict["maxdelay"],
|
|
2588
2772
|
numpoints=optiondict["numpoints"],
|
|
2589
2773
|
histlen=optiondict["histlen"],
|
|
2590
|
-
rt_floatset=rt_floatset,
|
|
2591
2774
|
rt_floattype=rt_floattype,
|
|
2592
2775
|
debug=optiondict["debug"],
|
|
2593
2776
|
)
|
|
2594
2777
|
lagtimesrefined = lagtimes + delayoffset
|
|
2778
|
+
|
|
2779
|
+
if optiondict["windowedrefinemasks"] is not None:
|
|
2780
|
+
windoweddelayoffsets = []
|
|
2781
|
+
for thetimemask in optiondict["windowedrefinemasks"]:
|
|
2782
|
+
(
|
|
2783
|
+
windoweddelayoffset,
|
|
2784
|
+
dummy,
|
|
2785
|
+
dummy,
|
|
2786
|
+
dummy,
|
|
2787
|
+
dummy,
|
|
2788
|
+
) = tide_refineDelayMap.refineDelay(
|
|
2789
|
+
fmri_data_valid,
|
|
2790
|
+
initial_fmri_x,
|
|
2791
|
+
xdim,
|
|
2792
|
+
ydim,
|
|
2793
|
+
slicethickness,
|
|
2794
|
+
sLFOfiltmask,
|
|
2795
|
+
genlagtc,
|
|
2796
|
+
oversamptr,
|
|
2797
|
+
sLFOfitmean,
|
|
2798
|
+
rvalue,
|
|
2799
|
+
r2value,
|
|
2800
|
+
fitNorm,
|
|
2801
|
+
fitcoeff,
|
|
2802
|
+
lagtc,
|
|
2803
|
+
outputname,
|
|
2804
|
+
validvoxels,
|
|
2805
|
+
nativespaceshape,
|
|
2806
|
+
theinputdata,
|
|
2807
|
+
lagtimes,
|
|
2808
|
+
optiondict,
|
|
2809
|
+
LGR,
|
|
2810
|
+
TimingLGR,
|
|
2811
|
+
outputlevel=optiondict["outputlevel"],
|
|
2812
|
+
gausssigma=optiondict["delayoffsetgausssigma"],
|
|
2813
|
+
patchthresh=optiondict["delaypatchthresh"],
|
|
2814
|
+
timemask=thetimemask,
|
|
2815
|
+
mindelay=optiondict["mindelay"],
|
|
2816
|
+
maxdelay=optiondict["maxdelay"],
|
|
2817
|
+
numpoints=optiondict["numpoints"],
|
|
2818
|
+
histlen=optiondict["histlen"],
|
|
2819
|
+
rt_floattype=rt_floattype,
|
|
2820
|
+
debug=optiondict["debug"],
|
|
2821
|
+
)
|
|
2822
|
+
windoweddelayoffsets.append(windoweddelayoffset)
|
|
2823
|
+
|
|
2595
2824
|
####################################################
|
|
2596
2825
|
# Delay refinement end
|
|
2597
2826
|
####################################################
|
|
@@ -2669,6 +2898,12 @@ def rapidtide_main(argparsingfunc):
|
|
|
2669
2898
|
varchange = initialvariance * 0.0
|
|
2670
2899
|
varchange[divlocs] = 100.0 * (finalvariance[divlocs] / initialvariance[divlocs] - 1.0)
|
|
2671
2900
|
|
|
2901
|
+
# calculate the voxelwise mean of the filtered data
|
|
2902
|
+
lfofilteredmeanvalue = np.mean(
|
|
2903
|
+
filtereddata,
|
|
2904
|
+
axis=1,
|
|
2905
|
+
)
|
|
2906
|
+
|
|
2672
2907
|
LGR.info("End filtering operation")
|
|
2673
2908
|
TimingLGR.info(
|
|
2674
2909
|
"sLFO filtering end",
|
|
@@ -2978,6 +3213,13 @@ def rapidtide_main(argparsingfunc):
|
|
|
2978
3213
|
"percent",
|
|
2979
3214
|
"Change in inband variance after filtering, in percent",
|
|
2980
3215
|
),
|
|
3216
|
+
# (
|
|
3217
|
+
# lfofilteredmeanvalue,
|
|
3218
|
+
# "lfofilterMean",
|
|
3219
|
+
# "map",
|
|
3220
|
+
# None,
|
|
3221
|
+
# "Voxelwise mean of the sLFO filtered data",
|
|
3222
|
+
# ),
|
|
2981
3223
|
]
|
|
2982
3224
|
if optiondict["saveminimumsLFOfiltfiles"]:
|
|
2983
3225
|
maplist += [
|
|
@@ -3039,6 +3281,59 @@ def rapidtide_main(argparsingfunc):
|
|
|
3039
3281
|
"Normalized fit coefficient",
|
|
3040
3282
|
),
|
|
3041
3283
|
]
|
|
3284
|
+
init_std_valid = init_std[validvoxels] + 0.0
|
|
3285
|
+
init_skew_valid = init_skew[validvoxels] + 0.0
|
|
3286
|
+
init_kurtosis_valid = init_kurtosis[validvoxels] + 0.0
|
|
3287
|
+
maplist += [
|
|
3288
|
+
(init_std_valid, "initialStd", "map", None, "Std of the raw input data"),
|
|
3289
|
+
(
|
|
3290
|
+
init_skew_valid,
|
|
3291
|
+
"initialSkewness",
|
|
3292
|
+
"map",
|
|
3293
|
+
None,
|
|
3294
|
+
"Skewness of the raw input data",
|
|
3295
|
+
),
|
|
3296
|
+
(
|
|
3297
|
+
init_kurtosis_valid,
|
|
3298
|
+
"initialKurtosis",
|
|
3299
|
+
"map",
|
|
3300
|
+
None,
|
|
3301
|
+
"Kurtosis of the raw input data",
|
|
3302
|
+
),
|
|
3303
|
+
]
|
|
3304
|
+
(
|
|
3305
|
+
final_min_valid,
|
|
3306
|
+
final_max_valid,
|
|
3307
|
+
final_mean_valid,
|
|
3308
|
+
final_std_valid,
|
|
3309
|
+
final_median_valid,
|
|
3310
|
+
final_MAD_valid,
|
|
3311
|
+
final_skew_valid,
|
|
3312
|
+
final_kurtosis_valid,
|
|
3313
|
+
) = tide_stats.fmristats(filtereddata)
|
|
3314
|
+
maplist += [
|
|
3315
|
+
(
|
|
3316
|
+
final_std_valid,
|
|
3317
|
+
"lfofilterCleanedStd",
|
|
3318
|
+
"map",
|
|
3319
|
+
None,
|
|
3320
|
+
"Std of the sLFO cleaned data",
|
|
3321
|
+
),
|
|
3322
|
+
(
|
|
3323
|
+
final_skew_valid,
|
|
3324
|
+
"lfofilterCleanedSkewness",
|
|
3325
|
+
"map",
|
|
3326
|
+
None,
|
|
3327
|
+
"Skewness of the sLFO cleaned data",
|
|
3328
|
+
),
|
|
3329
|
+
(
|
|
3330
|
+
final_kurtosis_valid,
|
|
3331
|
+
"lfofilterCleanedKurtosis",
|
|
3332
|
+
"map",
|
|
3333
|
+
None,
|
|
3334
|
+
"Kurtosis of the sLFO cleaned data",
|
|
3335
|
+
),
|
|
3336
|
+
]
|
|
3042
3337
|
else:
|
|
3043
3338
|
maplist = [
|
|
3044
3339
|
(
|
|
@@ -3062,25 +3357,22 @@ def rapidtide_main(argparsingfunc):
|
|
|
3062
3357
|
None,
|
|
3063
3358
|
"Percentage of inband variance attributable to CVR regressor",
|
|
3064
3359
|
),
|
|
3360
|
+
(rvalue, "CVRR", "map", None, "R value of the sLFO fit"),
|
|
3361
|
+
(
|
|
3362
|
+
r2value,
|
|
3363
|
+
"CVRR2",
|
|
3364
|
+
"map",
|
|
3365
|
+
None,
|
|
3366
|
+
"Squared R value of the sLFO fit (proportion of variance explained)",
|
|
3367
|
+
),
|
|
3368
|
+
(
|
|
3369
|
+
fitcoeff[:, 0],
|
|
3370
|
+
"CVR",
|
|
3371
|
+
"map",
|
|
3372
|
+
"percent",
|
|
3373
|
+
"Percent signal change due to the CVR regressor",
|
|
3374
|
+
)
|
|
3065
3375
|
]
|
|
3066
|
-
if optiondict["savenormalsLFOfiltfiles"]:
|
|
3067
|
-
maplist = [
|
|
3068
|
-
(rvalue, "CVRR", "map", None, "R value of the sLFO fit"),
|
|
3069
|
-
(
|
|
3070
|
-
r2value,
|
|
3071
|
-
"CVRR2",
|
|
3072
|
-
"map",
|
|
3073
|
-
None,
|
|
3074
|
-
"Squared R value of the sLFO fit (proportion of variance explained)",
|
|
3075
|
-
),
|
|
3076
|
-
(
|
|
3077
|
-
fitcoeff,
|
|
3078
|
-
"CVR",
|
|
3079
|
-
"map",
|
|
3080
|
-
"percent",
|
|
3081
|
-
"Percent signal change due to the CVR regressor",
|
|
3082
|
-
),
|
|
3083
|
-
]
|
|
3084
3376
|
|
|
3085
3377
|
tide_io.savemaplist(
|
|
3086
3378
|
outputname,
|