rapidtide 3.0.2__py3-none-any.whl → 3.0.3__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/calcsimfunc.py +3 -0
- rapidtide/correlate.py +18 -1
- rapidtide/data/examples/src/testfmri +7 -4
- rapidtide/data/examples/src/testretro +10 -4
- rapidtide/helper_classes.py +4 -4
- rapidtide/io.py +2 -0
- rapidtide/maskutil.py +144 -0
- rapidtide/tests/test_cleanregressor.py +185 -0
- rapidtide/tests/test_fullrunrapidtide_v1.py +4 -0
- rapidtide/tests/test_fullrunrapidtide_v7.py +114 -0
- rapidtide/tests/test_io.py +58 -13
- rapidtide/voxelData.py +1 -0
- rapidtide/workflows/cleanregressor.py +43 -6
- rapidtide/workflows/rapidtide.py +239 -106
- rapidtide/workflows/rapidtide_parser.py +115 -66
- rapidtide/workflows/retroregress.py +170 -34
- {rapidtide-3.0.2.dist-info → rapidtide-3.0.3.dist-info}/METADATA +1 -1
- {rapidtide-3.0.2.dist-info → rapidtide-3.0.3.dist-info}/RECORD +22 -20
- {rapidtide-3.0.2.dist-info → rapidtide-3.0.3.dist-info}/WHEEL +1 -1
- {rapidtide-3.0.2.dist-info → rapidtide-3.0.3.dist-info}/entry_points.txt +0 -0
- {rapidtide-3.0.2.dist-info → rapidtide-3.0.3.dist-info}/licenses/LICENSE +0 -0
- {rapidtide-3.0.2.dist-info → rapidtide-3.0.3.dist-info}/top_level.txt +0 -0
|
@@ -29,6 +29,7 @@ import rapidtide.io as tide_io
|
|
|
29
29
|
import rapidtide.util as tide_util
|
|
30
30
|
import rapidtide.workflows.parser_funcs as pf
|
|
31
31
|
|
|
32
|
+
|
|
32
33
|
# Create a sentinel.
|
|
33
34
|
# from https://stackoverflow.com/questions/58594956/find-out-which-arguments-were-passed-explicitly-in-argparse
|
|
34
35
|
class _Sentinel:
|
|
@@ -43,7 +44,7 @@ LGR = logging.getLogger(__name__)
|
|
|
43
44
|
DEFAULT_SPATIALFILT = -1
|
|
44
45
|
DEFAULT_HISTLEN = 101
|
|
45
46
|
DEFAULT_DETREND_ORDER = 3
|
|
46
|
-
|
|
47
|
+
DEFAULT_INITREGRESSOR_PCACOMPONENTS = 0.8
|
|
47
48
|
DEFAULT_CORRMASK_THRESHPCT = 1.0
|
|
48
49
|
DEFAULT_MUTUALINFO_SMOOTHINGTIME = 3.0
|
|
49
50
|
DEFAULT_LAGMIN = -30.0
|
|
@@ -62,7 +63,7 @@ DEFAULT_MAXPASSES = 15
|
|
|
62
63
|
DEFAULT_REFINE_TYPE = "pca"
|
|
63
64
|
DEFAULT_INTERPTYPE = "univariate"
|
|
64
65
|
DEFAULT_WINDOW_TYPE = "hamming"
|
|
65
|
-
|
|
66
|
+
DEFAULT_INITREGRESSOR_METHOD = "sum"
|
|
66
67
|
DEFAULT_CORRWEIGHTING = "phat"
|
|
67
68
|
DEFAULT_CORRTYPE = "linear"
|
|
68
69
|
DEFAULT_SIMILARITYMETRIC = "correlation"
|
|
@@ -193,7 +194,7 @@ def _get_parser():
|
|
|
193
194
|
)
|
|
194
195
|
analysis_type.add_argument(
|
|
195
196
|
"--globalpreselect",
|
|
196
|
-
dest="
|
|
197
|
+
dest="initregressorpreselect",
|
|
197
198
|
action="store_true",
|
|
198
199
|
help=(
|
|
199
200
|
"Treat this run as an initial pass to locate good candidate voxels for global mean "
|
|
@@ -259,7 +260,7 @@ def _get_parser():
|
|
|
259
260
|
"2) decide which voxels in which to calculate delays, "
|
|
260
261
|
"3) refine the regressor at the end of each pass, 4) determine the zero time offset value, and 5) process "
|
|
261
262
|
"to remove sLFO signal. "
|
|
262
|
-
"Setting --
|
|
263
|
+
"Setting --initregressorinclude, --corrmaskinclude, --refineinclude or --offsetinclude explicitly will "
|
|
263
264
|
"override this for the given include mask."
|
|
264
265
|
),
|
|
265
266
|
default=None,
|
|
@@ -272,9 +273,8 @@ def _get_parser():
|
|
|
272
273
|
"This specifies a gray matter mask registered to the input functional data. "
|
|
273
274
|
"If VALSPEC is given, only voxels in the mask with integral values listed in VALSPEC are used, otherwise "
|
|
274
275
|
"voxels with value > 0.1 are used. If this option is set, "
|
|
275
|
-
"rapidtide will use voxels in the gray matter mask to
|
|
276
|
-
"
|
|
277
|
-
"Setting --globalmeaninclude or --offsetinclude explicitly will override this for "
|
|
276
|
+
"rapidtide will use voxels in the gray matter mask to calculate the initial global mean regressor. "
|
|
277
|
+
"Setting --initregressorinclude explicitly will override this for "
|
|
278
278
|
"the given include mask."
|
|
279
279
|
),
|
|
280
280
|
default=None,
|
|
@@ -287,8 +287,21 @@ def _get_parser():
|
|
|
287
287
|
"This specifies a white matter mask registered to the input functional data. "
|
|
288
288
|
"If VALSPEC is given, only voxels in the mask with integral values listed in VALSPEC are used, otherwise "
|
|
289
289
|
"voxels with value > 0.1 are used. "
|
|
290
|
-
"This
|
|
291
|
-
"
|
|
290
|
+
"This will be used to calculate the white matter timecourse before running rapidtide, and after sLFO "
|
|
291
|
+
"filtering (if enabled)."
|
|
292
|
+
),
|
|
293
|
+
default=None,
|
|
294
|
+
)
|
|
295
|
+
anatomy.add_argument(
|
|
296
|
+
"--csfmask",
|
|
297
|
+
dest="csfincludespec",
|
|
298
|
+
metavar="MASK[:VALSPEC]",
|
|
299
|
+
help=(
|
|
300
|
+
"This specifies a CSF mask registered to the input functional data. "
|
|
301
|
+
"If VALSPEC is given, only voxels in the mask with integral values listed in VALSPEC are used, otherwise "
|
|
302
|
+
"voxels with value > 0.1 are used. "
|
|
303
|
+
"This will be used to calculate the CSF timecourse before running rapidtide, and after sLFO "
|
|
304
|
+
"filtering (if enabled)."
|
|
292
305
|
),
|
|
293
306
|
default=None,
|
|
294
307
|
)
|
|
@@ -437,7 +450,7 @@ def _get_parser():
|
|
|
437
450
|
)
|
|
438
451
|
preproc.add_argument(
|
|
439
452
|
"--globalmean",
|
|
440
|
-
dest="
|
|
453
|
+
dest="useinitregressorref",
|
|
441
454
|
action="store_true",
|
|
442
455
|
help=(
|
|
443
456
|
"Generate a global mean regressor and use that as the reference "
|
|
@@ -448,10 +461,10 @@ def _get_parser():
|
|
|
448
461
|
)
|
|
449
462
|
preproc.add_argument(
|
|
450
463
|
"--globalmeaninclude",
|
|
451
|
-
dest="
|
|
464
|
+
dest="initregressorincludespec",
|
|
452
465
|
metavar="MASK[:VALSPEC]",
|
|
453
466
|
help=(
|
|
454
|
-
"Only use voxels in mask file NAME for
|
|
467
|
+
"Only use voxels in mask file NAME for the initial regressor "
|
|
455
468
|
"generation (if VALSPEC is given, only voxels "
|
|
456
469
|
"with integral values listed in VALSPEC are used)."
|
|
457
470
|
),
|
|
@@ -459,10 +472,10 @@ def _get_parser():
|
|
|
459
472
|
)
|
|
460
473
|
preproc.add_argument(
|
|
461
474
|
"--globalmeanexclude",
|
|
462
|
-
dest="
|
|
475
|
+
dest="initregressorexcludespec",
|
|
463
476
|
metavar="MASK[:VALSPEC]",
|
|
464
477
|
help=(
|
|
465
|
-
"Do not use voxels in mask file NAME for
|
|
478
|
+
"Do not use voxels in mask file NAME for the initial regressor "
|
|
466
479
|
"generation (if VALSPEC is given, only voxels "
|
|
467
480
|
"with integral values listed in VALSPEC are excluded)."
|
|
468
481
|
),
|
|
@@ -479,6 +492,16 @@ def _get_parser():
|
|
|
479
492
|
),
|
|
480
493
|
default=None,
|
|
481
494
|
)
|
|
495
|
+
preproc.add_argument(
|
|
496
|
+
"--motpowers",
|
|
497
|
+
dest="mot_power",
|
|
498
|
+
metavar="N",
|
|
499
|
+
type=lambda x: pf.is_int(parser, x, minval=1),
|
|
500
|
+
help=(
|
|
501
|
+
"Include powers of each motion regressor up to order N. Default is 1 (no expansion). "
|
|
502
|
+
),
|
|
503
|
+
default=1,
|
|
504
|
+
)
|
|
482
505
|
preproc.add_argument(
|
|
483
506
|
"--nomotderiv",
|
|
484
507
|
dest="mot_deriv",
|
|
@@ -530,32 +553,32 @@ def _get_parser():
|
|
|
530
553
|
)
|
|
531
554
|
preproc.add_argument(
|
|
532
555
|
"--globalsignalmethod",
|
|
533
|
-
dest="
|
|
556
|
+
dest="initregressorsignalmethod",
|
|
534
557
|
action="store",
|
|
535
558
|
type=str,
|
|
536
559
|
choices=["sum", "meanscale", "pca", "random"],
|
|
537
560
|
help=(
|
|
538
|
-
"The method for constructing the initial
|
|
539
|
-
"mean scaling each voxel prior to summation, MLE PCA of the voxels in the
|
|
561
|
+
"The method for constructing the initial signal regressor - straight summation, "
|
|
562
|
+
"mean scaling each voxel prior to summation, MLE PCA of the voxels in the initial regressor mask, "
|
|
540
563
|
"or initializing using random noise."
|
|
541
|
-
f'Default is "{
|
|
564
|
+
f'Default is "{DEFAULT_INITREGRESSOR_METHOD}."'
|
|
542
565
|
),
|
|
543
|
-
default=
|
|
566
|
+
default=DEFAULT_INITREGRESSOR_METHOD,
|
|
544
567
|
)
|
|
545
568
|
preproc.add_argument(
|
|
546
569
|
"--globalpcacomponents",
|
|
547
|
-
dest="
|
|
570
|
+
dest="initregressorpcacomponents",
|
|
548
571
|
action="store",
|
|
549
572
|
type=float,
|
|
550
573
|
metavar="VALUE",
|
|
551
574
|
help=(
|
|
552
|
-
"Number of PCA components used for estimating the
|
|
575
|
+
"Number of PCA components used for estimating the initial regressor. If VALUE >= 1, will retain this"
|
|
553
576
|
"many components. If "
|
|
554
577
|
"0.0 < VALUE < 1.0, enough components will be retained to explain the fraction VALUE of the "
|
|
555
578
|
"total variance. If VALUE is negative, the number of components will be to retain will be selected "
|
|
556
|
-
f"automatically using the MLE method. Default is {
|
|
579
|
+
f"automatically using the MLE method. Default is {DEFAULT_INITREGRESSOR_PCACOMPONENTS}."
|
|
557
580
|
),
|
|
558
|
-
default=
|
|
581
|
+
default=DEFAULT_INITREGRESSOR_PCACOMPONENTS,
|
|
559
582
|
)
|
|
560
583
|
preproc.add_argument(
|
|
561
584
|
"--slicetimes",
|
|
@@ -1270,7 +1293,7 @@ def _get_parser():
|
|
|
1270
1293
|
"--saveintermediatemaps",
|
|
1271
1294
|
dest="saveintermediatemaps",
|
|
1272
1295
|
action="store_true",
|
|
1273
|
-
help="Save lag times, strengths, widths, and
|
|
1296
|
+
help="Save lag times, strengths, widths, mask (and shiftedtcs, if they'd normally be saved) for each pass.",
|
|
1274
1297
|
default=False,
|
|
1275
1298
|
)
|
|
1276
1299
|
output.add_argument(
|
|
@@ -1911,20 +1934,27 @@ def process_args(inputargs=None):
|
|
|
1911
1934
|
else:
|
|
1912
1935
|
args["inputfreq_nondefault"] = True
|
|
1913
1936
|
|
|
1914
|
-
# mask
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1937
|
+
# initial mask values from anatomical images (before any overrides)
|
|
1938
|
+
for key in [
|
|
1939
|
+
"corrmaskincludename",
|
|
1940
|
+
"corrmaskincludevals",
|
|
1941
|
+
"initregressorincludename",
|
|
1942
|
+
"initregressorincludevals",
|
|
1943
|
+
"initregressorexcludename",
|
|
1944
|
+
"initregressorexcludevals",
|
|
1945
|
+
"refineincludename",
|
|
1946
|
+
"refineincludevals",
|
|
1947
|
+
"refineexcludename",
|
|
1948
|
+
"refineexcludevals",
|
|
1949
|
+
"offsetincludename",
|
|
1950
|
+
"offsetincludevals",
|
|
1951
|
+
"offsetexcludename",
|
|
1952
|
+
"offsetexcludevals",
|
|
1953
|
+
]:
|
|
1954
|
+
args[key] = None
|
|
1955
|
+
|
|
1956
|
+
# if brainmaskincludespec is set, set initregressorinclude, corrmaskinclude, refineinclude, and offsetinclude to it.
|
|
1957
|
+
brainmasks = ["initregressor", "corrmask", "refine", "offset"]
|
|
1928
1958
|
if args["brainmaskincludespec"] is not None:
|
|
1929
1959
|
(
|
|
1930
1960
|
args["brainmaskincludename"],
|
|
@@ -1934,12 +1964,22 @@ def process_args(inputargs=None):
|
|
|
1934
1964
|
)
|
|
1935
1965
|
if not os.path.isfile(args["brainmaskincludename"]):
|
|
1936
1966
|
raise FileNotFoundError(f"file {args['brainmaskincludename']} does not exist.")
|
|
1967
|
+
for masktype in brainmasks:
|
|
1968
|
+
(
|
|
1969
|
+
args[f"{masktype}includename"],
|
|
1970
|
+
args[f"{masktype}includevals"],
|
|
1971
|
+
) = (
|
|
1972
|
+
args["brainmaskincludename"],
|
|
1973
|
+
args["brainmaskincludevals"],
|
|
1974
|
+
)
|
|
1975
|
+
print(f"setting {masktype}include mask to gray matter mask")
|
|
1937
1976
|
else:
|
|
1938
1977
|
args["brainmaskincludename"] = None
|
|
1939
1978
|
args["brainmaskincludevals"] = None
|
|
1940
1979
|
|
|
1941
|
-
# if graymatterincludespec is set, set
|
|
1942
|
-
graymasks = ["
|
|
1980
|
+
# if graymatterincludespec is set, set initregressorinclude, offsetinclude to it.
|
|
1981
|
+
# graymasks = ["initregressor", "offset"]
|
|
1982
|
+
graymasks = ["initregressor"]
|
|
1943
1983
|
if args["graymatterincludespec"] is not None:
|
|
1944
1984
|
(
|
|
1945
1985
|
args["graymatterincludename"],
|
|
@@ -1961,9 +2001,6 @@ def process_args(inputargs=None):
|
|
|
1961
2001
|
else:
|
|
1962
2002
|
args["graymatterincludename"] = None
|
|
1963
2003
|
args["graymatterincludevals"] = None
|
|
1964
|
-
for masktype in graymasks:
|
|
1965
|
-
args[f"{masktype}includename"] = None
|
|
1966
|
-
args[f"{masktype}includevals"] = None
|
|
1967
2004
|
|
|
1968
2005
|
if args["whitematterincludespec"] is not None:
|
|
1969
2006
|
(
|
|
@@ -1976,26 +2013,47 @@ def process_args(inputargs=None):
|
|
|
1976
2013
|
args["whitematterincludename"] = None
|
|
1977
2014
|
args["whitematterincludevals"] = None
|
|
1978
2015
|
|
|
1979
|
-
if args["
|
|
2016
|
+
if args["csfincludespec"] is not None:
|
|
1980
2017
|
(
|
|
1981
|
-
args["
|
|
1982
|
-
args["
|
|
2018
|
+
args["csfincludename"],
|
|
2019
|
+
args["csfincludevals"],
|
|
1983
2020
|
) = tide_io.processnamespec(
|
|
1984
|
-
args["
|
|
2021
|
+
args["csfincludespec"], "Including voxels where ", "in CSF mask."
|
|
1985
2022
|
)
|
|
2023
|
+
else:
|
|
2024
|
+
args["csfincludename"] = None
|
|
2025
|
+
args["csfincludevals"] = None
|
|
1986
2026
|
|
|
1987
|
-
|
|
2027
|
+
# individual mask processing (including overrides)
|
|
2028
|
+
if args["corrmaskincludespec"] is not None:
|
|
1988
2029
|
(
|
|
1989
|
-
args["
|
|
1990
|
-
args["
|
|
2030
|
+
args["corrmaskincludename"],
|
|
2031
|
+
args["corrmaskincludevals"],
|
|
1991
2032
|
) = tide_io.processnamespec(
|
|
1992
|
-
args["
|
|
2033
|
+
args["corrmaskincludespec"],
|
|
2034
|
+
"Including voxels where ",
|
|
2035
|
+
"in correlation calculations.",
|
|
2036
|
+
)
|
|
2037
|
+
|
|
2038
|
+
if args["initregressorincludespec"] is not None:
|
|
2039
|
+
(
|
|
2040
|
+
args["initregressorincludename"],
|
|
2041
|
+
args["initregressorincludevals"],
|
|
2042
|
+
) = tide_io.processnamespec(
|
|
2043
|
+
args["initregressorincludespec"],
|
|
2044
|
+
"Including voxels where ",
|
|
2045
|
+
"in initial regressor calculation.",
|
|
2046
|
+
)
|
|
2047
|
+
|
|
2048
|
+
if args["initregressorexcludespec"] is not None:
|
|
2049
|
+
(
|
|
2050
|
+
args["initregressorexcludename"],
|
|
2051
|
+
args["initregressorexcludevals"],
|
|
2052
|
+
) = tide_io.processnamespec(
|
|
2053
|
+
args["initregressorexcludespec"],
|
|
1993
2054
|
"Excluding voxels where ",
|
|
1994
|
-
"from
|
|
2055
|
+
"from initial regressor calculation.",
|
|
1995
2056
|
)
|
|
1996
|
-
else:
|
|
1997
|
-
args["globalmeanexcludename"] = None
|
|
1998
|
-
args["globalmeanexcludevals"] = None
|
|
1999
2057
|
|
|
2000
2058
|
if args["refineincludespec"] is not None:
|
|
2001
2059
|
(
|
|
@@ -2004,9 +2062,6 @@ def process_args(inputargs=None):
|
|
|
2004
2062
|
) = tide_io.processnamespec(
|
|
2005
2063
|
args["refineincludespec"], "Including voxels where ", "in refinement."
|
|
2006
2064
|
)
|
|
2007
|
-
else:
|
|
2008
|
-
args["refineincludename"] = None
|
|
2009
|
-
args["refineincludevals"] = None
|
|
2010
2065
|
|
|
2011
2066
|
if args["refineexcludespec"] is not None:
|
|
2012
2067
|
(
|
|
@@ -2015,9 +2070,6 @@ def process_args(inputargs=None):
|
|
|
2015
2070
|
) = tide_io.processnamespec(
|
|
2016
2071
|
args["refineexcludespec"], "Excluding voxels where ", "from refinement."
|
|
2017
2072
|
)
|
|
2018
|
-
else:
|
|
2019
|
-
args["refineexcludename"] = None
|
|
2020
|
-
args["refineexcludevals"] = None
|
|
2021
2073
|
|
|
2022
2074
|
if args["offsetincludespec"] is not None:
|
|
2023
2075
|
(
|
|
@@ -2034,9 +2086,6 @@ def process_args(inputargs=None):
|
|
|
2034
2086
|
) = tide_io.processnamespec(
|
|
2035
2087
|
args["offsetexcludespec"], "Excluding voxels where ", "from offset calculation."
|
|
2036
2088
|
)
|
|
2037
|
-
else:
|
|
2038
|
-
args["offsetexcludename"] = None
|
|
2039
|
-
args["offsetexcludevals"] = None
|
|
2040
2089
|
|
|
2041
2090
|
# motion processing
|
|
2042
2091
|
if args["motionfilespec"] is not None:
|
|
@@ -2091,7 +2140,7 @@ def process_args(inputargs=None):
|
|
|
2091
2140
|
args["outputlevel"] = "min"
|
|
2092
2141
|
args["dolinfitfilt"] = False
|
|
2093
2142
|
|
|
2094
|
-
if args["
|
|
2143
|
+
if args["initregressorpreselect"]:
|
|
2095
2144
|
LGR.warning('Using "globalpreselect" analysis mode. Overriding any affected arguments.')
|
|
2096
2145
|
args["passes"] = 1
|
|
2097
2146
|
args["despeckle_passes"] = 0
|
|
@@ -2198,7 +2247,7 @@ def process_args(inputargs=None):
|
|
|
2198
2247
|
args["territorymapname"],
|
|
2199
2248
|
args["territorymapincludevals"],
|
|
2200
2249
|
) = tide_io.processnamespec(
|
|
2201
|
-
args["territorymap"], "Including voxels where ", "in
|
|
2250
|
+
args["territorymap"], "Including voxels where ", "in initial regressor calculation."
|
|
2202
2251
|
)
|
|
2203
2252
|
else:
|
|
2204
2253
|
args["territorymapname"] = None
|
|
@@ -28,6 +28,7 @@ import numpy as np
|
|
|
28
28
|
|
|
29
29
|
import rapidtide.filter as tide_filt
|
|
30
30
|
import rapidtide.io as tide_io
|
|
31
|
+
import rapidtide.maskutil as tide_mask
|
|
31
32
|
import rapidtide.miscmath as tide_math
|
|
32
33
|
import rapidtide.multiproc as tide_multiproc
|
|
33
34
|
import rapidtide.refinedelay as tide_refinedelay
|
|
@@ -802,16 +803,138 @@ def retroregress(args):
|
|
|
802
803
|
"message3": "voxels",
|
|
803
804
|
},
|
|
804
805
|
)
|
|
805
|
-
# finalrawvariance = tide_math.imagevariance(filtereddata, None, 1.0 / fmritr)
|
|
806
806
|
finalvariance = tide_math.imagevariance(filtereddata, theprefilter, 1.0 / fmritr)
|
|
807
807
|
|
|
808
808
|
divlocs = np.where(finalvariance > 0.0)
|
|
809
809
|
varchange = initialvariance * 0.0
|
|
810
810
|
varchange[divlocs] = 100.0 * (finalvariance[divlocs] / initialvariance[divlocs] - 1.0)
|
|
811
811
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
812
|
+
# save regional timecourses if masks are defined
|
|
813
|
+
# read in the anatomic masks
|
|
814
|
+
anatomiclist = [
|
|
815
|
+
["brainmaskincludename", "brainmaskincludevals", "brainmask"],
|
|
816
|
+
["graymatterincludename", "graymatterincludevals", "graymattermask"],
|
|
817
|
+
["whitematterincludename", "whitematterincludevals", "whitemattermask"],
|
|
818
|
+
["csfincludename", "csfincludevals", "csfmask"],
|
|
819
|
+
]
|
|
820
|
+
anatomicmasks = []
|
|
821
|
+
for thisanatomic in anatomiclist:
|
|
822
|
+
if therunoptions[thisanatomic[0]] is not None:
|
|
823
|
+
anatomicmasks.append(
|
|
824
|
+
tide_mask.readamask(
|
|
825
|
+
therunoptions[thisanatomic[0]],
|
|
826
|
+
theinputdata.nim_hdr,
|
|
827
|
+
xsize,
|
|
828
|
+
istext=(theinputdata.filetype == "text"),
|
|
829
|
+
valslist=therunoptions[thisanatomic[1]],
|
|
830
|
+
maskname=thisanatomic[2],
|
|
831
|
+
tolerance=therunoptions["spatialtolerance"],
|
|
832
|
+
debug=args.focaldebug,
|
|
833
|
+
)
|
|
834
|
+
)
|
|
835
|
+
anatomicmasks[-1] = np.uint16(np.where(anatomicmasks[-1] > 0.1, 1, 0))
|
|
836
|
+
else:
|
|
837
|
+
anatomicmasks.append(None)
|
|
838
|
+
brainmask = anatomicmasks[0]
|
|
839
|
+
graymask = anatomicmasks[1]
|
|
840
|
+
whitemask = anatomicmasks[2]
|
|
841
|
+
csfmask = anatomicmasks[3]
|
|
842
|
+
|
|
843
|
+
"""if internalinitregressorincludemask is not None:
|
|
844
|
+
thisincludemask = internalinitregressorincludemask[validvoxels]
|
|
845
|
+
else:
|
|
846
|
+
thisincludemask = None
|
|
847
|
+
if internalinitregressorexcludemask is not None:
|
|
848
|
+
thisexcludemask = internalinitregressorexcludemask[validvoxels]
|
|
849
|
+
else:
|
|
850
|
+
thisexcludemask = None
|
|
851
|
+
|
|
852
|
+
meanvec, meanmask = tide_mask.saveregionaltimeseries(
|
|
853
|
+
"initial regressor",
|
|
854
|
+
"startregressormask",
|
|
855
|
+
filtereddata,
|
|
856
|
+
thisincludemask,
|
|
857
|
+
1.0 / fmritr,
|
|
858
|
+
outputname,
|
|
859
|
+
initfile=True,
|
|
860
|
+
excludemask=thisexcludemask,
|
|
861
|
+
filedesc="regionalpostfilter",
|
|
862
|
+
suffix="",
|
|
863
|
+
debug=args.debug,
|
|
864
|
+
)"""
|
|
865
|
+
# reformat the anatomic masks, if they exist
|
|
866
|
+
if brainmask is None:
|
|
867
|
+
invbrainmask = None
|
|
868
|
+
|
|
869
|
+
internalbrainmask = None
|
|
870
|
+
internalinvbrainmask = None
|
|
871
|
+
else:
|
|
872
|
+
invbrainmask = 1 - brainmask
|
|
873
|
+
internalbrainmask = brainmask.reshape((numspatiallocs))
|
|
874
|
+
internalinvbrainmask = invbrainmask.reshape((numspatiallocs))
|
|
875
|
+
if graymask is None:
|
|
876
|
+
internalgraymask = None
|
|
877
|
+
else:
|
|
878
|
+
internalgraymask = graymask.reshape((numspatiallocs))
|
|
879
|
+
if whitemask is None:
|
|
880
|
+
internalwhitemask = None
|
|
881
|
+
else:
|
|
882
|
+
internalwhitemask = whitemask.reshape((numspatiallocs))
|
|
883
|
+
if csfmask is None:
|
|
884
|
+
internalcsfmask = None
|
|
885
|
+
else:
|
|
886
|
+
internalcsfmask = csfmask.reshape((numspatiallocs))
|
|
887
|
+
if brainmask is not None:
|
|
888
|
+
brainvec, dummy = tide_mask.saveregionaltimeseries(
|
|
889
|
+
"whole brain",
|
|
890
|
+
"brain",
|
|
891
|
+
filtereddata,
|
|
892
|
+
internalbrainmask[validvoxels],
|
|
893
|
+
1.0 / fmritr,
|
|
894
|
+
outputname,
|
|
895
|
+
filedesc="regionalpostfilter",
|
|
896
|
+
suffix="",
|
|
897
|
+
debug=args.debug,
|
|
898
|
+
)
|
|
899
|
+
if graymask is not None:
|
|
900
|
+
grayvec, dummy = tide_mask.saveregionaltimeseries(
|
|
901
|
+
"gray matter",
|
|
902
|
+
"GM",
|
|
903
|
+
filtereddata,
|
|
904
|
+
internalgraymask[validvoxels],
|
|
905
|
+
1.0 / fmritr,
|
|
906
|
+
outputname,
|
|
907
|
+
excludemask=internalinvbrainmask[validvoxels],
|
|
908
|
+
filedesc="regionalpostfilter",
|
|
909
|
+
suffix="",
|
|
910
|
+
debug=args.debug,
|
|
911
|
+
)
|
|
912
|
+
if whitemask is not None:
|
|
913
|
+
whitevec, dummy = tide_mask.saveregionaltimeseries(
|
|
914
|
+
"white matter",
|
|
915
|
+
"WM",
|
|
916
|
+
filtereddata,
|
|
917
|
+
internalwhitemask[validvoxels],
|
|
918
|
+
1.0 / fmritr,
|
|
919
|
+
outputname,
|
|
920
|
+
excludemask=internalinvbrainmask[validvoxels],
|
|
921
|
+
filedesc="regionalpostfilter",
|
|
922
|
+
suffix="",
|
|
923
|
+
debug=args.debug,
|
|
924
|
+
)
|
|
925
|
+
if csfmask is not None:
|
|
926
|
+
grayvec, dummy = tide_mask.saveregionaltimeseries(
|
|
927
|
+
"CSF",
|
|
928
|
+
"CSF",
|
|
929
|
+
filtereddata,
|
|
930
|
+
internalcsfmask[validvoxels],
|
|
931
|
+
1.0 / fmritr,
|
|
932
|
+
outputname,
|
|
933
|
+
excludemask=internalinvbrainmask[validvoxels],
|
|
934
|
+
filedesc="regionalpostfilter",
|
|
935
|
+
suffix="",
|
|
936
|
+
debug=args.debug,
|
|
937
|
+
)
|
|
815
938
|
|
|
816
939
|
# save outputs
|
|
817
940
|
TimingLGR.info("Starting output save")
|
|
@@ -899,8 +1022,20 @@ def retroregress(args):
|
|
|
899
1022
|
"second",
|
|
900
1023
|
"Lag time in seconds used for calculation",
|
|
901
1024
|
),
|
|
902
|
-
(
|
|
903
|
-
|
|
1025
|
+
(
|
|
1026
|
+
corrmask_valid,
|
|
1027
|
+
"corrfitREAD",
|
|
1028
|
+
"mask",
|
|
1029
|
+
None,
|
|
1030
|
+
"Correlation mask used for calculation",
|
|
1031
|
+
),
|
|
1032
|
+
(
|
|
1033
|
+
procmask_valid,
|
|
1034
|
+
"processedREAD",
|
|
1035
|
+
"mask",
|
|
1036
|
+
None,
|
|
1037
|
+
"Processed mask used for calculation",
|
|
1038
|
+
),
|
|
904
1039
|
]
|
|
905
1040
|
if args.savenormalsLFOfiltfiles:
|
|
906
1041
|
if args.regressderivs > 0 or args.refinedelay:
|
|
@@ -1109,33 +1244,35 @@ def retroregress(args):
|
|
|
1109
1244
|
)
|
|
1110
1245
|
TimingLGR.info("Filtering for maxcorralt calculation complete")
|
|
1111
1246
|
TimingLGR.info("GLM for maxcorralt calculation start")
|
|
1112
|
-
voxelsprocessed_regressionfilt, regressorset, evset =
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1247
|
+
voxelsprocessed_regressionfilt, regressorset, evset = (
|
|
1248
|
+
tide_regressfrommaps.regressfrommaps(
|
|
1249
|
+
fmri_data_valid,
|
|
1250
|
+
validvoxels,
|
|
1251
|
+
initial_fmri_x,
|
|
1252
|
+
lagstouse_valid,
|
|
1253
|
+
corrmask_valid,
|
|
1254
|
+
genlagtc,
|
|
1255
|
+
mode,
|
|
1256
|
+
outputname,
|
|
1257
|
+
oversamptr,
|
|
1258
|
+
sLFOfitmean,
|
|
1259
|
+
rvalue,
|
|
1260
|
+
r2value,
|
|
1261
|
+
fitNorm[:, : args.regressderivs + 1],
|
|
1262
|
+
fitcoeff[:, : args.regressderivs + 1],
|
|
1263
|
+
movingsignal,
|
|
1264
|
+
lagtc,
|
|
1265
|
+
filtereddata,
|
|
1266
|
+
LGR,
|
|
1267
|
+
TimingLGR,
|
|
1268
|
+
threshval,
|
|
1269
|
+
args.saveminimumsLFOfiltfiles,
|
|
1270
|
+
nprocs_makelaggedtcs=args.nprocs,
|
|
1271
|
+
nprocs_regressionfilt=args.nprocs,
|
|
1272
|
+
regressderivs=args.regressderivs,
|
|
1273
|
+
showprogressbar=args.showprogressbar,
|
|
1274
|
+
debug=args.debug,
|
|
1275
|
+
)
|
|
1139
1276
|
)
|
|
1140
1277
|
TimingLGR.info(
|
|
1141
1278
|
"GLM for maxcorralt calculation done",
|
|
@@ -1241,7 +1378,6 @@ def retroregress(args):
|
|
|
1241
1378
|
debug=args.debug,
|
|
1242
1379
|
)
|
|
1243
1380
|
|
|
1244
|
-
|
|
1245
1381
|
# write the runoptions file
|
|
1246
1382
|
print("writing runoptions")
|
|
1247
1383
|
if args.refinedelay:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rapidtide
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.3
|
|
4
4
|
Summary: Tools for performing correlation analysis on fMRI data.
|
|
5
5
|
Author: Taylor Salo, Daniel M. Drucker, Ph.D., Jeffrey N Stout, Yaroslav O. Halchenko, Derek Monroe
|
|
6
6
|
Author-email: "Blaise deB. Frederick" <blaise.frederick@gmail.com>
|