rapidtide 3.0a13__py3-none-any.whl → 3.0a14__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 (31) hide show
  1. rapidtide/DerivativeDelay.py +3 -1
  2. rapidtide/data/examples/src/testdelayvar +2 -1
  3. rapidtide/linfitfiltpass.py +2 -0
  4. rapidtide/makelaggedtcs.py +8 -5
  5. rapidtide/multiproc.py +8 -11
  6. rapidtide/refinedelay.py +173 -86
  7. rapidtide/tests/test_fullrunhappy_v1.py +13 -5
  8. rapidtide/tests/test_fullrunhappy_v2.py +16 -8
  9. rapidtide/tests/test_fullrunhappy_v3.py +16 -8
  10. rapidtide/tests/test_fullrunhappy_v4.py +16 -8
  11. rapidtide/tests/test_fullrunhappy_v5.py +14 -6
  12. rapidtide/tests/test_fullrunrapidtide_v1.py +18 -10
  13. rapidtide/tests/test_fullrunrapidtide_v2.py +21 -13
  14. rapidtide/tests/test_fullrunrapidtide_v3.py +14 -6
  15. rapidtide/tests/test_fullrunrapidtide_v4.py +14 -7
  16. rapidtide/tests/test_fullrunrapidtide_v5.py +12 -4
  17. rapidtide/tests/test_fullrunrapidtide_v6.py +23 -15
  18. rapidtide/tests/test_refinedelay.py +3 -1
  19. rapidtide/workflows/atlasaverage.py +40 -12
  20. rapidtide/workflows/delayvar.py +121 -33
  21. rapidtide/workflows/rapidtide.py +12 -8
  22. rapidtide/workflows/rapidtide_parser.py +13 -15
  23. rapidtide/workflows/regressfrommaps.py +2 -0
  24. rapidtide/workflows/retrolagtcs.py +1 -0
  25. rapidtide/workflows/retroregress.py +25 -1
  26. {rapidtide-3.0a13.dist-info → rapidtide-3.0a14.dist-info}/METADATA +1 -1
  27. {rapidtide-3.0a13.dist-info → rapidtide-3.0a14.dist-info}/RECORD +31 -31
  28. {rapidtide-3.0a13.dist-info → rapidtide-3.0a14.dist-info}/WHEEL +0 -0
  29. {rapidtide-3.0a13.dist-info → rapidtide-3.0a14.dist-info}/entry_points.txt +0 -0
  30. {rapidtide-3.0a13.dist-info → rapidtide-3.0a14.dist-info}/licenses/LICENSE +0 -0
  31. {rapidtide-3.0a13.dist-info → rapidtide-3.0a14.dist-info}/top_level.txt +0 -0
@@ -25,22 +25,30 @@ import rapidtide.workflows.happy_parser as happy_parser
25
25
  from rapidtide.tests.utils import get_examples_path, get_test_temp_path
26
26
 
27
27
 
28
- def test_fullrunhappy_v4(debug=False, displayplots=False):
28
+ def test_fullrunhappy_v4(debug=False, local=False, displayplots=False):
29
+ # set input and output directories
30
+ if local:
31
+ exampleroot = "../data/examples/src"
32
+ testtemproot = "./tmp"
33
+ else:
34
+ exampleroot = get_examples_path()
35
+ testtemproot = get_test_temp_path()
36
+
29
37
  # run happy
30
38
  inputargs = [
31
- os.path.join(get_examples_path(), "sub-HAPPYTEST.nii.gz"),
32
- os.path.join(get_examples_path(), "sub-HAPPYTEST.json"),
33
- os.path.join(get_test_temp_path(), "happyout4"),
39
+ os.path.join(exampleroot, "sub-HAPPYTEST.nii.gz"),
40
+ os.path.join(exampleroot, "sub-HAPPYTEST.json"),
41
+ os.path.join(testtemproot, "happyout4"),
34
42
  "--estweights",
35
- os.path.join(get_examples_path(), "sub-HAPPYTEST_smallmask.nii.gz"),
43
+ os.path.join(exampleroot, "sub-HAPPYTEST_smallmask.nii.gz"),
36
44
  "--projmask",
37
- os.path.join(get_examples_path(), "sub-HAPPYTEST_smallmask.nii.gz"),
45
+ os.path.join(exampleroot, "sub-HAPPYTEST_smallmask.nii.gz"),
38
46
  "--mklthreads",
39
47
  "-1",
40
48
  "--model",
41
49
  "model_revised",
42
50
  "--motionfile",
43
- os.path.join(get_examples_path(), "sub-HAPPYTEST_mcf.par"),
51
+ os.path.join(exampleroot, "sub-HAPPYTEST_mcf.par"),
44
52
  "--aliasedcorrelation",
45
53
  ]
46
54
  happy_workflow.happy_main(happy_parser.process_args(inputargs=inputargs))
@@ -48,4 +56,4 @@ def test_fullrunhappy_v4(debug=False, displayplots=False):
48
56
 
49
57
  if __name__ == "__main__":
50
58
  mpl.use("TkAgg")
51
- test_fullrunhappy_v4(debug=True, displayplots=True)
59
+ test_fullrunhappy_v4(debug=True, local=True, displayplots=True)
@@ -25,16 +25,24 @@ import rapidtide.workflows.happy_parser as happy_parser
25
25
  from rapidtide.tests.utils import get_examples_path, get_test_temp_path
26
26
 
27
27
 
28
- def test_fullrunhappy_v4(debug=False, displayplots=False):
28
+ def test_fullrunhappy_v4(debug=False, local=False, displayplots=False):
29
+ # set input and output directories
30
+ if local:
31
+ exampleroot = "../data/examples/src"
32
+ testtemproot = "./tmp"
33
+ else:
34
+ exampleroot = get_examples_path()
35
+ testtemproot = get_test_temp_path()
36
+
29
37
  # run happy
30
38
  inputargs = [
31
- os.path.join(get_examples_path(), "sub-HAPPYTEST.nii.gz"),
32
- os.path.join(get_examples_path(), "sub-HAPPYTEST.json"),
33
- os.path.join(get_test_temp_path(), "happyout5"),
39
+ os.path.join(exampleroot, "sub-HAPPYTEST.nii.gz"),
40
+ os.path.join(exampleroot, "sub-HAPPYTEST.json"),
41
+ os.path.join(testtemproot, "happyout5"),
34
42
  "--model",
35
43
  "model_revised",
36
44
  "--motionfile",
37
- os.path.join(get_examples_path(), "sub-HAPPYTEST_mcf.par"),
45
+ os.path.join(exampleroot, "sub-HAPPYTEST_mcf.par"),
38
46
  "--nomotderiv",
39
47
  "--nomotorthogonalize",
40
48
  "--motfiltorder",
@@ -53,4 +61,4 @@ def test_fullrunhappy_v4(debug=False, displayplots=False):
53
61
 
54
62
  if __name__ == "__main__":
55
63
  mpl.use("TkAgg")
56
- test_fullrunhappy_v4(debug=True, displayplots=True)
64
+ test_fullrunhappy_v4(debug=True, local=True, displayplots=True)
@@ -26,11 +26,19 @@ import rapidtide.workflows.rapidtide_parser as rapidtide_parser
26
26
  from rapidtide.tests.utils import get_examples_path, get_test_temp_path
27
27
 
28
28
 
29
- def test_fullrunrapidtide_v1(debug=False, displayplots=False):
29
+ def test_fullrunrapidtide_v1(debug=False, local=False, displayplots=False):
30
+ # set input and output directories
31
+ if local:
32
+ exampleroot = "../data/examples/src"
33
+ testtemproot = "./tmp"
34
+ else:
35
+ exampleroot = get_examples_path()
36
+ testtemproot = get_test_temp_path()
37
+
30
38
  # run rapidtide
31
39
  inputargs = [
32
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST.nii.gz"),
33
- os.path.join(get_test_temp_path(), "sub-RAPIDTIDETEST1"),
40
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST.nii.gz"),
41
+ os.path.join(testtemproot, "sub-RAPIDTIDETEST1"),
34
42
  "--spatialfilt",
35
43
  "2",
36
44
  "--simcalcrange",
@@ -46,11 +54,11 @@ def test_fullrunrapidtide_v1(debug=False, displayplots=False):
46
54
  "4.0",
47
55
  ]
48
56
  rapidtide_workflow.rapidtide_main(rapidtide_parser.process_args(inputargs=inputargs))
49
- rapidtide_quality.qualitycheck(os.path.join(get_test_temp_path(), "sub-RAPIDTIDETEST1"))
57
+ rapidtide_quality.qualitycheck(os.path.join(testtemproot, "sub-RAPIDTIDETEST1"))
50
58
 
51
59
  inputargs = [
52
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST.nii.gz"),
53
- os.path.join(get_test_temp_path(), "sub-RAPIDTIDETEST1_fixval"),
60
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST.nii.gz"),
61
+ os.path.join(testtemproot, "sub-RAPIDTIDETEST1_fixval"),
54
62
  "--spatialfilt",
55
63
  "2",
56
64
  "--simcalcrange",
@@ -70,8 +78,8 @@ def test_fullrunrapidtide_v1(debug=False, displayplots=False):
70
78
  rapidtide_workflow.rapidtide_main(rapidtide_parser.process_args(inputargs=inputargs))
71
79
 
72
80
  inputargs = [
73
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST.nii.gz"),
74
- os.path.join(get_test_temp_path(), "sub-RAPIDTIDETEST1_fixmap"),
81
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST.nii.gz"),
82
+ os.path.join(testtemproot, "sub-RAPIDTIDETEST1_fixmap"),
75
83
  "--spatialfilt",
76
84
  "2",
77
85
  "--simcalcrange",
@@ -85,11 +93,11 @@ def test_fullrunrapidtide_v1(debug=False, displayplots=False):
85
93
  "3",
86
94
  "--nodenoise",
87
95
  "--initialdelay",
88
- os.path.join(get_test_temp_path(), "sub-RAPIDTIDETEST1_desc-maxtime_map.nii.gz"),
96
+ os.path.join(testtemproot, "sub-RAPIDTIDETEST1_desc-maxtime_map.nii.gz"),
89
97
  ]
90
98
  rapidtide_workflow.rapidtide_main(rapidtide_parser.process_args(inputargs=inputargs))
91
99
 
92
100
 
93
101
  if __name__ == "__main__":
94
102
  mpl.use("TkAgg")
95
- test_fullrunrapidtide_v1(debug=True, displayplots=True)
103
+ test_fullrunrapidtide_v1(debug=True, local=True, displayplots=True)
@@ -25,27 +25,35 @@ import rapidtide.workflows.rapidtide_parser as rapidtide_parser
25
25
  from rapidtide.tests.utils import get_examples_path, get_test_temp_path
26
26
 
27
27
 
28
- def test_fullrunrapidtide_v2(debug=False, displayplots=False):
28
+ def test_fullrunrapidtide_v2(debug=False, local=False, displayplots=False):
29
+ # set input and output directories
30
+ if local:
31
+ exampleroot = "../data/examples/src"
32
+ testtemproot = "./tmp"
33
+ else:
34
+ exampleroot = get_examples_path()
35
+ testtemproot = get_test_temp_path()
36
+
29
37
  # run rapidtide
30
38
  inputargs = [
31
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST.nii.gz"),
32
- os.path.join(get_test_temp_path(), "sub-RAPIDTIDETEST2"),
39
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST.nii.gz"),
40
+ os.path.join(testtemproot, "sub-RAPIDTIDETEST2"),
33
41
  "--tincludemask",
34
- os.path.join(get_examples_path(), "tmask3.txt"),
42
+ os.path.join(exampleroot, "tmask3.txt"),
35
43
  "--corrmask",
36
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST_restrictedmask.nii.gz"),
44
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST_restrictedmask.nii.gz"),
37
45
  "--globalmeaninclude",
38
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST_brainmask.nii.gz"),
46
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST_brainmask.nii.gz"),
39
47
  "--globalmeanexclude",
40
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST_nullmask.nii.gz"),
48
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST_nullmask.nii.gz"),
41
49
  "--refineinclude",
42
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST_brainmask.nii.gz"),
50
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST_brainmask.nii.gz"),
43
51
  "--refineexclude",
44
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST_nullmask.nii.gz"),
52
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST_nullmask.nii.gz"),
45
53
  "--offsetinclude",
46
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST_brainmask.nii.gz"),
54
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST_brainmask.nii.gz"),
47
55
  "--offsetexclude",
48
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST_nullmask.nii.gz"),
56
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST_nullmask.nii.gz"),
49
57
  "--spatialfilt",
50
58
  "-1",
51
59
  "--savelags",
@@ -74,7 +82,7 @@ def test_fullrunrapidtide_v2(debug=False, displayplots=False):
74
82
  "--refineprenorm",
75
83
  "var",
76
84
  "--motionfile",
77
- os.path.join(get_examples_path(), "fakemotion.par"),
85
+ os.path.join(exampleroot, "fakemotion.par"),
78
86
  ]
79
87
  if debug:
80
88
  print(inputargs)
@@ -83,4 +91,4 @@ def test_fullrunrapidtide_v2(debug=False, displayplots=False):
83
91
 
84
92
  if __name__ == "__main__":
85
93
  mpl.use("TkAgg")
86
- test_fullrunrapidtide_v2(debug=True, displayplots=True)
94
+ test_fullrunrapidtide_v2(debug=True, local=True, displayplots=True)
@@ -25,13 +25,21 @@ import rapidtide.workflows.rapidtide_parser as rapidtide_parser
25
25
  from rapidtide.tests.utils import get_examples_path, get_test_temp_path
26
26
 
27
27
 
28
- def test_fullrunrapidtide_v3(debug=False, displayplots=False):
28
+ def test_fullrunrapidtide_v3(debug=False, local=False, displayplots=False):
29
+ # set input and output directories
30
+ if local:
31
+ exampleroot = "../data/examples/src"
32
+ testtemproot = "./tmp"
33
+ else:
34
+ exampleroot = get_examples_path()
35
+ testtemproot = get_test_temp_path()
36
+
29
37
  # run rapidtide
30
38
  inputargs = [
31
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST.nii.gz"),
32
- os.path.join(get_test_temp_path(), "sub-RAPIDTIDETEST3"),
39
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST.nii.gz"),
40
+ os.path.join(testtemproot, "sub-RAPIDTIDETEST3"),
33
41
  "--corrmask",
34
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST_restrictedmask.nii.gz:1"),
42
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST_restrictedmask.nii.gz:1"),
35
43
  "--maxpasses",
36
44
  "2",
37
45
  "--numnull",
@@ -60,7 +68,7 @@ def test_fullrunrapidtide_v3(debug=False, displayplots=False):
60
68
  "R",
61
69
  "--regressor",
62
70
  os.path.join(
63
- get_examples_path(),
71
+ exampleroot,
64
72
  "sub-RAPIDTIDETEST_desc-oversampledmovingregressor_timeseries.json:pass3",
65
73
  ),
66
74
  ]
@@ -71,4 +79,4 @@ def test_fullrunrapidtide_v3(debug=False, displayplots=False):
71
79
 
72
80
  if __name__ == "__main__":
73
81
  mpl.use("TkAgg")
74
- test_fullrunrapidtide_v3(debug=True, displayplots=True)
82
+ test_fullrunrapidtide_v3(debug=True, local=True, displayplots=True)
@@ -25,18 +25,25 @@ import rapidtide.workflows.rapidtide_parser as rapidtide_parser
25
25
  from rapidtide.tests.utils import get_examples_path, get_test_temp_path
26
26
 
27
27
 
28
- def test_fullrunrapidtide_v4(debug=False, displayplots=False):
28
+ def test_fullrunrapidtide_v4(debug=False, local=False, displayplots=False):
29
+ # set input and output directories
30
+ if local:
31
+ exampleroot = "../data/examples/src"
32
+ testtemproot = "./tmp"
33
+ else:
34
+ exampleroot = get_examples_path()
35
+ testtemproot = get_test_temp_path()
36
+
29
37
  # run rapidtide
30
38
  inputargs = [
31
- os.path.join(get_examples_path(), "sub-NIRSRAPIDTIDETEST.txt"),
32
- os.path.join(get_test_temp_path(), "sub-NIRSRAPIDTIDETEST4"),
39
+ os.path.join(exampleroot, "sub-NIRSRAPIDTIDETEST.txt"),
40
+ os.path.join(testtemproot, "sub-NIRSRAPIDTIDETEST4"),
33
41
  "--globalmeaninclude",
34
- os.path.join(get_examples_path(), "sub-NIRSRAPIDTIDETEST_mask.txt"),
42
+ os.path.join(exampleroot, "sub-NIRSRAPIDTIDETEST_mask.txt"),
35
43
  "--nirs",
36
44
  "--datatstep",
37
45
  "0.2560",
38
- "--globalmaskmethod",
39
- "variance",
46
+ "--dataiszeromean",
40
47
  "--norefinedelay",
41
48
  "--despecklepasses",
42
49
  "0",
@@ -59,4 +66,4 @@ def test_fullrunrapidtide_v4(debug=False, displayplots=False):
59
66
 
60
67
  if __name__ == "__main__":
61
68
  mpl.use("TkAgg")
62
- test_fullrunrapidtide_v4(debug=True, displayplots=True)
69
+ test_fullrunrapidtide_v4(debug=True, local=True, displayplots=True)
@@ -25,11 +25,19 @@ import rapidtide.workflows.rapidtide_parser as rapidtide_parser
25
25
  from rapidtide.tests.utils import get_examples_path, get_test_temp_path
26
26
 
27
27
 
28
- def test_fullrunrapidtide_v5(debug=False, displayplots=False):
28
+ def test_fullrunrapidtide_v5(debug=False, local=False, displayplots=False):
29
+ # set input and output directories
30
+ if local:
31
+ exampleroot = "../data/examples/src"
32
+ testtemproot = "./tmp"
33
+ else:
34
+ exampleroot = get_examples_path()
35
+ testtemproot = get_test_temp_path()
36
+
29
37
  # run rapidtide
30
38
  inputargs = [
31
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST_cifti.ptseries.nii"),
32
- os.path.join(get_test_temp_path(), "sub-RAPIDTIDETEST5"),
39
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST_cifti.ptseries.nii"),
40
+ os.path.join(testtemproot, "sub-RAPIDTIDETEST5"),
33
41
  "--nprocs",
34
42
  "-1",
35
43
  "--passes",
@@ -46,4 +54,4 @@ def test_fullrunrapidtide_v5(debug=False, displayplots=False):
46
54
 
47
55
  if __name__ == "__main__":
48
56
  mpl.use("TkAgg")
49
- test_fullrunrapidtide_v5(debug=True, displayplots=True)
57
+ test_fullrunrapidtide_v5(debug=True, local=True, displayplots=True)
@@ -28,11 +28,19 @@ import rapidtide.workflows.retroregress as rapidtide_retroregress
28
28
  from rapidtide.tests.utils import get_examples_path, get_test_temp_path
29
29
 
30
30
 
31
- def test_fullrunrapidtide_v6(debug=False, displayplots=False):
31
+ def test_fullrunrapidtide_v6(debug=False, local=False, displayplots=False):
32
+ # set input and output directories
33
+ if local:
34
+ exampleroot = "../data/examples/src"
35
+ testtemproot = "./tmp"
36
+ else:
37
+ exampleroot = get_examples_path()
38
+ testtemproot = get_test_temp_path()
39
+
32
40
  # run rapidtide
33
41
  inputargs = [
34
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST.nii.gz"),
35
- os.path.join(get_test_temp_path(), "sub-RAPIDTIDETEST6"),
42
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST.nii.gz"),
43
+ os.path.join(testtemproot, "sub-RAPIDTIDETEST6"),
36
44
  "--spatialfilt",
37
45
  "2",
38
46
  "--simcalcrange",
@@ -54,10 +62,10 @@ def test_fullrunrapidtide_v6(debug=False, displayplots=False):
54
62
  rapidtide_workflow.rapidtide_main(rapidtide_parser.process_args(inputargs=inputargs))
55
63
 
56
64
  inputargs = [
57
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST.nii.gz"),
58
- os.path.join(get_test_temp_path(), "sub-RAPIDTIDETEST6"),
65
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST.nii.gz"),
66
+ os.path.join(testtemproot, "sub-RAPIDTIDETEST6"),
59
67
  "--alternateoutput",
60
- os.path.join(get_test_temp_path(), "2deriv"),
68
+ os.path.join(testtemproot, "2deriv"),
61
69
  "--nprocs",
62
70
  "-1",
63
71
  "--regressderivs",
@@ -69,10 +77,10 @@ def test_fullrunrapidtide_v6(debug=False, displayplots=False):
69
77
  rapidtide_retroregress.retroregress(rapidtide_retroregress.process_args(inputargs=inputargs))
70
78
 
71
79
  inputargs = [
72
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST.nii.gz"),
73
- os.path.join(get_test_temp_path(), "sub-RAPIDTIDETEST6"),
80
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST.nii.gz"),
81
+ os.path.join(testtemproot, "sub-RAPIDTIDETEST6"),
74
82
  "--alternateoutput",
75
- os.path.join(get_test_temp_path(), "1deriv_refined_corrected"),
83
+ os.path.join(testtemproot, "1deriv_refined_corrected"),
76
84
  "--nprocs",
77
85
  "1",
78
86
  "--regressderivs",
@@ -85,10 +93,10 @@ def test_fullrunrapidtide_v6(debug=False, displayplots=False):
85
93
  rapidtide_retroregress.retroregress(rapidtide_retroregress.process_args(inputargs=inputargs))
86
94
 
87
95
  inputargs = [
88
- os.path.join(get_examples_path(), "sub-RAPIDTIDETEST.nii.gz"),
89
- os.path.join(get_test_temp_path(), "sub-RAPIDTIDETEST6"),
96
+ os.path.join(exampleroot, "sub-RAPIDTIDETEST.nii.gz"),
97
+ os.path.join(testtemproot, "sub-RAPIDTIDETEST6"),
90
98
  "--alternateoutput",
91
- os.path.join(get_test_temp_path(), "concordance"),
99
+ os.path.join(testtemproot, "concordance"),
92
100
  "--nprocs",
93
101
  "-1",
94
102
  "--regressderivs",
@@ -118,8 +126,8 @@ def test_fullrunrapidtide_v6(debug=False, displayplots=False):
118
126
  "lfofilterR",
119
127
  ]:
120
128
  print(f"Testing map={map}")
121
- filename1 = os.path.join(get_test_temp_path(), f"sub-RAPIDTIDETEST6_desc-{map}_map.nii.gz")
122
- filename2 = os.path.join(get_test_temp_path(), f"concordance_desc-{map}_map.nii.gz")
129
+ filename1 = os.path.join(testtemproot, f"sub-RAPIDTIDETEST6_desc-{map}_map.nii.gz")
130
+ filename2 = os.path.join(testtemproot, f"concordance_desc-{map}_map.nii.gz")
123
131
  assert tide_io.checkniftifilematch(
124
132
  filename1,
125
133
  filename2,
@@ -132,4 +140,4 @@ def test_fullrunrapidtide_v6(debug=False, displayplots=False):
132
140
 
133
141
  if __name__ == "__main__":
134
142
  mpl.use("TkAgg")
135
- test_fullrunrapidtide_v6(debug=True, displayplots=True)
143
+ test_fullrunrapidtide_v6(debug=True, local=True, displayplots=True)
@@ -195,7 +195,9 @@ def eval_refinedelay(
195
195
 
196
196
  delayoffset = filteredregressderivratios * 0.0
197
197
  for i in range(filteredregressderivratios.shape[0]):
198
- delayoffset[i] = tide_refinedelay.ratiotodelay(filteredregressderivratios[i])
198
+ delayoffset[i], closestoffset = tide_refinedelay.ratiotodelay(
199
+ filteredregressderivratios[i]
200
+ )
199
201
 
200
202
  # do the tests
201
203
  msethresh = 0.1
@@ -135,6 +135,15 @@ def _get_parser():
135
135
  ),
136
136
  default=None,
137
137
  )
138
+ parser.add_argument(
139
+ "--regionlabelfile",
140
+ type=lambda x: pf.is_valid_file(parser, x),
141
+ help=(
142
+ "The name of of a text file containing the labels of the regions, one per line. The first line is "
143
+ "the label integer value 1, etc."
144
+ ),
145
+ default=None,
146
+ )
138
147
  parser.add_argument(
139
148
  "--includemask",
140
149
  dest="includespec",
@@ -224,11 +233,9 @@ def atlasaverage(args):
224
233
  sys.exit()
225
234
 
226
235
  print("reshaping")
227
- xsize = thedims[1]
228
- ysize = thedims[2]
229
- numslices = thedims[3]
230
- numtimepoints = thedims[4]
231
- numvoxels = int(xsize) * int(ysize) * int(numslices)
236
+ xdim, ydim, numslices, numtimepoints = tide_io.parseniftidims(thedims)
237
+ xsize, ysize, slicethickness, tr = tide_io.parseniftisizes(thesizes)
238
+ numvoxels = int(xdim) * int(ydim) * int(numslices)
232
239
 
233
240
  templatevoxels = np.reshape(template_data, numvoxels).astype(int)
234
241
  inputvoxels = np.reshape(input_data, (numvoxels, numtimepoints))
@@ -273,7 +280,7 @@ def atlasaverage(args):
273
280
  themask = themask * includemask.reshape((numvoxels))
274
281
  if args.debug:
275
282
  tide_io.savetonifti(
276
- includemask.reshape((xsize, ysize, numslices)),
283
+ includemask.reshape((xdim, ydim, numslices)),
277
284
  template_hdr,
278
285
  f"{args.outputroot}_includemask",
279
286
  )
@@ -281,7 +288,7 @@ def atlasaverage(args):
281
288
  themask = themask * (1 - excludemask.reshape((numvoxels)))
282
289
  if args.debug:
283
290
  tide_io.savetonifti(
284
- excludemask.reshape((xsize, ysize, numslices)),
291
+ excludemask.reshape((xdim, ydim, numslices)),
285
292
  template_hdr,
286
293
  f"{args.outputroot}_excludemask",
287
294
  )
@@ -289,11 +296,21 @@ def atlasaverage(args):
289
296
  themask = themask * extramask.reshape((numvoxels))
290
297
  if args.debug:
291
298
  tide_io.savetonifti(
292
- extramask.reshape((xsize, ysize, numslices)),
299
+ extramask.reshape((xdim, ydim, numslices)),
293
300
  template_hdr,
294
301
  f"{args.outputroot}_extramask",
295
302
  )
296
303
 
304
+ # get the region names
305
+ if args.regionlabelfile is None:
306
+ regionlabels = []
307
+ numregions = np.max(templatevoxels)
308
+ numdigits = int(np.log10(numregions)) + 1
309
+ for regnum in range(1, numregions + 1):
310
+ regionlabels.append(f"region_{str(regnum).zfill(numdigits)}")
311
+ else:
312
+ regionlabels = tide_io.readlabels(args.regionlabelfile)
313
+
297
314
  # decide what regions we will summarize
298
315
  if args.regionlistfile is None:
299
316
  numregions = np.max(templatevoxels)
@@ -301,6 +318,11 @@ def atlasaverage(args):
301
318
  else:
302
319
  regionlist = tide_io.readvec(args.regionlistfile).astype(int)
303
320
  numregions = len(regionlist)
321
+ newlabels = []
322
+ for theregion in range(numregions):
323
+ newlabels.append(regionlabels[theregion])
324
+ regionlabels = newlabels
325
+
304
326
  timecourses = np.zeros((numregions, numtimepoints), dtype="float")
305
327
  print(f"{numregions=}, {regionlist=}")
306
328
 
@@ -348,7 +370,13 @@ def atlasaverage(args):
348
370
  )
349
371
  if args.debug:
350
372
  print("timecourses shape:", timecourses.shape)
351
- tide_io.writenpvecs(timecourses, args.outputroot)
373
+ tide_io.writebidstsv(
374
+ args.outputroot,
375
+ timecourses,
376
+ 1.0 / tr,
377
+ columns=regionlabels,
378
+ yaxislabel="delay offset",
379
+ )
352
380
  else:
353
381
  print("processing 3D input file")
354
382
  outputvoxels = inputvoxels * 0.0
@@ -416,19 +444,19 @@ def atlasaverage(args):
416
444
  segmentedatlasvoxels += scratchvoxels
417
445
  template_hdr["dim"][4] = 1
418
446
  tide_io.savetonifti(
419
- outputvoxels.reshape((xsize, ysize, numslices)),
447
+ outputvoxels.reshape((xdim, ydim, numslices)),
420
448
  template_hdr,
421
449
  args.outputroot,
422
450
  )
423
451
  tide_io.savetonifti(
424
- segmentedatlasvoxels.reshape((xsize, ysize, numslices)),
452
+ segmentedatlasvoxels.reshape((xdim, ydim, numslices)),
425
453
  template_hdr,
426
454
  args.outputroot + "_percentiles",
427
455
  )
428
456
 
429
457
  if args.includename is not None or args.excludename is not None:
430
458
  tide_io.savetonifti(
431
- (templatevoxels * themask).reshape((xsize, ysize, numslices)),
459
+ (templatevoxels * themask).reshape((xdim, ydim, numslices)),
432
460
  template_hdr,
433
461
  f"{args.outputroot}_maskedatlas",
434
462
  )