rapidtide 3.0.4__py3-none-any.whl → 3.0.6__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/_version.py +3 -3
- rapidtide/calccoherence.py +51 -73
- rapidtide/calcnullsimfunc.py +65 -111
- rapidtide/calcsimfunc.py +73 -91
- rapidtide/data/examples/src/testatlasaverage +22 -0
- rapidtide/data/examples/src/testfmri +1 -1
- rapidtide/data/examples/src/testhappy +7 -6
- rapidtide/genericmultiproc.py +122 -0
- rapidtide/happy_supportfuncs.py +10 -1
- rapidtide/io.py +4 -2
- rapidtide/linfitfiltpass.py +8 -1
- rapidtide/makelaggedtcs.py +49 -78
- rapidtide/multiproc.py +5 -17
- rapidtide/refineregressor.py +59 -81
- rapidtide/tests/.coveragerc +9 -0
- rapidtide/tests/test_externaltools.py +69 -0
- rapidtide/tests/test_fastresampler.py +1 -0
- rapidtide/tests/test_fullrunrapidtide_v2.py +1 -0
- rapidtide/tests/test_nullcorr.py +2 -5
- rapidtide/tests/test_parserfuncs.py +46 -15
- rapidtide/tests/test_zRapidtideDataset.py +2 -2
- rapidtide/workflows/ccorrica.py +1 -2
- rapidtide/workflows/happy.py +3 -1
- rapidtide/workflows/rapidtide.py +3 -9
- rapidtide/workflows/rapidtide_parser.py +3 -3
- rapidtide/workflows/regressfrommaps.py +0 -2
- rapidtide/workflows/showxcorrx.py +4 -8
- rapidtide/workflows/simdata.py +17 -23
- {rapidtide-3.0.4.dist-info → rapidtide-3.0.6.dist-info}/METADATA +1 -1
- {rapidtide-3.0.4.dist-info → rapidtide-3.0.6.dist-info}/RECORD +34 -35
- {rapidtide-3.0.4.dist-info → rapidtide-3.0.6.dist-info}/WHEEL +1 -1
- rapidtide/DerivativeDelay.py +0 -209
- rapidtide/calcandfitcorrpairs.py +0 -262
- rapidtide/transformerdlfilter.py +0 -126
- {rapidtide-3.0.4.dist-info → rapidtide-3.0.6.dist-info}/entry_points.txt +0 -0
- {rapidtide-3.0.4.dist-info → rapidtide-3.0.6.dist-info}/licenses/LICENSE +0 -0
- {rapidtide-3.0.4.dist-info → rapidtide-3.0.6.dist-info}/top_level.txt +0 -0
rapidtide/_version.py
CHANGED
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "2025-05-
|
|
11
|
+
"date": "2025-05-21T09:46:09-0400",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "3.0.
|
|
14
|
+
"full-revisionid": "3f58d08c2a84ae41777dc6b9522b0e89da4cdaec",
|
|
15
|
+
"version": "3.0.6"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
rapidtide/calccoherence.py
CHANGED
|
@@ -21,17 +21,28 @@ import logging
|
|
|
21
21
|
import warnings
|
|
22
22
|
|
|
23
23
|
import numpy as np
|
|
24
|
-
from tqdm import tqdm
|
|
25
24
|
|
|
26
|
-
import rapidtide.
|
|
25
|
+
import rapidtide.genericmultiproc as tide_genericmultiproc
|
|
27
26
|
|
|
28
27
|
warnings.simplefilter(action="ignore", category=FutureWarning)
|
|
29
28
|
LGR = logging.getLogger("GENERAL")
|
|
30
29
|
|
|
31
30
|
|
|
32
31
|
def _procOneVoxelCoherence(
|
|
33
|
-
vox,
|
|
32
|
+
vox,
|
|
33
|
+
voxelargs,
|
|
34
|
+
**kwargs,
|
|
34
35
|
):
|
|
36
|
+
options = {
|
|
37
|
+
"alt": False,
|
|
38
|
+
"debug": False,
|
|
39
|
+
}
|
|
40
|
+
options.update(kwargs)
|
|
41
|
+
alt = options["alt"]
|
|
42
|
+
debug = options["debug"]
|
|
43
|
+
(theCoherer, fmritc) = voxelargs
|
|
44
|
+
if debug:
|
|
45
|
+
print(f"{alt=}")
|
|
35
46
|
if alt:
|
|
36
47
|
(
|
|
37
48
|
thecoherence_y,
|
|
@@ -53,6 +64,19 @@ def _procOneVoxelCoherence(
|
|
|
53
64
|
)
|
|
54
65
|
|
|
55
66
|
|
|
67
|
+
def _packvoxeldata(voxnum, voxelargs):
|
|
68
|
+
return [
|
|
69
|
+
voxelargs[0],
|
|
70
|
+
(voxelargs[1])[voxnum, :],
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _unpackvoxeldata(retvals, voxelproducts):
|
|
75
|
+
(voxelproducts[0])[retvals[0]] = retvals[2]
|
|
76
|
+
(voxelproducts[1])[retvals[0]] = retvals[3]
|
|
77
|
+
(voxelproducts[2])[retvals[0]] = retvals[4]
|
|
78
|
+
|
|
79
|
+
|
|
56
80
|
def coherencepass(
|
|
57
81
|
fmridata,
|
|
58
82
|
theCoherer,
|
|
@@ -64,8 +88,7 @@ def coherencepass(
|
|
|
64
88
|
nprocs=1,
|
|
65
89
|
alwaysmultiproc=False,
|
|
66
90
|
showprogressbar=True,
|
|
67
|
-
|
|
68
|
-
rt_floattype="float64",
|
|
91
|
+
debug=False,
|
|
69
92
|
):
|
|
70
93
|
"""
|
|
71
94
|
|
|
@@ -88,74 +111,29 @@ def coherencepass(
|
|
|
88
111
|
|
|
89
112
|
"""
|
|
90
113
|
inputshape = np.shape(fmridata)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
except Exception as e:
|
|
117
|
-
print("error!", e)
|
|
118
|
-
break
|
|
119
|
-
|
|
120
|
-
data_out = tide_multiproc.run_multiproc(
|
|
121
|
-
coherence_consumer,
|
|
122
|
-
inputshape,
|
|
123
|
-
None,
|
|
124
|
-
nprocs=nprocs,
|
|
125
|
-
showprogressbar=showprogressbar,
|
|
126
|
-
chunksize=chunksize,
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
# unpack the data
|
|
130
|
-
volumetotal = 0
|
|
131
|
-
for voxel in data_out:
|
|
132
|
-
coherencefunc[voxel[0], :] = voxel[2] + 0.0
|
|
133
|
-
coherencepeakval[voxel[0]] = voxel[3] + 0.0
|
|
134
|
-
coherencepeakfreq[voxel[0]] = voxel[4] + 0.0
|
|
135
|
-
volumetotal += 1
|
|
136
|
-
del data_out
|
|
137
|
-
else:
|
|
138
|
-
for vox in tqdm(
|
|
139
|
-
range(0, inputshape[0]),
|
|
140
|
-
desc="Voxel",
|
|
141
|
-
unit="voxels",
|
|
142
|
-
disable=(not showprogressbar),
|
|
143
|
-
):
|
|
144
|
-
(
|
|
145
|
-
dummy,
|
|
146
|
-
dummy,
|
|
147
|
-
coherencefunc[vox],
|
|
148
|
-
coherencepeakval[vox],
|
|
149
|
-
coherencepeakfreq[vox],
|
|
150
|
-
) = _procOneVoxelCoherence(
|
|
151
|
-
vox,
|
|
152
|
-
theCoherer,
|
|
153
|
-
fmridata[vox, :],
|
|
154
|
-
alt=alt,
|
|
155
|
-
rt_floatset=rt_floatset,
|
|
156
|
-
rt_floattype=rt_floattype,
|
|
157
|
-
)
|
|
158
|
-
volumetotal += 1
|
|
114
|
+
voxelargs = [theCoherer, fmridata]
|
|
115
|
+
voxelfunc = _procOneVoxelCoherence
|
|
116
|
+
packfunc = _packvoxeldata
|
|
117
|
+
unpackfunc = _unpackvoxeldata
|
|
118
|
+
voxeltargets = [coherencefunc, coherencepeakval, coherencepeakfreq]
|
|
119
|
+
voxelmask = fmridata[:, 0] * 0.0 + 1
|
|
120
|
+
|
|
121
|
+
volumetotal = tide_genericmultiproc.run_multiproc(
|
|
122
|
+
voxelfunc,
|
|
123
|
+
packfunc,
|
|
124
|
+
unpackfunc,
|
|
125
|
+
voxelargs,
|
|
126
|
+
voxeltargets,
|
|
127
|
+
inputshape,
|
|
128
|
+
voxelmask,
|
|
129
|
+
LGR,
|
|
130
|
+
nprocs,
|
|
131
|
+
alwaysmultiproc,
|
|
132
|
+
showprogressbar,
|
|
133
|
+
chunksize,
|
|
134
|
+
alt=alt,
|
|
135
|
+
debug=debug,
|
|
136
|
+
)
|
|
159
137
|
LGR.info(f"\nCoherence performed on {volumetotal} voxels")
|
|
160
138
|
|
|
161
139
|
# garbage collect
|
rapidtide/calcnullsimfunc.py
CHANGED
|
@@ -16,34 +16,41 @@
|
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
#
|
|
18
18
|
#
|
|
19
|
-
import os
|
|
20
19
|
import sys
|
|
21
|
-
|
|
20
|
+
|
|
22
21
|
|
|
23
22
|
import numpy as np
|
|
24
|
-
|
|
23
|
+
|
|
25
24
|
|
|
26
25
|
import rapidtide.filter as tide_filt
|
|
27
26
|
import rapidtide.miscmath as tide_math
|
|
28
|
-
import rapidtide.
|
|
27
|
+
import rapidtide.genericmultiproc as tide_genericmultiproc
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
# note: rawtimecourse has been filtered, but NOT windowed
|
|
32
31
|
def _procOneNullCorrelationx(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Fs,
|
|
37
|
-
theCorrelator,
|
|
38
|
-
thefitter,
|
|
39
|
-
despeckle_thresh=5.0,
|
|
40
|
-
fixdelay=False,
|
|
41
|
-
initialdelayvalue=0.0,
|
|
42
|
-
permutationmethod="shuffle",
|
|
43
|
-
disablethresholds=False,
|
|
44
|
-
rt_floatset=np.float64,
|
|
45
|
-
rt_floattype="float64",
|
|
32
|
+
vox,
|
|
33
|
+
voxelargs,
|
|
34
|
+
**kwargs,
|
|
46
35
|
):
|
|
36
|
+
|
|
37
|
+
options = {
|
|
38
|
+
"permutationmethod": "shuffle",
|
|
39
|
+
"debug": False,
|
|
40
|
+
}
|
|
41
|
+
options.update(kwargs)
|
|
42
|
+
permutationmethod = options["permutationmethod"]
|
|
43
|
+
debug = options["debug"]
|
|
44
|
+
if debug:
|
|
45
|
+
print(f"{permutationmethod=}")
|
|
46
|
+
(
|
|
47
|
+
normalizedreftc,
|
|
48
|
+
rawtcfft_r,
|
|
49
|
+
rawtcfft_ang,
|
|
50
|
+
theCorrelator,
|
|
51
|
+
thefitter,
|
|
52
|
+
) = voxelargs
|
|
53
|
+
|
|
47
54
|
# make a shuffled copy of the regressors
|
|
48
55
|
if permutationmethod == "shuffle":
|
|
49
56
|
permutedtc = np.random.permutation(normalizedreftc)
|
|
@@ -71,17 +78,22 @@ def _procOneNullCorrelationx(
|
|
|
71
78
|
peakend,
|
|
72
79
|
) = thefitter.fit(thexcorr_y)
|
|
73
80
|
|
|
74
|
-
return maxval
|
|
81
|
+
return vox, maxval
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _packvoxeldata(voxnum, voxelargs):
|
|
85
|
+
return [voxelargs[0], voxelargs[1], voxelargs[2], voxelargs[3], voxelargs[4]]
|
|
75
86
|
|
|
76
87
|
|
|
77
|
-
def
|
|
78
|
-
|
|
88
|
+
def _unpackvoxeldata(retvals, voxelproducts):
|
|
89
|
+
(voxelproducts[0])[retvals[0]] = retvals[1]
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def getNullDistributionData(
|
|
79
93
|
Fs,
|
|
80
94
|
theCorrelator,
|
|
81
95
|
thefitter,
|
|
82
|
-
|
|
83
|
-
fixdelay=False,
|
|
84
|
-
initialdelayvalue=0.0,
|
|
96
|
+
LGR,
|
|
85
97
|
numestreps=0,
|
|
86
98
|
nprocs=1,
|
|
87
99
|
alwaysmultiproc=False,
|
|
@@ -90,12 +102,16 @@ def getNullDistributionDatax(
|
|
|
90
102
|
permutationmethod="shuffle",
|
|
91
103
|
rt_floatset=np.float64,
|
|
92
104
|
rt_floattype="float64",
|
|
105
|
+
debug=False,
|
|
93
106
|
):
|
|
94
107
|
r"""Calculate a set of null correlations to determine the distribution of correlation values. This can
|
|
95
108
|
be used to find the spurious correlation threshold
|
|
96
109
|
|
|
97
110
|
Parameters
|
|
98
111
|
----------
|
|
112
|
+
Fs: float
|
|
113
|
+
The sample frequency of rawtimecourse, in Hz
|
|
114
|
+
|
|
99
115
|
rawtimecourse : 1D numpy array
|
|
100
116
|
The test regressor. This should be filtered to the desired bandwidth, but NOT windowed.
|
|
101
117
|
:param rawtimecourse:
|
|
@@ -106,9 +122,6 @@ def getNullDistributionDatax(
|
|
|
106
122
|
filterfunc: function
|
|
107
123
|
This is a preconfigured NoncausalFilter function which is used to filter data to the desired bandwidth
|
|
108
124
|
|
|
109
|
-
Fs: float
|
|
110
|
-
The sample frequency of rawtimecourse, in Hz
|
|
111
|
-
|
|
112
125
|
corrorigin: int
|
|
113
126
|
The bin number in the correlation timescale corresponding to 0.0 seconds delay
|
|
114
127
|
|
|
@@ -129,91 +142,32 @@ def getNullDistributionDatax(
|
|
|
129
142
|
),
|
|
130
143
|
)
|
|
131
144
|
rawtcfft_r, rawtcfft_ang = tide_filt.polarfft(normalizedreftc)
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
rt_floatset=rt_floatset,
|
|
159
|
-
rt_floattype=rt_floattype,
|
|
160
|
-
)
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
except Exception as e:
|
|
164
|
-
print("error!", e)
|
|
165
|
-
break
|
|
166
|
-
|
|
167
|
-
data_out = tide_multiproc.run_multiproc(
|
|
168
|
-
nullCorrelation_consumer,
|
|
169
|
-
inputshape,
|
|
170
|
-
None,
|
|
171
|
-
nprocs=nprocs,
|
|
172
|
-
showprogressbar=showprogressbar,
|
|
173
|
-
chunksize=chunksize,
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
# unpack the data
|
|
177
|
-
corrlist = np.asarray(data_out, dtype=rt_floattype)
|
|
178
|
-
else:
|
|
179
|
-
corrlist = np.zeros((numestreps), dtype=rt_floattype)
|
|
180
|
-
|
|
181
|
-
for i in tqdm(
|
|
182
|
-
range(0, numestreps),
|
|
183
|
-
desc="Sham correlation",
|
|
184
|
-
unit="correlations",
|
|
185
|
-
disable=(not showprogressbar),
|
|
186
|
-
):
|
|
187
|
-
# make a shuffled copy of the regressors
|
|
188
|
-
if permutationmethod == "shuffle":
|
|
189
|
-
permutedtc = np.random.permutation(normalizedreftc)
|
|
190
|
-
elif permutationmethod == "phaserandom":
|
|
191
|
-
permutedtc = tide_filt.ifftfrompolar(
|
|
192
|
-
rawtcfft_r, np.random.permutation(rawtcfft_ang)
|
|
193
|
-
)
|
|
194
|
-
else:
|
|
195
|
-
print("illegal shuffling method")
|
|
196
|
-
sys.exit()
|
|
197
|
-
|
|
198
|
-
# crosscorrelate with original, fit, and return the maximum value, and add it to the list
|
|
199
|
-
thexcorr = _procOneNullCorrelationx(
|
|
200
|
-
normalizedreftc,
|
|
201
|
-
rawtcfft_r,
|
|
202
|
-
rawtcfft_ang,
|
|
203
|
-
Fs,
|
|
204
|
-
theCorrelator,
|
|
205
|
-
thefitter,
|
|
206
|
-
despeckle_thresh=despeckle_thresh,
|
|
207
|
-
fixdelay=fixdelay,
|
|
208
|
-
initialdelayvalue=initialdelayvalue,
|
|
209
|
-
permutationmethod=permutationmethod,
|
|
210
|
-
rt_floatset=rt_floatset,
|
|
211
|
-
rt_floattype=rt_floattype,
|
|
212
|
-
)
|
|
213
|
-
corrlist[i] = thexcorr
|
|
214
|
-
|
|
215
|
-
# jump to line after progress bar
|
|
216
|
-
print()
|
|
145
|
+
corrlist = np.zeros((numestreps), dtype=rt_floattype)
|
|
146
|
+
voxelmask = np.ones((numestreps), dtype=rt_floattype)
|
|
147
|
+
voxelargs = [normalizedreftc, rawtcfft_r, rawtcfft_ang, theCorrelator, thefitter]
|
|
148
|
+
voxelfunc = _procOneNullCorrelationx
|
|
149
|
+
packfunc = _packvoxeldata
|
|
150
|
+
unpackfunc = _unpackvoxeldata
|
|
151
|
+
voxeltargets = [
|
|
152
|
+
corrlist,
|
|
153
|
+
]
|
|
154
|
+
|
|
155
|
+
volumetotal = tide_genericmultiproc.run_multiproc(
|
|
156
|
+
voxelfunc,
|
|
157
|
+
packfunc,
|
|
158
|
+
unpackfunc,
|
|
159
|
+
voxelargs,
|
|
160
|
+
voxeltargets,
|
|
161
|
+
inputshape,
|
|
162
|
+
voxelmask,
|
|
163
|
+
LGR,
|
|
164
|
+
nprocs,
|
|
165
|
+
alwaysmultiproc,
|
|
166
|
+
showprogressbar,
|
|
167
|
+
chunksize,
|
|
168
|
+
permutationmethod=permutationmethod,
|
|
169
|
+
debug=debug,
|
|
170
|
+
)
|
|
217
171
|
|
|
218
172
|
# return the distribution data
|
|
219
173
|
numnonzero = len(np.where(corrlist != 0.0)[0])
|
rapidtide/calcsimfunc.py
CHANGED
|
@@ -21,9 +21,8 @@ import logging
|
|
|
21
21
|
import warnings
|
|
22
22
|
|
|
23
23
|
import numpy as np
|
|
24
|
-
from tqdm import tqdm
|
|
25
24
|
|
|
26
|
-
import rapidtide.
|
|
25
|
+
import rapidtide.genericmultiproc as tide_genericmultiproc
|
|
27
26
|
import rapidtide.resample as tide_resample
|
|
28
27
|
|
|
29
28
|
warnings.simplefilter(action="ignore", category=FutureWarning)
|
|
@@ -32,23 +31,48 @@ LGR = logging.getLogger("GENERAL")
|
|
|
32
31
|
|
|
33
32
|
def _procOneVoxelCorrelation(
|
|
34
33
|
vox,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
fmri_x,
|
|
38
|
-
fmritc,
|
|
39
|
-
os_fmri_x,
|
|
40
|
-
oversampfactor=1,
|
|
41
|
-
interptype="univariate",
|
|
42
|
-
rt_floatset=np.float64,
|
|
43
|
-
rt_floattype="float64",
|
|
34
|
+
voxelargs,
|
|
35
|
+
**kwargs,
|
|
44
36
|
):
|
|
37
|
+
options = {
|
|
38
|
+
"oversampfactor": 1,
|
|
39
|
+
"interptype": "univariate",
|
|
40
|
+
"debug": False,
|
|
41
|
+
}
|
|
42
|
+
options.update(kwargs)
|
|
43
|
+
oversampfactor = options["oversampfactor"]
|
|
44
|
+
interptype = options["interptype"]
|
|
45
|
+
debug = options["debug"]
|
|
46
|
+
if debug:
|
|
47
|
+
print(f"{oversampfactor=} {interptype=}")
|
|
48
|
+
(thetc, theCorrelator, fmri_x, fmritc, os_fmri_x, theglobalmaxlist, thexcorr_y) = voxelargs
|
|
45
49
|
if oversampfactor >= 1:
|
|
46
50
|
thetc[:] = tide_resample.doresample(fmri_x, fmritc, os_fmri_x, method=interptype)
|
|
47
51
|
else:
|
|
48
52
|
thetc[:] = fmritc
|
|
49
53
|
thexcorr_y, thexcorr_x, theglobalmax = theCorrelator.run(thetc)
|
|
54
|
+
# print(f"_procOneVoxelCorrelation: {thexcorr_x=}")
|
|
55
|
+
|
|
56
|
+
return vox, np.mean(thetc), thexcorr_y, thexcorr_x, theglobalmax, theglobalmaxlist
|
|
50
57
|
|
|
51
|
-
|
|
58
|
+
|
|
59
|
+
def _packvoxeldata(voxnum, voxelargs):
|
|
60
|
+
return [
|
|
61
|
+
voxelargs[0],
|
|
62
|
+
voxelargs[1],
|
|
63
|
+
voxelargs[2],
|
|
64
|
+
(voxelargs[3])[voxnum, :],
|
|
65
|
+
voxelargs[4],
|
|
66
|
+
voxelargs[5],
|
|
67
|
+
voxelargs[6],
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _unpackvoxeldata(retvals, voxelproducts):
|
|
72
|
+
(voxelproducts[0])[retvals[0]] = retvals[1]
|
|
73
|
+
(voxelproducts[1])[retvals[0], :] = retvals[2]
|
|
74
|
+
voxelproducts[2] = retvals[3]
|
|
75
|
+
(voxelproducts[3]).append(retvals[4] + 0)
|
|
52
76
|
|
|
53
77
|
|
|
54
78
|
def correlationpass(
|
|
@@ -101,87 +125,45 @@ def correlationpass(
|
|
|
101
125
|
print(f"calling setreftc in calcsimfunc with length {len(referencetc)}")
|
|
102
126
|
theCorrelator.setreftc(referencetc)
|
|
103
127
|
theCorrelator.setlimits(lagmininpts, lagmaxinpts)
|
|
104
|
-
|
|
105
|
-
inputshape = np.shape(fmridata)
|
|
106
|
-
volumetotal = 0
|
|
107
128
|
thetc = np.zeros(np.shape(os_fmri_x), dtype=rt_floattype)
|
|
108
129
|
theglobalmaxlist = []
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
showprogressbar=showprogressbar,
|
|
147
|
-
chunksize=chunksize,
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
# unpack the data
|
|
151
|
-
volumetotal = 0
|
|
152
|
-
for voxel in data_out:
|
|
153
|
-
meanval[voxel[0]] = voxel[1]
|
|
154
|
-
corrout[voxel[0], :] = voxel[2]
|
|
155
|
-
thecorrscale = voxel[3]
|
|
156
|
-
theglobalmaxlist.append(voxel[4] + 0)
|
|
157
|
-
volumetotal += 1
|
|
158
|
-
del data_out
|
|
159
|
-
else:
|
|
160
|
-
for vox in tqdm(
|
|
161
|
-
range(0, inputshape[0]),
|
|
162
|
-
desc="Voxel",
|
|
163
|
-
disable=(not showprogressbar),
|
|
164
|
-
):
|
|
165
|
-
(
|
|
166
|
-
dummy,
|
|
167
|
-
meanval[vox],
|
|
168
|
-
corrout[vox, :],
|
|
169
|
-
thecorrscale,
|
|
170
|
-
theglobalmax,
|
|
171
|
-
) = _procOneVoxelCorrelation(
|
|
172
|
-
vox,
|
|
173
|
-
thetc,
|
|
174
|
-
theCorrelator,
|
|
175
|
-
fmri_x,
|
|
176
|
-
fmridata[vox, :],
|
|
177
|
-
os_fmri_x,
|
|
178
|
-
oversampfactor=oversampfactor,
|
|
179
|
-
interptype=interptype,
|
|
180
|
-
rt_floatset=rt_floatset,
|
|
181
|
-
rt_floattype=rt_floattype,
|
|
182
|
-
)
|
|
183
|
-
theglobalmaxlist.append(theglobalmax + 0)
|
|
184
|
-
volumetotal += 1
|
|
130
|
+
|
|
131
|
+
# generate a corrscale of the correct length
|
|
132
|
+
dummy = np.zeros(100, dtype=rt_floattype)
|
|
133
|
+
dummy, dummy, dummy, thecorrscale, dummy, dummy = _procOneVoxelCorrelation(
|
|
134
|
+
0,
|
|
135
|
+
_packvoxeldata(
|
|
136
|
+
0, [thetc, theCorrelator, fmri_x, fmridata, os_fmri_x, theglobalmaxlist, dummy]
|
|
137
|
+
),
|
|
138
|
+
oversampfactor=oversampfactor,
|
|
139
|
+
interptype=interptype,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
inputshape = np.shape(fmridata)
|
|
143
|
+
voxelargs = [thetc, theCorrelator, fmri_x, fmridata, os_fmri_x, theglobalmaxlist, thecorrscale]
|
|
144
|
+
voxelfunc = _procOneVoxelCorrelation
|
|
145
|
+
packfunc = _packvoxeldata
|
|
146
|
+
unpackfunc = _unpackvoxeldata
|
|
147
|
+
voxeltargets = [meanval, corrout, thecorrscale, theglobalmaxlist]
|
|
148
|
+
voxelmask = fmridata[:, 0] * 0.0 + 1
|
|
149
|
+
|
|
150
|
+
volumetotal = tide_genericmultiproc.run_multiproc(
|
|
151
|
+
voxelfunc,
|
|
152
|
+
packfunc,
|
|
153
|
+
unpackfunc,
|
|
154
|
+
voxelargs,
|
|
155
|
+
voxeltargets,
|
|
156
|
+
inputshape,
|
|
157
|
+
voxelmask,
|
|
158
|
+
LGR,
|
|
159
|
+
nprocs,
|
|
160
|
+
alwaysmultiproc,
|
|
161
|
+
showprogressbar,
|
|
162
|
+
chunksize,
|
|
163
|
+
oversampfactor=oversampfactor,
|
|
164
|
+
interptype=interptype,
|
|
165
|
+
debug=debug,
|
|
166
|
+
)
|
|
185
167
|
LGR.info(f"\nSimilarity function calculated on {volumetotal} voxels")
|
|
186
168
|
|
|
187
169
|
# garbage collect
|
|
@@ -21,3 +21,25 @@ atlasaverage \
|
|
|
21
21
|
--extramask /opt/fsl-latest/data/standard/MNI152_T1_1mm_brain_mask.nii.gz \
|
|
22
22
|
--summarymethod median \
|
|
23
23
|
--headerline
|
|
24
|
+
|
|
25
|
+
atlasaverage \
|
|
26
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
27
|
+
sub-RAPIDTIDETEST_dseg.nii.gz \
|
|
28
|
+
../dst/synthsegaverages \
|
|
29
|
+
--ignorezeros \
|
|
30
|
+
--numpercentiles 3 \
|
|
31
|
+
--includemask sub-RAPIDTIDETEST_brainmask.nii.gz \
|
|
32
|
+
--regionlabelfile dseglabels.txt \
|
|
33
|
+
--summarymethod mean
|
|
34
|
+
|
|
35
|
+
atlasaverage \
|
|
36
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
37
|
+
sub-RAPIDTIDETEST_dseg.nii.gz \
|
|
38
|
+
../dst/synthsegaverages_pctnorm \
|
|
39
|
+
--normmethod pct \
|
|
40
|
+
--ignorezeros \
|
|
41
|
+
--numpercentiles 3 \
|
|
42
|
+
--includemask sub-RAPIDTIDETEST_brainmask.nii.gz \
|
|
43
|
+
--regionlabelfile dseglabels.txt \
|
|
44
|
+
--summarymethod mean
|
|
45
|
+
|
|
@@ -6,10 +6,10 @@ rapidtide \
|
|
|
6
6
|
--searchrange -5 20 \
|
|
7
7
|
--simcalcrange 50 -1 \
|
|
8
8
|
--outputlevel more \
|
|
9
|
-
--dofinalrefine \
|
|
10
9
|
--graymattermask sub-RAPIDTIDETEST_synthseg.nii.gz:SSEG_GRAY \
|
|
11
10
|
--brainmask sub-RAPIDTIDETEST_brainmask.nii.gz \
|
|
12
11
|
--whitemattermask sub-RAPIDTIDETEST_synthseg.nii.gz:SSEG_WHITE \
|
|
13
12
|
--csfmask sub-RAPIDTIDETEST_synthseg.nii.gz:SSEG_CSF \
|
|
13
|
+
--cleanrefined \
|
|
14
14
|
sub-RAPIDTIDETEST.nii.gz \
|
|
15
15
|
../dst/sub-RAPIDTIDETEST
|
|
@@ -65,13 +65,14 @@
|
|
|
65
65
|
happy \
|
|
66
66
|
sub-HAPPYTEST.nii.gz \
|
|
67
67
|
sub-HAPPYTEST.json \
|
|
68
|
-
../dst/happy
|
|
68
|
+
../dst/happy \
|
|
69
|
+
--nprocs -1
|
|
69
70
|
|
|
70
|
-
happy \
|
|
71
|
-
sub-HAPPYTEST.nii.gz \
|
|
72
|
-
sub-HAPPYTEST.json \
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
#happy \
|
|
72
|
+
#sub-HAPPYTEST.nii.gz \
|
|
73
|
+
#sub-HAPPYTEST.json \
|
|
74
|
+
#--model ~/code/rapidtide/rapidtide/data/models/model_cnn_w064_l13_fn20_fl08 \
|
|
75
|
+
#../dst/happy_newcnn
|
|
75
76
|
|
|
76
77
|
#happy \
|
|
77
78
|
#sub-HAPPYTEST.nii.gz \
|