junifer 0.0.6.dev422__py3-none-any.whl → 0.0.6.dev459__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.
@@ -6,22 +6,19 @@
6
6
  from pathlib import Path
7
7
  from typing import Any, Optional, Union
8
8
 
9
- import datalad.api as dl
10
9
  import nibabel as nib
11
10
  import numpy as np
12
- from datalad.support.exceptions import IncompleteResultsError
11
+ from junifer_data import get
13
12
  from templateflow import api as tflow
14
13
 
15
14
  from ..utils import logger, raise_error
16
- from .utils import closest_resolution
15
+ from .utils import JUNIFER_DATA_VERSION, closest_resolution, get_dataset_path
17
16
 
18
17
 
19
18
  __all__ = ["get_template", "get_xfm"]
20
19
 
21
20
 
22
- def get_xfm(
23
- src: str, dst: str, xfms_dir: Union[str, Path, None] = None
24
- ) -> Path: # pragma: no cover
21
+ def get_xfm(src: str, dst: str) -> Path: # pragma: no cover
25
22
  """Fetch warp files to convert from ``src`` to ``dst``.
26
23
 
27
24
  Parameters
@@ -30,94 +27,21 @@ def get_xfm(
30
27
  The template space to transform from.
31
28
  dst : str
32
29
  The template space to transform to.
33
- xfms_dir : str or pathlib.Path, optional
34
- Path where the retrieved transformation files are stored.
35
- The default location is "$HOME/junifer/data/xfms" (default None).
36
30
 
37
31
  Returns
38
32
  -------
39
33
  pathlib.Path
40
34
  The path to the transformation file.
41
35
 
42
- Raises
43
- ------
44
- RuntimeError
45
- If there is a problem cloning the xfm dataset or
46
- if there is a problem fetching the xfm file.
47
-
48
36
  """
49
- # Set default path for storage
50
- if xfms_dir is None:
51
- xfms_dir = Path().home() / "junifer" / "data" / "xfms"
52
-
53
- # Convert str to Path
54
- if not isinstance(xfms_dir, Path):
55
- xfms_dir = Path(xfms_dir)
56
-
57
- # Check if the template xfms dataset is installed at storage path
58
- is_installed = dl.Dataset(xfms_dir).is_installed()
59
- # Use existing dataset
60
- if is_installed:
61
- logger.debug(
62
- f"Found existing template xfms dataset at: {xfms_dir.resolve()}"
63
- )
64
- # Set dataset
65
- dataset = dl.Dataset(xfms_dir)
66
- # Clone a fresh copy
67
- else:
68
- logger.debug(f"Cloning template xfms dataset to: {xfms_dir.resolve()}")
69
- # Clone dataset
70
- try:
71
- dataset = dl.clone(
72
- "https://github.com/juaml/human-template-xfms.git",
73
- path=xfms_dir,
74
- result_renderer="disabled",
75
- )
76
- except IncompleteResultsError as e:
77
- raise_error(
78
- msg=f"Failed to clone dataset: {e.failed}",
79
- klass=RuntimeError,
80
- )
81
- else:
82
- logger.debug(
83
- f"Successfully cloned template xfms dataset to: "
84
- f"{xfms_dir.resolve()}"
85
- )
86
-
87
37
  # Set file path to retrieve
88
- xfm_file_path = (
89
- xfms_dir / "xfms" / f"{src}_to_{dst}" / f"{src}_to_{dst}_Composite.h5"
90
- )
91
-
38
+ xfm_file_path = Path(f"xfms/{src}_to_{dst}/{src}_to_{dst}_Composite.h5")
92
39
  # Retrieve file
93
- try:
94
- got = dataset.get(xfm_file_path, result_renderer="disabled")
95
- except IncompleteResultsError as e:
96
- raise_error(
97
- msg=f"Failed to get file from dataset: {e.failed}",
98
- klass=RuntimeError,
99
- )
100
- else:
101
- file_path = Path(got[0]["path"])
102
- # Conditional logging based on file fetch
103
- status = got[0]["status"]
104
- if status == "ok":
105
- logger.info(
106
- f"Successfully fetched xfm file for {src} to {dst} at "
107
- f"{file_path.resolve()}"
108
- )
109
- return file_path
110
- elif status == "notneeded":
111
- logger.info(
112
- f"Found existing xfm file for {src} to {dst} at "
113
- f"{file_path.resolve()}"
114
- )
115
- return file_path
116
- else:
117
- raise_error(
118
- f"Failed to fetch xfm file for {src} to {dst} at "
119
- f"{file_path.resolve()}"
120
- )
40
+ return get(
41
+ file_path=xfm_file_path,
42
+ dataset_path=get_dataset_path(),
43
+ tag=JUNIFER_DATA_VERSION,
44
+ )
121
45
 
122
46
 
123
47
  def get_template(
@@ -190,7 +114,7 @@ def get_template(
190
114
 
191
115
  logger.info(
192
116
  f"Downloading template {space} ({template_type} in "
193
- f"resolution {resolution}"
117
+ f"resolution {resolution})"
194
118
  )
195
119
  # Retrieve template
196
120
  try:
@@ -224,9 +148,11 @@ def get_template(
224
148
  )
225
149
  except Exception: # noqa: BLE001
226
150
  raise_error(
227
- f"Template {space} ({template_type}) with resolution {resolution} "
228
- "not found",
151
+ msg=(
152
+ f"Template {space} ({template_type}) with resolution "
153
+ f"{resolution}) not found"
154
+ ),
229
155
  klass=RuntimeError,
230
156
  )
231
157
  else:
232
- return nib.load(template_path) # type: ignore
158
+ return nib.load(template_path)
junifer/data/utils.py CHANGED
@@ -5,14 +5,24 @@
5
5
  # License: AGPL
6
6
 
7
7
  from collections.abc import MutableMapping
8
+ from pathlib import Path
8
9
  from typing import Optional, Union
9
10
 
10
11
  import numpy as np
11
12
 
12
- from ..utils import logger, raise_error
13
+ from ..utils import config, logger, raise_error
13
14
 
14
15
 
15
- __all__ = ["closest_resolution", "get_native_warper"]
16
+ __all__ = [
17
+ "JUNIFER_DATA_VERSION",
18
+ "closest_resolution",
19
+ "get_dataset_path",
20
+ "get_native_warper",
21
+ ]
22
+
23
+
24
+ # junifer-data version constant
25
+ JUNIFER_DATA_VERSION = "1"
16
26
 
17
27
 
18
28
  def closest_resolution(
@@ -114,3 +124,19 @@ def get_native_warper(
114
124
  )
115
125
 
116
126
  return possible_warpers[0]
127
+
128
+
129
+ def get_dataset_path() -> Optional[Path]:
130
+ """Get junifer-data dataset path.
131
+
132
+ Returns
133
+ -------
134
+ pathlib.Path or None
135
+ Path to the dataset or None.
136
+
137
+ """
138
+ return (
139
+ Path(config.get("data.location"))
140
+ if config.get("data.location") is not None
141
+ else None
142
+ )
junifer/typing/_typing.py CHANGED
@@ -63,6 +63,6 @@ MarkerInOutMappings = MutableMapping[str, MutableMapping[str, str]]
63
63
  DataGrabberPatterns = dict[
64
64
  str, Union[dict[str, str], Sequence[dict[str, str]]]
65
65
  ]
66
- ConfigVal = Union[bool, int, float]
66
+ ConfigVal = Union[bool, int, float, str]
67
67
  Element = Union[str, tuple[str, ...]]
68
68
  Elements = Sequence[Element]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: junifer
3
- Version: 0.0.6.dev422
3
+ Version: 0.0.6.dev459
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>
@@ -38,13 +38,13 @@ Requires-Dist: nilearn<=0.10.4,>=0.10.3
38
38
  Requires-Dist: sqlalchemy<=2.1.0,>=2.0.25
39
39
  Requires-Dist: ruamel.yaml<0.19,>=0.17
40
40
  Requires-Dist: h5py>=3.10
41
- Requires-Dist: httpx[http2]<0.28.0,>=0.26.0
42
41
  Requires-Dist: tqdm<4.67.0,>=4.66.1
43
42
  Requires-Dist: templateflow>=23.0.0
44
43
  Requires-Dist: lapy<2.0.0,>=1.0.0
45
44
  Requires-Dist: lazy_loader==0.4
46
45
  Requires-Dist: importlib_metadata; python_version < "3.9"
47
46
  Requires-Dist: looseversion==1.3.0; python_version >= "3.12"
47
+ Requires-Dist: junifer_data==1.1.0
48
48
  Provides-Extra: all
49
49
  Requires-Dist: bctpy==0.6.0; extra == "all"
50
50
  Requires-Dist: neurokit2>=0.1.7; extra == "all"
@@ -1,6 +1,6 @@
1
1
  junifer/__init__.py,sha256=2McgH1yNue6Z1V26-uN_mfMjbTcx4CLhym-DMBl5xA4,266
2
2
  junifer/__init__.pyi,sha256=SsTvgq2Dod6UqJN96GH1lCphH6hJQQurEJHGNhHjGUI,508
3
- junifer/_version.py,sha256=0SUPdERo7s4t4XnU8IbLMWhY77f3A5mTiz_zmLl7P0w,428
3
+ junifer/_version.py,sha256=mHgU7i-2pUPZjIS1fJd2icWX-sd_Mww7MGNNfUY5ydo,428
4
4
  junifer/conftest.py,sha256=PWYkkRDU8ly2lYwv7VBKMHje4et6HX7Yey3Md_I2KbA,613
5
5
  junifer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  junifer/stats.py,sha256=e9aaagMGtgpRfW3Wdpz9ocpnYld1IWylCDcjFUgX9Mk,6225
@@ -48,7 +48,7 @@ junifer/cli/parser.py,sha256=jLinKVcZeuyTnxjB2p5sj8555DO5rcPcWKgZCtgFARY,8498
48
48
  junifer/cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
49
  junifer/cli/utils.py,sha256=AbPQC0Kl-tHMNKiPxp_01gLAGD3IGoLbsq3rXyPMM-c,3116
50
50
  junifer/cli/tests/test_cli.py,sha256=AYL4my12GmFRCbI3JV7-rju32heYxAqbXNwnV8PwqVY,10982
51
- junifer/cli/tests/test_cli_utils.py,sha256=orbBhWaaIxTgB_JzURYH8CvAYqrwle043zHWoVaj6cM,2746
51
+ junifer/cli/tests/test_cli_utils.py,sha256=AfBKG9nAxatDKPhs4fp42gSiF_e7F0XqGWLsWUg5DlQ,2736
52
52
  junifer/cli/tests/test_parser.py,sha256=5A6yI2t9Ou5w--wpEzXY7mdcVMWWFZaTNLPQ6yLU9gI,6113
53
53
  junifer/cli/tests/data/gmd_mean.yaml,sha256=Ohb_C5cfQMK-59U9O1ZhejXyBtzLc5Y4cv8QyYq2azg,330
54
54
  junifer/cli/tests/data/gmd_mean_htcondor.yaml,sha256=f7NLv_KIJXTiPNFmOWl2Vw8EfwojhfkGtwbh5prbd6w,417
@@ -75,12 +75,12 @@ junifer/data/__init__.pyi,sha256=qYszjUYcbFi_2zO23MnbA2HhTW-Ad2oh1pqPQYd6yt0,542
75
75
  junifer/data/_dispatch.py,sha256=O524U1R4MtbGhGJsL0HSh9EqisapBFJWK7uupXrJuMg,6158
76
76
  junifer/data/pipeline_data_registry_base.py,sha256=G8bE3WTj4D_rKC4ZKZe6E48Sd96CGea1PS3SxmTgGK4,2010
77
77
  junifer/data/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
78
- junifer/data/template_spaces.py,sha256=wkxaDA_I_W5FB42GPxOKrl_A_fp0Crdrh6wFux27_NA,7147
79
- junifer/data/utils.py,sha256=5r-0QGQCNZvDM1tVcl9xyrIdgAO85mww0plpM1RUaGA,3247
78
+ junifer/data/template_spaces.py,sha256=3qHlF-OdpnFezC4l3GrTtfv8PuA6nyY3RW_2MuWfPks,4665
79
+ junifer/data/utils.py,sha256=c3o4RcaTrD24jhmwjVBKz6P2gCCKPMg9SbMvNLBFUZA,3712
80
80
  junifer/data/coordinates/__init__.py,sha256=ffM8rwcHLgHAWixJbKrATrbUKzX940V1UF6RAxZdUMg,186
81
81
  junifer/data/coordinates/__init__.pyi,sha256=Z-Ti5XD3HigkZ8uYN6oYsLqw40-F1GvTVQ5QAy08Wng,88
82
82
  junifer/data/coordinates/_ants_coordinates_warper.py,sha256=5RWDC-nI3VG9lkSJ-_y_hlDtjPctKSJokQOp3v8ozwY,2956
83
- junifer/data/coordinates/_coordinates.py,sha256=fBXVvuTxYLTNBSrQiTCiQsxpT0SdbQze3DYuGGgz_mY,12501
83
+ junifer/data/coordinates/_coordinates.py,sha256=FaHxhHuAy9HZrcX5hJ4Lp0LvtKODyX-e02kT-sr04DY,13293
84
84
  junifer/data/coordinates/_fsl_coordinates_warper.py,sha256=5h7rwiPMYBQlA3sMZUImcpnNLLWvIp2-bAEaaHtzX9c,2409
85
85
  junifer/data/coordinates/VOIs/meta/AutobiographicalMemory_VOIs.txt,sha256=9af38naeL18Tlt_gy_ep6vyTAxOB336JYjbo5FvP8PQ,686
86
86
  junifer/data/coordinates/VOIs/meta/CogAC_VOIs.txt,sha256=Sr5_E712OLdeQRyUcDNM0wLBvZIyO6gc9Q7KkyJHX1A,398
@@ -101,12 +101,12 @@ junifer/data/coordinates/VOIs/meta/WM_VOIs.txt,sha256=6uyH5nsv9i5bKS_aEYCgg3wgE7
101
101
  junifer/data/coordinates/VOIs/meta/eMDN_VOIs.txt,sha256=p5D4GdBuGl1d5IbXhsuj3XIU6UGMxhzCR-T8Dwfxz30,382
102
102
  junifer/data/coordinates/VOIs/meta/eSAD_VOIs.txt,sha256=DwgDEFSZoAojG5RP6HpSvlRPpXItBzx8ms-1zoSxKRk,268
103
103
  junifer/data/coordinates/VOIs/meta/extDMN_VOIs.txt,sha256=Ogx1QvqZcnXDM3ncF2ha78br8xwQ5wklSjHygtoLpyI,317
104
- junifer/data/coordinates/tests/test_coordinates.py,sha256=_c2P4oaDGpsmui5gJBe_jN6HLGiKxONkYPR69sRBUlU,4219
104
+ junifer/data/coordinates/tests/test_coordinates.py,sha256=mjHm90Fgytv47F2vPQHW58jRy6LLbAttizEeg1zjxmA,4196
105
105
  junifer/data/masks/__init__.py,sha256=eEEhHglyVEx1LrqwXjq3cOmjf4sTsgBstRx5-k7zIQU,180
106
106
  junifer/data/masks/__init__.pyi,sha256=lcgr8gmWDPibC4RxnWBXb8DDpIkO73Aax09u6VXiJJI,114
107
107
  junifer/data/masks/_ants_mask_warper.py,sha256=JLK2Jh2AOAiv_NoUGhRoTBEhRFXPRXTDPmQGH9vBSok,5805
108
108
  junifer/data/masks/_fsl_mask_warper.py,sha256=YZOMlRgQ7_4shnXNc_05tmwDk5xHI-1wqle-RdNsJ34,2857
109
- junifer/data/masks/_masks.py,sha256=K-A1cr9TAeVzFPGgn4FUmwIo6LBP0xQb1Q4NW6WTWVo,28166
109
+ junifer/data/masks/_masks.py,sha256=NA2Px_PUv0DDtFpLpYjJxSGo2ozTk-6bSNd16Cou1VA,28671
110
110
  junifer/data/masks/tests/test_masks.py,sha256=W0bzRB5Bp-iGO44VtEmaf7BuT-joe_2tQI0lma5NQHA,16090
111
111
  junifer/data/masks/ukb/UKB_15K_GM_template.nii.gz,sha256=jcX1pDOrDsoph8cPMNFVKH5gZYio5G4rJNpOFXm9wJI,946636
112
112
  junifer/data/masks/vickery-patil/CAT12_IXI555_MNI152_TMP_GS_GMprob0.2_clean.nii.gz,sha256=j6EY8EtRnUuRxeKgD65Q6B0GPEPIALKDJEIje1TfnAU,88270
@@ -116,8 +116,8 @@ junifer/data/parcellations/__init__.py,sha256=6-Ysil3NyZ69V6rWx4RO15_d-iDKizfbHu
116
116
  junifer/data/parcellations/__init__.pyi,sha256=lhBHTbMDizzqUqVHrx2eyfPFodrTBgMFeTgxfESSkQ8,140
117
117
  junifer/data/parcellations/_ants_parcellation_warper.py,sha256=YUCJC0_wutGw7j_n9JRU3LCwm9Ttg5PIlJUgqejfRhs,5806
118
118
  junifer/data/parcellations/_fsl_parcellation_warper.py,sha256=JfJ022flg5OR48P4OAALVHHQgTVxdMBXT-fAqBl3nUM,2679
119
- junifer/data/parcellations/_parcellations.py,sha256=JUUglL0ZM_UKL5jTG1q-3x6Fd3CUO6Hl4YAGAUsGtmI,67019
120
- junifer/data/parcellations/tests/test_parcellations.py,sha256=ESQI-KWsepmgKB2BWWWUxjkpjOWeIZhhlKxNuTsRPJg,39268
119
+ junifer/data/parcellations/_parcellations.py,sha256=SbkXmyEG-ZY7QOlZYq15KULjzNJkp-jDRM9Au2R8Q5g,48625
120
+ junifer/data/parcellations/tests/test_parcellations.py,sha256=Pf7klYabWikrvanYPlukq2GcVyFXDc_IVB2TgN_BU9c,36027
121
121
  junifer/data/tests/test_data_utils.py,sha256=136iGPjGecCxyqgUwU8VZMHoE6imcYJ0WNC32PDGK4g,1063
122
122
  junifer/data/tests/test_template_spaces.py,sha256=ZEicEcLqOJ-NpuBZ5SYh4yZ0xZRkhYHnYXiC_YSxjrY,3219
123
123
  junifer/datagrabber/__init__.py,sha256=EHIK-lbjuvkt0V8ypFvLSt85OAAXSkaxBmVlCbNNz8M,323
@@ -327,7 +327,7 @@ junifer/tests/test_main.py,sha256=GMff7jlisGM9_FsiUwWDte43j-KQJGFRYZpwRRqTkd8,37
327
327
  junifer/tests/test_stats.py,sha256=NljoGFu2JOPADbi9W0WeUHwpf8nZSdOkcCgCv-Z1fY4,4149
328
328
  junifer/typing/__init__.py,sha256=e0UbuxozXUIxz8h8pLokMOxZV629Q1lnA7vvgm95WF0,215
329
329
  junifer/typing/__init__.pyi,sha256=GRGfrnReP1ROtQM6eT0EpFjmE-v-pCJuBiQZMXCVTsE,594
330
- junifer/typing/_typing.py,sha256=oKxUUelzxntTzlxyE9G4WV2xq600QaRx5vzNlGWL2dU,1658
330
+ junifer/typing/_typing.py,sha256=2D7ibO5OB3yTgpjI1IV_QorZ6b-ZEQVPQE-z2qxis9I,1663
331
331
  junifer/utils/__init__.py,sha256=I3tYaePAD_ZEU-36-TJ_OYeqW_aMmi5MZ3jmqie6RfU,260
332
332
  junifer/utils/__init__.pyi,sha256=CMb4rq1VcQ00IRuiBFfAWu07Vb-vA4qtVLAoY0ll-bA,422
333
333
  junifer/utils/_config.py,sha256=cfxyv1bfklID2atQseu6y3J7mZrCXPwnGEfBSImG9CM,3054
@@ -341,10 +341,10 @@ junifer/utils/tests/test_config.py,sha256=7ltIXuwb_W4Mv_1dxQWyiyM10XgUAfsWKV6D_i
341
341
  junifer/utils/tests/test_fs.py,sha256=WQS7cKlKEZ742CIuiOYYpueeAhY9PqlastfDVpVVtvE,923
342
342
  junifer/utils/tests/test_helpers.py,sha256=k5qqfxK8dFyuewTJyR1Qn6-nFaYNuVr0ysc18bfPjyU,929
343
343
  junifer/utils/tests/test_logging.py,sha256=duO4ou365hxwa_kwihFtKPLaL6LC5XHiyhOijrrngbA,8009
344
- junifer-0.0.6.dev422.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
345
- junifer-0.0.6.dev422.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
346
- junifer-0.0.6.dev422.dist-info/METADATA,sha256=PS2Llw7XCBtnS2KNkImOgWiT2RgUZ0Gshu2u1Z8F9VM,8429
347
- junifer-0.0.6.dev422.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
348
- junifer-0.0.6.dev422.dist-info/entry_points.txt,sha256=6O8ru0BP-SP7YMUZiizFNoaZ2HvJpadO2G7nKk4PwjI,48
349
- junifer-0.0.6.dev422.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
350
- junifer-0.0.6.dev422.dist-info/RECORD,,
344
+ junifer-0.0.6.dev459.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
345
+ junifer-0.0.6.dev459.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
346
+ junifer-0.0.6.dev459.dist-info/METADATA,sha256=DVNM9OEMkhbATGZgotZ-ZRhQqyvB2E48OgpwKVzoCLE,8420
347
+ junifer-0.0.6.dev459.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
348
+ junifer-0.0.6.dev459.dist-info/entry_points.txt,sha256=6O8ru0BP-SP7YMUZiizFNoaZ2HvJpadO2G7nKk4PwjI,48
349
+ junifer-0.0.6.dev459.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
350
+ junifer-0.0.6.dev459.dist-info/RECORD,,