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.
Files changed (73) hide show
  1. cloud/gmscalc-HCPYA +1 -1
  2. cloud/rapidtide-HCPYA +3 -3
  3. rapidtide/Colortables.py +10 -10
  4. rapidtide/DerivativeDelay.py +211 -0
  5. rapidtide/RegressorRefiner.py +464 -0
  6. rapidtide/__init__.py +2 -1
  7. rapidtide/_version.py +1 -1
  8. rapidtide/data/examples/src/test_mlregressallt.py +32 -17
  9. rapidtide/data/examples/src/testalign +1 -1
  10. rapidtide/data/examples/src/testboth +1 -1
  11. rapidtide/data/examples/src/testcifti +11 -0
  12. rapidtide/data/examples/src/testdelayvar +13 -0
  13. rapidtide/data/examples/src/testfmri +3 -124
  14. rapidtide/data/examples/src/testglmfilt +8 -6
  15. rapidtide/data/examples/src/testhappy +1 -1
  16. rapidtide/data/examples/src/testinitdelay +19 -0
  17. rapidtide/data/examples/src/testnewrefine +49 -0
  18. rapidtide/data/examples/src/testnoiseamp +2 -2
  19. rapidtide/data/examples/src/testrefineonly +22 -0
  20. rapidtide/data/examples/src/testretro +16 -7
  21. rapidtide/data/examples/src/testretrolagtcs +1 -1
  22. rapidtide/dlfilter.py +0 -1
  23. rapidtide/fit.py +41 -9
  24. rapidtide/happy_supportfuncs.py +5 -0
  25. rapidtide/io.py +13 -2
  26. rapidtide/{glmpass.py → linfitfiltpass.py} +29 -20
  27. rapidtide/refinedelay.py +133 -55
  28. rapidtide/refineregressor.py +38 -24
  29. rapidtide/resample.py +3 -0
  30. rapidtide/scripts/{retroglm.py → delayvar.py} +2 -2
  31. rapidtide/scripts/{glmfilt.py → linfitfilt.py} +2 -2
  32. rapidtide/scripts/retroregress.py +28 -0
  33. rapidtide/scripts/stupidramtricks.py +9 -7
  34. rapidtide/simfuncfit.py +1 -1
  35. rapidtide/tests/cleanposttest +21 -0
  36. rapidtide/tests/test_delayestimation.py +3 -3
  37. rapidtide/tests/test_fastresampler.py +1 -2
  38. rapidtide/tests/test_fullrunhappy_v1.py +1 -1
  39. rapidtide/tests/test_fullrunhappy_v2.py +1 -1
  40. rapidtide/tests/test_fullrunrapidtide_v1.py +2 -2
  41. rapidtide/tests/test_fullrunrapidtide_v3.py +1 -1
  42. rapidtide/tests/test_fullrunrapidtide_v5.py +1 -1
  43. rapidtide/tests/test_fullrunrapidtide_v6.py +11 -11
  44. rapidtide/tests/{test_glmpass.py → test_linfitfiltpass.py} +9 -9
  45. rapidtide/tests/test_motionregress.py +3 -3
  46. rapidtide/tests/test_refinedelay.py +12 -12
  47. rapidtide/tidepoolTemplate.py +1 -0
  48. rapidtide/tidepoolTemplate.ui +1 -0
  49. rapidtide/tidepoolTemplate_alt.py +5 -4
  50. rapidtide/tidepoolTemplate_alt.ui +3 -2
  51. rapidtide/tidepoolTemplate_alt_qt6.py +177 -49
  52. rapidtide/tidepoolTemplate_big.py +1 -0
  53. rapidtide/tidepoolTemplate_big.ui +1 -0
  54. rapidtide/tidepoolTemplate_big_qt6.py +197 -53
  55. rapidtide/tidepoolTemplate_qt6.py +151 -39
  56. rapidtide/workflows/delayvar.py +1048 -0
  57. rapidtide/workflows/happy.py +37 -11
  58. rapidtide/workflows/happy_parser.py +4 -4
  59. rapidtide/workflows/{glmfilt.py → linfitfilt.py} +4 -4
  60. rapidtide/workflows/parser_funcs.py +10 -2
  61. rapidtide/workflows/rapidtide.py +388 -452
  62. rapidtide/workflows/rapidtide_parser.py +129 -90
  63. rapidtide/workflows/{glmfrommaps.py → regressfrommaps.py} +28 -26
  64. rapidtide/workflows/retrolagtcs.py +12 -12
  65. rapidtide/workflows/{retroglm.py → retroregress.py} +243 -141
  66. rapidtide/workflows/tidepool.py +2 -2
  67. {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/METADATA +3 -2
  68. {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/RECORD +72 -63
  69. {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/WHEEL +1 -1
  70. {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info}/entry_points.txt +3 -2
  71. rapidtide/data/examples/src/testoutputsize +0 -45
  72. {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.dist-info/licenses}/LICENSE +0 -0
  73. {rapidtide-3.0a11.dist-info → rapidtide-3.0a13.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/minpreprocglm/${SUBJ}
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
- # --glmsourcefile=/data_in/HCP_1200/${SUBJ}/MNINonLinear/Results/rfMRI_${RUN}_${PEDIR}/rfMRI_${RUN}_${PEDIR}_hp2000_clean.nii.gz \
19
- mkdir -p /data_out/HCP_1200/minpreprocglm/${SUBJ}
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/minpreprocglm/${SUBJ}/rapidtide_rfMRI_${RUN}_${PEDIR} \
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,211 @@
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] = tide_refinedelay.ratiotodelay(filteredregressderivratios[i])
165
+ refinedvoxelstoreport = filteredregressderivratios.shape[0]
166
+ else:
167
+ medfiltregressderivratios = np.zeros_like(regressderivratios)
168
+ filteredregressderivratios = np.zeros_like(regressderivratios)
169
+ delayoffsetMAD = np.zeros(args.refineregressderivs, dtype=float)
170
+ for i in range(args.refineregressderivs):
171
+ (
172
+ medfiltregressderivratios[i, :],
173
+ filteredregressderivratios[i, :],
174
+ delayoffsetMAD[i],
175
+ ) = tide_refinedelay.filterderivratios(
176
+ regressderivratios[i, :],
177
+ (xsize, ysize, numslices),
178
+ validvoxels,
179
+ (xdim, ydim, slicedim),
180
+ gausssigma=args.delayoffsetgausssigma,
181
+ patchthresh=args.delaypatchthresh,
182
+ fileiscifti=False,
183
+ textio=False,
184
+ rt_floattype=rt_floattype,
185
+ debug=args.debug,
186
+ )
187
+
188
+ def getdelays(self):
189
+ # now calculate the delay offsets
190
+ delayoffset = np.zeros_like(filteredregressderivratios[0, :])
191
+ if self.debug:
192
+ print(f"calculating delayoffsets for {filteredregressderivratios.shape[1]} voxels")
193
+ for i in range(filteredregressderivratios.shape[1]):
194
+ delayoffset[i] = tide_refinedelay.coffstodelay(
195
+ filteredregressderivratios[:, i],
196
+ mindelay=self.mindelay,
197
+ maxdelay=self.maxdelay,
198
+ )
199
+ refinedvoxelstoreport = filteredregressderivratios.shape[1]
200
+
201
+ def savestats(self):
202
+ namesuffix = "_desc-delayoffset_hist"
203
+ tide_stats.makeandsavehistogram(
204
+ delayoffset,
205
+ therunoptions["histlen"],
206
+ 1,
207
+ self.outputname + namesuffix,
208
+ displaytitle="Histogram of delay offsets calculated from coefficient ratios",
209
+ dictvarname="delayoffsethist",
210
+ thedict=None,
211
+ )