rapidtide 3.0a12__py3-none-any.whl → 3.0a14__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.
- cloud/gmscalc-HCPYA +1 -1
- cloud/rapidtide-HCPYA +3 -3
- rapidtide/Colortables.py +10 -10
- rapidtide/DerivativeDelay.py +213 -0
- rapidtide/{Refiner.py → RegressorRefiner.py} +1 -1
- rapidtide/__init__.py +2 -1
- rapidtide/_version.py +1 -1
- rapidtide/data/examples/src/test_mlregressallt.py +32 -17
- rapidtide/data/examples/src/testalign +1 -1
- rapidtide/data/examples/src/testboth +1 -1
- rapidtide/data/examples/src/testcifti +11 -0
- rapidtide/data/examples/src/testdelayvar +14 -0
- rapidtide/data/examples/src/testfmri +1 -0
- rapidtide/data/examples/src/testglmfilt +8 -6
- rapidtide/data/examples/src/testhappy +1 -1
- rapidtide/data/examples/src/testnewrefine +11 -11
- rapidtide/data/examples/src/testnoiseamp +2 -2
- rapidtide/data/examples/src/testretro +16 -7
- rapidtide/data/examples/src/testretrolagtcs +1 -1
- rapidtide/dlfilter.py +0 -1
- rapidtide/fit.py +41 -9
- rapidtide/happy_supportfuncs.py +5 -0
- rapidtide/io.py +13 -2
- rapidtide/{glmpass.py → linfitfiltpass.py} +23 -19
- rapidtide/makelaggedtcs.py +8 -5
- rapidtide/multiproc.py +8 -11
- rapidtide/refinedelay.py +234 -109
- rapidtide/resample.py +3 -0
- rapidtide/scripts/{retroglm.py → delayvar.py} +2 -2
- rapidtide/scripts/{glmfilt.py → linfitfilt.py} +2 -2
- rapidtide/scripts/retroregress.py +28 -0
- rapidtide/scripts/stupidramtricks.py +9 -7
- rapidtide/simfuncfit.py +1 -1
- rapidtide/tests/cleanposttest +21 -0
- rapidtide/tests/test_delayestimation.py +3 -3
- rapidtide/tests/test_fastresampler.py +1 -2
- rapidtide/tests/test_fullrunhappy_v1.py +14 -6
- rapidtide/tests/test_fullrunhappy_v2.py +17 -9
- rapidtide/tests/test_fullrunhappy_v3.py +16 -8
- rapidtide/tests/test_fullrunhappy_v4.py +16 -8
- rapidtide/tests/test_fullrunhappy_v5.py +14 -6
- rapidtide/tests/test_fullrunrapidtide_v1.py +20 -12
- rapidtide/tests/test_fullrunrapidtide_v2.py +21 -13
- rapidtide/tests/test_fullrunrapidtide_v3.py +15 -7
- rapidtide/tests/test_fullrunrapidtide_v4.py +14 -7
- rapidtide/tests/test_fullrunrapidtide_v5.py +13 -5
- rapidtide/tests/test_fullrunrapidtide_v6.py +34 -26
- rapidtide/tests/{test_glmpass.py → test_linfitfiltpass.py} +9 -9
- rapidtide/tests/test_motionregress.py +3 -3
- rapidtide/tests/test_refinedelay.py +14 -12
- rapidtide/tidepoolTemplate_alt_qt6.py +172 -45
- rapidtide/tidepoolTemplate_big_qt6.py +196 -53
- rapidtide/tidepoolTemplate_qt6.py +150 -39
- rapidtide/workflows/atlasaverage.py +40 -12
- rapidtide/workflows/delayvar.py +1136 -0
- rapidtide/workflows/happy.py +37 -11
- rapidtide/workflows/happy_parser.py +4 -4
- rapidtide/workflows/{glmfilt.py → linfitfilt.py} +4 -4
- rapidtide/workflows/rapidtide.py +246 -178
- rapidtide/workflows/rapidtide_parser.py +116 -101
- rapidtide/workflows/{glmfrommaps.py → regressfrommaps.py} +30 -26
- rapidtide/workflows/retrolagtcs.py +13 -12
- rapidtide/workflows/{retroglm.py → retroregress.py} +182 -141
- {rapidtide-3.0a12.dist-info → rapidtide-3.0a14.dist-info}/METADATA +3 -2
- {rapidtide-3.0a12.dist-info → rapidtide-3.0a14.dist-info}/RECORD +69 -64
- {rapidtide-3.0a12.dist-info → rapidtide-3.0a14.dist-info}/WHEEL +1 -1
- {rapidtide-3.0a12.dist-info → rapidtide-3.0a14.dist-info}/entry_points.txt +3 -2
- rapidtide/data/examples/src/testoutputsize +0 -45
- {rapidtide-3.0a12.dist-info → rapidtide-3.0a14.dist-info/licenses}/LICENSE +0 -0
- {rapidtide-3.0a12.dist-info → rapidtide-3.0a14.dist-info}/top_level.txt +0 -0
|
@@ -70,7 +70,6 @@ DEFAULT_MAXPASSES = 15
|
|
|
70
70
|
DEFAULT_REFINE_TYPE = "pca"
|
|
71
71
|
DEFAULT_INTERPTYPE = "univariate"
|
|
72
72
|
DEFAULT_WINDOW_TYPE = "hamming"
|
|
73
|
-
DEFAULT_GLOBALMASK_METHOD = "mean"
|
|
74
73
|
DEFAULT_GLOBALSIGNAL_METHOD = "sum"
|
|
75
74
|
DEFAULT_CORRWEIGHTING = "phat"
|
|
76
75
|
DEFAULT_CORRTYPE = "linear"
|
|
@@ -79,8 +78,8 @@ DEFAULT_PEAKFIT_TYPE = "gauss"
|
|
|
79
78
|
DEFAULT_REFINE_PRENORM = "var"
|
|
80
79
|
DEFAULT_REFINE_WEIGHTING = "None"
|
|
81
80
|
DEFAULT_REFINE_PCACOMPONENTS = 0.8
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
DEFAULT_REGRESSIONFILTDERIVS = 0
|
|
82
|
+
DEFAULT_REFINEREGRESSDERIVS = 1
|
|
84
83
|
|
|
85
84
|
DEFAULT_DENOISING_LAGMIN = -10.0
|
|
86
85
|
DEFAULT_DENOISING_LAGMAX = 10.0
|
|
@@ -160,7 +159,7 @@ def _get_parser():
|
|
|
160
159
|
f"sets searchrange=({DEFAULT_DENOISING_LAGMIN}, {DEFAULT_DENOISING_LAGMAX}), "
|
|
161
160
|
f"passes={DEFAULT_DENOISING_PASSES}, despeckle_passes={DEFAULT_DENOISING_DESPECKLE_PASSES}, "
|
|
162
161
|
f"refineoffset=True, peakfittype={DEFAULT_DENOISING_PEAKFITTYPE}, "
|
|
163
|
-
f"gausssigma={DEFAULT_DENOISING_SPATIALFILT}, nofitfilt=True,
|
|
162
|
+
f"gausssigma={DEFAULT_DENOISING_SPATIALFILT}, nofitfilt=True, dolinfitfilt=True. "
|
|
164
163
|
"Any of these options can be overridden with the appropriate "
|
|
165
164
|
"additional arguments."
|
|
166
165
|
),
|
|
@@ -176,7 +175,7 @@ def _get_parser():
|
|
|
176
175
|
f"passes={DEFAULT_DELAYMAPPING_PASSES}, despeckle_passes={DEFAULT_DELAYMAPPING_DESPECKLE_PASSES}, "
|
|
177
176
|
f"gausssigma={DEFAULT_DELAYMAPPING_SPATIALFILT}, "
|
|
178
177
|
"refineoffset=True, refinedelay=True, outputlevel='normal', "
|
|
179
|
-
"
|
|
178
|
+
"dolinfitfilt=False. "
|
|
180
179
|
"Any of these options can be overridden with the appropriate "
|
|
181
180
|
"additional arguments."
|
|
182
181
|
),
|
|
@@ -193,7 +192,7 @@ def _get_parser():
|
|
|
193
192
|
f"passes=1, despeckle_passes={DEFAULT_CVRMAPPING_DESPECKLE_PASSES}, "
|
|
194
193
|
f"searchrange=({DEFAULT_CVRMAPPING_LAGMIN}, {DEFAULT_CVRMAPPING_LAGMAX}), "
|
|
195
194
|
f"filterfreqs=({DEFAULT_CVRMAPPING_FILTER_LOWERPASS}, {DEFAULT_CVRMAPPING_FILTER_UPPERPASS}), "
|
|
196
|
-
"and calculates a voxelwise
|
|
195
|
+
"and calculates a voxelwise regression fit using the optimally delayed "
|
|
197
196
|
"input regressor and the percent normalized, demeaned BOLD data as inputs. This map is output as "
|
|
198
197
|
"(XXX_desc-CVR_map.nii.gz). If no input regressor is supplied, this will generate an error. "
|
|
199
198
|
"These options can be overridden with the appropriate additional arguments."
|
|
@@ -207,7 +206,7 @@ def _get_parser():
|
|
|
207
206
|
help=(
|
|
208
207
|
"Treat this run as an initial pass to locate good candidate voxels for global mean "
|
|
209
208
|
"regressor generation. This sets: passes=1, despecklepasses=0, "
|
|
210
|
-
"refinedespeckle=False, outputlevel='normal',
|
|
209
|
+
"refinedespeckle=False, outputlevel='normal', dolinfitfilt=False, saveintermediatemaps=False."
|
|
211
210
|
),
|
|
212
211
|
default=False,
|
|
213
212
|
)
|
|
@@ -240,7 +239,7 @@ def _get_parser():
|
|
|
240
239
|
action="store_true",
|
|
241
240
|
help=(
|
|
242
241
|
"This is a NIRS analysis - this is a macro that "
|
|
243
|
-
"sets nothresh, refineprenorm=var, ampthresh=0.7, and "
|
|
242
|
+
"sets nothresh, dataiszeromean=True, refineprenorm=var, ampthresh=0.7, and "
|
|
244
243
|
"lagminthresh=0.1. "
|
|
245
244
|
),
|
|
246
245
|
default=False,
|
|
@@ -382,6 +381,17 @@ def _get_parser():
|
|
|
382
381
|
),
|
|
383
382
|
default=False,
|
|
384
383
|
)
|
|
384
|
+
preproc.add_argument(
|
|
385
|
+
"--dataiszeromean",
|
|
386
|
+
dest="dataiszeromean",
|
|
387
|
+
action="store_true",
|
|
388
|
+
help=(
|
|
389
|
+
"Assume that the fMRI data is zero mean (this will be the case if you used AFNI for preprocessing). "
|
|
390
|
+
"This affects how masks are generated. Rapidtide will attempt to detect this, but set explicitly "
|
|
391
|
+
"if you know this is the case."
|
|
392
|
+
),
|
|
393
|
+
default=False,
|
|
394
|
+
)
|
|
385
395
|
|
|
386
396
|
# Add filter options
|
|
387
397
|
pf.addfilteropts(parser, filtertarget="data and regressors", details=True)
|
|
@@ -444,19 +454,6 @@ def _get_parser():
|
|
|
444
454
|
),
|
|
445
455
|
default=False,
|
|
446
456
|
)
|
|
447
|
-
preproc.add_argument(
|
|
448
|
-
"--globalmaskmethod",
|
|
449
|
-
dest="globalmaskmethod",
|
|
450
|
-
action="store",
|
|
451
|
-
type=str,
|
|
452
|
-
choices=["mean", "variance"],
|
|
453
|
-
help=(
|
|
454
|
-
"Select whether to use timecourse mean or variance to "
|
|
455
|
-
"mask voxels prior to generating global mean. "
|
|
456
|
-
f'Default is "{DEFAULT_GLOBALMASK_METHOD}".'
|
|
457
|
-
),
|
|
458
|
-
default=DEFAULT_GLOBALMASK_METHOD,
|
|
459
|
-
)
|
|
460
457
|
preproc.add_argument(
|
|
461
458
|
"--globalmeaninclude",
|
|
462
459
|
dest="globalmeanincludespec",
|
|
@@ -1065,15 +1062,6 @@ def _get_parser():
|
|
|
1065
1062
|
help=("Disables selecting the leftmost delay peak when setting the refine offset."),
|
|
1066
1063
|
default=True,
|
|
1067
1064
|
)
|
|
1068
|
-
reg_ref.add_argument(
|
|
1069
|
-
"--pickleft",
|
|
1070
|
-
dest="dummy",
|
|
1071
|
-
action="store_true",
|
|
1072
|
-
help=(
|
|
1073
|
-
"DEPRECATED. pickleft is now on by default. Use 'nopickleft' to disable it instead."
|
|
1074
|
-
),
|
|
1075
|
-
default=True,
|
|
1076
|
-
)
|
|
1077
1065
|
reg_ref.add_argument(
|
|
1078
1066
|
"--pickleftthresh",
|
|
1079
1067
|
dest="pickleftthresh",
|
|
@@ -1167,22 +1155,22 @@ def _get_parser():
|
|
|
1167
1155
|
default=DEFAULT_MAXPASSES,
|
|
1168
1156
|
)
|
|
1169
1157
|
|
|
1170
|
-
#
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
"--
|
|
1174
|
-
dest="
|
|
1158
|
+
# sLFO noise removal options
|
|
1159
|
+
slfofilt = parser.add_argument_group("sLFO noise removal options")
|
|
1160
|
+
slfofilt.add_argument(
|
|
1161
|
+
"--nodenoise",
|
|
1162
|
+
dest="dolinfitfilt",
|
|
1175
1163
|
action="store_false",
|
|
1176
1164
|
help=(
|
|
1177
|
-
"Turn off
|
|
1165
|
+
"Turn off regression filtering to remove delayed "
|
|
1178
1166
|
"regressor from each voxel (disables output of "
|
|
1179
1167
|
"fitNorm)."
|
|
1180
1168
|
),
|
|
1181
1169
|
default=True,
|
|
1182
1170
|
)
|
|
1183
|
-
|
|
1184
|
-
"--
|
|
1185
|
-
dest="
|
|
1171
|
+
slfofilt.add_argument(
|
|
1172
|
+
"--denoisesourcefile",
|
|
1173
|
+
dest="denoisesourcefile",
|
|
1186
1174
|
action="store",
|
|
1187
1175
|
type=lambda x: pf.is_valid_file(parser, x),
|
|
1188
1176
|
metavar="FILE",
|
|
@@ -1193,48 +1181,39 @@ def _get_parser():
|
|
|
1193
1181
|
),
|
|
1194
1182
|
default=None,
|
|
1195
1183
|
)
|
|
1196
|
-
|
|
1184
|
+
slfofilt.add_argument(
|
|
1197
1185
|
"--preservefiltering",
|
|
1198
1186
|
dest="preservefiltering",
|
|
1199
1187
|
action="store_true",
|
|
1200
|
-
help="Don't reread data prior to performing
|
|
1188
|
+
help="Don't reread data prior to performing sLFO filtering.",
|
|
1201
1189
|
default=False,
|
|
1202
1190
|
)
|
|
1203
|
-
|
|
1204
|
-
"--
|
|
1205
|
-
dest="
|
|
1191
|
+
slfofilt.add_argument(
|
|
1192
|
+
"--regressderivs",
|
|
1193
|
+
dest="regressderivs",
|
|
1206
1194
|
action="store",
|
|
1207
1195
|
type=lambda x: pf.is_int(parser, x, minval=0),
|
|
1208
1196
|
metavar="NDERIVS",
|
|
1209
1197
|
help=(
|
|
1210
|
-
f"When doing final
|
|
1198
|
+
f"When doing final sLFO filtering, include derivatives up to NDERIVS order. Default is {DEFAULT_REGRESSIONFILTDERIVS}"
|
|
1211
1199
|
),
|
|
1212
|
-
default=
|
|
1200
|
+
default=DEFAULT_REGRESSIONFILTDERIVS,
|
|
1213
1201
|
)
|
|
1214
|
-
|
|
1202
|
+
slfofilt.add_argument(
|
|
1215
1203
|
"--norefinedelay",
|
|
1216
1204
|
dest="refinedelay",
|
|
1217
1205
|
action="store_false",
|
|
1218
|
-
help=("Do not calculate a refined delay map using
|
|
1206
|
+
help=("Do not calculate a refined delay map using sLFO regression information."),
|
|
1219
1207
|
default=True,
|
|
1220
1208
|
)
|
|
1221
|
-
|
|
1222
|
-
"--refinedelay",
|
|
1223
|
-
dest="dummy",
|
|
1224
|
-
action="store_true",
|
|
1225
|
-
help=(
|
|
1226
|
-
"Calculate a refined delay map using GLM information. ***DEPRECATED*** - this is now on by default."
|
|
1227
|
-
),
|
|
1228
|
-
default=True,
|
|
1229
|
-
)
|
|
1230
|
-
glm.add_argument(
|
|
1209
|
+
slfofilt.add_argument(
|
|
1231
1210
|
"--nofilterwithrefineddelay",
|
|
1232
1211
|
dest="filterwithrefineddelay",
|
|
1233
1212
|
action="store_false",
|
|
1234
|
-
help=("Do not use the refined delay in
|
|
1213
|
+
help=("Do not use the refined delay in sLFO filter."),
|
|
1235
1214
|
default=True,
|
|
1236
1215
|
)
|
|
1237
|
-
|
|
1216
|
+
slfofilt.add_argument(
|
|
1238
1217
|
"--delaypatchthresh",
|
|
1239
1218
|
dest="delaypatchthresh",
|
|
1240
1219
|
action="store",
|
|
@@ -1246,7 +1225,7 @@ def _get_parser():
|
|
|
1246
1225
|
),
|
|
1247
1226
|
default=DEFAULT_PATCHTHRESH,
|
|
1248
1227
|
)
|
|
1249
|
-
|
|
1228
|
+
slfofilt.add_argument(
|
|
1250
1229
|
"--delayoffsetspatialfilt",
|
|
1251
1230
|
dest="delayoffsetgausssigma",
|
|
1252
1231
|
action="store",
|
|
@@ -1271,7 +1250,7 @@ def _get_parser():
|
|
|
1271
1250
|
choices=["min", "less", "normal", "more", "max"],
|
|
1272
1251
|
help=(
|
|
1273
1252
|
"The level of file output produced. 'min' produces only absolutely essential files, 'less' adds in "
|
|
1274
|
-
"the
|
|
1253
|
+
"the sLFO filtered data (rather than just filter efficacy metrics), 'normal' saves what you "
|
|
1275
1254
|
"would typically want around for interactive data exploration, "
|
|
1276
1255
|
"'more' adds files that are sometimes useful, and 'max' outputs anything you might possibly want. "
|
|
1277
1256
|
"Selecting 'max' will produce ~3x your input datafile size as output. "
|
|
@@ -1279,16 +1258,6 @@ def _get_parser():
|
|
|
1279
1258
|
),
|
|
1280
1259
|
default=DEFAULT_OUTPUTLEVEL,
|
|
1281
1260
|
)
|
|
1282
|
-
output.add_argument(
|
|
1283
|
-
"--nolimitoutput",
|
|
1284
|
-
dest="limitoutput",
|
|
1285
|
-
action="store_false",
|
|
1286
|
-
help=(
|
|
1287
|
-
"Save some of the large and rarely used files. "
|
|
1288
|
-
"NB: THIS IS NOW DEPRECATED: Use '--outputlevel max' instead."
|
|
1289
|
-
),
|
|
1290
|
-
default=True,
|
|
1291
|
-
)
|
|
1292
1261
|
output.add_argument(
|
|
1293
1262
|
"--savelags",
|
|
1294
1263
|
dest="savecorrtimes",
|
|
@@ -1467,16 +1436,16 @@ def _get_parser():
|
|
|
1467
1436
|
"Experimental options (not fully tested, or not tested at all, may not work). Beware!"
|
|
1468
1437
|
)
|
|
1469
1438
|
experimental.add_argument(
|
|
1470
|
-
"--
|
|
1471
|
-
dest="
|
|
1439
|
+
"--refineregressderivs",
|
|
1440
|
+
dest="refineregressderivs",
|
|
1472
1441
|
action="store",
|
|
1473
1442
|
type=lambda x: pf.is_int(parser, x, minval=1),
|
|
1474
1443
|
metavar="NDERIVS",
|
|
1475
1444
|
help=(
|
|
1476
|
-
f"When doing
|
|
1477
|
-
f"Default is {
|
|
1445
|
+
f"When doing regression fit for delay refinement, include derivatives up to NDERIVS order. Must be 1 or more. "
|
|
1446
|
+
f"Default is {DEFAULT_REFINEREGRESSDERIVS}"
|
|
1478
1447
|
),
|
|
1479
|
-
default=
|
|
1448
|
+
default=DEFAULT_REFINEREGRESSDERIVS,
|
|
1480
1449
|
)
|
|
1481
1450
|
experimental.add_argument(
|
|
1482
1451
|
"--dofinalrefine",
|
|
@@ -1670,6 +1639,51 @@ def _get_parser():
|
|
|
1670
1639
|
default=False,
|
|
1671
1640
|
)
|
|
1672
1641
|
|
|
1642
|
+
# Deprecated options
|
|
1643
|
+
deprecated = parser.add_argument_group(
|
|
1644
|
+
"Deprecated options. These options will go away in the indeterminate future. Don't use them."
|
|
1645
|
+
)
|
|
1646
|
+
deprecated.add_argument(
|
|
1647
|
+
"--refinedelay",
|
|
1648
|
+
dest="dummy",
|
|
1649
|
+
action="store_true",
|
|
1650
|
+
help=(
|
|
1651
|
+
"Calculate a refined delay map using regression coefficient information. ***DEPRECATED***: refinedelay is now on by default."
|
|
1652
|
+
),
|
|
1653
|
+
default=True,
|
|
1654
|
+
)
|
|
1655
|
+
deprecated.add_argument(
|
|
1656
|
+
"--nolimitoutput",
|
|
1657
|
+
dest="limitoutput",
|
|
1658
|
+
action="store_false",
|
|
1659
|
+
help=(
|
|
1660
|
+
"Save some of the large and rarely used files. "
|
|
1661
|
+
"***DEPRECATED***: Use '--outputlevel max' instead."
|
|
1662
|
+
),
|
|
1663
|
+
default=True,
|
|
1664
|
+
)
|
|
1665
|
+
deprecated.add_argument(
|
|
1666
|
+
"--pickleft",
|
|
1667
|
+
dest="dummy",
|
|
1668
|
+
action="store_true",
|
|
1669
|
+
help=(
|
|
1670
|
+
"***DEPRECATED***: pickleft is now on by default. Use 'nopickleft' to disable it instead."
|
|
1671
|
+
),
|
|
1672
|
+
default=True,
|
|
1673
|
+
)
|
|
1674
|
+
deprecated.add_argument(
|
|
1675
|
+
"--noglm",
|
|
1676
|
+
dest="dolinfitfilt",
|
|
1677
|
+
action="store_false",
|
|
1678
|
+
help=(
|
|
1679
|
+
"Turn off regression filtering to remove delayed "
|
|
1680
|
+
"regressor from each voxel (disables output of "
|
|
1681
|
+
"fitNorm)."
|
|
1682
|
+
"***DEPRECATED***: Use '--nodenoise' instead."
|
|
1683
|
+
),
|
|
1684
|
+
default=True,
|
|
1685
|
+
)
|
|
1686
|
+
|
|
1673
1687
|
# Debugging options
|
|
1674
1688
|
debugging = parser.add_argument_group(
|
|
1675
1689
|
"Debugging options. You probably don't want to use any of these unless I ask you to to help diagnose a problem"
|
|
@@ -1759,10 +1773,10 @@ def _get_parser():
|
|
|
1759
1773
|
default=False,
|
|
1760
1774
|
)
|
|
1761
1775
|
debugging.add_argument(
|
|
1762
|
-
"--
|
|
1763
|
-
dest="
|
|
1776
|
+
"--singleproc_regressionfilt",
|
|
1777
|
+
dest="singleproc_regressionfilt",
|
|
1764
1778
|
action="store_true",
|
|
1765
|
-
help=("Force single proc path for
|
|
1779
|
+
help=("Force single proc path for regression filtering."),
|
|
1766
1780
|
default=False,
|
|
1767
1781
|
)
|
|
1768
1782
|
debugging.add_argument(
|
|
@@ -2134,7 +2148,7 @@ def process_args(inputargs=None):
|
|
|
2134
2148
|
args["refineoffset"] = True
|
|
2135
2149
|
args["refinedelay"] = True
|
|
2136
2150
|
args["outputlevel"] = "normal"
|
|
2137
|
-
pf.setifnotset(args, "
|
|
2151
|
+
pf.setifnotset(args, "dolinfitfilt", True)
|
|
2138
2152
|
|
|
2139
2153
|
if args["denoising"]:
|
|
2140
2154
|
LGR.warning('Using "denoising" analysis mode. Overriding any affected arguments.')
|
|
@@ -2147,7 +2161,7 @@ def process_args(inputargs=None):
|
|
|
2147
2161
|
args["refineoffset"] = True
|
|
2148
2162
|
args["refinedelay"] = True
|
|
2149
2163
|
args["zerooutbadfit"] = False
|
|
2150
|
-
pf.setifnotset(args, "
|
|
2164
|
+
pf.setifnotset(args, "dolinfitfilt", True)
|
|
2151
2165
|
|
|
2152
2166
|
if args["docvrmap"]:
|
|
2153
2167
|
LGR.warning('Using "CVR" analysis mode. Overriding any affected arguments.')
|
|
@@ -2166,7 +2180,7 @@ def process_args(inputargs=None):
|
|
|
2166
2180
|
args["preservefiltering"] = True
|
|
2167
2181
|
args["passes"] = 1
|
|
2168
2182
|
args["outputlevel"] = "min"
|
|
2169
|
-
args["
|
|
2183
|
+
args["dolinfitfilt"] = False
|
|
2170
2184
|
|
|
2171
2185
|
if args["globalpreselect"]:
|
|
2172
2186
|
LGR.warning('Using "globalpreselect" analysis mode. Overriding any affected arguments.')
|
|
@@ -2174,7 +2188,7 @@ def process_args(inputargs=None):
|
|
|
2174
2188
|
args["despeckle_passes"] = 0
|
|
2175
2189
|
args["refinedespeckle"] = False
|
|
2176
2190
|
args["outputlevel"] = "normal"
|
|
2177
|
-
pf.setifnotset(args, "
|
|
2191
|
+
pf.setifnotset(args, "dolinfitfilt", False)
|
|
2178
2192
|
args["saveintermediatemaps"] = False
|
|
2179
2193
|
|
|
2180
2194
|
# configure the filter
|
|
@@ -2194,6 +2208,7 @@ def process_args(inputargs=None):
|
|
|
2194
2208
|
LGR.warning('Using "nirs" macro. Overriding any affected arguments.')
|
|
2195
2209
|
args["nothresh"] = True
|
|
2196
2210
|
pf.setifnotset(args, "preservefiltering", False)
|
|
2211
|
+
args["dataiszeromean"] = True
|
|
2197
2212
|
args["refineprenorm"] = "var"
|
|
2198
2213
|
args["ampthresh"] = 0.7
|
|
2199
2214
|
args["ampthreshfromsig"] = False
|
|
@@ -2211,50 +2226,50 @@ def process_args(inputargs=None):
|
|
|
2211
2226
|
args["savecorrtimes"] = False
|
|
2212
2227
|
args["savelagregressors"] = False
|
|
2213
2228
|
args["savedespecklemasks"] = False
|
|
2214
|
-
args["
|
|
2215
|
-
args["
|
|
2229
|
+
args["saveminimumsLFOfiltfiles"] = False
|
|
2230
|
+
args["savenormalsLFOfiltfiles"] = False
|
|
2216
2231
|
args["savemovingsignal"] = False
|
|
2217
|
-
args["
|
|
2232
|
+
args["saveallsLFOfiltfiles"] = False
|
|
2218
2233
|
elif args["outputlevel"] == "less":
|
|
2219
2234
|
args["saveconfoundfiltered"] = False
|
|
2220
2235
|
args["savegaussout"] = False
|
|
2221
2236
|
args["savecorrtimes"] = False
|
|
2222
2237
|
args["savelagregressors"] = False
|
|
2223
2238
|
args["savedespecklemasks"] = False
|
|
2224
|
-
args["
|
|
2225
|
-
args["
|
|
2239
|
+
args["saveminimumsLFOfiltfiles"] = True
|
|
2240
|
+
args["savenormalsLFOfiltfiles"] = False
|
|
2226
2241
|
args["savemovingsignal"] = False
|
|
2227
|
-
args["
|
|
2242
|
+
args["saveallsLFOfiltfiles"] = False
|
|
2228
2243
|
elif args["outputlevel"] == "normal":
|
|
2229
2244
|
args["saveconfoundfiltered"] = False
|
|
2230
2245
|
args["savegaussout"] = False
|
|
2231
2246
|
args["savecorrtimes"] = False
|
|
2232
2247
|
args["savelagregressors"] = False
|
|
2233
2248
|
args["savedespecklemasks"] = False
|
|
2234
|
-
args["
|
|
2235
|
-
args["
|
|
2249
|
+
args["saveminimumsLFOfiltfiles"] = True
|
|
2250
|
+
args["savenormalsLFOfiltfiles"] = True
|
|
2236
2251
|
args["savemovingsignal"] = False
|
|
2237
|
-
args["
|
|
2252
|
+
args["saveallsLFOfiltfiles"] = False
|
|
2238
2253
|
elif args["outputlevel"] == "more":
|
|
2239
2254
|
args["saveconfoundfiltered"] = False
|
|
2240
2255
|
args["savegaussout"] = False
|
|
2241
2256
|
args["savecorrtimes"] = False
|
|
2242
2257
|
args["savelagregressors"] = True
|
|
2243
2258
|
args["savedespecklemasks"] = False
|
|
2244
|
-
args["
|
|
2245
|
-
args["
|
|
2259
|
+
args["saveminimumsLFOfiltfiles"] = True
|
|
2260
|
+
args["savenormalsLFOfiltfiles"] = True
|
|
2246
2261
|
args["savemovingsignal"] = True
|
|
2247
|
-
args["
|
|
2262
|
+
args["saveallsLFOfiltfiles"] = False
|
|
2248
2263
|
elif args["outputlevel"] == "max":
|
|
2249
2264
|
args["saveconfoundfiltered"] = True
|
|
2250
2265
|
args["savegaussout"] = True
|
|
2251
2266
|
args["savecorrtimes"] = True
|
|
2252
2267
|
args["savelagregressors"] = True
|
|
2253
2268
|
args["savedespecklemasks"] = True
|
|
2254
|
-
args["
|
|
2255
|
-
args["
|
|
2269
|
+
args["saveminimumsLFOfiltfiles"] = True
|
|
2270
|
+
args["savenormalsLFOfiltfiles"] = True
|
|
2256
2271
|
args["savemovingsignal"] = True
|
|
2257
|
-
args["
|
|
2272
|
+
args["saveallsLFOfiltfiles"] = True
|
|
2258
2273
|
else:
|
|
2259
2274
|
print(f"illegal output level {args['outputlevel']}")
|
|
2260
2275
|
sys.exit()
|
|
@@ -2286,8 +2301,8 @@ def process_args(inputargs=None):
|
|
|
2286
2301
|
args["territorymapname"] = None
|
|
2287
2302
|
args["territorymapincludevals"] = None
|
|
2288
2303
|
|
|
2289
|
-
# this is new enough to do retrospective
|
|
2290
|
-
args["
|
|
2304
|
+
# this is new enough to do retrospective regression filtering
|
|
2305
|
+
args["retroregresscompatible"] = True
|
|
2291
2306
|
|
|
2292
2307
|
LGR.debug("\nafter postprocessing\n{}".format(args))
|
|
2293
2308
|
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
import numpy as np
|
|
21
21
|
|
|
22
|
-
import rapidtide.glmpass as tide_glmpass
|
|
23
22
|
import rapidtide.io as tide_io
|
|
23
|
+
import rapidtide.linfitfiltpass as tide_linfitfiltpass
|
|
24
24
|
import rapidtide.makelaggedtcs as tide_makelagged
|
|
25
25
|
import rapidtide.util as tide_util
|
|
26
26
|
|
|
@@ -54,7 +54,7 @@ def addmemprofiling(thefunc, memprofile, themessage):
|
|
|
54
54
|
return thefunc
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
def
|
|
57
|
+
def regressfrommaps(
|
|
58
58
|
fmri_data_valid,
|
|
59
59
|
validvoxels,
|
|
60
60
|
initial_fmri_x,
|
|
@@ -64,7 +64,7 @@ def glmfrommaps(
|
|
|
64
64
|
mode,
|
|
65
65
|
outputname,
|
|
66
66
|
oversamptr,
|
|
67
|
-
|
|
67
|
+
sLFOfitmean,
|
|
68
68
|
rvalue,
|
|
69
69
|
r2value,
|
|
70
70
|
fitNorm,
|
|
@@ -74,11 +74,11 @@ def glmfrommaps(
|
|
|
74
74
|
filtereddata,
|
|
75
75
|
LGR,
|
|
76
76
|
TimingLGR,
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
regressfiltthreshval,
|
|
78
|
+
saveminimumsLFOfiltfiles,
|
|
79
79
|
nprocs_makelaggedtcs=1,
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
nprocs_regressionfilt=1,
|
|
81
|
+
regressderivs=0,
|
|
82
82
|
mp_chunksize=50000,
|
|
83
83
|
showprogressbar=True,
|
|
84
84
|
alwaysmultiproc=False,
|
|
@@ -86,10 +86,10 @@ def glmfrommaps(
|
|
|
86
86
|
debug=False,
|
|
87
87
|
):
|
|
88
88
|
if debug:
|
|
89
|
-
print("
|
|
89
|
+
print("regressfrommaps: Starting")
|
|
90
90
|
print(f"{nprocs_makelaggedtcs=}")
|
|
91
|
-
print(f"{
|
|
92
|
-
print(f"{
|
|
91
|
+
print(f"{nprocs_regressionfilt=}")
|
|
92
|
+
print(f"{regressderivs=}")
|
|
93
93
|
print(f"{mp_chunksize=}")
|
|
94
94
|
print(f"{showprogressbar=}")
|
|
95
95
|
print(f"{alwaysmultiproc=}")
|
|
@@ -97,7 +97,7 @@ def glmfrommaps(
|
|
|
97
97
|
print(f"{mode=}")
|
|
98
98
|
print(f"{outputname=}")
|
|
99
99
|
print(f"{oversamptr=}")
|
|
100
|
-
print(f"{
|
|
100
|
+
print(f"{regressfiltthreshval=}")
|
|
101
101
|
rt_floatset = np.float64
|
|
102
102
|
rt_floattype = "float64"
|
|
103
103
|
numvalidspatiallocs = np.shape(validvoxels)[0]
|
|
@@ -121,6 +121,7 @@ def glmfrommaps(
|
|
|
121
121
|
fitmask,
|
|
122
122
|
lagtimes,
|
|
123
123
|
lagtc,
|
|
124
|
+
LGR=LGR,
|
|
124
125
|
nprocs=nprocs_makelaggedtcs,
|
|
125
126
|
alwaysmultiproc=alwaysmultiproc,
|
|
126
127
|
showprogressbar=showprogressbar,
|
|
@@ -150,18 +151,20 @@ def glmfrommaps(
|
|
|
150
151
|
if TimingLGR is not None:
|
|
151
152
|
TimingLGR.info("Start filtering operation")
|
|
152
153
|
if memprofile:
|
|
153
|
-
|
|
154
|
+
linfitfiltpass_func = addmemprofiling(
|
|
155
|
+
tide_linfitfiltpass.linfitfiltpass, memprofile, "before linfitfiltpass"
|
|
156
|
+
)
|
|
154
157
|
else:
|
|
155
|
-
|
|
158
|
+
linfitfiltpass_func = tide_linfitfiltpass.linfitfiltpass
|
|
156
159
|
|
|
157
|
-
if
|
|
160
|
+
if regressderivs > 0:
|
|
158
161
|
if debug:
|
|
159
|
-
print(f"adding derivatives up to order {
|
|
160
|
-
regressorset =
|
|
162
|
+
print(f"adding derivatives up to order {regressderivs} prior to regression")
|
|
163
|
+
regressorset = tide_linfitfiltpass.makevoxelspecificderivs(lagtc, regressderivs)
|
|
161
164
|
baseev = rt_floatset(genlagtc.yfromx(initial_fmri_x))
|
|
162
|
-
evset =
|
|
163
|
-
(-1,
|
|
164
|
-
)
|
|
165
|
+
evset = tide_linfitfiltpass.makevoxelspecificderivs(
|
|
166
|
+
baseev.reshape((1, -1)), regressderivs
|
|
167
|
+
).reshape((-1, 2))
|
|
165
168
|
else:
|
|
166
169
|
if debug:
|
|
167
170
|
print(f"using raw lagged regressors for regression")
|
|
@@ -170,21 +173,22 @@ def glmfrommaps(
|
|
|
170
173
|
|
|
171
174
|
if debug:
|
|
172
175
|
print(f"{regressorset.shape=}")
|
|
173
|
-
|
|
176
|
+
voxelsprocessed_regressionfilt = linfitfiltpass_func(
|
|
174
177
|
numvalidspatiallocs,
|
|
175
178
|
fmri_data_valid,
|
|
176
|
-
|
|
179
|
+
regressfiltthreshval,
|
|
177
180
|
regressorset,
|
|
178
|
-
|
|
181
|
+
sLFOfitmean,
|
|
179
182
|
rvalue,
|
|
180
183
|
r2value,
|
|
181
184
|
fitcoeff,
|
|
182
185
|
fitNorm,
|
|
183
186
|
movingsignal,
|
|
184
187
|
filtereddata,
|
|
185
|
-
nprocs=
|
|
188
|
+
nprocs=nprocs_regressionfilt,
|
|
186
189
|
alwaysmultiproc=alwaysmultiproc,
|
|
187
190
|
showprogressbar=showprogressbar,
|
|
191
|
+
verbose=(LGR is not None),
|
|
188
192
|
mp_chunksize=mp_chunksize,
|
|
189
193
|
rt_floatset=rt_floatset,
|
|
190
194
|
rt_floattype=rt_floattype,
|
|
@@ -197,7 +201,7 @@ def glmfrommaps(
|
|
|
197
201
|
# determine what was removed
|
|
198
202
|
removeddata = fmri_data_valid - filtereddata
|
|
199
203
|
noiseremoved = np.var(removeddata, axis=0)
|
|
200
|
-
if
|
|
204
|
+
if saveminimumsLFOfiltfiles:
|
|
201
205
|
tide_io.writebidstsv(
|
|
202
206
|
f"{outputname}_desc-lfofilterNoiseRemoved_timeseries",
|
|
203
207
|
noiseremoved,
|
|
@@ -205,9 +209,9 @@ def glmfrommaps(
|
|
|
205
209
|
starttime=0.0,
|
|
206
210
|
columns=[f"removedbyglm"],
|
|
207
211
|
extraheaderinfo={
|
|
208
|
-
"Description": "Variance over space of data removed by
|
|
212
|
+
"Description": "Variance over space of data removed by the sLFO filter at each timepoint"
|
|
209
213
|
},
|
|
210
214
|
append=False,
|
|
211
215
|
)
|
|
212
216
|
|
|
213
|
-
return
|
|
217
|
+
return voxelsprocessed_regressionfilt, regressorset, evset
|
|
@@ -24,8 +24,8 @@ import sys
|
|
|
24
24
|
|
|
25
25
|
import numpy as np
|
|
26
26
|
|
|
27
|
-
import rapidtide.glmpass as tide_glmpass
|
|
28
27
|
import rapidtide.io as tide_io
|
|
28
|
+
import rapidtide.linfitfiltpass as tide_linfitfiltpass
|
|
29
29
|
import rapidtide.makelaggedtcs as tide_makelagged
|
|
30
30
|
import rapidtide.multiproc as tide_multiproc
|
|
31
31
|
import rapidtide.resample as tide_resample
|
|
@@ -36,7 +36,7 @@ LGR = logging.getLogger("GENERAL")
|
|
|
36
36
|
ErrorLGR = logging.getLogger("ERROR")
|
|
37
37
|
TimingLGR = logging.getLogger("TIMING")
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
DEFAULT_REGRESSIONFILTDERIVS = 0
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
def _get_parser():
|
|
@@ -76,15 +76,15 @@ def _get_parser():
|
|
|
76
76
|
help="Output root.",
|
|
77
77
|
)
|
|
78
78
|
parser.add_argument(
|
|
79
|
-
"--
|
|
80
|
-
dest="
|
|
79
|
+
"--regressderivs",
|
|
80
|
+
dest="regressderivs",
|
|
81
81
|
action="store",
|
|
82
82
|
type=int,
|
|
83
83
|
metavar="NDERIVS",
|
|
84
84
|
help=(
|
|
85
|
-
f"When doing final GLM, include derivatives up to NDERIVS order. Default is {
|
|
85
|
+
f"When doing final GLM, include derivatives up to NDERIVS order. Default is {DEFAULT_REGRESSIONFILTDERIVS}"
|
|
86
86
|
),
|
|
87
|
-
default=
|
|
87
|
+
default=DEFAULT_REGRESSIONFILTDERIVS,
|
|
88
88
|
)
|
|
89
89
|
parser.add_argument(
|
|
90
90
|
"--nprocs",
|
|
@@ -209,7 +209,7 @@ def retrolagtcs(args):
|
|
|
209
209
|
internalvalidspaceshape = numvalidspatiallocs
|
|
210
210
|
internalvalidspaceshapederivs = (
|
|
211
211
|
internalvalidspaceshape,
|
|
212
|
-
args.
|
|
212
|
+
args.regressderivs + 1,
|
|
213
213
|
)
|
|
214
214
|
internalvalidfmrishape = (numvalidspatiallocs, np.shape(initial_fmri_x)[0])
|
|
215
215
|
if args.debug:
|
|
@@ -250,13 +250,14 @@ def retrolagtcs(args):
|
|
|
250
250
|
"CommandLineArgs": thecommandline,
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
print("calling
|
|
253
|
+
print("calling makelaggedtcs")
|
|
254
254
|
voxelsprocessed_makelagged = tide_makelagged.makelaggedtcs(
|
|
255
255
|
genlagtc,
|
|
256
256
|
initial_fmri_x,
|
|
257
257
|
procmask_valid,
|
|
258
258
|
lagtimes_valid,
|
|
259
259
|
lagtc,
|
|
260
|
+
LGR=LGR,
|
|
260
261
|
nprocs=args.nprocs,
|
|
261
262
|
showprogressbar=args.showprogressbar,
|
|
262
263
|
)
|
|
@@ -293,10 +294,10 @@ def retrolagtcs(args):
|
|
|
293
294
|
theheader = copy.deepcopy(fmri_header)
|
|
294
295
|
maplist = []
|
|
295
296
|
|
|
296
|
-
if args.
|
|
297
|
+
if args.regressderivs > 0:
|
|
297
298
|
if args.debug:
|
|
298
|
-
print(f"adding derivatives up to order {args.
|
|
299
|
-
regressorset =
|
|
299
|
+
print(f"adding derivatives up to order {args.regressderivs} prior to regression")
|
|
300
|
+
regressorset = tide_linfitfiltpass.makevoxelspecificderivs(lagtc, args.regressderivs)
|
|
300
301
|
|
|
301
302
|
if args.debug:
|
|
302
303
|
print("going down the multiple EV path")
|
|
@@ -310,7 +311,7 @@ def retrolagtcs(args):
|
|
|
310
311
|
"Shifted sLFO regressor to filter",
|
|
311
312
|
),
|
|
312
313
|
]
|
|
313
|
-
for thederiv in range(1, args.
|
|
314
|
+
for thederiv in range(1, args.regressderivs + 1):
|
|
314
315
|
if args.debug:
|
|
315
316
|
print(f"{regressorset[:, :, thederiv].shape=}")
|
|
316
317
|
maplist += [
|