junifer 0.0.4.dev416__py3-none-any.whl → 0.0.4.dev425__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.
junifer/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.0.4.dev416'
16
- __version_tuple__ = version_tuple = (0, 0, 4, 'dev416')
15
+ __version__ = version = '0.0.4.dev425'
16
+ __version_tuple__ = version_tuple = (0, 0, 4, 'dev425')
junifer/api/cli.py CHANGED
@@ -463,3 +463,26 @@ def fsl_docker() -> None: # pragma: no cover
463
463
  export PATH="$PATH:{fsl_wrappers_path}"
464
464
  """
465
465
  click.secho(msg, fg="blue")
466
+
467
+
468
+ @setup.command("ants-docker")
469
+ def ants_docker() -> None: # pragma: no cover
470
+ """Configure ANTs-Docker wrappers."""
471
+ import junifer
472
+
473
+ pkg_path = Path(junifer.__path__[0]) # type: ignore
474
+ ants_wrappers_path = pkg_path / "api" / "res" / "ants"
475
+ msg = f"""
476
+ Installation instructions for ANTs-Docker wrappers:
477
+
478
+ 1. Install Docker: https://docs.docker.com/get-docker/
479
+
480
+ 2. Get the ANTs-Docker image by running this on the command line:
481
+
482
+ docker pull antsx/ants
483
+
484
+ 3. Add this line to the ~/.bashrc or ~/.zshrc file:
485
+
486
+ export PATH="$PATH:{ants_wrappers_path}"
487
+ """
488
+ click.secho(msg, fg="blue")
@@ -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"
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"
19
+ var=$(realpath "${var}")
20
+ else
21
+ echo "$var is a prefix"
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[*]}"
34
+ echo "Corrected args for fsl: ${corrected_args[*]}"
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}"
39
+ ${cmd}
@@ -260,11 +260,12 @@ def get_coordinates(
260
260
  std2imgcoord_out_path = element_tempdir / "coordinates_transformed.txt"
261
261
  # Set std2imgcoord command
262
262
  std2imgcoord_cmd = [
263
- "std2imgcoord",
263
+ "cat",
264
+ f"{pretransform_coordinates_path.resolve()}",
265
+ "| std2imgcoord",
264
266
  f"-img {target_data['reference_path'].resolve()}",
265
267
  f"-warp {extra_input['Warp']['path'].resolve()}",
266
- f"{pretransform_coordinates_path.resolve()}",
267
- f"> {std2imgcoord_out_path.resolve()}",
268
+ f"- > {std2imgcoord_out_path.resolve()}",
268
269
  ]
269
270
  # Call std2imgcoord
270
271
  std2imgcoord_cmd_str = " ".join(std2imgcoord_cmd)
junifer/pipeline/utils.py CHANGED
@@ -35,6 +35,9 @@ def check_ext_dependencies(name: str, optional: bool, **kwargs: Any) -> bool:
35
35
  # Check for fsl
36
36
  elif name == "fsl":
37
37
  found = _check_fsl(**kwargs)
38
+ # Check for ants
39
+ elif name == "ants":
40
+ found = _check_ants(**kwargs)
38
41
  # Went off the rails
39
42
  else:
40
43
  raise_error(
@@ -171,3 +174,63 @@ def _check_fsl(commands: Optional[List[str]] = None) -> bool:
171
174
  f"{commands_found_results}"
172
175
  )
173
176
  return fsl_found
177
+
178
+
179
+ def _check_ants(commands: Optional[List[str]] = None) -> bool:
180
+ """Check if ANTs is present in the system.
181
+
182
+ Parameters
183
+ ----------
184
+ commands : list of str, optional
185
+ The commands to specifically check for from ANTs. If None, only
186
+ the basic ANTS help would be looked up, else, would also
187
+ check for specific commands (default None).
188
+
189
+ Returns
190
+ -------
191
+ bool
192
+ Whether ANTs is found or not.
193
+
194
+ """
195
+ completed_process = subprocess.run(
196
+ "ANTS --help",
197
+ stdin=subprocess.DEVNULL,
198
+ stdout=subprocess.DEVNULL,
199
+ stderr=subprocess.STDOUT,
200
+ shell=True, # is unsafe but kept for resolution via PATH
201
+ check=False,
202
+ )
203
+ ants_found = completed_process.returncode == 0
204
+
205
+ # Check for specific commands
206
+ if ants_found and commands is not None:
207
+ if not isinstance(commands, list):
208
+ commands = [commands]
209
+ # Store command found results
210
+ commands_found_results = {}
211
+ # Set all commands found flag to True
212
+ all_commands_found = True
213
+ # Check commands' existence
214
+ for command in commands:
215
+ command_process = subprocess.run(
216
+ [command],
217
+ stdin=subprocess.DEVNULL,
218
+ stdout=subprocess.DEVNULL,
219
+ stderr=subprocess.STDOUT,
220
+ shell=True, # is unsafe but kept for resolution via PATH
221
+ check=False,
222
+ )
223
+ command_found = command_process.returncode == 0
224
+ commands_found_results[command] = (
225
+ "found" if command_found else "not found"
226
+ )
227
+ # Set flag to trigger warning
228
+ all_commands_found = all_commands_found and command_found
229
+ # One or more commands were missing
230
+ if not all_commands_found:
231
+ warn_with_log(
232
+ "ANTs is installed but some of the required commands "
233
+ "were not found. These are the results: "
234
+ f"{commands_found_results}"
235
+ )
236
+ return ants_found
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: junifer
3
- Version: 0.0.4.dev416
3
+ Version: 0.0.4.dev425
4
4
  Summary: JUelich NeuroImaging FEature extractoR
5
5
  Author-email: Fede Raimondo <f.raimondo@fz-juelich.de>, Synchon Mandal <s.mandal@fz-juelich.de>
6
6
  Maintainer-email: Fede Raimondo <f.raimondo@fz-juelich.de>, Synchon Mandal <s.mandal@fz-juelich.de>
@@ -1,8 +1,8 @@
1
1
  junifer/__init__.py,sha256=x1UR2jUcrUdm2HNl-3Qvyi4UUrU6ms5qm2qcmNY7zZk,391
2
- junifer/_version.py,sha256=oEiN87qcYMsn7tBFVlimnDizlVHV4f2oCFPPNYHlePw,428
2
+ junifer/_version.py,sha256=p31cczSx2OSKphtDx6E2KUtMOHSLo8bDd0Eg7yeGf58,428
3
3
  junifer/stats.py,sha256=KUX4jJcLWnlE34coet8EkdFypFd-td4Vtpx5LvlomVs,5879
4
4
  junifer/api/__init__.py,sha256=YILu9M7SC0Ri4CVd90fELH2OnK_gvCYAXCoqBNCFE8E,257
5
- junifer/api/cli.py,sha256=606LWHcQjF5gv3rxAqmD8i2tCG1cnu7t1Tpej7yJzJs,12247
5
+ junifer/api/cli.py,sha256=xScav2mF-Jr8JjVFt8kaHuLpX5l_jVTaQGPgQL3VNvA,12881
6
6
  junifer/api/decorators.py,sha256=8bnwHPAe7VgzKxl--M_e0umdAlTVSzaJQHEJZ5kof5k,2580
7
7
  junifer/api/functions.py,sha256=WPs0Yj10aWIOLh_1A12SBTdG0HK86si5fJ9qAfJJQO0,23057
8
8
  junifer/api/parser.py,sha256=a0IBvH3KN1PJaEpF3cnSv8g7VCVpDY1VsCvc8b8FFmE,3849
@@ -13,6 +13,9 @@ junifer/api/res/afni/3dRSFC,sha256=MkPtS_nKEoJOHDAT3ZP9IA-SvMdhyzZDiyxObV_XI3g,4
13
13
  junifer/api/res/afni/3dReHo,sha256=Jb5B97iPPPQ14zAz7tK5BVG4jPZyOe9c6kgM6ixKaY8,44
14
14
  junifer/api/res/afni/afni,sha256=idLvNWHwd6P4jWXfk6hMXQckdpcTJYbvnLC3uNP6sBg,42
15
15
  junifer/api/res/afni/run_afni_docker.sh,sha256=Qw_yLv7GijmjPmmuiDA0qRmB2Kxuvsoerm5R7mjtzZo,1106
16
+ junifer/api/res/ants/antsApplyTransforms,sha256=SqlQEJ2RMMw_qGyDaNTXKzQqO7Bvrm6y5SEPmyqHiYc,57
17
+ junifer/api/res/ants/antsApplyTransformsToPoints,sha256=lqyvQGo8oI-RNpNlRqz-BvLHh7Th5HQgsDZjHF6nEeI,65
18
+ junifer/api/res/ants/run_ants_docker.sh,sha256=svzsACUd1kh3C_ODL2fAUAY2fMKsjQ-MsCPOuxKxwW0,1095
16
19
  junifer/api/res/fsl/applywarp,sha256=DBgHfsn1yXWq0t-P7J0YvrjjJNgiblwDsh9L1hF9v_w,46
17
20
  junifer/api/res/fsl/flirt,sha256=tSjiUco8ui8AbHD7mTzChEwbR0Rf_4iJTgzYTPF_WuQ,42
18
21
  junifer/api/res/fsl/run_fsl_docker.sh,sha256=9y_9ehmVeflf0zfssXUNzaiS9FRPTXAd84XzyY5lmck,1098
@@ -37,7 +40,7 @@ junifer/configs/juseless/datagrabbers/tests/test_ixi_vbm.py,sha256=8jxpNZelXwpJG
37
40
  junifer/configs/juseless/datagrabbers/tests/test_ucla.py,sha256=e-jdvcZ9B0mka6_573JJU_cGwSaUV54U8X_n0UadtJY,3351
38
41
  junifer/configs/juseless/datagrabbers/tests/test_ukb_vbm.py,sha256=b9hjc1mgO--PSRC3id2EzzfE2yWNsuZ2UI47a6sfGZU,1025
39
42
  junifer/data/__init__.py,sha256=oUjOs8_M6fitNb44izxpXf3su1e4pG_vCdjwVYkjZjQ,550
40
- junifer/data/coordinates.py,sha256=BVpiz9dkwTKwlAnPE8R44dIUD3gCjd9CZBDJHQR9kCY,10957
43
+ junifer/data/coordinates.py,sha256=10bXVy94eZALfqdEbAbHTOuuF0Od9Zn2QbCFjAFSY5M,10980
41
44
  junifer/data/masks.py,sha256=chWSl-vyv5Nsd9GuQzydXPOY3AdhApOJq_42NSKpykQ,16952
42
45
  junifer/data/parcellations.py,sha256=wL8lkAYYvg7NDt160EA8N_xFjK8ZtDwoXYJQHNHwbDU,55805
43
46
  junifer/data/utils.py,sha256=K9quLIoWRmm2QFM8Rdy_5bYsWb_XhL0l5Uq_1Sie0kA,1274
@@ -178,7 +181,7 @@ junifer/pipeline/pipeline_step_mixin.py,sha256=fZtJa5NJ2_9r6dD_UOkXA5fOPtRjuPUbh
178
181
  junifer/pipeline/registry.py,sha256=PQq8D6DiHhSeh0tdHs9J6jv9L1WsfEUqJxzhlzAQDbE,3956
179
182
  junifer/pipeline/singleton.py,sha256=-BiiyFiEO1EItztBcAWI_eyApR-oJTAGVRXkV706rQ4,985
180
183
  junifer/pipeline/update_meta_mixin.py,sha256=WJhLdeIZQ3BjiEcPJM01wlH70ZNj0z5ZS2FfRTJG5oo,1532
181
- junifer/pipeline/utils.py,sha256=EnXtk7Nm7qacSoTiPbnERRhPzajD93d3-bvBgCvNv5U,5789
184
+ junifer/pipeline/utils.py,sha256=f8vsROGdSb6tdA70TbA0CzT5yzRhhq2W5czkJRu0VP4,7936
182
185
  junifer/pipeline/workdir_manager.py,sha256=LxIAMyCBtJbYnDI_23_pAFAXQAeJY3cS06SY9aIUbZ8,7972
183
186
  junifer/pipeline/tests/test_pipeline_step_mixin.py,sha256=LMVMgc6e4ahhcQWL9VNL3IgxEEZ-phO7jhKae5-Mqns,5393
184
187
  junifer/pipeline/tests/test_registry.py,sha256=rYN0pO3gSueQ6XsasEM9VU5BkLyaNl8WaCZiaO8Rno0,4105
@@ -222,10 +225,10 @@ junifer/utils/fs.py,sha256=Jd9AoV2fIF7pT7KhXsn8T1O1fJ1_SFZgaFuOBAM7DG8,460
222
225
  junifer/utils/logging.py,sha256=4kH8j9X_J2bMdnBJMldVF95C5sURa5UAsLmSgRaD9Ig,9117
223
226
  junifer/utils/tests/test_fs.py,sha256=WQS7cKlKEZ742CIuiOYYpueeAhY9PqlastfDVpVVtvE,923
224
227
  junifer/utils/tests/test_logging.py,sha256=l8oo-AiBV7H6_IzlsNcj__cLeZBUvgIGoaMszD9VaJg,7754
225
- junifer-0.0.4.dev416.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
226
- junifer-0.0.4.dev416.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
227
- junifer-0.0.4.dev416.dist-info/METADATA,sha256=JaWqiW8qJ8I6veUVWU1lr_mYKkzCOLMrIbaxgmzMN8o,7569
228
- junifer-0.0.4.dev416.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
229
- junifer-0.0.4.dev416.dist-info/entry_points.txt,sha256=DxFvKq0pOqRunAK0FxwJcoDfV1-dZvsFDpD5HRqSDhw,48
230
- junifer-0.0.4.dev416.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
231
- junifer-0.0.4.dev416.dist-info/RECORD,,
228
+ junifer-0.0.4.dev425.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
229
+ junifer-0.0.4.dev425.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
230
+ junifer-0.0.4.dev425.dist-info/METADATA,sha256=5u5z14ZMbrIE13ok_UGTzLaL4YQI2CHMOyegn6ifuS4,7569
231
+ junifer-0.0.4.dev425.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
232
+ junifer-0.0.4.dev425.dist-info/entry_points.txt,sha256=DxFvKq0pOqRunAK0FxwJcoDfV1-dZvsFDpD5HRqSDhw,48
233
+ junifer-0.0.4.dev425.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
234
+ junifer-0.0.4.dev425.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5