rapidtide 3.0.8__py3-none-any.whl → 3.0.10__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 (38) hide show
  1. rapidtide/OrthoImageItem.py +15 -6
  2. rapidtide/RapidtideDataset.py +22 -7
  3. rapidtide/_version.py +3 -3
  4. rapidtide/data/examples/src/testfmri +26 -20
  5. rapidtide/data/examples/src/testhappy +0 -1
  6. rapidtide/filter.py +60 -111
  7. rapidtide/fit.py +501 -108
  8. rapidtide/io.py +19 -8
  9. rapidtide/linfitfiltpass.py +44 -25
  10. rapidtide/refinedelay.py +2 -2
  11. rapidtide/refineregressor.py +1 -1
  12. rapidtide/resample.py +8 -8
  13. rapidtide/simFuncClasses.py +13 -7
  14. rapidtide/tests/.coveragerc +17 -11
  15. rapidtide/tests/test_delayestimation.py +1 -1
  16. rapidtide/tests/test_findmaxlag.py +31 -16
  17. rapidtide/tests/test_fullrunrapidtide_v8.py +66 -0
  18. rapidtide/tests/test_padvec.py +19 -1
  19. rapidtide/tests/test_simroundtrip.py +124 -0
  20. rapidtide/tidepoolTemplate.py +37 -37
  21. rapidtide/tidepoolTemplate_alt.py +40 -40
  22. rapidtide/tidepoolTemplate_big.py +56 -56
  23. rapidtide/workflows/calcSimFuncMap.py +271 -0
  24. rapidtide/workflows/delayvar.py +1 -1
  25. rapidtide/workflows/fitSimFuncMap.py +427 -0
  26. rapidtide/workflows/happy.py +2 -2
  27. rapidtide/workflows/parser_funcs.py +1 -1
  28. rapidtide/workflows/rapidtide.py +197 -48
  29. rapidtide/workflows/rapidtide_parser.py +23 -2
  30. rapidtide/workflows/regressfrommaps.py +7 -7
  31. rapidtide/workflows/tidepool.py +51 -15
  32. {rapidtide-3.0.8.dist-info → rapidtide-3.0.10.dist-info}/METADATA +3 -3
  33. {rapidtide-3.0.8.dist-info → rapidtide-3.0.10.dist-info}/RECORD +37 -34
  34. rapidtide/workflows/estimateDelayMap.py +0 -536
  35. {rapidtide-3.0.8.dist-info → rapidtide-3.0.10.dist-info}/WHEEL +0 -0
  36. {rapidtide-3.0.8.dist-info → rapidtide-3.0.10.dist-info}/entry_points.txt +0 -0
  37. {rapidtide-3.0.8.dist-info → rapidtide-3.0.10.dist-info}/licenses/LICENSE +0 -0
  38. {rapidtide-3.0.8.dist-info → rapidtide-3.0.10.dist-info}/top_level.txt +0 -0
rapidtide/io.py CHANGED
@@ -1263,6 +1263,10 @@ def readlabelledtsv(inputfilename, compressed=False):
1263
1263
  theext = ".tsv.gz"
1264
1264
  else:
1265
1265
  theext = ".tsv"
1266
+
1267
+ if not os.path.isfile(inputfilename + theext):
1268
+ raise FileNotFoundError(f"Labelled tsv file {inputfilename + theext} does not exist")
1269
+
1266
1270
  df = pd.read_csv(inputfilename + theext, sep="\t", quotechar='"')
1267
1271
 
1268
1272
  # replace nans with 0
@@ -1290,6 +1294,9 @@ def readcsv(inputfilename, debug=False):
1290
1294
  NOTE: If file does not exist or is not valid, return an empty dictionary
1291
1295
 
1292
1296
  """
1297
+ if not os.path.isfile(inputfilename + ".csv"):
1298
+ raise FileNotFoundError(f"csv file {inputfilename}.csv does not exist")
1299
+
1293
1300
  timeseriesdict = {}
1294
1301
 
1295
1302
  # Read the data in initially with no header
@@ -1341,6 +1348,9 @@ def readfslmat(inputfilename, debug=False):
1341
1348
  NOTE: If file does not exist or is not valid, return an empty dictionary
1342
1349
 
1343
1350
  """
1351
+ if not os.path.isfile(inputfilename + ".mat"):
1352
+ raise FileNotFoundError(f"FSL mat file {inputfilename}.mat does not exist")
1353
+
1344
1354
  timeseriesdict = {}
1345
1355
 
1346
1356
  # Read the data in with no header
@@ -1364,8 +1374,7 @@ def readoptionsfile(inputfileroot):
1364
1374
  # options saved as text
1365
1375
  thedict = readdict(inputfileroot + ".txt")
1366
1376
  else:
1367
- print("no valid options file found")
1368
- return {}
1377
+ raise FileNotFoundError(f"options file {inputfileroot}(.json/.txt) does not exist")
1369
1378
 
1370
1379
  # correct behavior for older options files
1371
1380
  try:
@@ -1476,7 +1485,7 @@ def writebidstsv(
1476
1485
  reshapeddata = data
1477
1486
  if append:
1478
1487
  insamplerate, instarttime, incolumns, indata, incompressed, incolsource = readbidstsv(
1479
- outputfileroot + ".json", debug=debug
1488
+ outputfileroot + ".json", neednotexist=True, debug=debug,
1480
1489
  )
1481
1490
  if debug:
1482
1491
  print("appending")
@@ -1723,7 +1732,7 @@ def readvectorsfromtextfile(fullfilespec, onecol=False, debug=False):
1723
1732
  return thesamplerate, thestarttime, thecolumns, thedata, compressed, filetype
1724
1733
 
1725
1734
 
1726
- def readbidstsv(inputfilename, colspec=None, warn=True, debug=False):
1735
+ def readbidstsv(inputfilename, colspec=None, warn=True, neednotexist=False, debug=False):
1727
1736
  r"""Read time series out of a BIDS tsv file
1728
1737
 
1729
1738
  Parameters
@@ -1890,11 +1899,13 @@ def readbidstsv(inputfilename, colspec=None, warn=True, debug=False):
1890
1899
  columnsource,
1891
1900
  )
1892
1901
  else:
1893
- print("file pair does not exist")
1894
- return [None, None, None, None, None, None]
1902
+ if neednotexist:
1903
+ return [None, None, None, None, None, None]
1904
+ else:
1905
+ raise FileNotFoundError(f"file pair {thefileroot}(.json/.tsv[.gz]) does not exist")
1895
1906
 
1896
1907
 
1897
- def readcolfrombidstsv(inputfilename, columnnum=0, columnname=None, debug=False):
1908
+ def readcolfrombidstsv(inputfilename, columnnum=0, columnname=None, neednotexist=False, debug=False):
1898
1909
  r"""
1899
1910
 
1900
1911
  Parameters
@@ -1908,7 +1919,7 @@ def readcolfrombidstsv(inputfilename, columnnum=0, columnname=None, debug=False)
1908
1919
 
1909
1920
  """
1910
1921
  samplerate, starttime, columns, data, compressed, colsource = readbidstsv(
1911
- inputfilename, debug=debug
1922
+ inputfilename, neednotexist=neednotexist, debug=debug
1912
1923
  )
1913
1924
  if data is None:
1914
1925
  print("no valid datafile found")
@@ -91,11 +91,12 @@ def linfitfiltpass(
91
91
  filtereddata,
92
92
  nprocs=1,
93
93
  alwaysmultiproc=False,
94
+ voxelspecific=True,
94
95
  confoundregress=False,
95
- ratiosonly=False,
96
+ coefficientsonly=False,
96
97
  procbyvoxel=True,
97
98
  showprogressbar=True,
98
- mp_chunksize=1000,
99
+ chunksize=1000,
99
100
  rt_floatset=np.float64,
100
101
  rt_floattype="float64",
101
102
  verbose=True,
@@ -142,7 +143,7 @@ def linfitfiltpass(
142
143
 
143
144
  # process and send the data
144
145
  if procbyvoxel:
145
- if confoundregress:
146
+ if confoundregress or (not voxelspecific):
146
147
  outQ.put(
147
148
  _procOneRegressionFitItem(
148
149
  val,
@@ -163,7 +164,7 @@ def linfitfiltpass(
163
164
  )
164
165
  )
165
166
  else:
166
- if confoundregress:
167
+ if confoundregress or (not voxelspecific):
167
168
  outQ.put(
168
169
  _procOneRegressionFitItem(
169
170
  val,
@@ -197,7 +198,7 @@ def linfitfiltpass(
197
198
  indexaxis=indexaxis,
198
199
  procunit=procunit,
199
200
  showprogressbar=showprogressbar,
200
- chunksize=mp_chunksize,
201
+ chunksize=chunksize,
201
202
  )
202
203
 
203
204
  # unpack the data
@@ -208,7 +209,7 @@ def linfitfiltpass(
208
209
  r2value[voxel[0]] = voxel[3]
209
210
  filtereddata[voxel[0], :] = voxel[7]
210
211
  itemstotal += 1
211
- elif ratiosonly:
212
+ elif coefficientsonly:
212
213
  for voxel in data_out:
213
214
  meanvalue[voxel[0]] = voxel[1]
214
215
  rvalue[voxel[0]] = voxel[2]
@@ -240,7 +241,7 @@ def linfitfiltpass(
240
241
  r2value[timepoint[0]] = timepoint[3]
241
242
  filtereddata[:, timepoint[0]] = timepoint[7]
242
243
  itemstotal += 1
243
- elif ratiosonly:
244
+ elif coefficientsonly:
244
245
  for timepoint in data_out:
245
246
  meanvalue[timepoint[0]] = timepoint[1]
246
247
  rvalue[timepoint[0]] = timepoint[2]
@@ -296,23 +297,41 @@ def linfitfiltpass(
296
297
  rt_floatset=rt_floatset,
297
298
  rt_floattype=rt_floattype,
298
299
  )
299
- elif ratiosonly:
300
- (
301
- dummy,
302
- meanvalue[vox],
303
- rvalue[vox],
304
- r2value[vox],
305
- fitcoeff[vox],
306
- fitNorm[vox],
307
- dummy,
308
- dummy,
309
- ) = _procOneRegressionFitItem(
310
- vox,
311
- theevs[vox, :],
312
- thedata,
313
- rt_floatset=rt_floatset,
314
- rt_floattype=rt_floattype,
315
- )
300
+ elif coefficientsonly:
301
+ if voxelspecific:
302
+ (
303
+ dummy,
304
+ meanvalue[vox],
305
+ rvalue[vox],
306
+ r2value[vox],
307
+ fitcoeff[vox],
308
+ fitNorm[vox],
309
+ dummy,
310
+ dummy,
311
+ ) = _procOneRegressionFitItem(
312
+ vox,
313
+ theevs[vox, :],
314
+ thedata,
315
+ rt_floatset=rt_floatset,
316
+ rt_floattype=rt_floattype,
317
+ )
318
+ else:
319
+ (
320
+ dummy,
321
+ meanvalue[vox],
322
+ rvalue[vox],
323
+ r2value[vox],
324
+ fitcoeff[vox],
325
+ fitNorm[vox],
326
+ dummy,
327
+ dummy,
328
+ ) = _procOneRegressionFitItem(
329
+ vox,
330
+ theevs,
331
+ thedata,
332
+ rt_floatset=rt_floatset,
333
+ rt_floattype=rt_floattype,
334
+ )
316
335
  else:
317
336
  (
318
337
  dummy,
@@ -357,7 +376,7 @@ def linfitfiltpass(
357
376
  rt_floatset=rt_floatset,
358
377
  rt_floattype=rt_floattype,
359
378
  )
360
- elif ratiosonly:
379
+ elif coefficientsonly:
361
380
  (
362
381
  dummy,
363
382
  meanvalue[timepoint],
rapidtide/refinedelay.py CHANGED
@@ -391,10 +391,10 @@ def getderivratios(
391
391
  nprocs_makelaggedtcs=optiondict["nprocs_makelaggedtcs"],
392
392
  nprocs_regressionfilt=optiondict["nprocs_regressionfilt"],
393
393
  regressderivs=regressderivs,
394
- mp_chunksize=optiondict["mp_chunksize"],
394
+ chunksize=optiondict["mp_chunksize"],
395
395
  showprogressbar=optiondict["showprogressbar"],
396
396
  alwaysmultiproc=optiondict["alwaysmultiproc"],
397
- ratiosonly=True,
397
+ coefficientsonly=True,
398
398
  debug=debug,
399
399
  )
400
400
 
@@ -590,7 +590,7 @@ def dorefine(
590
590
  sys.exit()
591
591
  LGR.info(
592
592
  f"Using {len(thefit.components_)} component(s), accounting for "
593
- + f"{100.0 * np.cumsum(thefit.explained_variance_ratio_)[len(thefit.components_) - 1]}% of the variance"
593
+ + f"{100.0 * np.cumsum(thefit.explained_variance_ratio_)[len(thefit.components_) - 1]:.2f}% of the variance"
594
594
  )
595
595
  reduceddata = thefit.inverse_transform(thefit.transform(refinevoxels))
596
596
  if debug:
rapidtide/resample.py CHANGED
@@ -597,7 +597,7 @@ def arbresample(
597
597
  return resampled
598
598
 
599
599
 
600
- def upsample(inputdata, Fs_init, Fs_higher, method="univariate", intfac=False, debug=False):
600
+ def upsample(inputdata, Fs_init, Fs_higher, method="univariate", intfac=False, dofilt=True, debug=False):
601
601
  starttime = time.time()
602
602
  if Fs_higher <= Fs_init:
603
603
  print("upsample: target frequency must be higher than initial frequency")
@@ -607,19 +607,19 @@ def upsample(inputdata, Fs_init, Fs_higher, method="univariate", intfac=False, d
607
607
  orig_x = np.linspace(0.0, (1.0 / Fs_init) * len(inputdata), num=len(inputdata), endpoint=False)
608
608
  endpoint = orig_x[-1] - orig_x[0]
609
609
  ts_higher = 1.0 / Fs_higher
610
- numresamppts = int(endpoint // ts_higher + 1)
611
610
  if intfac:
612
611
  numresamppts = int(Fs_higher // Fs_init) * len(inputdata)
613
612
  else:
614
613
  numresamppts = int(endpoint // ts_higher + 1)
615
614
  upsampled_x = np.arange(0.0, ts_higher * numresamppts, ts_higher)
616
615
  upsampled_y = doresample(orig_x, inputdata, upsampled_x, method=method)
617
- initfilter = tide_filt.NoncausalFilter(
618
- filtertype="arb", transferfunc="trapezoidal", debug=debug
619
- )
620
- stopfreq = np.min([1.1 * Fs_init / 2.0, Fs_higher / 2.0])
621
- initfilter.setfreqs(0.0, 0.0, Fs_init / 2.0, stopfreq)
622
- upsampled_y = initfilter.apply(Fs_higher, upsampled_y)
616
+ if dofilt:
617
+ initfilter = tide_filt.NoncausalFilter(
618
+ filtertype="arb", transferfunc="trapezoidal", debug=debug
619
+ )
620
+ stopfreq = np.min([1.1 * Fs_init / 2.0, Fs_higher / 2.0])
621
+ initfilter.setfreqs(0.0, 0.0, Fs_init / 2.0, stopfreq)
622
+ upsampled_y = initfilter.apply(Fs_higher, upsampled_y)
623
623
  if debug:
624
624
  print("upsampling took", time.time() - starttime, "seconds")
625
625
  return upsampled_y
@@ -694,9 +694,9 @@ class SimilarityFunctionFitter:
694
694
  while peakpoints[peakstart - 1] == 1:
695
695
  peakstart -= 1
696
696
  else:
697
- while thegrad[peakend + 1] <= 0.0 and peakpoints[peakend + 1] == 1:
697
+ while thegrad[peakend + 1] <= 0.0 and peakpoints[peakend + 1] == 1 and peakend < len(self.corrtimeaxis) - 2:
698
698
  peakend += 1
699
- while thegrad[peakstart - 1] >= 0.0 and peakpoints[peakstart - 1] == 1:
699
+ while thegrad[peakstart - 1] >= 0.0 and peakpoints[peakstart - 1] == 1 and peakstart >= 1:
700
700
  peakstart -= 1
701
701
  if self.debug:
702
702
  print("final peakstart, peakend:", peakstart, peakend)
@@ -819,12 +819,18 @@ class SimilarityFunctionFitter:
819
819
  if self.debug:
820
820
  print("fit input array:", p0)
821
821
  try:
822
- plsq, dummy = sp.optimize.leastsq(
822
+ plsq, ier = sp.optimize.leastsq(
823
823
  tide_fit.gaussresiduals, p0, args=(data, X), maxfev=5000
824
824
  )
825
- maxval = plsq[0] + baseline
826
- maxlag = np.fmod((1.0 * plsq[1]), self.lagmod)
827
- maxsigma = plsq[2]
825
+ if ier not in [1, 2, 3, 4]: # Check for successful convergence
826
+ failreason |= self.FML_FITALGOFAIL
827
+ maxval = np.float64(0.0)
828
+ maxlag = np.float64(0.0)
829
+ maxsigma = np.float64(0.0)
830
+ else:
831
+ maxval = plsq[0] + baseline
832
+ maxlag = np.fmod((1.0 * plsq[1]), self.lagmod)
833
+ maxsigma = plsq[2]
828
834
  except:
829
835
  failreason |= self.FML_FITALGOFAIL
830
836
  maxval = np.float64(0.0)
@@ -929,7 +935,7 @@ class SimilarityFunctionFitter:
929
935
  # different rules for mutual information peaks
930
936
  if ((maxval - baseline) < self.lthreshval * baselinedev) or (maxval < baseline):
931
937
  failreason |= self.FML_FITAMPLOW
932
- maxval_init = 0.0
938
+ maxval = 0.0
933
939
  if self.debug:
934
940
  if (maxval - baseline) < self.lthreshval * baselinedev:
935
941
  print(
@@ -6,17 +6,23 @@ sigterm = true
6
6
  source = .
7
7
  omit =
8
8
  __init__.py
9
- ../__init__.py
10
- ../scripts/__init__.py
11
- ../OrthoImageItem.py
12
- ../wiener2.py
13
- ../tidepoolTemplate.py
14
- ../tidepoolTemplate_qt6.py
15
- ../tidepoolTemplate_alt.py
16
- ../tidepoolTemplate_alt_qt6.py
17
- ../tidepoolTemplate_big.py
18
- ../tidepoolTemplate_big_qt6.py
19
- ../notreadyforprimetime/*
9
+ scripts/__init__.py
10
+ OrthoImageItem.py
11
+ wiener2.py
12
+ fMRIData_class.py
13
+ tidepoolTemplate.py
14
+ tidepoolTemplate_qt6.py
15
+ tidepoolTemplate_alt.py
16
+ tidepoolTemplate_alt_qt6.py
17
+ tidepoolTemplate_big.py
18
+ tidepoolTemplate_big_qt6.py
19
+ */tidepool.py
20
+ */delayvar.py
21
+ */variabilityizer.py
22
+ */synthASL.py
23
+ */proj2flow.py
24
+ */adjustoffset.py
25
+ notreadyforprimetime/*
20
26
 
21
27
  [report]
22
28
  exclude_lines =
@@ -350,7 +350,7 @@ def test_delayestimation(displayplots=False, debug=False):
350
350
  nprocs=nprocs,
351
351
  alwaysmultiproc=False,
352
352
  showprogressbar=False,
353
- mp_chunksize=chunksize,
353
+ chunksize=chunksize,
354
354
  )
355
355
 
356
356
  if nprocs == 1:
@@ -26,7 +26,7 @@ import numpy as np
26
26
  import rapidtide.fit as tide_fit
27
27
  import rapidtide.io as tide_io
28
28
  import rapidtide.simFuncClasses as tide_simFuncClasses
29
- from rapidtide.tests.utils import get_examples_path
29
+ from rapidtide.tests.utils import get_examples_path, get_test_temp_path
30
30
 
31
31
 
32
32
  def dumplists(results, targets, failflags):
@@ -39,7 +39,12 @@ def dumplists(results, targets, failflags):
39
39
  print(results[i], targets[i], failflags[i])
40
40
 
41
41
 
42
- def eval_fml_result(absmin, absmax, testvalues, foundvalues, failflags, tolerance=0.0001):
42
+ def eval_fml_result(absmin, absmax, testvalues, foundvalues, failflags, tolerance=0.0001, debug=False):
43
+ if debug:
44
+ print(f"{absmin=}, {absmax=}, {tolerance=}")
45
+ print(f"{testvalues=}")
46
+ print(f"{foundvalues=}")
47
+ print(f"{failflags=}")
43
48
  for i in range(len(testvalues)):
44
49
  if testvalues[i] < absmin:
45
50
  if foundvalues[i] != absmin:
@@ -61,12 +66,22 @@ def eval_fml_result(absmin, absmax, testvalues, foundvalues, failflags, toleranc
61
66
  return True
62
67
 
63
68
 
64
- def test_findmaxlag(displayplots=False, debug=False):
69
+ def test_findmaxlag(displayplots=False, local=False, debug=False):
70
+ # set input and output directories
71
+ if local:
72
+ exampleroot = "../data/examples/src"
73
+ testtemproot = "./tmp"
74
+ else:
75
+ exampleroot = get_examples_path()
76
+ testtemproot = get_test_temp_path()
77
+
78
+ if debug:
79
+ print("debug flag is set")
65
80
  # for fittype in ["gauss", "quad", "fastquad", "COM", "None", "fastgauss", "gausscf"]:
66
81
  for fittype in ["gauss"]:
67
82
  print("*************************************")
68
83
  print(f"testing fittype: {fittype}")
69
- textfilename = op.join(get_examples_path(), "lt_rt.txt")
84
+ textfilename = op.join(exampleroot, "lt_rt.txt")
70
85
 
71
86
  # set default variable values
72
87
  searchfrac = 0.75
@@ -172,16 +187,16 @@ def test_findmaxlag(displayplots=False, debug=False):
172
187
  for i in range(len(testlags)):
173
188
  print(testlags[i], fml_maxlags[i], fml_lfailreasons[i])
174
189
 
175
- assert eval_fml_result(lagmin, lagmax, testlags, fml_maxlags, fml_lfailreasons)
176
- assert eval_fml_result(absminval, absmaxval, testvals, fml_maxvals, fml_lfailreasons)
190
+ assert eval_fml_result(lagmin, lagmax, testlags, fml_maxlags, fml_lfailreasons, debug=debug)
191
+ assert eval_fml_result(absminval, absmaxval, testvals, fml_maxvals, fml_lfailreasons, debug=debug)
177
192
  assert eval_fml_result(
178
- absminsigma, absmaxsigma, testsigmas, fml_maxsigmas, fml_lfailreasons
193
+ absminsigma, absmaxsigma, testsigmas, fml_maxsigmas, fml_lfailreasons, debug=debug
179
194
  )
180
195
 
181
- assert eval_fml_result(lagmin, lagmax, testlags, fmlc_maxlags, fmlc_lfailreasons)
182
- assert eval_fml_result(absminval, absmaxval, testvals, fmlc_maxvals, fmlc_lfailreasons)
196
+ assert eval_fml_result(lagmin, lagmax, testlags, fmlc_maxlags, fmlc_lfailreasons, debug=debug)
197
+ assert eval_fml_result(absminval, absmaxval, testvals, fmlc_maxvals, fmlc_lfailreasons, debug=debug)
183
198
  assert eval_fml_result(
184
- absminsigma, absmaxsigma, testsigmas, fmlc_maxsigmas, fmlc_lfailreasons
199
+ absminsigma, absmaxsigma, testsigmas, fmlc_maxsigmas, fmlc_lfailreasons, debug=debug
185
200
  )
186
201
 
187
202
  if displayplots:
@@ -315,19 +330,19 @@ def test_findmaxlag(displayplots=False, debug=False):
315
330
  ax.legend(["findmaxlag_gauss", "classes"])
316
331
  plt.show()
317
332
 
318
- assert eval_fml_result(lagmin, lagmax, testlags, fml_maxlags, fml_wfailreasons)
333
+ assert eval_fml_result(lagmin, lagmax, testlags, fml_maxlags, fml_wfailreasons, debug=debug)
319
334
  # assert eval_fml_result(absminval, absmaxval, testvals, fml_maxvals, fml_wfailreasons)
320
335
  assert eval_fml_result(
321
- absminsigma, absmaxsigma, testsigmas, fml_maxsigmas, fml_wfailreasons
336
+ absminsigma, absmaxsigma, testsigmas, fml_maxsigmas, fml_wfailreasons, debug=debug
322
337
  )
323
338
 
324
- assert eval_fml_result(lagmin, lagmax, testlags, fmlc_maxlags, fmlc_wfailreasons)
325
- assert eval_fml_result(absminval, absmaxval, testvals, fmlc_maxvals, fmlc_wfailreasons)
339
+ assert eval_fml_result(lagmin, lagmax, testlags, fmlc_maxlags, fmlc_wfailreasons, debug=debug)
340
+ assert eval_fml_result(absminval, absmaxval, testvals, fmlc_maxvals, fmlc_wfailreasons, debug=debug)
326
341
  assert eval_fml_result(
327
- absminsigma, absmaxsigma, testsigmas, fmlc_maxsigmas, fmlc_wfailreasons
342
+ absminsigma, absmaxsigma, testsigmas, fmlc_maxsigmas, fmlc_wfailreasons, debug=debug
328
343
  )
329
344
 
330
345
 
331
346
  if __name__ == "__main__":
332
347
  mpl.use("TkAgg")
333
- test_findmaxlag(displayplots=True, debug=True)
348
+ test_findmaxlag(displayplots=True, local=True, debug=True)
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ #
4
+ # Copyright 2016-2025 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
+ import os
20
+
21
+ import matplotlib as mpl
22
+
23
+ import rapidtide.qualitycheck as rapidtide_quality
24
+ import rapidtide.workflows.rapidtide as rapidtide_workflow
25
+ import rapidtide.workflows.rapidtide_parser as rapidtide_parser
26
+ from rapidtide.tests.utils import get_examples_path, get_test_temp_path
27
+
28
+
29
+ def test_fullrunrapidtide_v8(debug=False, local=False, displayplots=False):
30
+ # set input and output directories
31
+ if local:
32
+ exampleroot = "../data/examples/src"
33
+ testtemproot = "./tmp"
34
+ else:
35
+ exampleroot = get_examples_path()
36
+ testtemproot = get_test_temp_path()
37
+
38
+ # run rapidtide
39
+ inputargs = [
40
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST.nii.gz"),
41
+ os.path.join(testtemproot, "sub-RAPIDTIDETEST8"),
42
+ "--spatialfilt",
43
+ "2",
44
+ "--simcalcrange",
45
+ "4",
46
+ "-1",
47
+ "--searchrange",
48
+ "-5",
49
+ "10",
50
+ "--nprocs",
51
+ "-1",
52
+ "--passes",
53
+ "1",
54
+ "--despecklepasses",
55
+ "3",
56
+ "--similaritymetric",
57
+ "riptide",
58
+ "--riptidestep",
59
+ "1.5",
60
+ ]
61
+ rapidtide_workflow.rapidtide_main(rapidtide_parser.process_args(inputargs=inputargs))
62
+
63
+
64
+ if __name__ == "__main__":
65
+ mpl.use("TkAgg")
66
+ test_fullrunrapidtide_v8(debug=True, local=True, displayplots=True)
@@ -63,6 +63,23 @@ def maketestwaves(timeaxis):
63
63
  "waveform": 1.0 * scratch,
64
64
  }
65
65
  )
66
+
67
+ scratch = np.exp(-timeaxis / timeaxis[2])
68
+ testwaves.append(
69
+ {
70
+ "name": "damped exponential regressor",
71
+ "timeaxis": 1.0 * timeaxis,
72
+ "waveform": 1.0 * scratch,
73
+ }
74
+ )
75
+
76
+ testwaves.append(
77
+ {
78
+ "name": "white noise plus exponential",
79
+ "timeaxis": 1.0 * timeaxis,
80
+ "waveform": 0.3 * np.random.normal(size=tclen) + scratch,
81
+ }
82
+ )
66
83
  return testwaves
67
84
 
68
85
 
@@ -89,7 +106,7 @@ def eval_padvecprops(
89
106
  nperseg = np.min([tclen, 2048])
90
107
  f, dummy = sp.signal.welch(overall, fs=1.0 / sampletime, nperseg=nperseg)
91
108
 
92
- padtypelist = ["reflect", "zero", "constant", "constant+"]
109
+ padtypelist = ["reflect", "zero", "cyclic", "constant", "constant+"]
93
110
  transferfunclist = ["brickwall", "trapezoidal", "butterworth"]
94
111
 
95
112
  # construct some test waveforms for end effects
@@ -184,6 +201,7 @@ def eval_padvecprops(
184
201
  legend.append(thewave["name"] + ": " + thefilter["name"])
185
202
  offset += 1.25
186
203
  plt.legend(legend)
204
+ plt.title(padtype)
187
205
  plt.show()
188
206
 
189
207