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
|
@@ -17,16 +17,20 @@
|
|
|
17
17
|
#
|
|
18
18
|
#
|
|
19
19
|
import argparse
|
|
20
|
-
from
|
|
21
|
-
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
|
20
|
+
from typing import Any, Optional
|
|
22
21
|
|
|
23
22
|
import numpy as np
|
|
24
|
-
from numpy.typing import NDArray
|
|
25
23
|
|
|
26
24
|
import rapidtide.io as tide_io
|
|
27
25
|
import rapidtide.multiproc as tide_multiproc
|
|
28
26
|
import rapidtide.workflows.parser_funcs as pf
|
|
29
27
|
|
|
28
|
+
try:
|
|
29
|
+
import tensorflow as tf
|
|
30
|
+
tensorflowpresent = True
|
|
31
|
+
except ImportError:
|
|
32
|
+
tensorflowpresent = False
|
|
33
|
+
|
|
30
34
|
DEFAULT_ALIASEDCORRELATIONWIDTH = 5.0
|
|
31
35
|
DEFAULT_PULSATILITYSIGMA = 6.0
|
|
32
36
|
DEFAULT_PULSATILITYTHRESHOLD = 0.5
|
|
@@ -73,6 +77,7 @@ def _get_parser() -> Any:
|
|
|
73
77
|
description="Hypersampling by Analytic Phase Projection - Yay!.",
|
|
74
78
|
allow_abbrev=False,
|
|
75
79
|
)
|
|
80
|
+
|
|
76
81
|
|
|
77
82
|
# Required arguments
|
|
78
83
|
parser.add_argument(
|
|
@@ -109,18 +114,19 @@ def _get_parser() -> Any:
|
|
|
109
114
|
help="Disable deep learning cardiac waveform filter. ",
|
|
110
115
|
default=True,
|
|
111
116
|
)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
if tensorflowpresent:
|
|
118
|
+
processing_steps.add_argument(
|
|
119
|
+
"--usesuperdangerousworkaround",
|
|
120
|
+
dest="mpfix",
|
|
121
|
+
action="store_true",
|
|
122
|
+
help=(
|
|
123
|
+
"Some versions of tensorflow seem to have some weird conflict with MKL which"
|
|
124
|
+
"I don't seem to be able to fix. If the dl filter bombs complaining about "
|
|
125
|
+
"multiple openmp libraries, try rerunning with the secret and inadvisable "
|
|
126
|
+
"'--usesuperdangerousworkaround' flag. Good luck! "
|
|
127
|
+
),
|
|
128
|
+
default=False,
|
|
129
|
+
)
|
|
124
130
|
processing_steps.add_argument(
|
|
125
131
|
"--slicetimesareinseconds",
|
|
126
132
|
action="store_true",
|
|
@@ -815,13 +821,14 @@ def _get_parser() -> Any:
|
|
|
815
821
|
help="Disable the congrid value cache completely.",
|
|
816
822
|
default=True,
|
|
817
823
|
)
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
824
|
+
if tensorflowpresent:
|
|
825
|
+
debug_opts.add_argument(
|
|
826
|
+
"--usetensorflow",
|
|
827
|
+
dest="usepytorch",
|
|
828
|
+
action="store_false",
|
|
829
|
+
help=("Switch to the old style tensorflow deep learning filter"),
|
|
830
|
+
default=True,
|
|
831
|
+
)
|
|
825
832
|
debug_opts.add_argument(
|
|
826
833
|
"--focaldebug",
|
|
827
834
|
dest="focaldebug",
|
|
@@ -833,7 +840,7 @@ def _get_parser() -> Any:
|
|
|
833
840
|
return parser
|
|
834
841
|
|
|
835
842
|
|
|
836
|
-
def process_args(inputargs: Optional[Any] = None) ->
|
|
843
|
+
def process_args(inputargs: Optional[Any] = None) -> Any:
|
|
837
844
|
"""
|
|
838
845
|
Compile arguments for happy workflow.
|
|
839
846
|
|
|
@@ -871,7 +878,7 @@ def process_args(inputargs: Optional[Any] = None) -> None:
|
|
|
871
878
|
|
|
872
879
|
# save the raw and formatted command lines
|
|
873
880
|
args.commandline = " ".join(argstowrite)
|
|
874
|
-
tide_io.writevec([args.commandline], args.outputroot + "_commandline.txt")
|
|
881
|
+
tide_io.writevec(np.array([args.commandline]), args.outputroot + "_commandline.txt")
|
|
875
882
|
formattedcommandline = []
|
|
876
883
|
for thetoken in argstowrite[0:3]:
|
|
877
884
|
formattedcommandline.append(thetoken)
|
|
@@ -890,7 +897,11 @@ def process_args(inputargs: Optional[Any] = None) -> None:
|
|
|
890
897
|
else:
|
|
891
898
|
suffix = ""
|
|
892
899
|
formattedcommandline[i] = prefix + formattedcommandline[i] + suffix
|
|
893
|
-
tide_io.writevec(formattedcommandline, args.outputroot + "_formattedcommandline.txt")
|
|
900
|
+
tide_io.writevec(np.array(formattedcommandline), args.outputroot + "_formattedcommandline.txt")
|
|
901
|
+
|
|
902
|
+
if not tensorflowpresent:
|
|
903
|
+
args.usepytorch = True
|
|
904
|
+
args.mpfix = False
|
|
894
905
|
|
|
895
906
|
# if user did not specify a model, set the default, depending on DL library
|
|
896
907
|
if args.modelname is None:
|
rapidtide/workflows/pairproc.py
CHANGED
|
@@ -235,9 +235,13 @@ def pairproc(args: Any) -> None:
|
|
|
235
235
|
desc="Voxel",
|
|
236
236
|
unit="voxels",
|
|
237
237
|
):
|
|
238
|
-
|
|
238
|
+
thepearsonresult = pearsonr(
|
|
239
239
|
tide_math.stdnormalize(evenims[vox, :]), tide_math.stdnormalize(oddims[vox, :])
|
|
240
240
|
)
|
|
241
|
+
temporalcorrelations[vox], temporalpvalues[vox] = (
|
|
242
|
+
thepearsonresult.statistic,
|
|
243
|
+
thepearsonresult.pvalue,
|
|
244
|
+
)
|
|
241
245
|
print()
|
|
242
246
|
|
|
243
247
|
outarray = np.zeros((xsize, ysize, numslices), dtype=np.double)
|
|
@@ -259,10 +263,14 @@ def pairproc(args: Any) -> None:
|
|
|
259
263
|
desc="Subject",
|
|
260
264
|
unit="subjects",
|
|
261
265
|
):
|
|
262
|
-
|
|
266
|
+
thepearsonresult = pearsonr(
|
|
263
267
|
tide_math.stdnormalize(evenims[:, subject]),
|
|
264
268
|
tide_math.stdnormalize(oddims[:, subject]),
|
|
265
269
|
)
|
|
270
|
+
spatialcorrelations[subject], spatialpvalues[subject] = (
|
|
271
|
+
thepearsonresult.statistic,
|
|
272
|
+
thepearsonresult.pvalue,
|
|
273
|
+
)
|
|
266
274
|
print()
|
|
267
275
|
|
|
268
276
|
tide_io.writenpvecs(
|
rapidtide/workflows/pixelcomp.py
CHANGED
|
@@ -25,7 +25,6 @@ from numpy.polynomial import Polynomial
|
|
|
25
25
|
import rapidtide.io as tide_io
|
|
26
26
|
|
|
27
27
|
mpl.use("Agg")
|
|
28
|
-
from argparse import Namespace
|
|
29
28
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
|
30
29
|
|
|
31
30
|
import matplotlib.pyplot as plt
|
|
@@ -236,7 +235,7 @@ def pairdata(input1_data: Any, input2_data: Any, totalmask: Any) -> None:
|
|
|
236
235
|
|
|
237
236
|
Returns
|
|
238
237
|
-------
|
|
239
|
-
|
|
238
|
+
NDArray
|
|
240
239
|
2D array where each row contains a pair of corresponding elements
|
|
241
240
|
from input1_data and input2_data at positions where totalmask > 0.
|
|
242
241
|
|
rapidtide/workflows/rankimage.py
CHANGED
rapidtide/workflows/rapidtide.py
CHANGED
|
@@ -67,6 +67,9 @@ LGR = logging.getLogger("GENERAL")
|
|
|
67
67
|
ErrorLGR = logging.getLogger("ERROR")
|
|
68
68
|
TimingLGR = logging.getLogger("TIMING")
|
|
69
69
|
|
|
70
|
+
global rt_floattype
|
|
71
|
+
rt_floattype: np.dtype = np.float64
|
|
72
|
+
|
|
70
73
|
|
|
71
74
|
def checkforzeromean(thedataset: Any) -> bool:
|
|
72
75
|
"""
|
|
@@ -366,25 +369,21 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
366
369
|
tide_util.disablenumba()
|
|
367
370
|
|
|
368
371
|
# set the internal precision
|
|
369
|
-
global
|
|
372
|
+
global rt_floattype
|
|
370
373
|
if optiondict["internalprecision"] == "double":
|
|
371
374
|
LGR.debug("setting internal precision to double")
|
|
372
|
-
rt_floattype =
|
|
373
|
-
rt_floatset = np.float64
|
|
375
|
+
rt_floattype = np.float64
|
|
374
376
|
else:
|
|
375
377
|
LGR.debug("setting internal precision to single")
|
|
376
|
-
rt_floattype =
|
|
377
|
-
rt_floatset = np.float32
|
|
378
|
+
rt_floattype = np.float32
|
|
378
379
|
|
|
379
380
|
# set the output precision
|
|
380
381
|
if optiondict["outputprecision"] == "double":
|
|
381
382
|
LGR.debug("setting output precision to double")
|
|
382
|
-
rt_outfloattype =
|
|
383
|
-
rt_outfloatset = np.float64
|
|
383
|
+
rt_outfloattype = np.float64
|
|
384
384
|
else:
|
|
385
385
|
LGR.debug("setting output precision to single")
|
|
386
|
-
rt_outfloattype =
|
|
387
|
-
rt_outfloatset = np.float32
|
|
386
|
+
rt_outfloattype = np.float32
|
|
388
387
|
|
|
389
388
|
# set the number of worker processes if multiprocessing
|
|
390
389
|
if optiondict["nprocs"] < 1:
|
|
@@ -540,8 +539,8 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
540
539
|
)
|
|
541
540
|
anatomicmasks[-1] = np.uint16(np.where(anatomicmasks[-1] > 0.1, 1, 0))
|
|
542
541
|
else:
|
|
543
|
-
anatomicmasks.append(
|
|
544
|
-
|
|
542
|
+
anatomicmasks.append(np.uint16(np.ones(nativespaceshape, dtype=np.uint16)))
|
|
543
|
+
|
|
545
544
|
brainmask = anatomicmasks[0]
|
|
546
545
|
graymask = anatomicmasks[1]
|
|
547
546
|
whitemask = anatomicmasks[2]
|
|
@@ -793,7 +792,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
793
792
|
LGR.info("moving fmri data to shared memory")
|
|
794
793
|
TimingLGR.verbose("Start moving fmri_data to shared memory")
|
|
795
794
|
fmri_data_valid, fmri_data_valid_shm = tide_util.numpy2shared(
|
|
796
|
-
fmri_data_valid,
|
|
795
|
+
fmri_data_valid, rt_floattype, name=f"fmri_data_valid_{optiondict['pid']}"
|
|
797
796
|
)
|
|
798
797
|
TimingLGR.verbose("End moving fmri_data to shared memory")
|
|
799
798
|
|
|
@@ -1263,7 +1262,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
1263
1262
|
padlen=int(inputfreq * optiondict["padseconds"]),
|
|
1264
1263
|
debug=optiondict["debug"],
|
|
1265
1264
|
)
|
|
1266
|
-
reference_y =
|
|
1265
|
+
reference_y = (reference_y_filt.real).astype(rt_floattype)
|
|
1267
1266
|
|
|
1268
1267
|
warnings.filterwarnings("ignore", "Casting*")
|
|
1269
1268
|
|
|
@@ -1324,11 +1323,11 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
1324
1323
|
# save the factor used to normalize the input regressor
|
|
1325
1324
|
optiondict["initialmovingregressornormfac"] = np.std(resampnonosref_y)
|
|
1326
1325
|
|
|
1327
|
-
# prepare the temporal
|
|
1326
|
+
# prepare the temporal masks
|
|
1328
1327
|
if optiondict["tincludemaskname"] is not None:
|
|
1329
1328
|
print("creating temporal include mask")
|
|
1330
1329
|
includetmask_y = tide_mask.maketmask(
|
|
1331
|
-
optiondict["tincludemaskname"], reference_x,
|
|
1330
|
+
optiondict["tincludemaskname"], reference_x, reference_y.astype(rt_floattype) + 0.0
|
|
1332
1331
|
)
|
|
1333
1332
|
else:
|
|
1334
1333
|
includetmask_y = (reference_x * 0.0) + 1.0
|
|
@@ -1337,7 +1336,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
1337
1336
|
excludetmask_y = (
|
|
1338
1337
|
-1.0
|
|
1339
1338
|
* tide_mask.maketmask(
|
|
1340
|
-
optiondict["texcludemaskname"], reference_x,
|
|
1339
|
+
optiondict["texcludemaskname"], reference_x, reference_y.astype(rt_floattype) + 0.0
|
|
1341
1340
|
)
|
|
1342
1341
|
+ 1.0
|
|
1343
1342
|
)
|
|
@@ -1373,6 +1372,9 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
1373
1372
|
else:
|
|
1374
1373
|
tmaskos_y = None
|
|
1375
1374
|
|
|
1375
|
+
# construct refine temporal masks here
|
|
1376
|
+
optiondict["windowedrefinemasks"] = None
|
|
1377
|
+
|
|
1376
1378
|
(
|
|
1377
1379
|
optiondict["kurtosis_reference_pass1"],
|
|
1378
1380
|
optiondict["kurtosisz_reference_pass1"],
|
|
@@ -1547,7 +1549,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
1547
1549
|
fitmask = np.zeros(internalvalidspaceshape, dtype="uint16")
|
|
1548
1550
|
failreason = np.zeros(internalvalidspaceshape, dtype="uint32")
|
|
1549
1551
|
R2 = np.zeros(internalvalidspaceshape, dtype=rt_floattype)
|
|
1550
|
-
outmaparray = np.zeros(internalspaceshape, dtype=rt_floattype)
|
|
1552
|
+
outmaparray = np.zeros((internalspaceshape), dtype=rt_floattype)
|
|
1551
1553
|
tide_util.logmem("after main array allocation")
|
|
1552
1554
|
|
|
1553
1555
|
if optiondict["similaritymetric"] == "riptide":
|
|
@@ -1563,7 +1565,6 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
1563
1565
|
chunksize=optiondict["mp_chunksize"],
|
|
1564
1566
|
nprocs=optiondict["nprocs"],
|
|
1565
1567
|
alwaysmultiproc=optiondict["alwaysmultiproc"],
|
|
1566
|
-
rt_floatset=rt_floatset,
|
|
1567
1568
|
rt_floattype=rt_floattype,
|
|
1568
1569
|
debug=optiondict["debug"],
|
|
1569
1570
|
)
|
|
@@ -1589,25 +1590,25 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
1589
1590
|
|
|
1590
1591
|
corrout, corrout_shm = tide_util.allocarray(
|
|
1591
1592
|
internalvalidcorrshape,
|
|
1592
|
-
|
|
1593
|
+
rt_floattype,
|
|
1593
1594
|
shared=optiondict["sharedmem"],
|
|
1594
1595
|
name=f"corrout_{optiondict['pid']}",
|
|
1595
1596
|
)
|
|
1596
1597
|
gaussout, gaussout_shm = tide_util.allocarray(
|
|
1597
1598
|
internalvalidcorrshape,
|
|
1598
|
-
|
|
1599
|
+
rt_floattype,
|
|
1599
1600
|
shared=optiondict["sharedmem"],
|
|
1600
1601
|
name=f"gaussout_{optiondict['pid']}",
|
|
1601
1602
|
)
|
|
1602
1603
|
windowout, windowout_shm = tide_util.allocarray(
|
|
1603
1604
|
internalvalidcorrshape,
|
|
1604
|
-
|
|
1605
|
+
rt_floattype,
|
|
1605
1606
|
shared=optiondict["sharedmem"],
|
|
1606
1607
|
name=f"windowout_{optiondict['pid']}",
|
|
1607
1608
|
)
|
|
1608
1609
|
outcorrarray, outcorrarray_shm = tide_util.allocarray(
|
|
1609
1610
|
internalcorrshape,
|
|
1610
|
-
|
|
1611
|
+
rt_floattype,
|
|
1611
1612
|
shared=optiondict["sharedmem"],
|
|
1612
1613
|
name=f"outcorrarray_{optiondict['pid']}",
|
|
1613
1614
|
)
|
|
@@ -1778,7 +1779,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
1778
1779
|
fastresamplerpadtime=optiondict["fastresamplerpadtime"],
|
|
1779
1780
|
prewhitenregressor=False,
|
|
1780
1781
|
prewhitenlags=optiondict["prewhitenlags"],
|
|
1781
|
-
debug=optiondict["
|
|
1782
|
+
debug=optiondict["debug"],
|
|
1782
1783
|
)
|
|
1783
1784
|
|
|
1784
1785
|
# cycle over all voxels
|
|
@@ -1839,7 +1840,6 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
1839
1840
|
interptype=optiondict["interptype"],
|
|
1840
1841
|
showprogressbar=optiondict["showprogressbar"],
|
|
1841
1842
|
chunksize=optiondict["mp_chunksize"],
|
|
1842
|
-
rt_floatset=rt_floatset,
|
|
1843
1843
|
rt_floattype=rt_floattype,
|
|
1844
1844
|
)
|
|
1845
1845
|
tide_util.enablemkl(optiondict["mklthreads"], debug=optiondict["threaddebug"])
|
|
@@ -1892,7 +1892,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
1892
1892
|
# Preprocessing - prewhitening
|
|
1893
1893
|
if optiondict["prewhitenregressor"]:
|
|
1894
1894
|
resampref_y = tide_fit.prewhiten(
|
|
1895
|
-
resampref_y, optiondict["prewhitenlags"], debug=optiondict["
|
|
1895
|
+
resampref_y, optiondict["prewhitenlags"], debug=optiondict["debug"]
|
|
1896
1896
|
)
|
|
1897
1897
|
tide_io.writebidstsv(
|
|
1898
1898
|
f"{outputname}_desc-oversampledmovingregressor_timeseries",
|
|
@@ -1992,7 +1992,6 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
1992
1992
|
respdelete=optiondict["respdelete"],
|
|
1993
1993
|
debug=optiondict["debug"],
|
|
1994
1994
|
rt_floattype=rt_floattype,
|
|
1995
|
-
rt_floatset=rt_floatset,
|
|
1996
1995
|
)
|
|
1997
1996
|
if optiondict["debug"]:
|
|
1998
1997
|
print(
|
|
@@ -2045,8 +2044,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2045
2044
|
showprogressbar=optiondict["showprogressbar"],
|
|
2046
2045
|
chunksize=optiondict["mp_chunksize"],
|
|
2047
2046
|
permutationmethod=optiondict["permutationmethod"],
|
|
2048
|
-
|
|
2049
|
-
rt_floattype="float64",
|
|
2047
|
+
rt_floattype=np.float64,
|
|
2050
2048
|
)
|
|
2051
2049
|
tide_util.enablemkl(optiondict["mklthreads"], debug=optiondict["threaddebug"])
|
|
2052
2050
|
|
|
@@ -2190,7 +2188,6 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2190
2188
|
interptype=optiondict["interptype"],
|
|
2191
2189
|
showprogressbar=optiondict["showprogressbar"],
|
|
2192
2190
|
chunksize=optiondict["mp_chunksize"],
|
|
2193
|
-
rt_floatset=rt_floatset,
|
|
2194
2191
|
rt_floattype=rt_floattype,
|
|
2195
2192
|
threaddebug=optiondict["threaddebug"],
|
|
2196
2193
|
debug=optiondict["debug"],
|
|
@@ -2260,8 +2257,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2260
2257
|
LGR,
|
|
2261
2258
|
TimingLGR,
|
|
2262
2259
|
simplefit=(optiondict["similaritymetric"] == "riptide"),
|
|
2263
|
-
|
|
2264
|
-
rt_floattype="float64",
|
|
2260
|
+
rt_floattype=np.float64,
|
|
2265
2261
|
)
|
|
2266
2262
|
|
|
2267
2263
|
# Step 2b - refine delay (optional)
|
|
@@ -2313,7 +2309,6 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2313
2309
|
maxdelay=optiondict["maxdelay"],
|
|
2314
2310
|
numpoints=optiondict["numpoints"],
|
|
2315
2311
|
histlen=optiondict["histlen"],
|
|
2316
|
-
rt_floatset=rt_floatset,
|
|
2317
2312
|
rt_floattype=rt_floattype,
|
|
2318
2313
|
debug=optiondict["debug"],
|
|
2319
2314
|
)
|
|
@@ -2338,7 +2333,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2338
2333
|
cifti_hdr=theinputdata.cifti_hdr,
|
|
2339
2334
|
)
|
|
2340
2335
|
|
|
2341
|
-
# Step
|
|
2336
|
+
# Step 2c - make a rank order map
|
|
2342
2337
|
timepercentile = (
|
|
2343
2338
|
100.0 * (rankdata(lagtimes, method="dense") - 1) / (numvalidspatiallocs - 1)
|
|
2344
2339
|
)
|
|
@@ -2380,7 +2375,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2380
2375
|
or optiondict["initregressorpreselect"]
|
|
2381
2376
|
or optiondict["dofinalrefine"]
|
|
2382
2377
|
):
|
|
2383
|
-
|
|
2378
|
+
resampref_y, resampnonosref_y, stoprefining, refinestopreason, genlagtc = (
|
|
2384
2379
|
tide_refineRegressor.refineRegressor(
|
|
2385
2380
|
LGR,
|
|
2386
2381
|
TimingLGR,
|
|
@@ -2407,8 +2402,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2407
2402
|
outputname,
|
|
2408
2403
|
nativefmrishape,
|
|
2409
2404
|
bidsbasedict,
|
|
2410
|
-
|
|
2411
|
-
rt_floattype="float64",
|
|
2405
|
+
rt_floattype=np.float64,
|
|
2412
2406
|
)
|
|
2413
2407
|
)
|
|
2414
2408
|
# End of main pass loop
|
|
@@ -2475,19 +2469,19 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2475
2469
|
# now allocate the arrays needed for the coherence calculation
|
|
2476
2470
|
coherencefunc, coherencefunc_shm = tide_util.allocarray(
|
|
2477
2471
|
internalvalidcoherenceshape,
|
|
2478
|
-
|
|
2472
|
+
rt_outfloattype,
|
|
2479
2473
|
shared=optiondict["sharedmem"],
|
|
2480
2474
|
name=f"coherencefunc_{optiondict['pid']}",
|
|
2481
2475
|
)
|
|
2482
2476
|
coherencepeakval, coherencepeakval_shm = tide_util.allocarray(
|
|
2483
2477
|
numvalidspatiallocs,
|
|
2484
|
-
|
|
2478
|
+
rt_outfloattype,
|
|
2485
2479
|
shared=optiondict["sharedmem"],
|
|
2486
2480
|
name=f"coherencepeakval_{optiondict['pid']}",
|
|
2487
2481
|
)
|
|
2488
2482
|
coherencepeakfreq, coherencepeakfreq_shm = tide_util.allocarray(
|
|
2489
2483
|
numvalidspatiallocs,
|
|
2490
|
-
|
|
2484
|
+
rt_outfloattype,
|
|
2491
2485
|
shared=optiondict["sharedmem"],
|
|
2492
2486
|
name=f"coherencepeakfreq_{optiondict['pid']}",
|
|
2493
2487
|
)
|
|
@@ -2551,13 +2545,13 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2551
2545
|
# now allocate the arrays needed for Wiener deconvolution
|
|
2552
2546
|
wienerdeconv, wienerdeconv_shm = tide_util.allocarray(
|
|
2553
2547
|
internalvalidspaceshape,
|
|
2554
|
-
|
|
2548
|
+
rt_outfloattype,
|
|
2555
2549
|
shared=optiondict["sharedmem"],
|
|
2556
2550
|
name=f"wienerdeconv_{optiondict['pid']}",
|
|
2557
2551
|
)
|
|
2558
2552
|
wpeak, wpeak_shm = tide_util.allocarray(
|
|
2559
2553
|
internalvalidspaceshape,
|
|
2560
|
-
|
|
2554
|
+
rt_outfloattype,
|
|
2561
2555
|
shared=optiondict["sharedmem"],
|
|
2562
2556
|
name=f"wpeak_{optiondict['pid']}",
|
|
2563
2557
|
)
|
|
@@ -2578,7 +2572,6 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2578
2572
|
wienerdeconv,
|
|
2579
2573
|
wpeak,
|
|
2580
2574
|
resampref_y,
|
|
2581
|
-
rt_floatset=rt_floatset,
|
|
2582
2575
|
rt_floattype=rt_floattype,
|
|
2583
2576
|
)
|
|
2584
2577
|
TimingLGR.info(
|
|
@@ -2641,7 +2634,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2641
2634
|
|
|
2642
2635
|
if optiondict["docvrmap"]:
|
|
2643
2636
|
# percent normalize the fmri data
|
|
2644
|
-
LGR.info("
|
|
2637
|
+
LGR.info("normalizing data for CVR map")
|
|
2645
2638
|
themean = np.mean(fmri_data_valid, axis=1)
|
|
2646
2639
|
fmri_data_valid /= themean[:, None]
|
|
2647
2640
|
|
|
@@ -2662,7 +2655,7 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2662
2655
|
TimingLGR.info("Start moving fmri_data to shared memory")
|
|
2663
2656
|
fmri_data_valid, fmri_data_valid_shm = tide_util.numpy2shared(
|
|
2664
2657
|
fmri_data_valid,
|
|
2665
|
-
|
|
2658
|
+
rt_floattype,
|
|
2666
2659
|
name=f"fmri_data_valid_regressionfilt_{optiondict['pid']}",
|
|
2667
2660
|
)
|
|
2668
2661
|
TimingLGR.info("End moving fmri_data to shared memory")
|
|
@@ -2778,11 +2771,56 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
2778
2771
|
maxdelay=optiondict["maxdelay"],
|
|
2779
2772
|
numpoints=optiondict["numpoints"],
|
|
2780
2773
|
histlen=optiondict["histlen"],
|
|
2781
|
-
rt_floatset=rt_floatset,
|
|
2782
2774
|
rt_floattype=rt_floattype,
|
|
2783
2775
|
debug=optiondict["debug"],
|
|
2784
2776
|
)
|
|
2785
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
|
+
|
|
2786
2824
|
####################################################
|
|
2787
2825
|
# Delay refinement end
|
|
2788
2826
|
####################################################
|
|
@@ -3319,25 +3357,22 @@ def rapidtide_main(argparsingfunc: Any) -> None:
|
|
|
3319
3357
|
None,
|
|
3320
3358
|
"Percentage of inband variance attributable to CVR regressor",
|
|
3321
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
|
+
)
|
|
3322
3375
|
]
|
|
3323
|
-
if optiondict["savenormalsLFOfiltfiles"]:
|
|
3324
|
-
maplist = [
|
|
3325
|
-
(rvalue, "CVRR", "map", None, "R value of the sLFO fit"),
|
|
3326
|
-
(
|
|
3327
|
-
r2value,
|
|
3328
|
-
"CVRR2",
|
|
3329
|
-
"map",
|
|
3330
|
-
None,
|
|
3331
|
-
"Squared R value of the sLFO fit (proportion of variance explained)",
|
|
3332
|
-
),
|
|
3333
|
-
(
|
|
3334
|
-
fitcoeff,
|
|
3335
|
-
"CVR",
|
|
3336
|
-
"map",
|
|
3337
|
-
"percent",
|
|
3338
|
-
"Percent signal change due to the CVR regressor",
|
|
3339
|
-
),
|
|
3340
|
-
]
|
|
3341
3376
|
|
|
3342
3377
|
tide_io.savemaplist(
|
|
3343
3378
|
outputname,
|
|
@@ -51,12 +51,12 @@ def refineDelay(
|
|
|
51
51
|
outputlevel: str = "normal",
|
|
52
52
|
gausssigma: int = -1,
|
|
53
53
|
patchthresh: float = 3.0,
|
|
54
|
+
timemask: NDArray | None = None,
|
|
54
55
|
mindelay: float = -5.0,
|
|
55
56
|
maxdelay: float = 5.0,
|
|
56
57
|
numpoints: int = 501,
|
|
57
58
|
histlen: int = 101,
|
|
58
|
-
|
|
59
|
-
rt_floattype: str = "float64",
|
|
59
|
+
rt_floattype: np.dtype = np.float64,
|
|
60
60
|
debug: bool = False,
|
|
61
61
|
) -> None:
|
|
62
62
|
"""
|
|
@@ -118,6 +118,8 @@ def refineDelay(
|
|
|
118
118
|
Sigma for Gaussian filtering, default is -1 (no filtering).
|
|
119
119
|
patchthresh : float, optional
|
|
120
120
|
Threshold for patch-based filtering, default is 3.0.
|
|
121
|
+
timemask : NDArray, optional
|
|
122
|
+
Mask of timepoints to include in regression filtering. Default is None.
|
|
121
123
|
mindelay : float, optional
|
|
122
124
|
Minimum delay value, default is -5.0.
|
|
123
125
|
maxdelay : float, optional
|
|
@@ -126,10 +128,8 @@ def refineDelay(
|
|
|
126
128
|
Number of points for delay interpolation, default is 501.
|
|
127
129
|
histlen : int, optional
|
|
128
130
|
Length of histogram bins, default is 101.
|
|
129
|
-
|
|
130
|
-
Data type for
|
|
131
|
-
rt_floattype : str, optional
|
|
132
|
-
String representation of float type, default is "float64".
|
|
131
|
+
rt_floattype : np.dtype, optional
|
|
132
|
+
Data type for rapidtide float operations, default is np.float64.
|
|
133
133
|
debug : bool, optional
|
|
134
134
|
Enable debug mode, default is False.
|
|
135
135
|
|
|
@@ -190,6 +190,7 @@ def refineDelay(
|
|
|
190
190
|
TimingLGR,
|
|
191
191
|
optiondict,
|
|
192
192
|
regressderivs=1,
|
|
193
|
+
timemask=timemask,
|
|
193
194
|
debug=debug,
|
|
194
195
|
)
|
|
195
196
|
|