junifer 0.0.6.dev445__py3-none-any.whl → 0.0.6.dev474__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.6.dev445'
16
- __version_tuple__ = version_tuple = (0, 0, 6, 'dev445')
15
+ __version__ = version = '0.0.6.dev474'
16
+ __version_tuple__ = version_tuple = (0, 0, 6, 'dev474')
@@ -48,6 +48,7 @@ def test_get_dependency_information_short() -> None:
48
48
  "lapy",
49
49
  "lazy_loader",
50
50
  "looseversion",
51
+ "junifer_data",
51
52
  ]
52
53
 
53
54
  if sys.version_info < (3, 11):
@@ -4,16 +4,18 @@
4
4
  # Synchon Mandal <s.mandal@fz-juelich.de>
5
5
  # License: AGPL
6
6
 
7
+ from pathlib import Path
7
8
  from typing import Any, Optional
8
9
 
9
10
  import numpy as np
10
11
  import pandas as pd
12
+ from junifer_data import get
11
13
  from numpy.typing import ArrayLike
12
14
 
13
15
  from ...utils import logger, raise_error
14
16
  from ...utils.singleton import Singleton
15
17
  from ..pipeline_data_registry_base import BasePipelineDataRegistry
16
- from ..utils import check_dataset, fetch_file_via_datalad, get_native_warper
18
+ from ..utils import JUNIFER_DATA_VERSION, get_dataset_path, get_native_warper
17
19
  from ._ants_coordinates_warper import ANTsCoordinatesWarper
18
20
  from ._fsl_coordinates_warper import FSLCoordinatesWarper
19
21
 
@@ -273,23 +275,17 @@ class CoordinatesRegistry(BasePipelineDataRegistry, metaclass=Singleton):
273
275
 
274
276
  # Load data for in-built ones
275
277
  if t_coord.get("file_path_suffix") is not None:
276
- # Get dataset
277
- dataset = check_dataset()
278
278
  # Set file path to retrieve
279
- coords_file_path = (
280
- dataset.pathobj
281
- / "coordinates"
282
- / name
283
- / t_coord["file_path_suffix"]
284
- )
285
- logger.debug(
286
- f"Loading coordinates `{name}` from: "
287
- f"{coords_file_path.absolute()!s}"
279
+ coords_file_path = Path(
280
+ f"coordinates/{name}/{t_coord['file_path_suffix']}"
288
281
  )
282
+ logger.debug(f"Loading coordinates: `{name}`")
289
283
  # Load via pandas
290
284
  df_coords = pd.read_csv(
291
- fetch_file_via_datalad(
292
- dataset=dataset, file_path=coords_file_path
285
+ get(
286
+ file_path=coords_file_path,
287
+ dataset_path=get_dataset_path(),
288
+ tag=JUNIFER_DATA_VERSION,
293
289
  ),
294
290
  sep="\t",
295
291
  header=None,
@@ -16,6 +16,7 @@ from typing import (
16
16
  import nibabel as nib
17
17
  import nilearn.image as nimg
18
18
  import numpy as np
19
+ from junifer_data import get
19
20
  from nilearn.masking import (
20
21
  compute_background_mask,
21
22
  compute_epi_mask,
@@ -27,9 +28,9 @@ from ...utils.singleton import Singleton
27
28
  from ..pipeline_data_registry_base import BasePipelineDataRegistry
28
29
  from ..template_spaces import get_template
29
30
  from ..utils import (
30
- check_dataset,
31
+ JUNIFER_DATA_VERSION,
31
32
  closest_resolution,
32
- fetch_file_via_datalad,
33
+ get_dataset_path,
33
34
  get_native_warper,
34
35
  )
35
36
  from ._ants_mask_warper import ANTsMaskWarper
@@ -37,7 +38,6 @@ from ._fsl_mask_warper import FSLMaskWarper
37
38
 
38
39
 
39
40
  if TYPE_CHECKING:
40
- from datalad.api import Dataset
41
41
  from nibabel.nifti1 import Nifti1Image
42
42
 
43
43
 
@@ -406,17 +406,14 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
406
406
  mask_img = mask_definition["func"]
407
407
  mask_fname = None
408
408
  elif t_family in ["Vickery-Patil", "UKB"]:
409
- # Get dataset
410
- dataset = check_dataset()
411
409
  # Load mask
412
410
  if t_family == "Vickery-Patil":
413
411
  mask_fname = _load_vickery_patil_mask(
414
- dataset=dataset,
415
412
  name=name,
416
413
  resolution=resolution,
417
414
  )
418
415
  elif t_family == "UKB":
419
- mask_fname = _load_ukb_mask(dataset=dataset, name=name)
416
+ mask_fname = _load_ukb_mask(name=name)
420
417
  else:
421
418
  raise_error(f"Unknown mask family: {t_family}")
422
419
 
@@ -698,7 +695,6 @@ class MaskRegistry(BasePipelineDataRegistry, metaclass=Singleton):
698
695
 
699
696
 
700
697
  def _load_vickery_patil_mask(
701
- dataset: "Dataset",
702
698
  name: str,
703
699
  resolution: Optional[float] = None,
704
700
  ) -> Path:
@@ -706,8 +702,6 @@ def _load_vickery_patil_mask(
706
702
 
707
703
  Parameters
708
704
  ----------
709
- dataset : datalad.api.Dataset
710
- The datalad dataset to fetch mask from.
711
705
  name : {"GM_prob0.2", "GM_prob0.2_cortex"}
712
706
  The name of the mask.
713
707
  resolution : float, optional
@@ -748,19 +742,18 @@ def _load_vickery_patil_mask(
748
742
  raise_error(f"Cannot find a Vickery-Patil mask called {name}")
749
743
 
750
744
  # Fetch file
751
- return fetch_file_via_datalad(
752
- dataset=dataset,
753
- file_path=dataset.pathobj / "masks" / "Vickery-Patil" / mask_fname,
745
+ return get(
746
+ file_path=Path(f"masks/Vickery-Patil/{mask_fname}"),
747
+ dataset_path=get_dataset_path(),
748
+ tag=JUNIFER_DATA_VERSION,
754
749
  )
755
750
 
756
751
 
757
- def _load_ukb_mask(dataset: "Dataset", name: str) -> Path:
752
+ def _load_ukb_mask(name: str) -> Path:
758
753
  """Load UKB mask.
759
754
 
760
755
  Parameters
761
756
  ----------
762
- dataset : datalad.api.Dataset
763
- The datalad dataset to fetch mask from.
764
757
  name : {"UKB_15K_GM"}
765
758
  The name of the mask.
766
759
 
@@ -782,9 +775,10 @@ def _load_ukb_mask(dataset: "Dataset", name: str) -> Path:
782
775
  raise_error(f"Cannot find a UKB mask called {name}")
783
776
 
784
777
  # Fetch file
785
- return fetch_file_via_datalad(
786
- dataset=dataset,
787
- file_path=dataset.pathobj / "masks" / "UKB" / mask_fname,
778
+ return get(
779
+ file_path=Path(f"masks/UKB/{mask_fname}"),
780
+ dataset_path=get_dataset_path(),
781
+ tag=JUNIFER_DATA_VERSION,
788
782
  )
789
783
 
790
784
 
@@ -26,7 +26,6 @@ from junifer.data.masks._masks import (
26
26
  _load_ukb_mask,
27
27
  _load_vickery_patil_mask,
28
28
  )
29
- from junifer.data.utils import check_dataset
30
29
  from junifer.datagrabber import DMCC13Benchmark
31
30
  from junifer.datareader import DefaultDataReader
32
31
  from junifer.testing.datagrabbers import (
@@ -283,9 +282,7 @@ def test_vickery_patil(
283
282
  def test_vickery_patil_error() -> None:
284
283
  """Test error for Vickery-Patil mask."""
285
284
  with pytest.raises(ValueError, match=r"find a Vickery-Patil mask "):
286
- _load_vickery_patil_mask(
287
- dataset=check_dataset(), name="wrong", resolution=2.0
288
- )
285
+ _load_vickery_patil_mask(name="wrong", resolution=2.0)
289
286
 
290
287
 
291
288
  def test_ukb() -> None:
@@ -300,7 +297,7 @@ def test_ukb() -> None:
300
297
  def test_ukb_error() -> None:
301
298
  """Test error for UKB mask."""
302
299
  with pytest.raises(ValueError, match=r"find a UKB mask "):
303
- _load_ukb_mask(dataset=check_dataset(), name="wrong")
300
+ _load_ukb_mask(name="wrong")
304
301
 
305
302
 
306
303
  def test_get() -> None: