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
rapidtide/workflows/rapidtide.py
CHANGED
|
@@ -37,22 +37,22 @@ import rapidtide.calcsimfunc as tide_calcsimfunc
|
|
|
37
37
|
import rapidtide.correlate as tide_corr
|
|
38
38
|
import rapidtide.filter as tide_filt
|
|
39
39
|
import rapidtide.fit as tide_fit
|
|
40
|
-
import rapidtide.glmpass as tide_glmpass
|
|
41
40
|
import rapidtide.helper_classes as tide_classes
|
|
42
41
|
import rapidtide.io as tide_io
|
|
42
|
+
import rapidtide.linfitfiltpass as tide_linfitfiltpass
|
|
43
43
|
import rapidtide.maskutil as tide_mask
|
|
44
44
|
import rapidtide.miscmath as tide_math
|
|
45
45
|
import rapidtide.multiproc as tide_multiproc
|
|
46
46
|
import rapidtide.patchmatch as tide_patch
|
|
47
47
|
import rapidtide.peakeval as tide_peakeval
|
|
48
48
|
import rapidtide.refinedelay as tide_refinedelay
|
|
49
|
-
import rapidtide.
|
|
49
|
+
import rapidtide.RegressorRefiner as tide_regrefiner
|
|
50
50
|
import rapidtide.resample as tide_resample
|
|
51
51
|
import rapidtide.simfuncfit as tide_simfuncfit
|
|
52
52
|
import rapidtide.stats as tide_stats
|
|
53
53
|
import rapidtide.util as tide_util
|
|
54
54
|
import rapidtide.wiener as tide_wiener
|
|
55
|
-
import rapidtide.workflows.
|
|
55
|
+
import rapidtide.workflows.regressfrommaps as tide_regressfrommaps
|
|
56
56
|
from rapidtide.tests.utils import mse
|
|
57
57
|
|
|
58
58
|
from .utils import setup_logger
|
|
@@ -382,10 +382,10 @@ def rapidtide_main(argparsingfunc):
|
|
|
382
382
|
else:
|
|
383
383
|
optiondict["nprocs_makelaggedtcs"] = optiondict["nprocs"]
|
|
384
384
|
|
|
385
|
-
if optiondict["
|
|
386
|
-
optiondict["
|
|
385
|
+
if optiondict["singleproc_regressionfilt"]:
|
|
386
|
+
optiondict["nprocs_regressionfilt"] = 1
|
|
387
387
|
else:
|
|
388
|
-
optiondict["
|
|
388
|
+
optiondict["nprocs_regressionfilt"] = optiondict["nprocs"]
|
|
389
389
|
|
|
390
390
|
# set the number of MKL threads to use
|
|
391
391
|
if mklexists:
|
|
@@ -607,14 +607,16 @@ def rapidtide_main(argparsingfunc):
|
|
|
607
607
|
fmri_data = nim_data.reshape((numspatiallocs, timepoints))[:, validstart : validend + 1]
|
|
608
608
|
|
|
609
609
|
# detect zero mean data
|
|
610
|
-
optiondict["dataiszeromean"]
|
|
610
|
+
if not optiondict["dataiszeromean"]:
|
|
611
|
+
# check anyway
|
|
612
|
+
optiondict["dataiszeromean"] = checkforzeromean(fmri_data)
|
|
613
|
+
|
|
611
614
|
if optiondict["dataiszeromean"]:
|
|
612
615
|
LGR.warning(
|
|
613
616
|
"WARNING: dataset is zero mean - forcing variance masking and no refine prenormalization. "
|
|
614
617
|
"Consider specifying a global mean and correlation mask."
|
|
615
618
|
)
|
|
616
619
|
optiondict["refineprenorm"] = "None"
|
|
617
|
-
optiondict["globalmaskmethod"] = "variance"
|
|
618
620
|
|
|
619
621
|
# reformat the brain mask, if it exists
|
|
620
622
|
if brainmask is None:
|
|
@@ -716,18 +718,18 @@ def rapidtide_main(argparsingfunc):
|
|
|
716
718
|
corrmask[np.where(datarange == 0)] = 0.0
|
|
717
719
|
else:
|
|
718
720
|
# check to see if the data has been demeaned
|
|
719
|
-
|
|
720
|
-
stdim = np.std(fmri_data, axis=1)
|
|
721
|
-
if fileiscifti:
|
|
721
|
+
if fileiscifti or optiondict["textio"]:
|
|
722
722
|
corrmask = np.uint(nim_data[:, 0] * 0 + 1)
|
|
723
723
|
else:
|
|
724
|
-
if
|
|
724
|
+
if optiondict["dataiszeromean"]:
|
|
725
725
|
LGR.verbose("generating correlation mask from mean image")
|
|
726
726
|
corrmask = np.uint16(tide_mask.makeepimask(nim).dataobj.reshape(numspatiallocs))
|
|
727
727
|
else:
|
|
728
728
|
LGR.verbose("generating correlation mask from std image")
|
|
729
729
|
corrmask = np.uint16(
|
|
730
|
-
tide_stats.makemask(
|
|
730
|
+
tide_stats.makemask(
|
|
731
|
+
np.std(fmri_data, axis=1), threshpct=optiondict["corrmaskthreshpct"]
|
|
732
|
+
)
|
|
731
733
|
)
|
|
732
734
|
if internalbrainmask is not None:
|
|
733
735
|
corrmask = internalbrainmask
|
|
@@ -889,7 +891,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
889
891
|
mergedregressorlabels,
|
|
890
892
|
fmri_data_valid,
|
|
891
893
|
confoundr2,
|
|
892
|
-
) =
|
|
894
|
+
) = tide_linfitfiltpass.confoundregress(
|
|
893
895
|
mergedregressors,
|
|
894
896
|
mergedregressorlabels,
|
|
895
897
|
fmri_data_valid,
|
|
@@ -961,7 +963,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
961
963
|
)
|
|
962
964
|
if optiondict["memprofile"]:
|
|
963
965
|
memcheckpoint("...done")
|
|
964
|
-
tide_util.logmem("after confound
|
|
966
|
+
tide_util.logmem("after confound sLFO filter")
|
|
965
967
|
|
|
966
968
|
if optiondict["saveconfoundfiltered"]:
|
|
967
969
|
if not optiondict["textio"]:
|
|
@@ -1736,7 +1738,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
1736
1738
|
or optiondict["convergencethresh"] is not None
|
|
1737
1739
|
):
|
|
1738
1740
|
# we will be doing regressor refinement, so set that up
|
|
1739
|
-
theRegressorRefiner =
|
|
1741
|
+
theRegressorRefiner = tide_regrefiner.RegressorRefiner(
|
|
1740
1742
|
internalvalidfmrishape,
|
|
1741
1743
|
internalvalidpaddedfmrishape,
|
|
1742
1744
|
optiondict["pid"],
|
|
@@ -1948,7 +1950,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
1948
1950
|
)
|
|
1949
1951
|
|
|
1950
1952
|
# regress out
|
|
1951
|
-
resampref_y, datatoremove, R, dummy = tide_fit.
|
|
1953
|
+
resampref_y, datatoremove, R, dummy = tide_fit.linfitfilt(
|
|
1952
1954
|
resampref_y, shiftednoise, debug=True
|
|
1953
1955
|
)
|
|
1954
1956
|
|
|
@@ -3155,20 +3157,20 @@ def rapidtide_main(argparsingfunc):
|
|
|
3155
3157
|
tide_util.cleanup_shm(wpeak_shm)
|
|
3156
3158
|
|
|
3157
3159
|
####################################################
|
|
3158
|
-
#
|
|
3160
|
+
# Linear regression filtering start
|
|
3159
3161
|
####################################################
|
|
3160
|
-
# Post refinement step 1 -
|
|
3162
|
+
# Post refinement step 1 - regression fitting, either to remove moving signal, or to calculate delayed CVR
|
|
3161
3163
|
# write out the current version of the run options
|
|
3162
|
-
optiondict["currentstage"] = "
|
|
3164
|
+
optiondict["currentstage"] = "presLFOfit"
|
|
3163
3165
|
tide_io.writedicttojson(optiondict, f"{outputname}_desc-runoptions_info.json")
|
|
3164
|
-
if optiondict["
|
|
3165
|
-
if optiondict["
|
|
3166
|
+
if optiondict["dolinfitfilt"] or optiondict["docvrmap"] or optiondict["refinedelay"]:
|
|
3167
|
+
if optiondict["dolinfitfilt"]:
|
|
3166
3168
|
if optiondict["refinedelay"]:
|
|
3167
|
-
TimingLGR.info("Setting up for delay refinement and
|
|
3168
|
-
LGR.info("\n\nDelay refinement and
|
|
3169
|
+
TimingLGR.info("Setting up for delay refinement and sLFO filtering")
|
|
3170
|
+
LGR.info("\n\nDelay refinement and sLFO filtering setup")
|
|
3169
3171
|
else:
|
|
3170
|
-
TimingLGR.info("Setting up for
|
|
3171
|
-
LGR.info("\n\
|
|
3172
|
+
TimingLGR.info("Setting up for sLFO filtering")
|
|
3173
|
+
LGR.info("\n\nsLFO filtering setup")
|
|
3172
3174
|
elif optiondict["docvrmap"]:
|
|
3173
3175
|
if optiondict["refinedelay"]:
|
|
3174
3176
|
TimingLGR.info("Setting up for delay refinement and CVR map generation")
|
|
@@ -3181,14 +3183,16 @@ def rapidtide_main(argparsingfunc):
|
|
|
3181
3183
|
LGR.info("\n\nDelay refinement setup")
|
|
3182
3184
|
if (
|
|
3183
3185
|
(optiondict["gausssigma"] > 0.0)
|
|
3184
|
-
or (optiondict["
|
|
3186
|
+
or (optiondict["denoisesourcefile"] is not None)
|
|
3185
3187
|
or optiondict["docvrmap"]
|
|
3186
3188
|
):
|
|
3187
|
-
if optiondict["
|
|
3188
|
-
LGR.info(
|
|
3189
|
-
|
|
3189
|
+
if optiondict["denoisesourcefile"] is not None:
|
|
3190
|
+
LGR.info(
|
|
3191
|
+
f"reading in {optiondict['denoisesourcefile']} for sLFO filter, please wait"
|
|
3192
|
+
)
|
|
3193
|
+
sourcename = optiondict["denoisesourcefile"]
|
|
3190
3194
|
else:
|
|
3191
|
-
LGR.info(f"rereading {fmrifilename} for
|
|
3195
|
+
LGR.info(f"rereading {fmrifilename} for sLFO filter, please wait")
|
|
3192
3196
|
sourcename = fmrifilename
|
|
3193
3197
|
if fileiscifti:
|
|
3194
3198
|
LGR.info("input file is CIFTI")
|
|
@@ -3235,28 +3239,30 @@ def rapidtide_main(argparsingfunc):
|
|
|
3235
3239
|
numpy2shared_func = addmemprofiling(
|
|
3236
3240
|
tide_util.numpy2shared,
|
|
3237
3241
|
optiondict["memprofile"],
|
|
3238
|
-
"before movetoshared (
|
|
3242
|
+
"before movetoshared (sLFO filter)",
|
|
3239
3243
|
)
|
|
3240
3244
|
fmri_data_valid, fmri_data_valid_shm = numpy2shared_func(
|
|
3241
|
-
fmri_data_valid,
|
|
3245
|
+
fmri_data_valid,
|
|
3246
|
+
rt_floatset,
|
|
3247
|
+
name=f"fmri_data_valid_regressionfilt_{optiondict['pid']}",
|
|
3242
3248
|
)
|
|
3243
3249
|
TimingLGR.info("End moving fmri_data to shared memory")
|
|
3244
3250
|
del nim_data
|
|
3245
3251
|
|
|
3246
|
-
# now allocate the arrays needed for
|
|
3252
|
+
# now allocate the arrays needed for sLFO filtering
|
|
3247
3253
|
if optiondict["refinedelay"]:
|
|
3248
3254
|
derivaxissize = np.max(
|
|
3249
|
-
[optiondict["
|
|
3255
|
+
[optiondict["refineregressderivs"] + 1, optiondict["regressderivs"] + 1]
|
|
3250
3256
|
)
|
|
3251
3257
|
else:
|
|
3252
|
-
derivaxissize = optiondict["
|
|
3258
|
+
derivaxissize = optiondict["regressderivs"] + 1
|
|
3253
3259
|
internalvalidspaceshapederivs = (
|
|
3254
3260
|
internalvalidspaceshape,
|
|
3255
3261
|
derivaxissize,
|
|
3256
3262
|
)
|
|
3257
3263
|
if optiondict["sharedmem"]:
|
|
3258
|
-
|
|
3259
|
-
internalvalidspaceshape, rt_outfloatset, name=f"
|
|
3264
|
+
sLFOfitmean, sLFOfitmean_shm = tide_util.allocshared(
|
|
3265
|
+
internalvalidspaceshape, rt_outfloatset, name=f"sLFOfitmean_{optiondict['pid']}"
|
|
3260
3266
|
)
|
|
3261
3267
|
rvalue, rvalue_shm = tide_util.allocshared(
|
|
3262
3268
|
internalvalidspaceshape, rt_outfloatset, name=f"rvalue_{optiondict['pid']}"
|
|
@@ -3281,7 +3287,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
3281
3287
|
)
|
|
3282
3288
|
ramlocation = "in shared memory"
|
|
3283
3289
|
else:
|
|
3284
|
-
|
|
3290
|
+
sLFOfitmean = np.zeros(internalvalidspaceshape, dtype=rt_outfloattype)
|
|
3285
3291
|
rvalue = np.zeros(internalvalidspaceshape, dtype=rt_outfloattype)
|
|
3286
3292
|
r2value = np.zeros(internalvalidspaceshape, dtype=rt_outfloattype)
|
|
3287
3293
|
fitNorm = np.zeros(internalvalidspaceshapederivs, dtype=rt_outfloattype)
|
|
@@ -3291,8 +3297,8 @@ def rapidtide_main(argparsingfunc):
|
|
|
3291
3297
|
filtereddata = np.zeros(internalvalidfmrishape, dtype=rt_outfloattype)
|
|
3292
3298
|
ramlocation = "locally"
|
|
3293
3299
|
|
|
3294
|
-
optiondict["
|
|
3295
|
-
|
|
3300
|
+
optiondict["totalsLFOfilterbytes"] = (
|
|
3301
|
+
sLFOfitmean.nbytes
|
|
3296
3302
|
+ rvalue.nbytes
|
|
3297
3303
|
+ r2value.nbytes
|
|
3298
3304
|
+ fitNorm.nbytes
|
|
@@ -3301,25 +3307,25 @@ def rapidtide_main(argparsingfunc):
|
|
|
3301
3307
|
+ lagtc.nbytes
|
|
3302
3308
|
+ filtereddata.nbytes
|
|
3303
3309
|
)
|
|
3304
|
-
thesize, theunit = tide_util.format_bytes(optiondict["
|
|
3305
|
-
print(f"allocated {thesize:.3f} {theunit} {ramlocation} for
|
|
3310
|
+
thesize, theunit = tide_util.format_bytes(optiondict["totalsLFOfilterbytes"])
|
|
3311
|
+
print(f"allocated {thesize:.3f} {theunit} {ramlocation} for sLFO filter/delay refinement")
|
|
3306
3312
|
|
|
3307
3313
|
if optiondict["memprofile"]:
|
|
3308
|
-
if optiondict["
|
|
3309
|
-
memcheckpoint("about to start
|
|
3314
|
+
if optiondict["dolinfitfilt"]:
|
|
3315
|
+
memcheckpoint("about to start sLFO noise removal...")
|
|
3310
3316
|
else:
|
|
3311
3317
|
memcheckpoint("about to start CVR magnitude estimation...")
|
|
3312
|
-
tide_util.logmem("before
|
|
3318
|
+
tide_util.logmem("before sLFO filter")
|
|
3313
3319
|
|
|
3314
|
-
if optiondict["
|
|
3320
|
+
if optiondict["dolinfitfilt"]:
|
|
3315
3321
|
mode = "glm"
|
|
3316
|
-
optiondict["
|
|
3322
|
+
optiondict["regressfiltthreshval"] = threshval
|
|
3317
3323
|
else:
|
|
3318
3324
|
# set the threshval to zero
|
|
3319
3325
|
mode = "cvrmap"
|
|
3320
|
-
optiondict["
|
|
3326
|
+
optiondict["regressfiltthreshval"] = 0.0
|
|
3321
3327
|
if optiondict["debug"]:
|
|
3322
|
-
# dump the fmri input file going to
|
|
3328
|
+
# dump the fmri input file going to sLFO filter
|
|
3323
3329
|
if not optiondict["textio"]:
|
|
3324
3330
|
theheader = copy.deepcopy(nim_hdr)
|
|
3325
3331
|
if fileiscifti:
|
|
@@ -3340,7 +3346,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
3340
3346
|
"datatofilter",
|
|
3341
3347
|
"bold",
|
|
3342
3348
|
None,
|
|
3343
|
-
"fMRI data that will be subjected to
|
|
3349
|
+
"fMRI data that will be subjected to sLFO filtering",
|
|
3344
3350
|
),
|
|
3345
3351
|
]
|
|
3346
3352
|
tide_io.savemaplist(
|
|
@@ -3356,7 +3362,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
3356
3362
|
cifti_hdr=cifti_hdr,
|
|
3357
3363
|
)
|
|
3358
3364
|
|
|
3359
|
-
# refine the delay value prior to calculating the
|
|
3365
|
+
# refine the delay value prior to calculating the sLFO filter
|
|
3360
3366
|
if optiondict["refinedelay"]:
|
|
3361
3367
|
TimingLGR.info("Delay refinement start")
|
|
3362
3368
|
LGR.info("\n\nDelay refinement")
|
|
@@ -3364,7 +3370,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
3364
3370
|
# set gausssigma automatically
|
|
3365
3371
|
optiondict["delayoffsetgausssigma"] = np.mean([xdim, ydim, slicethickness]) / 2.0
|
|
3366
3372
|
|
|
3367
|
-
|
|
3373
|
+
regressderivratios, regressrvalues = tide_refinedelay.getderivratios(
|
|
3368
3374
|
fmri_data_valid,
|
|
3369
3375
|
validvoxels,
|
|
3370
3376
|
initial_fmri_x,
|
|
@@ -3374,25 +3380,25 @@ def rapidtide_main(argparsingfunc):
|
|
|
3374
3380
|
mode,
|
|
3375
3381
|
outputname,
|
|
3376
3382
|
oversamptr,
|
|
3377
|
-
|
|
3383
|
+
sLFOfitmean,
|
|
3378
3384
|
rvalue,
|
|
3379
3385
|
r2value,
|
|
3380
|
-
fitNorm[:, : (optiondict["
|
|
3381
|
-
fitcoeff[:, : (optiondict["
|
|
3386
|
+
fitNorm[:, : (optiondict["refineregressderivs"] + 1)],
|
|
3387
|
+
fitcoeff[:, : (optiondict["refineregressderivs"] + 1)],
|
|
3382
3388
|
movingsignal,
|
|
3383
3389
|
lagtc,
|
|
3384
3390
|
filtereddata,
|
|
3385
3391
|
LGR,
|
|
3386
3392
|
TimingLGR,
|
|
3387
3393
|
optiondict,
|
|
3388
|
-
|
|
3394
|
+
regressderivs=optiondict["refineregressderivs"],
|
|
3389
3395
|
debug=optiondict["debug"],
|
|
3390
3396
|
)
|
|
3391
3397
|
|
|
3392
|
-
if optiondict["
|
|
3393
|
-
|
|
3398
|
+
if optiondict["refineregressderivs"] == 1:
|
|
3399
|
+
medfiltregressderivratios, filteredregressderivratios, delayoffsetMAD = (
|
|
3394
3400
|
tide_refinedelay.filterderivratios(
|
|
3395
|
-
|
|
3401
|
+
regressderivratios,
|
|
3396
3402
|
nativespaceshape,
|
|
3397
3403
|
validvoxels,
|
|
3398
3404
|
(xdim, ydim, slicethickness),
|
|
@@ -3406,7 +3412,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
3406
3412
|
)
|
|
3407
3413
|
optiondict["delayoffsetMAD"] = delayoffsetMAD
|
|
3408
3414
|
|
|
3409
|
-
# find the mapping of
|
|
3415
|
+
# find the mapping of derivative ratios to delays
|
|
3410
3416
|
tide_refinedelay.trainratiotooffset(
|
|
3411
3417
|
genlagtc,
|
|
3412
3418
|
initial_fmri_x,
|
|
@@ -3419,25 +3425,29 @@ def rapidtide_main(argparsingfunc):
|
|
|
3419
3425
|
)
|
|
3420
3426
|
|
|
3421
3427
|
# now calculate the delay offsets
|
|
3422
|
-
delayoffset = np.zeros_like(
|
|
3428
|
+
delayoffset = np.zeros_like(filteredregressderivratios)
|
|
3423
3429
|
if optiondict["debug"]:
|
|
3424
|
-
print(
|
|
3425
|
-
|
|
3426
|
-
|
|
3430
|
+
print(
|
|
3431
|
+
f"calculating delayoffsets for {filteredregressderivratios.shape[0]} voxels"
|
|
3432
|
+
)
|
|
3433
|
+
for i in range(filteredregressderivratios.shape[0]):
|
|
3434
|
+
delayoffset[i], closestoffset = tide_refinedelay.ratiotodelay(
|
|
3435
|
+
filteredregressderivratios[i]
|
|
3436
|
+
)
|
|
3427
3437
|
else:
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
delayoffsetMAD = np.zeros(optiondict["
|
|
3431
|
-
for i in range(
|
|
3438
|
+
medfiltregressderivratios = np.zeros_like(regressderivratios)
|
|
3439
|
+
filteredregressderivratios = np.zeros_like(regressderivratios)
|
|
3440
|
+
delayoffsetMAD = np.zeros(optiondict["refineregressderivs"], dtype=float)
|
|
3441
|
+
for i in range(optiondict["refineregressderivs"]):
|
|
3432
3442
|
(
|
|
3433
|
-
|
|
3434
|
-
|
|
3443
|
+
medfiltregressderivratios[i, :],
|
|
3444
|
+
filteredregressderivratios[i, :],
|
|
3435
3445
|
delayoffsetMAD[i],
|
|
3436
3446
|
) = tide_refinedelay.filterderivratios(
|
|
3437
|
-
|
|
3447
|
+
regressderivratios[i, :],
|
|
3438
3448
|
(xsize, ysize, numslices),
|
|
3439
3449
|
validvoxels,
|
|
3440
|
-
(xdim, ydim,
|
|
3450
|
+
(xdim, ydim, slicethickness),
|
|
3441
3451
|
gausssigma=optiondict["delayoffsetgausssigma"],
|
|
3442
3452
|
patchthresh=optiondict["delaypatchthresh"],
|
|
3443
3453
|
fileiscifti=False,
|
|
@@ -3448,24 +3458,26 @@ def rapidtide_main(argparsingfunc):
|
|
|
3448
3458
|
optiondict[f"delayoffsetMAD_{i + 1}"] = delayoffsetMAD[i]
|
|
3449
3459
|
|
|
3450
3460
|
# now calculate the delay offsets
|
|
3451
|
-
delayoffset = np.zeros_like(
|
|
3461
|
+
delayoffset = np.zeros_like(filteredregressderivratios[0, :])
|
|
3452
3462
|
if optiondict["debug"]:
|
|
3453
|
-
print(
|
|
3454
|
-
|
|
3463
|
+
print(
|
|
3464
|
+
f"calculating delayoffsets for {filteredregressderivratios.shape[1]} voxels"
|
|
3465
|
+
)
|
|
3466
|
+
for i in range(filteredregressderivratios.shape[1]):
|
|
3455
3467
|
delayoffset[i] = tide_refinedelay.coffstodelay(
|
|
3456
|
-
|
|
3468
|
+
filteredregressderivratios[:, i],
|
|
3457
3469
|
mindelay=optiondict["mindelay"],
|
|
3458
3470
|
maxdelay=optiondict["maxdelay"],
|
|
3459
3471
|
)
|
|
3460
3472
|
|
|
3461
3473
|
namesuffix = "_desc-delayoffset_hist"
|
|
3462
|
-
if optiondict["
|
|
3474
|
+
if optiondict["dolinfitfilt"]:
|
|
3463
3475
|
tide_stats.makeandsavehistogram(
|
|
3464
3476
|
delayoffset[np.where(fitmask > 0)],
|
|
3465
3477
|
optiondict["histlen"],
|
|
3466
3478
|
1,
|
|
3467
3479
|
outputname + namesuffix,
|
|
3468
|
-
displaytitle="Histogram of delay offsets calculated from
|
|
3480
|
+
displaytitle="Histogram of delay offsets calculated from regression coefficients",
|
|
3469
3481
|
dictvarname="delayoffsethist",
|
|
3470
3482
|
thedict=optiondict,
|
|
3471
3483
|
)
|
|
@@ -3475,11 +3487,11 @@ def rapidtide_main(argparsingfunc):
|
|
|
3475
3487
|
# Delay refinement end
|
|
3476
3488
|
####################################################
|
|
3477
3489
|
|
|
3478
|
-
# now calculate the
|
|
3479
|
-
if optiondict["
|
|
3480
|
-
if optiondict["
|
|
3481
|
-
TimingLGR.info("
|
|
3482
|
-
LGR.info("\n\
|
|
3490
|
+
# now calculate the sLFO filter or CVR map
|
|
3491
|
+
if optiondict["dolinfitfilt"] or optiondict["docvrmap"]:
|
|
3492
|
+
if optiondict["dolinfitfilt"]:
|
|
3493
|
+
TimingLGR.info("sLFO filtering start")
|
|
3494
|
+
LGR.info("\n\nsLFO filtering")
|
|
3483
3495
|
else:
|
|
3484
3496
|
TimingLGR.info("CVR map generation")
|
|
3485
3497
|
LGR.info("\n\nCVR mapping")
|
|
@@ -3488,46 +3500,48 @@ def rapidtide_main(argparsingfunc):
|
|
|
3488
3500
|
# initialrawvariance = tide_math.imagevariance(fmri_data_valid, None, 1.0 / fmritr)
|
|
3489
3501
|
initialvariance = tide_math.imagevariance(fmri_data_valid, theprefilter, 1.0 / fmritr)
|
|
3490
3502
|
|
|
3491
|
-
# now calculate the
|
|
3503
|
+
# now calculate the sLFO filter
|
|
3492
3504
|
if optiondict["refinedelay"] and optiondict["filterwithrefineddelay"]:
|
|
3493
3505
|
lagstouse = lagtimesrefined
|
|
3494
3506
|
else:
|
|
3495
3507
|
lagstouse = lagtimes
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3508
|
+
voxelsprocessed_regressionfilt, regressorset, evset = (
|
|
3509
|
+
tide_regressfrommaps.regressfrommaps(
|
|
3510
|
+
fmri_data_valid,
|
|
3511
|
+
validvoxels,
|
|
3512
|
+
initial_fmri_x,
|
|
3513
|
+
lagstouse,
|
|
3514
|
+
fitmask,
|
|
3515
|
+
genlagtc,
|
|
3516
|
+
mode,
|
|
3517
|
+
outputname,
|
|
3518
|
+
oversamptr,
|
|
3519
|
+
sLFOfitmean,
|
|
3520
|
+
rvalue,
|
|
3521
|
+
r2value,
|
|
3522
|
+
fitNorm[:, : optiondict["regressderivs"] + 1],
|
|
3523
|
+
fitcoeff[:, : optiondict["regressderivs"] + 1],
|
|
3524
|
+
movingsignal,
|
|
3525
|
+
lagtc,
|
|
3526
|
+
filtereddata,
|
|
3527
|
+
LGR,
|
|
3528
|
+
TimingLGR,
|
|
3529
|
+
optiondict["regressfiltthreshval"],
|
|
3530
|
+
optiondict["saveminimumsLFOfiltfiles"],
|
|
3531
|
+
nprocs_makelaggedtcs=optiondict["nprocs_makelaggedtcs"],
|
|
3532
|
+
nprocs_regressionfilt=optiondict["nprocs_regressionfilt"],
|
|
3533
|
+
regressderivs=optiondict["regressderivs"],
|
|
3534
|
+
mp_chunksize=optiondict["mp_chunksize"],
|
|
3535
|
+
showprogressbar=optiondict["showprogressbar"],
|
|
3536
|
+
alwaysmultiproc=optiondict["alwaysmultiproc"],
|
|
3537
|
+
memprofile=optiondict["memprofile"],
|
|
3538
|
+
debug=optiondict["debug"],
|
|
3539
|
+
)
|
|
3526
3540
|
)
|
|
3527
3541
|
|
|
3528
3542
|
evcolnames = ["base"]
|
|
3529
|
-
if optiondict["
|
|
3530
|
-
for i in range(1, optiondict["
|
|
3543
|
+
if optiondict["regressderivs"] > 0:
|
|
3544
|
+
for i in range(1, optiondict["regressderivs"] + 1):
|
|
3531
3545
|
evcolnames.append(f"deriv_{str(i)}")
|
|
3532
3546
|
|
|
3533
3547
|
tide_io.writebidstsv(
|
|
@@ -3535,7 +3549,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
3535
3549
|
np.transpose(evset),
|
|
3536
3550
|
1.0 / fmritr,
|
|
3537
3551
|
columns=evcolnames,
|
|
3538
|
-
extraheaderinfo={"Description": "
|
|
3552
|
+
extraheaderinfo={"Description": "sLFO filter regressor set"},
|
|
3539
3553
|
append=False,
|
|
3540
3554
|
)
|
|
3541
3555
|
|
|
@@ -3547,30 +3561,20 @@ def rapidtide_main(argparsingfunc):
|
|
|
3547
3561
|
varchange = initialvariance * 0.0
|
|
3548
3562
|
varchange[divlocs] = 100.0 * (finalvariance[divlocs] / initialvariance[divlocs] - 1.0)
|
|
3549
3563
|
|
|
3550
|
-
"""divlocs = np.where(finalrawvariance > 0.0)
|
|
3551
|
-
rawvarchange = initialrawvariance * 0.0
|
|
3552
|
-
rawvarchange[divlocs] = 100.0 * (
|
|
3553
|
-
finalrawvariance[divlocs] / initialvariance[divlocs] - 1.0
|
|
3554
|
-
)"""
|
|
3555
|
-
|
|
3556
|
-
del fmri_data_valid
|
|
3557
|
-
if optiondict["sharedmem"]:
|
|
3558
|
-
tide_util.cleanup_shm(fmri_data_valid_shm)
|
|
3559
|
-
|
|
3560
3564
|
LGR.info("End filtering operation")
|
|
3561
3565
|
TimingLGR.info(
|
|
3562
|
-
"
|
|
3566
|
+
"sLFO filtering end",
|
|
3563
3567
|
{
|
|
3564
|
-
"message2":
|
|
3568
|
+
"message2": voxelsprocessed_regressionfilt,
|
|
3565
3569
|
"message3": "voxels",
|
|
3566
3570
|
},
|
|
3567
3571
|
)
|
|
3568
3572
|
if optiondict["memprofile"]:
|
|
3569
3573
|
memcheckpoint("...done")
|
|
3570
|
-
tide_util.logmem("after
|
|
3574
|
+
tide_util.logmem("after sLFO filter")
|
|
3571
3575
|
LGR.info("")
|
|
3572
3576
|
####################################################
|
|
3573
|
-
#
|
|
3577
|
+
# sLFO filtering end
|
|
3574
3578
|
####################################################
|
|
3575
3579
|
|
|
3576
3580
|
# Post refinement step 2 - make and save interesting histograms
|
|
@@ -3608,24 +3612,24 @@ def rapidtide_main(argparsingfunc):
|
|
|
3608
3612
|
thedict=optiondict,
|
|
3609
3613
|
)
|
|
3610
3614
|
namesuffix = "_desc-lfofilterR2_hist"
|
|
3611
|
-
if optiondict["
|
|
3615
|
+
if optiondict["dolinfitfilt"]:
|
|
3612
3616
|
tide_stats.makeandsavehistogram(
|
|
3613
3617
|
r2value[np.where(fitmask > 0)],
|
|
3614
3618
|
optiondict["histlen"],
|
|
3615
3619
|
1,
|
|
3616
3620
|
outputname + namesuffix,
|
|
3617
|
-
displaytitle="Histogram of
|
|
3621
|
+
displaytitle="Histogram of sLFO filter R2 values",
|
|
3618
3622
|
dictvarname="R2hist",
|
|
3619
3623
|
thedict=optiondict,
|
|
3620
3624
|
)
|
|
3621
3625
|
namesuffix = "_desc-lfofilterInbandVarianceChange_hist"
|
|
3622
|
-
if optiondict["
|
|
3626
|
+
if optiondict["dolinfitfilt"]:
|
|
3623
3627
|
tide_stats.makeandsavehistogram(
|
|
3624
3628
|
varchange[np.where(fitmask > 0)],
|
|
3625
3629
|
optiondict["histlen"],
|
|
3626
3630
|
1,
|
|
3627
3631
|
outputname + namesuffix,
|
|
3628
|
-
displaytitle="Histogram of percent of inband variance removed by
|
|
3632
|
+
displaytitle="Histogram of percent of inband variance removed by sLFO filter",
|
|
3629
3633
|
dictvarname="varchangehist",
|
|
3630
3634
|
thedict=optiondict,
|
|
3631
3635
|
)
|
|
@@ -3714,56 +3718,55 @@ def rapidtide_main(argparsingfunc):
|
|
|
3714
3718
|
"second",
|
|
3715
3719
|
"Lag time in seconds, refined",
|
|
3716
3720
|
),
|
|
3717
|
-
(np.fabs(rvalue), "maxcorralt", "map", None, "R value of the GLM fit, with sign"),
|
|
3718
3721
|
]
|
|
3719
3722
|
if (optiondict["outputlevel"] != "min") and (optiondict["outputlevel"] != "less"):
|
|
3720
|
-
if optiondict["
|
|
3721
|
-
for i in range(optiondict["
|
|
3723
|
+
if optiondict["refineregressderivs"] > 1:
|
|
3724
|
+
for i in range(optiondict["refineregressderivs"]):
|
|
3722
3725
|
savelist += [
|
|
3723
3726
|
(
|
|
3724
|
-
|
|
3725
|
-
f"
|
|
3727
|
+
regressderivratios[i, :],
|
|
3728
|
+
f"regressderivratios_{i}",
|
|
3726
3729
|
"map",
|
|
3727
3730
|
None,
|
|
3728
3731
|
f"Ratio of derivative {i + 1} of delayed sLFO to the delayed sLFO",
|
|
3729
3732
|
),
|
|
3730
3733
|
(
|
|
3731
|
-
|
|
3732
|
-
f"
|
|
3734
|
+
medfiltregressderivratios[i, :],
|
|
3735
|
+
f"medfiltregressderivratios_{i}",
|
|
3733
3736
|
"map",
|
|
3734
3737
|
None,
|
|
3735
|
-
f"Median filtered version of the
|
|
3738
|
+
f"Median filtered version of the regressderivratios_{i} map",
|
|
3736
3739
|
),
|
|
3737
3740
|
(
|
|
3738
|
-
|
|
3739
|
-
f"
|
|
3741
|
+
filteredregressderivratios[i, :],
|
|
3742
|
+
f"filteredregressderivratios_{i}",
|
|
3740
3743
|
"map",
|
|
3741
3744
|
None,
|
|
3742
|
-
f"
|
|
3745
|
+
f"regressderivratios_{i}, with outliers patched using median filtered data",
|
|
3743
3746
|
),
|
|
3744
3747
|
]
|
|
3745
3748
|
else:
|
|
3746
3749
|
savelist += [
|
|
3747
3750
|
(
|
|
3748
|
-
|
|
3749
|
-
"
|
|
3751
|
+
regressderivratios,
|
|
3752
|
+
"regressderivratios",
|
|
3750
3753
|
"map",
|
|
3751
3754
|
None,
|
|
3752
3755
|
"Ratio of the first derivative of delayed sLFO to the delayed sLFO",
|
|
3753
3756
|
),
|
|
3754
3757
|
(
|
|
3755
|
-
|
|
3756
|
-
"
|
|
3758
|
+
medfiltregressderivratios,
|
|
3759
|
+
"medfiltregressderivratios",
|
|
3757
3760
|
"map",
|
|
3758
3761
|
None,
|
|
3759
|
-
"Median filtered version of the
|
|
3762
|
+
"Median filtered version of the regressderivratios map",
|
|
3760
3763
|
),
|
|
3761
3764
|
(
|
|
3762
|
-
|
|
3763
|
-
"
|
|
3765
|
+
filteredregressderivratios,
|
|
3766
|
+
"filteredregressderivratios",
|
|
3764
3767
|
"map",
|
|
3765
3768
|
None,
|
|
3766
|
-
"
|
|
3769
|
+
"regressderivratios, with outliers patched using median filtered data",
|
|
3767
3770
|
),
|
|
3768
3771
|
]
|
|
3769
3772
|
if optiondict["calccoherence"]:
|
|
@@ -3803,8 +3806,8 @@ def rapidtide_main(argparsingfunc):
|
|
|
3803
3806
|
tide_util.cleanup_shm(coherencepeakfreq_shm)
|
|
3804
3807
|
|
|
3805
3808
|
# write the optional 3D maps that need to be remapped
|
|
3806
|
-
if optiondict["
|
|
3807
|
-
if optiondict["
|
|
3809
|
+
if optiondict["dolinfitfilt"] or optiondict["docvrmap"]:
|
|
3810
|
+
if optiondict["dolinfitfilt"]:
|
|
3808
3811
|
maplist = [
|
|
3809
3812
|
(
|
|
3810
3813
|
initialvariance,
|
|
@@ -3828,22 +3831,22 @@ def rapidtide_main(argparsingfunc):
|
|
|
3828
3831
|
"Change in inband variance after filtering, in percent",
|
|
3829
3832
|
),
|
|
3830
3833
|
]
|
|
3831
|
-
if optiondict["
|
|
3834
|
+
if optiondict["saveminimumsLFOfiltfiles"]:
|
|
3832
3835
|
maplist += [
|
|
3833
3836
|
(
|
|
3834
3837
|
r2value,
|
|
3835
3838
|
"lfofilterR2",
|
|
3836
3839
|
"map",
|
|
3837
3840
|
None,
|
|
3838
|
-
"Squared R value of the
|
|
3841
|
+
"Squared R value of the sLFO fit (proportion of variance explained)",
|
|
3839
3842
|
),
|
|
3840
3843
|
]
|
|
3841
|
-
if optiondict["
|
|
3844
|
+
if optiondict["savenormalsLFOfiltfiles"]:
|
|
3842
3845
|
maplist += [
|
|
3843
|
-
(
|
|
3844
|
-
(
|
|
3846
|
+
(rvalue, "lfofilterR", "map", None, "R value of the sLFO fit"),
|
|
3847
|
+
(sLFOfitmean, "lfofilterMean", "map", None, "Intercept from sLFO fit"),
|
|
3845
3848
|
]
|
|
3846
|
-
if optiondict["
|
|
3849
|
+
if optiondict["regressderivs"] > 0:
|
|
3847
3850
|
maplist += [
|
|
3848
3851
|
(fitcoeff[:, 0], "lfofilterCoeff", "map", None, "Fit coefficient"),
|
|
3849
3852
|
(
|
|
@@ -3854,7 +3857,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
3854
3857
|
"Normalized fit coefficient",
|
|
3855
3858
|
),
|
|
3856
3859
|
]
|
|
3857
|
-
for thederiv in range(1, optiondict["
|
|
3860
|
+
for thederiv in range(1, optiondict["regressderivs"] + 1):
|
|
3858
3861
|
maplist += [
|
|
3859
3862
|
(
|
|
3860
3863
|
fitcoeff[:, thederiv],
|
|
@@ -3874,14 +3877,14 @@ def rapidtide_main(argparsingfunc):
|
|
|
3874
3877
|
else:
|
|
3875
3878
|
maplist += [
|
|
3876
3879
|
(
|
|
3877
|
-
fitcoeff[:, : optiondict["
|
|
3880
|
+
fitcoeff[:, : optiondict["regressderivs"] + 1],
|
|
3878
3881
|
"lfofilterCoeff",
|
|
3879
3882
|
"map",
|
|
3880
3883
|
None,
|
|
3881
3884
|
"Fit coefficient",
|
|
3882
3885
|
),
|
|
3883
3886
|
(
|
|
3884
|
-
fitNorm[:, : optiondict["
|
|
3887
|
+
fitNorm[:, : optiondict["regressderivs"] + 1],
|
|
3885
3888
|
"lfofilterNorm",
|
|
3886
3889
|
"map",
|
|
3887
3890
|
None,
|
|
@@ -3912,15 +3915,15 @@ def rapidtide_main(argparsingfunc):
|
|
|
3912
3915
|
"Percentage of inband variance attributable to CVR regressor",
|
|
3913
3916
|
),
|
|
3914
3917
|
]
|
|
3915
|
-
if optiondict["
|
|
3918
|
+
if optiondict["savenormalsLFOfiltfiles"]:
|
|
3916
3919
|
maplist = [
|
|
3917
|
-
(rvalue, "CVRR", "map", None, "R value of the
|
|
3920
|
+
(rvalue, "CVRR", "map", None, "R value of the sLFO fit"),
|
|
3918
3921
|
(
|
|
3919
3922
|
r2value,
|
|
3920
3923
|
"CVRR2",
|
|
3921
3924
|
"map",
|
|
3922
3925
|
None,
|
|
3923
|
-
"Squared R value of the
|
|
3926
|
+
"Squared R value of the sLFO fit (proportion of variance explained)",
|
|
3924
3927
|
),
|
|
3925
3928
|
(
|
|
3926
3929
|
fitcoeff,
|
|
@@ -3943,7 +3946,70 @@ def rapidtide_main(argparsingfunc):
|
|
|
3943
3946
|
rt_floattype=rt_floattype,
|
|
3944
3947
|
cifti_hdr=cifti_hdr,
|
|
3945
3948
|
)
|
|
3946
|
-
|
|
3949
|
+
|
|
3950
|
+
if optiondict["refinedelay"] and False:
|
|
3951
|
+
# filter the fmri data to the lfo band
|
|
3952
|
+
print("filtering fmri_data to sLFO band")
|
|
3953
|
+
for i in range(fmri_data_valid.shape[0]):
|
|
3954
|
+
fmri_data_valid[i, :] = theprefilter.apply(
|
|
3955
|
+
optiondict["fmrifreq"], fmri_data_valid[i, :]
|
|
3956
|
+
)
|
|
3957
|
+
|
|
3958
|
+
print("rerunning sLFO fit to get filtered R value")
|
|
3959
|
+
dummy, dummy, dummy = tide_regressfrommaps.regressfrommaps(
|
|
3960
|
+
fmri_data_valid,
|
|
3961
|
+
validvoxels,
|
|
3962
|
+
initial_fmri_x,
|
|
3963
|
+
lagstouse,
|
|
3964
|
+
fitmask,
|
|
3965
|
+
genlagtc,
|
|
3966
|
+
mode,
|
|
3967
|
+
outputname,
|
|
3968
|
+
oversamptr,
|
|
3969
|
+
sLFOfitmean,
|
|
3970
|
+
rvalue,
|
|
3971
|
+
r2value,
|
|
3972
|
+
fitNorm[:, : optiondict["regressderivs"] + 1],
|
|
3973
|
+
fitcoeff[:, : optiondict["regressderivs"] + 1],
|
|
3974
|
+
movingsignal,
|
|
3975
|
+
lagtc,
|
|
3976
|
+
filtereddata,
|
|
3977
|
+
LGR,
|
|
3978
|
+
TimingLGR,
|
|
3979
|
+
optiondict["regressfiltthreshval"],
|
|
3980
|
+
optiondict["saveminimumsLFOfiltfiles"],
|
|
3981
|
+
nprocs_makelaggedtcs=optiondict["nprocs_makelaggedtcs"],
|
|
3982
|
+
nprocs_regressionfilt=optiondict["nprocs_regressionfilt"],
|
|
3983
|
+
regressderivs=optiondict["regressderivs"],
|
|
3984
|
+
mp_chunksize=optiondict["mp_chunksize"],
|
|
3985
|
+
showprogressbar=optiondict["showprogressbar"],
|
|
3986
|
+
alwaysmultiproc=optiondict["alwaysmultiproc"],
|
|
3987
|
+
memprofile=optiondict["memprofile"],
|
|
3988
|
+
debug=optiondict["debug"],
|
|
3989
|
+
)
|
|
3990
|
+
|
|
3991
|
+
maplist = [
|
|
3992
|
+
(rvalue, "maxcorralt", "map", None, "R value of the inband sLFO fit, with sign"),
|
|
3993
|
+
]
|
|
3994
|
+
|
|
3995
|
+
tide_io.savemaplist(
|
|
3996
|
+
outputname,
|
|
3997
|
+
maplist,
|
|
3998
|
+
validvoxels,
|
|
3999
|
+
nativespaceshape,
|
|
4000
|
+
theheader,
|
|
4001
|
+
bidsbasedict,
|
|
4002
|
+
textio=optiondict["textio"],
|
|
4003
|
+
fileiscifti=fileiscifti,
|
|
4004
|
+
rt_floattype=rt_floattype,
|
|
4005
|
+
cifti_hdr=cifti_hdr,
|
|
4006
|
+
)
|
|
4007
|
+
|
|
4008
|
+
del fmri_data_valid
|
|
4009
|
+
if optiondict["sharedmem"]:
|
|
4010
|
+
tide_util.cleanup_shm(fmri_data_valid_shm)
|
|
4011
|
+
|
|
4012
|
+
del sLFOfitmean
|
|
3947
4013
|
del rvalue
|
|
3948
4014
|
del r2value
|
|
3949
4015
|
del fitcoeff
|
|
@@ -3952,7 +4018,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
3952
4018
|
del finalvariance
|
|
3953
4019
|
del varchange
|
|
3954
4020
|
if optiondict["sharedmem"]:
|
|
3955
|
-
tide_util.cleanup_shm(
|
|
4021
|
+
tide_util.cleanup_shm(sLFOfitmean_shm)
|
|
3956
4022
|
tide_util.cleanup_shm(rvalue_shm)
|
|
3957
4023
|
tide_util.cleanup_shm(r2value_shm)
|
|
3958
4024
|
tide_util.cleanup_shm(fitcoeff_shm)
|
|
@@ -4133,8 +4199,10 @@ def rapidtide_main(argparsingfunc):
|
|
|
4133
4199
|
cifti_hdr = None
|
|
4134
4200
|
|
|
4135
4201
|
maplist = []
|
|
4136
|
-
if optiondict["
|
|
4137
|
-
|
|
4202
|
+
if optiondict["saveallsLFOfiltfiles"] and (
|
|
4203
|
+
optiondict["dolinfitfilt"] or optiondict["docvrmap"]
|
|
4204
|
+
):
|
|
4205
|
+
if optiondict["regressderivs"] > 0:
|
|
4138
4206
|
maplist += [
|
|
4139
4207
|
(
|
|
4140
4208
|
regressorset[:, :, 0],
|
|
@@ -4144,7 +4212,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
4144
4212
|
"Shifted sLFO regressor to filter",
|
|
4145
4213
|
),
|
|
4146
4214
|
]
|
|
4147
|
-
for thederiv in range(1, optiondict["
|
|
4215
|
+
for thederiv in range(1, optiondict["regressderivs"] + 1):
|
|
4148
4216
|
maplist += [
|
|
4149
4217
|
(
|
|
4150
4218
|
regressorset[:, :, thederiv],
|
|
@@ -4159,7 +4227,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
4159
4227
|
(regressorset, "lfofilterEV", "bold", None, "Shifted sLFO regressor to filter"),
|
|
4160
4228
|
]
|
|
4161
4229
|
|
|
4162
|
-
if optiondict["passes"] > 1:
|
|
4230
|
+
if (optiondict["passes"] > 1) or optiondict["dofinalrefine"]:
|
|
4163
4231
|
if optiondict["savelagregressors"]:
|
|
4164
4232
|
maplist += [
|
|
4165
4233
|
(
|
|
@@ -4171,8 +4239,8 @@ def rapidtide_main(argparsingfunc):
|
|
|
4171
4239
|
),
|
|
4172
4240
|
]
|
|
4173
4241
|
|
|
4174
|
-
if optiondict["
|
|
4175
|
-
if optiondict["
|
|
4242
|
+
if optiondict["dolinfitfilt"]:
|
|
4243
|
+
if optiondict["saveminimumsLFOfiltfiles"]:
|
|
4176
4244
|
maplist += [
|
|
4177
4245
|
(
|
|
4178
4246
|
filtereddata,
|
|
@@ -4232,7 +4300,7 @@ def rapidtide_main(argparsingfunc):
|
|
|
4232
4300
|
# clean up
|
|
4233
4301
|
if optiondict["passes"] > 1:
|
|
4234
4302
|
theRegressorRefiner.cleanup()
|
|
4235
|
-
if optiondict["
|
|
4303
|
+
if optiondict["dolinfitfilt"]:
|
|
4236
4304
|
del lagtc
|
|
4237
4305
|
del filtereddata
|
|
4238
4306
|
del movingsignal
|