rapidtide 2.9.5__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 +94 -27
  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 +21 -0
  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 +178 -0
  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 +590 -1181
  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 +867 -137
  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.5.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 +27 -15
  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 +1833 -1919
  292. rapidtide/workflows/rapidtide2std.py +101 -3
  293. rapidtide/workflows/rapidtide_parser.py +607 -372
  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.5.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.5.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.5.data/scripts/adjustoffset +0 -23
  346. rapidtide-2.9.5.data/scripts/aligntcs +0 -23
  347. rapidtide-2.9.5.data/scripts/applydlfilter +0 -23
  348. rapidtide-2.9.5.data/scripts/atlasaverage +0 -23
  349. rapidtide-2.9.5.data/scripts/atlastool +0 -23
  350. rapidtide-2.9.5.data/scripts/calcicc +0 -22
  351. rapidtide-2.9.5.data/scripts/calctexticc +0 -23
  352. rapidtide-2.9.5.data/scripts/calcttest +0 -22
  353. rapidtide-2.9.5.data/scripts/ccorrica +0 -23
  354. rapidtide-2.9.5.data/scripts/diffrois +0 -23
  355. rapidtide-2.9.5.data/scripts/endtidalproc +0 -23
  356. rapidtide-2.9.5.data/scripts/filtnifti +0 -23
  357. rapidtide-2.9.5.data/scripts/filttc +0 -23
  358. rapidtide-2.9.5.data/scripts/fingerprint +0 -593
  359. rapidtide-2.9.5.data/scripts/fixtr +0 -23
  360. rapidtide-2.9.5.data/scripts/glmfilt +0 -24
  361. rapidtide-2.9.5.data/scripts/gmscalc +0 -22
  362. rapidtide-2.9.5.data/scripts/happy +0 -25
  363. rapidtide-2.9.5.data/scripts/happy2std +0 -23
  364. rapidtide-2.9.5.data/scripts/happywarp +0 -350
  365. rapidtide-2.9.5.data/scripts/histnifti +0 -23
  366. rapidtide-2.9.5.data/scripts/histtc +0 -23
  367. rapidtide-2.9.5.data/scripts/localflow +0 -23
  368. rapidtide-2.9.5.data/scripts/mergequality +0 -23
  369. rapidtide-2.9.5.data/scripts/pairproc +0 -23
  370. rapidtide-2.9.5.data/scripts/pairwisemergenifti +0 -23
  371. rapidtide-2.9.5.data/scripts/physiofreq +0 -23
  372. rapidtide-2.9.5.data/scripts/pixelcomp +0 -23
  373. rapidtide-2.9.5.data/scripts/plethquality +0 -23
  374. rapidtide-2.9.5.data/scripts/polyfitim +0 -23
  375. rapidtide-2.9.5.data/scripts/proj2flow +0 -23
  376. rapidtide-2.9.5.data/scripts/rankimage +0 -23
  377. rapidtide-2.9.5.data/scripts/rapidtide +0 -23
  378. rapidtide-2.9.5.data/scripts/rapidtide2std +0 -23
  379. rapidtide-2.9.5.data/scripts/resamplenifti +0 -23
  380. rapidtide-2.9.5.data/scripts/resampletc +0 -23
  381. rapidtide-2.9.5.data/scripts/retroglm +0 -23
  382. rapidtide-2.9.5.data/scripts/roisummarize +0 -23
  383. rapidtide-2.9.5.data/scripts/runqualitycheck +0 -23
  384. rapidtide-2.9.5.data/scripts/showarbcorr +0 -23
  385. rapidtide-2.9.5.data/scripts/showhist +0 -23
  386. rapidtide-2.9.5.data/scripts/showstxcorr +0 -23
  387. rapidtide-2.9.5.data/scripts/showtc +0 -23
  388. rapidtide-2.9.5.data/scripts/showxcorr_legacy +0 -536
  389. rapidtide-2.9.5.data/scripts/showxcorrx +0 -23
  390. rapidtide-2.9.5.data/scripts/showxy +0 -23
  391. rapidtide-2.9.5.data/scripts/simdata +0 -23
  392. rapidtide-2.9.5.data/scripts/spatialdecomp +0 -23
  393. rapidtide-2.9.5.data/scripts/spatialfit +0 -23
  394. rapidtide-2.9.5.data/scripts/spatialmi +0 -23
  395. rapidtide-2.9.5.data/scripts/spectrogram +0 -23
  396. rapidtide-2.9.5.data/scripts/synthASL +0 -23
  397. rapidtide-2.9.5.data/scripts/tcfrom2col +0 -23
  398. rapidtide-2.9.5.data/scripts/tcfrom3col +0 -23
  399. rapidtide-2.9.5.data/scripts/temporaldecomp +0 -23
  400. rapidtide-2.9.5.data/scripts/threeD +0 -236
  401. rapidtide-2.9.5.data/scripts/tidepool +0 -23
  402. rapidtide-2.9.5.data/scripts/variabilityizer +0 -23
  403. rapidtide-2.9.5.dist-info/RECORD +0 -357
  404. rapidtide-2.9.5.dist-info/top_level.txt +0 -86
  405. {rapidtide-2.9.5.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,9 +21,11 @@ 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
@@ -44,7 +46,7 @@ LGR = logging.getLogger(__name__)
44
46
  DEFAULT_SPATIALFILT = -1
45
47
  DEFAULT_HISTLEN = 101
46
48
  DEFAULT_DETREND_ORDER = 3
47
- DEFAULT_GLOBAL_PCACOMPONENTS = 0.8
49
+ DEFAULT_INITREGRESSOR_PCACOMPONENTS = 0.8
48
50
  DEFAULT_CORRMASK_THRESHPCT = 1.0
49
51
  DEFAULT_MUTUALINFO_SMOOTHINGTIME = 3.0
50
52
  DEFAULT_LAGMIN = -30.0
@@ -54,8 +56,8 @@ DEFAULT_SIGMAMIN = 0.0
54
56
  DEFAULT_DESPECKLE_PASSES = 4
55
57
  DEFAULT_DESPECKLE_THRESH = 5.0
56
58
  DEFAULT_PASSES = 3
57
- DEFAULT_LAGMIN_THRESH = 0.5
58
- DEFAULT_LAGMAX_THRESH = 5.0
59
+ DEFAULT_LAGMIN_THRESH = 0.25
60
+ DEFAULT_LAGMAX_THRESH = 3.0
59
61
  DEFAULT_AMPTHRESH = 0.3
60
62
  DEFAULT_PICKLEFT_THRESH = 0.33
61
63
  DEFAULT_SIGMATHRESH = 100.0
@@ -63,16 +65,15 @@ DEFAULT_MAXPASSES = 15
63
65
  DEFAULT_REFINE_TYPE = "pca"
64
66
  DEFAULT_INTERPTYPE = "univariate"
65
67
  DEFAULT_WINDOW_TYPE = "hamming"
66
- DEFAULT_GLOBALMASK_METHOD = "mean"
67
- DEFAULT_GLOBALSIGNAL_METHOD = "sum"
68
- DEFAULT_CORRWEIGHTING = "regressor"
68
+ DEFAULT_INITREGRESSOR_METHOD = "sum"
69
+ DEFAULT_CORRWEIGHTING = "phat"
69
70
  DEFAULT_CORRTYPE = "linear"
70
71
  DEFAULT_SIMILARITYMETRIC = "correlation"
71
72
  DEFAULT_PEAKFIT_TYPE = "gauss"
72
73
  DEFAULT_REFINE_PRENORM = "var"
73
74
  DEFAULT_REFINE_WEIGHTING = "None"
74
75
  DEFAULT_REFINE_PCACOMPONENTS = 0.8
75
- DEFAULT_GLMDERIVS = 0
76
+ DEFAULT_REGRESSIONFILTDERIVS = 0
76
77
 
77
78
  DEFAULT_DENOISING_LAGMIN = -10.0
78
79
  DEFAULT_DENOISING_LAGMAX = 10.0
@@ -85,6 +86,7 @@ DEFAULT_DELAYMAPPING_LAGMIN = -10.0
85
86
  DEFAULT_DELAYMAPPING_LAGMAX = 30.0
86
87
  DEFAULT_DELAYMAPPING_PASSES = 3
87
88
  DEFAULT_DELAYMAPPING_DESPECKLE_PASSES = 4
89
+ DEFAULT_DELAYMAPPING_SPATIALFILT = 2.5
88
90
 
89
91
  DEFAULT_CVRMAPPING_LAGMIN = -5.0
90
92
  DEFAULT_CVRMAPPING_LAGMAX = 20.0
@@ -94,10 +96,51 @@ DEFAULT_CVRMAPPING_DESPECKLE_PASSES = 4
94
96
 
95
97
  DEFAULT_OUTPUTLEVEL = "normal"
96
98
 
99
+ DEFAULT_SLFONOISEAMP_WINDOWSIZE = 40.0
97
100
 
98
- def _get_parser():
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
+
115
+
116
+ def _get_parser() -> Any:
99
117
  """
100
- 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)
101
144
  """
102
145
  parser = argparse.ArgumentParser(
103
146
  prog="rapidtide",
@@ -140,7 +183,7 @@ def _get_parser():
140
183
  f"sets searchrange=({DEFAULT_DENOISING_LAGMIN}, {DEFAULT_DENOISING_LAGMAX}), "
141
184
  f"passes={DEFAULT_DENOISING_PASSES}, despeckle_passes={DEFAULT_DENOISING_DESPECKLE_PASSES}, "
142
185
  f"refineoffset=True, peakfittype={DEFAULT_DENOISING_PEAKFITTYPE}, "
143
- f"gausssigma={DEFAULT_DENOISING_SPATIALFILT}, nofitfilt=True, doglmfilt=True. "
186
+ f"gausssigma={DEFAULT_DENOISING_SPATIALFILT}, nofitfilt=True, dolinfitfilt=True. "
144
187
  "Any of these options can be overridden with the appropriate "
145
188
  "additional arguments."
146
189
  ),
@@ -154,8 +197,9 @@ def _get_parser():
154
197
  "Preset for delay mapping analysis - this is a macro that "
155
198
  f"sets searchrange=({DEFAULT_DELAYMAPPING_LAGMIN}, {DEFAULT_DELAYMAPPING_LAGMAX}), "
156
199
  f"passes={DEFAULT_DELAYMAPPING_PASSES}, despeckle_passes={DEFAULT_DELAYMAPPING_DESPECKLE_PASSES}, "
157
- "refineoffset=True, outputlevel='normal', "
158
- "doglmfilt=False. "
200
+ f"gausssigma={DEFAULT_DELAYMAPPING_SPATIALFILT}, "
201
+ "refineoffset=True, refinedelay=True, outputlevel='normal', "
202
+ "dolinfitfilt=False. "
159
203
  "Any of these options can be overridden with the appropriate "
160
204
  "additional arguments."
161
205
  ),
@@ -172,7 +216,7 @@ def _get_parser():
172
216
  f"passes=1, despeckle_passes={DEFAULT_CVRMAPPING_DESPECKLE_PASSES}, "
173
217
  f"searchrange=({DEFAULT_CVRMAPPING_LAGMIN}, {DEFAULT_CVRMAPPING_LAGMAX}), "
174
218
  f"filterfreqs=({DEFAULT_CVRMAPPING_FILTER_LOWERPASS}, {DEFAULT_CVRMAPPING_FILTER_UPPERPASS}), "
175
- "and calculates a voxelwise GLM using the optimally delayed "
219
+ "and calculates a voxelwise regression fit using the optimally delayed "
176
220
  "input regressor and the percent normalized, demeaned BOLD data as inputs. This map is output as "
177
221
  "(XXX_desc-CVR_map.nii.gz). If no input regressor is supplied, this will generate an error. "
178
222
  "These options can be overridden with the appropriate additional arguments."
@@ -181,12 +225,12 @@ def _get_parser():
181
225
  )
182
226
  analysis_type.add_argument(
183
227
  "--globalpreselect",
184
- dest="globalpreselect",
228
+ dest="initregressorpreselect",
185
229
  action="store_true",
186
230
  help=(
187
231
  "Treat this run as an initial pass to locate good candidate voxels for global mean "
188
232
  "regressor generation. This sets: passes=1, despecklepasses=0, "
189
- "refinedespeckle=False, outputlevel='normal', doglmfilt=False, saveintermediatemaps=False."
233
+ "refinedespeckle=False, outputlevel='normal', dolinfitfilt=False, saveintermediatemaps=False."
190
234
  ),
191
235
  default=False,
192
236
  )
@@ -219,7 +263,7 @@ def _get_parser():
219
263
  action="store_true",
220
264
  help=(
221
265
  "This is a NIRS analysis - this is a macro that "
222
- "sets nothresh, refineprenorm=var, ampthresh=0.7, and "
266
+ "sets nothresh, dataiszeromean=True, refineprenorm=var, ampthresh=0.7, and "
223
267
  "lagminthresh=0.1. "
224
268
  ),
225
269
  default=False,
@@ -247,7 +291,7 @@ def _get_parser():
247
291
  "2) decide which voxels in which to calculate delays, "
248
292
  "3) refine the regressor at the end of each pass, 4) determine the zero time offset value, and 5) process "
249
293
  "to remove sLFO signal. "
250
- "Setting --globalmeaninclude, --refineinclude, --corrmaskinclude or --offsetinclude explicitly will "
294
+ "Setting --initregressorinclude, --corrmaskinclude, --refineinclude or --offsetinclude explicitly will "
251
295
  "override this for the given include mask."
252
296
  ),
253
297
  default=None,
@@ -260,9 +304,8 @@ def _get_parser():
260
304
  "This specifies a gray matter mask registered to the input functional data. "
261
305
  "If VALSPEC is given, only voxels in the mask with integral values listed in VALSPEC are used, otherwise "
262
306
  "voxels with value > 0.1 are used. If this option is set, "
263
- "rapidtide will use voxels in the gray matter mask to 1) calculate the initial global mean regressor, "
264
- "2) refine the regressor at the end of each pass, and 3) for determining the zero time offset value. "
265
- "Setting --globalmeaninclude, --refineinclude, 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 "
266
309
  "the given include mask."
267
310
  ),
268
311
  default=None,
@@ -275,8 +318,21 @@ def _get_parser():
275
318
  "This specifies a white matter mask registered to the input functional data. "
276
319
  "If VALSPEC is given, only voxels in the mask with integral values listed in VALSPEC are used, otherwise "
277
320
  "voxels with value > 0.1 are used. "
278
- "This currently isn't used for anything, but rapidtide will keep track of it and might use if for something "
279
- "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)."
280
336
  ),
281
337
  default=None,
282
338
  )
@@ -289,7 +345,7 @@ def _get_parser():
289
345
  dest="realtr",
290
346
  action="store",
291
347
  metavar="TSTEP",
292
- type=lambda x: pf.is_float(parser, x),
348
+ type=lambda x: pf.is_float(parser, x, minval=0.0),
293
349
  help=(
294
350
  "Set the timestep of the data file to TSTEP. "
295
351
  "This will override the TR in an "
@@ -361,6 +417,17 @@ def _get_parser():
361
417
  ),
362
418
  default=False,
363
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
+ )
364
431
 
365
432
  # Add filter options
366
433
  pf.addfilteropts(parser, filtertarget="data and regressors", details=True)
@@ -375,7 +442,7 @@ def _get_parser():
375
442
  "--detrendorder",
376
443
  dest="detrendorder",
377
444
  action="store",
378
- type=int,
445
+ type=lambda x: pf.is_int(parser, x, minval=0),
379
446
  metavar="ORDER",
380
447
  help=(f"Set order of trend removal (0 to disable). Default is {DEFAULT_DETREND_ORDER}."),
381
448
  default=DEFAULT_DETREND_ORDER,
@@ -390,40 +457,45 @@ def _get_parser():
390
457
  "Spatially filter fMRI data prior to analysis "
391
458
  "using GAUSSSIGMA in mm. Set GAUSSSIGMA negative "
392
459
  "to have rapidtide set it to half the mean voxel "
393
- "dimension (a rule of thumb for a good value)."
460
+ "dimension (a rule of thumb for a good value). Set to 0 to disable."
394
461
  ),
395
462
  default=DEFAULT_SPATIALFILT,
396
463
  )
397
464
  preproc.add_argument(
398
- "--globalmean",
399
- dest="useglobalref",
465
+ "--premask",
466
+ dest="premask",
400
467
  action="store_true",
401
468
  help=(
402
- "Generate a global mean regressor and use that as the reference "
403
- "regressor. If no external regressor is specified, this "
404
- "is enabled by default."
469
+ "Apply masking prior to spatial filtering to limit extracerebral sources (requires --brainmask)"
405
470
  ),
406
471
  default=False,
407
472
  )
408
473
  preproc.add_argument(
409
- "--globalmaskmethod",
410
- dest="globalmaskmethod",
411
- action="store",
412
- type=str,
413
- choices=["mean", "variance"],
474
+ "--premasktissueonly",
475
+ dest="premasktissueonly",
476
+ action="store_true",
477
+ help=(
478
+ "Apply more stringent masking prior to spatial filtering, removing CSF voxels (requires --graymattermask and --whitemattermask)."
479
+ ),
480
+ default=False,
481
+ )
482
+ preproc.add_argument(
483
+ "--globalmean",
484
+ dest="useinitregressorref",
485
+ action="store_true",
414
486
  help=(
415
- "Select whether to use timecourse mean or variance to "
416
- "mask voxels prior to generating global mean. "
417
- f'Default is "{DEFAULT_GLOBALMASK_METHOD}".'
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."
418
490
  ),
419
- default=DEFAULT_GLOBALMASK_METHOD,
491
+ default=False,
420
492
  )
421
493
  preproc.add_argument(
422
494
  "--globalmeaninclude",
423
- dest="globalmeanincludespec",
495
+ dest="initregressorincludespec",
424
496
  metavar="MASK[:VALSPEC]",
425
497
  help=(
426
- "Only use voxels in mask file NAME for global regressor "
498
+ "Only use voxels in mask file NAME for the initial regressor "
427
499
  "generation (if VALSPEC is given, only voxels "
428
500
  "with integral values listed in VALSPEC are used)."
429
501
  ),
@@ -431,10 +503,10 @@ def _get_parser():
431
503
  )
432
504
  preproc.add_argument(
433
505
  "--globalmeanexclude",
434
- dest="globalmeanexcludespec",
506
+ dest="initregressorexcludespec",
435
507
  metavar="MASK[:VALSPEC]",
436
508
  help=(
437
- "Do not use voxels in mask file NAME for global regressor "
509
+ "Do not use voxels in mask file NAME for the initial regressor "
438
510
  "generation (if VALSPEC is given, only voxels "
439
511
  "with integral values listed in VALSPEC are excluded)."
440
512
  ),
@@ -452,10 +524,22 @@ def _get_parser():
452
524
  default=None,
453
525
  )
454
526
  preproc.add_argument(
455
- "--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",
456
538
  dest="mot_deriv",
457
539
  action="store_false",
458
- 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
+ ),
459
543
  default=True,
460
544
  )
461
545
  preproc.add_argument(
@@ -474,18 +558,18 @@ def _get_parser():
474
558
  "--confoundpowers",
475
559
  dest="confound_power",
476
560
  metavar="N",
477
- type=int,
561
+ type=lambda x: pf.is_int(parser, x, minval=1),
478
562
  help=(
479
563
  "Include powers of each confound regressor up to order N. Default is 1 (no expansion). "
480
564
  ),
481
565
  default=1,
482
566
  )
483
567
  preproc.add_argument(
484
- "--confoundderiv",
568
+ "--noconfoundderiv",
485
569
  dest="confound_deriv",
486
570
  action="store_false",
487
571
  help=(
488
- "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."
489
573
  ),
490
574
  default=True,
491
575
  )
@@ -500,32 +584,32 @@ def _get_parser():
500
584
  )
501
585
  preproc.add_argument(
502
586
  "--globalsignalmethod",
503
- dest="globalsignalmethod",
587
+ dest="initregressorsignalmethod",
504
588
  action="store",
505
589
  type=str,
506
590
  choices=["sum", "meanscale", "pca", "random"],
507
591
  help=(
508
- "The method for constructing the initial global signal regressor - straight summation, "
509
- "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, "
510
594
  "or initializing using random noise."
511
- f'Default is "{DEFAULT_GLOBALSIGNAL_METHOD}."'
595
+ f'Default is "{DEFAULT_INITREGRESSOR_METHOD}."'
512
596
  ),
513
- default=DEFAULT_GLOBALSIGNAL_METHOD,
597
+ default=DEFAULT_INITREGRESSOR_METHOD,
514
598
  )
515
599
  preproc.add_argument(
516
600
  "--globalpcacomponents",
517
- dest="globalpcacomponents",
601
+ dest="initregressorpcacomponents",
518
602
  action="store",
519
603
  type=float,
520
604
  metavar="VALUE",
521
605
  help=(
522
- "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"
523
607
  "many components. If "
524
608
  "0.0 < VALUE < 1.0, enough components will be retained to explain the fraction VALUE of the "
525
609
  "total variance. If VALUE is negative, the number of components will be to retain will be selected "
526
- f"automatically using the MLE method. Default is {DEFAULT_GLOBAL_PCACOMPONENTS}."
610
+ f"automatically using the MLE method. Default is {DEFAULT_INITREGRESSOR_PCACOMPONENTS}."
527
611
  ),
528
- default=DEFAULT_GLOBAL_PCACOMPONENTS,
612
+ default=DEFAULT_INITREGRESSOR_PCACOMPONENTS,
529
613
  )
530
614
  preproc.add_argument(
531
615
  "--slicetimes",
@@ -540,7 +624,7 @@ def _get_parser():
540
624
  "--numskip",
541
625
  dest="preprocskip",
542
626
  action="store",
543
- type=int,
627
+ type=lambda x: pf.is_int(parser, x, minval=0),
544
628
  metavar="SKIP",
545
629
  help=(
546
630
  "SKIP TRs were previously deleted during "
@@ -549,19 +633,6 @@ def _get_parser():
549
633
  ),
550
634
  default=0,
551
635
  )
552
- preproc.add_argument(
553
- "--numtozero",
554
- dest="numtozero",
555
- action="store",
556
- type=int,
557
- metavar="NUMPOINTS",
558
- help=(
559
- "When calculating the moving regressor, set this number of points to zero at the beginning of the "
560
- "voxel timecourses. This prevents initial points which may not be in equilibrium from contaminating the "
561
- "calculated sLFO signal. This may improve similarity fitting and GLM noise removal. Default is 0."
562
- ),
563
- default=0,
564
- )
565
636
  preproc.add_argument(
566
637
  "--timerange",
567
638
  dest="timerange",
@@ -577,6 +648,34 @@ def _get_parser():
577
648
  ),
578
649
  default=(-1, -1),
579
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
+ )
580
679
  preproc.add_argument(
581
680
  "--nothresh",
582
681
  dest="nothresh",
@@ -617,7 +716,7 @@ def _get_parser():
617
716
  "--regressorfreq",
618
717
  dest="inputfreq",
619
718
  action="store",
620
- type=lambda x: pf.is_float(parser, x),
719
+ type=lambda x: pf.is_float(parser, x, minval=0.0),
621
720
  metavar="FREQ",
622
721
  help=(
623
722
  "Probe regressor in file has sample "
@@ -712,10 +811,10 @@ def _get_parser():
712
811
  dest="similaritymetric",
713
812
  action="store",
714
813
  type=str,
715
- choices=["correlation", "mutualinfo", "hybrid"],
814
+ choices=["correlation", "mutualinfo", "hybrid", "riptide"],
716
815
  help=(
717
816
  "Similarity metric for finding delay values. "
718
- 'Choices are "correlation", "mutualinfo", and "hybrid". '
817
+ 'Choices are "correlation", "mutualinfo", "hybrid", and "riptide". '
719
818
  f"Default is {DEFAULT_SIMILARITYMETRIC}."
720
819
  ),
721
820
  default=DEFAULT_SIMILARITYMETRIC,
@@ -755,16 +854,19 @@ def _get_parser():
755
854
  # Correlation fitting options
756
855
  corr_fit = parser.add_argument_group("Correlation fitting options")
757
856
 
758
- fixdelay = corr_fit.add_mutually_exclusive_group()
759
- fixdelay.add_argument(
760
- "--fixdelay",
761
- dest="fixeddelayvalue",
762
- action="store",
763
- type=float,
764
- metavar="DELAYTIME",
765
- help=("Don't fit the delay time - set it to DELAYTIME seconds for all " "voxels."),
766
- 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,
767
867
  )
868
+
869
+ fixdelay = corr_fit.add_mutually_exclusive_group()
768
870
  fixdelay.add_argument(
769
871
  "--searchrange",
770
872
  dest="lag_extrema",
@@ -778,6 +880,13 @@ def _get_parser():
778
880
  ),
779
881
  default=(DEFAULT_LAGMIN, DEFAULT_LAGMAX),
780
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
+ )
781
890
  corr_fit.add_argument(
782
891
  "--sigmalimit",
783
892
  dest="widthmax",
@@ -823,7 +932,7 @@ def _get_parser():
823
932
  "--despecklepasses",
824
933
  dest="despeckle_passes",
825
934
  action=pf.IndicateSpecifiedAction,
826
- type=int,
935
+ type=lambda x: pf.is_int(parser, x, minval=0),
827
936
  metavar="PASSES",
828
937
  help=(
829
938
  "Detect and refit suspect correlations to "
@@ -877,8 +986,8 @@ def _get_parser():
877
986
  reg_ref.add_argument(
878
987
  "--passes",
879
988
  dest="passes",
880
- action="store",
881
- type=int,
989
+ action=pf.IndicateSpecifiedAction,
990
+ type=lambda x: pf.is_int(parser, x, minval=1),
882
991
  metavar="PASSES",
883
992
  help=("Set the number of processing passes to PASSES. " f"Default is {DEFAULT_PASSES}."),
884
993
  default=DEFAULT_PASSES,
@@ -999,15 +1108,6 @@ def _get_parser():
999
1108
  help=("Disables selecting the leftmost delay peak when setting the refine offset."),
1000
1109
  default=True,
1001
1110
  )
1002
- reg_ref.add_argument(
1003
- "--pickleft",
1004
- dest="dummy",
1005
- action="store_true",
1006
- help=(
1007
- "DEPRECATED. pickleft is now on by default. Use 'nopickleft' to disable it instead."
1008
- ),
1009
- default=True,
1010
- )
1011
1111
  reg_ref.add_argument(
1012
1112
  "--pickleftthresh",
1013
1113
  dest="pickleftthresh",
@@ -1015,11 +1115,23 @@ def _get_parser():
1015
1115
  metavar="THRESH",
1016
1116
  type=float,
1017
1117
  help=(
1018
- "Threshhold value (fraction of maximum) in a histogram "
1118
+ "Threshold value (fraction of maximum) in a histogram "
1019
1119
  f"to be considered the start of a peak. Default is {DEFAULT_PICKLEFT_THRESH}."
1020
1120
  ),
1021
1121
  default=DEFAULT_PICKLEFT_THRESH,
1022
1122
  )
1123
+ reg_ref.add_argument(
1124
+ "--sLFOnoiseampwindow",
1125
+ dest="sLFOnoiseampwindow",
1126
+ action="store",
1127
+ metavar="SECONDS",
1128
+ type=float,
1129
+ help=(
1130
+ "Width of the averaging window for filtering the RMS sLFO waveform to calculate "
1131
+ f"amplitude change over time. Default is {DEFAULT_SLFONOISEAMP_WINDOWSIZE}."
1132
+ ),
1133
+ default=DEFAULT_SLFONOISEAMP_WINDOWSIZE,
1134
+ )
1023
1135
 
1024
1136
  refine = reg_ref.add_mutually_exclusive_group()
1025
1137
  refine.add_argument(
@@ -1080,31 +1192,31 @@ def _get_parser():
1080
1192
  "--maxpasses",
1081
1193
  dest="maxpasses",
1082
1194
  action="store",
1083
- type=int,
1195
+ type=lambda x: pf.is_int(parser, x, minval=1),
1084
1196
  metavar="MAXPASSES",
1085
1197
  help=(
1086
- "Terminate refinement after MAXPASSES passes, whether or not convergence has occured. "
1198
+ "Terminate refinement after MAXPASSES passes, whether or not convergence has occurred. "
1087
1199
  f"Default is {DEFAULT_MAXPASSES}."
1088
1200
  ),
1089
1201
  default=DEFAULT_MAXPASSES,
1090
1202
  )
1091
1203
 
1092
- # GLM noise removal options
1093
- glm = parser.add_argument_group("GLM noise removal options")
1094
- glm.add_argument(
1095
- "--noglm",
1096
- 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",
1097
1209
  action="store_false",
1098
1210
  help=(
1099
- "Turn off GLM filtering to remove delayed "
1211
+ "Turn off regression filtering to remove delayed "
1100
1212
  "regressor from each voxel (disables output of "
1101
1213
  "fitNorm)."
1102
1214
  ),
1103
1215
  default=True,
1104
1216
  )
1105
- glm.add_argument(
1106
- "--glmsourcefile",
1107
- dest="glmsourcefile",
1217
+ slfofilt.add_argument(
1218
+ "--denoisesourcefile",
1219
+ dest="denoisesourcefile",
1108
1220
  action="store",
1109
1221
  type=lambda x: pf.is_valid_file(parser, x),
1110
1222
  metavar="FILE",
@@ -1115,23 +1227,63 @@ def _get_parser():
1115
1227
  ),
1116
1228
  default=None,
1117
1229
  )
1118
- glm.add_argument(
1230
+ slfofilt.add_argument(
1119
1231
  "--preservefiltering",
1120
1232
  dest="preservefiltering",
1121
1233
  action="store_true",
1122
- help="Don't reread data prior to performing GLM.",
1234
+ help="Don't reread data prior to performing sLFO filtering.",
1123
1235
  default=False,
1124
1236
  )
1125
- glm.add_argument(
1126
- "--glmderivs",
1127
- dest="glmderivs",
1237
+ slfofilt.add_argument(
1238
+ "--regressderivs",
1239
+ dest="regressderivs",
1128
1240
  action="store",
1129
- type=int,
1241
+ type=lambda x: pf.is_int(parser, x, minval=0),
1130
1242
  metavar="NDERIVS",
1131
1243
  help=(
1132
- 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}"
1133
1245
  ),
1134
- 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,
1135
1287
  )
1136
1288
 
1137
1289
  # Output options
@@ -1144,7 +1296,7 @@ def _get_parser():
1144
1296
  choices=["min", "less", "normal", "more", "max"],
1145
1297
  help=(
1146
1298
  "The level of file output produced. 'min' produces only absolutely essential files, 'less' adds in "
1147
- "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 "
1148
1300
  "would typically want around for interactive data exploration, "
1149
1301
  "'more' adds files that are sometimes useful, and 'max' outputs anything you might possibly want. "
1150
1302
  "Selecting 'max' will produce ~3x your input datafile size as output. "
@@ -1152,16 +1304,6 @@ def _get_parser():
1152
1304
  ),
1153
1305
  default=DEFAULT_OUTPUTLEVEL,
1154
1306
  )
1155
- output.add_argument(
1156
- "--nolimitoutput",
1157
- dest="limitoutput",
1158
- action="store_false",
1159
- help=(
1160
- "Save some of the large and rarely used files. "
1161
- "NB: THIS IS NOW DEPRECATED: Use '--outputlevel max' instead."
1162
- ),
1163
- default=True,
1164
- )
1165
1307
  output.add_argument(
1166
1308
  "--savelags",
1167
1309
  dest="savecorrtimes",
@@ -1173,7 +1315,7 @@ def _get_parser():
1173
1315
  "--histlen", # was -h
1174
1316
  dest="histlen",
1175
1317
  action="store",
1176
- type=int,
1318
+ type=lambda x: pf.is_int(parser, x, minval=5),
1177
1319
  metavar="HISTLEN",
1178
1320
  help=(f"Change the histogram length to HISTLEN. Default is {DEFAULT_HISTLEN}."),
1179
1321
  default=DEFAULT_HISTLEN,
@@ -1182,7 +1324,7 @@ def _get_parser():
1182
1324
  "--saveintermediatemaps",
1183
1325
  dest="saveintermediatemaps",
1184
1326
  action="store_true",
1185
- 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.",
1186
1328
  default=False,
1187
1329
  )
1188
1330
  output.add_argument(
@@ -1225,7 +1367,7 @@ def _get_parser():
1225
1367
  "--mklthreads",
1226
1368
  dest="mklthreads",
1227
1369
  action="store",
1228
- type=int,
1370
+ type=lambda x: pf.is_int(parser, x, minval=1),
1229
1371
  metavar="MKLTHREADS",
1230
1372
  help=(
1231
1373
  "If mkl library is installed, use no more than MKLTHREADS worker "
@@ -1253,6 +1395,13 @@ def _get_parser():
1253
1395
  help=("Will disable showing progress bars (helpful if stdout is going to a file)."),
1254
1396
  default=True,
1255
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
+ )
1256
1405
  misc.add_argument(
1257
1406
  "--checkpoint",
1258
1407
  dest="checkpoint",
@@ -1279,6 +1428,18 @@ def _get_parser():
1279
1428
  help=("Use double precision for output files."),
1280
1429
  default="single",
1281
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
+ )
1282
1443
  misc.add_argument(
1283
1444
  "--cifti",
1284
1445
  dest="isgrayordinate",
@@ -1307,19 +1468,44 @@ def _get_parser():
1307
1468
  help=("Disable use of shared memory for large array storage."),
1308
1469
  default=True,
1309
1470
  )
1310
- misc.add_argument(
1311
- "--memprofile",
1312
- dest="memprofile",
1313
- action="store_true",
1314
- help=("Enable memory profiling - " "warning: this slows things down a lot."),
1315
- default=False,
1316
- )
1317
1471
  pf.addtagopts(misc)
1318
1472
 
1319
1473
  # Experimental options (not fully tested, may not work)
1320
1474
  experimental = parser.add_argument_group(
1321
1475
  "Experimental options (not fully tested, or not tested at all, may not work). Beware!"
1322
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
+ )
1323
1509
  experimental.add_argument(
1324
1510
  "--territorymap",
1325
1511
  dest="territorymap",
@@ -1334,13 +1520,6 @@ def _get_parser():
1334
1520
  ),
1335
1521
  default=None,
1336
1522
  )
1337
- experimental.add_argument(
1338
- "--psdfilter",
1339
- dest="psdfilter",
1340
- action="store_true",
1341
- help=("Apply a PSD weighted Wiener filter to shifted timecourses prior to refinement."),
1342
- default=False,
1343
- )
1344
1523
  experimental.add_argument(
1345
1524
  "--wiener",
1346
1525
  dest="dodeconv",
@@ -1348,38 +1527,6 @@ def _get_parser():
1348
1527
  help=("Do Wiener deconvolution to find voxel transfer function."),
1349
1528
  default=False,
1350
1529
  )
1351
- experimental.add_argument(
1352
- "--corrbaselinespatialsigma",
1353
- dest="corrbaselinespatialsigma",
1354
- action="store",
1355
- type=float,
1356
- metavar="SIGMA",
1357
- help=("Spatial lowpass kernel, in mm, for filtering the correlation function baseline. "),
1358
- default=0.0,
1359
- )
1360
- experimental.add_argument(
1361
- "--corrbaselinetemphpfcutoff",
1362
- dest="corrbaselinetemphpfcutoff",
1363
- action="store",
1364
- type=float,
1365
- metavar="FREQ",
1366
- help=(
1367
- "Temporal highpass cutoff, in Hz, for filtering the correlation function baseline. "
1368
- ),
1369
- default=0.0,
1370
- )
1371
- experimental.add_argument(
1372
- "--spatialtolerance",
1373
- dest="spatialtolerance",
1374
- action="store",
1375
- type=float,
1376
- metavar="EPSILON",
1377
- help=(
1378
- "When checking to see if the spatial dimensions of two NIFTI files match, allow a relative difference "
1379
- "of EPSILON in any dimension. By default, this is set to 0.0, requiring an exact match. "
1380
- ),
1381
- default=0.0,
1382
- )
1383
1530
  experimental.add_argument(
1384
1531
  "--echocancel",
1385
1532
  dest="echocancel",
@@ -1394,68 +1541,6 @@ def _get_parser():
1394
1541
  help=("Attempt to detect and remove respiratory signal that strays into " "the LFO band."),
1395
1542
  default=False,
1396
1543
  )
1397
-
1398
- experimental.add_argument(
1399
- "--noisetimecourse",
1400
- dest="noisetimecoursespec",
1401
- metavar="FILENAME[:VALSPEC]",
1402
- help=(
1403
- "Find and remove any instance of the timecourse supplied from any regressors used for analysis. "
1404
- "(if VALSPEC is given, and there are multiple timecourses in the file, use the indicated timecourse."
1405
- "This can be the name of the regressor if it's in the file, or the column number). "
1406
- ),
1407
- default=None,
1408
- )
1409
- noise_group = experimental.add_mutually_exclusive_group()
1410
- noise_group.add_argument(
1411
- "--noisefreq",
1412
- dest="noisefreq",
1413
- action="store",
1414
- type=lambda x: pf.is_float(parser, x),
1415
- metavar="FREQ",
1416
- help=(
1417
- "Noise timecourse in file has sample "
1418
- "frequency FREQ (default is 1/tr) "
1419
- "NB: --noisefreq and --noisetstep) "
1420
- "are two ways to specify the same thing."
1421
- ),
1422
- default="auto",
1423
- )
1424
- noise_group.add_argument(
1425
- "--noisetstep",
1426
- dest="noisefreq",
1427
- action="store",
1428
- type=lambda x: pf.invert_float(parser, x),
1429
- metavar="TSTEP",
1430
- help=(
1431
- "Noise timecourse in file has sample "
1432
- "frequency FREQ (default is 1/tr) "
1433
- "NB: --noisefreq and --noisetstep) "
1434
- "are two ways to specify the same thing."
1435
- ),
1436
- default="auto",
1437
- )
1438
- experimental.add_argument(
1439
- "--noisestart",
1440
- dest="noisestarttime",
1441
- action="store",
1442
- type=float,
1443
- metavar="START",
1444
- help=(
1445
- "The time delay in seconds into the noise timecourse "
1446
- "file, corresponding in the first TR of the fMRI "
1447
- "file (default is 0.0)."
1448
- ),
1449
- default=0.0,
1450
- )
1451
- experimental.add_argument(
1452
- "--noiseinvert",
1453
- dest="noiseinvert",
1454
- action="store_true",
1455
- help=("Invert noise regressor prior to alignment."),
1456
- default=False,
1457
- )
1458
-
1459
1544
  experimental.add_argument(
1460
1545
  "--acfix",
1461
1546
  dest="fix_autocorrelation",
@@ -1493,6 +1578,15 @@ def _get_parser():
1493
1578
  ),
1494
1579
  default=False,
1495
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
+ )
1496
1590
  experimental.add_argument(
1497
1591
  "--dispersioncalc",
1498
1592
  dest="dodispersioncalc",
@@ -1501,18 +1595,74 @@ def _get_parser():
1501
1595
  default=False,
1502
1596
  )
1503
1597
  experimental.add_argument(
1504
- "--tmask",
1505
- dest="tmaskname",
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",
1506
1614
  action="store",
1507
- type=lambda x: pf.is_valid_file(parser, x),
1508
- metavar="FILE",
1615
+ type=lambda x: pf.is_int(parser, x, minval=0),
1616
+ metavar="LAGS",
1509
1617
  help=(
1510
- "Only correlate during epochs specified "
1511
- "in MASKFILE (NB: each line of FILE "
1512
- "contains the time and duration of an "
1513
- "epoch to include."
1618
+ f"Set number of TRs to use in prewhitening. Set to -1 to calculate automatically. Default is {DEFAULT_PREWHITEN_LAGS}."
1514
1619
  ),
1515
- default=None,
1620
+ default=DEFAULT_PREWHITEN_LAGS,
1621
+ )
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",
1631
+ help=(
1632
+ "Calculate a refined delay map using regression coefficient information. ***DEPRECATED***: refinedelay is now on by default."
1633
+ ),
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,
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,
1516
1666
  )
1517
1667
 
1518
1668
  # Debugging options
@@ -1530,7 +1680,7 @@ def _get_parser():
1530
1680
  "--focaldebug",
1531
1681
  dest="focaldebug",
1532
1682
  action="store_true",
1533
- help=("Enable targetted additional debugging output (used during development)."),
1683
+ help=("Enable targeted additional debugging output (used during development)."),
1534
1684
  default=False,
1535
1685
  )
1536
1686
  debugging.add_argument(
@@ -1541,10 +1691,10 @@ def _get_parser():
1541
1691
  default=False,
1542
1692
  )
1543
1693
  debugging.add_argument(
1544
- "--disabledockermemfix",
1545
- dest="dockermemfix",
1694
+ "--disablecontainermemfix",
1695
+ dest="containermemfix",
1546
1696
  action="store_false",
1547
- help=("Disable docker memory limit setting."),
1697
+ help=("Disable container memory limit setting."),
1548
1698
  default=True,
1549
1699
  )
1550
1700
  debugging.add_argument(
@@ -1604,10 +1754,10 @@ def _get_parser():
1604
1754
  default=False,
1605
1755
  )
1606
1756
  debugging.add_argument(
1607
- "--singleproc_glm",
1608
- dest="singleproc_glm",
1757
+ "--singleproc_regressionfilt",
1758
+ dest="singleproc_regressionfilt",
1609
1759
  action="store_true",
1610
- help=("Force single proc path for glm."),
1760
+ help=("Force single proc path for regression filtering."),
1611
1761
  default=False,
1612
1762
  )
1613
1763
  debugging.add_argument(
@@ -1628,9 +1778,51 @@ def _get_parser():
1628
1778
  return parser
1629
1779
 
1630
1780
 
1631
- def process_args(inputargs=None):
1781
+ def process_args(inputargs: Optional[Any] = None) -> Tuple[Any, object]:
1632
1782
  """
1633
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'
1634
1826
  """
1635
1827
  inargs, argstowrite = pf.setargs(_get_parser, inputargs=inputargs)
1636
1828
  args = vars(inargs)
@@ -1644,7 +1836,7 @@ def process_args(inputargs=None):
1644
1836
  # save the raw and formatted command lines
1645
1837
  args["commandlineargs"] = argstowrite[1:]
1646
1838
  thecommandline = " ".join(argstowrite)
1647
- tide_io.writevec([thecommandline], args["outputname"] + "_commandline.txt")
1839
+ tide_io.writevec(np.array([thecommandline]), args["outputname"] + "_commandline.txt")
1648
1840
  formattedcommandline = []
1649
1841
  for thetoken in argstowrite[0:3]:
1650
1842
  formattedcommandline.append(thetoken)
@@ -1663,7 +1855,9 @@ def process_args(inputargs=None):
1663
1855
  else:
1664
1856
  suffix = ""
1665
1857
  formattedcommandline[i] = prefix + formattedcommandline[i] + suffix
1666
- tide_io.writevec(formattedcommandline, args["outputname"] + "_formattedcommandline.txt")
1858
+ tide_io.writevec(
1859
+ np.array(formattedcommandline), args["outputname"] + "_formattedcommandline.txt"
1860
+ )
1667
1861
 
1668
1862
  LGR.debug("\nbefore postprocessing:\n{}".format(args))
1669
1863
 
@@ -1672,7 +1866,7 @@ def process_args(inputargs=None):
1672
1866
  # what fraction of the correlation window to avoid on either end when
1673
1867
  # fitting
1674
1868
  args["edgebufferfrac"] = 0.0
1675
- # only do fits in voxels that exceed threshhold
1869
+ # only do fits in voxels that exceed threshold
1676
1870
  args["enforcethresh"] = True
1677
1871
  # if set to the location of the first autocorrelation sidelobe,
1678
1872
  # this will fold back sidelobes
@@ -1685,8 +1879,6 @@ def process_args(inputargs=None):
1685
1879
  args["absmaxsigma"] = 10000.0
1686
1880
  # width of the reference autocorrelation function
1687
1881
  args["absminsigma"] = 0.05
1688
- # search window width for noise regressor mutual information function
1689
- args["noisesearchwindow"] = 30.0
1690
1882
  # number of MADs away from the median to consider an outlier
1691
1883
  args["sigdistoutlierfac"] = 10.0
1692
1884
 
@@ -1697,11 +1889,12 @@ def process_args(inputargs=None):
1697
1889
  args["hardlimit"] = True
1698
1890
  # The fraction of the main peak over which points are included in the peak
1699
1891
  args["searchfrac"] = 0.5
1700
- args["mp_chunksize"] = 50000
1892
+ args["mp_chunksize"] = 500
1893
+ args["patchminsize"] = DEFAULT_PATCHMINSIZE
1894
+ args["patchfwhm"] = DEFAULT_PATCHFWHM
1701
1895
 
1702
1896
  # significance estimation
1703
1897
  args["sighistlen"] = 1000
1704
- args["dosighistfit"] = True
1705
1898
  if args["corrtype"] == "linear":
1706
1899
  args["corrpadding"] = -1
1707
1900
  # pf.setifnotset(args, "windowfunc", "None")
@@ -1716,6 +1909,10 @@ def process_args(inputargs=None):
1716
1909
  args["check_autocorrelation"] = True
1717
1910
  args["acwidth"] = 0.0 # width of the reference autocorrelation function
1718
1911
 
1912
+ # delay refinement
1913
+ args["mindelay"] = DEFAULT_REFINEDELAYMINDELAY
1914
+ args["maxdelay"] = DEFAULT_REFINEDELAYMAXDELAY
1915
+ args["numpoints"] = DEFAULT_REFINEDELAYNUMPOINTS
1719
1916
  # diagnostic information about version
1720
1917
  (
1721
1918
  args["release_version"],
@@ -1730,6 +1927,8 @@ def process_args(inputargs=None):
1730
1927
  args = vars(theobj)
1731
1928
 
1732
1929
  # Additional argument parsing not handled by argparse
1930
+ args["passes"] = np.max([args["passes"], 1])
1931
+
1733
1932
  args["despeckle_passes"] = np.max([args["despeckle_passes"], 0])
1734
1933
 
1735
1934
  if "lag_extrema_nondefault" in args.keys():
@@ -1739,6 +1938,9 @@ def process_args(inputargs=None):
1739
1938
  args["lagmin"] = args["lag_extrema"][0]
1740
1939
  args["lagmax"] = args["lag_extrema"][1]
1741
1940
 
1941
+ if args["prewhitenlags"] == -1:
1942
+ args["prewhitenlags"] = int(np.max([np.fabs(args["lagmin"]), np.fabs(args["lagmax"])]))
1943
+
1742
1944
  # set startpoint and endpoint
1743
1945
  args["startpoint"], args["endpoint"] = pf.parserange(args["timerange"], descriptor="timerange")
1744
1946
 
@@ -1781,18 +1983,22 @@ def process_args(inputargs=None):
1781
1983
  else:
1782
1984
  args["nohistzero"] = True
1783
1985
 
1784
- if args["fixeddelayvalue"] is not None:
1785
- 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
1786
1992
  args["lag_extrema"] = (
1787
- args["fixeddelayvalue"] - 10.0,
1788
- args["fixeddelayvalue"] + 10.0,
1993
+ tempinitialdelayvalue - 10.0,
1994
+ tempinitialdelayvalue + 10.0,
1789
1995
  )
1790
1996
  else:
1791
- args["fixdelay"] = False
1997
+ args["initialdelayvalue"] = None
1792
1998
 
1793
1999
  if args["in_file"].endswith("txt") and args["realtr"] == "auto":
1794
2000
  raise ValueError(
1795
- "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."
1796
2002
  )
1797
2003
 
1798
2004
  if args["realtr"] != "auto":
@@ -1801,7 +2007,7 @@ def process_args(inputargs=None):
1801
2007
  if tide_io.checkifcifti(args["in_file"]):
1802
2008
  fmri_tr, dummy = tide_io.getciftitr(nib.load(args["in_file"]).header)
1803
2009
  else:
1804
- fmri_tr = nib.load(args["in_file"]).header.get_zooms()[3]
2010
+ fmri_tr, dummy = tide_io.fmritimeinfo(args["in_file"])
1805
2011
  args["realtr"] = fmri_tr
1806
2012
 
1807
2013
  if args["inputfreq"] == "auto":
@@ -1810,32 +2016,27 @@ def process_args(inputargs=None):
1810
2016
  else:
1811
2017
  args["inputfreq_nondefault"] = True
1812
2018
 
1813
- if args["noisetimecoursespec"] is not None:
1814
- (
1815
- args["noisetimecoursename"],
1816
- args["noisetimecoursevals"],
1817
- ) = tide_io.parsefilespec(args["noisetimecoursespec"])
1818
- else:
1819
- args["noisetimecoursename"] = None
1820
- args["noisetimecoursevals"] = None
1821
-
1822
- if args["noisefreq"] == "auto":
1823
- args["noisefreq"] = 1.0 / fmri_tr
1824
-
1825
- # mask processing
1826
- if args["corrmaskincludespec"] is not None:
1827
- (
1828
- args["corrmaskincludename"],
1829
- args["corrmaskincludevals"],
1830
- ) = tide_io.processnamespec(
1831
- args["corrmaskincludespec"],
1832
- "Including voxels where ",
1833
- "in correlation calculations.",
1834
- )
1835
- else:
1836
- args["corrmaskincludename"] = None
1837
-
1838
- # 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"]
1839
2040
  if args["brainmaskincludespec"] is not None:
1840
2041
  (
1841
2042
  args["brainmaskincludename"],
@@ -1845,11 +2046,22 @@ def process_args(inputargs=None):
1845
2046
  )
1846
2047
  if not os.path.isfile(args["brainmaskincludename"]):
1847
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")
1848
2058
  else:
1849
2059
  args["brainmaskincludename"] = None
1850
2060
  args["brainmaskincludevals"] = None
1851
2061
 
1852
- # if graymatterincludespec is set, set globalmeaninclude, refineinclude, and offsetinclude to it.
2062
+ # if graymatterincludespec is set, set initregressorinclude, offsetinclude to it.
2063
+ # graymasks = ["initregressor", "offset"]
2064
+ graymasks = ["initregressor"]
1853
2065
  if args["graymatterincludespec"] is not None:
1854
2066
  (
1855
2067
  args["graymatterincludename"],
@@ -1859,36 +2071,18 @@ def process_args(inputargs=None):
1859
2071
  )
1860
2072
  if not os.path.isfile(args["graymatterincludename"]):
1861
2073
  raise FileNotFoundError(f"file {args['graymatterincludename']} does not exist.")
1862
- (
1863
- args["globalmeanincludename"],
1864
- args["globalmeanincludevals"],
1865
- ) = (
1866
- args["graymatterincludename"],
1867
- args["graymatterincludevals"],
1868
- )
1869
- (
1870
- args["refineincludename"],
1871
- args["refineincludevals"],
1872
- ) = (
1873
- args["graymatterincludename"],
1874
- args["graymatterincludevals"],
1875
- )
1876
- (
1877
- args["offsetincludename"],
1878
- args["offsetincludevals"],
1879
- ) = (
1880
- args["graymatterincludename"],
1881
- args["graymatterincludevals"],
1882
- )
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")
1883
2083
  else:
1884
2084
  args["graymatterincludename"] = None
1885
2085
  args["graymatterincludevals"] = None
1886
- args["globalmeanincludename"] = None
1887
- args["globalmeanincludevals"] = None
1888
- args["refineincludename"] = None
1889
- args["refineincludevals"] = None
1890
- args["offsetincludename"] = None
1891
- args["offsetincludevals"] = None
1892
2086
 
1893
2087
  if args["whitematterincludespec"] is not None:
1894
2088
  (
@@ -1901,26 +2095,47 @@ def process_args(inputargs=None):
1901
2095
  args["whitematterincludename"] = None
1902
2096
  args["whitematterincludevals"] = None
1903
2097
 
1904
- 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:
1905
2121
  (
1906
- args["globalmeanincludename"],
1907
- args["globalmeanincludevals"],
2122
+ args["initregressorincludename"],
2123
+ args["initregressorincludevals"],
1908
2124
  ) = tide_io.processnamespec(
1909
- args["globalmeanincludespec"], "Including voxels where ", "in global mean."
2125
+ args["initregressorincludespec"],
2126
+ "Including voxels where ",
2127
+ "in initial regressor calculation.",
1910
2128
  )
1911
2129
 
1912
- if args["globalmeanexcludespec"] is not None:
2130
+ if args["initregressorexcludespec"] is not None:
1913
2131
  (
1914
- args["globalmeanexcludename"],
1915
- args["globalmeanexcludevals"],
2132
+ args["initregressorexcludename"],
2133
+ args["initregressorexcludevals"],
1916
2134
  ) = tide_io.processnamespec(
1917
- args["globalmeanexcludespec"],
2135
+ args["initregressorexcludespec"],
1918
2136
  "Excluding voxels where ",
1919
- "from global mean.",
2137
+ "from initial regressor calculation.",
1920
2138
  )
1921
- else:
1922
- args["globalmeanexcludename"] = None
1923
- args["globalmeanexcludevals"] = None
1924
2139
 
1925
2140
  if args["refineincludespec"] is not None:
1926
2141
  (
@@ -1937,9 +2152,6 @@ def process_args(inputargs=None):
1937
2152
  ) = tide_io.processnamespec(
1938
2153
  args["refineexcludespec"], "Excluding voxels where ", "from refinement."
1939
2154
  )
1940
- else:
1941
- args["refineexcludename"] = None
1942
- args["refineexcludevals"] = None
1943
2155
 
1944
2156
  if args["offsetincludespec"] is not None:
1945
2157
  (
@@ -1956,9 +2168,6 @@ def process_args(inputargs=None):
1956
2168
  ) = tide_io.processnamespec(
1957
2169
  args["offsetexcludespec"], "Excluding voxels where ", "from offset calculation."
1958
2170
  )
1959
- else:
1960
- args["offsetexcludename"] = None
1961
- args["offsetexcludevals"] = None
1962
2171
 
1963
2172
  # motion processing
1964
2173
  if args["motionfilespec"] is not None:
@@ -1971,25 +2180,35 @@ def process_args(inputargs=None):
1971
2180
  # process analysis modes
1972
2181
  if args["delaymapping"]:
1973
2182
  LGR.warning('Using "delaymapping" analysis mode. Overriding any affected arguments.')
1974
- pf.setifnotset(args, "passes", DEFAULT_DELAYMAPPING_PASSES)
1975
- 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
1976
2189
  pf.setifnotset(args, "lagmin", DEFAULT_DELAYMAPPING_LAGMIN)
1977
2190
  pf.setifnotset(args, "lagmax", DEFAULT_DELAYMAPPING_LAGMAX)
1978
2191
  args["refineoffset"] = True
2192
+ args["refinedelay"] = True
1979
2193
  args["outputlevel"] = "normal"
1980
- pf.setifnotset(args, "doglmfilt", False)
2194
+ pf.setifnotset(args, "dolinfitfilt", True)
1981
2195
 
1982
2196
  if args["denoising"]:
1983
2197
  LGR.warning('Using "denoising" analysis mode. Overriding any affected arguments.')
1984
- pf.setifnotset(args, "passes", DEFAULT_DENOISING_PASSES)
1985
- 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
1986
2206
  pf.setifnotset(args, "lagmin", DEFAULT_DENOISING_LAGMIN)
1987
2207
  pf.setifnotset(args, "lagmax", DEFAULT_DENOISING_LAGMAX)
1988
- pf.setifnotset(args, "peakfittype", DEFAULT_DENOISING_PEAKFITTYPE)
1989
- pf.setifnotset(args, "gausssigma", DEFAULT_DENOISING_SPATIALFILT)
1990
2208
  args["refineoffset"] = True
2209
+ args["refinedelay"] = True
1991
2210
  args["zerooutbadfit"] = False
1992
- pf.setifnotset(args, "doglmfilt", True)
2211
+ args["dolinfitfilt"] = True
1993
2212
 
1994
2213
  if args["docvrmap"]:
1995
2214
  LGR.warning('Using "CVR" analysis mode. Overriding any affected arguments.')
@@ -2001,22 +2220,24 @@ def process_args(inputargs=None):
2001
2220
  DEFAULT_CVRMAPPING_FILTER_LOWERPASS,
2002
2221
  DEFAULT_CVRMAPPING_FILTER_UPPERPASS,
2003
2222
  )
2004
- pf.setifnotset(args, "filterband", "arb")
2005
- 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"
2006
2227
  pf.setifnotset(args, "lagmin", DEFAULT_CVRMAPPING_LAGMIN)
2007
2228
  pf.setifnotset(args, "lagmax", DEFAULT_CVRMAPPING_LAGMAX)
2008
2229
  args["preservefiltering"] = True
2009
2230
  args["passes"] = 1
2010
2231
  args["outputlevel"] = "min"
2011
- args["doglmfilt"] = False
2232
+ args["dolinfitfilt"] = False
2012
2233
 
2013
- if args["globalpreselect"]:
2234
+ if args["initregressorpreselect"]:
2014
2235
  LGR.warning('Using "globalpreselect" analysis mode. Overriding any affected arguments.')
2015
2236
  args["passes"] = 1
2016
2237
  args["despeckle_passes"] = 0
2017
2238
  args["refinedespeckle"] = False
2018
2239
  args["outputlevel"] = "normal"
2019
- pf.setifnotset(args, "doglmfilt", False)
2240
+ pf.setifnotset(args, "dolinfitfilt", False)
2020
2241
  args["saveintermediatemaps"] = False
2021
2242
 
2022
2243
  # configure the filter
@@ -2036,6 +2257,7 @@ def process_args(inputargs=None):
2036
2257
  LGR.warning('Using "nirs" macro. Overriding any affected arguments.')
2037
2258
  args["nothresh"] = True
2038
2259
  pf.setifnotset(args, "preservefiltering", False)
2260
+ args["dataiszeromean"] = True
2039
2261
  args["refineprenorm"] = "var"
2040
2262
  args["ampthresh"] = 0.7
2041
2263
  args["ampthreshfromsig"] = False
@@ -2053,54 +2275,67 @@ def process_args(inputargs=None):
2053
2275
  args["savecorrtimes"] = False
2054
2276
  args["savelagregressors"] = False
2055
2277
  args["savedespecklemasks"] = False
2056
- args["saveminimumglmfiles"] = False
2057
- args["savenormalglmfiles"] = False
2278
+ args["saveminimumsLFOfiltfiles"] = False
2279
+ args["savenormalsLFOfiltfiles"] = False
2058
2280
  args["savemovingsignal"] = False
2059
- args["saveallglmfiles"] = False
2281
+ args["saveallsLFOfiltfiles"] = False
2060
2282
  elif args["outputlevel"] == "less":
2061
2283
  args["saveconfoundfiltered"] = False
2062
2284
  args["savegaussout"] = False
2063
2285
  args["savecorrtimes"] = False
2064
2286
  args["savelagregressors"] = False
2065
2287
  args["savedespecklemasks"] = False
2066
- args["saveminimumglmfiles"] = True
2067
- args["savenormalglmfiles"] = False
2288
+ args["saveminimumsLFOfiltfiles"] = True
2289
+ args["savenormalsLFOfiltfiles"] = False
2068
2290
  args["savemovingsignal"] = False
2069
- args["saveallglmfiles"] = False
2291
+ args["saveallsLFOfiltfiles"] = False
2070
2292
  elif args["outputlevel"] == "normal":
2071
2293
  args["saveconfoundfiltered"] = False
2072
2294
  args["savegaussout"] = False
2073
2295
  args["savecorrtimes"] = False
2074
2296
  args["savelagregressors"] = False
2075
2297
  args["savedespecklemasks"] = False
2076
- args["saveminimumglmfiles"] = True
2077
- args["savenormalglmfiles"] = True
2298
+ args["saveminimumsLFOfiltfiles"] = True
2299
+ args["savenormalsLFOfiltfiles"] = True
2078
2300
  args["savemovingsignal"] = False
2079
- args["saveallglmfiles"] = False
2301
+ args["saveallsLFOfiltfiles"] = False
2080
2302
  elif args["outputlevel"] == "more":
2081
2303
  args["saveconfoundfiltered"] = False
2082
2304
  args["savegaussout"] = False
2083
2305
  args["savecorrtimes"] = False
2084
2306
  args["savelagregressors"] = True
2085
2307
  args["savedespecklemasks"] = False
2086
- args["saveminimumglmfiles"] = True
2087
- args["savenormalglmfiles"] = True
2308
+ args["saveminimumsLFOfiltfiles"] = True
2309
+ args["savenormalsLFOfiltfiles"] = True
2088
2310
  args["savemovingsignal"] = True
2089
- args["saveallglmfiles"] = False
2311
+ args["saveallsLFOfiltfiles"] = False
2090
2312
  elif args["outputlevel"] == "max":
2091
2313
  args["saveconfoundfiltered"] = True
2092
2314
  args["savegaussout"] = True
2093
2315
  args["savecorrtimes"] = True
2094
2316
  args["savelagregressors"] = True
2095
2317
  args["savedespecklemasks"] = True
2096
- args["saveminimumglmfiles"] = True
2097
- args["savenormalglmfiles"] = True
2318
+ args["saveminimumsLFOfiltfiles"] = True
2319
+ args["savenormalsLFOfiltfiles"] = True
2098
2320
  args["savemovingsignal"] = True
2099
- args["saveallglmfiles"] = True
2321
+ args["saveallsLFOfiltfiles"] = True
2100
2322
  else:
2101
2323
  print(f"illegal output level {args['outputlevel']}")
2102
2324
  sys.exit()
2103
2325
 
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
+ ]
2338
+
2104
2339
  # dispersion calculation
2105
2340
  args["dispersioncalc_lower"] = args["lagmin"]
2106
2341
  args["dispersioncalc_upper"] = args["lagmax"]
@@ -2116,14 +2351,14 @@ def process_args(inputargs=None):
2116
2351
  args["territorymapname"],
2117
2352
  args["territorymapincludevals"],
2118
2353
  ) = tide_io.processnamespec(
2119
- args["territorymap"], "Including voxels where ", "in global mean."
2354
+ args["territorymap"], "Including voxels where ", "in initial regressor calculation."
2120
2355
  )
2121
2356
  else:
2122
2357
  args["territorymapname"] = None
2123
2358
  args["territorymapincludevals"] = None
2124
2359
 
2125
- # this is new enough to do retrospective GLM
2126
- args["retroglmcompatible"] = True
2360
+ # this is new enough to do retrospective regression filtering
2361
+ args["retroregresscompatible"] = True
2127
2362
 
2128
2363
  LGR.debug("\nafter postprocessing\n{}".format(args))
2129
2364