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
cloud/gmscalc-HCPYA
CHANGED
|
@@ -15,7 +15,7 @@ fi
|
|
|
15
15
|
|
|
16
16
|
echo "Subject="${SUBJ}", RUN="${RUN}", PEDIR="${PEDIR}
|
|
17
17
|
|
|
18
|
-
mkdir -p /data_out/HCP_1200/
|
|
18
|
+
mkdir -p /data_out/HCP_1200/minpreprocslfofilt/${SUBJ}
|
|
19
19
|
gmscalc \
|
|
20
20
|
/data_out/HCP_1200/${SUBJ}/rapidtide_rfMRI_${RUN}_${PEDIR}_desc-lfofilterCleaned_bold.nii.gz
|
|
21
21
|
/data_out/HCP_1200/fixglm/${SUBJ}/rapidtide_rfMRI_${RUN}_${PEDIR}_lfofilteredCleanedGMS \
|
cloud/rapidtide-HCPYA
CHANGED
|
@@ -15,11 +15,11 @@ fi
|
|
|
15
15
|
|
|
16
16
|
echo "Subject="${SUBJ}", RUN="${RUN}", PEDIR="${PEDIR}
|
|
17
17
|
|
|
18
|
-
# --
|
|
19
|
-
mkdir -p /data_out/HCP_1200/
|
|
18
|
+
# --denoisesourcefile=/data_in/HCP_1200/${SUBJ}/MNINonLinear/Results/rfMRI_${RUN}_${PEDIR}/rfMRI_${RUN}_${PEDIR}_hp2000_clean.nii.gz \
|
|
19
|
+
mkdir -p /data_out/HCP_1200/minpreprocslfofilt/${SUBJ}
|
|
20
20
|
rapidtide \
|
|
21
21
|
/data_in/HCP_1200/${SUBJ}/MNINonLinear/Results/rfMRI_${RUN}_${PEDIR}/rfMRI_${RUN}_${PEDIR}.nii.gz \
|
|
22
|
-
/data_out/HCP_1200/
|
|
22
|
+
/data_out/HCP_1200/minpreprocslfofilt/${SUBJ}/rapidtide_rfMRI_${RUN}_${PEDIR} \
|
|
23
23
|
--despecklepasses 4 \
|
|
24
24
|
--filterfreqs 0.009 0.15 \
|
|
25
25
|
--searchrange -7.5 15.0 \
|
rapidtide/Colortables.py
CHANGED
|
@@ -66,7 +66,7 @@ def gen_thermal_state():
|
|
|
66
66
|
thegradient = Gradients["thermal"]
|
|
67
67
|
thegradient["name"] = "thermal"
|
|
68
68
|
return thegradient
|
|
69
|
-
#return Gradients["thermal"]
|
|
69
|
+
# return Gradients["thermal"]
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
def gen_flame_state():
|
|
@@ -75,7 +75,7 @@ def gen_flame_state():
|
|
|
75
75
|
thegradient = Gradients["flame"]
|
|
76
76
|
thegradient["name"] = "flame"
|
|
77
77
|
return thegradient
|
|
78
|
-
#return Gradients["flame"]
|
|
78
|
+
# return Gradients["flame"]
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
def gen_yellowy_state():
|
|
@@ -84,7 +84,7 @@ def gen_yellowy_state():
|
|
|
84
84
|
thegradient = Gradients["yellowy"]
|
|
85
85
|
thegradient["name"] = "yellowy"
|
|
86
86
|
return thegradient
|
|
87
|
-
#return Gradients["yellowy"]
|
|
87
|
+
# return Gradients["yellowy"]
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
def gen_bipolar_state():
|
|
@@ -93,7 +93,7 @@ def gen_bipolar_state():
|
|
|
93
93
|
thegradient = Gradients["bipolar"]
|
|
94
94
|
thegradient["name"] = "bipolar"
|
|
95
95
|
return thegradient
|
|
96
|
-
#return Gradients["bipolar"]
|
|
96
|
+
# return Gradients["bipolar"]
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
def gen_spectrum_state():
|
|
@@ -102,7 +102,7 @@ def gen_spectrum_state():
|
|
|
102
102
|
thegradient = Gradients["spectrum"]
|
|
103
103
|
thegradient["name"] = "spectrum"
|
|
104
104
|
return thegradient
|
|
105
|
-
#return Gradients["spectrum"]
|
|
105
|
+
# return Gradients["spectrum"]
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
def gen_turbo_state():
|
|
@@ -111,7 +111,7 @@ def gen_turbo_state():
|
|
|
111
111
|
thegradient = Gradients["turbo"]
|
|
112
112
|
thegradient["name"] = "turbo"
|
|
113
113
|
return thegradient
|
|
114
|
-
#return Gradients["turbo"]
|
|
114
|
+
# return Gradients["turbo"]
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
def gen_gray_state():
|
|
@@ -142,7 +142,7 @@ def gen_viridis_state():
|
|
|
142
142
|
thegradient = Gradients["viridis"]
|
|
143
143
|
thegradient["name"] = "viridis"
|
|
144
144
|
return thegradient
|
|
145
|
-
#return Gradients["viridis"]
|
|
145
|
+
# return Gradients["viridis"]
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
def gen_inferno_state():
|
|
@@ -151,7 +151,7 @@ def gen_inferno_state():
|
|
|
151
151
|
thegradient = Gradients["inferno"]
|
|
152
152
|
thegradient["name"] = "inferno"
|
|
153
153
|
return thegradient
|
|
154
|
-
#return Gradients["inferno"]
|
|
154
|
+
# return Gradients["inferno"]
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
def gen_plasma_state():
|
|
@@ -160,7 +160,7 @@ def gen_plasma_state():
|
|
|
160
160
|
thegradient = Gradients["plasma"]
|
|
161
161
|
thegradient["name"] = "plasma"
|
|
162
162
|
return thegradient
|
|
163
|
-
#return Gradients["plasma"]
|
|
163
|
+
# return Gradients["plasma"]
|
|
164
164
|
|
|
165
165
|
|
|
166
166
|
def gen_magma_state():
|
|
@@ -169,7 +169,7 @@ def gen_magma_state():
|
|
|
169
169
|
thegradient = Gradients["magma"]
|
|
170
170
|
thegradient["name"] = "magma"
|
|
171
171
|
return thegradient
|
|
172
|
-
#return Gradients["magma"]
|
|
172
|
+
# return Gradients["magma"]
|
|
173
173
|
|
|
174
174
|
|
|
175
175
|
def gen_g2y2r_state():
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2016-2024 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
|
+
"""
|
|
20
|
+
A class to impmement regressor refinement
|
|
21
|
+
"""
|
|
22
|
+
import copy
|
|
23
|
+
|
|
24
|
+
import numpy as np
|
|
25
|
+
|
|
26
|
+
import rapidtide.fit as tide_fit
|
|
27
|
+
import rapidtide.io as tide_io
|
|
28
|
+
import rapidtide.miscmath as tide_math
|
|
29
|
+
import rapidtide.refinedelay as tide_refinedelay
|
|
30
|
+
import rapidtide.resample as tide_resample
|
|
31
|
+
import rapidtide.stats as tide_stats
|
|
32
|
+
import rapidtide.util as tide_util
|
|
33
|
+
from rapidtide.tests.utils import mse
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class DerivativeDelay:
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
internalvalidfmrishape,
|
|
40
|
+
internalvalidpaddedfmrishape,
|
|
41
|
+
pid,
|
|
42
|
+
outputname,
|
|
43
|
+
initial_fmri_x,
|
|
44
|
+
paddedinitial_fmri_x,
|
|
45
|
+
os_fmri_x,
|
|
46
|
+
genlagtc,
|
|
47
|
+
sharedmem=False,
|
|
48
|
+
gausssigma=-1,
|
|
49
|
+
numderivs=1,
|
|
50
|
+
lagminthresh=0.25,
|
|
51
|
+
lagmaxthresh=3.0,
|
|
52
|
+
sigmathresh=1000.0,
|
|
53
|
+
cleanrefined=False,
|
|
54
|
+
bipolar=False,
|
|
55
|
+
fixdelay=False,
|
|
56
|
+
includemask=None,
|
|
57
|
+
excludemask=None,
|
|
58
|
+
LGR=None,
|
|
59
|
+
nprocs=1,
|
|
60
|
+
detrendorder=1,
|
|
61
|
+
alwaysmultiproc=False,
|
|
62
|
+
showprogressbar=True,
|
|
63
|
+
chunksize=50000,
|
|
64
|
+
padtrs=10,
|
|
65
|
+
refineprenorm="var",
|
|
66
|
+
refineweighting=None,
|
|
67
|
+
refinetype="pca",
|
|
68
|
+
pcacomponents=0.8,
|
|
69
|
+
dodispersioncalc=False,
|
|
70
|
+
dispersioncalc_lower=-5.0,
|
|
71
|
+
dispersioncalc_upper=5.0,
|
|
72
|
+
dispersioncalc_step=0.5,
|
|
73
|
+
windowfunc="hamming",
|
|
74
|
+
passes=3,
|
|
75
|
+
maxpasses=15,
|
|
76
|
+
convergencethresh=None,
|
|
77
|
+
interptype="univariate",
|
|
78
|
+
usetmask=False,
|
|
79
|
+
tmask_y=None,
|
|
80
|
+
tmaskos_y=None,
|
|
81
|
+
fastresamplerpadtime=45.0,
|
|
82
|
+
debug=False,
|
|
83
|
+
rt_floattype="float64",
|
|
84
|
+
rt_floatset=np.float64,
|
|
85
|
+
):
|
|
86
|
+
self.outputname = outputname
|
|
87
|
+
self.numderivs = numderivs
|
|
88
|
+
if gausssigma < 0.0:
|
|
89
|
+
# set gausssigma automatically
|
|
90
|
+
self.gausssigma = np.mean([xdim, ydim, slicedim]) / 2.0
|
|
91
|
+
else:
|
|
92
|
+
self.gausssigma = gausssigma
|
|
93
|
+
self.debug = debug
|
|
94
|
+
self.setgenlagtc(genlagtc)
|
|
95
|
+
|
|
96
|
+
def setgenlagtc(self, genlagtc):
|
|
97
|
+
self.genlagtc = genlagtc
|
|
98
|
+
|
|
99
|
+
def getderivratios(
|
|
100
|
+
self, fmri_data_valid, validvoxels, initial_fmri_x, lagtimes_valid, corrmask_valid
|
|
101
|
+
):
|
|
102
|
+
print("Refinement calibration start")
|
|
103
|
+
regressderivratios = tide_refinedelay.getderivratios(
|
|
104
|
+
fmri_data_valid,
|
|
105
|
+
validvoxels,
|
|
106
|
+
initial_fmri_x,
|
|
107
|
+
lagtimes_valid,
|
|
108
|
+
corrmask_valid,
|
|
109
|
+
self.genlagtc,
|
|
110
|
+
"glm",
|
|
111
|
+
self.outputname,
|
|
112
|
+
oversamptr,
|
|
113
|
+
sLFOfitmean,
|
|
114
|
+
rvalue,
|
|
115
|
+
r2value,
|
|
116
|
+
fitNorm[:, : (self.numderivs + 1)],
|
|
117
|
+
fitcoeff[:, : (self.numderivs + 1)],
|
|
118
|
+
movingsignal,
|
|
119
|
+
lagtc,
|
|
120
|
+
filtereddata,
|
|
121
|
+
LGR,
|
|
122
|
+
TimingLGR,
|
|
123
|
+
therunoptions,
|
|
124
|
+
regressderivs=self.numderivs,
|
|
125
|
+
debug=self.debug,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
def calibrate(self):
|
|
129
|
+
if self.numderivs == 1:
|
|
130
|
+
medfiltregressderivratios, filteredregressderivratios, delayoffsetMAD = (
|
|
131
|
+
tide_refinedelay.filterderivratios(
|
|
132
|
+
regressderivratios,
|
|
133
|
+
(xsize, ysize, numslices),
|
|
134
|
+
validvoxels,
|
|
135
|
+
(xdim, ydim, slicedim),
|
|
136
|
+
gausssigma=args.delayoffsetgausssigma,
|
|
137
|
+
patchthresh=args.delaypatchthresh,
|
|
138
|
+
fileiscifti=False,
|
|
139
|
+
textio=False,
|
|
140
|
+
rt_floattype=rt_floattype,
|
|
141
|
+
debug=args.debug,
|
|
142
|
+
)
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
# find the mapping of derivative ratios to delays
|
|
146
|
+
tide_refinedelay.trainratiotooffset(
|
|
147
|
+
self.genlagtc,
|
|
148
|
+
initial_fmri_x,
|
|
149
|
+
self.outputname,
|
|
150
|
+
args.outputlevel,
|
|
151
|
+
mindelay=args.mindelay,
|
|
152
|
+
maxdelay=args.maxdelay,
|
|
153
|
+
numpoints=args.numpoints,
|
|
154
|
+
debug=args.debug,
|
|
155
|
+
)
|
|
156
|
+
TimingLGR.info("Refinement calibration end")
|
|
157
|
+
|
|
158
|
+
# now calculate the delay offsets
|
|
159
|
+
TimingLGR.info("Calculating delay offsets")
|
|
160
|
+
delayoffset = np.zeros_like(filteredregressderivratios)
|
|
161
|
+
if args.focaldebug:
|
|
162
|
+
print(f"calculating delayoffsets for {filteredregressderivratios.shape[0]} voxels")
|
|
163
|
+
for i in range(filteredregressderivratios.shape[0]):
|
|
164
|
+
delayoffset[i], closestoffset = tide_refinedelay.ratiotodelay(
|
|
165
|
+
filteredregressderivratios[i]
|
|
166
|
+
)
|
|
167
|
+
refinedvoxelstoreport = filteredregressderivratios.shape[0]
|
|
168
|
+
else:
|
|
169
|
+
medfiltregressderivratios = np.zeros_like(regressderivratios)
|
|
170
|
+
filteredregressderivratios = np.zeros_like(regressderivratios)
|
|
171
|
+
delayoffsetMAD = np.zeros(args.refineregressderivs, dtype=float)
|
|
172
|
+
for i in range(args.refineregressderivs):
|
|
173
|
+
(
|
|
174
|
+
medfiltregressderivratios[i, :],
|
|
175
|
+
filteredregressderivratios[i, :],
|
|
176
|
+
delayoffsetMAD[i],
|
|
177
|
+
) = tide_refinedelay.filterderivratios(
|
|
178
|
+
regressderivratios[i, :],
|
|
179
|
+
(xsize, ysize, numslices),
|
|
180
|
+
validvoxels,
|
|
181
|
+
(xdim, ydim, slicedim),
|
|
182
|
+
gausssigma=args.delayoffsetgausssigma,
|
|
183
|
+
patchthresh=args.delaypatchthresh,
|
|
184
|
+
fileiscifti=False,
|
|
185
|
+
textio=False,
|
|
186
|
+
rt_floattype=rt_floattype,
|
|
187
|
+
debug=args.debug,
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
def getdelays(self):
|
|
191
|
+
# now calculate the delay offsets
|
|
192
|
+
delayoffset = np.zeros_like(filteredregressderivratios[0, :])
|
|
193
|
+
if self.debug:
|
|
194
|
+
print(f"calculating delayoffsets for {filteredregressderivratios.shape[1]} voxels")
|
|
195
|
+
for i in range(filteredregressderivratios.shape[1]):
|
|
196
|
+
delayoffset[i] = tide_refinedelay.coffstodelay(
|
|
197
|
+
filteredregressderivratios[:, i],
|
|
198
|
+
mindelay=self.mindelay,
|
|
199
|
+
maxdelay=self.maxdelay,
|
|
200
|
+
)
|
|
201
|
+
refinedvoxelstoreport = filteredregressderivratios.shape[1]
|
|
202
|
+
|
|
203
|
+
def savestats(self):
|
|
204
|
+
namesuffix = "_desc-delayoffset_hist"
|
|
205
|
+
tide_stats.makeandsavehistogram(
|
|
206
|
+
delayoffset,
|
|
207
|
+
therunoptions["histlen"],
|
|
208
|
+
1,
|
|
209
|
+
self.outputname + namesuffix,
|
|
210
|
+
displaytitle="Histogram of delay offsets calculated from coefficient ratios",
|
|
211
|
+
dictvarname="delayoffsethist",
|
|
212
|
+
thedict=None,
|
|
213
|
+
)
|
rapidtide/__init__.py
CHANGED
rapidtide/_version.py
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"""Git implementation of _version.py."""
|
|
13
13
|
|
|
14
14
|
import errno
|
|
15
|
+
import functools
|
|
15
16
|
import os
|
|
16
17
|
import re
|
|
17
18
|
import subprocess
|
|
18
19
|
import sys
|
|
19
20
|
from typing import Any, Callable, Dict, List, Optional, Tuple
|
|
20
|
-
import functools
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def get_keywords() -> Dict[str, str]:
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
from sklearn.linear_model import LinearRegression
|
|
5
5
|
|
|
6
|
-
from rapidtide.fit import
|
|
6
|
+
from rapidtide.fit import mlregress, olsregress
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
def
|
|
9
|
+
def test_olsregress():
|
|
10
10
|
# Test with a simple dataset
|
|
11
11
|
X = np.array([[1, 2], [3, 4]])
|
|
12
12
|
y = np.array([5, 6])
|
|
@@ -15,13 +15,20 @@ def test_mlregress_alt():
|
|
|
15
15
|
expected_intercept = 4
|
|
16
16
|
expected_R = 0.707
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
mlcoeffs, mlR = mlregress(X, y, intercept=intercept)
|
|
19
|
+
print(f"{mlcoeffs=}, {mlR=}")
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
assert np.isclose(R, expected_R)
|
|
21
|
+
olscoeffs, olsR = olsregress(X, y, intercept=intercept)
|
|
22
|
+
print(f"{olscoeffs=}, {olsR=}")
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
print(mlcoeffs, expected_coeffs)
|
|
25
|
+
print(olscoeffs, expected_coeffs)
|
|
26
|
+
assert np.allclose(mlcoeffs, expected_coeffs)
|
|
27
|
+
assert np.isclose(mlR, expected_R)
|
|
28
|
+
assert np.allclose(olscoeffs, expected_coeffs)
|
|
29
|
+
assert np.isclose(olsR, expected_R)
|
|
30
|
+
|
|
31
|
+
def test_olsregress_intercept():
|
|
25
32
|
# Test with a simple dataset and no intercept
|
|
26
33
|
X = np.array([[1, 2], [3, 4]])
|
|
27
34
|
y = np.array([5, 6])
|
|
@@ -30,26 +37,34 @@ def test_mlregress_alt_intercept():
|
|
|
30
37
|
expected_intercept = None
|
|
31
38
|
expected_R = 0.707
|
|
32
39
|
|
|
33
|
-
coeffs, R =
|
|
40
|
+
coeffs, R = mlregress(X, y, intercept)
|
|
34
41
|
|
|
35
42
|
assert np.allclose(coeffs, expected_coeffs)
|
|
36
43
|
assert np.isclose(R, expected_R)
|
|
37
44
|
|
|
38
|
-
def
|
|
45
|
+
def test_olsregress_nointercept():
|
|
39
46
|
# Test with a simple dataset and no intercept
|
|
40
47
|
X = np.array([[1, 2], [3, 4]])
|
|
41
48
|
y = np.array([5, 6])
|
|
42
|
-
intercept =
|
|
49
|
+
intercept = False
|
|
43
50
|
expected_coeffs = np.array([[1, 2], [3, 4]])
|
|
44
|
-
expected_intercept =
|
|
51
|
+
expected_intercept = False
|
|
45
52
|
expected_R = 0.707
|
|
46
53
|
|
|
47
|
-
|
|
54
|
+
mlcoeffs, mlR = mlregress(X, y, intercept=intercept)
|
|
55
|
+
print(f"{mlcoeffs=}, {mlR=}")
|
|
48
56
|
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
olscoeffs, olsR = olsregress(X, y, intercept=intercept)
|
|
58
|
+
print(f"{olscoeffs=}, {olsR=}")
|
|
59
|
+
|
|
60
|
+
print(mlcoeffs, expected_coeffs)
|
|
61
|
+
print(olscoeffs, expected_coeffs)
|
|
62
|
+
assert np.allclose(mlcoeffs, expected_coeffs)
|
|
63
|
+
assert np.isclose(mlR, expected_R)
|
|
64
|
+
assert np.allclose(olscoeffs, expected_coeffs)
|
|
65
|
+
assert np.isclose(olsR, expected_R)
|
|
51
66
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
test_olsregress_nointercept()
|
|
68
|
+
test_olsregress_intercept()
|
|
69
|
+
test_olsregress()
|
|
55
70
|
|
|
@@ -41,7 +41,7 @@ alignedvec, maxdelay, maxval, failreason = tide_corr.aligntcwithref(
|
|
|
41
41
|
)
|
|
42
42
|
print(f"{maxdelay=}, {maxval=}, {failreason=}")
|
|
43
43
|
|
|
44
|
-
filteredvec, datatoremove, R, coffs = tide_fit.
|
|
44
|
+
filteredvec, datatoremove, R, coffs = tide_fit.linfitfilt(fixedvec, alignedvec, debug=True)
|
|
45
45
|
|
|
46
46
|
offset = 0.0
|
|
47
47
|
plt.plot(xaxis, fixedvec + offset)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
delayvar \
|
|
4
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
5
|
+
../dst/sub-RAPIDTIDETEST \
|
|
6
|
+
--alternateoutput ../dst/delayvartest \
|
|
7
|
+
--nprocs -1 \
|
|
8
|
+
--windowsize 30 \
|
|
9
|
+
--systemicfittype pca \
|
|
10
|
+
--trainrange -999 -999 \
|
|
11
|
+
--pcacomponents 0.8 \
|
|
12
|
+
--outputlevel max \
|
|
13
|
+
--focaldebug \
|
|
14
|
+
--windelayoffsetspatialfilt 3
|
|
@@ -34,7 +34,9 @@ datavec = amp1 * evs[:, 0] + amp2 * evs[:, 1] + amp3 * evs[:, 2] + intercept
|
|
|
34
34
|
noisevec = noiseamp * np.random.rand(arrlen)
|
|
35
35
|
invec = datavec + noisevec
|
|
36
36
|
|
|
37
|
-
filtered, datatoremove, R, outcoffs, outintercept = tide_fit.
|
|
37
|
+
filtered, datatoremove, R, outcoffs, outintercept = tide_fit.linfitfilt(
|
|
38
|
+
invec, evs, returnintercept=True, debug=True
|
|
39
|
+
)
|
|
38
40
|
|
|
39
41
|
incoffs = [amp1, amp2, amp3]
|
|
40
42
|
coffdiffs = outcoffs - incoffs
|
|
@@ -58,7 +60,7 @@ plt.plot(datavec - datatoremove + offset)
|
|
|
58
60
|
print(R)
|
|
59
61
|
plt.show()
|
|
60
62
|
|
|
61
|
-
filtered, datatoremove, R, coffs = tide_fit.
|
|
63
|
+
filtered, datatoremove, R, coffs = tide_fit.linfitfilt(invec, evs[:, 0], debug=True)
|
|
62
64
|
|
|
63
65
|
"""
|
|
64
66
|
offset = 0.0
|
|
@@ -80,7 +82,7 @@ invec2 = (
|
|
|
80
82
|
+ noiseamp * np.random.rand(arrlen)
|
|
81
83
|
)
|
|
82
84
|
|
|
83
|
-
filtered, datatoremove, R, coffs = tide_fit.
|
|
85
|
+
filtered, datatoremove, R, coffs = tide_fit.linfitfilt(invec2, evs, debug=True)
|
|
84
86
|
|
|
85
87
|
"""
|
|
86
88
|
offset = 0.0
|
|
@@ -95,7 +97,7 @@ print(R)
|
|
|
95
97
|
plt.show()
|
|
96
98
|
"""
|
|
97
99
|
|
|
98
|
-
filtered, thenewevs, datatoremove, R, coffs = tide_fit.
|
|
100
|
+
filtered, thenewevs, datatoremove, R, coffs = tide_fit.expandedlinfitfilt(
|
|
99
101
|
invec2, evs, ncomps=3, debug=True
|
|
100
102
|
)
|
|
101
103
|
|
|
@@ -116,7 +118,7 @@ print(R)
|
|
|
116
118
|
plt.show()
|
|
117
119
|
"""
|
|
118
120
|
|
|
119
|
-
filtered, datatoremove, R, coffs = tide_fit.
|
|
121
|
+
filtered, datatoremove, R, coffs = tide_fit.linfitfilt(invec2, thenewevs, debug=True)
|
|
120
122
|
"""
|
|
121
123
|
offset = 0.0
|
|
122
124
|
plt.plot(invec2 + offset)
|
|
@@ -138,7 +140,7 @@ alignedev, maxdelay, maxval, failreason = tide_corr.aligntcwithref(
|
|
|
138
140
|
verbose=True,
|
|
139
141
|
)
|
|
140
142
|
print(f"{maxdelay=}, {maxval=}, {failreason=}")
|
|
141
|
-
filtered, datatoremove, R, coffs = tide_fit.
|
|
143
|
+
filtered, datatoremove, R, coffs = tide_fit.linfitfilt(invec3, alignedev, debug=True)
|
|
142
144
|
offset = 0.0
|
|
143
145
|
plt.plot(evs[:, 0])
|
|
144
146
|
offset += 1.0
|
|
@@ -6,7 +6,7 @@ rapidtide \
|
|
|
6
6
|
--searchrange -5 20 \
|
|
7
7
|
--simcalcrange 50 -1 \
|
|
8
8
|
--outputlevel max \
|
|
9
|
-
--
|
|
9
|
+
--refineregressderivs 1 \
|
|
10
10
|
sub-RAPIDTIDETEST.nii.gz \
|
|
11
11
|
../dst/sub-RAPIDTIDETEST_1deriv
|
|
12
12
|
|
|
@@ -16,34 +16,34 @@ rapidtide \
|
|
|
16
16
|
--searchrange -5 20 \
|
|
17
17
|
--simcalcrange 50 -1 \
|
|
18
18
|
--outputlevel max \
|
|
19
|
-
--
|
|
19
|
+
--refineregressderivs 2 \
|
|
20
20
|
sub-RAPIDTIDETEST.nii.gz \
|
|
21
21
|
../dst/sub-RAPIDTIDETEST_2deriv
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
retroregress \
|
|
25
25
|
sub-RAPIDTIDETEST.nii.gz \
|
|
26
26
|
../dst/sub-RAPIDTIDETEST_1deriv \
|
|
27
27
|
--alternateoutput ../dst/retrotest_1to1 \
|
|
28
28
|
--nprocs -1 \
|
|
29
|
-
--
|
|
30
|
-
--
|
|
29
|
+
--regressderivs 0 \
|
|
30
|
+
--refineregressderivs 1 \
|
|
31
31
|
--outputlevel max
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
retroregress \
|
|
34
34
|
sub-RAPIDTIDETEST.nii.gz \
|
|
35
35
|
../dst/sub-RAPIDTIDETEST_2deriv \
|
|
36
36
|
--alternateoutput ../dst/retrotest_2to1 \
|
|
37
37
|
--nprocs -1 \
|
|
38
|
-
--
|
|
39
|
-
--
|
|
38
|
+
--regressderivs 0 \
|
|
39
|
+
--refineregressderivs 1 \
|
|
40
40
|
--outputlevel max
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
retroregress \
|
|
43
43
|
sub-RAPIDTIDETEST.nii.gz \
|
|
44
44
|
../dst/sub-RAPIDTIDETEST_1deriv \
|
|
45
45
|
--alternateoutput ../dst/retrotest_1to2 \
|
|
46
46
|
--nprocs -1 \
|
|
47
|
-
--
|
|
48
|
-
--
|
|
47
|
+
--regressderivs 0 \
|
|
48
|
+
--refineregressderivs 2 \
|
|
49
49
|
--outputlevel max
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
|
|
3
|
-
import rapidtide.miscmath as tide_math
|
|
4
|
-
import rapidtide.io as tide_io
|
|
5
3
|
import matplotlib.pyplot as plt
|
|
6
4
|
|
|
5
|
+
import rapidtide.io as tide_io
|
|
6
|
+
import rapidtide.miscmath as tide_math
|
|
7
7
|
|
|
8
8
|
windowsize = 40.0
|
|
9
9
|
samplerate, starttime, inputdata = tide_io.readcolfrombidstsv("../dst/sub-RAPIDTIDETEST_desc-oversampledmovingregressor_timeseries.json", columnname="pass3")
|
|
@@ -6,16 +6,25 @@
|
|
|
6
6
|
# --refinetype unweighted_average \
|
|
7
7
|
# --numnull 0 \
|
|
8
8
|
# --outputlevel max \
|
|
9
|
-
# --
|
|
9
|
+
# --regressderivs 1 \
|
|
10
10
|
# sub-RAPIDTIDETEST.nii.gz \
|
|
11
11
|
# ../dst/sub-RAPIDTIDETEST
|
|
12
12
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
##retroregress sub-RAPIDTIDETEST.nii.gz ../dst/sub-RAPIDTIDETEST --alternateoutput ../dst/0deriv --nprocs -1
|
|
14
|
+
|
|
15
|
+
retroregress \
|
|
16
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
17
|
+
../dst/sub-RAPIDTIDETEST \
|
|
18
|
+
--alternateoutput ../dst/wintest \
|
|
19
|
+
--nprocs -1 \
|
|
20
|
+
--outputlevel max \
|
|
21
|
+
--focaldebug \
|
|
22
|
+
--delayoffsetspatialfilt -1
|
|
23
|
+
|
|
24
|
+
#retroregress sub-RAPIDTIDETEST.nii.gz ../dst/sub-RAPIDTIDETEST --alternateoutput ../dst/0deriv_refined --nprocs -1 --regressderivs 0 --makepseudofile --outputlevel max --refinedelay --nofilterwithrefineddelay
|
|
25
|
+
#retroregress sub-RAPIDTIDETEST.nii.gz ../dst/sub-RAPIDTIDETEST --alternateoutput ../dst/0deriv_refinedfit --nprocs -1 --regressderivs 0 --makepseudofile --outputlevel max --refinedelay
|
|
26
|
+
##retroregress sub-RAPIDTIDETEST.nii.gz ../dst/sub-RAPIDTIDETEST --alternateoutput ../dst/2deriv --nprocs -1 --regressderivs 2
|
|
27
|
+
##retroregress sub-RAPIDTIDETEST.nii.gz ../dst/sub-RAPIDTIDETEST --alternateoutput ../dst/3deriv --nprocs -1 --regressderivs 3
|
|
19
28
|
|
|
20
29
|
ALTNAME=1deriv
|
|
21
30
|
|