rapidtide 3.1__py3-none-any.whl → 3.1.1__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 (70) hide show
  1. rapidtide/OrthoImageItem.py +4 -4
  2. rapidtide/_version.py +3 -3
  3. rapidtide/calccoherence.py +4 -4
  4. rapidtide/calcnullsimfunc.py +2 -5
  5. rapidtide/calcsimfunc.py +1 -4
  6. rapidtide/correlate.py +130 -127
  7. rapidtide/data/examples/src/testfmri +41 -9
  8. rapidtide/data/examples/src/testhappy +8 -8
  9. rapidtide/dlfilter.py +21 -22
  10. rapidtide/dlfiltertorch.py +18 -19
  11. rapidtide/filter.py +4 -4
  12. rapidtide/fit.py +18 -18
  13. rapidtide/happy_supportfuncs.py +84 -82
  14. rapidtide/helper_classes.py +2 -2
  15. rapidtide/io.py +88 -83
  16. rapidtide/linfitfiltpass.py +30 -49
  17. rapidtide/makelaggedtcs.py +11 -16
  18. rapidtide/maskutil.py +30 -14
  19. rapidtide/miscmath.py +2 -2
  20. rapidtide/patchmatch.py +10 -11
  21. rapidtide/peakeval.py +1 -3
  22. rapidtide/ppgproc.py +3 -3
  23. rapidtide/qualitycheck.py +2 -2
  24. rapidtide/refinedelay.py +12 -3
  25. rapidtide/refineregressor.py +20 -29
  26. rapidtide/scripts/showxcorr_legacy.py +7 -7
  27. rapidtide/scripts/stupidramtricks.py +15 -17
  28. rapidtide/simFuncClasses.py +2 -2
  29. rapidtide/simfuncfit.py +27 -41
  30. rapidtide/tests/test_cleanregressor.py +1 -2
  31. rapidtide/tests/test_fullrunhappy_v3.py +11 -5
  32. rapidtide/tests/test_fullrunhappy_v4.py +9 -1
  33. rapidtide/tests/test_getparsers.py +11 -3
  34. rapidtide/tests/test_refinedelay.py +0 -1
  35. rapidtide/tests/test_simroundtrip.py +8 -0
  36. rapidtide/tests/test_stcorrelate.py +3 -1
  37. rapidtide/util.py +6 -6
  38. rapidtide/voxelData.py +1 -1
  39. rapidtide/wiener.py +122 -16
  40. rapidtide/wiener2.py +3 -3
  41. rapidtide/workflows/applyppgproc.py +33 -15
  42. rapidtide/workflows/calcSimFuncMap.py +11 -22
  43. rapidtide/workflows/ccorrica.py +4 -2
  44. rapidtide/workflows/cleanregressor.py +6 -11
  45. rapidtide/workflows/delayvar.py +8 -13
  46. rapidtide/workflows/fitSimFuncMap.py +2 -9
  47. rapidtide/workflows/happy.py +6 -6
  48. rapidtide/workflows/happy_parser.py +36 -25
  49. rapidtide/workflows/pairproc.py +10 -2
  50. rapidtide/workflows/pixelcomp.py +1 -2
  51. rapidtide/workflows/rankimage.py +1 -1
  52. rapidtide/workflows/rapidtide.py +98 -63
  53. rapidtide/workflows/refineDelayMap.py +7 -6
  54. rapidtide/workflows/refineRegressor.py +6 -16
  55. rapidtide/workflows/regressfrommaps.py +9 -6
  56. rapidtide/workflows/retrolagtcs.py +5 -7
  57. rapidtide/workflows/retroregress.py +11 -17
  58. rapidtide/workflows/roisummarize.py +11 -10
  59. rapidtide/workflows/showarbcorr.py +2 -2
  60. rapidtide/workflows/showxcorrx.py +6 -6
  61. rapidtide/workflows/simdata.py +31 -31
  62. rapidtide/workflows/spatialmi.py +0 -1
  63. rapidtide/workflows/tidepool.py +6 -4
  64. {rapidtide-3.1.dist-info → rapidtide-3.1.1.dist-info}/METADATA +8 -7
  65. {rapidtide-3.1.dist-info → rapidtide-3.1.1.dist-info}/RECORD +69 -70
  66. rapidtide/wiener_doc.py +0 -255
  67. {rapidtide-3.1.dist-info → rapidtide-3.1.1.dist-info}/WHEEL +0 -0
  68. {rapidtide-3.1.dist-info → rapidtide-3.1.1.dist-info}/entry_points.txt +0 -0
  69. {rapidtide-3.1.dist-info → rapidtide-3.1.1.dist-info}/licenses/LICENSE +0 -0
  70. {rapidtide-3.1.dist-info → rapidtide-3.1.1.dist-info}/top_level.txt +0 -0
@@ -21,6 +21,7 @@ import time
21
21
  import warnings
22
22
 
23
23
  import numpy as np
24
+ from numpy.typing import NDArray
24
25
  from scipy.signal import savgol_filter, welch
25
26
  from scipy.stats import kurtosis, pearsonr, skew
26
27
  from statsmodels.robust import mad
@@ -46,7 +47,7 @@ except ImportError:
46
47
  mklexists = False
47
48
 
48
49
 
49
- def rrifromphase(timeaxis: np.ndarray, thephase: np.ndarray) -> None:
50
+ def rrifromphase(timeaxis: NDArray, thephase: NDArray) -> None:
50
51
  """
51
52
  Convert phase to range rate.
52
53
 
@@ -55,9 +56,9 @@ def rrifromphase(timeaxis: np.ndarray, thephase: np.ndarray) -> None:
55
56
 
56
57
  Parameters
57
58
  ----------
58
- timeaxis : np.ndarray
59
+ timeaxis : NDArray
59
60
  Time axis values corresponding to the phase measurements.
60
- thephase : np.ndarray
61
+ thephase : NDArray
61
62
  Phase measurements to be converted to range rate.
62
63
 
63
64
  Returns
@@ -82,13 +83,13 @@ def rrifromphase(timeaxis: np.ndarray, thephase: np.ndarray) -> None:
82
83
 
83
84
 
84
85
  def calc_3d_optical_flow(
85
- video: np.ndarray,
86
- projmask: np.ndarray,
86
+ video: NDArray,
87
+ projmask: NDArray,
87
88
  flowhdr: dict,
88
89
  outputroot: str,
89
90
  window_size: int = 3,
90
91
  debug: bool = False,
91
- ) -> tuple[np.ndarray, np.ndarray]:
92
+ ) -> tuple[NDArray, NDArray]:
92
93
  """
93
94
  Compute 3D optical flow for a video volume using the Lucas-Kanade method.
94
95
 
@@ -99,10 +100,10 @@ def calc_3d_optical_flow(
99
100
 
100
101
  Parameters
101
102
  ----------
102
- video : np.ndarray
103
+ video : NDArray
103
104
  4D array of shape (xsize, ysize, zsize, num_frames) representing the
104
105
  input video data.
105
- projmask : np.ndarray
106
+ projmask : NDArray
106
107
  3D boolean or integer mask of shape (xsize, ysize, zsize) indicating
107
108
  which voxels to process for optical flow computation.
108
109
  flowhdr : dict
@@ -118,7 +119,7 @@ def calc_3d_optical_flow(
118
119
 
119
120
  Returns
120
121
  -------
121
- tuple[np.ndarray, np.ndarray]
122
+ tuple[NDArray, NDArray]
122
123
  A tuple containing:
123
124
  - `flow_vectors`: 5D array of shape (xsize, ysize, zsize, num_frames, 3)
124
125
  representing the computed optical flow vectors for each frame.
@@ -220,7 +221,7 @@ def calc_3d_optical_flow(
220
221
  return flow_vectors
221
222
 
222
223
 
223
- def phasejolt(phaseimage: np.ndarray) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
224
+ def phasejolt(phaseimage: NDArray) -> tuple[NDArray, NDArray, NDArray]:
224
225
  """
225
226
  Compute phase gradient-based metrics including jump, jolt, and laplacian.
226
227
 
@@ -231,12 +232,12 @@ def phasejolt(phaseimage: np.ndarray) -> tuple[np.ndarray, np.ndarray, np.ndarra
231
232
 
232
233
  Parameters
233
234
  ----------
234
- phaseimage : numpy.ndarray
235
+ phaseimage : NDArray
235
236
  Input phase image array of arbitrary dimensions (typically 2D or 3D).
236
237
 
237
238
  Returns
238
239
  -------
239
- tuple of numpy.ndarray
240
+ tuple of NDArray
240
241
  A tuple containing three arrays:
241
242
  - jump: array of same shape as input, representing average absolute gradient
242
243
  - jolt: array of same shape as input, representing average absolute second-order gradient
@@ -277,11 +278,11 @@ def phasejolt(phaseimage: np.ndarray) -> tuple[np.ndarray, np.ndarray, np.ndarra
277
278
 
278
279
 
279
280
  def cardiacsig(
280
- thisphase: float | np.ndarray,
281
- amps: tuple | np.ndarray = (1.0, 0.0, 0.0),
282
- phases: np.ndarray | None = None,
281
+ thisphase: float | NDArray,
282
+ amps: tuple | NDArray = (1.0, 0.0, 0.0),
283
+ phases: NDArray | None = None,
283
284
  overallphase: float = 0.0,
284
- ) -> float | np.ndarray:
285
+ ) -> float | NDArray:
285
286
  """
286
287
  Generate a cardiac signal model using harmonic components.
287
288
 
@@ -291,14 +292,14 @@ def cardiacsig(
291
292
 
292
293
  Parameters
293
294
  ----------
294
- thisphase : float or np.ndarray
295
+ thisphase : float or NDArray
295
296
  The phase value(s) at which to evaluate the cardiac signal.
296
297
  Can be a scalar or array of phase values.
297
- amps : tuple or np.ndarray, optional
298
+ amps : tuple or NDArray, optional
298
299
  Amplitude coefficients for each harmonic component. Default is
299
300
  (1.0, 0.0, 0.0) representing the fundamental frequency with
300
301
  amplitude 1.0 and higher harmonics with amplitude 0.0.
301
- phases : np.ndarray or None, optional
302
+ phases : NDArray or None, optional
302
303
  Phase shifts for each harmonic component. If None, all phase shifts
303
304
  are set to zero. Default is None.
304
305
  overallphase : float, optional
@@ -306,7 +307,7 @@ def cardiacsig(
306
307
 
307
308
  Returns
308
309
  -------
309
- float or np.ndarray
310
+ float or NDArray
310
311
  The computed cardiac signal value(s) at the given phase(s).
311
312
  Returns a scalar if input is scalar, or array if input is array.
312
313
 
@@ -343,12 +344,12 @@ def cardiacsig(
343
344
 
344
345
 
345
346
  def cardiacfromimage(
346
- normdata_byslice: np.ndarray,
347
- estweights_byslice: np.ndarray,
347
+ normdata_byslice: NDArray,
348
+ estweights_byslice: NDArray,
348
349
  numslices: int,
349
350
  timepoints: int,
350
351
  tr: float,
351
- slicetimes: np.ndarray,
352
+ slicetimes: NDArray,
352
353
  cardprefilter: object,
353
354
  respprefilter: object,
354
355
  notchpct: float = 1.5,
@@ -359,11 +360,11 @@ def cardiacfromimage(
359
360
  arteriesonly: bool = False,
360
361
  fliparteries: bool = False,
361
362
  debug: bool = False,
362
- appflips_byslice: np.ndarray | None = None,
363
+ appflips_byslice: NDArray | None = None,
363
364
  verbose: bool = False,
364
365
  usemask: bool = True,
365
366
  multiplicative: bool = True,
366
- ) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
367
+ ) -> tuple[NDArray, NDArray, NDArray, NDArray, NDArray, NDArray]:
367
368
  """
368
369
  Extract cardiac and respiratory signals from 4D fMRI data using slice timing information.
369
370
 
@@ -374,9 +375,9 @@ def cardiacfromimage(
374
375
 
375
376
  Parameters
376
377
  ----------
377
- normdata_byslice : np.ndarray
378
+ normdata_byslice : NDArray
378
379
  Normalized fMRI data organized by slice, shape (timepoints, numslices, timepoints).
379
- estweights_byslice : np.ndarray
380
+ estweights_byslice : NDArray
380
381
  Estimated weights for each voxel and slice, shape (timepoints, numslices).
381
382
  numslices : int
382
383
  Number of slices in the acquisition.
@@ -384,7 +385,7 @@ def cardiacfromimage(
384
385
  Number of time points in the fMRI time series.
385
386
  tr : float
386
387
  Repetition time (TR) in seconds.
387
- slicetimes : np.ndarray
388
+ slicetimes : NDArray
388
389
  Slice acquisition times relative to the start of the TR, shape (numslices,).
389
390
  cardprefilter : object
390
391
  Cardiac prefilter object with an `apply` method for filtering physiological signals.
@@ -406,7 +407,7 @@ def cardiacfromimage(
406
407
  If True, flip the arterial signal, default is False.
407
408
  debug : bool, optional
408
409
  If True, enable debug output, default is False.
409
- appflips_byslice : np.ndarray | None, optional
410
+ appflips_byslice : NDArray | None, optional
410
411
  Array of application flips for each slice, default is None.
411
412
  verbose : bool, optional
412
413
  If True, print verbose output, default is False.
@@ -417,7 +418,7 @@ def cardiacfromimage(
417
418
 
418
419
  Returns
419
420
  -------
420
- tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]
421
+ tuple[NDArray, NDArray, NDArray, NDArray, NDArray, NDArray]
421
422
  - `hirescardtc`: High-resolution cardiac time course.
422
423
  - `cardnormfac`: Normalization factor for cardiac signal.
423
424
  - `hiresresptc`: High-resolution respiratory time course.
@@ -551,15 +552,15 @@ def cardiacfromimage(
551
552
  )
552
553
 
553
554
 
554
- def theCOM(X: np.ndarray, data: np.ndarray) -> float:
555
+ def theCOM(X: NDArray, data: NDArray) -> float:
555
556
  """
556
557
  Calculate the center of mass of a system of particles.
557
558
 
558
559
  Parameters
559
560
  ----------
560
- X : np.ndarray
561
+ X : NDArray
561
562
  Array of positions (coordinates) of particles. Shape should be (n_particles, n_dimensions).
562
- data : np.ndarray
563
+ data : NDArray
563
564
  Array of mass values for each particle. Shape should be (n_particles,).
564
565
 
565
566
  Returns
@@ -587,7 +588,7 @@ def theCOM(X: np.ndarray, data: np.ndarray) -> float:
587
588
  return np.sum(X * data) / np.sum(data)
588
589
 
589
590
 
590
- def savgolsmooth(data: np.ndarray, smoothlen: int = 101, polyorder: int = 3) -> np.ndarray:
591
+ def savgolsmooth(data: NDArray, smoothlen: int = 101, polyorder: int = 3) -> NDArray:
591
592
  """
592
593
  Apply Savitzky-Golay filter to smooth data.
593
594
 
@@ -598,7 +599,7 @@ def savgolsmooth(data: np.ndarray, smoothlen: int = 101, polyorder: int = 3) ->
598
599
 
599
600
  Parameters
600
601
  ----------
601
- data : np.ndarray
602
+ data : NDArray
602
603
  Input data to be smoothed. Can be 1D or 2D array.
603
604
  smoothlen : int, optional
604
605
  Length of the filter window (i.e., the number of coefficients).
@@ -609,7 +610,7 @@ def savgolsmooth(data: np.ndarray, smoothlen: int = 101, polyorder: int = 3) ->
609
610
 
610
611
  Returns
611
612
  -------
612
- np.ndarray
613
+ NDArray
613
614
  Smoothed data with the same shape as the input `data`.
614
615
 
615
616
  Notes
@@ -633,13 +634,13 @@ def savgolsmooth(data: np.ndarray, smoothlen: int = 101, polyorder: int = 3) ->
633
634
 
634
635
 
635
636
  def getperiodic(
636
- inputdata: np.ndarray,
637
+ inputdata: NDArray,
637
638
  Fs: float,
638
639
  fundfreq: float,
639
640
  ncomps: int = 1,
640
641
  width: float = 0.4,
641
642
  debug: bool = False,
642
- ) -> np.ndarray:
643
+ ) -> NDArray:
643
644
  """
644
645
  Apply a periodic filter to extract harmonic components from input data.
645
646
 
@@ -650,7 +651,7 @@ def getperiodic(
650
651
 
651
652
  Parameters
652
653
  ----------
653
- inputdata : np.ndarray
654
+ inputdata : NDArray
654
655
  Input signal data to be filtered.
655
656
  Fs : float
656
657
  Sampling frequency of the input signal (Hz).
@@ -666,7 +667,7 @@ def getperiodic(
666
667
 
667
668
  Returns
668
669
  -------
669
- np.ndarray
670
+ NDArray
670
671
  Filtered output signal containing the specified harmonic components.
671
672
 
672
673
  Notes
@@ -700,7 +701,7 @@ def getperiodic(
700
701
 
701
702
 
702
703
  def getcardcoeffs(
703
- cardiacwaveform: np.ndarray,
704
+ cardiacwaveform: NDArray,
704
705
  slicesamplerate: float,
705
706
  minhr: float = 40.0,
706
707
  maxhr: float = 140.0,
@@ -717,7 +718,7 @@ def getcardcoeffs(
717
718
 
718
719
  Parameters
719
720
  ----------
720
- cardiacwaveform : np.ndarray
721
+ cardiacwaveform : NDArray
721
722
  Input cardiac waveform signal as a 1D numpy array.
722
723
  slicesamplerate : float
723
724
  Sampling rate of the input waveform in Hz.
@@ -787,7 +788,7 @@ def _procOneVoxelDetrend(
787
788
  vox: int,
788
789
  voxelargs: tuple,
789
790
  **kwargs,
790
- ) -> tuple[int, np.ndarray]:
791
+ ) -> tuple[int, NDArray]:
791
792
  """
792
793
  Detrend fMRI voxel data for a single voxel.
793
794
 
@@ -859,7 +860,7 @@ def _procOneVoxelDetrend(
859
860
  )
860
861
 
861
862
 
862
- def _packDetrendvoxeldata(voxnum: int, voxelargs: list) -> list[np.ndarray]:
863
+ def _packDetrendvoxeldata(voxnum: int, voxelargs: list) -> list[NDArray]:
863
864
  """
864
865
  Extract voxel data for a specific voxel number from voxel arguments.
865
866
 
@@ -929,9 +930,9 @@ def _unpackDetrendvoxeldata(retvals: tuple, voxelproducts: list) -> None:
929
930
 
930
931
 
931
932
  def normalizevoxels(
932
- fmri_data: np.ndarray,
933
+ fmri_data: NDArray,
933
934
  detrendorder: int,
934
- validvoxels: np.ndarray,
935
+ validvoxels: NDArray,
935
936
  time: object,
936
937
  timings: list,
937
938
  LGR: object | None = None,
@@ -941,7 +942,7 @@ def normalizevoxels(
941
942
  showprogressbar: bool = True,
942
943
  chunksize: int = 1000,
943
944
  debug: bool = False,
944
- ) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
945
+ ) -> tuple[NDArray, NDArray, NDArray, NDArray]:
945
946
  """
946
947
  Normalize fMRI voxel data by detrending and z-scoring.
947
948
 
@@ -951,11 +952,11 @@ def normalizevoxels(
951
952
 
952
953
  Parameters
953
954
  ----------
954
- fmri_data : np.ndarray
955
+ fmri_data : NDArray
955
956
  2D array of fMRI data with shape (n_voxels, n_timepoints).
956
957
  detrendorder : int
957
958
  Order of detrending to apply. If 0, no detrending is performed.
958
- validvoxels : np.ndarray
959
+ validvoxels : NDArray
959
960
  1D array of indices indicating which voxels are valid for processing.
960
961
  time : object
961
962
  Module or object with a `time.time()` method for timing operations.
@@ -978,7 +979,7 @@ def normalizevoxels(
978
979
 
979
980
  Returns
980
981
  -------
981
- tuple of np.ndarray
982
+ tuple of NDArray
982
983
  A tuple containing:
983
984
  - `normdata`: Normalized fMRI data (z-scored).
984
985
  - `demeandata`: Detrended and mean-centered data.
@@ -1077,13 +1078,13 @@ def normalizevoxels(
1077
1078
 
1078
1079
  def cleanphysio(
1079
1080
  Fs: float,
1080
- physiowaveform: np.ndarray,
1081
+ physiowaveform: NDArray,
1081
1082
  cutoff: float = 0.4,
1082
1083
  thresh: float = 0.2,
1083
1084
  nyquist: float | None = None,
1084
1085
  iscardiac: bool = True,
1085
1086
  debug: bool = False,
1086
- ) -> tuple[np.ndarray, np.ndarray, np.ndarray, float]:
1087
+ ) -> tuple[NDArray, NDArray, NDArray, float]:
1087
1088
  """
1088
1089
  Apply filtering and normalization to a physiological waveform to extract a cleaned signal and envelope.
1089
1090
 
@@ -1095,7 +1096,7 @@ def cleanphysio(
1095
1096
  ----------
1096
1097
  Fs : float
1097
1098
  Sampling frequency of the input waveform in Hz.
1098
- physiowaveform : np.ndarray
1099
+ physiowaveform : NDArray
1099
1100
  Input physiological waveform signal (1D array).
1100
1101
  cutoff : float, optional
1101
1102
  Cutoff frequency for envelope detection, by default 0.4.
@@ -1110,7 +1111,7 @@ def cleanphysio(
1110
1111
 
1111
1112
  Returns
1112
1113
  -------
1113
- tuple[np.ndarray, np.ndarray, np.ndarray, float]
1114
+ tuple[NDArray, NDArray, NDArray, float]
1114
1115
  A tuple containing:
1115
1116
  - `filtphysiowaveform`: The high-pass filtered waveform.
1116
1117
  - `normphysio`: The normalized waveform using the envelope.
@@ -1172,7 +1173,7 @@ def cleanphysio(
1172
1173
 
1173
1174
 
1174
1175
  def findbadpts(
1175
- thewaveform: np.ndarray,
1176
+ thewaveform: NDArray,
1176
1177
  nameroot: str,
1177
1178
  outputroot: str,
1178
1179
  samplerate: float,
@@ -1182,7 +1183,7 @@ def findbadpts(
1182
1183
  mingap: float = 2.0,
1183
1184
  outputlevel: int = 0,
1184
1185
  debug: bool = True,
1185
- ) -> tuple[np.ndarray, float | tuple[float, float]]:
1186
+ ) -> tuple[NDArray, float | tuple[float, float]]:
1186
1187
  """
1187
1188
  Identify bad points in a waveform based on statistical thresholding and gap filling.
1188
1189
 
@@ -1192,7 +1193,7 @@ def findbadpts(
1192
1193
 
1193
1194
  Parameters
1194
1195
  ----------
1195
- thewaveform : np.ndarray
1196
+ thewaveform : NDArray
1196
1197
  Input waveform data as a 1D numpy array.
1197
1198
  nameroot : str
1198
1199
  Root name used for labeling output files and dictionary keys.
@@ -1217,7 +1218,7 @@ def findbadpts(
1217
1218
 
1218
1219
  Returns
1219
1220
  -------
1220
- tuple[np.ndarray, float | tuple[float, float]]
1221
+ tuple[NDArray, float | tuple[float, float]]
1221
1222
  A tuple containing:
1222
1223
  - `thebadpts`: A 1D numpy array of the same length as `thewaveform`, with 1.0 for bad points and 0.0 for good.
1223
1224
  - `thresh`: The calculated threshold value(s) used for bad point detection.
@@ -1307,7 +1308,7 @@ def findbadpts(
1307
1308
  return thebadpts
1308
1309
 
1309
1310
 
1310
- def approximateentropy(waveform: np.ndarray, m: int, r: float) -> float:
1311
+ def approximateentropy(waveform: NDArray, m: int, r: float) -> float:
1311
1312
  """
1312
1313
  Calculate the approximate entropy of a waveform.
1313
1314
 
@@ -1489,7 +1490,7 @@ def summarizerun(theinfodict: dict, getkeys: bool = False) -> str:
1489
1490
  return ",".join(outputline)
1490
1491
 
1491
1492
 
1492
- def entropy(waveform: np.ndarray) -> float:
1493
+ def entropy(waveform: NDArray) -> float:
1493
1494
  """
1494
1495
  Calculate the entropy of a waveform.
1495
1496
 
@@ -1522,7 +1523,7 @@ def entropy(waveform: np.ndarray) -> float:
1522
1523
 
1523
1524
 
1524
1525
  def calcplethquality(
1525
- waveform: np.ndarray,
1526
+ waveform: NDArray,
1526
1527
  Fs: float,
1527
1528
  infodict: dict,
1528
1529
  suffix: str,
@@ -1534,7 +1535,7 @@ def calcplethquality(
1534
1535
  outputlevel: int = 0,
1535
1536
  initfile: bool = True,
1536
1537
  debug: bool = False,
1537
- ) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
1538
+ ) -> tuple[NDArray, NDArray, NDArray]:
1538
1539
  """
1539
1540
  Calculate windowed skewness, kurtosis, and entropy quality metrics for a plethysmogram.
1540
1541
 
@@ -1701,7 +1702,7 @@ def getphysiofile(
1701
1702
  waveformfile: str,
1702
1703
  inputfreq: float,
1703
1704
  inputstart: float | None,
1704
- slicetimeaxis: np.ndarray,
1705
+ slicetimeaxis: NDArray,
1705
1706
  stdfreq: float,
1706
1707
  stdpoints: int,
1707
1708
  envcutoff: float,
@@ -1712,7 +1713,7 @@ def getphysiofile(
1712
1713
  outputlevel: int = 0,
1713
1714
  iscardiac: bool = True,
1714
1715
  debug: bool = False,
1715
- ) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
1716
+ ) -> tuple[NDArray, NDArray, NDArray, NDArray, NDArray, NDArray]:
1716
1717
  """
1717
1718
  Read, process, and resample physiological waveform data.
1718
1719
 
@@ -1919,7 +1920,7 @@ def readextmask(
1919
1920
  ysize: int,
1920
1921
  numslices: int,
1921
1922
  debug: bool = False,
1922
- ) -> np.ndarray:
1923
+ ) -> NDArray:
1923
1924
  """
1924
1925
  Read and validate external mask from NIfTI file.
1925
1926
 
@@ -1944,7 +1945,7 @@ def readextmask(
1944
1945
 
1945
1946
  Returns
1946
1947
  -------
1947
- numpy.ndarray
1948
+ NDArray
1948
1949
  The mask data array with shape (xsize, ysize, numslices)
1949
1950
 
1950
1951
  Raises
@@ -1993,8 +1994,8 @@ def readextmask(
1993
1994
 
1994
1995
 
1995
1996
  def checkcardmatch(
1996
- reference: np.ndarray,
1997
- candidate: np.ndarray,
1997
+ reference: NDArray,
1998
+ candidate: NDArray,
1998
1999
  samplerate: float,
1999
2000
  refine: bool = True,
2000
2001
  zeropadding: int = 0,
@@ -2106,16 +2107,16 @@ def checkcardmatch(
2106
2107
 
2107
2108
 
2108
2109
  def cardiaccycleaverage(
2109
- sourcephases: np.ndarray,
2110
- destinationphases: np.ndarray,
2111
- waveform: np.ndarray,
2110
+ sourcephases: NDArray,
2111
+ destinationphases: NDArray,
2112
+ waveform: NDArray,
2112
2113
  procpoints: int,
2113
2114
  congridbins: int,
2114
2115
  gridkernel: str,
2115
2116
  centric: bool,
2116
2117
  cache: bool = True,
2117
2118
  cyclic: bool = True,
2118
- ) -> np.ndarray:
2119
+ ) -> NDArray:
2119
2120
  """
2120
2121
  Compute the average waveform over a cardiac cycle using phase-based resampling.
2121
2122
 
@@ -2205,7 +2206,7 @@ def cardiaccycleaverage(
2205
2206
  return rawapp_bypoint, weight_bypoint
2206
2207
 
2207
2208
 
2208
- def circularderivs(timecourse: np.ndarray) -> tuple[np.ndarray, float, float]:
2209
+ def circularderivs(timecourse: NDArray) -> tuple[NDArray, float, float]:
2209
2210
  """
2210
2211
  Compute circular first derivatives and their extremal values.
2211
2212
 
@@ -2483,7 +2484,7 @@ def _unpackslicedataPhaseProject(retvals, voxelproducts):
2483
2484
 
2484
2485
 
2485
2486
  def preloadcongrid(
2486
- outphases: np.ndarray,
2487
+ outphases: NDArray,
2487
2488
  congridbins: int,
2488
2489
  gridkernel: str = "kaiser",
2489
2490
  cyclic: bool = True,
@@ -2909,13 +2910,13 @@ def tcsmoothingpass(
2909
2910
  Number of slices in the dataset
2910
2911
  validlocslist : list
2911
2912
  List of valid locations for processing
2912
- rawapp_byslice : numpy.ndarray
2913
+ rawapp_byslice : NDArray
2913
2914
  Raw application data organized by slice
2914
- appsmoothingfilter : numpy.ndarray
2915
+ appsmoothingfilter : NDArray
2915
2916
  Smoothing filter to be applied
2916
2917
  phaseFs : float
2917
2918
  Phase frequency parameter for smoothing operations
2918
- derivatives_byslice : numpy.ndarray
2919
+ derivatives_byslice : NDArray
2919
2920
  Derivative data organized by slice
2920
2921
  nprocs : int, optional
2921
2922
  Number of processors to use for multiprocessing (default is 1)
@@ -2928,7 +2929,7 @@ def tcsmoothingpass(
2928
2929
 
2929
2930
  Returns
2930
2931
  -------
2931
- numpy.ndarray
2932
+ NDArray
2932
2933
  Processed data after smoothing operations have been applied
2933
2934
 
2934
2935
  Notes
@@ -3232,11 +3233,11 @@ def findvessels(
3232
3233
 
3233
3234
  Parameters
3234
3235
  ----------
3235
- app : numpy.ndarray
3236
+ app : NDArray
3236
3237
  Raw app data array
3237
- normapp : numpy.ndarray
3238
+ normapp : NDArray
3238
3239
  Normalized app data array
3239
- validlocs : numpy.ndarray
3240
+ validlocs : NDArray
3240
3241
  Array of valid locations for processing
3241
3242
  numspatiallocs : int
3242
3243
  Number of spatial locations
@@ -3545,10 +3546,11 @@ def wrightmap(
3545
3546
  )
3546
3547
  for theslice in range(numslices):
3547
3548
  for thepoint in validlocslist[theslice]:
3548
- theRvalue, thepvalue = pearsonr(
3549
+ theresult = pearsonr(
3549
3550
  rawapp_byslice1[thepoint, theslice, :],
3550
3551
  rawapp_byslice2[thepoint, theslice, :],
3551
3552
  )
3553
+ theRvalue = theresult.statistic
3552
3554
  if debug:
3553
3555
  print("theRvalue = ", theRvalue)
3554
3556
  wrightcorrs_byslice[thepoint, theslice, theiteration] = theRvalue
@@ -528,7 +528,7 @@ class Coherer:
528
528
  Maximum frequency for filtering. If None, no maximum frequency filtering is applied.
529
529
  ncprefilter : Any, optional
530
530
  Pre-filtering configuration for non-coherent filtering.
531
- reftc : numpy.ndarray, optional
531
+ reftc : NDArray, optional
532
532
  Reference time course for coherence calculations.
533
533
  detrendorder : int, default=1
534
534
  Order of detrending to apply to the data. 0 for no detrending, 1 for linear detrending.
@@ -705,7 +705,7 @@ class Coherer:
705
705
 
706
706
  Parameters
707
707
  ----------
708
- reftc : numpy.ndarray
708
+ reftc : NDArray
709
709
  Reference time series data to be processed. The array will be copied and converted
710
710
  to float type to ensure proper numerical operations.
711
711