rapidtide 3.0a11__py3-none-any.whl → 3.0a13__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 +211 -0
- rapidtide/RegressorRefiner.py +464 -0
- 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 +13 -0
- rapidtide/data/examples/src/testfmri +3 -124
- rapidtide/data/examples/src/testglmfilt +8 -6
- rapidtide/data/examples/src/testhappy +1 -1
- rapidtide/data/examples/src/testinitdelay +19 -0
- rapidtide/data/examples/src/testnewrefine +49 -0
- rapidtide/data/examples/src/testnoiseamp +2 -2
- rapidtide/data/examples/src/testrefineonly +22 -0
- 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} +29 -20
- rapidtide/refinedelay.py +133 -55
- rapidtide/refineregressor.py +38 -24
- 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 +1 -1
- rapidtide/tests/test_fullrunhappy_v2.py +1 -1
- rapidtide/tests/test_fullrunrapidtide_v1.py +2 -2
- rapidtide/tests/test_fullrunrapidtide_v3.py +1 -1
- rapidtide/tests/test_fullrunrapidtide_v5.py +1 -1
- rapidtide/tests/test_fullrunrapidtide_v6.py +11 -11
- rapidtide/tests/{test_glmpass.py → test_linfitfiltpass.py} +9 -9
- rapidtide/tests/test_motionregress.py +3 -3
- rapidtide/tests/test_refinedelay.py +12 -12
- rapidtide/tidepoolTemplate.py +1 -0
- rapidtide/tidepoolTemplate.ui +1 -0
- rapidtide/tidepoolTemplate_alt.py +5 -4
- rapidtide/tidepoolTemplate_alt.ui +3 -2
- rapidtide/tidepoolTemplate_alt_qt6.py +177 -49
- rapidtide/tidepoolTemplate_big.py +1 -0
- rapidtide/tidepoolTemplate_big.ui +1 -0
- rapidtide/tidepoolTemplate_big_qt6.py +197 -53
- rapidtide/tidepoolTemplate_qt6.py +151 -39
- rapidtide/workflows/delayvar.py +1048 -0
- rapidtide/workflows/happy.py +37 -11
- rapidtide/workflows/happy_parser.py +4 -4
- rapidtide/workflows/{glmfilt.py → linfitfilt.py} +4 -4
- rapidtide/workflows/parser_funcs.py +10 -2
- rapidtide/workflows/rapidtide.py +388 -452
- rapidtide/workflows/rapidtide_parser.py +129 -90
- rapidtide/workflows/{glmfrommaps.py → regressfrommaps.py} +28 -26
- rapidtide/workflows/retrolagtcs.py +12 -12
- rapidtide/workflows/{retroglm.py → retroregress.py} +243 -141
- rapidtide/workflows/tidepool.py +2 -2
- {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/METADATA +3 -2
- {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/RECORD +72 -63
- {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/WHEEL +1 -1
- {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/entry_points.txt +3 -2
- rapidtide/data/examples/src/testoutputsize +0 -45
- {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info/licenses}/LICENSE +0 -0
- {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/top_level.txt +0 -0
|
@@ -1,132 +1,11 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
#rapidtide \
|
|
4
|
-
# --spatialfilt 2 \
|
|
5
|
-
# --nprocs -1 \
|
|
6
|
-
# --simcalcrange 50 -1 \
|
|
7
|
-
# --outputlevel max \
|
|
8
|
-
# --glmderivs 1 \
|
|
9
|
-
# sub-RAPIDTIDETEST.nii.gz \
|
|
10
|
-
# ../dst/sub-RAPIDTIDETEST_norefine
|
|
11
|
-
|
|
12
3
|
rapidtide \
|
|
13
4
|
--spatialfilt -1 \
|
|
5
|
+
--delayoffsetspatialfilt -1 \
|
|
14
6
|
--nprocs -1 \
|
|
15
7
|
--searchrange -5 20 \
|
|
16
8
|
--simcalcrange 50 -1 \
|
|
9
|
+
--outputlevel max \
|
|
17
10
|
sub-RAPIDTIDETEST.nii.gz \
|
|
18
|
-
../dst/sub-
|
|
19
|
-
|
|
20
|
-
rapidtide \
|
|
21
|
-
--spatialfilt 5 \
|
|
22
|
-
--nprocs -1 \
|
|
23
|
-
--searchrange -5 20 \
|
|
24
|
-
--simcalcrange 50 -1 \
|
|
25
|
-
sub-RAPIDTIDETEST.nii.gz \
|
|
26
|
-
../dst/sub-RAPIDTIDETEST_5mmfilt
|
|
27
|
-
|
|
28
|
-
rapidtide \
|
|
29
|
-
--spatialfilt 0 \
|
|
30
|
-
--nprocs -1 \
|
|
31
|
-
--searchrange -5 20 \
|
|
32
|
-
--simcalcrange 50 -1 \
|
|
33
|
-
sub-RAPIDTIDETEST.nii.gz \
|
|
34
|
-
../dst/sub-RAPIDTIDETEST_nospatialfilt
|
|
35
|
-
|
|
36
|
-
#rapidtide \
|
|
37
|
-
# --spatialfilt 5 \
|
|
38
|
-
# --nprocs -1 \
|
|
39
|
-
# --simcalcrange 50 -1 \
|
|
40
|
-
# --outputlevel max \
|
|
41
|
-
# --refinedelay \
|
|
42
|
-
# sub-RAPIDTIDETEST.nii.gz \
|
|
43
|
-
# ../dst/sub-RAPIDTIDETEST_corr
|
|
44
|
-
|
|
45
|
-
#rapidtide \
|
|
46
|
-
# --spatialfilt 2 \
|
|
47
|
-
# --nprocs -1 \
|
|
48
|
-
# --passes 50 \
|
|
49
|
-
# --despecklepasses 50 \
|
|
50
|
-
# --simcalcrange 50 -1 \
|
|
51
|
-
# --outputlevel max \
|
|
52
|
-
# sub-RAPIDTIDETEST.nii.gz \
|
|
53
|
-
# ../dst/sub-RAPIDTIDETEST_spec
|
|
54
|
-
#
|
|
55
|
-
#rapidtide \
|
|
56
|
-
# --spatialfilt 2 \
|
|
57
|
-
# --nprocs -1 \
|
|
58
|
-
# --denoising \
|
|
59
|
-
# --passes 4 \
|
|
60
|
-
# --despecklepasses 5 \
|
|
61
|
-
# --simcalcrange 50 -1 \
|
|
62
|
-
# --outputlevel max \
|
|
63
|
-
# sub-RAPIDTIDETEST.nii.gz \
|
|
64
|
-
# ../dst/sub-RAPIDTIDETEST_denoisingspec
|
|
65
|
-
#
|
|
66
|
-
#rapidtide \
|
|
67
|
-
# --spatialfilt 2 \
|
|
68
|
-
# --nprocs -1 \
|
|
69
|
-
# --denoising \
|
|
70
|
-
# --simcalcrange 50 -1 \
|
|
71
|
-
# --outputlevel max \
|
|
72
|
-
# sub-RAPIDTIDETEST.nii.gz \
|
|
73
|
-
# ../dst/sub-RAPIDTIDETEST_denoisingnospec
|
|
74
|
-
#rapidtide \
|
|
75
|
-
#--spatialfilt 2 \
|
|
76
|
-
#--nprocs -1 \
|
|
77
|
-
#--passes 3 \
|
|
78
|
-
#--simcalcrange 50 -1 \
|
|
79
|
-
#--padtype constant \
|
|
80
|
-
#--outputlevel max \
|
|
81
|
-
#sub-RAPIDTIDETEST.nii.gz \
|
|
82
|
-
#../dst/sub-RAPIDTIDETEST_constantpad
|
|
83
|
-
|
|
84
|
-
#rapidtide \
|
|
85
|
-
# --spatialfilt 2 \
|
|
86
|
-
# --nprocs -1 \
|
|
87
|
-
# --passes 3 \
|
|
88
|
-
# --simcalcrange 50 -1 \
|
|
89
|
-
# --memprofile \
|
|
90
|
-
# sub-RAPIDTIDETEST.nii.gz \
|
|
91
|
-
# ../dst/sub-RAPIDTIDETEST_memprofile
|
|
92
|
-
|
|
93
|
-
#rapidtide \
|
|
94
|
-
#--spatialfilt 2 \
|
|
95
|
-
#--nprocs -1 \
|
|
96
|
-
#--passes 3 \
|
|
97
|
-
#--simcalcrange 50 -1 \
|
|
98
|
-
#--texcludemask tmask3_exclude.txt \
|
|
99
|
-
#sub-RAPIDTIDETEST.nii.gz \
|
|
100
|
-
#../dst/sub-RAPIDTIDETEST_excludemask
|
|
101
|
-
#
|
|
102
|
-
#rapidtide \
|
|
103
|
-
#--spatialfilt 2 \
|
|
104
|
-
#--nprocs -1 \
|
|
105
|
-
#--passes 3 \
|
|
106
|
-
#--simcalcrange 50 -1 \
|
|
107
|
-
#--tincludemask tmask3.txt \
|
|
108
|
-
#--texcludemask tmask3_exclude.txt \
|
|
109
|
-
#sub-RAPIDTIDETEST.nii.gz \
|
|
110
|
-
#../dst/sub-RAPIDTIDETEST_bothmasks
|
|
111
|
-
|
|
112
|
-
#for FILT in 1 2 4 8 16
|
|
113
|
-
#do
|
|
114
|
-
# rapidtide \
|
|
115
|
-
# --spatialfilt ${FILT} \
|
|
116
|
-
# --nprocs -1 \
|
|
117
|
-
# --passes 3 \
|
|
118
|
-
# --simcalcrange 50 -1 \
|
|
119
|
-
# --outputlevel min \
|
|
120
|
-
# sub-RAPIDTIDETEST.nii.gz \
|
|
121
|
-
# ../dst/sub-RAPIDTIDETEST_${FILT}
|
|
122
|
-
#done
|
|
123
|
-
#
|
|
124
|
-
#for MAP in maxtime maxcorr
|
|
125
|
-
#do
|
|
126
|
-
# fslmerge -t ../dst/all_${MAP} \
|
|
127
|
-
# ../dst/sub-RAPIDTIDETEST_1_desc-${MAP}_map.nii.gz \
|
|
128
|
-
# ../dst/sub-RAPIDTIDETEST_2_desc-${MAP}_map.nii.gz \
|
|
129
|
-
# ../dst/sub-RAPIDTIDETEST_4_desc-${MAP}_map.nii.gz \
|
|
130
|
-
# ../dst/sub-RAPIDTIDETEST_8_desc-${MAP}_map.nii.gz \
|
|
131
|
-
# ../dst/sub-RAPIDTIDETEST_16_desc-${MAP}_map.nii.gz
|
|
132
|
-
#done
|
|
11
|
+
../dst/sub-RAPIDTIDETEST
|
|
@@ -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
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
rapidtide \
|
|
4
|
+
--spatialfilt -1 \
|
|
5
|
+
--nprocs -1 \
|
|
6
|
+
--searchrange -5 20 \
|
|
7
|
+
--simcalcrange 50 -1 \
|
|
8
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
9
|
+
../dst/sub-RAPIDTIDETEST_defaultfilt
|
|
10
|
+
|
|
11
|
+
rapidtide \
|
|
12
|
+
--spatialfilt -1 \
|
|
13
|
+
--nprocs -1 \
|
|
14
|
+
--searchrange -5 20 \
|
|
15
|
+
--simcalcrange 50 -1 \
|
|
16
|
+
--regressor ../dst/sub-RAPIDTIDETEST_defaultfilt_desc-movingregressor_timeseries.json:pass3 \
|
|
17
|
+
--initialdelay ../dst/sub-RAPIDTIDETEST_defaultfilt_desc-maxtimerefined_map.nii.gz \
|
|
18
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
19
|
+
../dst/sub-RAPIDTIDETEST_startfromlast
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
rapidtide \
|
|
4
|
+
--spatialfilt -1 \
|
|
5
|
+
--nprocs -1 \
|
|
6
|
+
--searchrange -5 20 \
|
|
7
|
+
--simcalcrange 50 -1 \
|
|
8
|
+
--outputlevel max \
|
|
9
|
+
--refineregressderivs 1 \
|
|
10
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
11
|
+
../dst/sub-RAPIDTIDETEST_1deriv
|
|
12
|
+
|
|
13
|
+
rapidtide \
|
|
14
|
+
--spatialfilt -1 \
|
|
15
|
+
--nprocs -1 \
|
|
16
|
+
--searchrange -5 20 \
|
|
17
|
+
--simcalcrange 50 -1 \
|
|
18
|
+
--outputlevel max \
|
|
19
|
+
--refineregressderivs 2 \
|
|
20
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
21
|
+
../dst/sub-RAPIDTIDETEST_2deriv
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
retroregress \
|
|
25
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
26
|
+
../dst/sub-RAPIDTIDETEST_1deriv \
|
|
27
|
+
--alternateoutput ../dst/retrotest_1to1 \
|
|
28
|
+
--nprocs -1 \
|
|
29
|
+
--regressderivs 0 \
|
|
30
|
+
--refineregressderivs 1 \
|
|
31
|
+
--outputlevel max
|
|
32
|
+
|
|
33
|
+
retroregress \
|
|
34
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
35
|
+
../dst/sub-RAPIDTIDETEST_2deriv \
|
|
36
|
+
--alternateoutput ../dst/retrotest_2to1 \
|
|
37
|
+
--nprocs -1 \
|
|
38
|
+
--regressderivs 0 \
|
|
39
|
+
--refineregressderivs 1 \
|
|
40
|
+
--outputlevel max
|
|
41
|
+
|
|
42
|
+
retroregress \
|
|
43
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
44
|
+
../dst/sub-RAPIDTIDETEST_1deriv \
|
|
45
|
+
--alternateoutput ../dst/retrotest_1to2 \
|
|
46
|
+
--nprocs -1 \
|
|
47
|
+
--regressderivs 0 \
|
|
48
|
+
--refineregressderivs 2 \
|
|
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")
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
rapidtide \
|
|
4
|
+
--spatialfilt -1 \
|
|
5
|
+
--nprocs -1 \
|
|
6
|
+
--passes 1 \
|
|
7
|
+
--nodelayfit \
|
|
8
|
+
--focaldebug \
|
|
9
|
+
--dofinalrefine \
|
|
10
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
11
|
+
../dst/sub-RAPIDTIDETEST_firstpass
|
|
12
|
+
|
|
13
|
+
rapidtide \
|
|
14
|
+
--spatialfilt -1 \
|
|
15
|
+
--nprocs -1 \
|
|
16
|
+
--nodelayfit \
|
|
17
|
+
--regressor ../dst/sub-RAPIDTIDETEST_firstpass_desc-refinedmovingregressor_timeseries.json:filtered_pass1 \
|
|
18
|
+
--initialdelay ../dst/sub-RAPIDTIDETEST_firstpass_desc-maxtimerefined_map.nii.gz \
|
|
19
|
+
--dofinalrefine \
|
|
20
|
+
--passes 1 \
|
|
21
|
+
sub-RAPIDTIDETEST.nii.gz \
|
|
22
|
+
../dst/sub-RAPIDTIDETEST_secondpass
|
|
@@ -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
|
|
rapidtide/dlfilter.py
CHANGED
rapidtide/fit.py
CHANGED
|
@@ -23,6 +23,7 @@ import matplotlib.pyplot as plt
|
|
|
23
23
|
import numpy as np
|
|
24
24
|
import scipy as sp
|
|
25
25
|
import scipy.special as sps
|
|
26
|
+
import statsmodels.api as sm
|
|
26
27
|
import tqdm
|
|
27
28
|
from numpy.polynomial import Polynomial
|
|
28
29
|
from scipy.optimize import curve_fit
|
|
@@ -1105,6 +1106,37 @@ def mlproject(thefit, theevs, intercept):
|
|
|
1105
1106
|
return thedest
|
|
1106
1107
|
|
|
1107
1108
|
|
|
1109
|
+
def olsregress(X, y, intercept=True, debug=False):
|
|
1110
|
+
"""
|
|
1111
|
+
|
|
1112
|
+
Parameters
|
|
1113
|
+
----------
|
|
1114
|
+
X
|
|
1115
|
+
y
|
|
1116
|
+
intercept
|
|
1117
|
+
|
|
1118
|
+
Returns
|
|
1119
|
+
-------
|
|
1120
|
+
|
|
1121
|
+
"""
|
|
1122
|
+
"""Return the coefficients from a multiple linear regression, along with R, the coefficient of determination.
|
|
1123
|
+
|
|
1124
|
+
X: The independent variables (nxp).
|
|
1125
|
+
y: The dependent variable (1xn or nx1).
|
|
1126
|
+
intercept: Specifies whether or not the slope intercept should be considered.
|
|
1127
|
+
|
|
1128
|
+
The routine computes the coefficients (b_0, b_1, ..., b_p) from the data (x,y) under
|
|
1129
|
+
the assumption that y = b0 + b_1 * x_1 + b_2 * x_2 + ... + b_p * x_p.
|
|
1130
|
+
|
|
1131
|
+
If intercept is False, the routine assumes that b0 = 0 and returns (b_1, b_2, ..., b_p).
|
|
1132
|
+
"""
|
|
1133
|
+
if intercept:
|
|
1134
|
+
X = sm.add_constant(X, prepend=True)
|
|
1135
|
+
model = sm.OLS(y, exog=X)
|
|
1136
|
+
thefit = model.fit()
|
|
1137
|
+
return thefit.params, np.sqrt(thefit.rsquared)
|
|
1138
|
+
|
|
1139
|
+
|
|
1108
1140
|
def mlregress(X, y, intercept=True, debug=False):
|
|
1109
1141
|
"""
|
|
1110
1142
|
|
|
@@ -1223,9 +1255,9 @@ def calcexpandedregressors(
|
|
|
1223
1255
|
return outputregressors, outlabels
|
|
1224
1256
|
|
|
1225
1257
|
|
|
1226
|
-
def
|
|
1258
|
+
def derivativelinfitfilt(thedata, theevs, nderivs=1, debug=False):
|
|
1227
1259
|
r"""First perform multicomponent expansion on theevs (each ev replaced by itself,
|
|
1228
|
-
its square, its cube, etc.). Then perform a
|
|
1260
|
+
its square, its cube, etc.). Then perform a linear fit of thedata using the vectors
|
|
1229
1261
|
in thenewevs and return the result.
|
|
1230
1262
|
|
|
1231
1263
|
Parameters
|
|
@@ -1269,16 +1301,16 @@ def derivativeglmfilt(thedata, theevs, nderivs=1, debug=False):
|
|
|
1269
1301
|
if debug:
|
|
1270
1302
|
print(f"{nderivs=}")
|
|
1271
1303
|
print(f"{thenewevs.shape=}")
|
|
1272
|
-
filtered, datatoremove, R, coffs =
|
|
1304
|
+
filtered, datatoremove, R, coffs = linfitfilt(thedata, thenewevs, debug=debug)
|
|
1273
1305
|
if debug:
|
|
1274
1306
|
print(f"{R=}")
|
|
1275
1307
|
|
|
1276
1308
|
return filtered, thenewevs, datatoremove, R, coffs
|
|
1277
1309
|
|
|
1278
1310
|
|
|
1279
|
-
def
|
|
1311
|
+
def expandedlinfitfilt(thedata, theevs, ncomps=1, debug=False):
|
|
1280
1312
|
r"""First perform multicomponent expansion on theevs (each ev replaced by itself,
|
|
1281
|
-
its square, its cube, etc.). Then perform a
|
|
1313
|
+
its square, its cube, etc.). Then perform a multiple regression fit of thedata using the vectors
|
|
1282
1314
|
in thenewevs and return the result.
|
|
1283
1315
|
|
|
1284
1316
|
Parameters
|
|
@@ -1322,15 +1354,15 @@ def expandedglmfilt(thedata, theevs, ncomps=1, debug=False):
|
|
|
1322
1354
|
if debug:
|
|
1323
1355
|
print(f"{ncomps=}")
|
|
1324
1356
|
print(f"{thenewevs.shape=}")
|
|
1325
|
-
filtered, datatoremove, R, coffs =
|
|
1357
|
+
filtered, datatoremove, R, coffs = linfitfilt(thedata, thenewevs, debug=debug)
|
|
1326
1358
|
if debug:
|
|
1327
1359
|
print(f"{R=}")
|
|
1328
1360
|
|
|
1329
1361
|
return filtered, thenewevs, datatoremove, R, coffs
|
|
1330
1362
|
|
|
1331
1363
|
|
|
1332
|
-
def
|
|
1333
|
-
r"""Performs a
|
|
1364
|
+
def linfitfilt(thedata, theevs, returnintercept=False, debug=False):
|
|
1365
|
+
r"""Performs a multiple regression fit of thedata using the vectors in theevs
|
|
1334
1366
|
and returns the result.
|
|
1335
1367
|
|
|
1336
1368
|
Parameters
|
|
@@ -1383,7 +1415,7 @@ def glmfilt(thedata, theevs, returnintercept=False, debug=False):
|
|
|
1383
1415
|
return filtered, datatoremove, R2, retcoffs
|
|
1384
1416
|
|
|
1385
1417
|
|
|
1386
|
-
def
|
|
1418
|
+
def confoundregress(
|
|
1387
1419
|
data,
|
|
1388
1420
|
regressors,
|
|
1389
1421
|
debug=False,
|
rapidtide/happy_supportfuncs.py
CHANGED
|
@@ -290,6 +290,11 @@ def cardiacfromimage(
|
|
|
290
290
|
)
|
|
291
291
|
|
|
292
292
|
|
|
293
|
+
def theCOM(X, data):
|
|
294
|
+
# return the center of mass
|
|
295
|
+
return np.sum(X * data) / np.sum(data)
|
|
296
|
+
|
|
297
|
+
|
|
293
298
|
def savgolsmooth(data, smoothlen=101, polyorder=3):
|
|
294
299
|
return savgol_filter(data, smoothlen, polyorder)
|
|
295
300
|
|
rapidtide/io.py
CHANGED
|
@@ -1426,6 +1426,8 @@ def writebidstsv(
|
|
|
1426
1426
|
extraheaderinfo=None,
|
|
1427
1427
|
compressed=True,
|
|
1428
1428
|
columns=None,
|
|
1429
|
+
xaxislabel="time",
|
|
1430
|
+
yaxislabel="arbitrary value",
|
|
1429
1431
|
starttime=0.0,
|
|
1430
1432
|
append=False,
|
|
1431
1433
|
colsinjson=True,
|
|
@@ -1447,6 +1449,8 @@ def writebidstsv(
|
|
|
1447
1449
|
:param samplerate:
|
|
1448
1450
|
:param compressed:
|
|
1449
1451
|
:param columns:
|
|
1452
|
+
:param xaxislabel:
|
|
1453
|
+
:param yaxislabel:
|
|
1450
1454
|
:param starttime:
|
|
1451
1455
|
:param append:
|
|
1452
1456
|
:param colsinjson:
|
|
@@ -1462,6 +1466,8 @@ def writebidstsv(
|
|
|
1462
1466
|
print("\tsamplerate:", samplerate)
|
|
1463
1467
|
print("\tcompressed:", compressed)
|
|
1464
1468
|
print("\tcolumns:", columns)
|
|
1469
|
+
print("\txaxislabel:", xaxislabel)
|
|
1470
|
+
print("\tyaxislabel:", yaxislabel)
|
|
1465
1471
|
print("\tstarttime:", starttime)
|
|
1466
1472
|
print("\tappend:", append)
|
|
1467
1473
|
if len(data.shape) == 1:
|
|
@@ -1538,6 +1544,8 @@ def writebidstsv(
|
|
|
1538
1544
|
headerdict = {}
|
|
1539
1545
|
headerdict["SamplingFrequency"] = float(samplerate)
|
|
1540
1546
|
headerdict["StartTime"] = float(starttime)
|
|
1547
|
+
headerdict["XAxisLabel"] = xaxislabel
|
|
1548
|
+
headerdict["YAxisLabel"] = yaxislabel
|
|
1541
1549
|
if colsinjson:
|
|
1542
1550
|
if startcol == 0:
|
|
1543
1551
|
headerdict["Columns"] = columns
|
|
@@ -1991,8 +1999,11 @@ def colspectolist(colspec, debug=False):
|
|
|
1991
1999
|
("APARC_SUBCORTGRAY", "8-13,17-20,26-28,47-56,58-60,96,97"),
|
|
1992
2000
|
("APARC_CORTGRAY", "1000-1035,2000-2035"),
|
|
1993
2001
|
("APARC_GRAY", "8-13,17-20,26-28,47-56,58-60,96,97,1000-1035,2000-2035"),
|
|
1994
|
-
("APARC_WHITE", "2,7,41,46,177,219"),
|
|
1995
|
-
(
|
|
2002
|
+
("APARC_WHITE", "2,7,41,46,177,219,3000-3035,4000-4035,5001,5002"),
|
|
2003
|
+
(
|
|
2004
|
+
"APARC_ALLBUTCSF",
|
|
2005
|
+
"2,7-13,17-20,26-28,41,46-56,58-60,96,97,177,219,1000-1035,2000-2035,3000-3035,4000-4035,5001,5002",
|
|
2006
|
+
),
|
|
1996
2007
|
("SSEG_GRAY", "3,8,10-13,16-18,26,42,47,49-54,58"),
|
|
1997
2008
|
("SSEG_WHITE", "2,7,41,46"),
|
|
1998
2009
|
)
|