junifer 0.0.6.dev445__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.
- junifer/_version.py +2 -2
- junifer/cli/tests/test_cli_utils.py +1 -0
- junifer/data/coordinates/_coordinates.py +10 -14
- junifer/data/masks/_masks.py +13 -19
- junifer/data/masks/tests/test_masks.py +2 -5
- junifer/data/parcellations/_parcellations.py +94 -159
- junifer/data/parcellations/tests/test_parcellations.py +2 -20
- junifer/data/template_spaces.py +8 -10
- junifer/data/utils.py +15 -90
- junifer/typing/_typing.py +1 -1
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev459.dist-info}/METADATA +2 -1
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev459.dist-info}/RECORD +17 -17
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev459.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev459.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev459.dist-info}/WHEEL +0 -0
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev459.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev459.dist-info}/top_level.txt +0 -0
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.
|
16
|
-
__version_tuple__ = version_tuple = (0, 0, 6, '
|
15
|
+
__version__ = version = '0.0.6.dev459'
|
16
|
+
__version_tuple__ = version_tuple = (0, 0, 6, 'dev459')
|
@@ -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
|
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
|
-
|
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
|
-
|
292
|
-
|
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,
|
junifer/data/masks/_masks.py
CHANGED
@@ -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
|
-
|
31
|
+
JUNIFER_DATA_VERSION,
|
31
32
|
closest_resolution,
|
32
|
-
|
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(
|
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
|
752
|
-
|
753
|
-
|
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(
|
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
|
786
|
-
|
787
|
-
|
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(
|
300
|
+
_load_ukb_mask(name="wrong")
|
304
301
|
|
305
302
|
|
306
303
|
def test_get() -> None:
|
@@ -13,14 +13,15 @@ import nibabel as nib
|
|
13
13
|
import nilearn.image as nimg
|
14
14
|
import numpy as np
|
15
15
|
import pandas as pd
|
16
|
+
from junifer_data import get
|
16
17
|
|
17
18
|
from ...utils import logger, raise_error, warn_with_log
|
18
19
|
from ...utils.singleton import Singleton
|
19
20
|
from ..pipeline_data_registry_base import BasePipelineDataRegistry
|
20
21
|
from ..utils import (
|
21
|
-
|
22
|
+
JUNIFER_DATA_VERSION,
|
22
23
|
closest_resolution,
|
23
|
-
|
24
|
+
get_dataset_path,
|
24
25
|
get_native_warper,
|
25
26
|
)
|
26
27
|
from ._ants_parcellation_warper import ANTsParcellationWarper
|
@@ -28,7 +29,6 @@ from ._fsl_parcellation_warper import FSLParcellationWarper
|
|
28
29
|
|
29
30
|
|
30
31
|
if TYPE_CHECKING:
|
31
|
-
from datalad.api import Dataset
|
32
32
|
from nibabel.nifti1 import Nifti1Image
|
33
33
|
|
34
34
|
|
@@ -357,49 +357,40 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
357
357
|
"Yan2023",
|
358
358
|
"Brainnetome",
|
359
359
|
]:
|
360
|
-
# Get dataset
|
361
|
-
dataset = check_dataset()
|
362
360
|
# Load parcellation and labels
|
363
361
|
if t_family == "Schaefer2018":
|
364
362
|
parcellation_fname, parcellation_labels = _retrieve_schaefer(
|
365
|
-
dataset=dataset,
|
366
363
|
resolution=resolution,
|
367
364
|
**parcellation_definition,
|
368
365
|
)
|
369
366
|
elif t_family == "SUIT":
|
370
367
|
parcellation_fname, parcellation_labels = _retrieve_suit(
|
371
|
-
dataset=dataset,
|
372
368
|
resolution=resolution,
|
373
369
|
**parcellation_definition,
|
374
370
|
)
|
375
371
|
elif t_family == "Melbourne":
|
376
372
|
parcellation_fname, parcellation_labels = _retrieve_tian(
|
377
|
-
dataset=dataset,
|
378
373
|
resolution=resolution,
|
379
374
|
**parcellation_definition,
|
380
375
|
)
|
381
376
|
elif t_family == "AICHA":
|
382
377
|
parcellation_fname, parcellation_labels = _retrieve_aicha(
|
383
|
-
dataset=dataset,
|
384
378
|
resolution=resolution,
|
385
379
|
**parcellation_definition,
|
386
380
|
)
|
387
381
|
elif t_family == "Shen":
|
388
382
|
parcellation_fname, parcellation_labels = _retrieve_shen(
|
389
|
-
dataset=dataset,
|
390
383
|
resolution=resolution,
|
391
384
|
**parcellation_definition,
|
392
385
|
)
|
393
386
|
elif t_family == "Yan2023":
|
394
387
|
parcellation_fname, parcellation_labels = _retrieve_yan(
|
395
|
-
dataset=dataset,
|
396
388
|
resolution=resolution,
|
397
389
|
**parcellation_definition,
|
398
390
|
)
|
399
391
|
elif t_family == "Brainnetome":
|
400
392
|
parcellation_fname, parcellation_labels = (
|
401
393
|
_retrieve_brainnetome(
|
402
|
-
dataset=dataset,
|
403
394
|
resolution=resolution,
|
404
395
|
**parcellation_definition,
|
405
396
|
)
|
@@ -585,7 +576,6 @@ class ParcellationRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|
585
576
|
|
586
577
|
|
587
578
|
def _retrieve_schaefer(
|
588
|
-
dataset: "Dataset",
|
589
579
|
resolution: Optional[float] = None,
|
590
580
|
n_rois: Optional[int] = None,
|
591
581
|
yeo_networks: int = 7,
|
@@ -594,8 +584,6 @@ def _retrieve_schaefer(
|
|
594
584
|
|
595
585
|
Parameters
|
596
586
|
----------
|
597
|
-
dataset : datalad.api.Dataset
|
598
|
-
The datalad dataset to fetch parcellation from.
|
599
587
|
resolution : float, optional
|
600
588
|
The desired resolution of the parcellation to load. If it is not
|
601
589
|
available, the closest resolution will be loaded. Preferably, use a
|
@@ -646,24 +634,18 @@ def _retrieve_schaefer(
|
|
646
634
|
resolution = closest_resolution(resolution, _valid_resolutions)
|
647
635
|
|
648
636
|
# Fetch file paths
|
649
|
-
|
650
|
-
|
651
|
-
file_path=
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
/ (
|
656
|
-
f"Schaefer2018_{n_rois}Parcels_{yeo_networks}Networks_order_"
|
657
|
-
f"FSLMNI152_{resolution}mm.nii.gz"
|
658
|
-
),
|
637
|
+
path_prefix = Path("parcellations/Schaefer2018/Yeo2011")
|
638
|
+
parcellation_img_path = get(
|
639
|
+
file_path=path_prefix / f"Schaefer2018_{n_rois}Parcels_{yeo_networks}"
|
640
|
+
f"Networks_order_FSLMNI152_{resolution}mm.nii.gz",
|
641
|
+
dataset_path=get_dataset_path(),
|
642
|
+
tag=JUNIFER_DATA_VERSION,
|
659
643
|
)
|
660
|
-
parcellation_label_path =
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
/ "Yeo2011"
|
666
|
-
/ (f"Schaefer2018_{n_rois}Parcels_{yeo_networks}Networks_order.txt"),
|
644
|
+
parcellation_label_path = get(
|
645
|
+
file_path=path_prefix
|
646
|
+
/ f"Schaefer2018_{n_rois}Parcels_{yeo_networks}Networks_order.txt",
|
647
|
+
dataset_path=get_dataset_path(),
|
648
|
+
tag=JUNIFER_DATA_VERSION,
|
667
649
|
)
|
668
650
|
|
669
651
|
# Load labels
|
@@ -678,7 +660,6 @@ def _retrieve_schaefer(
|
|
678
660
|
|
679
661
|
|
680
662
|
def _retrieve_tian(
|
681
|
-
dataset: "Dataset",
|
682
663
|
resolution: Optional[float] = None,
|
683
664
|
scale: Optional[int] = None,
|
684
665
|
space: str = "MNI152NLin6Asym",
|
@@ -688,8 +669,6 @@ def _retrieve_tian(
|
|
688
669
|
|
689
670
|
Parameters
|
690
671
|
----------
|
691
|
-
dataset : datalad.api.Dataset
|
692
|
-
The datalad dataset to fetch parcellation from.
|
693
672
|
resolution : float, optional
|
694
673
|
The desired resolution of the parcellation to load. If it is not
|
695
674
|
available, the closest resolution will be loaded. Preferably, use a
|
@@ -758,13 +737,8 @@ def _retrieve_tian(
|
|
758
737
|
|
759
738
|
# Fetch file paths
|
760
739
|
if magneticfield == "3T":
|
761
|
-
parcellation_fname_base_3T = (
|
762
|
-
|
763
|
-
/ "parcellations"
|
764
|
-
/ "Melbourne"
|
765
|
-
/ "v1.4"
|
766
|
-
/ "3T"
|
767
|
-
/ "Subcortex-Only"
|
740
|
+
parcellation_fname_base_3T = Path(
|
741
|
+
"parcellations/Melbourne/v1.4/3T/Subcortex-Only"
|
768
742
|
)
|
769
743
|
if space == "MNI152NLin6Asym":
|
770
744
|
if resolution == 1:
|
@@ -787,28 +761,29 @@ def _retrieve_tian(
|
|
787
761
|
f"Tian_Subcortex_S{scale}_{magneticfield}_{space}.nii.gz"
|
788
762
|
)
|
789
763
|
|
790
|
-
parcellation_img_path =
|
791
|
-
dataset=dataset,
|
764
|
+
parcellation_img_path = get(
|
792
765
|
file_path=parcellation_fname,
|
766
|
+
dataset_path=get_dataset_path(),
|
767
|
+
tag=JUNIFER_DATA_VERSION,
|
793
768
|
)
|
794
|
-
parcellation_label_path =
|
795
|
-
dataset=dataset,
|
769
|
+
parcellation_label_path = get(
|
796
770
|
file_path=parcellation_fname_base_3T
|
797
771
|
/ f"Tian_Subcortex_S{scale}_3T_label.txt",
|
772
|
+
dataset_path=get_dataset_path(),
|
773
|
+
tag=JUNIFER_DATA_VERSION,
|
798
774
|
)
|
799
775
|
# Load labels
|
800
776
|
labels = pd.read_csv(parcellation_label_path, sep=" ", header=None)[
|
801
777
|
0
|
802
778
|
].to_list()
|
803
779
|
elif magneticfield == "7T":
|
804
|
-
parcellation_img_path =
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
/ f"Tian_Subcortex_S{scale}_{magneticfield}.nii.gz",
|
780
|
+
parcellation_img_path = get(
|
781
|
+
file_path=Path(
|
782
|
+
"parcellations/Melbourne/v1.4/7T/"
|
783
|
+
f"Tian_Subcortex_S{scale}_{magneticfield}.nii.gz"
|
784
|
+
),
|
785
|
+
dataset_path=get_dataset_path(),
|
786
|
+
tag=JUNIFER_DATA_VERSION,
|
812
787
|
)
|
813
788
|
# define 7T labels (b/c currently no labels file available for 7T)
|
814
789
|
scale7Trois = {1: 16, 2: 34, 3: 54, 4: 62}
|
@@ -825,7 +800,6 @@ def _retrieve_tian(
|
|
825
800
|
|
826
801
|
|
827
802
|
def _retrieve_suit(
|
828
|
-
dataset: "Dataset",
|
829
803
|
resolution: Optional[float],
|
830
804
|
space: str = "MNI152NLin6Asym",
|
831
805
|
) -> tuple[Path, list[str]]:
|
@@ -833,8 +807,6 @@ def _retrieve_suit(
|
|
833
807
|
|
834
808
|
Parameters
|
835
809
|
----------
|
836
|
-
dataset : datalad.api.Dataset
|
837
|
-
The datalad dataset to fetch parcellation from.
|
838
810
|
resolution : float, optional
|
839
811
|
The desired resolution of the parcellation to load. If it is not
|
840
812
|
available, the closest resolution will be loaded. Preferably, use a
|
@@ -879,19 +851,16 @@ def _retrieve_suit(
|
|
879
851
|
space = "MNI"
|
880
852
|
|
881
853
|
# Fetch file paths
|
882
|
-
|
883
|
-
|
884
|
-
file_path=
|
885
|
-
|
886
|
-
|
887
|
-
/ f"SUIT_{space}Space_{resolution}mm.nii",
|
854
|
+
path_prefix = Path("parcellations/SUIT")
|
855
|
+
parcellation_img_path = get(
|
856
|
+
file_path=path_prefix / f"SUIT_{space}Space_{resolution}mm.nii",
|
857
|
+
dataset_path=get_dataset_path(),
|
858
|
+
tag=JUNIFER_DATA_VERSION,
|
888
859
|
)
|
889
|
-
parcellation_label_path =
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
/ "SUIT"
|
894
|
-
/ f"SUIT_{space}Space_{resolution}mm.tsv",
|
860
|
+
parcellation_label_path = get(
|
861
|
+
file_path=path_prefix / f"SUIT_{space}Space_{resolution}mm.tsv",
|
862
|
+
dataset_path=get_dataset_path(),
|
863
|
+
tag=JUNIFER_DATA_VERSION,
|
895
864
|
)
|
896
865
|
|
897
866
|
# Load labels
|
@@ -903,7 +872,6 @@ def _retrieve_suit(
|
|
903
872
|
|
904
873
|
|
905
874
|
def _retrieve_aicha(
|
906
|
-
dataset: "Dataset",
|
907
875
|
resolution: Optional[float] = None,
|
908
876
|
version: int = 2,
|
909
877
|
) -> tuple[Path, list[str]]:
|
@@ -911,8 +879,6 @@ def _retrieve_aicha(
|
|
911
879
|
|
912
880
|
Parameters
|
913
881
|
----------
|
914
|
-
dataset : datalad.api.Dataset
|
915
|
-
The datalad dataset to fetch parcellation from.
|
916
882
|
resolution : float, optional
|
917
883
|
The desired resolution of the parcellation to load. If it is not
|
918
884
|
available, the closest resolution will be loaded. Preferably, use a
|
@@ -968,32 +934,24 @@ def _retrieve_aicha(
|
|
968
934
|
resolution = closest_resolution(resolution, _valid_resolutions)
|
969
935
|
|
970
936
|
# Fetch file paths
|
971
|
-
|
972
|
-
|
973
|
-
file_path=
|
974
|
-
|
975
|
-
|
976
|
-
/ f"v{version}"
|
977
|
-
/ "AICHA.nii",
|
937
|
+
path_prefix = Path(f"parcellations/AICHA/v{version}")
|
938
|
+
parcellation_img_path = get(
|
939
|
+
file_path=path_prefix / "AICHA.nii",
|
940
|
+
dataset_path=get_dataset_path(),
|
941
|
+
tag=JUNIFER_DATA_VERSION,
|
978
942
|
)
|
979
943
|
# Conditional label file fetch
|
980
944
|
if version == 1:
|
981
|
-
parcellation_label_path =
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
/ "AICHA"
|
986
|
-
/ f"v{version}"
|
987
|
-
/ "AICHA_vol1.txt",
|
945
|
+
parcellation_label_path = get(
|
946
|
+
file_path=path_prefix / "AICHA_vol1.txt",
|
947
|
+
dataset_path=get_dataset_path(),
|
948
|
+
tag=JUNIFER_DATA_VERSION,
|
988
949
|
)
|
989
950
|
elif version == 2:
|
990
|
-
parcellation_label_path =
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
/ "AICHA"
|
995
|
-
/ f"v{version}"
|
996
|
-
/ "AICHA_vol3.txt",
|
951
|
+
parcellation_label_path = get(
|
952
|
+
file_path=path_prefix / "AICHA_vol3.txt",
|
953
|
+
dataset_path=get_dataset_path(),
|
954
|
+
tag=JUNIFER_DATA_VERSION,
|
997
955
|
)
|
998
956
|
|
999
957
|
# Load labels
|
@@ -1008,7 +966,6 @@ def _retrieve_aicha(
|
|
1008
966
|
|
1009
967
|
|
1010
968
|
def _retrieve_shen(
|
1011
|
-
dataset: "Dataset",
|
1012
969
|
resolution: Optional[float] = None,
|
1013
970
|
year: int = 2015,
|
1014
971
|
n_rois: int = 268,
|
@@ -1017,8 +974,6 @@ def _retrieve_shen(
|
|
1017
974
|
|
1018
975
|
Parameters
|
1019
976
|
----------
|
1020
|
-
dataset : datalad.api.Dataset
|
1021
|
-
The datalad dataset to fetch parcellation from.
|
1022
977
|
resolution : float, optional
|
1023
978
|
The desired resolution of the parcellation to load. If it is not
|
1024
979
|
available, the closest resolution will be loaded. Preferably, use a
|
@@ -1095,22 +1050,17 @@ def _retrieve_shen(
|
|
1095
1050
|
)
|
1096
1051
|
|
1097
1052
|
# Fetch file paths based on year
|
1053
|
+
path_prefix = Path(f"parcellations/Shen/{year}")
|
1098
1054
|
if year == 2013:
|
1099
|
-
parcellation_img_path =
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
/ "Shen"
|
1104
|
-
/ "2013"
|
1105
|
-
/ f"fconn_atlas_{n_rois}_{resolution}mm.nii",
|
1055
|
+
parcellation_img_path = get(
|
1056
|
+
file_path=path_prefix / f"fconn_atlas_{n_rois}_{resolution}mm.nii",
|
1057
|
+
dataset_path=get_dataset_path(),
|
1058
|
+
tag=JUNIFER_DATA_VERSION,
|
1106
1059
|
)
|
1107
|
-
parcellation_label_path =
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
/ "Shen"
|
1112
|
-
/ "2013"
|
1113
|
-
/ f"Group_seg{n_rois}_BAindexing_setA.txt",
|
1060
|
+
parcellation_label_path = get(
|
1061
|
+
file_path=path_prefix / f"Group_seg{n_rois}_BAindexing_setA.txt",
|
1062
|
+
dataset_path=get_dataset_path(),
|
1063
|
+
tag=JUNIFER_DATA_VERSION,
|
1114
1064
|
)
|
1115
1065
|
labels = (
|
1116
1066
|
pd.read_csv(
|
@@ -1123,23 +1073,18 @@ def _retrieve_shen(
|
|
1123
1073
|
.to_list()
|
1124
1074
|
)
|
1125
1075
|
elif year == 2015:
|
1126
|
-
parcellation_img_path =
|
1127
|
-
|
1128
|
-
file_path=dataset.pathobj
|
1129
|
-
/ "parcellations"
|
1130
|
-
/ "Shen"
|
1131
|
-
/ "2015"
|
1076
|
+
parcellation_img_path = get(
|
1077
|
+
file_path=path_prefix
|
1132
1078
|
/ f"shen_{resolution}mm_268_parcellation.nii.gz",
|
1079
|
+
dataset_path=get_dataset_path(),
|
1080
|
+
tag=JUNIFER_DATA_VERSION,
|
1133
1081
|
)
|
1134
1082
|
labels = list(range(1, 269))
|
1135
1083
|
elif year == 2019:
|
1136
|
-
parcellation_img_path =
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
/ "Shen"
|
1141
|
-
/ "2019"
|
1142
|
-
/ "Shen_1mm_368_parcellation.nii.gz",
|
1084
|
+
parcellation_img_path = get(
|
1085
|
+
file_path=path_prefix / "Shen_1mm_368_parcellation.nii.gz",
|
1086
|
+
dataset_path=get_dataset_path(),
|
1087
|
+
tag=JUNIFER_DATA_VERSION,
|
1143
1088
|
)
|
1144
1089
|
labels = list(range(1, 369))
|
1145
1090
|
|
@@ -1147,7 +1092,6 @@ def _retrieve_shen(
|
|
1147
1092
|
|
1148
1093
|
|
1149
1094
|
def _retrieve_yan(
|
1150
|
-
dataset: "Dataset",
|
1151
1095
|
resolution: Optional[float] = None,
|
1152
1096
|
n_rois: Optional[int] = None,
|
1153
1097
|
yeo_networks: Optional[int] = None,
|
@@ -1157,8 +1101,6 @@ def _retrieve_yan(
|
|
1157
1101
|
|
1158
1102
|
Parameters
|
1159
1103
|
----------
|
1160
|
-
dataset : datalad.api.Dataset
|
1161
|
-
The datalad dataset to fetch parcellation from.
|
1162
1104
|
resolution : float, optional
|
1163
1105
|
The desired resolution of the parcellation to load. If it is not
|
1164
1106
|
available, the closest resolution will be loaded. Preferably, use a
|
@@ -1214,6 +1156,7 @@ def _retrieve_yan(
|
|
1214
1156
|
)
|
1215
1157
|
|
1216
1158
|
# Fetch file paths based on networks
|
1159
|
+
pre_path_prefix = Path("parcellations/Yan2023")
|
1217
1160
|
if yeo_networks:
|
1218
1161
|
# Check yeo_networks value
|
1219
1162
|
_valid_yeo_networks = [7, 17]
|
@@ -1223,24 +1166,21 @@ def _retrieve_yan(
|
|
1223
1166
|
f"one of the following: {_valid_yeo_networks}"
|
1224
1167
|
)
|
1225
1168
|
|
1226
|
-
|
1227
|
-
|
1228
|
-
file_path=
|
1229
|
-
/ "parcellations"
|
1230
|
-
/ "Yan2023"
|
1231
|
-
/ "Yeo2011"
|
1169
|
+
path_prefix = pre_path_prefix / "Yeo2011"
|
1170
|
+
parcellation_img_path = get(
|
1171
|
+
file_path=path_prefix
|
1232
1172
|
/ (
|
1233
1173
|
f"{n_rois}Parcels_Yeo2011_{yeo_networks}Networks_FSLMNI152_"
|
1234
1174
|
f"{resolution}mm.nii.gz"
|
1235
1175
|
),
|
1176
|
+
dataset_path=get_dataset_path(),
|
1177
|
+
tag=JUNIFER_DATA_VERSION,
|
1236
1178
|
)
|
1237
|
-
parcellation_label_path =
|
1238
|
-
|
1239
|
-
file_path=dataset.pathobj
|
1240
|
-
/ "parcellations"
|
1241
|
-
/ "Yan2023"
|
1242
|
-
/ "Yeo2011"
|
1179
|
+
parcellation_label_path = get(
|
1180
|
+
file_path=path_prefix
|
1243
1181
|
/ f"{n_rois}Parcels_Yeo2011_{yeo_networks}Networks_LUT.txt",
|
1182
|
+
dataset_path=get_dataset_path(),
|
1183
|
+
tag=JUNIFER_DATA_VERSION,
|
1244
1184
|
)
|
1245
1185
|
elif kong_networks:
|
1246
1186
|
# Check kong_networks value
|
@@ -1251,24 +1191,21 @@ def _retrieve_yan(
|
|
1251
1191
|
f"one of the following: {_valid_kong_networks}"
|
1252
1192
|
)
|
1253
1193
|
|
1254
|
-
|
1255
|
-
|
1256
|
-
file_path=
|
1257
|
-
/ "parcellations"
|
1258
|
-
/ "Yan2023"
|
1259
|
-
/ "Kong2022"
|
1194
|
+
path_prefix = pre_path_prefix / "Kong2022"
|
1195
|
+
parcellation_img_path = get(
|
1196
|
+
file_path=path_prefix
|
1260
1197
|
/ (
|
1261
1198
|
f"{n_rois}Parcels_Kong2022_{kong_networks}Networks_FSLMNI152_"
|
1262
1199
|
f"{resolution}mm.nii.gz"
|
1263
1200
|
),
|
1201
|
+
dataset_path=get_dataset_path(),
|
1202
|
+
tag=JUNIFER_DATA_VERSION,
|
1264
1203
|
)
|
1265
|
-
parcellation_label_path =
|
1266
|
-
|
1267
|
-
file_path=dataset.pathobj
|
1268
|
-
/ "parcellations"
|
1269
|
-
/ "Yan2023"
|
1270
|
-
/ "Kong2022"
|
1204
|
+
parcellation_label_path = get(
|
1205
|
+
file_path=path_prefix
|
1271
1206
|
/ f"{n_rois}Parcels_Kong2022_{kong_networks}Networks_LUT.txt",
|
1207
|
+
dataset_path=get_dataset_path(),
|
1208
|
+
tag=JUNIFER_DATA_VERSION,
|
1272
1209
|
)
|
1273
1210
|
|
1274
1211
|
# Load label file
|
@@ -1280,7 +1217,6 @@ def _retrieve_yan(
|
|
1280
1217
|
|
1281
1218
|
|
1282
1219
|
def _retrieve_brainnetome(
|
1283
|
-
dataset: "Dataset",
|
1284
1220
|
resolution: Optional[float] = None,
|
1285
1221
|
threshold: Optional[int] = None,
|
1286
1222
|
) -> tuple[Path, list[str]]:
|
@@ -1288,8 +1224,6 @@ def _retrieve_brainnetome(
|
|
1288
1224
|
|
1289
1225
|
Parameters
|
1290
1226
|
----------
|
1291
|
-
dataset : datalad.api.Dataset
|
1292
|
-
The datalad dataset to fetch parcellation from.
|
1293
1227
|
resolution : {1.0, 1.25, 2.0}, optional
|
1294
1228
|
The desired resolution of the parcellation to load. If it is not
|
1295
1229
|
available, the closest resolution will be loaded. Preferably, use a
|
@@ -1332,12 +1266,13 @@ def _retrieve_brainnetome(
|
|
1332
1266
|
resolution = int(resolution)
|
1333
1267
|
|
1334
1268
|
# Fetch file path
|
1335
|
-
parcellation_img_path =
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1269
|
+
parcellation_img_path = get(
|
1270
|
+
file_path=Path(
|
1271
|
+
"parcellations/Brainnetome/"
|
1272
|
+
f"BNA-maxprob-thr{threshold}-{resolution}mm.nii.gz"
|
1273
|
+
),
|
1274
|
+
dataset_path=get_dataset_path(),
|
1275
|
+
tag=JUNIFER_DATA_VERSION,
|
1341
1276
|
)
|
1342
1277
|
|
1343
1278
|
# Load labels
|
@@ -24,7 +24,6 @@ from junifer.data.parcellations._parcellations import (
|
|
24
24
|
_retrieve_tian,
|
25
25
|
_retrieve_yan,
|
26
26
|
)
|
27
|
-
from junifer.data.utils import check_dataset
|
28
27
|
from junifer.datareader import DefaultDataReader
|
29
28
|
from junifer.pipeline.utils import _check_ants
|
30
29
|
from junifer.testing.datagrabbers import (
|
@@ -335,7 +334,6 @@ def test_retrieve_schaefer_incorrect_n_rois() -> None:
|
|
335
334
|
"""Test retrieve Schaefer with incorrect ROIs."""
|
336
335
|
with pytest.raises(ValueError, match=r"The parameter `n_rois`"):
|
337
336
|
_retrieve_schaefer(
|
338
|
-
dataset=check_dataset(),
|
339
337
|
resolution=1,
|
340
338
|
n_rois=101,
|
341
339
|
yeo_networks=7,
|
@@ -346,7 +344,6 @@ def test_retrieve_schaefer_incorrect_yeo_networks() -> None:
|
|
346
344
|
"""Test retrieve Schaefer with incorrect Yeo networks."""
|
347
345
|
with pytest.raises(ValueError, match=r"The parameter `yeo_networks`"):
|
348
346
|
_retrieve_schaefer(
|
349
|
-
dataset=check_dataset(),
|
350
347
|
resolution=1,
|
351
348
|
n_rois=100,
|
352
349
|
yeo_networks=8,
|
@@ -384,7 +381,7 @@ def test_suit(space_key: str, space: str) -> None:
|
|
384
381
|
def test_retrieve_suit_incorrect_space() -> None:
|
385
382
|
"""Test retrieve SUIT with incorrect space."""
|
386
383
|
with pytest.raises(ValueError, match=r"The parameter `space`"):
|
387
|
-
_retrieve_suit(
|
384
|
+
_retrieve_suit(resolution=1.0, space="wrong")
|
388
385
|
|
389
386
|
|
390
387
|
@pytest.mark.parametrize(
|
@@ -512,13 +509,10 @@ def test_tian_7T_6thgeneration(scale: int, n_label: int) -> None:
|
|
512
509
|
def test_retrieve_tian_incorrect_space() -> None:
|
513
510
|
"""Test retrieve tian with incorrect space."""
|
514
511
|
with pytest.raises(ValueError, match=r"The parameter `space`"):
|
515
|
-
_retrieve_tian(
|
516
|
-
dataset=check_dataset(), resolution=1, scale=1, space="wrong"
|
517
|
-
)
|
512
|
+
_retrieve_tian(resolution=1, scale=1, space="wrong")
|
518
513
|
|
519
514
|
with pytest.raises(ValueError, match=r"MNI152NLin6Asym"):
|
520
515
|
_retrieve_tian(
|
521
|
-
dataset=check_dataset(),
|
522
516
|
resolution=1,
|
523
517
|
scale=1,
|
524
518
|
magneticfield="7T",
|
@@ -530,7 +524,6 @@ def test_retrieve_tian_incorrect_magneticfield() -> None:
|
|
530
524
|
"""Test retrieve tian with incorrect magneticfield."""
|
531
525
|
with pytest.raises(ValueError, match=r"The parameter `magneticfield`"):
|
532
526
|
_retrieve_tian(
|
533
|
-
dataset=check_dataset(),
|
534
527
|
resolution=1,
|
535
528
|
scale=1,
|
536
529
|
magneticfield="wrong",
|
@@ -541,7 +534,6 @@ def test_retrieve_tian_incorrect_scale(tmp_path: Path) -> None:
|
|
541
534
|
"""Test retrieve tian with incorrect scale."""
|
542
535
|
with pytest.raises(ValueError, match=r"The parameter `scale`"):
|
543
536
|
_retrieve_tian(
|
544
|
-
dataset=check_dataset(),
|
545
537
|
resolution=1,
|
546
538
|
scale=5,
|
547
539
|
space="MNI152NLin6Asym",
|
@@ -577,7 +569,6 @@ def test_retrieve_aicha_incorrect_version() -> None:
|
|
577
569
|
"""Test retrieve AICHA with incorrect version."""
|
578
570
|
with pytest.raises(ValueError, match="The parameter `version`"):
|
579
571
|
_retrieve_aicha(
|
580
|
-
dataset=check_dataset(),
|
581
572
|
version=100,
|
582
573
|
)
|
583
574
|
|
@@ -639,7 +630,6 @@ def test_retrieve_shen_incorrect_year() -> None:
|
|
639
630
|
"""Test retrieve Shen with incorrect year."""
|
640
631
|
with pytest.raises(ValueError, match="The parameter `year`"):
|
641
632
|
_retrieve_shen(
|
642
|
-
dataset=check_dataset(),
|
643
633
|
year=1969,
|
644
634
|
)
|
645
635
|
|
@@ -648,7 +638,6 @@ def test_retrieve_shen_incorrect_n_rois() -> None:
|
|
648
638
|
"""Test retrieve Shen with incorrect ROIs."""
|
649
639
|
with pytest.raises(ValueError, match="The parameter `n_rois`"):
|
650
640
|
_retrieve_shen(
|
651
|
-
dataset=check_dataset(),
|
652
641
|
year=2015,
|
653
642
|
n_rois=10,
|
654
643
|
)
|
@@ -691,7 +680,6 @@ def test_retrieve_shen_incorrect_param_combo(
|
|
691
680
|
"""
|
692
681
|
with pytest.raises(ValueError, match="The parameter combination"):
|
693
682
|
_retrieve_shen(
|
694
|
-
dataset=check_dataset(),
|
695
683
|
resolution=resolution,
|
696
684
|
year=year,
|
697
685
|
n_rois=n_rois,
|
@@ -819,7 +807,6 @@ def test_retrieve_yan_incorrect_networks() -> None:
|
|
819
807
|
ValueError, match="Either one of `yeo_networks` or `kong_networks`"
|
820
808
|
):
|
821
809
|
_retrieve_yan(
|
822
|
-
dataset=check_dataset(),
|
823
810
|
n_rois=31418,
|
824
811
|
yeo_networks=100,
|
825
812
|
kong_networks=100,
|
@@ -829,7 +816,6 @@ def test_retrieve_yan_incorrect_networks() -> None:
|
|
829
816
|
ValueError, match="Either one of `yeo_networks` or `kong_networks`"
|
830
817
|
):
|
831
818
|
_retrieve_yan(
|
832
|
-
dataset=check_dataset(),
|
833
819
|
n_rois=31418,
|
834
820
|
yeo_networks=None,
|
835
821
|
kong_networks=None,
|
@@ -840,7 +826,6 @@ def test_retrieve_yan_incorrect_n_rois() -> None:
|
|
840
826
|
"""Test retrieve Yan with incorrect ROIs."""
|
841
827
|
with pytest.raises(ValueError, match="The parameter `n_rois`"):
|
842
828
|
_retrieve_yan(
|
843
|
-
dataset=check_dataset(),
|
844
829
|
n_rois=31418,
|
845
830
|
yeo_networks=7,
|
846
831
|
)
|
@@ -850,7 +835,6 @@ def test_retrieve_yan_incorrect_yeo_networks() -> None:
|
|
850
835
|
"""Test retrieve Yan with incorrect Yeo networks."""
|
851
836
|
with pytest.raises(ValueError, match="The parameter `yeo_networks`"):
|
852
837
|
_retrieve_yan(
|
853
|
-
dataset=check_dataset(),
|
854
838
|
n_rois=100,
|
855
839
|
yeo_networks=27,
|
856
840
|
)
|
@@ -860,7 +844,6 @@ def test_retrieve_yan_incorrect_kong_networks() -> None:
|
|
860
844
|
"""Test retrieve Yan with incorrect Kong networks."""
|
861
845
|
with pytest.raises(ValueError, match="The parameter `kong_networks`"):
|
862
846
|
_retrieve_yan(
|
863
|
-
dataset=check_dataset(),
|
864
847
|
n_rois=100,
|
865
848
|
kong_networks=27,
|
866
849
|
)
|
@@ -922,7 +905,6 @@ def test_retrieve_brainnetome_incorrect_threshold() -> None:
|
|
922
905
|
"""Test retrieve Brainnetome with incorrect threshold."""
|
923
906
|
with pytest.raises(ValueError, match="The parameter `threshold`"):
|
924
907
|
_retrieve_brainnetome(
|
925
|
-
dataset=check_dataset(),
|
926
908
|
threshold=100,
|
927
909
|
)
|
928
910
|
|
junifer/data/template_spaces.py
CHANGED
@@ -8,10 +8,11 @@ from typing import Any, Optional, Union
|
|
8
8
|
|
9
9
|
import nibabel as nib
|
10
10
|
import numpy as np
|
11
|
+
from junifer_data import get
|
11
12
|
from templateflow import api as tflow
|
12
13
|
|
13
14
|
from ..utils import logger, raise_error
|
14
|
-
from .utils import
|
15
|
+
from .utils import JUNIFER_DATA_VERSION, closest_resolution, get_dataset_path
|
15
16
|
|
16
17
|
|
17
18
|
__all__ = ["get_template", "get_xfm"]
|
@@ -33,17 +34,14 @@ def get_xfm(src: str, dst: str) -> Path: # pragma: no cover
|
|
33
34
|
The path to the transformation file.
|
34
35
|
|
35
36
|
"""
|
36
|
-
# Get dataset
|
37
|
-
dataset = check_dataset()
|
38
37
|
# Set file path to retrieve
|
39
|
-
xfm_file_path = (
|
40
|
-
dataset.pathobj
|
41
|
-
/ "xfms"
|
42
|
-
/ f"{src}_to_{dst}"
|
43
|
-
/ f"{src}_to_{dst}_Composite.h5"
|
44
|
-
)
|
38
|
+
xfm_file_path = Path(f"xfms/{src}_to_{dst}/{src}_to_{dst}_Composite.h5")
|
45
39
|
# Retrieve file
|
46
|
-
return
|
40
|
+
return get(
|
41
|
+
file_path=xfm_file_path,
|
42
|
+
dataset_path=get_dataset_path(),
|
43
|
+
tag=JUNIFER_DATA_VERSION,
|
44
|
+
)
|
47
45
|
|
48
46
|
|
49
47
|
def get_template(
|
junifer/data/utils.py
CHANGED
@@ -8,21 +8,23 @@ from collections.abc import MutableMapping
|
|
8
8
|
from pathlib import Path
|
9
9
|
from typing import Optional, Union
|
10
10
|
|
11
|
-
import datalad.api as dl
|
12
11
|
import numpy as np
|
13
|
-
from datalad.support.exceptions import IncompleteResultsError
|
14
12
|
|
15
13
|
from ..utils import config, logger, raise_error
|
16
14
|
|
17
15
|
|
18
16
|
__all__ = [
|
19
|
-
"
|
17
|
+
"JUNIFER_DATA_VERSION",
|
20
18
|
"closest_resolution",
|
21
|
-
"
|
19
|
+
"get_dataset_path",
|
22
20
|
"get_native_warper",
|
23
21
|
]
|
24
22
|
|
25
23
|
|
24
|
+
# junifer-data version constant
|
25
|
+
JUNIFER_DATA_VERSION = "1"
|
26
|
+
|
27
|
+
|
26
28
|
def closest_resolution(
|
27
29
|
resolution: Optional[Union[float, int]],
|
28
30
|
valid_resolution: Union[list[float], list[int], np.ndarray],
|
@@ -124,94 +126,17 @@ def get_native_warper(
|
|
124
126
|
return possible_warpers[0]
|
125
127
|
|
126
128
|
|
127
|
-
def
|
128
|
-
"""Get
|
129
|
+
def get_dataset_path() -> Optional[Path]:
|
130
|
+
"""Get junifer-data dataset path.
|
129
131
|
|
130
132
|
Returns
|
131
133
|
-------
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
Raises
|
136
|
-
------
|
137
|
-
RuntimeError
|
138
|
-
If there is a problem cloning the dataset.
|
134
|
+
pathlib.Path or None
|
135
|
+
Path to the dataset or None.
|
139
136
|
|
140
137
|
"""
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
data_dir = Path().home() / "junifer_data"
|
147
|
-
|
148
|
-
# Check if the dataset is installed at storage path;
|
149
|
-
# else clone a fresh copy
|
150
|
-
if dl.Dataset(data_dir).is_installed():
|
151
|
-
logger.debug(f"Found existing junifer-data at: {data_dir.resolve()}")
|
152
|
-
return dl.Dataset(data_dir)
|
153
|
-
else:
|
154
|
-
logger.debug(f"Cloning junifer-data to: {data_dir.resolve()}")
|
155
|
-
# Clone dataset
|
156
|
-
try:
|
157
|
-
dataset = dl.clone(
|
158
|
-
"https://github.com/juaml/junifer-data.git",
|
159
|
-
path=data_dir,
|
160
|
-
result_renderer="disabled",
|
161
|
-
)
|
162
|
-
except IncompleteResultsError as e:
|
163
|
-
raise_error(
|
164
|
-
msg=f"Failed to clone junifer-data: {e.failed}",
|
165
|
-
klass=RuntimeError,
|
166
|
-
)
|
167
|
-
else:
|
168
|
-
logger.debug(
|
169
|
-
f"Successfully cloned junifer-data to: "
|
170
|
-
f"{data_dir.resolve()}"
|
171
|
-
)
|
172
|
-
return dataset
|
173
|
-
|
174
|
-
|
175
|
-
def fetch_file_via_datalad(dataset: dl.Dataset, file_path: Path) -> Path:
|
176
|
-
"""Fetch `file_path` from `dataset` via datalad.
|
177
|
-
|
178
|
-
Parameters
|
179
|
-
----------
|
180
|
-
dataset : datalad.api.Dataset
|
181
|
-
The datalad dataset to fetch files from.
|
182
|
-
file_path : pathlib.Path
|
183
|
-
The file path to fetch.
|
184
|
-
|
185
|
-
Returns
|
186
|
-
-------
|
187
|
-
pathlib.Path
|
188
|
-
Resolved fetched file path.
|
189
|
-
|
190
|
-
Raises
|
191
|
-
------
|
192
|
-
RuntimeError
|
193
|
-
If there is a problem fetching the file.
|
194
|
-
|
195
|
-
"""
|
196
|
-
try:
|
197
|
-
got = dataset.get(file_path, result_renderer="disabled")
|
198
|
-
except IncompleteResultsError as e:
|
199
|
-
raise_error(
|
200
|
-
msg=f"Failed to get file from dataset: {e.failed}",
|
201
|
-
klass=RuntimeError,
|
202
|
-
)
|
203
|
-
else:
|
204
|
-
got_path = Path(got[0]["path"])
|
205
|
-
# Conditional logging based on file fetch
|
206
|
-
status = got[0]["status"]
|
207
|
-
if status == "ok":
|
208
|
-
logger.info(f"Successfully fetched file: {got_path.resolve()}")
|
209
|
-
return got_path
|
210
|
-
elif status == "notneeded":
|
211
|
-
logger.debug(f"Found existing file: {got_path.resolve()}")
|
212
|
-
return got_path
|
213
|
-
else:
|
214
|
-
raise_error(
|
215
|
-
msg=f"Failed to fetch file: {got_path.resolve()}",
|
216
|
-
klass=RuntimeError,
|
217
|
-
)
|
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.
|
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>
|
@@ -44,6 +44,7 @@ Requires-Dist: lapy<2.0.0,>=1.0.0
|
|
44
44
|
Requires-Dist: lazy_loader==0.4
|
45
45
|
Requires-Dist: importlib_metadata; python_version < "3.9"
|
46
46
|
Requires-Dist: looseversion==1.3.0; python_version >= "3.12"
|
47
|
+
Requires-Dist: junifer_data==1.1.0
|
47
48
|
Provides-Extra: all
|
48
49
|
Requires-Dist: bctpy==0.6.0; extra == "all"
|
49
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=
|
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=
|
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=
|
79
|
-
junifer/data/utils.py,sha256=
|
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=
|
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
|
@@ -106,8 +106,8 @@ junifer/data/masks/__init__.py,sha256=eEEhHglyVEx1LrqwXjq3cOmjf4sTsgBstRx5-k7zIQ
|
|
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=
|
110
|
-
junifer/data/masks/tests/test_masks.py,sha256=
|
109
|
+
junifer/data/masks/_masks.py,sha256=NA2Px_PUv0DDtFpLpYjJxSGo2ozTk-6bSNd16Cou1VA,28671
|
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
|
113
113
|
junifer/data/masks/vickery-patil/CAT12_IXI555_MNI152_TMP_GS_GMprob0.2_clean_3mm.nii.gz,sha256=crb_y7YO1vjjf2PwbRJUm8KamPK6fx1y0B_l-E3g8FY,12862
|
@@ -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=
|
120
|
-
junifer/data/parcellations/tests/test_parcellations.py,sha256=
|
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=
|
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.
|
345
|
-
junifer-0.0.6.
|
346
|
-
junifer-0.0.6.
|
347
|
-
junifer-0.0.6.
|
348
|
-
junifer-0.0.6.
|
349
|
-
junifer-0.0.6.
|
350
|
-
junifer-0.0.6.
|
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,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|