junifer 0.0.3.dev188__py3-none-any.whl → 0.0.4__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 (178) hide show
  1. junifer/_version.py +14 -2
  2. junifer/api/cli.py +162 -17
  3. junifer/api/functions.py +87 -419
  4. junifer/api/parser.py +24 -0
  5. junifer/api/queue_context/__init__.py +8 -0
  6. junifer/api/queue_context/gnu_parallel_local_adapter.py +258 -0
  7. junifer/api/queue_context/htcondor_adapter.py +365 -0
  8. junifer/api/queue_context/queue_context_adapter.py +60 -0
  9. junifer/api/queue_context/tests/test_gnu_parallel_local_adapter.py +192 -0
  10. junifer/api/queue_context/tests/test_htcondor_adapter.py +257 -0
  11. junifer/api/res/afni/run_afni_docker.sh +6 -6
  12. junifer/api/res/ants/ResampleImage +3 -0
  13. junifer/api/res/ants/antsApplyTransforms +3 -0
  14. junifer/api/res/ants/antsApplyTransformsToPoints +3 -0
  15. junifer/api/res/ants/run_ants_docker.sh +39 -0
  16. junifer/api/res/fsl/applywarp +3 -0
  17. junifer/api/res/fsl/flirt +3 -0
  18. junifer/api/res/fsl/img2imgcoord +3 -0
  19. junifer/api/res/fsl/run_fsl_docker.sh +39 -0
  20. junifer/api/res/fsl/std2imgcoord +3 -0
  21. junifer/api/res/run_conda.sh +4 -4
  22. junifer/api/res/run_venv.sh +22 -0
  23. junifer/api/tests/data/partly_cloudy_agg_mean_tian.yml +16 -0
  24. junifer/api/tests/test_api_utils.py +21 -3
  25. junifer/api/tests/test_cli.py +232 -9
  26. junifer/api/tests/test_functions.py +211 -439
  27. junifer/api/tests/test_parser.py +1 -1
  28. junifer/configs/juseless/datagrabbers/aomic_id1000_vbm.py +6 -1
  29. junifer/configs/juseless/datagrabbers/camcan_vbm.py +6 -1
  30. junifer/configs/juseless/datagrabbers/ixi_vbm.py +6 -1
  31. junifer/configs/juseless/datagrabbers/tests/test_ucla.py +8 -8
  32. junifer/configs/juseless/datagrabbers/ucla.py +44 -26
  33. junifer/configs/juseless/datagrabbers/ukb_vbm.py +6 -1
  34. junifer/data/VOIs/meta/AutobiographicalMemory_VOIs.txt +23 -0
  35. junifer/data/VOIs/meta/Power2013_MNI_VOIs.tsv +264 -0
  36. junifer/data/__init__.py +4 -0
  37. junifer/data/coordinates.py +298 -31
  38. junifer/data/masks.py +360 -28
  39. junifer/data/parcellations.py +621 -188
  40. junifer/data/template_spaces.py +190 -0
  41. junifer/data/tests/test_coordinates.py +34 -3
  42. junifer/data/tests/test_data_utils.py +1 -0
  43. junifer/data/tests/test_masks.py +202 -86
  44. junifer/data/tests/test_parcellations.py +266 -55
  45. junifer/data/tests/test_template_spaces.py +104 -0
  46. junifer/data/utils.py +4 -2
  47. junifer/datagrabber/__init__.py +1 -0
  48. junifer/datagrabber/aomic/id1000.py +111 -70
  49. junifer/datagrabber/aomic/piop1.py +116 -53
  50. junifer/datagrabber/aomic/piop2.py +116 -53
  51. junifer/datagrabber/aomic/tests/test_id1000.py +27 -27
  52. junifer/datagrabber/aomic/tests/test_piop1.py +27 -27
  53. junifer/datagrabber/aomic/tests/test_piop2.py +27 -27
  54. junifer/datagrabber/base.py +62 -10
  55. junifer/datagrabber/datalad_base.py +0 -2
  56. junifer/datagrabber/dmcc13_benchmark.py +372 -0
  57. junifer/datagrabber/hcp1200/datalad_hcp1200.py +5 -0
  58. junifer/datagrabber/hcp1200/hcp1200.py +30 -13
  59. junifer/datagrabber/pattern.py +133 -27
  60. junifer/datagrabber/pattern_datalad.py +111 -13
  61. junifer/datagrabber/tests/test_base.py +57 -6
  62. junifer/datagrabber/tests/test_datagrabber_utils.py +204 -76
  63. junifer/datagrabber/tests/test_datalad_base.py +0 -6
  64. junifer/datagrabber/tests/test_dmcc13_benchmark.py +256 -0
  65. junifer/datagrabber/tests/test_multiple.py +43 -10
  66. junifer/datagrabber/tests/test_pattern.py +125 -178
  67. junifer/datagrabber/tests/test_pattern_datalad.py +44 -25
  68. junifer/datagrabber/utils.py +151 -16
  69. junifer/datareader/default.py +36 -10
  70. junifer/external/nilearn/junifer_nifti_spheres_masker.py +6 -0
  71. junifer/markers/base.py +25 -16
  72. junifer/markers/collection.py +35 -16
  73. junifer/markers/complexity/__init__.py +27 -0
  74. junifer/markers/complexity/complexity_base.py +149 -0
  75. junifer/markers/complexity/hurst_exponent.py +136 -0
  76. junifer/markers/complexity/multiscale_entropy_auc.py +140 -0
  77. junifer/markers/complexity/perm_entropy.py +132 -0
  78. junifer/markers/complexity/range_entropy.py +136 -0
  79. junifer/markers/complexity/range_entropy_auc.py +145 -0
  80. junifer/markers/complexity/sample_entropy.py +134 -0
  81. junifer/markers/complexity/tests/test_complexity_base.py +19 -0
  82. junifer/markers/complexity/tests/test_hurst_exponent.py +69 -0
  83. junifer/markers/complexity/tests/test_multiscale_entropy_auc.py +68 -0
  84. junifer/markers/complexity/tests/test_perm_entropy.py +68 -0
  85. junifer/markers/complexity/tests/test_range_entropy.py +69 -0
  86. junifer/markers/complexity/tests/test_range_entropy_auc.py +69 -0
  87. junifer/markers/complexity/tests/test_sample_entropy.py +68 -0
  88. junifer/markers/complexity/tests/test_weighted_perm_entropy.py +68 -0
  89. junifer/markers/complexity/weighted_perm_entropy.py +133 -0
  90. junifer/markers/falff/_afni_falff.py +153 -0
  91. junifer/markers/falff/_junifer_falff.py +142 -0
  92. junifer/markers/falff/falff_base.py +91 -84
  93. junifer/markers/falff/falff_parcels.py +61 -45
  94. junifer/markers/falff/falff_spheres.py +64 -48
  95. junifer/markers/falff/tests/test_falff_parcels.py +89 -121
  96. junifer/markers/falff/tests/test_falff_spheres.py +92 -127
  97. junifer/markers/functional_connectivity/crossparcellation_functional_connectivity.py +1 -0
  98. junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +1 -0
  99. junifer/markers/functional_connectivity/functional_connectivity_base.py +1 -0
  100. junifer/markers/functional_connectivity/tests/test_crossparcellation_functional_connectivity.py +46 -44
  101. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_parcels.py +34 -39
  102. junifer/markers/functional_connectivity/tests/test_edge_functional_connectivity_spheres.py +40 -52
  103. junifer/markers/functional_connectivity/tests/test_functional_connectivity_parcels.py +62 -70
  104. junifer/markers/functional_connectivity/tests/test_functional_connectivity_spheres.py +99 -85
  105. junifer/markers/parcel_aggregation.py +60 -38
  106. junifer/markers/reho/_afni_reho.py +192 -0
  107. junifer/markers/reho/_junifer_reho.py +281 -0
  108. junifer/markers/reho/reho_base.py +69 -34
  109. junifer/markers/reho/reho_parcels.py +26 -16
  110. junifer/markers/reho/reho_spheres.py +23 -9
  111. junifer/markers/reho/tests/test_reho_parcels.py +93 -92
  112. junifer/markers/reho/tests/test_reho_spheres.py +88 -86
  113. junifer/markers/sphere_aggregation.py +54 -9
  114. junifer/markers/temporal_snr/temporal_snr_base.py +1 -0
  115. junifer/markers/temporal_snr/tests/test_temporal_snr_parcels.py +38 -37
  116. junifer/markers/temporal_snr/tests/test_temporal_snr_spheres.py +34 -38
  117. junifer/markers/tests/test_collection.py +43 -42
  118. junifer/markers/tests/test_ets_rss.py +29 -37
  119. junifer/markers/tests/test_parcel_aggregation.py +587 -468
  120. junifer/markers/tests/test_sphere_aggregation.py +209 -157
  121. junifer/markers/utils.py +2 -40
  122. junifer/onthefly/read_transform.py +13 -6
  123. junifer/pipeline/__init__.py +1 -0
  124. junifer/pipeline/pipeline_step_mixin.py +105 -41
  125. junifer/pipeline/registry.py +17 -0
  126. junifer/pipeline/singleton.py +45 -0
  127. junifer/pipeline/tests/test_pipeline_step_mixin.py +139 -51
  128. junifer/pipeline/tests/test_update_meta_mixin.py +1 -0
  129. junifer/pipeline/tests/test_workdir_manager.py +104 -0
  130. junifer/pipeline/update_meta_mixin.py +8 -2
  131. junifer/pipeline/utils.py +154 -15
  132. junifer/pipeline/workdir_manager.py +246 -0
  133. junifer/preprocess/__init__.py +3 -0
  134. junifer/preprocess/ants/__init__.py +4 -0
  135. junifer/preprocess/ants/ants_apply_transforms_warper.py +185 -0
  136. junifer/preprocess/ants/tests/test_ants_apply_transforms_warper.py +56 -0
  137. junifer/preprocess/base.py +96 -69
  138. junifer/preprocess/bold_warper.py +265 -0
  139. junifer/preprocess/confounds/fmriprep_confound_remover.py +91 -134
  140. junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +106 -111
  141. junifer/preprocess/fsl/__init__.py +4 -0
  142. junifer/preprocess/fsl/apply_warper.py +179 -0
  143. junifer/preprocess/fsl/tests/test_apply_warper.py +45 -0
  144. junifer/preprocess/tests/test_bold_warper.py +159 -0
  145. junifer/preprocess/tests/test_preprocess_base.py +6 -6
  146. junifer/preprocess/warping/__init__.py +6 -0
  147. junifer/preprocess/warping/_ants_warper.py +167 -0
  148. junifer/preprocess/warping/_fsl_warper.py +109 -0
  149. junifer/preprocess/warping/space_warper.py +213 -0
  150. junifer/preprocess/warping/tests/test_space_warper.py +198 -0
  151. junifer/stats.py +18 -4
  152. junifer/storage/base.py +9 -1
  153. junifer/storage/hdf5.py +8 -3
  154. junifer/storage/pandas_base.py +2 -1
  155. junifer/storage/sqlite.py +1 -0
  156. junifer/storage/tests/test_hdf5.py +2 -1
  157. junifer/storage/tests/test_sqlite.py +8 -8
  158. junifer/storage/tests/test_utils.py +6 -6
  159. junifer/storage/utils.py +1 -0
  160. junifer/testing/datagrabbers.py +11 -7
  161. junifer/testing/utils.py +1 -0
  162. junifer/tests/test_stats.py +2 -0
  163. junifer/utils/__init__.py +1 -0
  164. junifer/utils/helpers.py +53 -0
  165. junifer/utils/logging.py +14 -3
  166. junifer/utils/tests/test_helpers.py +35 -0
  167. {junifer-0.0.3.dev188.dist-info → junifer-0.0.4.dist-info}/METADATA +59 -28
  168. junifer-0.0.4.dist-info/RECORD +257 -0
  169. {junifer-0.0.3.dev188.dist-info → junifer-0.0.4.dist-info}/WHEEL +1 -1
  170. junifer/markers/falff/falff_estimator.py +0 -334
  171. junifer/markers/falff/tests/test_falff_estimator.py +0 -238
  172. junifer/markers/reho/reho_estimator.py +0 -515
  173. junifer/markers/reho/tests/test_reho_estimator.py +0 -260
  174. junifer-0.0.3.dev188.dist-info/RECORD +0 -199
  175. {junifer-0.0.3.dev188.dist-info → junifer-0.0.4.dist-info}/AUTHORS.rst +0 -0
  176. {junifer-0.0.3.dev188.dist-info → junifer-0.0.4.dist-info}/LICENSE.md +0 -0
  177. {junifer-0.0.3.dev188.dist-info → junifer-0.0.4.dist-info}/entry_points.txt +0 -0
  178. {junifer-0.0.3.dev188.dist-info → junifer-0.0.4.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,192 @@
1
+ """Provide tests for GnuParallelLocalAdapter."""
2
+
3
+ # Authors: Synchon Mandal <s.mandal@fz-juelich.de>
4
+ # License: AGPL
5
+
6
+ import logging
7
+ from pathlib import Path
8
+ from typing import Dict, List, Optional, Tuple, Union
9
+
10
+ import pytest
11
+
12
+ from junifer.api.queue_context import GnuParallelLocalAdapter
13
+
14
+
15
+ def test_GnuParallelLocalAdapter_env_error() -> None:
16
+ """Test error for invalid env kind."""
17
+ with pytest.raises(ValueError, match="Invalid value for `env.kind`"):
18
+ GnuParallelLocalAdapter(
19
+ job_name="check_env",
20
+ job_dir=Path("."),
21
+ yaml_config_path=Path("."),
22
+ elements=["sub01"],
23
+ env={"kind": "jambalaya"},
24
+ )
25
+
26
+
27
+ @pytest.mark.parametrize(
28
+ "elements, expected_text",
29
+ [
30
+ (["sub01", "sub02"], "sub01\nsub02"),
31
+ ([("sub01", "ses01"), ("sub02", "ses01")], "sub01,ses01\nsub02,ses01"),
32
+ ],
33
+ )
34
+ def test_GnuParallelLocalAdapter_elements(
35
+ elements: List[Union[str, Tuple]],
36
+ expected_text: str,
37
+ ) -> None:
38
+ """Test GnuParallelLocalAdapter elements().
39
+
40
+ Parameters
41
+ ----------
42
+ elements : list of str or tuple
43
+ The parametrized elements.
44
+ expected_text : str
45
+ The parametrized expected text.
46
+
47
+ """
48
+ adapter = GnuParallelLocalAdapter(
49
+ job_name="test_elements",
50
+ job_dir=Path("."),
51
+ yaml_config_path=Path("."),
52
+ elements=elements,
53
+ )
54
+ assert expected_text in adapter.elements()
55
+
56
+
57
+ @pytest.mark.parametrize(
58
+ "pre_run, expected_text",
59
+ [
60
+ (None, "# Force datalad"),
61
+ ("# Check this out\n", "# Check this out"),
62
+ ],
63
+ )
64
+ def test_GnuParallelLocalAdapter_pre_run(
65
+ pre_run: Optional[str], expected_text: str
66
+ ) -> None:
67
+ """Test GnuParallelLocalAdapter pre_run().
68
+
69
+ Parameters
70
+ ----------
71
+ pre_run : str or None
72
+ The parametrized pre run text.
73
+ expected_text : str
74
+ The parametrized expected text.
75
+
76
+ """
77
+ adapter = GnuParallelLocalAdapter(
78
+ job_name="test_pre_run",
79
+ job_dir=Path("."),
80
+ yaml_config_path=Path("."),
81
+ elements=["sub01"],
82
+ pre_run=pre_run,
83
+ )
84
+ assert expected_text in adapter.pre_run()
85
+
86
+
87
+ @pytest.mark.parametrize(
88
+ "pre_collect, expected_text",
89
+ [
90
+ (None, "# This script"),
91
+ ("# Check this out\n", "# Check this out"),
92
+ ],
93
+ )
94
+ def test_GnuParallelLocalAdapter_pre_collect(
95
+ pre_collect: Optional[str],
96
+ expected_text: str,
97
+ ) -> None:
98
+ """Test GnuParallelLocalAdapter pre_collect().
99
+
100
+ Parameters
101
+ ----------
102
+ pre_collect : str or None
103
+ The parametrized pre collect text.
104
+ expected_text : str
105
+ The parametrized expected text.
106
+
107
+ """
108
+ adapter = GnuParallelLocalAdapter(
109
+ job_name="test_pre_collect",
110
+ job_dir=Path("."),
111
+ yaml_config_path=Path("."),
112
+ elements=["sub01"],
113
+ pre_collect=pre_collect,
114
+ )
115
+ assert expected_text in adapter.pre_collect()
116
+
117
+
118
+ def test_GnuParallelLocalAdapter_run() -> None:
119
+ """Test HTCondorAdapter run()."""
120
+ adapter = GnuParallelLocalAdapter(
121
+ job_name="test_run",
122
+ job_dir=Path("."),
123
+ yaml_config_path=Path("."),
124
+ elements=["sub01"],
125
+ )
126
+ assert "run" in adapter.run()
127
+
128
+
129
+ def test_GnuParallelLocalAdapter_collect() -> None:
130
+ """Test HTCondorAdapter collect()."""
131
+ adapter = GnuParallelLocalAdapter(
132
+ job_name="test_run_collect",
133
+ job_dir=Path("."),
134
+ yaml_config_path=Path("."),
135
+ elements=["sub01"],
136
+ )
137
+ assert "collect" in adapter.collect()
138
+
139
+
140
+ @pytest.mark.parametrize(
141
+ "env",
142
+ [
143
+ {"kind": "conda", "name": "junifer"},
144
+ {"kind": "venv", "name": "./junifer"},
145
+ ],
146
+ )
147
+ def test_GnuParallelLocalAdapter_prepare(
148
+ tmp_path: Path,
149
+ monkeypatch: pytest.MonkeyPatch,
150
+ caplog: pytest.LogCaptureFixture,
151
+ env: Dict[str, str],
152
+ ) -> None:
153
+ """Test GnuParallelLocalAdapter prepare().
154
+
155
+ Parameters
156
+ ----------
157
+ tmp_path : pathlib.Path
158
+ The path to the test directory.
159
+ monkeypatch : pytest.MonkeyPatch
160
+ The pytest.MonkeyPatch object.
161
+ caplog : pytest.LogCaptureFixture
162
+ The pytest.LogCaptureFixture object.
163
+ env : dict
164
+ The parametrized Python environment config.
165
+
166
+ """
167
+ with monkeypatch.context() as m:
168
+ m.chdir(tmp_path)
169
+ with caplog.at_level(logging.DEBUG):
170
+ adapter = GnuParallelLocalAdapter(
171
+ job_name="test_prepare",
172
+ job_dir=tmp_path,
173
+ yaml_config_path=tmp_path / "config.yaml",
174
+ elements=["sub01"],
175
+ env=env,
176
+ )
177
+ adapter.prepare()
178
+
179
+ assert "GNU parallel" in caplog.text
180
+ assert f"Copying run_{env['kind']}" in caplog.text
181
+ assert "Writing pre_run.sh" in caplog.text
182
+ assert "Writing run_test_prepare.sh" in caplog.text
183
+ assert "Writing pre_collect.sh" in caplog.text
184
+ assert "Writing collect_test_prepare.sh" in caplog.text
185
+ assert "Shell scripts created" in caplog.text
186
+
187
+ assert adapter._exec_path.stat().st_size != 0
188
+ assert adapter._elements_file_path.stat().st_size != 0
189
+ assert adapter._pre_run_path.stat().st_size != 0
190
+ assert adapter._run_path.stat().st_size != 0
191
+ assert adapter._pre_collect_path.stat().st_size != 0
192
+ assert adapter._collect_path.stat().st_size != 0
@@ -0,0 +1,257 @@
1
+ """Provide tests for HTCondorAdapter."""
2
+
3
+ # Authors: Synchon Mandal <s.mandal@fz-juelich.de>
4
+ # License: AGPL
5
+
6
+ import logging
7
+ from pathlib import Path
8
+ from typing import Dict, List, Optional, Tuple, Union
9
+
10
+ import pytest
11
+
12
+ from junifer.api.queue_context import HTCondorAdapter
13
+
14
+
15
+ def test_HTCondorAdapter_env_error() -> None:
16
+ """Test error for invalid env kind."""
17
+ with pytest.raises(ValueError, match="Invalid value for `env.kind`"):
18
+ HTCondorAdapter(
19
+ job_name="check_env",
20
+ job_dir=Path("."),
21
+ yaml_config_path=Path("."),
22
+ elements=["sub01"],
23
+ env={"kind": "jambalaya"},
24
+ )
25
+
26
+
27
+ def test_HTCondorAdapter_collect_error() -> None:
28
+ """Test error for invalid collect option."""
29
+ with pytest.raises(ValueError, match="Invalid value for `collect`"):
30
+ HTCondorAdapter(
31
+ job_name="check_collect",
32
+ job_dir=Path("."),
33
+ yaml_config_path=Path("."),
34
+ elements=["sub01"],
35
+ collect="off",
36
+ )
37
+
38
+
39
+ @pytest.mark.parametrize(
40
+ "pre_run, expected_text",
41
+ [
42
+ (None, "# Force datalad"),
43
+ ("# Check this out\n", "# Check this out"),
44
+ ],
45
+ )
46
+ def test_HTCondorAdapter_pre_run(
47
+ pre_run: Optional[str], expected_text: str
48
+ ) -> None:
49
+ """Test HTCondorAdapter pre_run().
50
+
51
+ Parameters
52
+ ----------
53
+ pre_run : str or None
54
+ The parametrized pre run text.
55
+ expected_text : str
56
+ The parametrized expected text.
57
+
58
+ """
59
+ adapter = HTCondorAdapter(
60
+ job_name="test_pre_run",
61
+ job_dir=Path("."),
62
+ yaml_config_path=Path("."),
63
+ elements=["sub01"],
64
+ pre_run=pre_run,
65
+ )
66
+ assert expected_text in adapter.pre_run()
67
+
68
+
69
+ @pytest.mark.parametrize(
70
+ "pre_collect, expected_text, collect",
71
+ [
72
+ (None, "exit 1", "yes"),
73
+ (None, "# This script", "on_success_only"),
74
+ ("# Check this out\n", "# Check this out", "yes"),
75
+ ("# Check this out\n", "# Check this out", "on_success_only"),
76
+ ],
77
+ )
78
+ def test_HTCondorAdapter_pre_collect(
79
+ pre_collect: Optional[str], expected_text: str, collect: str
80
+ ) -> None:
81
+ """Test HTCondorAdapter pre_collect().
82
+
83
+ Parameters
84
+ ----------
85
+ pre_collect : str or None
86
+ The parametrized pre collect text.
87
+ expected_text : str
88
+ The parametrized expected text.
89
+ collect : str
90
+ The parametrized collect parameter.
91
+
92
+ """
93
+ adapter = HTCondorAdapter(
94
+ job_name="test_pre_collect",
95
+ job_dir=Path("."),
96
+ yaml_config_path=Path("."),
97
+ elements=["sub01"],
98
+ pre_collect=pre_collect,
99
+ collect=collect,
100
+ )
101
+ assert expected_text in adapter.pre_collect()
102
+
103
+
104
+ @pytest.mark.parametrize(
105
+ "extra_preamble, expected_text",
106
+ [
107
+ (None, "universe = vanilla"),
108
+ ("# Check this out\n", "# Check this out"),
109
+ ],
110
+ )
111
+ def test_HTCondorAdapter_run_collect(
112
+ extra_preamble: Optional[str], expected_text: str
113
+ ) -> None:
114
+ """Test HTCondorAdapter run() and collect().
115
+
116
+ Parameters
117
+ ----------
118
+ extra_preamble : str or None
119
+ The parametrized extra preamble text.
120
+ expected_text : str
121
+ The parametrized expected text.
122
+
123
+ """
124
+ adapter = HTCondorAdapter(
125
+ job_name="test_run_collect",
126
+ job_dir=Path("."),
127
+ yaml_config_path=Path("."),
128
+ elements=["sub01"],
129
+ extra_preamble=extra_preamble,
130
+ )
131
+ assert expected_text in adapter.run()
132
+ assert expected_text in adapter.collect()
133
+
134
+
135
+ @pytest.mark.parametrize(
136
+ "elements, collect, expected_text",
137
+ [
138
+ (["sub01"], "yes", "FINAL collect"),
139
+ (
140
+ [("sub01", "ses01")],
141
+ "yes",
142
+ 'element="sub01,ses01" log_element="sub01-ses01"',
143
+ ),
144
+ (["sub01"], "on_success_only", "JOB collect"),
145
+ (
146
+ [("sub01", "ses01")],
147
+ "on_success_only",
148
+ 'element="sub01,ses01" log_element="sub01-ses01"',
149
+ ),
150
+ ],
151
+ )
152
+ def test_HTCondor_dag(
153
+ elements: List[Union[str, Tuple]], collect: str, expected_text: str
154
+ ) -> None:
155
+ """Test HTCondorAdapter dag().
156
+
157
+ Parameters
158
+ ----------
159
+ elements : list of str or tuple
160
+ The parametrized elements.
161
+ collect : str
162
+ The parametrized collect parameter.
163
+ expected_text : str
164
+ The parametrized expected text.
165
+
166
+ """
167
+ adapter = HTCondorAdapter(
168
+ job_name="test_dag",
169
+ job_dir=Path("."),
170
+ yaml_config_path=Path("."),
171
+ elements=elements,
172
+ collect=collect,
173
+ )
174
+ assert expected_text in adapter.dag()
175
+
176
+
177
+ @pytest.mark.parametrize(
178
+ "env",
179
+ [
180
+ {"kind": "conda", "name": "junifer"},
181
+ {"kind": "venv", "name": "./junifer"},
182
+ ],
183
+ )
184
+ def test_HTCondorAdapter_prepare(
185
+ tmp_path: Path,
186
+ monkeypatch: pytest.MonkeyPatch,
187
+ caplog: pytest.LogCaptureFixture,
188
+ env: Dict[str, str],
189
+ ) -> None:
190
+ """Test HTCondorAdapter prepare().
191
+
192
+ Parameters
193
+ ----------
194
+ tmp_path : pathlib.Path
195
+ The path to the test directory.
196
+ monkeypatch : pytest.MonkeyPatch
197
+ The pytest.MonkeyPatch object.
198
+ caplog : pytest.LogCaptureFixture
199
+ The pytest.LogCaptureFixture object.
200
+ env : dict
201
+ The parametrized Python environment config.
202
+
203
+ """
204
+ with monkeypatch.context() as m:
205
+ m.chdir(tmp_path)
206
+ with caplog.at_level(logging.DEBUG):
207
+ adapter = HTCondorAdapter(
208
+ job_name="test_prepare",
209
+ job_dir=tmp_path,
210
+ yaml_config_path=tmp_path / "config.yaml",
211
+ elements=["sub01"],
212
+ env=env,
213
+ )
214
+ adapter.prepare()
215
+
216
+ assert "Creating HTCondor job" in caplog.text
217
+ assert "Creating logs directory" in caplog.text
218
+ assert f"Copying run_{env['kind']}" in caplog.text
219
+ assert "Writing pre_run.sh" in caplog.text
220
+ assert "Writing run_test_prepare.submit" in caplog.text
221
+ assert "Writing pre_collect.sh" in caplog.text
222
+ assert "Writing collect_test_prepare.submit" in caplog.text
223
+ assert "HTCondor job files created" in caplog.text
224
+
225
+ assert adapter._exec_path.stat().st_size != 0
226
+ assert adapter._pre_run_path.stat().st_size != 0
227
+ assert adapter._submit_run_path.stat().st_size != 0
228
+ assert adapter._pre_collect_path.stat().st_size != 0
229
+ assert adapter._submit_collect_path.stat().st_size != 0
230
+ assert adapter._dag_path.stat().st_size != 0
231
+
232
+
233
+ def test_HTCondorAdapter_prepare_submit_fail(
234
+ tmp_path: Path,
235
+ monkeypatch: pytest.MonkeyPatch,
236
+ ) -> None:
237
+ """Test HTCondorAdapter prepare() with failed submit.
238
+
239
+ Parameters
240
+ ----------
241
+ tmp_path : pathlib.Path
242
+ The path to the test directory.
243
+ monkeypatch : pytest.MonkeyPatch
244
+ The pytest.MonkeyPatch object.
245
+
246
+ """
247
+ with monkeypatch.context() as m:
248
+ m.chdir(tmp_path)
249
+ adapter = HTCondorAdapter(
250
+ job_name="test_prepare_submit_fail",
251
+ job_dir=tmp_path,
252
+ yaml_config_path=tmp_path / "config.yaml",
253
+ elements=["sub01"],
254
+ submit=True,
255
+ )
256
+ with pytest.raises(RuntimeError, match="condor_submit_dag"):
257
+ adapter.prepare()
@@ -6,7 +6,7 @@ mounts=0
6
6
  for var in "$@"
7
7
  do
8
8
  if [ -d "${var}" ]; then
9
- echo "$var is a directory"
9
+ echo "$var is a directory" >&2
10
10
  var=$(realpath "${var}")
11
11
  host_dir=$(dirname "${var}")
12
12
  ((mounts+=1))
@@ -15,10 +15,10 @@ if [ -d "${var}" ]; then
15
15
  var=${container_dir}
16
16
  elif [ -f "${var}" ] || [[ "${var}" == /* ]]; then
17
17
  if [ -f "${var}" ]; then
18
- echo "$var is a file"
18
+ echo "$var is a file" >&2
19
19
  var=$(realpath "${var}")
20
20
  else
21
- echo "$var is a prefix"
21
+ echo "$var is a prefix" >&2
22
22
  fi
23
23
  fname=$(basename "${var}")
24
24
  host_dir=$(dirname "${var}")
@@ -30,10 +30,10 @@ if [ -d "${var}" ]; then
30
30
  corrected_args+=("${var}")
31
31
  done
32
32
 
33
- echo "Docker args: ${docker_args[*]}"
34
- echo "Corrected args for afni: ${corrected_args[*]}"
33
+ echo "Docker args: ${docker_args[*]}" >&2
34
+ echo "Corrected args for afni: ${corrected_args[*]}" >&2
35
35
 
36
36
  cwd=$(pwd)
37
37
  cmd="docker run --rm ${docker_args[*]} -v ${cwd}:${cwd} -w ${cwd} afni/afni_make_build ${corrected_args[*]}"
38
- echo "Running command: ${cmd}"
38
+ echo "Running command: ${cmd}" >&2
39
39
  ${cmd}
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ run_ants_docker.sh ResampleImage "$@"
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ run_ants_docker.sh antsApplyTransforms "$@"
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ run_ants_docker.sh antsApplyTransformsToPoints "$@"
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+
3
+ corrected_args=()
4
+ docker_args=()
5
+ mounts=0
6
+ for var in "$@"
7
+ do
8
+ if [ -d "${var}" ]; then
9
+ echo "$var is a directory" >&2
10
+ var=$(realpath "${var}")
11
+ host_dir=$(dirname "${var}")
12
+ ((mounts+=1))
13
+ container_dir="/data/mount_${mounts}"
14
+ docker_args+=("-v ${host_dir}:${container_dir}")
15
+ var=${container_dir}
16
+ elif [ -f "${var}" ] || [[ "${var}" == /* ]]; then
17
+ if [ -f "${var}" ]; then
18
+ echo "$var is a file" >&2
19
+ var=$(realpath "${var}")
20
+ else
21
+ echo "$var is a prefix" >&2
22
+ fi
23
+ fname=$(basename "${var}")
24
+ host_dir=$(dirname "${var}")
25
+ ((mounts+=1))
26
+ container_dir="/data/mount_${mounts}"
27
+ docker_args+=("-v ${host_dir}:${container_dir}")
28
+ var=${container_dir}/${fname}
29
+ fi
30
+ corrected_args+=("${var}")
31
+ done
32
+
33
+ echo "Docker args: ${docker_args[*]}" >&2
34
+ echo "Corrected args for fsl: ${corrected_args[*]}" >&2
35
+
36
+ cwd=$(pwd)
37
+ cmd="docker run --rm ${docker_args[*]} -v ${cwd}:${cwd} -w ${cwd} antsx/ants ${corrected_args[*]}"
38
+ echo "Running command: ${cmd}" >&2
39
+ ${cmd}
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ run_fsl_docker.sh applywarp "$@"
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ run_fsl_docker.sh flirt "$@"
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ run_fsl_docker.sh img2imgcoord "$@"
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+
3
+ corrected_args=()
4
+ docker_args=()
5
+ mounts=0
6
+ for var in "$@"
7
+ do
8
+ if [ -d "${var}" ]; then
9
+ echo "$var is a directory" >&2
10
+ var=$(realpath "${var}")
11
+ host_dir=$(dirname "${var}")
12
+ ((mounts+=1))
13
+ container_dir="/data/mount_${mounts}"
14
+ docker_args+=("-v ${host_dir}:${container_dir}")
15
+ var=${container_dir}
16
+ elif [ -f "${var}" ] || [[ "${var}" == /* ]]; then
17
+ if [ -f "${var}" ]; then
18
+ echo "$var is a file" >&2
19
+ var=$(realpath "${var}")
20
+ else
21
+ echo "$var is a prefix" >&2
22
+ fi
23
+ fname=$(basename "${var}")
24
+ host_dir=$(dirname "${var}")
25
+ ((mounts+=1))
26
+ container_dir="/data/mount_${mounts}"
27
+ docker_args+=("-v ${host_dir}:${container_dir}")
28
+ var=${container_dir}/${fname}
29
+ fi
30
+ corrected_args+=("${var}")
31
+ done
32
+
33
+ echo "Docker args: ${docker_args[*]}" >&2
34
+ echo "Corrected args for fsl: ${corrected_args[*]}" >&2
35
+
36
+ cwd=$(pwd)
37
+ cmd="docker run --rm ${docker_args[*]} -v ${cwd}:${cwd} -w ${cwd} brainlife/fsl ${corrected_args[*]}"
38
+ echo "Running command: ${cmd}" >&2
39
+ ${cmd}
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ run_fsl_docker.sh std2imgcoord "$@"
@@ -1,17 +1,17 @@
1
1
  #!/bin/bash
2
2
 
3
3
  if [ $# -lt 2 ]; then
4
- echo "This script is meant to run a command within a python environment"
4
+ echo "This script is meant to run a command within a conda environment."
5
5
  echo "It needs at least 2 parameters."
6
6
  echo "The first one must be the environment name."
7
- echo "The rest will be the command"
7
+ echo "The rest will be the command."
8
8
  exit 255
9
9
  fi
10
10
 
11
11
  eval "$(conda shell.bash hook)"
12
12
  env_name=$1
13
13
  echo "Activating ${env_name}"
14
- conda activate "$1"
14
+ conda activate "${env_name}"
15
15
  shift 1
16
16
 
17
17
  if [ -f "pre_run.sh" ]; then
@@ -19,5 +19,5 @@ if [ -f "pre_run.sh" ]; then
19
19
  . ./pre_run.sh
20
20
  fi
21
21
 
22
- echo "Running ${*} in virtual environment"
22
+ echo "Running ${*} in conda environment"
23
23
  "$@"
@@ -0,0 +1,22 @@
1
+ #!/bin/bash
2
+
3
+ if [ $# -lt 2 ]; then
4
+ echo "This script is meant to run a command within a Python virtual environment."
5
+ echo "It needs at least 2 parameters."
6
+ echo "The first one must be the virtualenv path."
7
+ echo "The rest will be the command."
8
+ exit 255
9
+ fi
10
+
11
+ env_path=$1
12
+ echo "Activating ${env_path}"
13
+ source "${env_path}"/bin/activate
14
+ shift 1
15
+
16
+ if [ -f "pre_run.sh" ]; then
17
+ echo "Sourcing pre_run.sh"
18
+ . ./pre_run.sh
19
+ fi
20
+
21
+ echo "Running ${*} in Python virtual environment"
22
+ "$@"
@@ -0,0 +1,16 @@
1
+ workdir: /tmp
2
+
3
+ with: junifer.testing.registry
4
+
5
+ datagrabber:
6
+ kind: PartlyCloudyTestingDataGrabber
7
+
8
+ markers:
9
+ - kind: ParcelAggregation
10
+ parcellation: TianxS1x3TxMNInonlinear2009cAsym
11
+ method: mean
12
+ name: tian-s1-3T_mean
13
+
14
+ storage:
15
+ kind: HDF5FeatureStorage
16
+ uri: /tmp/partly_cloudy_agg_mean_tian.hdf5