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 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.
@@ -21,21 +21,16 @@ import logging
21
21
  import os
22
22
  import sys
23
23
  from argparse import Namespace
24
+ from typing import Any, Callable, Dict, List, Optional, Tuple, Union
24
25
 
25
26
  import nibabel as nib
26
27
  import numpy as np
28
+ from numpy.typing import NDArray
27
29
 
28
30
  import rapidtide.io as tide_io
29
31
  import rapidtide.util as tide_util
30
32
  import rapidtide.workflows.parser_funcs as pf
31
33
 
32
- try:
33
- from memory_profiler import profile
34
-
35
- memprofilerexists = True
36
- except ImportError:
37
- memprofilerexists = False
38
-
39
34
 
40
35
  # Create a sentinel.
41
36
  # from https://stackoverflow.com/questions/58594956/find-out-which-arguments-were-passed-explicitly-in-argparse
@@ -51,7 +46,7 @@ LGR = logging.getLogger(__name__)
51
46
  DEFAULT_SPATIALFILT = -1
52
47
  DEFAULT_HISTLEN = 101
53
48
  DEFAULT_DETREND_ORDER = 3
54
- DEFAULT_GLOBAL_PCACOMPONENTS = 0.8
49
+ DEFAULT_INITREGRESSOR_PCACOMPONENTS = 0.8
55
50
  DEFAULT_CORRMASK_THRESHPCT = 1.0
56
51
  DEFAULT_MUTUALINFO_SMOOTHINGTIME = 3.0
57
52
  DEFAULT_LAGMIN = -30.0
@@ -61,8 +56,8 @@ DEFAULT_SIGMAMIN = 0.0
61
56
  DEFAULT_DESPECKLE_PASSES = 4
62
57
  DEFAULT_DESPECKLE_THRESH = 5.0
63
58
  DEFAULT_PASSES = 3
64
- DEFAULT_LAGMIN_THRESH = 0.5
65
- DEFAULT_LAGMAX_THRESH = 5.0
59
+ DEFAULT_LAGMIN_THRESH = 0.25
60
+ DEFAULT_LAGMAX_THRESH = 3.0
66
61
  DEFAULT_AMPTHRESH = 0.3
67
62
  DEFAULT_PICKLEFT_THRESH = 0.33
68
63
  DEFAULT_SIGMATHRESH = 100.0
@@ -70,16 +65,15 @@ DEFAULT_MAXPASSES = 15
70
65
  DEFAULT_REFINE_TYPE = "pca"
71
66
  DEFAULT_INTERPTYPE = "univariate"
72
67
  DEFAULT_WINDOW_TYPE = "hamming"
73
- DEFAULT_GLOBALMASK_METHOD = "mean"
74
- DEFAULT_GLOBALSIGNAL_METHOD = "sum"
75
- DEFAULT_CORRWEIGHTING = "regressor"
68
+ DEFAULT_INITREGRESSOR_METHOD = "sum"
69
+ DEFAULT_CORRWEIGHTING = "phat"
76
70
  DEFAULT_CORRTYPE = "linear"
77
71
  DEFAULT_SIMILARITYMETRIC = "correlation"
78
72
  DEFAULT_PEAKFIT_TYPE = "gauss"
79
73
  DEFAULT_REFINE_PRENORM = "var"
80
74
  DEFAULT_REFINE_WEIGHTING = "None"
81
75
  DEFAULT_REFINE_PCACOMPONENTS = 0.8
82
- DEFAULT_GLMDERIVS = 0
76
+ DEFAULT_REGRESSIONFILTDERIVS = 0
83
77
 
84
78
  DEFAULT_DENOISING_LAGMIN = -10.0
85
79
  DEFAULT_DENOISING_LAGMAX = 10.0
@@ -92,6 +86,7 @@ DEFAULT_DELAYMAPPING_LAGMIN = -10.0
92
86
  DEFAULT_DELAYMAPPING_LAGMAX = 30.0
93
87
  DEFAULT_DELAYMAPPING_PASSES = 3
94
88
  DEFAULT_DELAYMAPPING_DESPECKLE_PASSES = 4
89
+ DEFAULT_DELAYMAPPING_SPATIALFILT = 2.5
95
90
 
96
91
  DEFAULT_CVRMAPPING_LAGMIN = -5.0
97
92
  DEFAULT_CVRMAPPING_LAGMAX = 20.0
@@ -103,10 +98,49 @@ DEFAULT_OUTPUTLEVEL = "normal"
103
98
 
104
99
  DEFAULT_SLFONOISEAMP_WINDOWSIZE = 40.0
105
100
 
101
+ DEFAULT_COARSEDELAY_TYPE = "simfunc"
102
+ DEFAULT_RIPTIDESTEP = 2.0
103
+
104
+ DEFAULT_PATCHTHRESH = 3.0
105
+ DEFAULT_REFINEDELAYMINDELAY = -5.0
106
+ DEFAULT_REFINEDELAYMAXDELAY = 5.0
107
+ DEFAULT_REFINEDELAYNUMPOINTS = 501
108
+ DEFAULT_DELAYOFFSETSPATIALFILT = -1
109
+
110
+ DEFAULT_PATCHMINSIZE = 10
111
+ DEFAULT_PATCHFWHM = 5
112
+
113
+ DEFAULT_PREWHITEN_LAGS = -1
114
+
106
115
 
107
- def _get_parser():
116
+ def _get_parser() -> Any:
108
117
  """
109
- Argument parser for rapidtide
118
+ Set up the argument parser for rapidtide command-line interface.
119
+
120
+ This function configures all available command-line arguments for the rapidtide
121
+ tool, organizing them into logical groups for easy reference and use.
122
+
123
+ Returns
124
+ -------
125
+ argparse.ArgumentParser
126
+ Configured argument parser with all rapidtide options added
127
+
128
+ Notes
129
+ -----
130
+ The parser includes several groups of options:
131
+ - Input/Output options
132
+ - Processing options
133
+ - Performance options
134
+ - Miscellaneous options
135
+ - Experimental options (not fully tested)
136
+ - Deprecated options (will be removed in future versions)
137
+ - Debugging options (for development and troubleshooting)
138
+
139
+ Examples
140
+ --------
141
+ >>> parser = setup_parser()
142
+ >>> args = parser.parse_args()
143
+ >>> print(args.version)
110
144
  """
111
145
  parser = argparse.ArgumentParser(
112
146
  prog="rapidtide",
@@ -149,7 +183,7 @@ def _get_parser():
149
183
  f"sets searchrange=({DEFAULT_DENOISING_LAGMIN}, {DEFAULT_DENOISING_LAGMAX}), "
150
184
  f"passes={DEFAULT_DENOISING_PASSES}, despeckle_passes={DEFAULT_DENOISING_DESPECKLE_PASSES}, "
151
185
  f"refineoffset=True, peakfittype={DEFAULT_DENOISING_PEAKFITTYPE}, "
152
- f"gausssigma={DEFAULT_DENOISING_SPATIALFILT}, nofitfilt=True, doglmfilt=True. "
186
+ f"gausssigma={DEFAULT_DENOISING_SPATIALFILT}, nofitfilt=True, dolinfitfilt=True. "
153
187
  "Any of these options can be overridden with the appropriate "
154
188
  "additional arguments."
155
189
  ),
@@ -163,8 +197,9 @@ def _get_parser():
163
197
  "Preset for delay mapping analysis - this is a macro that "
164
198
  f"sets searchrange=({DEFAULT_DELAYMAPPING_LAGMIN}, {DEFAULT_DELAYMAPPING_LAGMAX}), "
165
199
  f"passes={DEFAULT_DELAYMAPPING_PASSES}, despeckle_passes={DEFAULT_DELAYMAPPING_DESPECKLE_PASSES}, "
166
- "refineoffset=True, outputlevel='normal', "
167
- "doglmfilt=False. "
200
+ f"gausssigma={DEFAULT_DELAYMAPPING_SPATIALFILT}, "
201
+ "refineoffset=True, refinedelay=True, outputlevel='normal', "
202
+ "dolinfitfilt=False. "
168
203
  "Any of these options can be overridden with the appropriate "
169
204
  "additional arguments."
170
205
  ),
@@ -181,7 +216,7 @@ def _get_parser():
181
216
  f"passes=1, despeckle_passes={DEFAULT_CVRMAPPING_DESPECKLE_PASSES}, "
182
217
  f"searchrange=({DEFAULT_CVRMAPPING_LAGMIN}, {DEFAULT_CVRMAPPING_LAGMAX}), "
183
218
  f"filterfreqs=({DEFAULT_CVRMAPPING_FILTER_LOWERPASS}, {DEFAULT_CVRMAPPING_FILTER_UPPERPASS}), "
184
- "and calculates a voxelwise GLM using the optimally delayed "
219
+ "and calculates a voxelwise regression fit using the optimally delayed "
185
220
  "input regressor and the percent normalized, demeaned BOLD data as inputs. This map is output as "
186
221
  "(XXX_desc-CVR_map.nii.gz). If no input regressor is supplied, this will generate an error. "
187
222
  "These options can be overridden with the appropriate additional arguments."
@@ -190,12 +225,12 @@ def _get_parser():
190
225
  )
191
226
  analysis_type.add_argument(
192
227
  "--globalpreselect",
193
- dest="globalpreselect",
228
+ dest="initregressorpreselect",
194
229
  action="store_true",
195
230
  help=(
196
231
  "Treat this run as an initial pass to locate good candidate voxels for global mean "
197
232
  "regressor generation. This sets: passes=1, despecklepasses=0, "
198
- "refinedespeckle=False, outputlevel='normal', doglmfilt=False, saveintermediatemaps=False."
233
+ "refinedespeckle=False, outputlevel='normal', dolinfitfilt=False, saveintermediatemaps=False."
199
234
  ),
200
235
  default=False,
201
236
  )
@@ -228,7 +263,7 @@ def _get_parser():
228
263
  action="store_true",
229
264
  help=(
230
265
  "This is a NIRS analysis - this is a macro that "
231
- "sets nothresh, refineprenorm=var, ampthresh=0.7, and "
266
+ "sets nothresh, dataiszeromean=True, refineprenorm=var, ampthresh=0.7, and "
232
267
  "lagminthresh=0.1. "
233
268
  ),
234
269
  default=False,
@@ -256,7 +291,7 @@ def _get_parser():
256
291
  "2) decide which voxels in which to calculate delays, "
257
292
  "3) refine the regressor at the end of each pass, 4) determine the zero time offset value, and 5) process "
258
293
  "to remove sLFO signal. "
259
- "Setting --globalmeaninclude, --refineinclude, --corrmaskinclude or --offsetinclude explicitly will "
294
+ "Setting --initregressorinclude, --corrmaskinclude, --refineinclude or --offsetinclude explicitly will "
260
295
  "override this for the given include mask."
261
296
  ),
262
297
  default=None,
@@ -269,9 +304,8 @@ def _get_parser():
269
304
  "This specifies a gray matter mask registered to the input functional data. "
270
305
  "If VALSPEC is given, only voxels in the mask with integral values listed in VALSPEC are used, otherwise "
271
306
  "voxels with value > 0.1 are used. If this option is set, "
272
- "rapidtide will use voxels in the gray matter mask to 1) calculate the initial global mean regressor, "
273
- "and 2) for determining the zero time offset value. "
274
- "Setting --globalmeaninclude or --offsetinclude explicitly will override this for "
307
+ "rapidtide will use voxels in the gray matter mask to calculate the initial global mean regressor. "
308
+ "Setting --initregressorinclude explicitly will override this for "
275
309
  "the given include mask."
276
310
  ),
277
311
  default=None,
@@ -284,8 +318,21 @@ def _get_parser():
284
318
  "This specifies a white matter mask registered to the input functional data. "
285
319
  "If VALSPEC is given, only voxels in the mask with integral values listed in VALSPEC are used, otherwise "
286
320
  "voxels with value > 0.1 are used. "
287
- "This currently isn't used for anything, but rapidtide will keep track of it and might use if for something "
288
- "in a later version."
321
+ "This will be used to calculate the white matter timecourse before running rapidtide, and after sLFO "
322
+ "filtering (if enabled)."
323
+ ),
324
+ default=None,
325
+ )
326
+ anatomy.add_argument(
327
+ "--csfmask",
328
+ dest="csfincludespec",
329
+ metavar="MASK[:VALSPEC]",
330
+ help=(
331
+ "This specifies a CSF mask registered to the input functional data. "
332
+ "If VALSPEC is given, only voxels in the mask with integral values listed in VALSPEC are used, otherwise "
333
+ "voxels with value > 0.1 are used. "
334
+ "This will be used to calculate the CSF timecourse before running rapidtide, and after sLFO "
335
+ "filtering (if enabled)."
289
336
  ),
290
337
  default=None,
291
338
  )
@@ -298,7 +345,7 @@ def _get_parser():
298
345
  dest="realtr",
299
346
  action="store",
300
347
  metavar="TSTEP",
301
- type=lambda x: pf.is_float(parser, x),
348
+ type=lambda x: pf.is_float(parser, x, minval=0.0),
302
349
  help=(
303
350
  "Set the timestep of the data file to TSTEP. "
304
351
  "This will override the TR in an "
@@ -370,6 +417,17 @@ def _get_parser():
370
417
  ),
371
418
  default=False,
372
419
  )
420
+ preproc.add_argument(
421
+ "--dataiszeromean",
422
+ dest="dataiszeromean",
423
+ action="store_true",
424
+ help=(
425
+ "Assume that the fMRI data is zero mean (this will be the case if you used AFNI for preprocessing). "
426
+ "This affects how masks are generated. Rapidtide will attempt to detect this, but set explicitly "
427
+ "if you know this is the case."
428
+ ),
429
+ default=False,
430
+ )
373
431
 
374
432
  # Add filter options
375
433
  pf.addfilteropts(parser, filtertarget="data and regressors", details=True)
@@ -384,7 +442,7 @@ def _get_parser():
384
442
  "--detrendorder",
385
443
  dest="detrendorder",
386
444
  action="store",
387
- type=int,
445
+ type=lambda x: pf.is_int(parser, x, minval=0),
388
446
  metavar="ORDER",
389
447
  help=(f"Set order of trend removal (0 to disable). Default is {DEFAULT_DETREND_ORDER}."),
390
448
  default=DEFAULT_DETREND_ORDER,
@@ -399,40 +457,45 @@ def _get_parser():
399
457
  "Spatially filter fMRI data prior to analysis "
400
458
  "using GAUSSSIGMA in mm. Set GAUSSSIGMA negative "
401
459
  "to have rapidtide set it to half the mean voxel "
402
- "dimension (a rule of thumb for a good value)."
460
+ "dimension (a rule of thumb for a good value). Set to 0 to disable."
403
461
  ),
404
462
  default=DEFAULT_SPATIALFILT,
405
463
  )
406
464
  preproc.add_argument(
407
- "--globalmean",
408
- dest="useglobalref",
465
+ "--premask",
466
+ dest="premask",
409
467
  action="store_true",
410
468
  help=(
411
- "Generate a global mean regressor and use that as the reference "
412
- "regressor. If no external regressor is specified, this "
413
- "is enabled by default."
469
+ "Apply masking prior to spatial filtering to limit extracerebral sources (requires --brainmask)"
414
470
  ),
415
471
  default=False,
416
472
  )
417
473
  preproc.add_argument(
418
- "--globalmaskmethod",
419
- dest="globalmaskmethod",
420
- action="store",
421
- type=str,
422
- choices=["mean", "variance"],
474
+ "--premasktissueonly",
475
+ dest="premasktissueonly",
476
+ action="store_true",
423
477
  help=(
424
- "Select whether to use timecourse mean or variance to "
425
- "mask voxels prior to generating global mean. "
426
- f'Default is "{DEFAULT_GLOBALMASK_METHOD}".'
478
+ "Apply more stringent masking prior to spatial filtering, removing CSF voxels (requires --graymattermask and --whitemattermask)."
427
479
  ),
428
- default=DEFAULT_GLOBALMASK_METHOD,
480
+ default=False,
481
+ )
482
+ preproc.add_argument(
483
+ "--globalmean",
484
+ dest="useinitregressorref",
485
+ action="store_true",
486
+ help=(
487
+ "Generate a global mean regressor and use that as the reference "
488
+ "regressor. If no external regressor is specified, this "
489
+ "is enabled by default."
490
+ ),
491
+ default=False,
429
492
  )
430
493
  preproc.add_argument(
431
494
  "--globalmeaninclude",
432
- dest="globalmeanincludespec",
495
+ dest="initregressorincludespec",
433
496
  metavar="MASK[:VALSPEC]",
434
497
  help=(
435
- "Only use voxels in mask file NAME for global regressor "
498
+ "Only use voxels in mask file NAME for the initial regressor "
436
499
  "generation (if VALSPEC is given, only voxels "
437
500
  "with integral values listed in VALSPEC are used)."
438
501
  ),
@@ -440,10 +503,10 @@ def _get_parser():
440
503
  )
441
504
  preproc.add_argument(
442
505
  "--globalmeanexclude",
443
- dest="globalmeanexcludespec",
506
+ dest="initregressorexcludespec",
444
507
  metavar="MASK[:VALSPEC]",
445
508
  help=(
446
- "Do not use voxels in mask file NAME for global regressor "
509
+ "Do not use voxels in mask file NAME for the initial regressor "
447
510
  "generation (if VALSPEC is given, only voxels "
448
511
  "with integral values listed in VALSPEC are excluded)."
449
512
  ),
@@ -461,10 +524,22 @@ def _get_parser():
461
524
  default=None,
462
525
  )
463
526
  preproc.add_argument(
464
- "--motderiv",
527
+ "--motpowers",
528
+ dest="mot_power",
529
+ metavar="N",
530
+ type=lambda x: pf.is_int(parser, x, minval=1),
531
+ help=(
532
+ "Include powers of each motion regressor up to order N. Default is 1 (no expansion). "
533
+ ),
534
+ default=1,
535
+ )
536
+ preproc.add_argument(
537
+ "--nomotderiv",
465
538
  dest="mot_deriv",
466
539
  action="store_false",
467
- help=("Toggle whether derivatives will be used in motion regression. Default is True."),
540
+ help=(
541
+ "Do not use derivatives in motion regression. Default is to use temporal derivatives."
542
+ ),
468
543
  default=True,
469
544
  )
470
545
  preproc.add_argument(
@@ -483,18 +558,18 @@ def _get_parser():
483
558
  "--confoundpowers",
484
559
  dest="confound_power",
485
560
  metavar="N",
486
- type=int,
561
+ type=lambda x: pf.is_int(parser, x, minval=1),
487
562
  help=(
488
563
  "Include powers of each confound regressor up to order N. Default is 1 (no expansion). "
489
564
  ),
490
565
  default=1,
491
566
  )
492
567
  preproc.add_argument(
493
- "--confoundderiv",
568
+ "--noconfoundderiv",
494
569
  dest="confound_deriv",
495
570
  action="store_false",
496
571
  help=(
497
- "Toggle whether derivatives will be used in confound regression. Default is True. "
572
+ "Do not use derivatives in confound regression. Default is to use temporal derivatives."
498
573
  ),
499
574
  default=True,
500
575
  )
@@ -509,32 +584,32 @@ def _get_parser():
509
584
  )
510
585
  preproc.add_argument(
511
586
  "--globalsignalmethod",
512
- dest="globalsignalmethod",
587
+ dest="initregressorsignalmethod",
513
588
  action="store",
514
589
  type=str,
515
590
  choices=["sum", "meanscale", "pca", "random"],
516
591
  help=(
517
- "The method for constructing the initial global signal regressor - straight summation, "
518
- "mean scaling each voxel prior to summation, MLE PCA of the voxels in the global signal mask, "
592
+ "The method for constructing the initial signal regressor - straight summation, "
593
+ "mean scaling each voxel prior to summation, MLE PCA of the voxels in the initial regressor mask, "
519
594
  "or initializing using random noise."
520
- f'Default is "{DEFAULT_GLOBALSIGNAL_METHOD}."'
595
+ f'Default is "{DEFAULT_INITREGRESSOR_METHOD}."'
521
596
  ),
522
- default=DEFAULT_GLOBALSIGNAL_METHOD,
597
+ default=DEFAULT_INITREGRESSOR_METHOD,
523
598
  )
524
599
  preproc.add_argument(
525
600
  "--globalpcacomponents",
526
- dest="globalpcacomponents",
601
+ dest="initregressorpcacomponents",
527
602
  action="store",
528
603
  type=float,
529
604
  metavar="VALUE",
530
605
  help=(
531
- "Number of PCA components used for estimating the global signal. If VALUE >= 1, will retain this"
606
+ "Number of PCA components used for estimating the initial regressor. If VALUE >= 1, will retain this"
532
607
  "many components. If "
533
608
  "0.0 < VALUE < 1.0, enough components will be retained to explain the fraction VALUE of the "
534
609
  "total variance. If VALUE is negative, the number of components will be to retain will be selected "
535
- f"automatically using the MLE method. Default is {DEFAULT_GLOBAL_PCACOMPONENTS}."
610
+ f"automatically using the MLE method. Default is {DEFAULT_INITREGRESSOR_PCACOMPONENTS}."
536
611
  ),
537
- default=DEFAULT_GLOBAL_PCACOMPONENTS,
612
+ default=DEFAULT_INITREGRESSOR_PCACOMPONENTS,
538
613
  )
539
614
  preproc.add_argument(
540
615
  "--slicetimes",
@@ -549,7 +624,7 @@ def _get_parser():
549
624
  "--numskip",
550
625
  dest="preprocskip",
551
626
  action="store",
552
- type=int,
627
+ type=lambda x: pf.is_int(parser, x, minval=0),
553
628
  metavar="SKIP",
554
629
  help=(
555
630
  "SKIP TRs were previously deleted during "
@@ -558,19 +633,6 @@ def _get_parser():
558
633
  ),
559
634
  default=0,
560
635
  )
561
- preproc.add_argument(
562
- "--numtozero",
563
- dest="numtozero",
564
- action="store",
565
- type=int,
566
- metavar="NUMPOINTS",
567
- help=(
568
- "When calculating the moving regressor, set this number of points to zero at the beginning of the "
569
- "voxel timecourses. This prevents initial points which may not be in equilibrium from contaminating the "
570
- "calculated sLFO signal. This may improve similarity fitting and GLM noise removal. Default is 0."
571
- ),
572
- default=0,
573
- )
574
636
  preproc.add_argument(
575
637
  "--timerange",
576
638
  dest="timerange",
@@ -586,6 +648,34 @@ def _get_parser():
586
648
  ),
587
649
  default=(-1, -1),
588
650
  )
651
+ preproc.add_argument(
652
+ "--tincludemask",
653
+ dest="tincludemaskname",
654
+ action="store",
655
+ type=lambda x: pf.is_valid_file(parser, x),
656
+ metavar="FILE",
657
+ help=(
658
+ "Only correlate during epochs specified "
659
+ "in MASKFILE (NB: each line of FILE "
660
+ "contains the time and duration of an "
661
+ "epoch to include."
662
+ ),
663
+ default=None,
664
+ )
665
+ preproc.add_argument(
666
+ "--texcludemask",
667
+ dest="texcludemaskname",
668
+ action="store",
669
+ type=lambda x: pf.is_valid_file(parser, x),
670
+ metavar="FILE",
671
+ help=(
672
+ "Do not correlate during epochs specified "
673
+ "in MASKFILE (NB: each line of FILE "
674
+ "contains the time and duration of an "
675
+ "epoch to exclude."
676
+ ),
677
+ default=None,
678
+ )
589
679
  preproc.add_argument(
590
680
  "--nothresh",
591
681
  dest="nothresh",
@@ -626,7 +716,7 @@ def _get_parser():
626
716
  "--regressorfreq",
627
717
  dest="inputfreq",
628
718
  action="store",
629
- type=lambda x: pf.is_float(parser, x),
719
+ type=lambda x: pf.is_float(parser, x, minval=0.0),
630
720
  metavar="FREQ",
631
721
  help=(
632
722
  "Probe regressor in file has sample "
@@ -721,10 +811,10 @@ def _get_parser():
721
811
  dest="similaritymetric",
722
812
  action="store",
723
813
  type=str,
724
- choices=["correlation", "mutualinfo", "hybrid"],
814
+ choices=["correlation", "mutualinfo", "hybrid", "riptide"],
725
815
  help=(
726
816
  "Similarity metric for finding delay values. "
727
- 'Choices are "correlation", "mutualinfo", and "hybrid". '
817
+ 'Choices are "correlation", "mutualinfo", "hybrid", and "riptide". '
728
818
  f"Default is {DEFAULT_SIMILARITYMETRIC}."
729
819
  ),
730
820
  default=DEFAULT_SIMILARITYMETRIC,
@@ -764,16 +854,19 @@ def _get_parser():
764
854
  # Correlation fitting options
765
855
  corr_fit = parser.add_argument_group("Correlation fitting options")
766
856
 
767
- fixdelay = corr_fit.add_mutually_exclusive_group()
768
- fixdelay.add_argument(
769
- "--fixdelay",
770
- dest="fixeddelayvalue",
771
- action="store",
772
- type=float,
773
- metavar="DELAYTIME",
774
- help=("Don't fit the delay time - set it to DELAYTIME seconds for all " "voxels."),
775
- default=None,
857
+ corr_fit.add_argument(
858
+ "--initialdelay",
859
+ dest="initialdelayvalue",
860
+ type=lambda x: pf.is_valid_file_or_float(parser, x),
861
+ metavar="DELAY",
862
+ help=(
863
+ "Start the analysis with predefined delays. If DELAY is a filename, use it as an initial delay map; "
864
+ "if DELAY is a float, initialize all voxels to a delay of DELAY seconds."
865
+ ),
866
+ default=0.0,
776
867
  )
868
+
869
+ fixdelay = corr_fit.add_mutually_exclusive_group()
777
870
  fixdelay.add_argument(
778
871
  "--searchrange",
779
872
  dest="lag_extrema",
@@ -787,6 +880,13 @@ def _get_parser():
787
880
  ),
788
881
  default=(DEFAULT_LAGMIN, DEFAULT_LAGMAX),
789
882
  )
883
+ fixdelay.add_argument(
884
+ "--nodelayfit",
885
+ dest="fixdelay",
886
+ action="store_true",
887
+ help=("Fix the delay in every voxel to its initial value. Do not perform any fitting."),
888
+ default=False,
889
+ )
790
890
  corr_fit.add_argument(
791
891
  "--sigmalimit",
792
892
  dest="widthmax",
@@ -832,7 +932,7 @@ def _get_parser():
832
932
  "--despecklepasses",
833
933
  dest="despeckle_passes",
834
934
  action=pf.IndicateSpecifiedAction,
835
- type=int,
935
+ type=lambda x: pf.is_int(parser, x, minval=0),
836
936
  metavar="PASSES",
837
937
  help=(
838
938
  "Detect and refit suspect correlations to "
@@ -886,8 +986,8 @@ def _get_parser():
886
986
  reg_ref.add_argument(
887
987
  "--passes",
888
988
  dest="passes",
889
- action="store",
890
- type=int,
989
+ action=pf.IndicateSpecifiedAction,
990
+ type=lambda x: pf.is_int(parser, x, minval=1),
891
991
  metavar="PASSES",
892
992
  help=("Set the number of processing passes to PASSES. " f"Default is {DEFAULT_PASSES}."),
893
993
  default=DEFAULT_PASSES,
@@ -1008,15 +1108,6 @@ def _get_parser():
1008
1108
  help=("Disables selecting the leftmost delay peak when setting the refine offset."),
1009
1109
  default=True,
1010
1110
  )
1011
- reg_ref.add_argument(
1012
- "--pickleft",
1013
- dest="dummy",
1014
- action="store_true",
1015
- help=(
1016
- "DEPRECATED. pickleft is now on by default. Use 'nopickleft' to disable it instead."
1017
- ),
1018
- default=True,
1019
- )
1020
1111
  reg_ref.add_argument(
1021
1112
  "--pickleftthresh",
1022
1113
  dest="pickleftthresh",
@@ -1024,7 +1115,7 @@ def _get_parser():
1024
1115
  metavar="THRESH",
1025
1116
  type=float,
1026
1117
  help=(
1027
- "Threshhold value (fraction of maximum) in a histogram "
1118
+ "Threshold value (fraction of maximum) in a histogram "
1028
1119
  f"to be considered the start of a peak. Default is {DEFAULT_PICKLEFT_THRESH}."
1029
1120
  ),
1030
1121
  default=DEFAULT_PICKLEFT_THRESH,
@@ -1101,31 +1192,31 @@ def _get_parser():
1101
1192
  "--maxpasses",
1102
1193
  dest="maxpasses",
1103
1194
  action="store",
1104
- type=int,
1195
+ type=lambda x: pf.is_int(parser, x, minval=1),
1105
1196
  metavar="MAXPASSES",
1106
1197
  help=(
1107
- "Terminate refinement after MAXPASSES passes, whether or not convergence has occured. "
1198
+ "Terminate refinement after MAXPASSES passes, whether or not convergence has occurred. "
1108
1199
  f"Default is {DEFAULT_MAXPASSES}."
1109
1200
  ),
1110
1201
  default=DEFAULT_MAXPASSES,
1111
1202
  )
1112
1203
 
1113
- # GLM noise removal options
1114
- glm = parser.add_argument_group("GLM noise removal options")
1115
- glm.add_argument(
1116
- "--noglm",
1117
- dest="doglmfilt",
1204
+ # sLFO noise removal options
1205
+ slfofilt = parser.add_argument_group("sLFO noise removal options")
1206
+ slfofilt.add_argument(
1207
+ "--nodenoise",
1208
+ dest="dolinfitfilt",
1118
1209
  action="store_false",
1119
1210
  help=(
1120
- "Turn off GLM filtering to remove delayed "
1211
+ "Turn off regression filtering to remove delayed "
1121
1212
  "regressor from each voxel (disables output of "
1122
1213
  "fitNorm)."
1123
1214
  ),
1124
1215
  default=True,
1125
1216
  )
1126
- glm.add_argument(
1127
- "--glmsourcefile",
1128
- dest="glmsourcefile",
1217
+ slfofilt.add_argument(
1218
+ "--denoisesourcefile",
1219
+ dest="denoisesourcefile",
1129
1220
  action="store",
1130
1221
  type=lambda x: pf.is_valid_file(parser, x),
1131
1222
  metavar="FILE",
@@ -1136,23 +1227,63 @@ def _get_parser():
1136
1227
  ),
1137
1228
  default=None,
1138
1229
  )
1139
- glm.add_argument(
1230
+ slfofilt.add_argument(
1140
1231
  "--preservefiltering",
1141
1232
  dest="preservefiltering",
1142
1233
  action="store_true",
1143
- help="Don't reread data prior to performing GLM.",
1234
+ help="Don't reread data prior to performing sLFO filtering.",
1144
1235
  default=False,
1145
1236
  )
1146
- glm.add_argument(
1147
- "--glmderivs",
1148
- dest="glmderivs",
1237
+ slfofilt.add_argument(
1238
+ "--regressderivs",
1239
+ dest="regressderivs",
1149
1240
  action="store",
1150
- type=int,
1241
+ type=lambda x: pf.is_int(parser, x, minval=0),
1151
1242
  metavar="NDERIVS",
1152
1243
  help=(
1153
- f"When doing final GLM, include derivatives up to NDERIVS order. Default is {DEFAULT_GLMDERIVS}"
1244
+ f"When doing final sLFO filtering, include derivatives up to NDERIVS order. Default is {DEFAULT_REGRESSIONFILTDERIVS}"
1154
1245
  ),
1155
- default=DEFAULT_GLMDERIVS,
1246
+ default=DEFAULT_REGRESSIONFILTDERIVS,
1247
+ )
1248
+ slfofilt.add_argument(
1249
+ "--norefinedelay",
1250
+ dest="refinedelay",
1251
+ action="store_false",
1252
+ help=("Do not calculate a refined delay map using sLFO regression information."),
1253
+ default=True,
1254
+ )
1255
+ slfofilt.add_argument(
1256
+ "--nofilterwithrefineddelay",
1257
+ dest="filterwithrefineddelay",
1258
+ action="store_false",
1259
+ help=("Do not use the refined delay in sLFO filter."),
1260
+ default=True,
1261
+ )
1262
+ slfofilt.add_argument(
1263
+ "--delaypatchthresh",
1264
+ dest="delaypatchthresh",
1265
+ action="store",
1266
+ type=float,
1267
+ metavar="NUMMADs",
1268
+ help=(
1269
+ "Maximum number of robust standard deviations to permit in the offset delay refine map. "
1270
+ f"Default is {DEFAULT_PATCHTHRESH}"
1271
+ ),
1272
+ default=DEFAULT_PATCHTHRESH,
1273
+ )
1274
+ slfofilt.add_argument(
1275
+ "--delayoffsetspatialfilt",
1276
+ dest="delayoffsetgausssigma",
1277
+ action="store",
1278
+ type=float,
1279
+ metavar="GAUSSSIGMA",
1280
+ help=(
1281
+ "Spatially filter fMRI data prior to calculating delay offsets "
1282
+ "using GAUSSSIGMA in mm. Set GAUSSSIGMA negative "
1283
+ "to have rapidtide set it to half the mean voxel "
1284
+ "dimension (a rule of thumb for a good value). Set to 0 to disable."
1285
+ ),
1286
+ default=DEFAULT_DELAYOFFSETSPATIALFILT,
1156
1287
  )
1157
1288
 
1158
1289
  # Output options
@@ -1165,7 +1296,7 @@ def _get_parser():
1165
1296
  choices=["min", "less", "normal", "more", "max"],
1166
1297
  help=(
1167
1298
  "The level of file output produced. 'min' produces only absolutely essential files, 'less' adds in "
1168
- "the GLM filtered data (rather than just filter efficacy metrics), 'normal' saves what you "
1299
+ "the sLFO filtered data (rather than just filter efficacy metrics), 'normal' saves what you "
1169
1300
  "would typically want around for interactive data exploration, "
1170
1301
  "'more' adds files that are sometimes useful, and 'max' outputs anything you might possibly want. "
1171
1302
  "Selecting 'max' will produce ~3x your input datafile size as output. "
@@ -1173,16 +1304,6 @@ def _get_parser():
1173
1304
  ),
1174
1305
  default=DEFAULT_OUTPUTLEVEL,
1175
1306
  )
1176
- output.add_argument(
1177
- "--nolimitoutput",
1178
- dest="limitoutput",
1179
- action="store_false",
1180
- help=(
1181
- "Save some of the large and rarely used files. "
1182
- "NB: THIS IS NOW DEPRECATED: Use '--outputlevel max' instead."
1183
- ),
1184
- default=True,
1185
- )
1186
1307
  output.add_argument(
1187
1308
  "--savelags",
1188
1309
  dest="savecorrtimes",
@@ -1194,7 +1315,7 @@ def _get_parser():
1194
1315
  "--histlen", # was -h
1195
1316
  dest="histlen",
1196
1317
  action="store",
1197
- type=int,
1318
+ type=lambda x: pf.is_int(parser, x, minval=5),
1198
1319
  metavar="HISTLEN",
1199
1320
  help=(f"Change the histogram length to HISTLEN. Default is {DEFAULT_HISTLEN}."),
1200
1321
  default=DEFAULT_HISTLEN,
@@ -1203,7 +1324,7 @@ def _get_parser():
1203
1324
  "--saveintermediatemaps",
1204
1325
  dest="saveintermediatemaps",
1205
1326
  action="store_true",
1206
- help="Save lag times, strengths, widths, and mask for each pass.",
1327
+ help="Save lag times, strengths, widths, mask (and shiftedtcs, if they'd normally be saved) for each pass.",
1207
1328
  default=False,
1208
1329
  )
1209
1330
  output.add_argument(
@@ -1246,7 +1367,7 @@ def _get_parser():
1246
1367
  "--mklthreads",
1247
1368
  dest="mklthreads",
1248
1369
  action="store",
1249
- type=int,
1370
+ type=lambda x: pf.is_int(parser, x, minval=1),
1250
1371
  metavar="MKLTHREADS",
1251
1372
  help=(
1252
1373
  "If mkl library is installed, use no more than MKLTHREADS worker "
@@ -1274,6 +1395,13 @@ def _get_parser():
1274
1395
  help=("Will disable showing progress bars (helpful if stdout is going to a file)."),
1275
1396
  default=True,
1276
1397
  )
1398
+ misc.add_argument(
1399
+ "--makepseudofile",
1400
+ dest="makepseudofile",
1401
+ action="store_true",
1402
+ help=("Make a simulated input file from the mean and the movingsignal."),
1403
+ default=False,
1404
+ )
1277
1405
  misc.add_argument(
1278
1406
  "--checkpoint",
1279
1407
  dest="checkpoint",
@@ -1300,6 +1428,18 @@ def _get_parser():
1300
1428
  help=("Use double precision for output files."),
1301
1429
  default="single",
1302
1430
  )
1431
+ misc.add_argument(
1432
+ "--spatialtolerance",
1433
+ dest="spatialtolerance",
1434
+ action="store",
1435
+ type=float,
1436
+ metavar="EPSILON",
1437
+ help=(
1438
+ "When checking to see if the spatial dimensions of two NIFTI files match, allow a relative difference "
1439
+ "of EPSILON in any dimension. By default, this is set to 0.0, requiring an exact match. "
1440
+ ),
1441
+ default=0.0,
1442
+ )
1303
1443
  misc.add_argument(
1304
1444
  "--cifti",
1305
1445
  dest="isgrayordinate",
@@ -1328,19 +1468,44 @@ def _get_parser():
1328
1468
  help=("Disable use of shared memory for large array storage."),
1329
1469
  default=True,
1330
1470
  )
1331
- misc.add_argument(
1332
- "--memprofile",
1333
- dest="memprofile",
1334
- action="store_true",
1335
- help=("Enable memory profiling - " "warning: this slows things down a lot."),
1336
- default=False,
1337
- )
1338
1471
  pf.addtagopts(misc)
1339
1472
 
1340
1473
  # Experimental options (not fully tested, may not work)
1341
1474
  experimental = parser.add_argument_group(
1342
1475
  "Experimental options (not fully tested, or not tested at all, may not work). Beware!"
1343
1476
  )
1477
+ experimental.add_argument(
1478
+ "--riptidestep", # was -h
1479
+ dest="riptidestep",
1480
+ action="store",
1481
+ type=lambda x: pf.is_float(parser, x, maxval=5.0),
1482
+ metavar="STEP",
1483
+ help=(
1484
+ f"Timestep between RIPTiDe regressors, in seconds. Default is {DEFAULT_RIPTIDESTEP}."
1485
+ ),
1486
+ default=DEFAULT_RIPTIDESTEP,
1487
+ )
1488
+ experimental.add_argument(
1489
+ "--refinedelayeachpass",
1490
+ dest="refinedelayeachpass",
1491
+ action="store_true",
1492
+ help=("Do delay refinement in each pass."),
1493
+ default=False,
1494
+ )
1495
+ experimental.add_argument(
1496
+ "--dofinalrefine",
1497
+ dest="dofinalrefine",
1498
+ action="store_true",
1499
+ help=("Do regressor refinement on the final pass."),
1500
+ default=False,
1501
+ )
1502
+ experimental.add_argument(
1503
+ "--sLFOfiltmask",
1504
+ dest="sLFOfiltmask",
1505
+ action="store_true",
1506
+ help=("Limit sLFO filter to fit voxels."),
1507
+ default=False,
1508
+ )
1344
1509
  experimental.add_argument(
1345
1510
  "--territorymap",
1346
1511
  dest="territorymap",
@@ -1355,13 +1520,6 @@ def _get_parser():
1355
1520
  ),
1356
1521
  default=None,
1357
1522
  )
1358
- experimental.add_argument(
1359
- "--psdfilter",
1360
- dest="psdfilter",
1361
- action="store_true",
1362
- help=("Apply a PSD weighted Wiener filter to shifted timecourses prior to refinement."),
1363
- default=False,
1364
- )
1365
1523
  experimental.add_argument(
1366
1524
  "--wiener",
1367
1525
  dest="dodeconv",
@@ -1369,38 +1527,6 @@ def _get_parser():
1369
1527
  help=("Do Wiener deconvolution to find voxel transfer function."),
1370
1528
  default=False,
1371
1529
  )
1372
- experimental.add_argument(
1373
- "--corrbaselinespatialsigma",
1374
- dest="corrbaselinespatialsigma",
1375
- action="store",
1376
- type=float,
1377
- metavar="SIGMA",
1378
- help=("Spatial lowpass kernel, in mm, for filtering the correlation function baseline. "),
1379
- default=0.0,
1380
- )
1381
- experimental.add_argument(
1382
- "--corrbaselinetemphpfcutoff",
1383
- dest="corrbaselinetemphpfcutoff",
1384
- action="store",
1385
- type=float,
1386
- metavar="FREQ",
1387
- help=(
1388
- "Temporal highpass cutoff, in Hz, for filtering the correlation function baseline. "
1389
- ),
1390
- default=0.0,
1391
- )
1392
- experimental.add_argument(
1393
- "--spatialtolerance",
1394
- dest="spatialtolerance",
1395
- action="store",
1396
- type=float,
1397
- metavar="EPSILON",
1398
- help=(
1399
- "When checking to see if the spatial dimensions of two NIFTI files match, allow a relative difference "
1400
- "of EPSILON in any dimension. By default, this is set to 0.0, requiring an exact match. "
1401
- ),
1402
- default=0.0,
1403
- )
1404
1530
  experimental.add_argument(
1405
1531
  "--echocancel",
1406
1532
  dest="echocancel",
@@ -1415,68 +1541,6 @@ def _get_parser():
1415
1541
  help=("Attempt to detect and remove respiratory signal that strays into " "the LFO band."),
1416
1542
  default=False,
1417
1543
  )
1418
-
1419
- experimental.add_argument(
1420
- "--noisetimecourse",
1421
- dest="noisetimecoursespec",
1422
- metavar="FILENAME[:VALSPEC]",
1423
- help=(
1424
- "Find and remove any instance of the timecourse supplied from any regressors used for analysis. "
1425
- "(if VALSPEC is given, and there are multiple timecourses in the file, use the indicated timecourse."
1426
- "This can be the name of the regressor if it's in the file, or the column number). "
1427
- ),
1428
- default=None,
1429
- )
1430
- noise_group = experimental.add_mutually_exclusive_group()
1431
- noise_group.add_argument(
1432
- "--noisefreq",
1433
- dest="noisefreq",
1434
- action="store",
1435
- type=lambda x: pf.is_float(parser, x),
1436
- metavar="FREQ",
1437
- help=(
1438
- "Noise timecourse in file has sample "
1439
- "frequency FREQ (default is 1/tr) "
1440
- "NB: --noisefreq and --noisetstep) "
1441
- "are two ways to specify the same thing."
1442
- ),
1443
- default="auto",
1444
- )
1445
- noise_group.add_argument(
1446
- "--noisetstep",
1447
- dest="noisefreq",
1448
- action="store",
1449
- type=lambda x: pf.invert_float(parser, x),
1450
- metavar="TSTEP",
1451
- help=(
1452
- "Noise timecourse in file has sample "
1453
- "frequency FREQ (default is 1/tr) "
1454
- "NB: --noisefreq and --noisetstep) "
1455
- "are two ways to specify the same thing."
1456
- ),
1457
- default="auto",
1458
- )
1459
- experimental.add_argument(
1460
- "--noisestart",
1461
- dest="noisestarttime",
1462
- action="store",
1463
- type=float,
1464
- metavar="START",
1465
- help=(
1466
- "The time delay in seconds into the noise timecourse "
1467
- "file, corresponding in the first TR of the fMRI "
1468
- "file (default is 0.0)."
1469
- ),
1470
- default=0.0,
1471
- )
1472
- experimental.add_argument(
1473
- "--noiseinvert",
1474
- dest="noiseinvert",
1475
- action="store_true",
1476
- help=("Invert noise regressor prior to alignment."),
1477
- default=False,
1478
- )
1479
-
1480
1544
  experimental.add_argument(
1481
1545
  "--acfix",
1482
1546
  dest="fix_autocorrelation",
@@ -1514,6 +1578,15 @@ def _get_parser():
1514
1578
  ),
1515
1579
  default=False,
1516
1580
  )
1581
+ experimental.add_argument(
1582
+ "--donotfilterinputdata",
1583
+ dest="filterinputdata",
1584
+ action="store_false",
1585
+ help=(
1586
+ "Do not filter input data prior to similarity calculation. May make processing faster."
1587
+ ),
1588
+ default=True,
1589
+ )
1517
1590
  experimental.add_argument(
1518
1591
  "--dispersioncalc",
1519
1592
  dest="dodispersioncalc",
@@ -1522,33 +1595,76 @@ def _get_parser():
1522
1595
  default=False,
1523
1596
  )
1524
1597
  experimental.add_argument(
1525
- "--tincludemask",
1526
- dest="tincludemaskname",
1598
+ "--patchshift",
1599
+ dest="patchshift",
1600
+ action="store_true",
1601
+ help=("Perform patch shift correction."),
1602
+ default=False,
1603
+ )
1604
+ experimental.add_argument(
1605
+ "--prewhitenregressor",
1606
+ dest="prewhitenregressor",
1607
+ action="store_true",
1608
+ help=("Prewhiten probe regressor prior to calculating correlations."),
1609
+ default=False,
1610
+ )
1611
+ experimental.add_argument(
1612
+ "--prewhitenlags",
1613
+ dest="prewhitenlags",
1527
1614
  action="store",
1528
- type=lambda x: pf.is_valid_file(parser, x),
1529
- metavar="FILE",
1615
+ type=lambda x: pf.is_int(parser, x, minval=0),
1616
+ metavar="LAGS",
1530
1617
  help=(
1531
- "Only correlate during epochs specified "
1532
- "in MASKFILE (NB: each line of FILE "
1533
- "contains the time and duration of an "
1534
- "epoch to include."
1618
+ f"Set number of TRs to use in prewhitening. Set to -1 to calculate automatically. Default is {DEFAULT_PREWHITEN_LAGS}."
1535
1619
  ),
1536
- default=None,
1620
+ default=DEFAULT_PREWHITEN_LAGS,
1537
1621
  )
1538
- experimental.add_argument(
1539
- "--texcludemask",
1540
- dest="texcludemaskname",
1541
- action="store",
1542
- type=lambda x: pf.is_valid_file(parser, x),
1543
- metavar="FILE",
1622
+
1623
+ # Deprecated options
1624
+ deprecated = parser.add_argument_group(
1625
+ "Deprecated options. These options will go away in the indeterminate future. Don't use them."
1626
+ )
1627
+ deprecated.add_argument(
1628
+ "--refinedelay",
1629
+ dest="dummy",
1630
+ action="store_true",
1544
1631
  help=(
1545
- "Do not correlate during epochs specified "
1546
- "in MASKFILE (NB: each line of FILE "
1547
- "contains the time and duration of an "
1548
- "epoch to exclude."
1632
+ "Calculate a refined delay map using regression coefficient information. ***DEPRECATED***: refinedelay is now on by default."
1549
1633
  ),
1550
- default=None,
1634
+ default=True,
1635
+ )
1636
+ deprecated.add_argument(
1637
+ "--nolimitoutput",
1638
+ dest="limitoutput",
1639
+ action="store_false",
1640
+ help=(
1641
+ "Save some of the large and rarely used files. "
1642
+ "***DEPRECATED***: Use '--outputlevel max' instead."
1643
+ ),
1644
+ default=True,
1551
1645
  )
1646
+ deprecated.add_argument(
1647
+ "--pickleft",
1648
+ dest="dummy",
1649
+ action="store_true",
1650
+ help=(
1651
+ "***DEPRECATED***: pickleft is now on by default. Use 'nopickleft' to disable it instead."
1652
+ ),
1653
+ default=True,
1654
+ )
1655
+ deprecated.add_argument(
1656
+ "--noglm",
1657
+ dest="dolinfitfilt",
1658
+ action="store_false",
1659
+ help=(
1660
+ "Turn off regression filtering to remove delayed "
1661
+ "regressor from each voxel (disables output of "
1662
+ "fitNorm)."
1663
+ "***DEPRECATED***: Use '--nodenoise' instead."
1664
+ ),
1665
+ default=True,
1666
+ )
1667
+
1552
1668
  # Debugging options
1553
1669
  debugging = parser.add_argument_group(
1554
1670
  "Debugging options. You probably don't want to use any of these unless I ask you to to help diagnose a problem"
@@ -1564,7 +1680,7 @@ def _get_parser():
1564
1680
  "--focaldebug",
1565
1681
  dest="focaldebug",
1566
1682
  action="store_true",
1567
- help=("Enable targetted additional debugging output (used during development)."),
1683
+ help=("Enable targeted additional debugging output (used during development)."),
1568
1684
  default=False,
1569
1685
  )
1570
1686
  debugging.add_argument(
@@ -1575,10 +1691,10 @@ def _get_parser():
1575
1691
  default=False,
1576
1692
  )
1577
1693
  debugging.add_argument(
1578
- "--disabledockermemfix",
1579
- dest="dockermemfix",
1694
+ "--disablecontainermemfix",
1695
+ dest="containermemfix",
1580
1696
  action="store_false",
1581
- help=("Disable docker memory limit setting."),
1697
+ help=("Disable container memory limit setting."),
1582
1698
  default=True,
1583
1699
  )
1584
1700
  debugging.add_argument(
@@ -1638,10 +1754,10 @@ def _get_parser():
1638
1754
  default=False,
1639
1755
  )
1640
1756
  debugging.add_argument(
1641
- "--singleproc_glm",
1642
- dest="singleproc_glm",
1757
+ "--singleproc_regressionfilt",
1758
+ dest="singleproc_regressionfilt",
1643
1759
  action="store_true",
1644
- help=("Force single proc path for glm."),
1760
+ help=("Force single proc path for regression filtering."),
1645
1761
  default=False,
1646
1762
  )
1647
1763
  debugging.add_argument(
@@ -1662,9 +1778,51 @@ def _get_parser():
1662
1778
  return parser
1663
1779
 
1664
1780
 
1665
- def process_args(inputargs=None):
1781
+ def process_args(inputargs: Optional[Any] = None) -> Tuple[Any, object]:
1666
1782
  """
1667
1783
  Compile arguments for rapidtide workflow.
1784
+
1785
+ This function processes command-line arguments and sets up the configuration
1786
+ for the rapidtide workflow. It handles argument parsing, logging setup,
1787
+ command-line saving, and various parameter defaults and overrides based on
1788
+ analysis modes and macros.
1789
+
1790
+ Parameters
1791
+ ----------
1792
+ inputargs : optional
1793
+ Input arguments to be processed. If None, arguments are parsed from
1794
+ sys.argv. Default is None.
1795
+
1796
+ Returns
1797
+ -------
1798
+ tuple
1799
+ A tuple containing:
1800
+ - args : dict
1801
+ Dictionary of processed arguments.
1802
+ - theprefilter : object
1803
+ Preprocessing filter object.
1804
+
1805
+ Notes
1806
+ -----
1807
+ The function performs the following key operations:
1808
+ 1. Parses command-line arguments using `_get_parser`
1809
+ 2. Sets up logging based on debug flag
1810
+ 3. Saves raw and formatted command lines to files
1811
+ 4. Applies default values and overrides for various parameters
1812
+ 5. Handles analysis modes (delaymapping, denoising, cvrmap, etc.)
1813
+ 6. Processes macros (venousrefine, nirs)
1814
+ 7. Configures output options based on `outputlevel`
1815
+ 8. Sets up pass options and dispersion calculation parameters
1816
+ 9. Handles mask specifications and file processing
1817
+ 10. Initializes filter options
1818
+
1819
+ Examples
1820
+ --------
1821
+ >>> args, prefilter = process_args()
1822
+ >>> print(args['passes'])
1823
+ 1
1824
+ >>> print(args['outputlevel'])
1825
+ 'normal'
1668
1826
  """
1669
1827
  inargs, argstowrite = pf.setargs(_get_parser, inputargs=inputargs)
1670
1828
  args = vars(inargs)
@@ -1678,7 +1836,7 @@ def process_args(inputargs=None):
1678
1836
  # save the raw and formatted command lines
1679
1837
  args["commandlineargs"] = argstowrite[1:]
1680
1838
  thecommandline = " ".join(argstowrite)
1681
- tide_io.writevec([thecommandline], args["outputname"] + "_commandline.txt")
1839
+ tide_io.writevec(np.array([thecommandline]), args["outputname"] + "_commandline.txt")
1682
1840
  formattedcommandline = []
1683
1841
  for thetoken in argstowrite[0:3]:
1684
1842
  formattedcommandline.append(thetoken)
@@ -1697,7 +1855,9 @@ def process_args(inputargs=None):
1697
1855
  else:
1698
1856
  suffix = ""
1699
1857
  formattedcommandline[i] = prefix + formattedcommandline[i] + suffix
1700
- tide_io.writevec(formattedcommandline, args["outputname"] + "_formattedcommandline.txt")
1858
+ tide_io.writevec(
1859
+ np.array(formattedcommandline), args["outputname"] + "_formattedcommandline.txt"
1860
+ )
1701
1861
 
1702
1862
  LGR.debug("\nbefore postprocessing:\n{}".format(args))
1703
1863
 
@@ -1706,7 +1866,7 @@ def process_args(inputargs=None):
1706
1866
  # what fraction of the correlation window to avoid on either end when
1707
1867
  # fitting
1708
1868
  args["edgebufferfrac"] = 0.0
1709
- # only do fits in voxels that exceed threshhold
1869
+ # only do fits in voxels that exceed threshold
1710
1870
  args["enforcethresh"] = True
1711
1871
  # if set to the location of the first autocorrelation sidelobe,
1712
1872
  # this will fold back sidelobes
@@ -1719,8 +1879,6 @@ def process_args(inputargs=None):
1719
1879
  args["absmaxsigma"] = 10000.0
1720
1880
  # width of the reference autocorrelation function
1721
1881
  args["absminsigma"] = 0.05
1722
- # search window width for noise regressor mutual information function
1723
- args["noisesearchwindow"] = 30.0
1724
1882
  # number of MADs away from the median to consider an outlier
1725
1883
  args["sigdistoutlierfac"] = 10.0
1726
1884
 
@@ -1731,11 +1889,12 @@ def process_args(inputargs=None):
1731
1889
  args["hardlimit"] = True
1732
1890
  # The fraction of the main peak over which points are included in the peak
1733
1891
  args["searchfrac"] = 0.5
1734
- args["mp_chunksize"] = 50000
1892
+ args["mp_chunksize"] = 500
1893
+ args["patchminsize"] = DEFAULT_PATCHMINSIZE
1894
+ args["patchfwhm"] = DEFAULT_PATCHFWHM
1735
1895
 
1736
1896
  # significance estimation
1737
1897
  args["sighistlen"] = 1000
1738
- args["dosighistfit"] = True
1739
1898
  if args["corrtype"] == "linear":
1740
1899
  args["corrpadding"] = -1
1741
1900
  # pf.setifnotset(args, "windowfunc", "None")
@@ -1750,6 +1909,10 @@ def process_args(inputargs=None):
1750
1909
  args["check_autocorrelation"] = True
1751
1910
  args["acwidth"] = 0.0 # width of the reference autocorrelation function
1752
1911
 
1912
+ # delay refinement
1913
+ args["mindelay"] = DEFAULT_REFINEDELAYMINDELAY
1914
+ args["maxdelay"] = DEFAULT_REFINEDELAYMAXDELAY
1915
+ args["numpoints"] = DEFAULT_REFINEDELAYNUMPOINTS
1753
1916
  # diagnostic information about version
1754
1917
  (
1755
1918
  args["release_version"],
@@ -1764,6 +1927,8 @@ def process_args(inputargs=None):
1764
1927
  args = vars(theobj)
1765
1928
 
1766
1929
  # Additional argument parsing not handled by argparse
1930
+ args["passes"] = np.max([args["passes"], 1])
1931
+
1767
1932
  args["despeckle_passes"] = np.max([args["despeckle_passes"], 0])
1768
1933
 
1769
1934
  if "lag_extrema_nondefault" in args.keys():
@@ -1773,6 +1938,9 @@ def process_args(inputargs=None):
1773
1938
  args["lagmin"] = args["lag_extrema"][0]
1774
1939
  args["lagmax"] = args["lag_extrema"][1]
1775
1940
 
1941
+ if args["prewhitenlags"] == -1:
1942
+ args["prewhitenlags"] = int(np.max([np.fabs(args["lagmin"]), np.fabs(args["lagmax"])]))
1943
+
1776
1944
  # set startpoint and endpoint
1777
1945
  args["startpoint"], args["endpoint"] = pf.parserange(args["timerange"], descriptor="timerange")
1778
1946
 
@@ -1815,18 +1983,22 @@ def process_args(inputargs=None):
1815
1983
  else:
1816
1984
  args["nohistzero"] = True
1817
1985
 
1818
- if args["fixeddelayvalue"] is not None:
1819
- args["fixdelay"] = True
1986
+ # sort out initial delay options
1987
+ if args["fixdelay"]:
1988
+ try:
1989
+ tempinitialdelayvalue = float(args["initialdelayvalue"])
1990
+ except ValueError:
1991
+ tempinitialdelayvalue = 0.0
1820
1992
  args["lag_extrema"] = (
1821
- args["fixeddelayvalue"] - 10.0,
1822
- args["fixeddelayvalue"] + 10.0,
1993
+ tempinitialdelayvalue - 10.0,
1994
+ tempinitialdelayvalue + 10.0,
1823
1995
  )
1824
1996
  else:
1825
- args["fixdelay"] = False
1997
+ args["initialdelayvalue"] = None
1826
1998
 
1827
1999
  if args["in_file"].endswith("txt") and args["realtr"] == "auto":
1828
2000
  raise ValueError(
1829
- "Either --datatstep or --datafreq must be provided " "if data file is a text file."
2001
+ "Either --datatstep or --datafreq must be provided if data file is a text file."
1830
2002
  )
1831
2003
 
1832
2004
  if args["realtr"] != "auto":
@@ -1835,7 +2007,7 @@ def process_args(inputargs=None):
1835
2007
  if tide_io.checkifcifti(args["in_file"]):
1836
2008
  fmri_tr, dummy = tide_io.getciftitr(nib.load(args["in_file"]).header)
1837
2009
  else:
1838
- fmri_tr = nib.load(args["in_file"]).header.get_zooms()[3]
2010
+ fmri_tr, dummy = tide_io.fmritimeinfo(args["in_file"])
1839
2011
  args["realtr"] = fmri_tr
1840
2012
 
1841
2013
  if args["inputfreq"] == "auto":
@@ -1844,32 +2016,27 @@ def process_args(inputargs=None):
1844
2016
  else:
1845
2017
  args["inputfreq_nondefault"] = True
1846
2018
 
1847
- if args["noisetimecoursespec"] is not None:
1848
- (
1849
- args["noisetimecoursename"],
1850
- args["noisetimecoursevals"],
1851
- ) = tide_io.parsefilespec(args["noisetimecoursespec"])
1852
- else:
1853
- args["noisetimecoursename"] = None
1854
- args["noisetimecoursevals"] = None
1855
-
1856
- if args["noisefreq"] == "auto":
1857
- args["noisefreq"] = 1.0 / fmri_tr
1858
-
1859
- # mask processing
1860
- if args["corrmaskincludespec"] is not None:
1861
- (
1862
- args["corrmaskincludename"],
1863
- args["corrmaskincludevals"],
1864
- ) = tide_io.processnamespec(
1865
- args["corrmaskincludespec"],
1866
- "Including voxels where ",
1867
- "in correlation calculations.",
1868
- )
1869
- else:
1870
- args["corrmaskincludename"] = None
1871
-
1872
- # if brainmaskincludespec is set, set corrmaskinclude to it.
2019
+ # initial mask values from anatomical images (before any overrides)
2020
+ for key in [
2021
+ "corrmaskincludename",
2022
+ "corrmaskincludevals",
2023
+ "initregressorincludename",
2024
+ "initregressorincludevals",
2025
+ "initregressorexcludename",
2026
+ "initregressorexcludevals",
2027
+ "refineincludename",
2028
+ "refineincludevals",
2029
+ "refineexcludename",
2030
+ "refineexcludevals",
2031
+ "offsetincludename",
2032
+ "offsetincludevals",
2033
+ "offsetexcludename",
2034
+ "offsetexcludevals",
2035
+ ]:
2036
+ args[key] = None
2037
+
2038
+ # if brainmaskincludespec is set, set initregressorinclude, corrmaskinclude, refineinclude, and offsetinclude to it.
2039
+ brainmasks = ["initregressor", "corrmask", "refine", "offset"]
1873
2040
  if args["brainmaskincludespec"] is not None:
1874
2041
  (
1875
2042
  args["brainmaskincludename"],
@@ -1879,11 +2046,22 @@ def process_args(inputargs=None):
1879
2046
  )
1880
2047
  if not os.path.isfile(args["brainmaskincludename"]):
1881
2048
  raise FileNotFoundError(f"file {args['brainmaskincludename']} does not exist.")
2049
+ for masktype in brainmasks:
2050
+ (
2051
+ args[f"{masktype}includename"],
2052
+ args[f"{masktype}includevals"],
2053
+ ) = (
2054
+ args["brainmaskincludename"],
2055
+ args["brainmaskincludevals"],
2056
+ )
2057
+ print(f"setting {masktype}include mask to gray matter mask")
1882
2058
  else:
1883
2059
  args["brainmaskincludename"] = None
1884
2060
  args["brainmaskincludevals"] = None
1885
2061
 
1886
- # if graymatterincludespec is set, set globalmeaninclude and offsetinclude to it.
2062
+ # if graymatterincludespec is set, set initregressorinclude, offsetinclude to it.
2063
+ # graymasks = ["initregressor", "offset"]
2064
+ graymasks = ["initregressor"]
1887
2065
  if args["graymatterincludespec"] is not None:
1888
2066
  (
1889
2067
  args["graymatterincludename"],
@@ -1893,27 +2071,18 @@ def process_args(inputargs=None):
1893
2071
  )
1894
2072
  if not os.path.isfile(args["graymatterincludename"]):
1895
2073
  raise FileNotFoundError(f"file {args['graymatterincludename']} does not exist.")
1896
- (
1897
- args["globalmeanincludename"],
1898
- args["globalmeanincludevals"],
1899
- ) = (
1900
- args["graymatterincludename"],
1901
- args["graymatterincludevals"],
1902
- )
1903
- (
1904
- args["offsetincludename"],
1905
- args["offsetincludevals"],
1906
- ) = (
1907
- args["graymatterincludename"],
1908
- args["graymatterincludevals"],
1909
- )
2074
+ for masktype in graymasks:
2075
+ (
2076
+ args[f"{masktype}includename"],
2077
+ args[f"{masktype}includevals"],
2078
+ ) = (
2079
+ args["graymatterincludename"],
2080
+ args["graymatterincludevals"],
2081
+ )
2082
+ print(f"setting {masktype}include mask to gray matter mask")
1910
2083
  else:
1911
2084
  args["graymatterincludename"] = None
1912
2085
  args["graymatterincludevals"] = None
1913
- args["globalmeanincludename"] = None
1914
- args["globalmeanincludevals"] = None
1915
- args["offsetincludename"] = None
1916
- args["offsetincludevals"] = None
1917
2086
 
1918
2087
  if args["whitematterincludespec"] is not None:
1919
2088
  (
@@ -1926,26 +2095,47 @@ def process_args(inputargs=None):
1926
2095
  args["whitematterincludename"] = None
1927
2096
  args["whitematterincludevals"] = None
1928
2097
 
1929
- if args["globalmeanincludespec"] is not None:
2098
+ if args["csfincludespec"] is not None:
2099
+ (
2100
+ args["csfincludename"],
2101
+ args["csfincludevals"],
2102
+ ) = tide_io.processnamespec(
2103
+ args["csfincludespec"], "Including voxels where ", "in CSF mask."
2104
+ )
2105
+ else:
2106
+ args["csfincludename"] = None
2107
+ args["csfincludevals"] = None
2108
+
2109
+ # individual mask processing (including overrides)
2110
+ if args["corrmaskincludespec"] is not None:
2111
+ (
2112
+ args["corrmaskincludename"],
2113
+ args["corrmaskincludevals"],
2114
+ ) = tide_io.processnamespec(
2115
+ args["corrmaskincludespec"],
2116
+ "Including voxels where ",
2117
+ "in correlation calculations.",
2118
+ )
2119
+
2120
+ if args["initregressorincludespec"] is not None:
1930
2121
  (
1931
- args["globalmeanincludename"],
1932
- args["globalmeanincludevals"],
2122
+ args["initregressorincludename"],
2123
+ args["initregressorincludevals"],
1933
2124
  ) = tide_io.processnamespec(
1934
- args["globalmeanincludespec"], "Including voxels where ", "in global mean."
2125
+ args["initregressorincludespec"],
2126
+ "Including voxels where ",
2127
+ "in initial regressor calculation.",
1935
2128
  )
1936
2129
 
1937
- if args["globalmeanexcludespec"] is not None:
2130
+ if args["initregressorexcludespec"] is not None:
1938
2131
  (
1939
- args["globalmeanexcludename"],
1940
- args["globalmeanexcludevals"],
2132
+ args["initregressorexcludename"],
2133
+ args["initregressorexcludevals"],
1941
2134
  ) = tide_io.processnamespec(
1942
- args["globalmeanexcludespec"],
2135
+ args["initregressorexcludespec"],
1943
2136
  "Excluding voxels where ",
1944
- "from global mean.",
2137
+ "from initial regressor calculation.",
1945
2138
  )
1946
- else:
1947
- args["globalmeanexcludename"] = None
1948
- args["globalmeanexcludevals"] = None
1949
2139
 
1950
2140
  if args["refineincludespec"] is not None:
1951
2141
  (
@@ -1954,9 +2144,6 @@ def process_args(inputargs=None):
1954
2144
  ) = tide_io.processnamespec(
1955
2145
  args["refineincludespec"], "Including voxels where ", "in refinement."
1956
2146
  )
1957
- else:
1958
- args["refineincludename"] = None
1959
- args["refineincludevals"] = None
1960
2147
 
1961
2148
  if args["refineexcludespec"] is not None:
1962
2149
  (
@@ -1965,9 +2152,6 @@ def process_args(inputargs=None):
1965
2152
  ) = tide_io.processnamespec(
1966
2153
  args["refineexcludespec"], "Excluding voxels where ", "from refinement."
1967
2154
  )
1968
- else:
1969
- args["refineexcludename"] = None
1970
- args["refineexcludevals"] = None
1971
2155
 
1972
2156
  if args["offsetincludespec"] is not None:
1973
2157
  (
@@ -1984,9 +2168,6 @@ def process_args(inputargs=None):
1984
2168
  ) = tide_io.processnamespec(
1985
2169
  args["offsetexcludespec"], "Excluding voxels where ", "from offset calculation."
1986
2170
  )
1987
- else:
1988
- args["offsetexcludename"] = None
1989
- args["offsetexcludevals"] = None
1990
2171
 
1991
2172
  # motion processing
1992
2173
  if args["motionfilespec"] is not None:
@@ -1999,25 +2180,35 @@ def process_args(inputargs=None):
1999
2180
  # process analysis modes
2000
2181
  if args["delaymapping"]:
2001
2182
  LGR.warning('Using "delaymapping" analysis mode. Overriding any affected arguments.')
2002
- pf.setifnotset(args, "passes", DEFAULT_DELAYMAPPING_PASSES)
2003
- pf.setifnotset(args, "despeckle_passes", DEFAULT_DELAYMAPPING_DESPECKLE_PASSES)
2183
+ if args["passes"] == DEFAULT_PASSES:
2184
+ args["passes"] = DEFAULT_DELAYMAPPING_PASSES
2185
+ if args["despeckle_passes"] == DEFAULT_DESPECKLE_PASSES:
2186
+ args["despeckle_passes"] = DEFAULT_DELAYMAPPING_DESPECKLE_PASSES
2187
+ if args["gausssigma"] == DEFAULT_SPATIALFILT:
2188
+ args["gausssigma"] = DEFAULT_DELAYMAPPING_SPATIALFILT
2004
2189
  pf.setifnotset(args, "lagmin", DEFAULT_DELAYMAPPING_LAGMIN)
2005
2190
  pf.setifnotset(args, "lagmax", DEFAULT_DELAYMAPPING_LAGMAX)
2006
2191
  args["refineoffset"] = True
2192
+ args["refinedelay"] = True
2007
2193
  args["outputlevel"] = "normal"
2008
- pf.setifnotset(args, "doglmfilt", False)
2194
+ pf.setifnotset(args, "dolinfitfilt", True)
2009
2195
 
2010
2196
  if args["denoising"]:
2011
2197
  LGR.warning('Using "denoising" analysis mode. Overriding any affected arguments.')
2012
- pf.setifnotset(args, "passes", DEFAULT_DENOISING_PASSES)
2013
- pf.setifnotset(args, "despeckle_passes", DEFAULT_DENOISING_DESPECKLE_PASSES)
2198
+ if args["passes"] == DEFAULT_PASSES:
2199
+ args["passes"] = DEFAULT_DENOISING_PASSES
2200
+ if args["despeckle_passes"] == DEFAULT_DESPECKLE_PASSES:
2201
+ args["despeckle_passes"] = DEFAULT_DENOISING_DESPECKLE_PASSES
2202
+ if args["gausssigma"] == DEFAULT_SPATIALFILT:
2203
+ args["gausssigma"] = DEFAULT_DENOISING_SPATIALFILT
2204
+ if args["peakfittype"] == DEFAULT_PEAKFIT_TYPE:
2205
+ args["peakfittype"] = DEFAULT_DENOISING_PEAKFITTYPE
2014
2206
  pf.setifnotset(args, "lagmin", DEFAULT_DENOISING_LAGMIN)
2015
2207
  pf.setifnotset(args, "lagmax", DEFAULT_DENOISING_LAGMAX)
2016
- pf.setifnotset(args, "peakfittype", DEFAULT_DENOISING_PEAKFITTYPE)
2017
- pf.setifnotset(args, "gausssigma", DEFAULT_DENOISING_SPATIALFILT)
2018
2208
  args["refineoffset"] = True
2209
+ args["refinedelay"] = True
2019
2210
  args["zerooutbadfit"] = False
2020
- pf.setifnotset(args, "doglmfilt", True)
2211
+ args["dolinfitfilt"] = True
2021
2212
 
2022
2213
  if args["docvrmap"]:
2023
2214
  LGR.warning('Using "CVR" analysis mode. Overriding any affected arguments.')
@@ -2029,22 +2220,24 @@ def process_args(inputargs=None):
2029
2220
  DEFAULT_CVRMAPPING_FILTER_LOWERPASS,
2030
2221
  DEFAULT_CVRMAPPING_FILTER_UPPERPASS,
2031
2222
  )
2032
- pf.setifnotset(args, "filterband", "arb")
2033
- pf.setifnotset(args, "despeckle_passes", DEFAULT_CVRMAPPING_DESPECKLE_PASSES)
2223
+ if args["despeckle_passes"] == DEFAULT_DESPECKLE_PASSES:
2224
+ args["despeckle_passes"] = DEFAULT_CVRMAPPING_DESPECKLE_PASSES
2225
+ if args["filterband"] == pf.DEFAULT_FILTERBAND:
2226
+ args["filterband"] = "None"
2034
2227
  pf.setifnotset(args, "lagmin", DEFAULT_CVRMAPPING_LAGMIN)
2035
2228
  pf.setifnotset(args, "lagmax", DEFAULT_CVRMAPPING_LAGMAX)
2036
2229
  args["preservefiltering"] = True
2037
2230
  args["passes"] = 1
2038
2231
  args["outputlevel"] = "min"
2039
- args["doglmfilt"] = False
2232
+ args["dolinfitfilt"] = False
2040
2233
 
2041
- if args["globalpreselect"]:
2234
+ if args["initregressorpreselect"]:
2042
2235
  LGR.warning('Using "globalpreselect" analysis mode. Overriding any affected arguments.')
2043
2236
  args["passes"] = 1
2044
2237
  args["despeckle_passes"] = 0
2045
2238
  args["refinedespeckle"] = False
2046
2239
  args["outputlevel"] = "normal"
2047
- pf.setifnotset(args, "doglmfilt", False)
2240
+ pf.setifnotset(args, "dolinfitfilt", False)
2048
2241
  args["saveintermediatemaps"] = False
2049
2242
 
2050
2243
  # configure the filter
@@ -2064,6 +2257,7 @@ def process_args(inputargs=None):
2064
2257
  LGR.warning('Using "nirs" macro. Overriding any affected arguments.')
2065
2258
  args["nothresh"] = True
2066
2259
  pf.setifnotset(args, "preservefiltering", False)
2260
+ args["dataiszeromean"] = True
2067
2261
  args["refineprenorm"] = "var"
2068
2262
  args["ampthresh"] = 0.7
2069
2263
  args["ampthreshfromsig"] = False
@@ -2081,59 +2275,66 @@ def process_args(inputargs=None):
2081
2275
  args["savecorrtimes"] = False
2082
2276
  args["savelagregressors"] = False
2083
2277
  args["savedespecklemasks"] = False
2084
- args["saveminimumglmfiles"] = False
2085
- args["savenormalglmfiles"] = False
2278
+ args["saveminimumsLFOfiltfiles"] = False
2279
+ args["savenormalsLFOfiltfiles"] = False
2086
2280
  args["savemovingsignal"] = False
2087
- args["saveallglmfiles"] = False
2281
+ args["saveallsLFOfiltfiles"] = False
2088
2282
  elif args["outputlevel"] == "less":
2089
2283
  args["saveconfoundfiltered"] = False
2090
2284
  args["savegaussout"] = False
2091
2285
  args["savecorrtimes"] = False
2092
2286
  args["savelagregressors"] = False
2093
2287
  args["savedespecklemasks"] = False
2094
- args["saveminimumglmfiles"] = True
2095
- args["savenormalglmfiles"] = False
2288
+ args["saveminimumsLFOfiltfiles"] = True
2289
+ args["savenormalsLFOfiltfiles"] = False
2096
2290
  args["savemovingsignal"] = False
2097
- args["saveallglmfiles"] = False
2291
+ args["saveallsLFOfiltfiles"] = False
2098
2292
  elif args["outputlevel"] == "normal":
2099
2293
  args["saveconfoundfiltered"] = False
2100
2294
  args["savegaussout"] = False
2101
2295
  args["savecorrtimes"] = False
2102
2296
  args["savelagregressors"] = False
2103
2297
  args["savedespecklemasks"] = False
2104
- args["saveminimumglmfiles"] = True
2105
- args["savenormalglmfiles"] = True
2298
+ args["saveminimumsLFOfiltfiles"] = True
2299
+ args["savenormalsLFOfiltfiles"] = True
2106
2300
  args["savemovingsignal"] = False
2107
- args["saveallglmfiles"] = False
2301
+ args["saveallsLFOfiltfiles"] = False
2108
2302
  elif args["outputlevel"] == "more":
2109
2303
  args["saveconfoundfiltered"] = False
2110
2304
  args["savegaussout"] = False
2111
2305
  args["savecorrtimes"] = False
2112
2306
  args["savelagregressors"] = True
2113
2307
  args["savedespecklemasks"] = False
2114
- args["saveminimumglmfiles"] = True
2115
- args["savenormalglmfiles"] = True
2308
+ args["saveminimumsLFOfiltfiles"] = True
2309
+ args["savenormalsLFOfiltfiles"] = True
2116
2310
  args["savemovingsignal"] = True
2117
- args["saveallglmfiles"] = False
2311
+ args["saveallsLFOfiltfiles"] = False
2118
2312
  elif args["outputlevel"] == "max":
2119
2313
  args["saveconfoundfiltered"] = True
2120
2314
  args["savegaussout"] = True
2121
2315
  args["savecorrtimes"] = True
2122
2316
  args["savelagregressors"] = True
2123
2317
  args["savedespecklemasks"] = True
2124
- args["saveminimumglmfiles"] = True
2125
- args["savenormalglmfiles"] = True
2318
+ args["saveminimumsLFOfiltfiles"] = True
2319
+ args["savenormalsLFOfiltfiles"] = True
2126
2320
  args["savemovingsignal"] = True
2127
- args["saveallglmfiles"] = True
2321
+ args["saveallsLFOfiltfiles"] = True
2128
2322
  else:
2129
2323
  print(f"illegal output level {args['outputlevel']}")
2130
2324
  sys.exit()
2131
2325
 
2132
- # disable memory profiling if necessary
2133
- if not memprofilerexists:
2134
- if args["memprofile"]:
2135
- LGR.info("memprofiler is not installed - disabling memory profiling")
2136
- args["memprofile"] = False
2326
+ # make the pass options dictionary
2327
+ args["passoptions"] = [
2328
+ {
2329
+ "similaritymetric": "riptide",
2330
+ },
2331
+ {
2332
+ "similaritymetric": "correlation",
2333
+ },
2334
+ {
2335
+ "similaritymetric": "correlation",
2336
+ },
2337
+ ]
2137
2338
 
2138
2339
  # dispersion calculation
2139
2340
  args["dispersioncalc_lower"] = args["lagmin"]
@@ -2150,14 +2351,14 @@ def process_args(inputargs=None):
2150
2351
  args["territorymapname"],
2151
2352
  args["territorymapincludevals"],
2152
2353
  ) = tide_io.processnamespec(
2153
- args["territorymap"], "Including voxels where ", "in global mean."
2354
+ args["territorymap"], "Including voxels where ", "in initial regressor calculation."
2154
2355
  )
2155
2356
  else:
2156
2357
  args["territorymapname"] = None
2157
2358
  args["territorymapincludevals"] = None
2158
2359
 
2159
- # this is new enough to do retrospective GLM
2160
- args["retroglmcompatible"] = True
2360
+ # this is new enough to do retrospective regression filtering
2361
+ args["retroregresscompatible"] = True
2161
2362
 
2162
2363
  LGR.debug("\nafter postprocessing\n{}".format(args))
2163
2364