rapidtide 3.0.7__py3-none-any.whl → 3.0.8__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 (50) hide show
  1. rapidtide/_version.py +3 -3
  2. rapidtide/calcnullsimfunc.py +1 -3
  3. rapidtide/data/examples/src/test_findmaxlag.py +1 -1
  4. rapidtide/data/examples/src/testfmri +22 -16
  5. rapidtide/data/examples/src/testnewrefine +0 -23
  6. rapidtide/fMRIData_class.py +29 -52
  7. rapidtide/fit.py +4 -4
  8. rapidtide/happy_supportfuncs.py +1 -1
  9. rapidtide/helper_classes.py +0 -1099
  10. rapidtide/linfitfiltpass.py +59 -0
  11. rapidtide/makelaggedtcs.py +10 -0
  12. rapidtide/refinedelay.py +10 -19
  13. rapidtide/simFuncClasses.py +1132 -0
  14. rapidtide/simfuncfit.py +30 -30
  15. rapidtide/stats.py +5 -2
  16. rapidtide/tests/.coveragerc +6 -0
  17. rapidtide/tests/cleanposttest +1 -1
  18. rapidtide/tests/runlocaltest +2 -2
  19. rapidtide/tests/test_cleanregressor.py +3 -3
  20. rapidtide/tests/test_congrid.py +1 -1
  21. rapidtide/tests/test_corrpass.py +3 -3
  22. rapidtide/tests/test_delayestimation.py +8 -7
  23. rapidtide/tests/test_findmaxlag.py +2 -2
  24. rapidtide/tests/test_fullrunrapidtide_v3.py +2 -1
  25. rapidtide/tests/test_getparsers.py +14 -6
  26. rapidtide/tests/test_io.py +2 -6
  27. rapidtide/tests/test_nullcorr.py +3 -3
  28. rapidtide/tests/test_refinedelay.py +20 -5
  29. rapidtide/tidepoolTemplate_alt.py +1 -1
  30. rapidtide/util.py +7 -0
  31. rapidtide/voxelData.py +3 -6
  32. rapidtide/workflows/cleanregressor.py +2 -2
  33. rapidtide/workflows/delayvar.py +44 -58
  34. rapidtide/workflows/{delayestimation.py → estimateDelayMap.py} +84 -31
  35. rapidtide/workflows/rapidtide.py +361 -865
  36. rapidtide/workflows/rapidtide_parser.py +8 -41
  37. rapidtide/workflows/refineDelayMap.py +138 -0
  38. rapidtide/{RegressorRefiner.py → workflows/refineRegressor.py} +200 -28
  39. rapidtide/workflows/regressfrommaps.py +35 -27
  40. rapidtide/workflows/retrolagtcs.py +5 -6
  41. rapidtide/workflows/retroregress.py +93 -193
  42. rapidtide/workflows/showarbcorr.py +2 -2
  43. rapidtide/workflows/showxcorrx.py +5 -5
  44. rapidtide/workflows/tidepool.py +5 -5
  45. {rapidtide-3.0.7.dist-info → rapidtide-3.0.8.dist-info}/METADATA +2 -2
  46. {rapidtide-3.0.7.dist-info → rapidtide-3.0.8.dist-info}/RECORD +50 -48
  47. {rapidtide-3.0.7.dist-info → rapidtide-3.0.8.dist-info}/WHEEL +0 -0
  48. {rapidtide-3.0.7.dist-info → rapidtide-3.0.8.dist-info}/entry_points.txt +0 -0
  49. {rapidtide-3.0.7.dist-info → rapidtide-3.0.8.dist-info}/licenses/LICENSE +0 -0
  50. {rapidtide-3.0.7.dist-info → rapidtide-3.0.8.dist-info}/top_level.txt +0 -0
rapidtide/simfuncfit.py CHANGED
@@ -208,10 +208,10 @@ def fitcorr(
208
208
  break
209
209
 
210
210
  # process and send the data
211
- if (lagmask is None) or (initiallags is None):
211
+ if (themask is None) or (initiallags is None):
212
212
  thislag = None
213
213
  else:
214
- if lagmask[val] > 0:
214
+ if themask[val] > 0:
215
215
  thislag = initiallags[val]
216
216
  else:
217
217
  thislag = None
@@ -289,32 +289,23 @@ def fitcorr(
289
289
  unit="voxels",
290
290
  disable=(not showprogressbar),
291
291
  ):
292
- if themask is None:
293
- dothisone = True
292
+ # process and send the data
293
+ if (themask is None) or (initiallags is None):
294
294
  thislag = None
295
- elif themask[vox] > 0:
296
295
  dothisone = True
297
- thislag = initiallags[vox]
298
296
  else:
299
- dothisone = False
300
- thislag = None
297
+ if themask[vox] > 0:
298
+ thislag = initiallags[vox]
299
+ dothisone = True
300
+ else:
301
+ thislag = None
302
+ dothisone = False
301
303
  if isinstance(initialdelayvalue, np.ndarray):
302
304
  thisinitialdelayvalue = initialdelayvalue[vox]
303
305
  else:
304
306
  thisinitialdelayvalue = initialdelayvalue
305
307
  if dothisone:
306
- (
307
- dummy,
308
- volumetotalinc,
309
- lagtimes[vox],
310
- lagstrengths[vox],
311
- lagsigma[vox],
312
- gaussout[vox, :],
313
- windowout[vox, :],
314
- R2[vox],
315
- lagmask[vox],
316
- failreason,
317
- ) = _procOneVoxelFitcorr(
308
+ voxel = _procOneVoxelFitcorr(
318
309
  vox,
319
310
  corrout[vox, :],
320
311
  thefitter,
@@ -326,29 +317,38 @@ def fitcorr(
326
317
  rt_floatset=rt_floatset,
327
318
  rt_floattype=rt_floattype,
328
319
  )
329
- volumetotal += volumetotalinc
330
320
  if (
331
321
  thefitter.FML_INITAMPLOW
332
322
  | thefitter.FML_INITAMPHIGH
333
323
  | thefitter.FML_FITAMPLOW
334
324
  | thefitter.FML_FITAMPHIGH
335
- ) & failreason:
325
+ ) & voxel[9]:
336
326
  ampfails += 1
337
- if (thefitter.FML_INITWIDTHLOW | thefitter.FML_FITWIDTHLOW) & failreason:
327
+ if (thefitter.FML_INITWIDTHLOW | thefitter.FML_FITWIDTHLOW) & voxel[9]:
338
328
  lowwidthfails += 1
339
- if (thefitter.FML_INITWIDTHHIGH | thefitter.FML_FITWIDTHHIGH) & failreason:
329
+ if (thefitter.FML_INITWIDTHHIGH | thefitter.FML_FITWIDTHHIGH) & voxel[9]:
340
330
  highwidthfails += 1
341
- if (thefitter.FML_INITLAGLOW | thefitter.FML_INITLAGHIGH) & failreason:
331
+ if (thefitter.FML_INITLAGLOW | thefitter.FML_FITLAGLOW) & voxel[9]:
342
332
  lowlagfails += 1
343
- if (thefitter.FML_INITLAGLOW | thefitter.FML_FITLAGLOW) & failreason:
344
- lowlagfails += 1
345
- if (thefitter.FML_INITLAGHIGH | thefitter.FML_FITLAGHIGH) & failreason:
333
+ if (thefitter.FML_INITLAGHIGH | thefitter.FML_FITLAGHIGH) & voxel[9]:
346
334
  highlagfails += 1
347
- if thefitter.FML_INITFAIL & failreason:
335
+ if thefitter.FML_INITFAIL & voxel[9]:
348
336
  initfails += 1
349
- if thefitter.FML_FITFAIL & failreason:
337
+ if thefitter.FML_FITFAIL & voxel[9]:
350
338
  fitfails += 1
351
339
 
340
+ # if this is a despeckle pass, only accept the new values if the fit did not fail
341
+ if (voxel[9] == 0) or not despeckling:
342
+ volumetotal += voxel[1]
343
+ lagtimes[vox] = voxel[2]
344
+ lagstrengths[vox] = voxel[3]
345
+ lagsigma[vox] = voxel[4]
346
+ gaussout[vox, :] = voxel[5]
347
+ windowout[vox, :] = voxel[6]
348
+ R2[vox] = voxel[7]
349
+ lagmask[vox] = voxel[8]
350
+ failimage[vox] = voxel[9] & 0xFFFF
351
+
352
352
  LGR.info(f"\nSimilarity function fitted in {volumetotal} voxels")
353
353
  LGR.info(
354
354
  f"\tampfails: {ampfails}"
rapidtide/stats.py CHANGED
@@ -269,7 +269,7 @@ def sigFromDistributionData(
269
269
  # check to make sure there are nonzero values first
270
270
  if len(np.where(vallist != 0.0)[0]) == 0:
271
271
  print("no nonzero values - skipping percentile calculation")
272
- return None, 0, 0
272
+ return None, None, None
273
273
  thehistogram, peakheight, peakloc, peakwidth, centerofmass, peakpercentile = makehistogram(
274
274
  np.abs(vallist), histlen, therange=[0.0, 1.0]
275
275
  )
@@ -300,7 +300,10 @@ def sigFromDistributionData(
300
300
  pcts_fit = getfracvalsfromfit(histfit, thepercentiles)
301
301
  return pcts_data, pcts_fit, histfit
302
302
  else:
303
- return pcts_data, 0, 0
303
+ pcts_fit = []
304
+ for i in len(pcts_data):
305
+ pcts_fit.append(None)
306
+ return pcts_data, pcts_fit, None
304
307
 
305
308
 
306
309
  global neglogpfromr_interpolator, minrforneglogp, maxrforneglogp
@@ -22,9 +22,15 @@ omit =
22
22
  exclude_lines =
23
23
  # Don't complain if non-runnable code isn't run:
24
24
  if displayplots:
25
+ if args.displayplots:
26
+ if args.display:
25
27
  if doplot:
28
+ if args.doplot:
26
29
  if args.displayplots:
27
30
  if debug:
31
+ if optiondict["debug"]:
32
+ if optiondict['debug']:
33
+ if args.debug:
28
34
  if self.debug:
29
35
  if False:
30
36
  if __name__ == .__main__.:
@@ -17,4 +17,4 @@
17
17
  #
18
18
 
19
19
  rm tmp/*
20
- rm .coveragerc.*
20
+ rm .coverage.*
@@ -18,8 +18,8 @@
18
18
 
19
19
  # make sure the test data is installed
20
20
  pushd ../data/examples/src
21
- cleanupdir
22
- installtestdatahere
21
+ ./cleanupdir
22
+ ./installtestdatahere
23
23
  popd
24
24
 
25
25
  # clean out old tests
@@ -22,9 +22,9 @@ import matplotlib as mpl
22
22
  import numpy as np
23
23
 
24
24
  import rapidtide.filter as tide_filt
25
- import rapidtide.helper_classes as tide_classes
26
25
  import rapidtide.miscmath as tide_math
27
26
  import rapidtide.resample as tide_resample
27
+ import rapidtide.simFuncClasses as tide_simFuncClasses
28
28
  import rapidtide.workflows.cleanregressor as tide_cleanregressor
29
29
  from rapidtide.tests.utils import get_examples_path, get_test_temp_path, mse
30
30
 
@@ -58,14 +58,14 @@ def test_cleanregressor(debug=False, local=False, displayplots=False):
58
58
  osvalidsimcalcstart = 0
59
59
  osvalidsimcalcend = tclen * oversampfac
60
60
 
61
- theCorrelator = tide_classes.Correlator(
61
+ theCorrelator = tide_simFuncClasses.Correlator(
62
62
  Fs=oversampfreq,
63
63
  ncprefilter=theprefilter,
64
64
  detrendorder=1,
65
65
  windowfunc="hamming",
66
66
  corrweighting="phat",
67
67
  )
68
- theFitter = tide_classes.SimilarityFunctionFitter(
68
+ theFitter = tide_simFuncClasses.SimilarityFunctionFitter(
69
69
  lagmod=lagmod,
70
70
  lagmin=lagmin,
71
71
  lagmax=lagmax,
@@ -20,8 +20,8 @@ import matplotlib as mpl
20
20
  import matplotlib.pyplot as plt
21
21
  import numpy as np
22
22
 
23
- from rapidtide.resample import congrid
24
23
  from rapidtide.happy_supportfuncs import preloadcongrid
24
+ from rapidtide.resample import congrid
25
25
  from rapidtide.tests.utils import mse
26
26
 
27
27
 
@@ -23,8 +23,8 @@ import numpy as np
23
23
  import rapidtide.calcsimfunc as tide_calcsimfunc
24
24
  import rapidtide.correlate as tide_corr
25
25
  import rapidtide.filter as tide_filt
26
- import rapidtide.helper_classes as tide_classes
27
26
  import rapidtide.resample as tide_resample
27
+ import rapidtide.simFuncClasses as tide_simFuncClasses
28
28
  import rapidtide.simfuncfit as tide_simfuncfit
29
29
  from rapidtide.tests.utils import mse
30
30
 
@@ -133,7 +133,7 @@ def test_calcsimfunc(debug=False, displayplots=False):
133
133
  }
134
134
 
135
135
  theprefilter = tide_filt.NoncausalFilter("lfo")
136
- theCorrelator = tide_classes.Correlator(
136
+ theCorrelator = tide_simFuncClasses.Correlator(
137
137
  Fs=oversampfreq,
138
138
  ncprefilter=theprefilter,
139
139
  detrendorder=optiondict["detrendorder"],
@@ -141,7 +141,7 @@ def test_calcsimfunc(debug=False, displayplots=False):
141
141
  corrweighting=optiondict["corrweighting"],
142
142
  )
143
143
 
144
- thefitter = tide_classes.SimilarityFunctionFitter(
144
+ thefitter = tide_simFuncClasses.SimilarityFunctionFitter(
145
145
  lagmod=optiondict["lagmod"],
146
146
  lthreshval=optiondict["lthreshval"],
147
147
  uthreshval=optiondict["uthreshval"],
@@ -24,11 +24,11 @@ import numpy as np
24
24
 
25
25
  import rapidtide.calcsimfunc as tide_calcsimfunc
26
26
  import rapidtide.filter as tide_filt
27
- import rapidtide.helper_classes as tide_classes
28
27
  import rapidtide.linfitfiltpass as tide_linfitfiltpass
29
28
  import rapidtide.miscmath as tide_math
30
29
  import rapidtide.peakeval as tide_peakeval
31
30
  import rapidtide.resample as tide_resample
31
+ import rapidtide.simFuncClasses as tide_simFuncClasses
32
32
  import rapidtide.simfuncfit as tide_simfuncfit
33
33
  import rapidtide.util as tide_util
34
34
 
@@ -130,7 +130,7 @@ def test_delayestimation(displayplots=False, debug=False):
130
130
  # set up theCorrelator
131
131
  if debug:
132
132
  print("\n\nsetting up theCorrelator")
133
- theCorrelator = tide_classes.Correlator(
133
+ theCorrelator = tide_simFuncClasses.Correlator(
134
134
  Fs=oversampfreq,
135
135
  ncprefilter=theprefilter,
136
136
  detrendorder=detrendorder,
@@ -152,7 +152,7 @@ def test_delayestimation(displayplots=False, debug=False):
152
152
  # set up theMutualInformationator
153
153
  if debug:
154
154
  print("\n\nsetting up theMutualInformationator")
155
- theMutualInformationator = tide_classes.MutualInformationator(
155
+ theMutualInformationator = tide_simFuncClasses.MutualInformationator(
156
156
  Fs=oversampfreq,
157
157
  smoothingtime=smoothingtime,
158
158
  ncprefilter=theprefilter,
@@ -170,7 +170,7 @@ def test_delayestimation(displayplots=False, debug=False):
170
170
  # set up thefitter
171
171
  if debug:
172
172
  print("\n\nsetting up thefitter")
173
- thefitter = tide_classes.SimilarityFunctionFitter(
173
+ thefitter = tide_simFuncClasses.SimilarityFunctionFitter(
174
174
  lagmod=lagmod,
175
175
  lthreshval=0.0,
176
176
  uthreshval=1.0,
@@ -360,9 +360,10 @@ def test_delayestimation(displayplots=False, debug=False):
360
360
  diffsignal = filtereddata
361
361
  fig = plt.figure()
362
362
  ax = fig.add_subplot(1, 1, 1)
363
- # ax.plot(timepoints, filtereddata[refnum, :], label='filtereddata')
364
- ax.plot(oversamptimepoints, referencetc, label="referencetc")
365
- ax.plot(timepoints, movingsignal[refnum, :], label="movingsignal")
363
+ # ax.plot(oversamptimepoints, referencetc, label="referencetc")
364
+ ax.plot(timepoints, waveforms[refnum, :], label="waveform")
365
+ ax.plot(timepoints, fitcoff[refnum] * movingsignal[refnum, :], label="movingsignal")
366
+ # ax.plot(timepoints, filtereddata[refnum, :], label="filtereddata")
366
367
  ax.legend()
367
368
  plt.show()
368
369
 
@@ -24,8 +24,8 @@ import matplotlib.pyplot as plt
24
24
  import numpy as np
25
25
 
26
26
  import rapidtide.fit as tide_fit
27
- import rapidtide.helper_classes as tide_classes
28
27
  import rapidtide.io as tide_io
28
+ import rapidtide.simFuncClasses as tide_simFuncClasses
29
29
  from rapidtide.tests.utils import get_examples_path
30
30
 
31
31
 
@@ -101,7 +101,7 @@ def test_findmaxlag(displayplots=False, debug=False):
101
101
  fmlc_lfailreasons = np.zeros(len(testlags), dtype=np.uint16)
102
102
 
103
103
  # initialize the correlation fitter
104
- thefitter = tide_classes.SimilarityFunctionFitter(
104
+ thefitter = tide_simFuncClasses.SimilarityFunctionFitter(
105
105
  corrtimeaxis=xvecs,
106
106
  lagmin=lagmin,
107
107
  lagmax=lagmax,
@@ -22,8 +22,8 @@ import matplotlib as mpl
22
22
 
23
23
  import rapidtide.workflows.rapidtide as rapidtide_workflow
24
24
  import rapidtide.workflows.rapidtide_parser as rapidtide_parser
25
- from rapidtide.tests.utils import get_examples_path, get_test_temp_path
26
25
  import rapidtide.workflows.retroregress as rapidtide_retroregress
26
+ from rapidtide.tests.utils import get_examples_path, get_test_temp_path
27
27
 
28
28
 
29
29
  def test_fullrunrapidtide_v3(debug=False, local=False, displayplots=False):
@@ -87,6 +87,7 @@ def test_fullrunrapidtide_v3(debug=False, local=False, displayplots=False):
87
87
  ]
88
88
  rapidtide_retroregress.retroregress(rapidtide_retroregress.process_args(inputargs=inputargs))
89
89
 
90
+
90
91
  if __name__ == "__main__":
91
92
  mpl.use("TkAgg")
92
93
  test_fullrunrapidtide_v3(debug=True, local=True, displayplots=True)
@@ -33,18 +33,24 @@ from rapidtide.workflows.filtnifti import _get_parser as filtnifti_getparser
33
33
  from rapidtide.workflows.filttc import _get_parser as filttc_getparser
34
34
  from rapidtide.workflows.fixtr import _get_parser as fixtr_getparser
35
35
  from rapidtide.workflows.gmscalc import _get_parser as gmscalc_getparser
36
- from rapidtide.workflows.happy_parser import _get_parser as happy_parser_getparser
37
36
  from rapidtide.workflows.happy2std import _get_parser as happy2std_getparser
37
+ from rapidtide.workflows.happy_parser import _get_parser as happy_parser_getparser
38
38
  from rapidtide.workflows.histnifti import _get_parser as histnifti_getparser
39
39
  from rapidtide.workflows.histtc import _get_parser as histtc_getparser
40
40
  from rapidtide.workflows.linfitfilt import _get_parser as linfitfilt_getparser
41
41
  from rapidtide.workflows.localflow import _get_parser as localflow_getparser
42
42
  from rapidtide.workflows.mergequality import _get_parser as mergequality_getparser
43
- from rapidtide.workflows.niftidecomp import _get_parser_temporal as niftidecomp_getparser_temporal
44
- from rapidtide.workflows.niftidecomp import _get_parser_spatial as niftidecomp_getparser_spatial
43
+ from rapidtide.workflows.niftidecomp import (
44
+ _get_parser_spatial as niftidecomp_getparser_spatial,
45
+ )
46
+ from rapidtide.workflows.niftidecomp import (
47
+ _get_parser_temporal as niftidecomp_getparser_temporal,
48
+ )
45
49
  from rapidtide.workflows.niftistats import _get_parser as niftistats_getparser
46
50
  from rapidtide.workflows.pairproc import _get_parser as pairproc_getparser
47
- from rapidtide.workflows.pairwisemergenifti import _get_parser as pairwisemergenifti_getparser
51
+ from rapidtide.workflows.pairwisemergenifti import (
52
+ _get_parser as pairwisemergenifti_getparser,
53
+ )
48
54
  from rapidtide.workflows.physiofreq import _get_parser as physiofreq_getparser
49
55
  from rapidtide.workflows.pixelcomp import _get_parser as pixelcomp_getparser
50
56
  from rapidtide.workflows.plethquality import _get_parser as plethquality_getparser
@@ -75,7 +81,8 @@ from rapidtide.workflows.variabilityizer import _get_parser as variabilityizer_g
75
81
 
76
82
 
77
83
  def test_parsers(debug=False):
78
- parserlist = [ adjustoffset_getparser,
84
+ parserlist = [
85
+ adjustoffset_getparser,
79
86
  aligntcs_getparser,
80
87
  applydlfilter_getparser,
81
88
  atlasaverage_getparser,
@@ -128,7 +135,8 @@ def test_parsers(debug=False):
128
135
  synthASL_getparser,
129
136
  tcfrom2col_getparser,
130
137
  tcfrom3col_getparser,
131
- variabilityizer_getparser ]
138
+ variabilityizer_getparser,
139
+ ]
132
140
 
133
141
  for thegetparser in parserlist:
134
142
  theusage = thegetparser().format_help()
@@ -95,14 +95,10 @@ def test_io(debug=True, local=False, displayplots=False):
95
95
 
96
96
  # test fmritimeinfo
97
97
  fmritimeinfothresh = 1e-2
98
- tr, timepoints = tide_io.fmritimeinfo(
99
- os.path.join(exampleroot, "sub-HAPPYTEST.nii.gz")
100
- )
98
+ tr, timepoints = tide_io.fmritimeinfo(os.path.join(exampleroot, "sub-HAPPYTEST.nii.gz"))
101
99
  assert np.fabs(tr - 1.16) < fmritimeinfothresh
102
100
  assert timepoints == 110
103
- tr, timepoints = tide_io.fmritimeinfo(
104
- os.path.join(exampleroot, "sub-RAPIDTIDETEST.nii.gz")
105
- )
101
+ tr, timepoints = tide_io.fmritimeinfo(os.path.join(exampleroot, "sub-RAPIDTIDETEST.nii.gz"))
106
102
  assert np.fabs(tr - 1.5) < fmritimeinfothresh
107
103
  assert timepoints == 260
108
104
 
@@ -25,8 +25,8 @@ import numpy as np
25
25
  import rapidtide.calcnullsimfunc as tide_nullsimfunc
26
26
  import rapidtide.correlate as tide_corr
27
27
  import rapidtide.filter as tide_filt
28
- import rapidtide.helper_classes as tide_classes
29
28
  import rapidtide.io as tide_io
29
+ import rapidtide.simFuncClasses as tide_simFuncClasses
30
30
  import rapidtide.stats as tide_stats
31
31
  from rapidtide.tests.utils import get_test_data_path, get_test_temp_path
32
32
 
@@ -94,7 +94,7 @@ def test_nullsimfunc(debug=False, displayplots=False):
94
94
  "hardlimit": True,
95
95
  }
96
96
  theprefilter = tide_filt.NoncausalFilter("lfo")
97
- theCorrelator = tide_classes.Correlator(
97
+ theCorrelator = tide_simFuncClasses.Correlator(
98
98
  Fs=Fs,
99
99
  ncprefilter=theprefilter,
100
100
  detrendorder=optiondict["detrendorder"],
@@ -102,7 +102,7 @@ def test_nullsimfunc(debug=False, displayplots=False):
102
102
  corrweighting=optiondict["corrweighting"],
103
103
  )
104
104
 
105
- thefitter = tide_classes.SimilarityFunctionFitter(
105
+ thefitter = tide_simFuncClasses.SimilarityFunctionFitter(
106
106
  lagmod=optiondict["lagmod"],
107
107
  lthreshval=optiondict["lthreshval"],
108
108
  uthreshval=optiondict["uthreshval"],
@@ -36,6 +36,7 @@ def eval_refinedelay(
36
36
  tclengthinsecs=300.0,
37
37
  mindelay=-5.0,
38
38
  maxdelay=5.0,
39
+ lagpad=0.0,
39
40
  numpoints=501,
40
41
  smoothpts=3,
41
42
  nativespaceshape=(10, 10, 10),
@@ -43,8 +44,17 @@ def eval_refinedelay(
43
44
  padtime=30.0,
44
45
  noiselevel=0.0,
45
46
  outputsuffix="",
47
+ local=False,
46
48
  debug=False,
47
49
  ):
50
+ # set input and output directories
51
+ if local:
52
+ exampleroot = "../data/examples/src"
53
+ testtemproot = "./tmp"
54
+ else:
55
+ exampleroot = get_examples_path()
56
+ testtemproot = get_test_temp_path()
57
+
48
58
  np.random.seed(12345)
49
59
  tclen = int(tclengthinsecs // sampletime)
50
60
 
@@ -84,7 +94,7 @@ def eval_refinedelay(
84
94
  tide_refinedelay.trainratiotooffset(
85
95
  lagtcgenerator,
86
96
  timeaxis,
87
- os.path.join(get_test_temp_path(), "refinedelaytest" + outputsuffix),
97
+ os.path.join(testtemproot, "refinedelaytest" + outputsuffix),
88
98
  "norm",
89
99
  mindelay=mindelay,
90
100
  maxdelay=maxdelay,
@@ -95,7 +105,7 @@ def eval_refinedelay(
95
105
 
96
106
  # make a delay map
97
107
  numlags = nativespaceshape[0] * nativespaceshape[1] * nativespaceshape[2]
98
- lagtimes = np.linspace(mindelay, maxdelay, numlags, endpoint=True)
108
+ lagtimes = np.linspace(mindelay - lagpad, maxdelay + lagpad, numlags, endpoint=True)
99
109
  if debug:
100
110
  print(" lagtimes=", lagtimes)
101
111
 
@@ -120,7 +130,7 @@ def eval_refinedelay(
120
130
 
121
131
  # make a fake header
122
132
  nim, nim_data, nim_hdr, thedims, thesizes = tide_io.readfromnifti(
123
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST_brainmask.nii.gz")
133
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST_brainmask.nii.gz")
124
134
  )
125
135
  xdim, ydim, slicedim, fmritr = tide_io.parseniftisizes(thesizes)
126
136
  theheader = copy.copy(nim_hdr)
@@ -212,7 +222,7 @@ def eval_refinedelay(
212
222
  plt.show()
213
223
 
214
224
 
215
- def test_refinedelay(displayplots=False, debug=False):
225
+ def test_refinedelay(displayplots=False, local=False, debug=False):
216
226
  for noiselevel in np.linspace(0.0, 0.5, num=5, endpoint=True):
217
227
  eval_refinedelay(
218
228
  sampletime=0.72,
@@ -225,6 +235,7 @@ def test_refinedelay(displayplots=False, debug=False):
225
235
  displayplots=displayplots,
226
236
  outputsuffix="_1",
227
237
  noiselevel=noiselevel,
238
+ local=local,
228
239
  debug=debug,
229
240
  )
230
241
  eval_refinedelay(
@@ -237,6 +248,7 @@ def test_refinedelay(displayplots=False, debug=False):
237
248
  nativespaceshape=(10, 10, 10),
238
249
  displayplots=displayplots,
239
250
  outputsuffix="_2",
251
+ local=local,
240
252
  debug=debug,
241
253
  )
242
254
  eval_refinedelay(
@@ -249,6 +261,7 @@ def test_refinedelay(displayplots=False, debug=False):
249
261
  nativespaceshape=(10, 10, 10),
250
262
  displayplots=displayplots,
251
263
  outputsuffix="_3",
264
+ local=local,
252
265
  debug=debug,
253
266
  )
254
267
  eval_refinedelay(
@@ -261,6 +274,7 @@ def test_refinedelay(displayplots=False, debug=False):
261
274
  nativespaceshape=(10, 10, 10),
262
275
  displayplots=displayplots,
263
276
  outputsuffix="_1p5_501_3",
277
+ local=local,
264
278
  debug=debug,
265
279
  )
266
280
  eval_refinedelay(
@@ -273,10 +287,11 @@ def test_refinedelay(displayplots=False, debug=False):
273
287
  nativespaceshape=(10, 10, 10),
274
288
  displayplots=displayplots,
275
289
  outputsuffix="_3p0_501_3",
290
+ local=local,
276
291
  debug=debug,
277
292
  )
278
293
 
279
294
 
280
295
  if __name__ == "__main__":
281
296
  mpl.use("TkAgg")
282
- test_refinedelay(displayplots=True, debug=True)
297
+ test_refinedelay(displayplots=True, local=True, debug=True)
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Form implementation generated from reading ui file 'tidepoolTemplate_alt.ui'
4
4
  #
5
- # Created by: PyQt5 UI code generator 5.15.10
5
+ # Created by: PyQt5 UI code generator 5.15.11
6
6
  #
7
7
  # WARNING: Any manual changes made to this file will be lost when pyuic5 is
8
8
  # run again. Do not edit this file unless you know what you are doing.
rapidtide/util.py CHANGED
@@ -1106,6 +1106,13 @@ def allocshared(theshape, thetype, name=None):
1106
1106
  return outarray, shm # Return both the array and the shared memory object
1107
1107
 
1108
1108
 
1109
+ def allocarray(theshape, thetype, shared=False, name=None):
1110
+ if shared:
1111
+ return allocshared(theshape, thetype, name)
1112
+ else:
1113
+ return np.zeros(theshape, dtype=thetype), None
1114
+
1115
+
1109
1116
  def cleanup_shm(shm):
1110
1117
  # Cleanup
1111
1118
  pass
rapidtide/voxelData.py CHANGED
@@ -61,12 +61,9 @@ class dataVolume:
61
61
  print(f"illegal shape: {shape}")
62
62
  self.numspatiallocs = self.xsize * self.ysize * self.numslices
63
63
  self.dtype = dtype
64
- if not shared:
65
- self.data = np.zeros(shape, dtype=dtype)
66
- else:
67
- self.data, self.data_shm = tide_util.allocshared(
68
- shape, self.dtype, name=f"filtereddata_{thepid}"
69
- )
64
+ self.data, self.data_shm = tide_util.allocarray(
65
+ shape, self.dtype, shared=shared, name=f"filtereddata_{thepid}"
66
+ )
70
67
  return self.data
71
68
 
72
69
  def byvol(self):
@@ -20,9 +20,9 @@ import numpy as np
20
20
 
21
21
  import rapidtide.correlate as tide_corr
22
22
  import rapidtide.filter as tide_filt
23
- import rapidtide.helper_classes as tide_classes
24
23
  import rapidtide.io as tide_io
25
24
  import rapidtide.miscmath as tide_math
25
+ import rapidtide.simFuncClasses as tide_simFuncClasses
26
26
  import rapidtide.simfuncfit as tide_simfuncfit
27
27
 
28
28
 
@@ -81,7 +81,7 @@ def cleanregressor(
81
81
  dolagmod = True
82
82
  doreferencenotch = True
83
83
  if respdelete:
84
- resptracker = tide_classes.FrequencyTracker(nperseg=64)
84
+ resptracker = tide_simFuncClasses.FrequencyTracker(nperseg=64)
85
85
  thetimes, thefreqs = resptracker.track(resampref_y, oversampfreq)
86
86
  tide_io.writevec(thefreqs, f"{outputname}_peakfreaks_pass{thepass}.txt")
87
87
  resampref_y = resptracker.clean(resampref_y, oversampfreq, thetimes, thefreqs)