rapidtide 3.0a13__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.
- rapidtide/DerivativeDelay.py +3 -1
- rapidtide/data/examples/src/testdelayvar +2 -1
- rapidtide/linfitfiltpass.py +2 -0
- rapidtide/makelaggedtcs.py +8 -5
- rapidtide/multiproc.py +8 -11
- rapidtide/refinedelay.py +173 -86
- rapidtide/tests/test_fullrunhappy_v1.py +13 -5
- rapidtide/tests/test_fullrunhappy_v2.py +16 -8
- 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 +18 -10
- rapidtide/tests/test_fullrunrapidtide_v2.py +21 -13
- rapidtide/tests/test_fullrunrapidtide_v3.py +14 -6
- rapidtide/tests/test_fullrunrapidtide_v4.py +14 -7
- rapidtide/tests/test_fullrunrapidtide_v5.py +12 -4
- rapidtide/tests/test_fullrunrapidtide_v6.py +23 -15
- rapidtide/tests/test_refinedelay.py +3 -1
- rapidtide/workflows/atlasaverage.py +40 -12
- rapidtide/workflows/delayvar.py +121 -33
- rapidtide/workflows/rapidtide.py +12 -8
- rapidtide/workflows/rapidtide_parser.py +13 -15
- rapidtide/workflows/regressfrommaps.py +2 -0
- rapidtide/workflows/retrolagtcs.py +1 -0
- rapidtide/workflows/retroregress.py +25 -1
- {rapidtide-3.0a13.dist-info → rapidtide-3.0a14.dist-info}/METADATA +1 -1
- {rapidtide-3.0a13.dist-info → rapidtide-3.0a14.dist-info}/RECORD +31 -31
- {rapidtide-3.0a13.dist-info → rapidtide-3.0a14.dist-info}/WHEEL +0 -0
- {rapidtide-3.0a13.dist-info → rapidtide-3.0a14.dist-info}/entry_points.txt +0 -0
- {rapidtide-3.0a13.dist-info → rapidtide-3.0a14.dist-info}/licenses/LICENSE +0 -0
- {rapidtide-3.0a13.dist-info → rapidtide-3.0a14.dist-info}/top_level.txt +0 -0
rapidtide/DerivativeDelay.py
CHANGED
|
@@ -161,7 +161,9 @@ class DerivativeDelay:
|
|
|
161
161
|
if args.focaldebug:
|
|
162
162
|
print(f"calculating delayoffsets for {filteredregressderivratios.shape[0]} voxels")
|
|
163
163
|
for i in range(filteredregressderivratios.shape[0]):
|
|
164
|
-
delayoffset[i] = tide_refinedelay.ratiotodelay(
|
|
164
|
+
delayoffset[i], closestoffset = tide_refinedelay.ratiotodelay(
|
|
165
|
+
filteredregressderivratios[i]
|
|
166
|
+
)
|
|
165
167
|
refinedvoxelstoreport = filteredregressderivratios.shape[0]
|
|
166
168
|
else:
|
|
167
169
|
medfiltregressderivratios = np.zeros_like(regressderivratios)
|
rapidtide/linfitfiltpass.py
CHANGED
|
@@ -97,6 +97,7 @@ def linfitfiltpass(
|
|
|
97
97
|
mp_chunksize=1000,
|
|
98
98
|
rt_floatset=np.float64,
|
|
99
99
|
rt_floattype="float64",
|
|
100
|
+
verbose=True,
|
|
100
101
|
debug=False,
|
|
101
102
|
):
|
|
102
103
|
inputshape = np.shape(fmri_data)
|
|
@@ -184,6 +185,7 @@ def linfitfiltpass(
|
|
|
184
185
|
GLM_consumer,
|
|
185
186
|
inputshape,
|
|
186
187
|
themask,
|
|
188
|
+
verbose=verbose,
|
|
187
189
|
nprocs=nprocs,
|
|
188
190
|
procbyvoxel=procbyvoxel,
|
|
189
191
|
showprogressbar=showprogressbar,
|
rapidtide/makelaggedtcs.py
CHANGED
|
@@ -24,8 +24,6 @@ from tqdm import tqdm
|
|
|
24
24
|
|
|
25
25
|
import rapidtide.multiproc as tide_multiproc
|
|
26
26
|
|
|
27
|
-
LGR = logging.getLogger("GENERAL")
|
|
28
|
-
|
|
29
27
|
|
|
30
28
|
def _procOneVoxelMakelagtc(
|
|
31
29
|
vox,
|
|
@@ -51,6 +49,7 @@ def makelaggedtcs(
|
|
|
51
49
|
lagmask,
|
|
52
50
|
lagtimes,
|
|
53
51
|
lagtc,
|
|
52
|
+
LGR=None,
|
|
54
53
|
nprocs=1,
|
|
55
54
|
alwaysmultiproc=False,
|
|
56
55
|
showprogressbar=True,
|
|
@@ -90,6 +89,7 @@ def makelaggedtcs(
|
|
|
90
89
|
makelagtc_consumer,
|
|
91
90
|
inputshape,
|
|
92
91
|
lagmask,
|
|
92
|
+
verbose=(LGR is not None),
|
|
93
93
|
nprocs=nprocs,
|
|
94
94
|
showprogressbar=showprogressbar,
|
|
95
95
|
chunksize=chunksize,
|
|
@@ -127,13 +127,16 @@ def makelaggedtcs(
|
|
|
127
127
|
)
|
|
128
128
|
volumetotal += 1
|
|
129
129
|
|
|
130
|
-
LGR
|
|
130
|
+
if LGR is not None:
|
|
131
|
+
LGR.info(f"\nLagged timecourses created for {volumetotal} voxels")
|
|
131
132
|
|
|
132
133
|
# garbage collect
|
|
133
134
|
uncollected = gc.collect()
|
|
134
135
|
if uncollected != 0:
|
|
135
|
-
LGR
|
|
136
|
+
if LGR is not None:
|
|
137
|
+
LGR.info(f"garbage collected - unable to collect {uncollected} objects")
|
|
136
138
|
else:
|
|
137
|
-
LGR
|
|
139
|
+
if LGR is not None:
|
|
140
|
+
LGR.info("garbage collected")
|
|
138
141
|
|
|
139
142
|
return volumetotal
|
rapidtide/multiproc.py
CHANGED
|
@@ -77,8 +77,8 @@ def _process_data(data_in, inQ, outQ, showprogressbar=True, reportstep=1000, chu
|
|
|
77
77
|
pbar.update(1)
|
|
78
78
|
if numreturned > remainder - 1:
|
|
79
79
|
break
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
if showprogressbar:
|
|
81
|
+
print()
|
|
82
82
|
|
|
83
83
|
return data_out
|
|
84
84
|
|
|
@@ -88,6 +88,7 @@ def run_multiproc(
|
|
|
88
88
|
inputshape,
|
|
89
89
|
maskarray,
|
|
90
90
|
nprocs=1,
|
|
91
|
+
verbose=True,
|
|
91
92
|
procbyvoxel=True,
|
|
92
93
|
showprogressbar=True,
|
|
93
94
|
chunksize=1000,
|
|
@@ -105,13 +106,6 @@ def run_multiproc(
|
|
|
105
106
|
workers = [ctx.Process(target=consumerfunc, args=(inQ, outQ)) for i in range(n_workers)]
|
|
106
107
|
# signal.signal(signal.SIGINT, original_sigint_handler)
|
|
107
108
|
else:
|
|
108
|
-
"""# try adding this magic incantation to get coverage to record multiprocessing properly
|
|
109
|
-
# This fails for python 3.8 and above
|
|
110
|
-
try:
|
|
111
|
-
from pytest_cov.embed import cleanup
|
|
112
|
-
except ImportError:
|
|
113
|
-
cleanup = None
|
|
114
|
-
"""
|
|
115
109
|
cleanup = None # just disable this for now
|
|
116
110
|
inQ = mp.Queue()
|
|
117
111
|
outQ = mp.Queue()
|
|
@@ -141,7 +135,8 @@ def run_multiproc(
|
|
|
141
135
|
data_in.append(d)
|
|
142
136
|
elif maskarray[d] > 0.5:
|
|
143
137
|
data_in.append(d)
|
|
144
|
-
|
|
138
|
+
if verbose:
|
|
139
|
+
print("processing", len(data_in), procunit + " with", n_workers, "processes")
|
|
145
140
|
data_out = _process_data(
|
|
146
141
|
data_in, inQ, outQ, showprogressbar=showprogressbar, chunksize=chunksize
|
|
147
142
|
)
|
|
@@ -162,6 +157,7 @@ def run_multithread(
|
|
|
162
157
|
consumerfunc,
|
|
163
158
|
inputshape,
|
|
164
159
|
maskarray,
|
|
160
|
+
verbose=True,
|
|
165
161
|
nprocs=1,
|
|
166
162
|
procbyvoxel=True,
|
|
167
163
|
showprogressbar=True,
|
|
@@ -197,7 +193,8 @@ def run_multithread(
|
|
|
197
193
|
data_in.append(d)
|
|
198
194
|
elif maskarray[d] > 0:
|
|
199
195
|
data_in.append(d)
|
|
200
|
-
|
|
196
|
+
if verbose:
|
|
197
|
+
print("processing", len(data_in), procunit + " with", n_workers, "threads")
|
|
201
198
|
data_out = _process_data(
|
|
202
199
|
data_in, inQ, outQ, showprogressbar=showprogressbar, chunksize=chunksize
|
|
203
200
|
)
|
rapidtide/refinedelay.py
CHANGED
|
@@ -26,7 +26,7 @@ import rapidtide.filter as tide_filt
|
|
|
26
26
|
import rapidtide.io as tide_io
|
|
27
27
|
import rapidtide.workflows.regressfrommaps as tide_regressfrommaps
|
|
28
28
|
|
|
29
|
-
global ratiotooffsetfunc, maplimits
|
|
29
|
+
global ratiotooffsetfunc, funcoffsets, maplimits
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
def smooth(y, box_pts):
|
|
@@ -40,37 +40,39 @@ def trainratiotooffset(
|
|
|
40
40
|
timeaxis,
|
|
41
41
|
outputname,
|
|
42
42
|
outputlevel,
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
trainlagmin=0.0,
|
|
44
|
+
trainlagmax=0.0,
|
|
45
|
+
trainlagstep=0.5,
|
|
45
46
|
mindelay=-3.0,
|
|
46
47
|
maxdelay=3.0,
|
|
47
48
|
numpoints=501,
|
|
48
49
|
smoothpts=3,
|
|
49
50
|
edgepad=5,
|
|
50
51
|
regressderivs=1,
|
|
52
|
+
LGR=None,
|
|
53
|
+
TimingLGR=None,
|
|
54
|
+
verbose=False,
|
|
51
55
|
debug=False,
|
|
52
56
|
):
|
|
53
|
-
global ratiotooffsetfunc, maplimits
|
|
57
|
+
global ratiotooffsetfunc, funcoffsets, maplimits
|
|
54
58
|
|
|
55
59
|
if debug:
|
|
56
60
|
print("ratiotooffsetfunc:")
|
|
57
61
|
lagtcgenerator.info(prefix="\t")
|
|
58
62
|
print("\ttimeaxis:", timeaxis)
|
|
59
63
|
print("\toutputname:", outputname)
|
|
60
|
-
print("\
|
|
61
|
-
print("\
|
|
64
|
+
print("\ttrainlagmin:", trainlagmin)
|
|
65
|
+
print("\ttrainlagmax:", trainlagmax)
|
|
66
|
+
print("\ttrainlagstep:", trainlagstep)
|
|
62
67
|
print("\tmindelay:", mindelay)
|
|
63
68
|
print("\tmaxdelay:", maxdelay)
|
|
64
69
|
print("\tsmoothpts:", smoothpts)
|
|
65
70
|
print("\tedgepad:", edgepad)
|
|
66
71
|
print("\tregressderivs:", regressderivs)
|
|
67
72
|
print("\tlagtcgenerator:", lagtcgenerator)
|
|
73
|
+
|
|
68
74
|
# make a delay map
|
|
69
75
|
delaystep = (maxdelay - mindelay) / (numpoints - 1)
|
|
70
|
-
if debug:
|
|
71
|
-
print(f"{delaystep=}")
|
|
72
|
-
print(f"{mindelay=}")
|
|
73
|
-
print(f"{maxdelay=}")
|
|
74
76
|
lagtimes = np.linspace(
|
|
75
77
|
mindelay - edgepad * delaystep,
|
|
76
78
|
maxdelay + edgepad * delaystep,
|
|
@@ -80,6 +82,7 @@ def trainratiotooffset(
|
|
|
80
82
|
if debug:
|
|
81
83
|
print(f"{mindelay=}")
|
|
82
84
|
print(f"{maxdelay=}")
|
|
85
|
+
print(f"{delaystep=}")
|
|
83
86
|
print("lagtimes=", lagtimes)
|
|
84
87
|
|
|
85
88
|
# set up for getratioderivs call
|
|
@@ -111,103 +114,142 @@ def trainratiotooffset(
|
|
|
111
114
|
"textio": False,
|
|
112
115
|
}
|
|
113
116
|
|
|
114
|
-
if
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
if trainlagmax - trainlagmin > 0.0:
|
|
118
|
+
numnegoffsets = np.max((-int(np.round(trainlagmin / trainlagstep, 0)), 1))
|
|
119
|
+
numposoffsets = np.max((int(np.round(trainlagmax / trainlagstep, 0)), 1))
|
|
120
|
+
numoffsets = numnegoffsets + 1 + numposoffsets
|
|
118
121
|
trainoffsets = (
|
|
119
|
-
np.linspace(0,
|
|
120
|
-
-
|
|
122
|
+
np.linspace(0, (numoffsets - 1) * trainlagstep, numoffsets, endpoint=True)
|
|
123
|
+
- numnegoffsets * trainlagstep
|
|
121
124
|
)
|
|
122
125
|
else:
|
|
123
126
|
trainoffsets = np.array([0.0], dtype=float)
|
|
127
|
+
numoffsets = 1
|
|
124
128
|
if debug:
|
|
125
129
|
print("trainoffsets:", trainoffsets)
|
|
130
|
+
allsmoothregressderivratios = np.zeros(
|
|
131
|
+
(numpoints + 2 * edgepad, numoffsets), dtype=rt_floattype
|
|
132
|
+
)
|
|
133
|
+
theEVs = np.zeros((numoffsets, timeaxis.shape[0]), dtype=float)
|
|
126
134
|
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
if verbose and (LGR is not None):
|
|
136
|
+
thisLGR = LGR
|
|
137
|
+
thisTimingLGR = TimingLGR
|
|
138
|
+
else:
|
|
139
|
+
thisLGR = None
|
|
140
|
+
thisTimingLGR = None
|
|
129
141
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
fmridata[i, :] = lagtcgenerator.yfromx(timeaxis - lagtimes[i])
|
|
142
|
+
for whichoffset in range(numoffsets):
|
|
143
|
+
thisoffset = trainoffsets[whichoffset]
|
|
133
144
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
smoothregressderivratios = tide_filt.unpadvec(
|
|
164
|
-
smooth(tide_filt.padvec(regressderivratios, padlen=20, padtype="constant"), smoothpts),
|
|
165
|
-
padlen=20,
|
|
145
|
+
# now make synthetic fMRI data
|
|
146
|
+
for i in range(numpoints + 2 * edgepad):
|
|
147
|
+
fmridata[i, :] = lagtcgenerator.yfromx(timeaxis - lagtimes[i] + thisoffset)
|
|
148
|
+
|
|
149
|
+
theEVs[whichoffset, :] = lagtcgenerator.yfromx(timeaxis + thisoffset)
|
|
150
|
+
|
|
151
|
+
regressderivratios, regressrvalues = getderivratios(
|
|
152
|
+
fmridata,
|
|
153
|
+
validvoxels,
|
|
154
|
+
timeaxis + thisoffset,
|
|
155
|
+
0.0 * lagtimes,
|
|
156
|
+
fmrimask,
|
|
157
|
+
lagtcgenerator,
|
|
158
|
+
"glm",
|
|
159
|
+
"refinedelaytest",
|
|
160
|
+
sampletime,
|
|
161
|
+
sLFOfitmean,
|
|
162
|
+
rvalue,
|
|
163
|
+
r2value,
|
|
164
|
+
fitNorm[:, :2],
|
|
165
|
+
fitcoeff[:, :2],
|
|
166
|
+
movingsignal,
|
|
167
|
+
lagtc,
|
|
168
|
+
filtereddata,
|
|
169
|
+
thisLGR,
|
|
170
|
+
thisTimingLGR,
|
|
171
|
+
optiondict,
|
|
172
|
+
regressderivs=regressderivs,
|
|
173
|
+
debug=debug,
|
|
166
174
|
)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
smoothregressderivratios
|
|
175
|
+
if debug:
|
|
176
|
+
print("before trimming")
|
|
177
|
+
print(f"{regressderivratios.shape=}")
|
|
178
|
+
print(f"{lagtimes.shape=}")
|
|
179
|
+
if regressderivs == 1:
|
|
180
|
+
smoothregressderivratios = tide_filt.unpadvec(
|
|
173
181
|
smooth(
|
|
174
|
-
tide_filt.padvec(regressderivratios
|
|
175
|
-
smoothpts,
|
|
182
|
+
tide_filt.padvec(regressderivratios, padlen=20, padtype="constant"), smoothpts
|
|
176
183
|
),
|
|
177
184
|
padlen=20,
|
|
178
185
|
)
|
|
179
|
-
|
|
180
|
-
|
|
186
|
+
# regressderivratios = regressderivratios[edgepad:-edgepad]
|
|
187
|
+
allsmoothregressderivratios[:, whichoffset] = smoothregressderivratios + 0.0
|
|
188
|
+
else:
|
|
189
|
+
smoothregressderivratios = np.zeros_like(regressderivratios)
|
|
190
|
+
for i in range(regressderivs):
|
|
191
|
+
allsmoothregressderivratios[i, :] = tide_filt.unpadvec(
|
|
192
|
+
smooth(
|
|
193
|
+
tide_filt.padvec(regressderivratios[i, :], padlen=20, padtype="constant"),
|
|
194
|
+
smoothpts,
|
|
195
|
+
),
|
|
196
|
+
padlen=20,
|
|
197
|
+
)
|
|
198
|
+
# regressderivratios = regressderivratios[:, edgepad:-edgepad]
|
|
199
|
+
allsmoothregressderivratios = smoothregressderivratios + 0.0
|
|
200
|
+
|
|
201
|
+
allsmoothregressderivratios = allsmoothregressderivratios[edgepad:-edgepad, :]
|
|
181
202
|
lagtimes = lagtimes[edgepad:-edgepad]
|
|
182
203
|
if debug:
|
|
183
204
|
print("after trimming")
|
|
184
205
|
print(f"{regressderivratios.shape=}")
|
|
185
|
-
print(f"{
|
|
206
|
+
print(f"{allsmoothregressderivratios.shape=}")
|
|
186
207
|
print(f"{lagtimes.shape=}")
|
|
187
208
|
|
|
188
|
-
#
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
lowerlim
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
upperlim
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
209
|
+
# find the minimum legal limits of the mapping function
|
|
210
|
+
highestlowerlim = 0
|
|
211
|
+
lowestupperlim = numpoints
|
|
212
|
+
for whichoffset in range(numoffsets):
|
|
213
|
+
xaxis = allsmoothregressderivratios[::-1, whichoffset]
|
|
214
|
+
midpoint = int(len(xaxis) // 2)
|
|
215
|
+
lowerlim = midpoint + 0
|
|
216
|
+
while (lowerlim > 1) and xaxis[lowerlim] > xaxis[lowerlim - 1]:
|
|
217
|
+
lowerlim -= 1
|
|
218
|
+
upperlim = midpoint + 0
|
|
219
|
+
while (upperlim < len(xaxis) - 2) and xaxis[upperlim] < xaxis[upperlim + 1]:
|
|
220
|
+
upperlim += 1
|
|
221
|
+
if lowerlim > highestlowerlim:
|
|
222
|
+
highestlowerlim = lowerlim
|
|
223
|
+
if upperlim < lowestupperlim:
|
|
224
|
+
lowestupperlim = upperlim
|
|
225
|
+
|
|
226
|
+
ratiotooffsetfunc = []
|
|
227
|
+
funcoffsets = []
|
|
228
|
+
for whichoffset in range(numoffsets):
|
|
229
|
+
xaxis = allsmoothregressderivratios[::-1, whichoffset]
|
|
230
|
+
yaxis = lagtimes[::-1]
|
|
231
|
+
xaxis = xaxis[highestlowerlim : lowestupperlim + 1]
|
|
232
|
+
yaxis = yaxis[highestlowerlim : lowestupperlim + 1]
|
|
233
|
+
ratiotooffsetfunc.append(CubicSpline(xaxis, yaxis))
|
|
234
|
+
funcoffsets.append(trainoffsets[whichoffset] + 0.0)
|
|
201
235
|
maplimits = (xaxis[0], xaxis[-1])
|
|
202
236
|
|
|
203
237
|
if outputlevel != "min":
|
|
204
238
|
resampaxis = np.linspace(xaxis[0], xaxis[-1], num=len(xaxis), endpoint=True)
|
|
239
|
+
outputfuncs = np.zeros((resampaxis.size, numoffsets), dtype=float)
|
|
240
|
+
colnames = []
|
|
241
|
+
for whichoffset in range(numoffsets):
|
|
242
|
+
colnames.append(f"{funcoffsets[whichoffset]}")
|
|
243
|
+
outputfuncs[:, whichoffset] = ratiotooffsetfunc[whichoffset](resampaxis)
|
|
244
|
+
if debug:
|
|
245
|
+
print(f"{colnames=}")
|
|
246
|
+
print(f"{outputfuncs.shape=}")
|
|
205
247
|
tide_io.writebidstsv(
|
|
206
248
|
f"{outputname}_desc-ratiotodelayfunc_timeseries",
|
|
207
|
-
|
|
249
|
+
np.transpose(outputfuncs),
|
|
208
250
|
1.0 / (resampaxis[1] - resampaxis[0]),
|
|
209
251
|
starttime=resampaxis[0],
|
|
210
|
-
columns=
|
|
252
|
+
columns=colnames,
|
|
211
253
|
extraheaderinfo={
|
|
212
254
|
"Description": "The function mapping derivative ratio to delay",
|
|
213
255
|
"minratio": f"{resampaxis[0]}",
|
|
@@ -217,16 +259,59 @@ def trainratiotooffset(
|
|
|
217
259
|
yaxislabel="time",
|
|
218
260
|
append=False,
|
|
219
261
|
)
|
|
262
|
+
if numoffsets > 1:
|
|
263
|
+
print(f"{theEVs.shape=}, {numoffsets=}, {(numoffsets>1)=}")
|
|
264
|
+
tide_io.writebidstsv(
|
|
265
|
+
f"{outputname}_desc-trainratioEV_timeseries",
|
|
266
|
+
theEVs,
|
|
267
|
+
1.0 / (timeaxis[1] - timeaxis[0]),
|
|
268
|
+
starttime=timeaxis[0],
|
|
269
|
+
columns=colnames,
|
|
270
|
+
extraheaderinfo={"Description": f"EVs used for each offset"},
|
|
271
|
+
append=False,
|
|
272
|
+
)
|
|
273
|
+
|
|
220
274
|
|
|
275
|
+
def ratiotodelay(theratio, offset=0.0, debug=False):
|
|
276
|
+
global ratiotooffsetfunc, funcoffsets, maplimits
|
|
277
|
+
|
|
278
|
+
# find the closest calculated offset
|
|
279
|
+
closestindex = 0
|
|
280
|
+
for offsetindex in range(1, len(funcoffsets)):
|
|
281
|
+
if np.fabs(funcoffsets[offsetindex] - offset) < np.fabs(
|
|
282
|
+
funcoffsets[closestindex] - offset
|
|
283
|
+
):
|
|
284
|
+
closestindex = offsetindex
|
|
285
|
+
closestoffset = funcoffsets[closestindex]
|
|
286
|
+
distance = np.fabs(funcoffsets[closestindex] - offset)
|
|
287
|
+
"""if (maplimits[0] < theratio < maplimits[1]) and (
|
|
288
|
+
distance < (funcoffsets[1] - funcoffsets[0]) / 2
|
|
289
|
+
):
|
|
290
|
+
return (
|
|
291
|
+
ratiotooffsetfunc[closestindex](theratio) + (offset - closestoffset),
|
|
292
|
+
closestoffset,
|
|
293
|
+
)
|
|
294
|
+
else:
|
|
295
|
+
return (
|
|
296
|
+
0.0,
|
|
297
|
+
closestoffset,
|
|
298
|
+
)"""
|
|
221
299
|
|
|
222
|
-
def ratiotodelay(theratio):
|
|
223
|
-
global ratiotooffsetfunc, maplimits
|
|
224
300
|
if theratio < maplimits[0]:
|
|
225
|
-
return
|
|
301
|
+
return (
|
|
302
|
+
ratiotooffsetfunc[closestindex](maplimits[0]) + (offset - closestoffset),
|
|
303
|
+
closestoffset,
|
|
304
|
+
)
|
|
226
305
|
elif theratio > maplimits[1]:
|
|
227
|
-
return
|
|
306
|
+
return (
|
|
307
|
+
ratiotooffsetfunc[closestindex](maplimits[1]),
|
|
308
|
+
closestoffset,
|
|
309
|
+
)
|
|
228
310
|
else:
|
|
229
|
-
return
|
|
311
|
+
return (
|
|
312
|
+
ratiotooffsetfunc[closestindex](theratio),
|
|
313
|
+
closestoffset,
|
|
314
|
+
)
|
|
230
315
|
|
|
231
316
|
|
|
232
317
|
def coffstodelay(thecoffs, mindelay=-3.0, maxdelay=3.0, debug=False):
|
|
@@ -316,7 +401,7 @@ def getderivratios(
|
|
|
316
401
|
LGR,
|
|
317
402
|
TimingLGR,
|
|
318
403
|
optiondict["regressfiltthreshval"],
|
|
319
|
-
|
|
404
|
+
False,
|
|
320
405
|
nprocs_makelaggedtcs=optiondict["nprocs_makelaggedtcs"],
|
|
321
406
|
nprocs_regressionfilt=optiondict["nprocs_regressionfilt"],
|
|
322
407
|
regressderivs=regressderivs,
|
|
@@ -349,6 +434,7 @@ def filterderivratios(
|
|
|
349
434
|
fileiscifti=False,
|
|
350
435
|
textio=False,
|
|
351
436
|
rt_floattype="float64",
|
|
437
|
+
verbose=True,
|
|
352
438
|
debug=False,
|
|
353
439
|
):
|
|
354
440
|
|
|
@@ -360,7 +446,8 @@ def filterderivratios(
|
|
|
360
446
|
|
|
361
447
|
# filter the ratio to find weird values
|
|
362
448
|
themad = mad(regressderivratios).astype(np.float64)
|
|
363
|
-
|
|
449
|
+
if verbose:
|
|
450
|
+
print(f"MAD of regression fit derivative ratios = {themad}")
|
|
364
451
|
outmaparray, internalspaceshape = tide_io.makedestarray(
|
|
365
452
|
nativespaceshape,
|
|
366
453
|
textio=textio,
|
|
@@ -25,12 +25,20 @@ import rapidtide.workflows.happy_parser as happy_parser
|
|
|
25
25
|
from rapidtide.tests.utils import create_dir, get_examples_path, get_test_temp_path, mse
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def test_fullrunhappy_v1(debug=False, displayplots=False):
|
|
28
|
+
def test_fullrunhappy_v1(debug=False, local=False, displayplots=False):
|
|
29
|
+
# set input and output directories
|
|
30
|
+
if local:
|
|
31
|
+
exampleroot = "../data/examples/src"
|
|
32
|
+
testtemproot = "./tmp"
|
|
33
|
+
else:
|
|
34
|
+
exampleroot = get_examples_path()
|
|
35
|
+
testtemproot = get_test_temp_path()
|
|
36
|
+
|
|
29
37
|
# run happy
|
|
30
38
|
inputargs = [
|
|
31
|
-
os.path.join(
|
|
32
|
-
os.path.join(
|
|
33
|
-
os.path.join(
|
|
39
|
+
os.path.join(exampleroot, "sub-HAPPYTEST.nii.gz"),
|
|
40
|
+
os.path.join(exampleroot, "sub-HAPPYTEST.json"),
|
|
41
|
+
os.path.join(testtemproot, "happyout1"),
|
|
34
42
|
"--mklthreads",
|
|
35
43
|
"-1",
|
|
36
44
|
"--spatialregression",
|
|
@@ -42,4 +50,4 @@ def test_fullrunhappy_v1(debug=False, displayplots=False):
|
|
|
42
50
|
|
|
43
51
|
if __name__ == "__main__":
|
|
44
52
|
mpl.use("TkAgg")
|
|
45
|
-
test_fullrunhappy_v1(debug=True, displayplots=True)
|
|
53
|
+
test_fullrunhappy_v1(debug=True, local=True, displayplots=True)
|
|
@@ -25,16 +25,24 @@ import rapidtide.workflows.happy_parser as happy_parser
|
|
|
25
25
|
from rapidtide.tests.utils import get_examples_path, get_test_temp_path
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def test_fullrunhappy_v2(debug=False, displayplots=False):
|
|
28
|
+
def test_fullrunhappy_v2(debug=False, local=False, displayplots=False):
|
|
29
|
+
# set input and output directories
|
|
30
|
+
if local:
|
|
31
|
+
exampleroot = "../data/examples/src"
|
|
32
|
+
testtemproot = "./tmp"
|
|
33
|
+
else:
|
|
34
|
+
exampleroot = get_examples_path()
|
|
35
|
+
testtemproot = get_test_temp_path()
|
|
36
|
+
|
|
29
37
|
# run happy
|
|
30
38
|
inputargs = [
|
|
31
|
-
os.path.join(
|
|
32
|
-
os.path.join(
|
|
33
|
-
os.path.join(
|
|
39
|
+
os.path.join(exampleroot, "sub-HAPPYTEST.nii.gz"),
|
|
40
|
+
os.path.join(exampleroot, "sub-HAPPYTEST.json"),
|
|
41
|
+
os.path.join(testtemproot, "happyout2"),
|
|
34
42
|
"--estweights",
|
|
35
|
-
os.path.join(
|
|
43
|
+
os.path.join(exampleroot, "sub-HAPPYTEST_smallmask.nii.gz"),
|
|
36
44
|
"--projmask",
|
|
37
|
-
os.path.join(
|
|
45
|
+
os.path.join(exampleroot, "sub-HAPPYTEST_smallmask.nii.gz"),
|
|
38
46
|
"--mklthreads",
|
|
39
47
|
"-1",
|
|
40
48
|
"--model",
|
|
@@ -43,7 +51,7 @@ def test_fullrunhappy_v2(debug=False, displayplots=False):
|
|
|
43
51
|
"--temporalregression",
|
|
44
52
|
"--cardiacfile",
|
|
45
53
|
os.path.join(
|
|
46
|
-
|
|
54
|
+
exampleroot,
|
|
47
55
|
"sub-HAPPYTEST_desc-slicerescardfromfmri_timeseries.json:cardiacfromfmri_dlfiltered",
|
|
48
56
|
),
|
|
49
57
|
"--increaseoutputlevel",
|
|
@@ -54,4 +62,4 @@ def test_fullrunhappy_v2(debug=False, displayplots=False):
|
|
|
54
62
|
|
|
55
63
|
if __name__ == "__main__":
|
|
56
64
|
mpl.use("TkAgg")
|
|
57
|
-
test_fullrunhappy_v2(debug=True, displayplots=True)
|
|
65
|
+
test_fullrunhappy_v2(debug=True, local=True, displayplots=True)
|
|
@@ -25,16 +25,24 @@ import rapidtide.workflows.happy_parser as happy_parser
|
|
|
25
25
|
from rapidtide.tests.utils import get_examples_path, get_test_temp_path
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def test_fullrunhappy_v3(debug=False, displayplots=False):
|
|
28
|
+
def test_fullrunhappy_v3(debug=False, local=False, displayplots=False):
|
|
29
|
+
# set input and output directories
|
|
30
|
+
if local:
|
|
31
|
+
exampleroot = "../data/examples/src"
|
|
32
|
+
testtemproot = "./tmp"
|
|
33
|
+
else:
|
|
34
|
+
exampleroot = get_examples_path()
|
|
35
|
+
testtemproot = get_test_temp_path()
|
|
36
|
+
|
|
29
37
|
# run happy
|
|
30
38
|
inputargs = [
|
|
31
|
-
os.path.join(
|
|
32
|
-
os.path.join(
|
|
33
|
-
os.path.join(
|
|
39
|
+
os.path.join(exampleroot, "sub-HAPPYTEST.nii.gz"),
|
|
40
|
+
os.path.join(exampleroot, "sub-HAPPYTEST.json"),
|
|
41
|
+
os.path.join(testtemproot, "happyout3"),
|
|
34
42
|
"--estweights",
|
|
35
|
-
os.path.join(
|
|
43
|
+
os.path.join(exampleroot, "sub-HAPPYTEST_smallmask.nii.gz"),
|
|
36
44
|
"--projmask",
|
|
37
|
-
os.path.join(
|
|
45
|
+
os.path.join(exampleroot, "sub-HAPPYTEST_smallmask.nii.gz"),
|
|
38
46
|
"--mklthreads",
|
|
39
47
|
"-1",
|
|
40
48
|
"--model",
|
|
@@ -42,10 +50,10 @@ def test_fullrunhappy_v3(debug=False, displayplots=False):
|
|
|
42
50
|
"--cardcalconly",
|
|
43
51
|
]
|
|
44
52
|
# "--motionfile",
|
|
45
|
-
# os.path.join(
|
|
53
|
+
# os.path.join(exampleroot, "sub-HAPPYTEST_mcf.par"),
|
|
46
54
|
happy_workflow.happy_main(happy_parser.process_args(inputargs=inputargs))
|
|
47
55
|
|
|
48
56
|
|
|
49
57
|
if __name__ == "__main__":
|
|
50
58
|
mpl.use("TkAgg")
|
|
51
|
-
test_fullrunhappy_v3(debug=True, displayplots=True)
|
|
59
|
+
test_fullrunhappy_v3(debug=True, local=True, displayplots=True)
|