rapidtide 3.0.11__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 (144) hide show
  1. rapidtide/Colortables.py +492 -27
  2. rapidtide/OrthoImageItem.py +1049 -46
  3. rapidtide/RapidtideDataset.py +1533 -86
  4. rapidtide/_version.py +3 -3
  5. rapidtide/calccoherence.py +196 -29
  6. rapidtide/calcnullsimfunc.py +188 -40
  7. rapidtide/calcsimfunc.py +242 -42
  8. rapidtide/correlate.py +1203 -383
  9. rapidtide/data/examples/src/testLD +56 -0
  10. rapidtide/data/examples/src/testalign +1 -1
  11. rapidtide/data/examples/src/testdelayvar +0 -1
  12. rapidtide/data/examples/src/testfmri +53 -3
  13. rapidtide/data/examples/src/testglmfilt +5 -5
  14. rapidtide/data/examples/src/testhappy +29 -7
  15. rapidtide/data/examples/src/testppgproc +17 -0
  16. rapidtide/data/examples/src/testrolloff +11 -0
  17. rapidtide/data/models/model_cnn_pytorch/best_model.pth +0 -0
  18. rapidtide/data/models/model_cnn_pytorch/loss.png +0 -0
  19. rapidtide/data/models/model_cnn_pytorch/loss.txt +1 -0
  20. rapidtide/data/models/model_cnn_pytorch/model.pth +0 -0
  21. rapidtide/data/models/model_cnn_pytorch/model_meta.json +68 -0
  22. rapidtide/decorators.py +91 -0
  23. rapidtide/dlfilter.py +2226 -110
  24. rapidtide/dlfiltertorch.py +4842 -0
  25. rapidtide/externaltools.py +327 -12
  26. rapidtide/fMRIData_class.py +79 -40
  27. rapidtide/filter.py +1899 -810
  28. rapidtide/fit.py +2011 -581
  29. rapidtide/genericmultiproc.py +93 -18
  30. rapidtide/happy_supportfuncs.py +2047 -172
  31. rapidtide/helper_classes.py +584 -43
  32. rapidtide/io.py +2370 -372
  33. rapidtide/linfitfiltpass.py +346 -99
  34. rapidtide/makelaggedtcs.py +210 -24
  35. rapidtide/maskutil.py +448 -62
  36. rapidtide/miscmath.py +827 -121
  37. rapidtide/multiproc.py +210 -22
  38. rapidtide/patchmatch.py +242 -42
  39. rapidtide/peakeval.py +31 -31
  40. rapidtide/ppgproc.py +2203 -0
  41. rapidtide/qualitycheck.py +352 -39
  42. rapidtide/refinedelay.py +431 -57
  43. rapidtide/refineregressor.py +494 -189
  44. rapidtide/resample.py +671 -185
  45. rapidtide/scripts/applyppgproc.py +28 -0
  46. rapidtide/scripts/showxcorr_legacy.py +7 -7
  47. rapidtide/scripts/stupidramtricks.py +15 -17
  48. rapidtide/simFuncClasses.py +1052 -77
  49. rapidtide/simfuncfit.py +269 -69
  50. rapidtide/stats.py +540 -238
  51. rapidtide/tests/happycomp +9 -0
  52. rapidtide/tests/test_cleanregressor.py +1 -2
  53. rapidtide/tests/test_dlfiltertorch.py +627 -0
  54. rapidtide/tests/test_findmaxlag.py +24 -8
  55. rapidtide/tests/test_fullrunhappy_v1.py +0 -2
  56. rapidtide/tests/test_fullrunhappy_v2.py +0 -2
  57. rapidtide/tests/test_fullrunhappy_v3.py +11 -4
  58. rapidtide/tests/test_fullrunhappy_v4.py +10 -2
  59. rapidtide/tests/test_fullrunrapidtide_v7.py +1 -1
  60. rapidtide/tests/test_getparsers.py +11 -3
  61. rapidtide/tests/test_refinedelay.py +0 -1
  62. rapidtide/tests/test_simroundtrip.py +16 -8
  63. rapidtide/tests/test_stcorrelate.py +3 -1
  64. rapidtide/tests/utils.py +9 -8
  65. rapidtide/tidepoolTemplate.py +142 -38
  66. rapidtide/tidepoolTemplate_alt.py +165 -44
  67. rapidtide/tidepoolTemplate_big.py +189 -52
  68. rapidtide/util.py +1217 -118
  69. rapidtide/voxelData.py +684 -37
  70. rapidtide/wiener.py +136 -23
  71. rapidtide/wiener2.py +113 -7
  72. rapidtide/workflows/adjustoffset.py +105 -3
  73. rapidtide/workflows/aligntcs.py +85 -2
  74. rapidtide/workflows/applydlfilter.py +87 -10
  75. rapidtide/workflows/applyppgproc.py +540 -0
  76. rapidtide/workflows/atlasaverage.py +210 -47
  77. rapidtide/workflows/atlastool.py +100 -3
  78. rapidtide/workflows/calcSimFuncMap.py +288 -69
  79. rapidtide/workflows/calctexticc.py +201 -9
  80. rapidtide/workflows/ccorrica.py +101 -6
  81. rapidtide/workflows/cleanregressor.py +165 -31
  82. rapidtide/workflows/delayvar.py +171 -23
  83. rapidtide/workflows/diffrois.py +81 -3
  84. rapidtide/workflows/endtidalproc.py +144 -4
  85. rapidtide/workflows/fdica.py +195 -15
  86. rapidtide/workflows/filtnifti.py +70 -3
  87. rapidtide/workflows/filttc.py +74 -3
  88. rapidtide/workflows/fitSimFuncMap.py +202 -51
  89. rapidtide/workflows/fixtr.py +73 -3
  90. rapidtide/workflows/gmscalc.py +113 -3
  91. rapidtide/workflows/happy.py +801 -199
  92. rapidtide/workflows/happy2std.py +144 -12
  93. rapidtide/workflows/happy_parser.py +163 -23
  94. rapidtide/workflows/histnifti.py +118 -2
  95. rapidtide/workflows/histtc.py +84 -3
  96. rapidtide/workflows/linfitfilt.py +117 -4
  97. rapidtide/workflows/localflow.py +328 -28
  98. rapidtide/workflows/mergequality.py +79 -3
  99. rapidtide/workflows/niftidecomp.py +322 -18
  100. rapidtide/workflows/niftistats.py +174 -4
  101. rapidtide/workflows/pairproc.py +98 -4
  102. rapidtide/workflows/pairwisemergenifti.py +85 -2
  103. rapidtide/workflows/parser_funcs.py +1421 -40
  104. rapidtide/workflows/physiofreq.py +137 -11
  105. rapidtide/workflows/pixelcomp.py +207 -5
  106. rapidtide/workflows/plethquality.py +103 -21
  107. rapidtide/workflows/polyfitim.py +151 -11
  108. rapidtide/workflows/proj2flow.py +75 -2
  109. rapidtide/workflows/rankimage.py +111 -4
  110. rapidtide/workflows/rapidtide.py +368 -76
  111. rapidtide/workflows/rapidtide2std.py +98 -2
  112. rapidtide/workflows/rapidtide_parser.py +109 -9
  113. rapidtide/workflows/refineDelayMap.py +144 -33
  114. rapidtide/workflows/refineRegressor.py +675 -96
  115. rapidtide/workflows/regressfrommaps.py +161 -37
  116. rapidtide/workflows/resamplenifti.py +85 -3
  117. rapidtide/workflows/resampletc.py +91 -3
  118. rapidtide/workflows/retrolagtcs.py +99 -9
  119. rapidtide/workflows/retroregress.py +176 -26
  120. rapidtide/workflows/roisummarize.py +174 -5
  121. rapidtide/workflows/runqualitycheck.py +71 -3
  122. rapidtide/workflows/showarbcorr.py +149 -6
  123. rapidtide/workflows/showhist.py +86 -2
  124. rapidtide/workflows/showstxcorr.py +160 -3
  125. rapidtide/workflows/showtc.py +159 -3
  126. rapidtide/workflows/showxcorrx.py +190 -10
  127. rapidtide/workflows/showxy.py +185 -15
  128. rapidtide/workflows/simdata.py +264 -38
  129. rapidtide/workflows/spatialfit.py +77 -2
  130. rapidtide/workflows/spatialmi.py +250 -27
  131. rapidtide/workflows/spectrogram.py +305 -32
  132. rapidtide/workflows/synthASL.py +154 -3
  133. rapidtide/workflows/tcfrom2col.py +76 -2
  134. rapidtide/workflows/tcfrom3col.py +74 -2
  135. rapidtide/workflows/tidepool.py +2971 -130
  136. rapidtide/workflows/utils.py +19 -14
  137. rapidtide/workflows/utils_doc.py +293 -0
  138. rapidtide/workflows/variabilityizer.py +116 -3
  139. {rapidtide-3.0.11.dist-info → rapidtide-3.1.1.dist-info}/METADATA +10 -8
  140. {rapidtide-3.0.11.dist-info → rapidtide-3.1.1.dist-info}/RECORD +144 -128
  141. {rapidtide-3.0.11.dist-info → rapidtide-3.1.1.dist-info}/entry_points.txt +1 -0
  142. {rapidtide-3.0.11.dist-info → rapidtide-3.1.1.dist-info}/WHEEL +0 -0
  143. {rapidtide-3.0.11.dist-info → rapidtide-3.1.1.dist-info}/licenses/LICENSE +0 -0
  144. {rapidtide-3.0.11.dist-info → rapidtide-3.1.1.dist-info}/top_level.txt +0 -0
@@ -18,31 +18,106 @@
18
18
  #
19
19
  import gc
20
20
  import logging
21
+ from typing import Any, Callable
21
22
 
22
- import numpy as np
23
+ from numpy.typing import NDArray
23
24
  from tqdm import tqdm
24
25
 
25
26
  import rapidtide.multiproc as tide_multiproc
26
27
 
27
28
 
28
29
  def run_multiproc(
29
- voxelfunc,
30
- packfunc,
31
- unpackfunc,
32
- voxelargs,
33
- voxelproducts,
34
- inputshape,
35
- voxelmask,
36
- LGR,
37
- nprocs,
38
- alwaysmultiproc,
39
- showprogressbar,
40
- chunksize,
41
- indexaxis=0,
42
- procunit="voxels",
43
- debug=False,
44
- **kwargs,
45
- ):
30
+ voxelfunc: Callable,
31
+ packfunc: Callable,
32
+ unpackfunc: Callable,
33
+ voxelargs: list,
34
+ voxelproducts: list,
35
+ inputshape: tuple,
36
+ voxelmask: NDArray,
37
+ LGR: logging.Logger | None,
38
+ nprocs: int,
39
+ alwaysmultiproc: bool,
40
+ showprogressbar: bool,
41
+ chunksize: int,
42
+ indexaxis: int = 0,
43
+ procunit: str = "voxels",
44
+ debug: bool = False,
45
+ **kwargs: Any,
46
+ ) -> int:
47
+ """
48
+ Execute voxel-wise processing with optional multiprocessing support.
49
+
50
+ This function performs voxel-wise computations using the provided functions
51
+ for processing, packing, and unpacking data. It supports both single-threaded
52
+ and multi-process execution depending on the input parameters.
53
+
54
+ Parameters
55
+ ----------
56
+ voxelfunc : callable
57
+ Function to be applied to each voxel. It should accept a voxel index,
58
+ packed arguments, and optional debug and keyword arguments.
59
+ packfunc : callable
60
+ Function to pack voxel arguments for use in `voxelfunc`. It takes a voxel
61
+ index and `voxelargs` as input.
62
+ unpackfunc : callable
63
+ Function to unpack results from `voxelfunc` and store them in `voxelproducts`.
64
+ voxelargs : list
65
+ List of arguments to be passed to `packfunc`.
66
+ voxelproducts : list
67
+ List of arrays or data structures to be updated with results from `unpackfunc`.
68
+ inputshape : tuple
69
+ Shape of the input data, used to determine the number of voxels to process.
70
+ voxelmask : ndarray
71
+ Boolean or integer mask indicating which voxels to process.
72
+ LGR : logging.Logger or None
73
+ Logger instance for logging messages. If None, no logging is performed.
74
+ nprocs : int
75
+ Number of processes to use for multiprocessing. If 1, single-threaded execution is used.
76
+ alwaysmultiproc : bool
77
+ If True, forces multiprocessing even when `nprocs` is 1.
78
+ showprogressbar : bool
79
+ If True, displays a progress bar during processing.
80
+ chunksize : int
81
+ Size of chunks to process in each step for multiprocessing.
82
+ indexaxis : int, optional
83
+ Axis along which to iterate over voxels, default is 0.
84
+ procunit : str, optional
85
+ Unit of processing for progress bar, default is "voxels".
86
+ debug : bool, optional
87
+ If True, prints debug information, default is False.
88
+ **kwargs : dict
89
+ Additional keyword arguments passed to `voxelfunc`.
90
+
91
+ Returns
92
+ -------
93
+ int
94
+ Total number of voxels processed.
95
+
96
+ Notes
97
+ -----
98
+ - If `nprocs` > 1 or `alwaysmultiproc` is True, multiprocessing is used.
99
+ - Otherwise, a single-threaded loop is used with optional progress bar.
100
+ - The function uses `tide_multiproc.run_multiproc` internally for multiprocessing.
101
+ - Garbage collection is performed after processing.
102
+
103
+ Examples
104
+ --------
105
+ >>> run_multiproc(
106
+ ... voxelfunc=my_voxel_func,
107
+ ... packfunc=pack_voxel_args,
108
+ ... unpackfunc=unpack_results,
109
+ ... voxelargs=[arg1, arg2],
110
+ ... voxelproducts=[output_array],
111
+ ... inputshape=(100, 100, 100),
112
+ ... voxelmask=mask_array,
113
+ ... LGR=None,
114
+ ... nprocs=4,
115
+ ... alwaysmultiproc=False,
116
+ ... showprogressbar=True,
117
+ ... chunksize=10,
118
+ ... )
119
+ 1000
120
+ """
46
121
  if debug:
47
122
  print(f"{len(voxelproducts)=}, {voxelproducts[0].shape}")
48
123
  if nprocs > 1 or alwaysmultiproc: