rapidtide 3.0a13__py3-none-any.whl → 3.0a15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rapidtide/Colortables.py +1 -1
- rapidtide/DerivativeDelay.py +4 -2
- rapidtide/OrthoImageItem.py +1 -1
- rapidtide/RapidtideDataset.py +3 -1
- rapidtide/RegressorRefiner.py +1 -1
- rapidtide/calcandfitcorrpairs.py +1 -1
- rapidtide/calccoherence.py +1 -1
- rapidtide/calcnullsimfunc.py +1 -1
- rapidtide/calcsimfunc.py +1 -1
- rapidtide/correlate.py +1 -1
- rapidtide/data/examples/src/test_findmaxlag.py +1 -1
- rapidtide/data/examples/src/testdelayvar +2 -1
- rapidtide/data/examples/src/testfmri +3 -2
- rapidtide/data/examples/src/testfuncs +1 -1
- rapidtide/data/examples/src/testhappy +12 -1
- rapidtide/data/examples/src/testmodels +33 -0
- rapidtide/data/models/model_cnn_w064_l13_fn20_fl08/loss.png +0 -0
- rapidtide/data/models/model_cnn_w064_l13_fn20_fl08/loss.txt +1 -0
- rapidtide/data/models/model_cnn_w064_l13_fn20_fl08/model.keras +0 -0
- rapidtide/data/models/model_cnn_w064_l13_fn20_fl08/model_meta.json +167 -0
- rapidtide/data/models/model_revised_tf2/model.keras +0 -0
- rapidtide/data/models/{model_serdar → model_revised_tf2}/model_meta.json +1 -1
- rapidtide/data/models/model_serdar2_tf2/model.keras +0 -0
- rapidtide/data/models/{model_serdar2 → model_serdar2_tf2}/model_meta.json +1 -1
- rapidtide/data/models/model_serdar_tf2/model.keras +0 -0
- rapidtide/data/models/{model_revised → model_serdar_tf2}/model_meta.json +1 -1
- rapidtide/dlfilter.py +325 -241
- rapidtide/externaltools.py +1 -1
- rapidtide/fMRIData_class.py +1 -1
- rapidtide/filter.py +1 -8
- rapidtide/fit.py +1 -8
- rapidtide/happy_supportfuncs.py +30 -1
- rapidtide/helper_classes.py +1 -1
- rapidtide/io.py +1 -1
- rapidtide/linfitfiltpass.py +3 -1
- rapidtide/makelaggedtcs.py +9 -6
- rapidtide/maskutil.py +1 -1
- rapidtide/miscmath.py +1 -8
- rapidtide/multiproc.py +9 -12
- rapidtide/patchmatch.py +1 -1
- rapidtide/peakeval.py +1 -1
- rapidtide/qualitycheck.py +1 -1
- rapidtide/refinedelay.py +174 -89
- rapidtide/refineregressor.py +1 -1
- rapidtide/resample.py +1 -1
- rapidtide/scripts/adjustoffset.py +1 -1
- rapidtide/scripts/aligntcs.py +1 -1
- rapidtide/scripts/applydlfilter.py +1 -1
- rapidtide/scripts/atlasaverage.py +1 -1
- rapidtide/scripts/atlastool.py +1 -1
- rapidtide/scripts/calcicc.py +1 -1
- rapidtide/scripts/calctexticc.py +1 -1
- rapidtide/scripts/calcttest.py +1 -1
- rapidtide/scripts/ccorrica.py +1 -1
- rapidtide/scripts/delayvar.py +2 -2
- rapidtide/scripts/diffrois.py +1 -1
- rapidtide/scripts/endtidalproc.py +1 -1
- rapidtide/scripts/fdica.py +1 -1
- rapidtide/scripts/filtnifti.py +1 -1
- rapidtide/scripts/filttc.py +1 -1
- rapidtide/scripts/fingerprint.py +1 -1
- rapidtide/scripts/fixtr.py +1 -1
- rapidtide/scripts/gmscalc.py +1 -1
- rapidtide/scripts/happy.py +1 -1
- rapidtide/scripts/happy2std.py +1 -1
- rapidtide/scripts/happywarp.py +1 -1
- rapidtide/scripts/histnifti.py +1 -1
- rapidtide/scripts/histtc.py +1 -1
- rapidtide/scripts/linfitfilt.py +1 -1
- rapidtide/scripts/localflow.py +1 -1
- rapidtide/scripts/mergequality.py +1 -1
- rapidtide/scripts/pairproc.py +1 -1
- rapidtide/scripts/pairwisemergenifti.py +1 -1
- rapidtide/scripts/physiofreq.py +1 -1
- rapidtide/scripts/pixelcomp.py +1 -1
- rapidtide/scripts/plethquality.py +1 -1
- rapidtide/scripts/polyfitim.py +1 -1
- rapidtide/scripts/proj2flow.py +1 -1
- rapidtide/scripts/rankimage.py +1 -1
- rapidtide/scripts/rapidtide.py +1 -1
- rapidtide/scripts/rapidtide2std.py +1 -1
- rapidtide/scripts/resamplenifti.py +1 -1
- rapidtide/scripts/resampletc.py +1 -1
- rapidtide/scripts/retrolagtcs.py +1 -1
- rapidtide/scripts/retroregress.py +1 -1
- rapidtide/scripts/roisummarize.py +1 -1
- rapidtide/scripts/runqualitycheck.py +1 -1
- rapidtide/scripts/showarbcorr.py +1 -1
- rapidtide/scripts/showhist.py +1 -1
- rapidtide/scripts/showstxcorr.py +1 -1
- rapidtide/scripts/showtc.py +1 -1
- rapidtide/scripts/showxcorr_legacy.py +1 -1
- rapidtide/scripts/showxcorrx.py +1 -1
- rapidtide/scripts/showxy.py +1 -1
- rapidtide/scripts/simdata.py +1 -1
- rapidtide/scripts/spatialdecomp.py +1 -1
- rapidtide/scripts/spatialfit.py +1 -1
- rapidtide/scripts/spatialmi.py +1 -1
- rapidtide/scripts/spectrogram.py +1 -1
- rapidtide/scripts/stupidramtricks.py +1 -1
- rapidtide/scripts/synthASL.py +1 -1
- rapidtide/scripts/tcfrom2col.py +1 -1
- rapidtide/scripts/tcfrom3col.py +1 -1
- rapidtide/scripts/temporaldecomp.py +1 -1
- rapidtide/scripts/testhrv.py +1 -1
- rapidtide/scripts/threeD.py +1 -1
- rapidtide/scripts/tidepool.py +1 -1
- rapidtide/scripts/variabilityizer.py +1 -1
- rapidtide/simfuncfit.py +1 -1
- rapidtide/stats.py +1 -8
- rapidtide/tests/cleanposttest +1 -1
- rapidtide/tests/resethappytargets +1 -1
- rapidtide/tests/resetrapidtidetargets +1 -1
- rapidtide/tests/resettargets +1 -1
- rapidtide/tests/runlocaltest +1 -1
- rapidtide/tests/showkernels +1 -1
- rapidtide/tests/test_aliasedcorrelate.py +1 -1
- rapidtide/tests/test_aligntcs.py +1 -1
- rapidtide/tests/test_calcicc.py +1 -1
- rapidtide/tests/test_congrid.py +1 -1
- rapidtide/tests/test_correlate.py +1 -1
- rapidtide/tests/test_corrpass.py +1 -1
- rapidtide/tests/test_delayestimation.py +1 -1
- rapidtide/tests/test_doresample.py +1 -1
- rapidtide/tests/test_fastresampler.py +1 -1
- rapidtide/tests/test_findmaxlag.py +1 -1
- rapidtide/tests/test_fullrunhappy_v1.py +15 -7
- rapidtide/tests/test_fullrunhappy_v2.py +18 -10
- rapidtide/tests/test_fullrunhappy_v3.py +18 -10
- rapidtide/tests/test_fullrunhappy_v4.py +18 -10
- rapidtide/tests/test_fullrunhappy_v5.py +15 -9
- rapidtide/tests/test_fullrunrapidtide_v1.py +19 -11
- rapidtide/tests/test_fullrunrapidtide_v2.py +24 -14
- rapidtide/tests/test_fullrunrapidtide_v3.py +15 -7
- rapidtide/tests/test_fullrunrapidtide_v4.py +15 -8
- rapidtide/tests/test_fullrunrapidtide_v5.py +13 -5
- rapidtide/tests/test_fullrunrapidtide_v6.py +24 -16
- rapidtide/tests/test_io.py +1 -1
- rapidtide/tests/test_linfitfiltpass.py +1 -1
- rapidtide/tests/test_mi.py +1 -1
- rapidtide/tests/test_miscmath.py +1 -1
- rapidtide/tests/test_motionregress.py +1 -1
- rapidtide/tests/test_nullcorr.py +1 -1
- rapidtide/tests/test_padvec.py +1 -1
- rapidtide/tests/test_phaseanalysis.py +1 -1
- rapidtide/tests/test_rapidtideparser.py +1 -1
- rapidtide/tests/test_refinedelay.py +4 -3
- rapidtide/tests/test_runmisc.py +1 -1
- rapidtide/tests/test_sharedmem.py +1 -1
- rapidtide/tests/test_simulate.py +1 -1
- rapidtide/tests/test_stcorrelate.py +1 -1
- rapidtide/tests/test_timeshift.py +1 -1
- rapidtide/tests/test_valtoindex.py +1 -1
- rapidtide/tests/test_zRapidtideDataset.py +1 -1
- rapidtide/tests/utils.py +1 -1
- rapidtide/transformerdlfilter.py +2 -4
- rapidtide/util.py +37 -14
- rapidtide/voxelData.py +278 -0
- rapidtide/wiener.py +1 -1
- rapidtide/wiener2.py +1 -1
- rapidtide/workflows/adjustoffset.py +1 -1
- rapidtide/workflows/aligntcs.py +1 -1
- rapidtide/workflows/applydlfilter.py +20 -65
- rapidtide/workflows/atlasaverage.py +41 -13
- rapidtide/workflows/atlastool.py +1 -1
- rapidtide/workflows/calctexticc.py +1 -1
- rapidtide/workflows/ccorrica.py +1 -1
- rapidtide/workflows/cleanregressor.py +243 -0
- rapidtide/workflows/delayestimation.py +488 -0
- rapidtide/workflows/delayvar.py +122 -34
- rapidtide/workflows/diffrois.py +1 -1
- rapidtide/workflows/endtidalproc.py +1 -1
- rapidtide/workflows/fdica.py +1 -1
- rapidtide/workflows/filtnifti.py +1 -1
- rapidtide/workflows/filttc.py +1 -1
- rapidtide/workflows/fixtr.py +1 -1
- rapidtide/workflows/gmscalc.py +1 -1
- rapidtide/workflows/happy.py +49 -3
- rapidtide/workflows/happy2std.py +1 -1
- rapidtide/workflows/happy_parser.py +30 -6
- rapidtide/workflows/histnifti.py +1 -1
- rapidtide/workflows/histtc.py +1 -1
- rapidtide/workflows/linfitfilt.py +1 -1
- rapidtide/workflows/localflow.py +1 -1
- rapidtide/workflows/mergequality.py +1 -1
- rapidtide/workflows/niftidecomp.py +1 -1
- rapidtide/workflows/niftistats.py +1 -1
- rapidtide/workflows/pairproc.py +1 -1
- rapidtide/workflows/pairwisemergenifti.py +1 -1
- rapidtide/workflows/parser_funcs.py +1 -1
- rapidtide/workflows/physiofreq.py +1 -1
- rapidtide/workflows/pixelcomp.py +1 -1
- rapidtide/workflows/plethquality.py +1 -1
- rapidtide/workflows/polyfitim.py +1 -1
- rapidtide/workflows/proj2flow.py +1 -1
- rapidtide/workflows/rankimage.py +1 -1
- rapidtide/workflows/rapidtide.py +174 -686
- rapidtide/workflows/rapidtide2std.py +1 -1
- rapidtide/workflows/rapidtide_parser.py +14 -113
- rapidtide/workflows/regressfrommaps.py +6 -48
- rapidtide/workflows/resamplenifti.py +1 -1
- rapidtide/workflows/resampletc.py +1 -1
- rapidtide/workflows/retrolagtcs.py +2 -1
- rapidtide/workflows/retroregress.py +26 -2
- rapidtide/workflows/roisummarize.py +1 -1
- rapidtide/workflows/runqualitycheck.py +1 -1
- rapidtide/workflows/showarbcorr.py +1 -1
- rapidtide/workflows/showhist.py +1 -1
- rapidtide/workflows/showstxcorr.py +1 -1
- rapidtide/workflows/showtc.py +1 -1
- rapidtide/workflows/showxcorrx.py +1 -1
- rapidtide/workflows/showxy.py +1 -1
- rapidtide/workflows/simdata.py +1 -1
- rapidtide/workflows/spatialfit.py +1 -1
- rapidtide/workflows/spatialmi.py +1 -1
- rapidtide/workflows/spectrogram.py +1 -1
- rapidtide/workflows/synthASL.py +1 -1
- rapidtide/workflows/tcfrom2col.py +1 -1
- rapidtide/workflows/tcfrom3col.py +1 -1
- rapidtide/workflows/tidepool.py +2 -1
- rapidtide/workflows/utils.py +1 -1
- rapidtide/workflows/variabilityizer.py +1 -1
- {rapidtide-3.0a13.dist-info → rapidtide-3.0a15.dist-info}/METADATA +1 -1
- rapidtide-3.0a15.dist-info/RECORD +353 -0
- {rapidtide-3.0a13.dist-info → rapidtide-3.0a15.dist-info}/WHEEL +1 -1
- rapidtide/data/models/model_revised/model.h5 +0 -0
- rapidtide/data/models/model_serdar/model.h5 +0 -0
- rapidtide/data/models/model_serdar2/model.h5 +0 -0
- rapidtide-3.0a13.dist-info/RECORD +0 -345
- {rapidtide-3.0a13.dist-info → rapidtide-3.0a15.dist-info}/entry_points.txt +0 -0
- {rapidtide-3.0a13.dist-info → rapidtide-3.0a15.dist-info}/licenses/LICENSE +0 -0
- {rapidtide-3.0a13.dist-info → rapidtide-3.0a15.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
#
|
|
4
|
-
# Copyright 2016-
|
|
4
|
+
# Copyright 2016-2025 Blaise Frederick
|
|
5
5
|
#
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
# you may not use this file except in compliance with the License.
|
|
@@ -135,6 +135,15 @@ def _get_parser():
|
|
|
135
135
|
),
|
|
136
136
|
default=None,
|
|
137
137
|
)
|
|
138
|
+
parser.add_argument(
|
|
139
|
+
"--regionlabelfile",
|
|
140
|
+
type=lambda x: pf.is_valid_file(parser, x),
|
|
141
|
+
help=(
|
|
142
|
+
"The name of of a text file containing the labels of the regions, one per line. The first line is "
|
|
143
|
+
"the label integer value 1, etc."
|
|
144
|
+
),
|
|
145
|
+
default=None,
|
|
146
|
+
)
|
|
138
147
|
parser.add_argument(
|
|
139
148
|
"--includemask",
|
|
140
149
|
dest="includespec",
|
|
@@ -224,11 +233,9 @@ def atlasaverage(args):
|
|
|
224
233
|
sys.exit()
|
|
225
234
|
|
|
226
235
|
print("reshaping")
|
|
227
|
-
|
|
228
|
-
ysize =
|
|
229
|
-
|
|
230
|
-
numtimepoints = thedims[4]
|
|
231
|
-
numvoxels = int(xsize) * int(ysize) * int(numslices)
|
|
236
|
+
xdim, ydim, numslices, numtimepoints = tide_io.parseniftidims(thedims)
|
|
237
|
+
xsize, ysize, slicethickness, tr = tide_io.parseniftisizes(thesizes)
|
|
238
|
+
numvoxels = int(xdim) * int(ydim) * int(numslices)
|
|
232
239
|
|
|
233
240
|
templatevoxels = np.reshape(template_data, numvoxels).astype(int)
|
|
234
241
|
inputvoxels = np.reshape(input_data, (numvoxels, numtimepoints))
|
|
@@ -273,7 +280,7 @@ def atlasaverage(args):
|
|
|
273
280
|
themask = themask * includemask.reshape((numvoxels))
|
|
274
281
|
if args.debug:
|
|
275
282
|
tide_io.savetonifti(
|
|
276
|
-
includemask.reshape((
|
|
283
|
+
includemask.reshape((xdim, ydim, numslices)),
|
|
277
284
|
template_hdr,
|
|
278
285
|
f"{args.outputroot}_includemask",
|
|
279
286
|
)
|
|
@@ -281,7 +288,7 @@ def atlasaverage(args):
|
|
|
281
288
|
themask = themask * (1 - excludemask.reshape((numvoxels)))
|
|
282
289
|
if args.debug:
|
|
283
290
|
tide_io.savetonifti(
|
|
284
|
-
excludemask.reshape((
|
|
291
|
+
excludemask.reshape((xdim, ydim, numslices)),
|
|
285
292
|
template_hdr,
|
|
286
293
|
f"{args.outputroot}_excludemask",
|
|
287
294
|
)
|
|
@@ -289,11 +296,21 @@ def atlasaverage(args):
|
|
|
289
296
|
themask = themask * extramask.reshape((numvoxels))
|
|
290
297
|
if args.debug:
|
|
291
298
|
tide_io.savetonifti(
|
|
292
|
-
extramask.reshape((
|
|
299
|
+
extramask.reshape((xdim, ydim, numslices)),
|
|
293
300
|
template_hdr,
|
|
294
301
|
f"{args.outputroot}_extramask",
|
|
295
302
|
)
|
|
296
303
|
|
|
304
|
+
# get the region names
|
|
305
|
+
if args.regionlabelfile is None:
|
|
306
|
+
regionlabels = []
|
|
307
|
+
numregions = np.max(templatevoxels)
|
|
308
|
+
numdigits = int(np.log10(numregions)) + 1
|
|
309
|
+
for regnum in range(1, numregions + 1):
|
|
310
|
+
regionlabels.append(f"region_{str(regnum).zfill(numdigits)}")
|
|
311
|
+
else:
|
|
312
|
+
regionlabels = tide_io.readlabels(args.regionlabelfile)
|
|
313
|
+
|
|
297
314
|
# decide what regions we will summarize
|
|
298
315
|
if args.regionlistfile is None:
|
|
299
316
|
numregions = np.max(templatevoxels)
|
|
@@ -301,6 +318,11 @@ def atlasaverage(args):
|
|
|
301
318
|
else:
|
|
302
319
|
regionlist = tide_io.readvec(args.regionlistfile).astype(int)
|
|
303
320
|
numregions = len(regionlist)
|
|
321
|
+
newlabels = []
|
|
322
|
+
for theregion in range(numregions):
|
|
323
|
+
newlabels.append(regionlabels[theregion])
|
|
324
|
+
regionlabels = newlabels
|
|
325
|
+
|
|
304
326
|
timecourses = np.zeros((numregions, numtimepoints), dtype="float")
|
|
305
327
|
print(f"{numregions=}, {regionlist=}")
|
|
306
328
|
|
|
@@ -348,7 +370,13 @@ def atlasaverage(args):
|
|
|
348
370
|
)
|
|
349
371
|
if args.debug:
|
|
350
372
|
print("timecourses shape:", timecourses.shape)
|
|
351
|
-
tide_io.
|
|
373
|
+
tide_io.writebidstsv(
|
|
374
|
+
args.outputroot,
|
|
375
|
+
timecourses,
|
|
376
|
+
1.0 / tr,
|
|
377
|
+
columns=regionlabels,
|
|
378
|
+
yaxislabel="delay offset",
|
|
379
|
+
)
|
|
352
380
|
else:
|
|
353
381
|
print("processing 3D input file")
|
|
354
382
|
outputvoxels = inputvoxels * 0.0
|
|
@@ -416,19 +444,19 @@ def atlasaverage(args):
|
|
|
416
444
|
segmentedatlasvoxels += scratchvoxels
|
|
417
445
|
template_hdr["dim"][4] = 1
|
|
418
446
|
tide_io.savetonifti(
|
|
419
|
-
outputvoxels.reshape((
|
|
447
|
+
outputvoxels.reshape((xdim, ydim, numslices)),
|
|
420
448
|
template_hdr,
|
|
421
449
|
args.outputroot,
|
|
422
450
|
)
|
|
423
451
|
tide_io.savetonifti(
|
|
424
|
-
segmentedatlasvoxels.reshape((
|
|
452
|
+
segmentedatlasvoxels.reshape((xdim, ydim, numslices)),
|
|
425
453
|
template_hdr,
|
|
426
454
|
args.outputroot + "_percentiles",
|
|
427
455
|
)
|
|
428
456
|
|
|
429
457
|
if args.includename is not None or args.excludename is not None:
|
|
430
458
|
tide_io.savetonifti(
|
|
431
|
-
(templatevoxels * themask).reshape((
|
|
459
|
+
(templatevoxels * themask).reshape((xdim, ydim, numslices)),
|
|
432
460
|
template_hdr,
|
|
433
461
|
f"{args.outputroot}_maskedatlas",
|
|
434
462
|
)
|
rapidtide/workflows/atlastool.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
#
|
|
4
|
-
# Copyright 2016-
|
|
4
|
+
# Copyright 2016-2025 Blaise Frederick
|
|
5
5
|
#
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
# you may not use this file except in compliance with the License.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
#
|
|
4
|
-
# Copyright 2016-
|
|
4
|
+
# Copyright 2016-2025 Blaise Frederick
|
|
5
5
|
#
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
# you may not use this file except in compliance with the License.
|
rapidtide/workflows/ccorrica.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
#
|
|
4
|
-
# Copyright 2016-
|
|
4
|
+
# Copyright 2016-2025 Blaise Frederick
|
|
5
5
|
#
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
# you may not use this file except in compliance with the License.
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2016-2025 Blaise Frederick
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
#
|
|
19
|
+
import numpy as np
|
|
20
|
+
|
|
21
|
+
import rapidtide.correlate as tide_corr
|
|
22
|
+
import rapidtide.filter as tide_filt
|
|
23
|
+
import rapidtide.helper_classes as tide_classes
|
|
24
|
+
import rapidtide.io as tide_io
|
|
25
|
+
import rapidtide.miscmath as tide_math
|
|
26
|
+
import rapidtide.simfuncfit as tide_simfuncfit
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def cleanregressor(
|
|
30
|
+
outputname,
|
|
31
|
+
thepass,
|
|
32
|
+
referencetc,
|
|
33
|
+
resampref_y,
|
|
34
|
+
resampnonosref_y,
|
|
35
|
+
fmrifreq,
|
|
36
|
+
oversampfreq,
|
|
37
|
+
osvalidsimcalcstart,
|
|
38
|
+
osvalidsimcalcend,
|
|
39
|
+
lagmininpts,
|
|
40
|
+
lagmaxinpts,
|
|
41
|
+
theFitter,
|
|
42
|
+
theCorrelator,
|
|
43
|
+
lagmin,
|
|
44
|
+
lagmax,
|
|
45
|
+
LGR=None,
|
|
46
|
+
check_autocorrelation=True,
|
|
47
|
+
fix_autocorrelation=True,
|
|
48
|
+
despeckle_thresh=5.0,
|
|
49
|
+
lthreshval=0.0,
|
|
50
|
+
fixdelay=False,
|
|
51
|
+
detrendorder=3,
|
|
52
|
+
windowfunc="hamming",
|
|
53
|
+
respdelete=False,
|
|
54
|
+
debug=False,
|
|
55
|
+
rt_floattype="float64",
|
|
56
|
+
rt_floatset=np.float64,
|
|
57
|
+
):
|
|
58
|
+
# check the regressor for periodic components in the passband
|
|
59
|
+
dolagmod = True
|
|
60
|
+
doreferencenotch = True
|
|
61
|
+
if respdelete:
|
|
62
|
+
resptracker = tide_classes.FrequencyTracker(nperseg=64)
|
|
63
|
+
thetimes, thefreqs = resptracker.track(resampref_y, oversampfreq)
|
|
64
|
+
tide_io.writevec(thefreqs, f"{outputname}_peakfreaks_pass{thepass}.txt")
|
|
65
|
+
resampref_y = resptracker.clean(resampref_y, oversampfreq, thetimes, thefreqs)
|
|
66
|
+
tide_io.writevec(resampref_y, f"{outputname}_respfilt_pass{thepass}.txt")
|
|
67
|
+
referencetc = tide_math.corrnormalize(
|
|
68
|
+
resampref_y[osvalidsimcalcstart : osvalidsimcalcend + 1],
|
|
69
|
+
detrendorder=detrendorder,
|
|
70
|
+
windowfunc=windowfunc,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
if check_autocorrelation:
|
|
74
|
+
if LGR is not None:
|
|
75
|
+
LGR.info("checking reference regressor autocorrelation properties")
|
|
76
|
+
lagmod = 1000.0
|
|
77
|
+
lagindpad = np.max((lagmininpts, lagmaxinpts))
|
|
78
|
+
acmininpts = lagindpad
|
|
79
|
+
acmaxinpts = lagindpad
|
|
80
|
+
theCorrelator.setreftc(referencetc)
|
|
81
|
+
theCorrelator.setlimits(acmininpts, acmaxinpts)
|
|
82
|
+
# theCorrelator.setlimits(lagmininpts, lagmaxinpts)
|
|
83
|
+
print("check_autocorrelation:", acmininpts, acmaxinpts, lagmininpts, lagmaxinpts)
|
|
84
|
+
thexcorr, accheckcorrscale, dummy = theCorrelator.run(
|
|
85
|
+
resampref_y[osvalidsimcalcstart : osvalidsimcalcend + 1]
|
|
86
|
+
)
|
|
87
|
+
theFitter.setcorrtimeaxis(accheckcorrscale)
|
|
88
|
+
(
|
|
89
|
+
dummy,
|
|
90
|
+
dummy,
|
|
91
|
+
dummy,
|
|
92
|
+
acwidth,
|
|
93
|
+
dummy,
|
|
94
|
+
dummy,
|
|
95
|
+
dummy,
|
|
96
|
+
dummy,
|
|
97
|
+
) = tide_simfuncfit.onesimfuncfit(
|
|
98
|
+
thexcorr,
|
|
99
|
+
theFitter,
|
|
100
|
+
despeckle_thresh=despeckle_thresh,
|
|
101
|
+
lthreshval=lthreshval,
|
|
102
|
+
fixdelay=fixdelay,
|
|
103
|
+
rt_floatset=rt_floatset,
|
|
104
|
+
rt_floattype=rt_floattype,
|
|
105
|
+
)
|
|
106
|
+
tide_io.writebidstsv(
|
|
107
|
+
f"{outputname}_desc-autocorr_timeseries",
|
|
108
|
+
thexcorr,
|
|
109
|
+
1.0 / (accheckcorrscale[1] - accheckcorrscale[0]),
|
|
110
|
+
starttime=accheckcorrscale[0],
|
|
111
|
+
extraheaderinfo={
|
|
112
|
+
"Description": "Autocorrelation of the probe regressor for each pass"
|
|
113
|
+
},
|
|
114
|
+
columns=[f"pass{thepass}"],
|
|
115
|
+
append=(thepass > 1),
|
|
116
|
+
)
|
|
117
|
+
thelagthresh = np.max((abs(lagmin), abs(lagmax)))
|
|
118
|
+
theampthresh = 0.1
|
|
119
|
+
if LGR is not None:
|
|
120
|
+
LGR.info(
|
|
121
|
+
f"searching for sidelobes with amplitude > {theampthresh} "
|
|
122
|
+
f"with abs(lag) < {thelagthresh} s"
|
|
123
|
+
)
|
|
124
|
+
sidelobetime, sidelobeamp = tide_corr.check_autocorrelation(
|
|
125
|
+
accheckcorrscale,
|
|
126
|
+
thexcorr,
|
|
127
|
+
acampthresh=theampthresh,
|
|
128
|
+
aclagthresh=thelagthresh,
|
|
129
|
+
detrendorder=detrendorder,
|
|
130
|
+
)
|
|
131
|
+
absmaxsigma = acwidth * 10.0
|
|
132
|
+
passsuffix = "_pass" + str(thepass)
|
|
133
|
+
if sidelobetime is not None:
|
|
134
|
+
despeckle_thresh = np.max([despeckle_thresh, sidelobetime / 2.0])
|
|
135
|
+
LGR.warning(
|
|
136
|
+
f"\n\nWARNING: check_autocorrelation found bad sidelobe at {sidelobetime} "
|
|
137
|
+
f"seconds ({1.0 / sidelobetime} Hz)..."
|
|
138
|
+
)
|
|
139
|
+
# bidsify
|
|
140
|
+
"""tide_io.writebidstsv(
|
|
141
|
+
f"{outputname}_desc-movingregressor_timeseries",
|
|
142
|
+
tide_math.stdnormalize(resampnonosref_y),
|
|
143
|
+
1.0 / fmritr,
|
|
144
|
+
columns=["pass1"],
|
|
145
|
+
append=False,
|
|
146
|
+
)"""
|
|
147
|
+
tide_io.writenpvecs(
|
|
148
|
+
np.array([sidelobetime]),
|
|
149
|
+
f"{outputname}_autocorr_sidelobetime" + passsuffix + ".txt",
|
|
150
|
+
)
|
|
151
|
+
if fix_autocorrelation:
|
|
152
|
+
if LGR is not None:
|
|
153
|
+
LGR.info("Removing sidelobe")
|
|
154
|
+
if dolagmod:
|
|
155
|
+
if LGR is not None:
|
|
156
|
+
LGR.info("subjecting lag times to modulus")
|
|
157
|
+
lagmod = sidelobetime / 2.0
|
|
158
|
+
if doreferencenotch:
|
|
159
|
+
if LGR is not None:
|
|
160
|
+
LGR.info("removing spectral component at sidelobe frequency")
|
|
161
|
+
acstopfreq = 1.0 / sidelobetime
|
|
162
|
+
acfixfilter = tide_filt.NoncausalFilter(
|
|
163
|
+
debug=debug,
|
|
164
|
+
)
|
|
165
|
+
acfixfilter.settype("arb_stop")
|
|
166
|
+
acfixfilter.setfreqs(
|
|
167
|
+
acstopfreq * 0.9,
|
|
168
|
+
acstopfreq * 0.95,
|
|
169
|
+
acstopfreq * 1.05,
|
|
170
|
+
acstopfreq * 1.1,
|
|
171
|
+
)
|
|
172
|
+
cleaned_resampref_y = tide_math.corrnormalize(
|
|
173
|
+
acfixfilter.apply(oversampfreq, resampref_y),
|
|
174
|
+
windowfunc="None",
|
|
175
|
+
detrendorder=detrendorder,
|
|
176
|
+
)
|
|
177
|
+
cleaned_referencetc = tide_math.corrnormalize(
|
|
178
|
+
cleaned_resampref_y,
|
|
179
|
+
detrendorder=detrendorder,
|
|
180
|
+
windowfunc=windowfunc,
|
|
181
|
+
)
|
|
182
|
+
cleaned_nonosreferencetc = tide_math.stdnormalize(
|
|
183
|
+
acfixfilter.apply(fmrifreq, resampnonosref_y)
|
|
184
|
+
)
|
|
185
|
+
tide_io.writebidstsv(
|
|
186
|
+
f"{outputname}_desc-cleanedreferencefmrires_info",
|
|
187
|
+
cleaned_nonosreferencetc,
|
|
188
|
+
fmrifreq,
|
|
189
|
+
columns=[f"pass{thepass}"],
|
|
190
|
+
append=(thepass > 1),
|
|
191
|
+
)
|
|
192
|
+
tide_io.writebidstsv(
|
|
193
|
+
f"{outputname}_desc-cleanedreference_info",
|
|
194
|
+
cleaned_referencetc,
|
|
195
|
+
oversampfreq,
|
|
196
|
+
columns=[f"pass{thepass}"],
|
|
197
|
+
append=(thepass > 1),
|
|
198
|
+
)
|
|
199
|
+
tide_io.writebidstsv(
|
|
200
|
+
f"{outputname}_desc-cleanedresamprefy_info",
|
|
201
|
+
cleaned_resampref_y,
|
|
202
|
+
oversampfreq,
|
|
203
|
+
columns=[f"pass{thepass}"],
|
|
204
|
+
append=(thepass > 1),
|
|
205
|
+
)
|
|
206
|
+
else:
|
|
207
|
+
cleaned_resampref_y = 1.0 * tide_math.corrnormalize(
|
|
208
|
+
resampref_y,
|
|
209
|
+
windowfunc="None",
|
|
210
|
+
detrendorder=detrendorder,
|
|
211
|
+
)
|
|
212
|
+
cleaned_referencetc = 1.0 * referencetc
|
|
213
|
+
cleaned_nonosreferencetc = 1.0 * resampnonosref_y
|
|
214
|
+
else:
|
|
215
|
+
if LGR is not None:
|
|
216
|
+
LGR.info("no sidelobes found in range")
|
|
217
|
+
cleaned_resampref_y = 1.0 * tide_math.corrnormalize(
|
|
218
|
+
resampref_y,
|
|
219
|
+
windowfunc="None",
|
|
220
|
+
detrendorder=detrendorder,
|
|
221
|
+
)
|
|
222
|
+
cleaned_referencetc = 1.0 * referencetc
|
|
223
|
+
cleaned_nonosreferencetc = 1.0 * resampnonosref_y
|
|
224
|
+
else:
|
|
225
|
+
acwidth = None
|
|
226
|
+
absmaxsigma = None
|
|
227
|
+
cleaned_resampref_y = 1.0 * tide_math.corrnormalize(
|
|
228
|
+
resampref_y, windowfunc="None", detrendorder=detrendorder
|
|
229
|
+
)
|
|
230
|
+
cleaned_referencetc = 1.0 * referencetc
|
|
231
|
+
cleaned_nonosreferencetc = 1.0 * resampnonosref_y
|
|
232
|
+
|
|
233
|
+
return (
|
|
234
|
+
cleaned_resampref_y,
|
|
235
|
+
cleaned_referencetc,
|
|
236
|
+
cleaned_nonosreferencetc,
|
|
237
|
+
despeckle_thresh,
|
|
238
|
+
sidelobeamp,
|
|
239
|
+
sidelobetime,
|
|
240
|
+
lagmod,
|
|
241
|
+
acwidth,
|
|
242
|
+
absmaxsigma,
|
|
243
|
+
)
|