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 +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/external/nilearn/tests/test_junifer_connectivity_measure.py +1 -1
- junifer/preprocess/confounds/fmriprep_confound_remover.py +185 -44
- junifer/preprocess/confounds/tests/test_fmriprep_confound_remover.py +90 -2
- junifer/typing/_typing.py +1 -1
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev474.dist-info}/METADATA +2 -1
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev474.dist-info}/RECORD +20 -20
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev474.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev474.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev474.dist-info}/WHEEL +0 -0
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev474.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.6.dev445.dist-info → junifer-0.0.6.dev474.dist-info}/top_level.txt +0 -0
@@ -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
|
|