rapidtide 2.9.6__py3-none-any.whl → 3.1.3__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 (405) hide show
  1. cloud/gmscalc-HCPYA +1 -1
  2. cloud/mount-and-run +2 -0
  3. cloud/rapidtide-HCPYA +3 -3
  4. rapidtide/Colortables.py +538 -38
  5. rapidtide/OrthoImageItem.py +1094 -51
  6. rapidtide/RapidtideDataset.py +1709 -114
  7. rapidtide/__init__.py +0 -8
  8. rapidtide/_version.py +4 -4
  9. rapidtide/calccoherence.py +242 -97
  10. rapidtide/calcnullsimfunc.py +240 -140
  11. rapidtide/calcsimfunc.py +314 -129
  12. rapidtide/correlate.py +1211 -389
  13. rapidtide/data/examples/src/testLD +56 -0
  14. rapidtide/data/examples/src/test_findmaxlag.py +2 -2
  15. rapidtide/data/examples/src/test_mlregressallt.py +32 -17
  16. rapidtide/data/examples/src/testalign +1 -1
  17. rapidtide/data/examples/src/testatlasaverage +35 -7
  18. rapidtide/data/examples/src/testboth +21 -0
  19. rapidtide/data/examples/src/testcifti +11 -0
  20. rapidtide/data/examples/src/testdelayvar +13 -0
  21. rapidtide/data/examples/src/testdlfilt +25 -0
  22. rapidtide/data/examples/src/testfft +35 -0
  23. rapidtide/data/examples/src/testfileorfloat +37 -0
  24. rapidtide/data/examples/src/testfmri +92 -42
  25. rapidtide/data/examples/src/testfuncs +3 -3
  26. rapidtide/data/examples/src/testglmfilt +8 -6
  27. rapidtide/data/examples/src/testhappy +84 -51
  28. rapidtide/data/examples/src/testinitdelay +19 -0
  29. rapidtide/data/examples/src/testmodels +33 -0
  30. rapidtide/data/examples/src/testnewrefine +26 -0
  31. rapidtide/data/examples/src/testnoiseamp +2 -2
  32. rapidtide/data/examples/src/testppgproc +17 -0
  33. rapidtide/data/examples/src/testrefineonly +22 -0
  34. rapidtide/data/examples/src/testretro +26 -13
  35. rapidtide/data/examples/src/testretrolagtcs +16 -0
  36. rapidtide/data/examples/src/testrolloff +11 -0
  37. rapidtide/data/examples/src/testsimdata +45 -28
  38. rapidtide/data/models/model_cnn_pytorch/loss.png +0 -0
  39. rapidtide/data/models/model_cnn_pytorch/loss.txt +1 -0
  40. rapidtide/data/models/model_cnn_pytorch/model.pth +0 -0
  41. rapidtide/data/models/model_cnn_pytorch/model_meta.json +68 -0
  42. rapidtide/data/models/model_cnn_pytorch_fulldata/loss.png +0 -0
  43. rapidtide/data/models/model_cnn_pytorch_fulldata/loss.txt +1 -0
  44. rapidtide/data/models/model_cnn_pytorch_fulldata/model.pth +0 -0
  45. rapidtide/data/models/model_cnn_pytorch_fulldata/model_meta.json +80 -0
  46. rapidtide/data/models/model_cnnbp_pytorch_fullldata/loss.png +0 -0
  47. rapidtide/data/models/model_cnnbp_pytorch_fullldata/loss.txt +1 -0
  48. rapidtide/data/models/model_cnnbp_pytorch_fullldata/model.pth +0 -0
  49. rapidtide/data/models/model_cnnbp_pytorch_fullldata/model_meta.json +138 -0
  50. rapidtide/data/models/model_cnnfft_pytorch_fulldata/loss.png +0 -0
  51. rapidtide/data/models/model_cnnfft_pytorch_fulldata/loss.txt +1 -0
  52. rapidtide/data/models/model_cnnfft_pytorch_fulldata/model.pth +0 -0
  53. rapidtide/data/models/model_cnnfft_pytorch_fulldata/model_meta.json +128 -0
  54. rapidtide/data/models/model_ppgattention_pytorch_w128_fulldata/loss.png +0 -0
  55. rapidtide/data/models/model_ppgattention_pytorch_w128_fulldata/loss.txt +1 -0
  56. rapidtide/data/models/model_ppgattention_pytorch_w128_fulldata/model.pth +0 -0
  57. rapidtide/data/models/model_ppgattention_pytorch_w128_fulldata/model_meta.json +49 -0
  58. rapidtide/data/models/model_revised_tf2/model.keras +0 -0
  59. rapidtide/data/models/{model_serdar → model_revised_tf2}/model_meta.json +1 -1
  60. rapidtide/data/models/model_serdar2_tf2/model.keras +0 -0
  61. rapidtide/data/models/{model_serdar2 → model_serdar2_tf2}/model_meta.json +1 -1
  62. rapidtide/data/models/model_serdar_tf2/model.keras +0 -0
  63. rapidtide/data/models/{model_revised → model_serdar_tf2}/model_meta.json +1 -1
  64. rapidtide/data/reference/HCP1200v2_MTT_2mm.nii.gz +0 -0
  65. rapidtide/data/reference/HCP1200v2_binmask_2mm.nii.gz +0 -0
  66. rapidtide/data/reference/HCP1200v2_csf_2mm.nii.gz +0 -0
  67. rapidtide/data/reference/HCP1200v2_gray_2mm.nii.gz +0 -0
  68. rapidtide/data/reference/HCP1200v2_graylaghist.json +7 -0
  69. rapidtide/data/reference/HCP1200v2_graylaghist.tsv.gz +0 -0
  70. rapidtide/data/reference/HCP1200v2_laghist.json +7 -0
  71. rapidtide/data/reference/HCP1200v2_laghist.tsv.gz +0 -0
  72. rapidtide/data/reference/HCP1200v2_mask_2mm.nii.gz +0 -0
  73. rapidtide/data/reference/HCP1200v2_maxcorr_2mm.nii.gz +0 -0
  74. rapidtide/data/reference/HCP1200v2_maxtime_2mm.nii.gz +0 -0
  75. rapidtide/data/reference/HCP1200v2_maxwidth_2mm.nii.gz +0 -0
  76. rapidtide/data/reference/HCP1200v2_negmask_2mm.nii.gz +0 -0
  77. rapidtide/data/reference/HCP1200v2_timepercentile_2mm.nii.gz +0 -0
  78. rapidtide/data/reference/HCP1200v2_white_2mm.nii.gz +0 -0
  79. rapidtide/data/reference/HCP1200v2_whitelaghist.json +7 -0
  80. rapidtide/data/reference/HCP1200v2_whitelaghist.tsv.gz +0 -0
  81. rapidtide/data/reference/JHU-ArterialTerritoriesNoVent-LVL1-seg2.xml +131 -0
  82. rapidtide/data/reference/JHU-ArterialTerritoriesNoVent-LVL1-seg2_regions.txt +60 -0
  83. rapidtide/data/reference/JHU-ArterialTerritoriesNoVent-LVL1-seg2_space-MNI152NLin6Asym_2mm.nii.gz +0 -0
  84. rapidtide/data/reference/JHU-ArterialTerritoriesNoVent-LVL1_space-MNI152NLin2009cAsym_2mm.nii.gz +0 -0
  85. rapidtide/data/reference/JHU-ArterialTerritoriesNoVent-LVL1_space-MNI152NLin2009cAsym_2mm_mask.nii.gz +0 -0
  86. rapidtide/data/reference/JHU-ArterialTerritoriesNoVent-LVL1_space-MNI152NLin6Asym_2mm_mask.nii.gz +0 -0
  87. rapidtide/data/reference/JHU-ArterialTerritoriesNoVent-LVL2_space-MNI152NLin6Asym_2mm_mask.nii.gz +0 -0
  88. rapidtide/data/reference/MNI152_T1_1mm_Brain_FAST_seg.nii.gz +0 -0
  89. rapidtide/data/reference/MNI152_T1_1mm_Brain_Mask.nii.gz +0 -0
  90. rapidtide/data/reference/MNI152_T1_2mm_Brain_FAST_seg.nii.gz +0 -0
  91. rapidtide/data/reference/MNI152_T1_2mm_Brain_Mask.nii.gz +0 -0
  92. rapidtide/decorators.py +91 -0
  93. rapidtide/dlfilter.py +2553 -414
  94. rapidtide/dlfiltertorch.py +5201 -0
  95. rapidtide/externaltools.py +328 -13
  96. rapidtide/fMRIData_class.py +108 -92
  97. rapidtide/ffttools.py +168 -0
  98. rapidtide/filter.py +2704 -1462
  99. rapidtide/fit.py +2361 -579
  100. rapidtide/genericmultiproc.py +197 -0
  101. rapidtide/happy_supportfuncs.py +3255 -548
  102. rapidtide/helper_classes.py +587 -1116
  103. rapidtide/io.py +2569 -468
  104. rapidtide/linfitfiltpass.py +784 -0
  105. rapidtide/makelaggedtcs.py +267 -97
  106. rapidtide/maskutil.py +555 -25
  107. rapidtide/miscmath.py +835 -144
  108. rapidtide/multiproc.py +217 -44
  109. rapidtide/patchmatch.py +752 -0
  110. rapidtide/peakeval.py +32 -32
  111. rapidtide/ppgproc.py +2205 -0
  112. rapidtide/qualitycheck.py +353 -40
  113. rapidtide/refinedelay.py +854 -0
  114. rapidtide/refineregressor.py +939 -0
  115. rapidtide/resample.py +725 -204
  116. rapidtide/scripts/__init__.py +1 -0
  117. rapidtide/scripts/{adjustoffset → adjustoffset.py} +7 -2
  118. rapidtide/scripts/{aligntcs → aligntcs.py} +7 -2
  119. rapidtide/scripts/{applydlfilter → applydlfilter.py} +7 -2
  120. rapidtide/scripts/applyppgproc.py +28 -0
  121. rapidtide/scripts/{atlasaverage → atlasaverage.py} +7 -2
  122. rapidtide/scripts/{atlastool → atlastool.py} +7 -2
  123. rapidtide/scripts/{calcicc → calcicc.py} +7 -2
  124. rapidtide/scripts/{calctexticc → calctexticc.py} +7 -2
  125. rapidtide/scripts/{calcttest → calcttest.py} +7 -2
  126. rapidtide/scripts/{ccorrica → ccorrica.py} +7 -2
  127. rapidtide/scripts/delayvar.py +28 -0
  128. rapidtide/scripts/{diffrois → diffrois.py} +7 -2
  129. rapidtide/scripts/{endtidalproc → endtidalproc.py} +7 -2
  130. rapidtide/scripts/{fdica → fdica.py} +7 -2
  131. rapidtide/scripts/{filtnifti → filtnifti.py} +7 -2
  132. rapidtide/scripts/{filttc → filttc.py} +7 -2
  133. rapidtide/scripts/{fingerprint → fingerprint.py} +20 -16
  134. rapidtide/scripts/{fixtr → fixtr.py} +7 -2
  135. rapidtide/scripts/{gmscalc → gmscalc.py} +7 -2
  136. rapidtide/scripts/{happy → happy.py} +7 -2
  137. rapidtide/scripts/{happy2std → happy2std.py} +7 -2
  138. rapidtide/scripts/{happywarp → happywarp.py} +8 -4
  139. rapidtide/scripts/{histnifti → histnifti.py} +7 -2
  140. rapidtide/scripts/{histtc → histtc.py} +7 -2
  141. rapidtide/scripts/{glmfilt → linfitfilt.py} +7 -4
  142. rapidtide/scripts/{localflow → localflow.py} +7 -2
  143. rapidtide/scripts/{mergequality → mergequality.py} +7 -2
  144. rapidtide/scripts/{pairproc → pairproc.py} +7 -2
  145. rapidtide/scripts/{pairwisemergenifti → pairwisemergenifti.py} +7 -2
  146. rapidtide/scripts/{physiofreq → physiofreq.py} +7 -2
  147. rapidtide/scripts/{pixelcomp → pixelcomp.py} +7 -2
  148. rapidtide/scripts/{plethquality → plethquality.py} +7 -2
  149. rapidtide/scripts/{polyfitim → polyfitim.py} +7 -2
  150. rapidtide/scripts/{proj2flow → proj2flow.py} +7 -2
  151. rapidtide/scripts/{rankimage → rankimage.py} +7 -2
  152. rapidtide/scripts/{rapidtide → rapidtide.py} +7 -2
  153. rapidtide/scripts/{rapidtide2std → rapidtide2std.py} +7 -2
  154. rapidtide/scripts/{resamplenifti → resamplenifti.py} +7 -2
  155. rapidtide/scripts/{resampletc → resampletc.py} +7 -2
  156. rapidtide/scripts/retrolagtcs.py +28 -0
  157. rapidtide/scripts/retroregress.py +28 -0
  158. rapidtide/scripts/{roisummarize → roisummarize.py} +7 -2
  159. rapidtide/scripts/{runqualitycheck → runqualitycheck.py} +7 -2
  160. rapidtide/scripts/{showarbcorr → showarbcorr.py} +7 -2
  161. rapidtide/scripts/{showhist → showhist.py} +7 -2
  162. rapidtide/scripts/{showstxcorr → showstxcorr.py} +7 -2
  163. rapidtide/scripts/{showtc → showtc.py} +7 -2
  164. rapidtide/scripts/{showxcorr_legacy → showxcorr_legacy.py} +8 -8
  165. rapidtide/scripts/{showxcorrx → showxcorrx.py} +7 -2
  166. rapidtide/scripts/{showxy → showxy.py} +7 -2
  167. rapidtide/scripts/{simdata → simdata.py} +7 -2
  168. rapidtide/scripts/{spatialdecomp → spatialdecomp.py} +7 -2
  169. rapidtide/scripts/{spatialfit → spatialfit.py} +7 -2
  170. rapidtide/scripts/{spatialmi → spatialmi.py} +7 -2
  171. rapidtide/scripts/{spectrogram → spectrogram.py} +7 -2
  172. rapidtide/scripts/stupidramtricks.py +238 -0
  173. rapidtide/scripts/{synthASL → synthASL.py} +7 -2
  174. rapidtide/scripts/{tcfrom2col → tcfrom2col.py} +7 -2
  175. rapidtide/scripts/{tcfrom3col → tcfrom3col.py} +7 -2
  176. rapidtide/scripts/{temporaldecomp → temporaldecomp.py} +7 -2
  177. rapidtide/scripts/{testhrv → testhrv.py} +1 -1
  178. rapidtide/scripts/{threeD → threeD.py} +7 -2
  179. rapidtide/scripts/{tidepool → tidepool.py} +7 -2
  180. rapidtide/scripts/{variabilityizer → variabilityizer.py} +7 -2
  181. rapidtide/simFuncClasses.py +2113 -0
  182. rapidtide/simfuncfit.py +312 -108
  183. rapidtide/stats.py +579 -247
  184. rapidtide/tests/.coveragerc +27 -6
  185. rapidtide-2.9.6.data/scripts/fdica → rapidtide/tests/cleanposttest +4 -6
  186. rapidtide/tests/happycomp +9 -0
  187. rapidtide/tests/resethappytargets +1 -1
  188. rapidtide/tests/resetrapidtidetargets +1 -1
  189. rapidtide/tests/resettargets +1 -1
  190. rapidtide/tests/runlocaltest +3 -3
  191. rapidtide/tests/showkernels +1 -1
  192. rapidtide/tests/test_aliasedcorrelate.py +4 -4
  193. rapidtide/tests/test_aligntcs.py +1 -1
  194. rapidtide/tests/test_calcicc.py +1 -1
  195. rapidtide/tests/test_cleanregressor.py +184 -0
  196. rapidtide/tests/test_congrid.py +70 -81
  197. rapidtide/tests/test_correlate.py +1 -1
  198. rapidtide/tests/test_corrpass.py +4 -4
  199. rapidtide/tests/test_delayestimation.py +54 -59
  200. rapidtide/tests/test_dlfiltertorch.py +437 -0
  201. rapidtide/tests/test_doresample.py +2 -2
  202. rapidtide/tests/test_externaltools.py +69 -0
  203. rapidtide/tests/test_fastresampler.py +9 -5
  204. rapidtide/tests/test_filter.py +96 -57
  205. rapidtide/tests/test_findmaxlag.py +50 -19
  206. rapidtide/tests/test_fullrunhappy_v1.py +15 -10
  207. rapidtide/tests/test_fullrunhappy_v2.py +19 -13
  208. rapidtide/tests/test_fullrunhappy_v3.py +28 -13
  209. rapidtide/tests/test_fullrunhappy_v4.py +30 -11
  210. rapidtide/tests/test_fullrunhappy_v5.py +62 -0
  211. rapidtide/tests/test_fullrunrapidtide_v1.py +61 -7
  212. rapidtide/tests/test_fullrunrapidtide_v2.py +26 -14
  213. rapidtide/tests/test_fullrunrapidtide_v3.py +28 -8
  214. rapidtide/tests/test_fullrunrapidtide_v4.py +16 -8
  215. rapidtide/tests/test_fullrunrapidtide_v5.py +15 -6
  216. rapidtide/tests/test_fullrunrapidtide_v6.py +142 -0
  217. rapidtide/tests/test_fullrunrapidtide_v7.py +114 -0
  218. rapidtide/tests/test_fullrunrapidtide_v8.py +66 -0
  219. rapidtide/tests/test_getparsers.py +158 -0
  220. rapidtide/tests/test_io.py +59 -18
  221. rapidtide/tests/{test_glmpass.py → test_linfitfiltpass.py} +10 -10
  222. rapidtide/tests/test_mi.py +1 -1
  223. rapidtide/tests/test_miscmath.py +1 -1
  224. rapidtide/tests/test_motionregress.py +5 -5
  225. rapidtide/tests/test_nullcorr.py +6 -9
  226. rapidtide/tests/test_padvec.py +216 -0
  227. rapidtide/tests/test_parserfuncs.py +101 -0
  228. rapidtide/tests/test_phaseanalysis.py +1 -1
  229. rapidtide/tests/test_rapidtideparser.py +59 -53
  230. rapidtide/tests/test_refinedelay.py +296 -0
  231. rapidtide/tests/test_runmisc.py +5 -5
  232. rapidtide/tests/test_sharedmem.py +60 -0
  233. rapidtide/tests/test_simroundtrip.py +132 -0
  234. rapidtide/tests/test_simulate.py +1 -1
  235. rapidtide/tests/test_stcorrelate.py +4 -2
  236. rapidtide/tests/test_timeshift.py +2 -2
  237. rapidtide/tests/test_valtoindex.py +1 -1
  238. rapidtide/tests/test_zRapidtideDataset.py +5 -3
  239. rapidtide/tests/utils.py +10 -9
  240. rapidtide/tidepoolTemplate.py +88 -70
  241. rapidtide/tidepoolTemplate.ui +60 -46
  242. rapidtide/tidepoolTemplate_alt.py +88 -53
  243. rapidtide/tidepoolTemplate_alt.ui +62 -52
  244. rapidtide/tidepoolTemplate_alt_qt6.py +921 -0
  245. rapidtide/tidepoolTemplate_big.py +1125 -0
  246. rapidtide/tidepoolTemplate_big.ui +2386 -0
  247. rapidtide/tidepoolTemplate_big_qt6.py +1129 -0
  248. rapidtide/tidepoolTemplate_qt6.py +793 -0
  249. rapidtide/util.py +1389 -148
  250. rapidtide/voxelData.py +1048 -0
  251. rapidtide/wiener.py +138 -25
  252. rapidtide/wiener2.py +114 -8
  253. rapidtide/workflows/adjustoffset.py +107 -5
  254. rapidtide/workflows/aligntcs.py +86 -3
  255. rapidtide/workflows/applydlfilter.py +231 -89
  256. rapidtide/workflows/applyppgproc.py +540 -0
  257. rapidtide/workflows/atlasaverage.py +309 -48
  258. rapidtide/workflows/atlastool.py +130 -9
  259. rapidtide/workflows/calcSimFuncMap.py +490 -0
  260. rapidtide/workflows/calctexticc.py +202 -10
  261. rapidtide/workflows/ccorrica.py +123 -15
  262. rapidtide/workflows/cleanregressor.py +415 -0
  263. rapidtide/workflows/delayvar.py +1268 -0
  264. rapidtide/workflows/diffrois.py +84 -6
  265. rapidtide/workflows/endtidalproc.py +149 -9
  266. rapidtide/workflows/fdica.py +197 -17
  267. rapidtide/workflows/filtnifti.py +71 -4
  268. rapidtide/workflows/filttc.py +76 -5
  269. rapidtide/workflows/fitSimFuncMap.py +578 -0
  270. rapidtide/workflows/fixtr.py +74 -4
  271. rapidtide/workflows/gmscalc.py +116 -6
  272. rapidtide/workflows/happy.py +1242 -480
  273. rapidtide/workflows/happy2std.py +145 -13
  274. rapidtide/workflows/happy_parser.py +277 -59
  275. rapidtide/workflows/histnifti.py +120 -4
  276. rapidtide/workflows/histtc.py +85 -4
  277. rapidtide/workflows/{glmfilt.py → linfitfilt.py} +128 -14
  278. rapidtide/workflows/localflow.py +329 -29
  279. rapidtide/workflows/mergequality.py +80 -4
  280. rapidtide/workflows/niftidecomp.py +323 -19
  281. rapidtide/workflows/niftistats.py +178 -8
  282. rapidtide/workflows/pairproc.py +99 -5
  283. rapidtide/workflows/pairwisemergenifti.py +86 -3
  284. rapidtide/workflows/parser_funcs.py +1488 -56
  285. rapidtide/workflows/physiofreq.py +139 -12
  286. rapidtide/workflows/pixelcomp.py +211 -9
  287. rapidtide/workflows/plethquality.py +105 -23
  288. rapidtide/workflows/polyfitim.py +159 -19
  289. rapidtide/workflows/proj2flow.py +76 -3
  290. rapidtide/workflows/rankimage.py +115 -8
  291. rapidtide/workflows/rapidtide.py +1785 -1858
  292. rapidtide/workflows/rapidtide2std.py +101 -3
  293. rapidtide/workflows/rapidtide_parser.py +590 -389
  294. rapidtide/workflows/refineDelayMap.py +249 -0
  295. rapidtide/workflows/refineRegressor.py +1215 -0
  296. rapidtide/workflows/regressfrommaps.py +308 -0
  297. rapidtide/workflows/resamplenifti.py +86 -4
  298. rapidtide/workflows/resampletc.py +92 -4
  299. rapidtide/workflows/retrolagtcs.py +442 -0
  300. rapidtide/workflows/retroregress.py +1501 -0
  301. rapidtide/workflows/roisummarize.py +176 -7
  302. rapidtide/workflows/runqualitycheck.py +72 -7
  303. rapidtide/workflows/showarbcorr.py +172 -16
  304. rapidtide/workflows/showhist.py +87 -3
  305. rapidtide/workflows/showstxcorr.py +161 -4
  306. rapidtide/workflows/showtc.py +172 -10
  307. rapidtide/workflows/showxcorrx.py +250 -62
  308. rapidtide/workflows/showxy.py +186 -16
  309. rapidtide/workflows/simdata.py +418 -112
  310. rapidtide/workflows/spatialfit.py +83 -8
  311. rapidtide/workflows/spatialmi.py +252 -29
  312. rapidtide/workflows/spectrogram.py +306 -33
  313. rapidtide/workflows/synthASL.py +157 -6
  314. rapidtide/workflows/tcfrom2col.py +77 -3
  315. rapidtide/workflows/tcfrom3col.py +75 -3
  316. rapidtide/workflows/tidepool.py +3829 -666
  317. rapidtide/workflows/utils.py +45 -19
  318. rapidtide/workflows/utils_doc.py +293 -0
  319. rapidtide/workflows/variabilityizer.py +118 -5
  320. {rapidtide-2.9.6.dist-info → rapidtide-3.1.3.dist-info}/METADATA +30 -223
  321. rapidtide-3.1.3.dist-info/RECORD +393 -0
  322. {rapidtide-2.9.6.dist-info → rapidtide-3.1.3.dist-info}/WHEEL +1 -1
  323. rapidtide-3.1.3.dist-info/entry_points.txt +65 -0
  324. rapidtide-3.1.3.dist-info/top_level.txt +2 -0
  325. rapidtide/calcandfitcorrpairs.py +0 -262
  326. rapidtide/data/examples/src/testoutputsize +0 -45
  327. rapidtide/data/models/model_revised/model.h5 +0 -0
  328. rapidtide/data/models/model_serdar/model.h5 +0 -0
  329. rapidtide/data/models/model_serdar2/model.h5 +0 -0
  330. rapidtide/data/reference/ASPECTS_nlin_asym_09c_2mm.nii.gz +0 -0
  331. rapidtide/data/reference/ASPECTS_nlin_asym_09c_2mm_mask.nii.gz +0 -0
  332. rapidtide/data/reference/ATTbasedFlowTerritories_split_nlin_asym_09c_2mm.nii.gz +0 -0
  333. rapidtide/data/reference/ATTbasedFlowTerritories_split_nlin_asym_09c_2mm_mask.nii.gz +0 -0
  334. rapidtide/data/reference/HCP1200_binmask_2mm_2009c_asym.nii.gz +0 -0
  335. rapidtide/data/reference/HCP1200_lag_2mm_2009c_asym.nii.gz +0 -0
  336. rapidtide/data/reference/HCP1200_mask_2mm_2009c_asym.nii.gz +0 -0
  337. rapidtide/data/reference/HCP1200_negmask_2mm_2009c_asym.nii.gz +0 -0
  338. rapidtide/data/reference/HCP1200_sigma_2mm_2009c_asym.nii.gz +0 -0
  339. rapidtide/data/reference/HCP1200_strength_2mm_2009c_asym.nii.gz +0 -0
  340. rapidtide/glmpass.py +0 -434
  341. rapidtide/refine_factored.py +0 -641
  342. rapidtide/scripts/retroglm +0 -23
  343. rapidtide/workflows/glmfrommaps.py +0 -202
  344. rapidtide/workflows/retroglm.py +0 -643
  345. rapidtide-2.9.6.data/scripts/adjustoffset +0 -23
  346. rapidtide-2.9.6.data/scripts/aligntcs +0 -23
  347. rapidtide-2.9.6.data/scripts/applydlfilter +0 -23
  348. rapidtide-2.9.6.data/scripts/atlasaverage +0 -23
  349. rapidtide-2.9.6.data/scripts/atlastool +0 -23
  350. rapidtide-2.9.6.data/scripts/calcicc +0 -22
  351. rapidtide-2.9.6.data/scripts/calctexticc +0 -23
  352. rapidtide-2.9.6.data/scripts/calcttest +0 -22
  353. rapidtide-2.9.6.data/scripts/ccorrica +0 -23
  354. rapidtide-2.9.6.data/scripts/diffrois +0 -23
  355. rapidtide-2.9.6.data/scripts/endtidalproc +0 -23
  356. rapidtide-2.9.6.data/scripts/filtnifti +0 -23
  357. rapidtide-2.9.6.data/scripts/filttc +0 -23
  358. rapidtide-2.9.6.data/scripts/fingerprint +0 -593
  359. rapidtide-2.9.6.data/scripts/fixtr +0 -23
  360. rapidtide-2.9.6.data/scripts/glmfilt +0 -24
  361. rapidtide-2.9.6.data/scripts/gmscalc +0 -22
  362. rapidtide-2.9.6.data/scripts/happy +0 -25
  363. rapidtide-2.9.6.data/scripts/happy2std +0 -23
  364. rapidtide-2.9.6.data/scripts/happywarp +0 -350
  365. rapidtide-2.9.6.data/scripts/histnifti +0 -23
  366. rapidtide-2.9.6.data/scripts/histtc +0 -23
  367. rapidtide-2.9.6.data/scripts/localflow +0 -23
  368. rapidtide-2.9.6.data/scripts/mergequality +0 -23
  369. rapidtide-2.9.6.data/scripts/pairproc +0 -23
  370. rapidtide-2.9.6.data/scripts/pairwisemergenifti +0 -23
  371. rapidtide-2.9.6.data/scripts/physiofreq +0 -23
  372. rapidtide-2.9.6.data/scripts/pixelcomp +0 -23
  373. rapidtide-2.9.6.data/scripts/plethquality +0 -23
  374. rapidtide-2.9.6.data/scripts/polyfitim +0 -23
  375. rapidtide-2.9.6.data/scripts/proj2flow +0 -23
  376. rapidtide-2.9.6.data/scripts/rankimage +0 -23
  377. rapidtide-2.9.6.data/scripts/rapidtide +0 -23
  378. rapidtide-2.9.6.data/scripts/rapidtide2std +0 -23
  379. rapidtide-2.9.6.data/scripts/resamplenifti +0 -23
  380. rapidtide-2.9.6.data/scripts/resampletc +0 -23
  381. rapidtide-2.9.6.data/scripts/retroglm +0 -23
  382. rapidtide-2.9.6.data/scripts/roisummarize +0 -23
  383. rapidtide-2.9.6.data/scripts/runqualitycheck +0 -23
  384. rapidtide-2.9.6.data/scripts/showarbcorr +0 -23
  385. rapidtide-2.9.6.data/scripts/showhist +0 -23
  386. rapidtide-2.9.6.data/scripts/showstxcorr +0 -23
  387. rapidtide-2.9.6.data/scripts/showtc +0 -23
  388. rapidtide-2.9.6.data/scripts/showxcorr_legacy +0 -536
  389. rapidtide-2.9.6.data/scripts/showxcorrx +0 -23
  390. rapidtide-2.9.6.data/scripts/showxy +0 -23
  391. rapidtide-2.9.6.data/scripts/simdata +0 -23
  392. rapidtide-2.9.6.data/scripts/spatialdecomp +0 -23
  393. rapidtide-2.9.6.data/scripts/spatialfit +0 -23
  394. rapidtide-2.9.6.data/scripts/spatialmi +0 -23
  395. rapidtide-2.9.6.data/scripts/spectrogram +0 -23
  396. rapidtide-2.9.6.data/scripts/synthASL +0 -23
  397. rapidtide-2.9.6.data/scripts/tcfrom2col +0 -23
  398. rapidtide-2.9.6.data/scripts/tcfrom3col +0 -23
  399. rapidtide-2.9.6.data/scripts/temporaldecomp +0 -23
  400. rapidtide-2.9.6.data/scripts/threeD +0 -236
  401. rapidtide-2.9.6.data/scripts/tidepool +0 -23
  402. rapidtide-2.9.6.data/scripts/variabilityizer +0 -23
  403. rapidtide-2.9.6.dist-info/RECORD +0 -359
  404. rapidtide-2.9.6.dist-info/top_level.txt +0 -86
  405. {rapidtide-2.9.6.dist-info → rapidtide-3.1.3.dist-info/licenses}/LICENSE +0 -0
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
  #
4
- # Copyright 2020-2024 Blaise Frederick
4
+ # Copyright 2020-2025 Blaise Frederick
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -18,9 +18,12 @@
18
18
  #
19
19
  import argparse
20
20
  import os
21
+ from argparse import Namespace
22
+ from typing import Any, Callable, Dict, List, Optional, Tuple, Union
21
23
 
22
24
  import matplotlib.pyplot as plt
23
25
  import numpy as np
26
+ from numpy.typing import NDArray
24
27
  from scipy.signal import savgol_filter, welch
25
28
 
26
29
  import rapidtide.filter as tide_filt
@@ -29,7 +32,32 @@ import rapidtide.io as tide_io
29
32
  import rapidtide.miscmath as tide_math
30
33
 
31
34
 
32
- def _get_parser():
35
+ def _get_parser() -> Any:
36
+ """
37
+ Create and configure argument parser for physiofreq command line tool.
38
+
39
+ This function initializes an ArgumentParser object with all necessary
40
+ command line arguments for the physiofreq tool, which is designed to
41
+ find the dominant frequency in cardiac or respiratory waveforms.
42
+
43
+ Returns
44
+ -------
45
+ argparse.ArgumentParser
46
+ Configured argument parser object with all required arguments
47
+ for the physiofreq tool.
48
+
49
+ Notes
50
+ -----
51
+ The parser includes arguments for input file specification, display options,
52
+ sampling rate, frequency range constraints, and smoothing settings.
53
+
54
+ Examples
55
+ --------
56
+ >>> parser = _get_parser()
57
+ >>> args = parser.parse_args(['input.txt', '--display', '--samplerate', '2.0'])
58
+ >>> print(args.textfilename)
59
+ 'input.txt'
60
+ """
33
61
  parser = argparse.ArgumentParser(
34
62
  prog="physiofreq",
35
63
  description="Finds the dominant frequency in a cardiac or respiratory waveform.",
@@ -75,15 +103,65 @@ def _get_parser():
75
103
 
76
104
 
77
105
  def getwavefreq(
78
- thewaveform,
79
- thesamplerate,
80
- minpermin=40.0,
81
- maxpermin=140.0,
82
- smooth=True,
83
- smoothlen=101,
84
- debug=False,
85
- displayplots=False,
86
- ):
106
+ thewaveform: Any,
107
+ thesamplerate: Any,
108
+ minpermin: float = 40.0,
109
+ maxpermin: float = 140.0,
110
+ smooth: bool = True,
111
+ smoothlen: int = 101,
112
+ debug: bool = False,
113
+ displayplots: bool = False,
114
+ ) -> None:
115
+ """
116
+ Compute the fundamental frequency of a waveform using Welch's method and spectral analysis.
117
+
118
+ This function estimates the fundamental frequency of a given waveform by computing
119
+ its power spectrum using Welch's method, applying filtering and smoothing, and
120
+ identifying the peak within a specified frequency range. The result is returned in
121
+ beats per minute (BPM).
122
+
123
+ Parameters
124
+ ----------
125
+ thewaveform : array-like
126
+ Input waveform data to analyze.
127
+ thesamplerate : float
128
+ Sampling rate of the waveform in Hz.
129
+ minpermin : float, optional
130
+ Minimum allowed frequency in BPM. Default is 40.0.
131
+ maxpermin : float, optional
132
+ Maximum allowed frequency in BPM. Default is 140.0.
133
+ smooth : bool, optional
134
+ If True, apply Savitzky-Golay smoothing to the spectrum. Default is True.
135
+ smoothlen : int, optional
136
+ Length of the smoothing window for Savitzky-Golay filter. Default is 101.
137
+ debug : bool, optional
138
+ If True, print debug information during computation. Default is False.
139
+ displayplots : bool, optional
140
+ If True, display intermediate plots of the power spectrum. Default is False.
141
+
142
+ Returns
143
+ -------
144
+ float
145
+ Estimated fundamental frequency in BPM.
146
+
147
+ Notes
148
+ -----
149
+ - The function internally uses `scipy.signal.welch` for power spectral density estimation.
150
+ - A Hamming window and detrending are applied before spectral analysis.
151
+ - The frequency range is constrained to the interval [minpermin, maxpermin].
152
+ - If `displayplots` is True, two plots will be shown:
153
+ 1. Initial power spectrum with peak marked.
154
+ 2. Smoothed spectrum with final peak marked.
155
+
156
+ Examples
157
+ --------
158
+ >>> import numpy as np
159
+ >>> from scipy.signal import chirp
160
+ >>> t = np.linspace(0, 5, 1000, endpoint=False)
161
+ >>> signal = chirp(t, f0=60, f1=120, t1=5, method='linear')
162
+ >>> freq = getwavefreq(signal, thesamplerate=1000, debug=True)
163
+ >>> print(f"Estimated frequency: {freq} BPM")
164
+ """
87
165
  if len(thewaveform) % 2 == 1:
88
166
  thewaveform = thewaveform[:-1]
89
167
  if len(thewaveform) > 1024:
@@ -141,7 +219,55 @@ def getwavefreq(
141
219
  return peakfreq
142
220
 
143
221
 
144
- def physiofreq(args):
222
+ def physiofreq(args: Any) -> None:
223
+ """
224
+ Calculate and display the dominant frequency of physiological data.
225
+
226
+ This function reads physiological time series data from a file and determines
227
+ the peak frequency using wavelet analysis. It supports both JSON and standard
228
+ text file formats, and displays the results in Hz, BPM, and period in seconds.
229
+
230
+ Parameters
231
+ ----------
232
+ args : Any
233
+ An object containing command line arguments with the following attributes:
234
+ - textfilename : str
235
+ Path to the input file containing physiological data
236
+ - samplerate : float, optional
237
+ Sampling rate of the data (used when file is not in JSON format)
238
+ - lowestbpm : float, optional
239
+ Minimum allowed heart rate in beats per minute (default: 30)
240
+ - highestbpm : float, optional
241
+ Maximum allowed heart rate in beats per minute (default: 200)
242
+ - nosmooth : bool, optional
243
+ If True, disables smoothing of the frequency spectrum
244
+ - displayplots : bool, optional
245
+ If True, displays frequency plots
246
+
247
+ Returns
248
+ -------
249
+ None
250
+ This function prints the frequency analysis results to stdout and does not return a value.
251
+
252
+ Notes
253
+ -----
254
+ The function automatically detects the file format based on the extension:
255
+ - JSON files are processed using `tide_io.readbidstsv()`
256
+ - Other formats are processed using `tide_io.readvecs()`
257
+
258
+ Examples
259
+ --------
260
+ >>> args = type('Args', (), {
261
+ ... 'textfilename': 'data.txt',
262
+ ... 'samplerate': 100.0,
263
+ ... 'lowestbpm': 40,
264
+ ... 'highestbpm': 180,
265
+ ... 'nosmooth': False,
266
+ ... 'displayplots': False
267
+ ... })()
268
+ >>> physiofreq(args)
269
+ data.txt: 0.83 Hz, 49.80 per minute, period is 1.20 seconds
270
+ """
145
271
  textfileinfo, textfilecolspec = tide_io.parsefilespec(args.textfilename)
146
272
  filebase, extension = os.path.splitext(textfileinfo[0])
147
273
  if extension == ".json":
@@ -152,6 +278,7 @@ def physiofreq(args):
152
278
  invec,
153
279
  compressed,
154
280
  fakecolumns,
281
+ extrainfo,
155
282
  ) = tide_io.readbidstsv(textfileinfo[0])
156
283
  else:
157
284
  invec = tide_io.readvecs(textfileinfo[0])[0]
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
  #
4
- # Copyright 2016-2024 Blaise Frederick
4
+ # Copyright 2016-2025 Blaise Frederick
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -25,12 +25,61 @@ from numpy.polynomial import Polynomial
25
25
  import rapidtide.io as tide_io
26
26
 
27
27
  mpl.use("Agg")
28
+ from typing import Any, Callable, Dict, List, Optional, Tuple, Union
29
+
28
30
  import matplotlib.pyplot as plt
31
+ from numpy.typing import NDArray
29
32
 
30
33
 
31
- def _get_parser():
34
+ def _get_parser() -> Any:
32
35
  """
33
- Argument parser for pixelcomp
36
+ Argument parser for pixelcomp.
37
+
38
+ This function creates and configures an argument parser for the pixelcomp tool,
39
+ which is used to compare two NIfTI files voxel by voxel and generate either
40
+ a contour plot or a scatter plot of the differences.
41
+
42
+ Returns
43
+ -------
44
+ argparse.ArgumentParser
45
+ Configured argument parser object with all required and optional arguments
46
+ for the pixelcomp tool.
47
+
48
+ Notes
49
+ -----
50
+ The parser supports the following positional arguments:
51
+
52
+ - ``inputfilename1`` : str
53
+ The name of the first input image NIfTI file.
54
+ - ``maskfilename1`` : str
55
+ The name of the first input mask NIfTI file.
56
+ - ``inputfilename2`` : str
57
+ The name of the second input image NIfTI file.
58
+ - ``maskfilename2`` : str
59
+ The name of the second input mask NIfTI file.
60
+ - ``outputroot`` : str
61
+ The root name of the output files.
62
+
63
+ And the following optional arguments:
64
+
65
+ - ``--scatter`` : bool, optional
66
+ Do a scatter plot instead of a contour plot. Default is False.
67
+ - ``--fitonly`` : bool, optional
68
+ Perform fit only - do not generate graph. Default is False.
69
+ - ``--nodisplay`` : bool, optional
70
+ Save graphs to file only - do not display. Default is True.
71
+ - ``--fitorder`` : int, optional
72
+ Order of line fit - default is 1 (linear). Default is 1.
73
+ - ``--usex`` : bool, optional
74
+ Use x instead of (y + x)/2 in Bland-Altman plot. Default is False.
75
+ - ``--histbins`` : int, optional
76
+ Number of bins per dimension for the contour plot - default is 51.
77
+ Default is 51.
78
+
79
+ Examples
80
+ --------
81
+ >>> parser = _get_parser()
82
+ >>> args = parser.parse_args()
34
83
  """
35
84
  parser = argparse.ArgumentParser(
36
85
  prog="pixelcomp",
@@ -57,7 +106,7 @@ def _get_parser():
57
106
  parser.add_argument(
58
107
  "--scatter",
59
108
  action="store_true",
60
- help=("Do a scatter plot intstead of a contour plot."),
109
+ help=("Do a scatter plot instead of a contour plot."),
61
110
  default=False,
62
111
  )
63
112
  parser.add_argument(
@@ -99,7 +148,58 @@ def _get_parser():
99
148
  return parser
100
149
 
101
150
 
102
- def bland_altman_plot(data1, data2, usex=False, *args, **kwargs):
151
+ def bland_altman_plot(
152
+ data1: Any, data2: Any, usex: bool = False, *args: Any, **kwargs: Any
153
+ ) -> None:
154
+ """
155
+ Create a Bland-Altman plot for comparing two sets of measurements.
156
+
157
+ This function generates a scatter plot showing the difference between two
158
+ measurements against their mean. The plot includes horizontal lines indicating
159
+ the mean difference and ±2 standard deviations, which are commonly used to
160
+ assess agreement between two measurement methods.
161
+
162
+ Parameters
163
+ ----------
164
+ data1 : array-like
165
+ First set of measurements (X values in the plot).
166
+ data2 : array-like
167
+ Second set of measurements (Y values in the plot).
168
+ usex : bool, optional
169
+ If True, use data1 as the x-values for the plot. If False (default),
170
+ use the mean of data1 and data2 as x-values.
171
+ *args : tuple
172
+ Additional arguments to pass to matplotlib's scatter function.
173
+ **kwargs : dict
174
+ Additional keyword arguments to pass to matplotlib's scatter function.
175
+
176
+ Returns
177
+ -------
178
+ None
179
+ This function displays the plot but does not return any value.
180
+
181
+ Notes
182
+ -----
183
+ The Bland-Altman plot is used to assess the agreement between two different
184
+ measurement methods. The mean difference (MD) is plotted on the y-axis, and
185
+ the mean of the two measurements is plotted on the x-axis. The horizontal
186
+ lines represent:
187
+ - Mean difference (MD)
188
+ - Mean difference ± 2 standard deviations (±2SD)
189
+
190
+ Examples
191
+ --------
192
+ >>> import numpy as np
193
+ >>> import matplotlib.pyplot as plt
194
+ >>> data1 = np.array([1, 2, 3, 4, 5])
195
+ >>> data2 = np.array([1.1, 2.2, 2.8, 4.1, 4.9])
196
+ >>> bland_altman_plot(data1, data2)
197
+ >>> plt.show()
198
+
199
+ >>> # Using custom scatter plot properties
200
+ >>> bland_altman_plot(data1, data2, c='red', alpha=0.7)
201
+ >>> plt.show()
202
+ """
103
203
  # data1 is X, data2 is Y
104
204
  data1 = np.asarray(data1)
105
205
  data2 = np.asarray(data2)
@@ -117,7 +217,47 @@ def bland_altman_plot(data1, data2, usex=False, *args, **kwargs):
117
217
  plt.axhline(md - 2 * sd, color="gray", linestyle="--")
118
218
 
119
219
 
120
- def pairdata(input1_data, input2_data, totalmask):
220
+ def pairdata(input1_data: Any, input2_data: Any, totalmask: Any) -> NDArray:
221
+ """
222
+ Pair corresponding elements from two 3D arrays based on a mask.
223
+
224
+ This function extracts elements from two 3D input arrays where the mask
225
+ has non-zero values, creating pairs of corresponding elements.
226
+
227
+ Parameters
228
+ ----------
229
+ input1_data : array-like
230
+ First 3D array from which elements will be extracted.
231
+ input2_data : array-like
232
+ Second 3D array from which elements will be extracted.
233
+ totalmask : array-like
234
+ 3D mask array where non-zero values indicate positions to pair.
235
+
236
+ Returns
237
+ -------
238
+ NDArray
239
+ 2D array where each row contains a pair of corresponding elements
240
+ from input1_data and input2_data at positions where totalmask > 0.
241
+
242
+ Notes
243
+ -----
244
+ - The function assumes all input arrays have the same shape
245
+ - Only positions where totalmask > 0 are considered
246
+ - The returned array has shape (n_pairs, 2) where n_pairs is the number
247
+ of non-zero mask positions
248
+
249
+ Examples
250
+ --------
251
+ >>> import numpy as np
252
+ >>> input1 = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
253
+ >>> input2 = np.array([[[9, 10], [11, 12]], [[13, 14], [15, 16]]])
254
+ >>> mask = np.array([[[1, 0], [0, 1]], [[1, 1], [0, 0]]])
255
+ >>> pairdata(input1, input2, mask)
256
+ array([[ 1, 9],
257
+ [ 4, 12],
258
+ [ 5, 13],
259
+ [ 6, 14]])
260
+ """
121
261
  nonzeropoints = np.where(totalmask > 0)
122
262
  pairlist = []
123
263
  for i in range(0, len(nonzeropoints[0])):
@@ -131,7 +271,69 @@ def pairdata(input1_data, input2_data, totalmask):
131
271
  return np.asarray(pairlist)
132
272
 
133
273
 
134
- def pixelcomp(args):
274
+ def pixelcomp(args: Any) -> None:
275
+ """
276
+ Compare pixel values from two input images using masks and generate statistical plots.
277
+
278
+ This function reads two NIfTI images and their corresponding masks, performs a pixel-wise
279
+ comparison, and generates either a scatter plot or a 2D histogram of the paired data.
280
+ It also fits a polynomial to the data and optionally produces a Bland-Altman plot.
281
+
282
+ Parameters
283
+ ----------
284
+ args : Any
285
+ An object containing the following attributes:
286
+ - inputfilename1 : str
287
+ Path to the first input NIfTI image file.
288
+ - maskfilename1 : str
289
+ Path to the first mask NIfTI file.
290
+ - inputfilename2 : str
291
+ Path to the second input NIfTI image file.
292
+ - maskfilename2 : str
293
+ Path to the second mask NIfTI file.
294
+ - outputroot : str
295
+ Root name for output files.
296
+ - histbins : int
297
+ Number of bins for the 2D histogram.
298
+ - fitorder : int
299
+ Order of the polynomial to fit.
300
+ - display : bool
301
+ If True, display plots; otherwise, save them to files.
302
+ - scatter : bool
303
+ If True, generate a scatter plot; otherwise, generate a contour plot.
304
+ - fitonly : bool
305
+ If True, only perform the polynomial fit and save coefficients.
306
+
307
+ Returns
308
+ -------
309
+ None
310
+ This function does not return any value. It saves plots and data to files.
311
+
312
+ Notes
313
+ -----
314
+ - The function requires both input images and masks to have matching spatial dimensions.
315
+ - The output includes:
316
+ * A scatter or contour plot saved as PNG.
317
+ * A file with polynomial coefficients.
318
+ * Optionally, a Bland-Altman plot saved as PNG.
319
+ - If a RankWarning occurs during polynomial fitting, the coefficients are set to [0.0, 0.0].
320
+
321
+ Examples
322
+ --------
323
+ >>> class Args:
324
+ ... inputfilename1 = "image1.nii.gz"
325
+ ... maskfilename1 = "mask1.nii.gz"
326
+ ... inputfilename2 = "image2.nii.gz"
327
+ ... maskfilename2 = "mask2.nii.gz"
328
+ ... outputroot = "output"
329
+ ... histbins = 50
330
+ ... fitorder = 1
331
+ ... display = False
332
+ ... scatter = False
333
+ ... fitonly = False
334
+ >>> args = Args()
335
+ >>> pixelcomp(args)
336
+ """
135
337
  if args.display:
136
338
  mpl.use("TkAgg")
137
339
 
@@ -194,8 +396,8 @@ def pixelcomp(args):
194
396
  thecoffs = (
195
397
  Polynomial.fit(thearray[:, 0], thearray[:, 1], args.fitorder).convert().coef[::-1]
196
398
  )
197
- except np.RankWarning:
198
- thecoffs = [0.0, 0.0]
399
+ except np.exceptions.RankWarning:
400
+ thecoffs = np.asarray([0.0, 0.0])
199
401
  print("thecoffs=", thecoffs)
200
402
  with open(f"{args.outputroot}_order_{args.fitorder}_fit", "w") as file:
201
403
  file.writelines(str(thecoffs))
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
  #
4
- # Copyright 2016-2024 Blaise Frederick
4
+ # Copyright 2016-2025 Blaise Frederick
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -18,17 +18,39 @@
18
18
  #
19
19
  import argparse
20
20
  import sys
21
+ from argparse import Namespace
22
+ from typing import Any, Callable, Dict, List, Optional, Tuple, Union
21
23
 
22
24
  import numpy as np
25
+ from numpy.typing import NDArray
23
26
  from scipy.stats import skew
24
27
 
25
28
  import rapidtide.io as tide_io
26
29
  import rapidtide.workflows.parser_funcs as pf
27
30
 
28
31
 
29
- def _get_parser():
32
+ def _get_parser() -> Any:
30
33
  """
31
- Argument parser for plethquality
34
+ Argument parser for plethquality.
35
+
36
+ This function creates and configures an argument parser for the plethquality
37
+ command-line tool that calculates quality metrics from cardiac text files.
38
+
39
+ Returns
40
+ -------
41
+ argparse.ArgumentParser
42
+ Configured argument parser object with all required and optional
43
+ arguments for plethquality functionality.
44
+
45
+ Notes
46
+ -----
47
+ The parser includes both required and optional arguments for processing
48
+ cardiac text files and generating quality metrics.
49
+
50
+ Examples
51
+ --------
52
+ >>> parser = _get_parser()
53
+ >>> args = parser.parse_args(['input.txt', 'output.txt'])
32
54
  """
33
55
  parser = argparse.ArgumentParser(
34
56
  prog="plethquality",
@@ -57,37 +79,55 @@ def _get_parser():
57
79
  return parser
58
80
 
59
81
 
60
- def plethquality(waveform, Fs, S_windowsecs=5.0, debug=False):
82
+ def plethquality(waveform: Any, Fs: Any, S_windowsecs: float = 5.0, debug: bool = False) -> None:
61
83
  """
84
+ Calculate the windowed skewness quality metrics for a photoplethysmogram (PPG) signal.
85
+
86
+ This function computes the signal quality index based on the skewness of the PPG waveform
87
+ over a sliding window, as described in Elgendi, M. "Optimal Signal Quality Index for
88
+ Photoplethysmogram Signals". Bioengineering 2016, Vol. 3, Page 21 (2016).
62
89
 
63
90
  Parameters
64
91
  ----------
65
- waveform: array-like
66
- The cardiac waveform to be assessed
67
- Fs: float
68
- The sample rate of the data
69
- S_windowsecs: float
70
- Window duration in seconds. Defaults to 2.0 (optimal according to Elgendi
71
- debug: boolean
72
- Turn on extended output
92
+ waveform : array-like
93
+ The cardiac waveform to be assessed.
94
+ Fs : float
95
+ The sample rate of the data in Hz.
96
+ S_windowsecs : float, optional
97
+ Window duration in seconds. Defaults to 5.0.
98
+ debug : bool, optional
99
+ Turn on extended output for debugging purposes. Defaults to False.
73
100
 
74
101
  Returns
75
102
  -------
76
- S_sqi_mean: float
77
- The mean value of the quality index over all time
78
- S_std_mean: float
79
- The standard deviation of the quality index over all time
80
- S_waveform: array
81
- The quality metric over all timepoints
82
-
103
+ S_sqi_mean : float
104
+ The mean value of the quality index over all time.
105
+ S_sqi_std : float
106
+ The standard deviation of the quality index over all time.
107
+ S_waveform : array
108
+ The quality metric computed over all timepoints.
109
+
110
+ Notes
111
+ -----
112
+ The window size is rounded to the nearest odd number of samples to ensure symmetric
113
+ sliding windows around each point. The skewness is calculated using `scipy.stats.skew`
114
+ with `nan_policy="omit"` to ignore NaN values.
115
+
116
+ Examples
117
+ --------
118
+ >>> import numpy as np
119
+ >>> from scipy.stats import skew
120
+ >>> waveform = np.random.randn(1000)
121
+ >>> Fs = 100.0
122
+ >>> mean_sqi, std_sqi, sqi_waveform = plethquality(waveform, Fs)
123
+ >>> print(f"Mean SQI: {mean_sqi:.3f}")
124
+ Mean SQI: 0.000
83
125
 
84
- Calculates the windowed skewness quality metrics described in Elgendi, M. "Optimal Signal Quality Index for
85
- Photoplethysmogram Signals". Bioengineering 2016, Vol. 3, Page 21 3, 21 (2016).
86
126
  """
87
127
  # calculate S_sqi over a sliding window. Window size should be an odd number of points.
88
128
  S_windowpts = int(np.round(S_windowsecs * Fs, 0))
89
129
  S_windowpts += 1 - S_windowpts % 2
90
- S_waveform = waveform * 0.0
130
+ S_waveform = np.zeros_like(waveform)
91
131
  if debug:
92
132
  print("S_windowsecs, S_windowpts:", S_windowsecs, S_windowpts)
93
133
  for i in range(0, len(waveform)):
@@ -103,7 +143,49 @@ def plethquality(waveform, Fs, S_windowsecs=5.0, debug=False):
103
143
  return S_sqi_mean, S_sqi_std, S_waveform
104
144
 
105
145
 
106
- def plethquality(args):
146
+ def plethquality(args: Any) -> None:
147
+ """
148
+ Calculate plethysmography quality score and optionally display results.
149
+
150
+ This function reads plethysmography data from a text file, calculates a quality
151
+ score based on the signal characteristics, and writes the quality scores to an
152
+ output file. Optionally displays the quality score plot.
153
+
154
+ Parameters
155
+ ----------
156
+ args : Any
157
+ An object containing command line arguments with the following attributes:
158
+ - infilename : str
159
+ Input filename containing plethysmography data
160
+ - outfilename : str
161
+ Output filename for quality scores
162
+ - samplerate : float, optional
163
+ Sampling rate of the data (if not specified, will be read from file)
164
+ - display : bool
165
+ Whether to display the quality score plot
166
+
167
+ Returns
168
+ -------
169
+ None
170
+ This function does not return a value but writes results to files and
171
+ optionally displays plots.
172
+
173
+ Notes
174
+ -----
175
+ The function uses `tide_io.readvectorsfromtextfile` to read data and
176
+ `tide_io.writevec` to write quality scores. Quality scores are calculated
177
+ using an internal `plethquality` function that analyzes signal characteristics.
178
+
179
+ Examples
180
+ --------
181
+ >>> args = argparse.Namespace(
182
+ ... infilename='pleth_data.txt',
183
+ ... outfilename='quality_scores.txt',
184
+ ... samplerate=100.0,
185
+ ... display=True
186
+ ... )
187
+ >>> plethquality(args)
188
+ """
107
189
  if args.display:
108
190
  import matplotlib as mpl
109
191