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.
|
|
@@ -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.
|
|
@@ -151,7 +151,6 @@ def eval_refinedelay(
|
|
|
151
151
|
"mp_chunksize": 1000,
|
|
152
152
|
"showprogressbar": False,
|
|
153
153
|
"alwaysmultiproc": False,
|
|
154
|
-
"memprofile": False,
|
|
155
154
|
"focaldebug": debug,
|
|
156
155
|
"fmrifreq": Fs,
|
|
157
156
|
"textio": False,
|
|
@@ -195,7 +194,9 @@ def eval_refinedelay(
|
|
|
195
194
|
|
|
196
195
|
delayoffset = filteredregressderivratios * 0.0
|
|
197
196
|
for i in range(filteredregressderivratios.shape[0]):
|
|
198
|
-
delayoffset[i] = tide_refinedelay.ratiotodelay(
|
|
197
|
+
delayoffset[i], closestoffset = tide_refinedelay.ratiotodelay(
|
|
198
|
+
filteredregressderivratios[i]
|
|
199
|
+
)
|
|
199
200
|
|
|
200
201
|
# do the tests
|
|
201
202
|
msethresh = 0.1
|
rapidtide/tests/test_runmisc.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/tests/test_simulate.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
#
|
|
4
|
-
# Copyright 2017-
|
|
4
|
+
# Copyright 2017-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.
|
|
@@ -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.
|
|
@@ -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/tests/utils.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.
|
rapidtide/transformerdlfilter.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.
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
#
|
|
18
18
|
#
|
|
19
|
-
"""This module contains all an alternate filter routine
|
|
20
|
-
|
|
21
|
-
"""
|
|
19
|
+
"""This module contains all an alternate filter routine"""
|
|
22
20
|
import tensorflow as tf
|
|
23
21
|
from tensorflow.keras.layers import (
|
|
24
22
|
Dense,
|
rapidtide/util.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.
|
|
@@ -35,6 +35,13 @@ import pandas as pd
|
|
|
35
35
|
import rapidtide._version as tide_versioneer
|
|
36
36
|
import rapidtide.io as tide_io
|
|
37
37
|
|
|
38
|
+
try:
|
|
39
|
+
import mkl
|
|
40
|
+
|
|
41
|
+
mklexists = True
|
|
42
|
+
except ImportError:
|
|
43
|
+
mklexists = False
|
|
44
|
+
|
|
38
45
|
LGR = logging.getLogger(__name__)
|
|
39
46
|
TimingLGR = logging.getLogger("TIMING")
|
|
40
47
|
MemoryLGR = logging.getLogger("MEMORY")
|
|
@@ -46,13 +53,6 @@ MAXLINES = 10000000
|
|
|
46
53
|
donotbeaggressive = True
|
|
47
54
|
|
|
48
55
|
# ----------------------------------------- Conditional imports ---------------------------------------
|
|
49
|
-
try:
|
|
50
|
-
from memory_profiler import profile
|
|
51
|
-
|
|
52
|
-
memprofilerexists = True
|
|
53
|
-
except ImportError:
|
|
54
|
-
memprofilerexists = False
|
|
55
|
-
|
|
56
56
|
try:
|
|
57
57
|
from numba import jit
|
|
58
58
|
except ImportError:
|
|
@@ -69,12 +69,6 @@ else:
|
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
def checkimports(optiondict):
|
|
72
|
-
if memprofilerexists:
|
|
73
|
-
print("memprofiler exists")
|
|
74
|
-
else:
|
|
75
|
-
print("memprofiler does not exist")
|
|
76
|
-
optiondict["memprofilerexists"] = memprofilerexists
|
|
77
|
-
|
|
78
72
|
if pyfftwpresent:
|
|
79
73
|
print("pfftw exists")
|
|
80
74
|
else:
|
|
@@ -119,6 +113,21 @@ def disablenumba():
|
|
|
119
113
|
donotusenumba = True
|
|
120
114
|
|
|
121
115
|
|
|
116
|
+
def disablemkl(numprocs, debug=False):
|
|
117
|
+
if mklexists:
|
|
118
|
+
if numprocs > 1:
|
|
119
|
+
if debug:
|
|
120
|
+
print("disablemkl: setting threads to 1")
|
|
121
|
+
mkl.set_num_threads(1)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def enablemkl(numthreads, debug=False):
|
|
125
|
+
if mklexists:
|
|
126
|
+
if debug:
|
|
127
|
+
print(f"enablemkl: setting threads to {numthreads}")
|
|
128
|
+
mkl.set_num_threads(numthreads)
|
|
129
|
+
|
|
130
|
+
|
|
122
131
|
# --------------------------- Utility functions -------------------------------------------------
|
|
123
132
|
def findavailablemem():
|
|
124
133
|
if os.path.isfile("/sys/fs/cgroup/memory/memory.limit_in_bytes"):
|
|
@@ -292,6 +301,20 @@ def isexecutable(command):
|
|
|
292
301
|
)
|
|
293
302
|
|
|
294
303
|
|
|
304
|
+
def makeadir(pathname):
|
|
305
|
+
try:
|
|
306
|
+
os.makedirs(pathname)
|
|
307
|
+
except OSError:
|
|
308
|
+
if os.path.exists(pathname):
|
|
309
|
+
# We are nearly safe
|
|
310
|
+
return True
|
|
311
|
+
else:
|
|
312
|
+
# There was an error on creation, so make sure we know about it
|
|
313
|
+
print("ERROR: ", pathname, " does not exist, and could not create it")
|
|
314
|
+
return False
|
|
315
|
+
return True
|
|
316
|
+
|
|
317
|
+
|
|
295
318
|
def findreferencedir():
|
|
296
319
|
# Get the list of directories
|
|
297
320
|
site_packages_dirs = site.getsitepackages()
|
rapidtide/voxelData.py
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
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
|
+
from tf_keras.src.layers.preprocessing.benchmarks.index_lookup_forward_benchmark import (
|
|
21
|
+
get_vocab,
|
|
22
|
+
)
|
|
23
|
+
from tqdm import tqdm
|
|
24
|
+
|
|
25
|
+
import rapidtide.filter as tide_filt
|
|
26
|
+
import rapidtide.io as tide_io
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class VoxelData:
|
|
30
|
+
nim = None
|
|
31
|
+
nim_data = None
|
|
32
|
+
nim_hdr = None
|
|
33
|
+
nim_affine = None
|
|
34
|
+
theshape = None
|
|
35
|
+
xsize = None
|
|
36
|
+
ysize = None
|
|
37
|
+
numslices = None
|
|
38
|
+
timepoints = None
|
|
39
|
+
xdim = None
|
|
40
|
+
ydim = None
|
|
41
|
+
slicethickness = None
|
|
42
|
+
timestep = None
|
|
43
|
+
thesizes = None
|
|
44
|
+
thedims = None
|
|
45
|
+
numspatiallocs = None
|
|
46
|
+
nativespaceshape = None
|
|
47
|
+
validvoxels = None
|
|
48
|
+
cifti_hdr = None
|
|
49
|
+
filetype = None
|
|
50
|
+
resident = False
|
|
51
|
+
|
|
52
|
+
def __init__(
|
|
53
|
+
self,
|
|
54
|
+
filename,
|
|
55
|
+
timestep=0.0,
|
|
56
|
+
validstart=None,
|
|
57
|
+
validend=None,
|
|
58
|
+
):
|
|
59
|
+
|
|
60
|
+
self.filename = filename
|
|
61
|
+
self.readdata(timestep, validstart, validend)
|
|
62
|
+
|
|
63
|
+
def readdata(self, timestep, validstart, validend):
|
|
64
|
+
self.load()
|
|
65
|
+
|
|
66
|
+
if tide_io.checkiftext(self.filename):
|
|
67
|
+
self.filetype = "text"
|
|
68
|
+
self.nim_hdr = None
|
|
69
|
+
self.nim_affine = None
|
|
70
|
+
self.theshape = np.shape(self.nim_data)
|
|
71
|
+
self.xsize = self.theshape[0]
|
|
72
|
+
self.ysize = 1
|
|
73
|
+
self.numslices = 1
|
|
74
|
+
self.timepoints = self.theshape[1]
|
|
75
|
+
self.thesizes = [0, int(self.xsize), 1, 1, int(self.timepoints)]
|
|
76
|
+
self.toffset = 0.0
|
|
77
|
+
self.numspatiallocs = int(self.xsize)
|
|
78
|
+
self.nativespaceshape = self.xsize
|
|
79
|
+
self.cifti_hdr = None
|
|
80
|
+
else:
|
|
81
|
+
if tide_io.checkifcifti(self.filename):
|
|
82
|
+
self.filetype = "cifti"
|
|
83
|
+
self.nim_affine = None
|
|
84
|
+
self.timepoints = self.nim_data.shape[1]
|
|
85
|
+
self.numspatiallocs = self.nim_data.shape[0]
|
|
86
|
+
self.nativespaceshape = (1, 1, 1, 1, self.numspatiallocs)
|
|
87
|
+
else:
|
|
88
|
+
self.filetype = "nifti"
|
|
89
|
+
self.nim_affine = self.nim.affine
|
|
90
|
+
self.xsize, self.ysize, self.numslices, self.timepoints = tide_io.parseniftidims(
|
|
91
|
+
self.thedims
|
|
92
|
+
)
|
|
93
|
+
self.numspatiallocs = int(self.xsize) * int(self.ysize) * int(self.numslices)
|
|
94
|
+
self.cifti_hdr = None
|
|
95
|
+
self.nativespaceshape = (self.xsize, self.ysize, self.numslices)
|
|
96
|
+
self.xdim, self.ydim, self.slicethickness, dummy = tide_io.parseniftisizes(
|
|
97
|
+
self.thesizes
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# correct some fields if necessary
|
|
101
|
+
if self.filetype == "cifti":
|
|
102
|
+
self.timestep = 0.72 # this is wrong and is a hack until I can parse CIFTI XML
|
|
103
|
+
self.toffset = 0.0
|
|
104
|
+
else:
|
|
105
|
+
if self.filetype == "text":
|
|
106
|
+
if timestep <= 0.0:
|
|
107
|
+
raise ValueError(
|
|
108
|
+
"for text file data input, you must use the -t option to set the timestep"
|
|
109
|
+
)
|
|
110
|
+
else:
|
|
111
|
+
if self.nim_hdr.get_xyzt_units()[1] == "msec":
|
|
112
|
+
self.timestep = self.thesizes[4] / 1000.0
|
|
113
|
+
self.toffset = self.nim_hdr["toffset"] / 1000.0
|
|
114
|
+
else:
|
|
115
|
+
self.timestep = self.thesizes[4]
|
|
116
|
+
self.toffset = self.nim_hdr["toffset"]
|
|
117
|
+
if timestep > 0.0:
|
|
118
|
+
self.timestep = timestep
|
|
119
|
+
|
|
120
|
+
self.setvalidtimes(validstart, validend)
|
|
121
|
+
self.resident = True
|
|
122
|
+
|
|
123
|
+
def getsizes(self):
|
|
124
|
+
return self.xdim, self.ydim, self.slicethickness, self.timestep
|
|
125
|
+
|
|
126
|
+
def getdims(self):
|
|
127
|
+
return self.xsize, self.ysize, self.numslices, self.timepoints
|
|
128
|
+
|
|
129
|
+
def unload(self):
|
|
130
|
+
del self.nim_data
|
|
131
|
+
del self.nim
|
|
132
|
+
self.resident = False
|
|
133
|
+
|
|
134
|
+
def load(self):
|
|
135
|
+
if self.filetype is not None:
|
|
136
|
+
print("reloading non-resident data")
|
|
137
|
+
else:
|
|
138
|
+
print(f"loading data from {self.filename}")
|
|
139
|
+
if tide_io.checkiftext(self.filename):
|
|
140
|
+
self.nim_data = tide_io.readvecs(self.filename)
|
|
141
|
+
self.nim = None
|
|
142
|
+
else:
|
|
143
|
+
if tide_io.checkifcifti(self.filename):
|
|
144
|
+
self.filetype = "cifti"
|
|
145
|
+
(
|
|
146
|
+
dummy,
|
|
147
|
+
self.cifti_hdr,
|
|
148
|
+
self.nim_data,
|
|
149
|
+
self.nim_hdr,
|
|
150
|
+
self.thedims,
|
|
151
|
+
self.thesizes,
|
|
152
|
+
dummy,
|
|
153
|
+
) = tide_io.readfromcifti(self.filename)
|
|
154
|
+
self.nim = None
|
|
155
|
+
else:
|
|
156
|
+
self.nim, self.nim_data, self.nim_hdr, self.thedims, self.thesizes = (
|
|
157
|
+
tide_io.readfromnifti(self.filename)
|
|
158
|
+
)
|
|
159
|
+
self.resident = True
|
|
160
|
+
|
|
161
|
+
def setvalidtimes(self, validstart, validend):
|
|
162
|
+
if validstart is None:
|
|
163
|
+
self.validstart = 0
|
|
164
|
+
else:
|
|
165
|
+
self.validstart = validstart
|
|
166
|
+
if validend is None:
|
|
167
|
+
self.validend = self.timepoints - 1
|
|
168
|
+
else:
|
|
169
|
+
self.validend = validend
|
|
170
|
+
|
|
171
|
+
def setvalidvoxels(self, validvoxels):
|
|
172
|
+
self.validvoxels = validvoxels
|
|
173
|
+
self.numvalidspatiallocs = np.shape(self.validvoxels)[0]
|
|
174
|
+
|
|
175
|
+
def native(self):
|
|
176
|
+
if not self.resident:
|
|
177
|
+
self.load()
|
|
178
|
+
return self.nim_data
|
|
179
|
+
|
|
180
|
+
def nativetrimmed(self):
|
|
181
|
+
if not self.resident:
|
|
182
|
+
self.load()
|
|
183
|
+
if self.filetype == "nifti":
|
|
184
|
+
return self.nim_data[:, :, :, self.validstart : self.validend + 1]
|
|
185
|
+
else:
|
|
186
|
+
return self.nim_data[:, self.validstart: self.validend + 1]
|
|
187
|
+
|
|
188
|
+
def voxelbytime(self):
|
|
189
|
+
return self.nativetrimmed().reshape(self.numspatiallocs, -1)
|
|
190
|
+
|
|
191
|
+
def getvalidvoxels(self):
|
|
192
|
+
if self.validvoxels is None:
|
|
193
|
+
return self.voxelbytime()
|
|
194
|
+
else:
|
|
195
|
+
return self.voxelbytime()[self.validvoxels, :]
|
|
196
|
+
|
|
197
|
+
def smooth(
|
|
198
|
+
self,
|
|
199
|
+
gausssigma,
|
|
200
|
+
brainmask=None,
|
|
201
|
+
graymask=None,
|
|
202
|
+
whitemask=None,
|
|
203
|
+
premask=False,
|
|
204
|
+
premasktissueonly=False,
|
|
205
|
+
showprogressbar=False,
|
|
206
|
+
):
|
|
207
|
+
# do spatial filtering if requested
|
|
208
|
+
if self.filetype == "cifti" or self.filetype == "text":
|
|
209
|
+
gausssigma = 0.0
|
|
210
|
+
if gausssigma < 0.0:
|
|
211
|
+
# set gausssigma automatically
|
|
212
|
+
gausssigma = np.mean([self.xdim, self.ydim, self.slicethickness]) / 2.0
|
|
213
|
+
if gausssigma > 0.0:
|
|
214
|
+
# premask data if requested
|
|
215
|
+
if premask:
|
|
216
|
+
if premasktissueonly:
|
|
217
|
+
if (graymask is not None) and (whitemask is not None):
|
|
218
|
+
multmask = graymask + whitemask
|
|
219
|
+
else:
|
|
220
|
+
raise ValueError(
|
|
221
|
+
"ERROR: graymask and whitemask must be defined to use premasktissueonly - exiting"
|
|
222
|
+
)
|
|
223
|
+
else:
|
|
224
|
+
if brainmask is not None:
|
|
225
|
+
multmask = brainmask
|
|
226
|
+
else:
|
|
227
|
+
raise ValueError(
|
|
228
|
+
"ERROR: brainmask must be defined to use premask - exiting"
|
|
229
|
+
)
|
|
230
|
+
print(f"premasking timepoints {self.validstart} to {self.validend}")
|
|
231
|
+
for i in tqdm(
|
|
232
|
+
range(self.validstart, self.validend + 1),
|
|
233
|
+
desc="Timepoint",
|
|
234
|
+
unit="timepoints",
|
|
235
|
+
disable=(not showprogressbar),
|
|
236
|
+
):
|
|
237
|
+
self.nim_data[:, :, :, i] *= multmask
|
|
238
|
+
|
|
239
|
+
# now apply the filter
|
|
240
|
+
print(
|
|
241
|
+
f"applying gaussian spatial filter to timepoints {self.validstart} "
|
|
242
|
+
f"to {self.validend} with sigma={gausssigma}"
|
|
243
|
+
)
|
|
244
|
+
sourcedata = self.native()
|
|
245
|
+
for i in tqdm(
|
|
246
|
+
range(self.validstart, self.validend + 1),
|
|
247
|
+
desc="Timepoint",
|
|
248
|
+
unit="timepoints",
|
|
249
|
+
disable=(not showprogressbar),
|
|
250
|
+
):
|
|
251
|
+
self.nim_data[:, :, :, i] = tide_filt.ssmooth(
|
|
252
|
+
self.xdim,
|
|
253
|
+
self.ydim,
|
|
254
|
+
self.slicethickness,
|
|
255
|
+
gausssigma,
|
|
256
|
+
sourcedata[:, :, :, i],
|
|
257
|
+
)
|
|
258
|
+
return gausssigma
|
|
259
|
+
|
|
260
|
+
def summarize(self):
|
|
261
|
+
print("Voxel data summary:")
|
|
262
|
+
print(f"\t{self.nim=}")
|
|
263
|
+
print(f"\t{self.nim_data.shape=}")
|
|
264
|
+
print(f"\t{self.nim_hdr=}")
|
|
265
|
+
print(f"\t{self.nim_affine=}")
|
|
266
|
+
print(f"\t{self.theshape=}")
|
|
267
|
+
print(f"\t{self.xsize=}")
|
|
268
|
+
print(f"\t{self.ysize=}")
|
|
269
|
+
print(f"\t{self.numslices=}")
|
|
270
|
+
print(f"\t{self.timepoints=}")
|
|
271
|
+
print(f"\t{self.timestep=}")
|
|
272
|
+
print(f"\t{self.thesizes=}")
|
|
273
|
+
print(f"\t{self.thedims=}")
|
|
274
|
+
print(f"\t{self.numspatiallocs=}")
|
|
275
|
+
print(f"\t{self.nativespaceshape=}")
|
|
276
|
+
print(f"\t{self.cifti_hdr=}")
|
|
277
|
+
print(f"\t{self.filetype=}")
|
|
278
|
+
print(f"\t{self.resident=}")
|
rapidtide/wiener.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.
|
rapidtide/wiener2.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/aligntcs.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.
|
|
@@ -26,6 +26,7 @@ import rapidtide.correlate as tide_corr
|
|
|
26
26
|
import rapidtide.dlfilter as tide_dlfilt
|
|
27
27
|
import rapidtide.filter as tide_filt
|
|
28
28
|
import rapidtide.fit as tide_fit
|
|
29
|
+
import rapidtide.happy_supportfuncs as happy_support
|
|
29
30
|
import rapidtide.io as tide_io
|
|
30
31
|
import rapidtide.miscmath as tide_math
|
|
31
32
|
import rapidtide.util as tide_util
|
|
@@ -87,65 +88,6 @@ def _get_parser():
|
|
|
87
88
|
return parser
|
|
88
89
|
|
|
89
90
|
|
|
90
|
-
def checkcardmatch(reference, candidate, samplerate, refine=True, zeropadding=0, debug=False):
|
|
91
|
-
thecardfilt = tide_filt.NoncausalFilter(filtertype="cardiac")
|
|
92
|
-
trimlength = np.min([len(reference), len(candidate)])
|
|
93
|
-
thexcorr = tide_corr.fastcorrelate(
|
|
94
|
-
tide_math.corrnormalize(
|
|
95
|
-
thecardfilt.apply(samplerate, reference),
|
|
96
|
-
detrendorder=3,
|
|
97
|
-
windowfunc="hamming",
|
|
98
|
-
)[:trimlength],
|
|
99
|
-
tide_math.corrnormalize(
|
|
100
|
-
thecardfilt.apply(samplerate, candidate),
|
|
101
|
-
detrendorder=3,
|
|
102
|
-
windowfunc="hamming",
|
|
103
|
-
)[:trimlength],
|
|
104
|
-
usefft=True,
|
|
105
|
-
zeropadding=zeropadding,
|
|
106
|
-
)
|
|
107
|
-
xcorrlen = len(thexcorr)
|
|
108
|
-
sampletime = 1.0 / samplerate
|
|
109
|
-
xcorr_x = np.r_[0.0:xcorrlen] * sampletime - (xcorrlen * sampletime) / 2.0 + sampletime / 2.0
|
|
110
|
-
searchrange = 5.0
|
|
111
|
-
trimstart = tide_util.valtoindex(xcorr_x, -2.0 * searchrange)
|
|
112
|
-
trimend = tide_util.valtoindex(xcorr_x, 2.0 * searchrange)
|
|
113
|
-
(
|
|
114
|
-
maxindex,
|
|
115
|
-
maxdelay,
|
|
116
|
-
maxval,
|
|
117
|
-
maxsigma,
|
|
118
|
-
maskval,
|
|
119
|
-
failreason,
|
|
120
|
-
peakstart,
|
|
121
|
-
peakend,
|
|
122
|
-
) = tide_fit.findmaxlag_gauss(
|
|
123
|
-
xcorr_x[trimstart:trimend],
|
|
124
|
-
thexcorr[trimstart:trimend],
|
|
125
|
-
-searchrange,
|
|
126
|
-
searchrange,
|
|
127
|
-
3.0,
|
|
128
|
-
refine=refine,
|
|
129
|
-
zerooutbadfit=False,
|
|
130
|
-
useguess=False,
|
|
131
|
-
fastgauss=False,
|
|
132
|
-
displayplots=False,
|
|
133
|
-
)
|
|
134
|
-
if debug:
|
|
135
|
-
print(
|
|
136
|
-
"CORRELATION: maxindex, maxdelay, maxval, maxsigma, maskval, failreason, peakstart, peakend:",
|
|
137
|
-
maxindex,
|
|
138
|
-
maxdelay,
|
|
139
|
-
maxval,
|
|
140
|
-
maxsigma,
|
|
141
|
-
maskval,
|
|
142
|
-
failreason,
|
|
143
|
-
peakstart,
|
|
144
|
-
peakend,
|
|
145
|
-
)
|
|
146
|
-
return maxval, maxdelay, failreason
|
|
147
|
-
|
|
148
|
-
|
|
149
91
|
def applydlfilter(args):
|
|
150
92
|
if args.display:
|
|
151
93
|
import matplotlib as mpl
|
|
@@ -184,8 +126,6 @@ def applydlfilter(args):
|
|
|
184
126
|
)
|
|
185
127
|
thedlfilter = tide_dlfilt.DeepLearningFilter(modelpath=modelpath)
|
|
186
128
|
thedlfilter.loadmodel(args.model)
|
|
187
|
-
model = thedlfilter.model
|
|
188
|
-
window_size = thedlfilter.window_size
|
|
189
129
|
usebadpts = thedlfilter.usebadpts
|
|
190
130
|
|
|
191
131
|
badpts = None
|
|
@@ -204,17 +144,32 @@ def applydlfilter(args):
|
|
|
204
144
|
# read in the data
|
|
205
145
|
if args.verbose:
|
|
206
146
|
print("reading in", infilename)
|
|
207
|
-
|
|
208
|
-
|
|
147
|
+
(
|
|
148
|
+
thesamplerate,
|
|
149
|
+
thestarttime,
|
|
150
|
+
thecolumns,
|
|
151
|
+
fmridata,
|
|
152
|
+
compressed,
|
|
153
|
+
filetype,
|
|
154
|
+
) = tide_io.readvectorsfromtextfile(infilename, onecol=True, debug=args.verbose)
|
|
155
|
+
if args.verbose:
|
|
156
|
+
print("data is read")
|
|
157
|
+
if thesamplerate != 25.0:
|
|
158
|
+
print("sampling rate", thesamplerate)
|
|
159
|
+
sys.exit()
|
|
209
160
|
if args.verbose:
|
|
210
161
|
print("filtering...")
|
|
211
162
|
predicteddata = thedlfilter.apply(fmridata, badpts=badpts)
|
|
163
|
+
if args.verbose:
|
|
164
|
+
print("done...")
|
|
212
165
|
|
|
213
166
|
if args.verbose:
|
|
214
167
|
print("writing to", outfilenamelist[idx])
|
|
215
168
|
tide_io.writevec(predicteddata, outfilenamelist[idx])
|
|
216
169
|
|
|
217
|
-
maxval, maxdelay, failreason = checkcardmatch(
|
|
170
|
+
maxval, maxdelay, failreason = happy_support.checkcardmatch(
|
|
171
|
+
fmridata, predicteddata, 25.0, debug=False
|
|
172
|
+
)
|
|
218
173
|
print(infilename, "max correlation input to output:", maxval)
|
|
219
174
|
|
|
220
175
|
if args.display:
|