junifer 0.0.6.dev418__py3-none-any.whl → 0.0.6.dev445__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 +0 -2
- junifer/data/coordinates/_coordinates.py +128 -105
- junifer/data/coordinates/tests/test_coordinates.py +1 -2
- junifer/data/masks/_masks.py +81 -59
- junifer/data/masks/tests/test_masks.py +5 -2
- junifer/data/parcellations/_parcellations.py +297 -678
- junifer/data/parcellations/tests/test_parcellations.py +82 -211
- junifer/data/template_spaces.py +15 -87
- junifer/data/utils.py +103 -2
- {junifer-0.0.6.dev418.dist-info → junifer-0.0.6.dev445.dist-info}/METADATA +1 -2
- {junifer-0.0.6.dev418.dist-info → junifer-0.0.6.dev445.dist-info}/RECORD +17 -17
- {junifer-0.0.6.dev418.dist-info → junifer-0.0.6.dev445.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.6.dev418.dist-info → junifer-0.0.6.dev445.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.6.dev418.dist-info → junifer-0.0.6.dev445.dist-info}/WHEEL +0 -0
- {junifer-0.0.6.dev418.dist-info → junifer-0.0.6.dev445.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.6.dev418.dist-info → junifer-0.0.6.dev445.dist-info}/top_level.txt +0 -0
@@ -18,13 +18,13 @@ from junifer.data.parcellations import merge_parcellations
|
|
18
18
|
from junifer.data.parcellations._parcellations import (
|
19
19
|
_retrieve_aicha,
|
20
20
|
_retrieve_brainnetome,
|
21
|
-
_retrieve_parcellation,
|
22
21
|
_retrieve_schaefer,
|
23
22
|
_retrieve_shen,
|
24
23
|
_retrieve_suit,
|
25
24
|
_retrieve_tian,
|
26
25
|
_retrieve_yan,
|
27
26
|
)
|
27
|
+
from junifer.data.utils import check_dataset
|
28
28
|
from junifer.datareader import DefaultDataReader
|
29
29
|
from junifer.pipeline.utils import _check_ants
|
30
30
|
from junifer.testing.datagrabbers import (
|
@@ -247,12 +247,6 @@ def test_load_incorrect() -> None:
|
|
247
247
|
ParcellationRegistry().load("wrongparcellation", "MNI152NLin6Asym")
|
248
248
|
|
249
249
|
|
250
|
-
def test_retrieve_parcellation_incorrect() -> None:
|
251
|
-
"""Test retrieval of invalid parcellations."""
|
252
|
-
with pytest.raises(ValueError, match=r"provided parcellation name"):
|
253
|
-
_retrieve_parcellation("wrongparcellation")
|
254
|
-
|
255
|
-
|
256
250
|
@pytest.mark.parametrize(
|
257
251
|
"resolution, n_rois, yeo_networks",
|
258
252
|
[
|
@@ -299,7 +293,6 @@ def test_retrieve_parcellation_incorrect() -> None:
|
|
299
293
|
],
|
300
294
|
)
|
301
295
|
def test_schaefer(
|
302
|
-
tmp_path: Path,
|
303
296
|
resolution: float,
|
304
297
|
n_rois: int,
|
305
298
|
yeo_networks: int,
|
@@ -308,8 +301,6 @@ def test_schaefer(
|
|
308
301
|
|
309
302
|
Parameters
|
310
303
|
----------
|
311
|
-
tmp_path : pathlib.Path
|
312
|
-
The path to the test directory.
|
313
304
|
resolution : float
|
314
305
|
The parametrized resolution values.
|
315
306
|
n_rois : int
|
@@ -329,7 +320,6 @@ def test_schaefer(
|
|
329
320
|
img, label, img_path, space = ParcellationRegistry().load(
|
330
321
|
name=parcellation_name,
|
331
322
|
target_space="MNI152NLin6Asym",
|
332
|
-
parcellations_dir=tmp_path,
|
333
323
|
resolution=resolution,
|
334
324
|
)
|
335
325
|
assert img is not None
|
@@ -341,36 +331,22 @@ def test_schaefer(
|
|
341
331
|
)
|
342
332
|
|
343
333
|
|
344
|
-
def test_retrieve_schaefer_incorrect_n_rois(
|
345
|
-
"""Test retrieve Schaefer with incorrect ROIs.
|
346
|
-
|
347
|
-
Parameters
|
348
|
-
----------
|
349
|
-
tmp_path : pathlib.Path
|
350
|
-
The path to the test directory.
|
351
|
-
|
352
|
-
"""
|
334
|
+
def test_retrieve_schaefer_incorrect_n_rois() -> None:
|
335
|
+
"""Test retrieve Schaefer with incorrect ROIs."""
|
353
336
|
with pytest.raises(ValueError, match=r"The parameter `n_rois`"):
|
354
337
|
_retrieve_schaefer(
|
355
|
-
|
338
|
+
dataset=check_dataset(),
|
356
339
|
resolution=1,
|
357
340
|
n_rois=101,
|
358
341
|
yeo_networks=7,
|
359
342
|
)
|
360
343
|
|
361
344
|
|
362
|
-
def test_retrieve_schaefer_incorrect_yeo_networks(
|
363
|
-
"""Test retrieve Schaefer with incorrect Yeo networks.
|
364
|
-
|
365
|
-
Parameters
|
366
|
-
----------
|
367
|
-
tmp_path : pathlib.Path
|
368
|
-
The path to the test directory.
|
369
|
-
|
370
|
-
"""
|
345
|
+
def test_retrieve_schaefer_incorrect_yeo_networks() -> None:
|
346
|
+
"""Test retrieve Schaefer with incorrect Yeo networks."""
|
371
347
|
with pytest.raises(ValueError, match=r"The parameter `yeo_networks`"):
|
372
348
|
_retrieve_schaefer(
|
373
|
-
|
349
|
+
dataset=check_dataset(),
|
374
350
|
resolution=1,
|
375
351
|
n_rois=100,
|
376
352
|
yeo_networks=8,
|
@@ -381,13 +357,11 @@ def test_retrieve_schaefer_incorrect_yeo_networks(tmp_path: Path) -> None:
|
|
381
357
|
"space_key, space",
|
382
358
|
[("SUIT", "SUIT"), ("MNI", "MNI152NLin6Asym")],
|
383
359
|
)
|
384
|
-
def test_suit(
|
360
|
+
def test_suit(space_key: str, space: str) -> None:
|
385
361
|
"""Test SUIT parcellation.
|
386
362
|
|
387
363
|
Parameters
|
388
364
|
----------
|
389
|
-
tmp_path : pathlib.Path
|
390
|
-
The path to the test directory.
|
391
365
|
space_key : str
|
392
366
|
The parametrized space values for the key.
|
393
367
|
space : str
|
@@ -399,7 +373,6 @@ def test_suit(tmp_path: Path, space_key: str, space: str) -> None:
|
|
399
373
|
img, label, img_path, parcellation_space = ParcellationRegistry().load(
|
400
374
|
name=f"SUITx{space_key}",
|
401
375
|
target_space=space,
|
402
|
-
parcellations_dir=tmp_path,
|
403
376
|
)
|
404
377
|
assert img is not None
|
405
378
|
assert img_path.name == f"SUIT_{space_key}Space_1mm.nii"
|
@@ -408,33 +381,20 @@ def test_suit(tmp_path: Path, space_key: str, space: str) -> None:
|
|
408
381
|
assert_array_equal(img.header["pixdim"][1:4], [1, 1, 1]) # type: ignore
|
409
382
|
|
410
383
|
|
411
|
-
def test_retrieve_suit_incorrect_space(
|
412
|
-
"""Test retrieve SUIT with incorrect space.
|
413
|
-
|
414
|
-
Parameters
|
415
|
-
----------
|
416
|
-
tmp_path : pathlib.Path
|
417
|
-
The path to the test directory.
|
418
|
-
|
419
|
-
"""
|
384
|
+
def test_retrieve_suit_incorrect_space() -> None:
|
385
|
+
"""Test retrieve SUIT with incorrect space."""
|
420
386
|
with pytest.raises(ValueError, match=r"The parameter `space`"):
|
421
|
-
_retrieve_suit(
|
422
|
-
parcellations_dir=tmp_path, resolution=1.0, space="wrong"
|
423
|
-
)
|
387
|
+
_retrieve_suit(dataset=check_dataset(), resolution=1.0, space="wrong")
|
424
388
|
|
425
389
|
|
426
390
|
@pytest.mark.parametrize(
|
427
391
|
"scale, n_label", [(1, 16), (2, 32), (3, 50), (4, 54)]
|
428
392
|
)
|
429
|
-
def test_tian_3T_6thgeneration(
|
430
|
-
tmp_path: Path, scale: int, n_label: int
|
431
|
-
) -> None:
|
393
|
+
def test_tian_3T_6thgeneration(scale: int, n_label: int) -> None:
|
432
394
|
"""Test Tian parcellation.
|
433
395
|
|
434
396
|
Parameters
|
435
397
|
----------
|
436
|
-
tmp_path : pathlib.Path
|
437
|
-
The path to the test directory.
|
438
398
|
scale : int
|
439
399
|
The parametrized scale values.
|
440
400
|
n_label : int
|
@@ -447,44 +407,38 @@ def test_tian_3T_6thgeneration(
|
|
447
407
|
assert "TianxS3x3TxMNI6thgeneration" in parcellations
|
448
408
|
assert "TianxS4x3TxMNI6thgeneration" in parcellations
|
449
409
|
# Load parcellation
|
450
|
-
img, lbl, fname,
|
410
|
+
img, lbl, fname, space = ParcellationRegistry().load(
|
451
411
|
name=f"TianxS{scale}x3TxMNI6thgeneration",
|
452
|
-
|
453
|
-
target_space="MNI152NLin2009cAsym",
|
412
|
+
target_space="MNI152NLin2009cAsym", # force highest resolution
|
454
413
|
)
|
455
|
-
|
414
|
+
expected_fname = f"Tian_Subcortex_S{scale}_3T_1mm.nii.gz"
|
456
415
|
assert img is not None
|
457
|
-
assert fname.name ==
|
458
|
-
assert
|
416
|
+
assert fname.name == expected_fname
|
417
|
+
assert space == "MNI152NLin6Asym"
|
459
418
|
assert len(lbl) == n_label
|
460
|
-
assert_array_equal(img.header["pixdim"][1:4], [1, 1, 1])
|
419
|
+
assert_array_equal(img.header["pixdim"][1:4], [1, 1, 1])
|
461
420
|
# Load parcellation
|
462
|
-
img, lbl, fname,
|
421
|
+
img, lbl, fname, space = ParcellationRegistry().load(
|
463
422
|
name=f"TianxS{scale}x3TxMNI6thgeneration",
|
464
423
|
target_space="MNI152NLin6Asym",
|
465
|
-
parcellations_dir=tmp_path,
|
466
424
|
resolution=2,
|
467
425
|
)
|
468
|
-
|
426
|
+
expected_fname = f"Tian_Subcortex_S{scale}_3T.nii.gz"
|
469
427
|
assert img is not None
|
470
|
-
assert fname.name ==
|
471
|
-
assert
|
428
|
+
assert fname.name == expected_fname
|
429
|
+
assert space == "MNI152NLin6Asym"
|
472
430
|
assert len(lbl) == n_label
|
473
|
-
assert_array_equal(img.header["pixdim"][1:4], [2, 2, 2])
|
431
|
+
assert_array_equal(img.header["pixdim"][1:4], [2, 2, 2])
|
474
432
|
|
475
433
|
|
476
434
|
@pytest.mark.parametrize(
|
477
435
|
"scale, n_label", [(1, 16), (2, 32), (3, 50), (4, 54)]
|
478
436
|
)
|
479
|
-
def test_tian_3T_nonlinear2009cAsym(
|
480
|
-
tmp_path: Path, scale: int, n_label: int
|
481
|
-
) -> None:
|
437
|
+
def test_tian_3T_nonlinear2009cAsym(scale: int, n_label: int) -> None:
|
482
438
|
"""Test Tian parcellation.
|
483
439
|
|
484
440
|
Parameters
|
485
441
|
----------
|
486
|
-
tmp_path : pathlib.Path
|
487
|
-
The path to the test directory.
|
488
442
|
scale : int
|
489
443
|
The parametrized scale values.
|
490
444
|
n_label : int
|
@@ -497,31 +451,38 @@ def test_tian_3T_nonlinear2009cAsym(
|
|
497
451
|
assert "TianxS3x3TxMNInonlinear2009cAsym" in parcellations
|
498
452
|
assert "TianxS4x3TxMNInonlinear2009cAsym" in parcellations
|
499
453
|
# Load parcellation
|
454
|
+
img, lbl, fname, space = ParcellationRegistry().load(
|
455
|
+
name=f"TianxS{scale}x3TxMNInonlinear2009cAsym",
|
456
|
+
target_space="MNI152NLin6Asym", # force highest resolution
|
457
|
+
)
|
458
|
+
expected_fname = f"Tian_Subcortex_S{scale}_3T_2009cAsym_1mm.nii.gz"
|
459
|
+
assert img is not None
|
460
|
+
assert fname.name == expected_fname
|
461
|
+
assert space == "MNI152NLin2009cAsym"
|
462
|
+
assert len(lbl) == n_label
|
463
|
+
assert_array_equal(img.header["pixdim"][1:4], [1, 1, 1])
|
464
|
+
# Load parcellation
|
500
465
|
img, lbl, fname, space = ParcellationRegistry().load(
|
501
466
|
name=f"TianxS{scale}x3TxMNInonlinear2009cAsym",
|
502
467
|
target_space="MNI152NLin2009cAsym",
|
503
|
-
|
468
|
+
resolution=2,
|
504
469
|
)
|
505
|
-
|
470
|
+
expected_fname = f"Tian_Subcortex_S{scale}_3T_2009cAsym.nii.gz"
|
506
471
|
assert img is not None
|
507
|
-
assert fname.name ==
|
472
|
+
assert fname.name == expected_fname
|
508
473
|
assert space == "MNI152NLin2009cAsym"
|
509
474
|
assert len(lbl) == n_label
|
510
|
-
assert_array_equal(img.header["pixdim"][1:4], [2, 2, 2])
|
475
|
+
assert_array_equal(img.header["pixdim"][1:4], [2, 2, 2])
|
511
476
|
|
512
477
|
|
513
478
|
@pytest.mark.parametrize(
|
514
479
|
"scale, n_label", [(1, 16), (2, 34), (3, 54), (4, 62)]
|
515
480
|
)
|
516
|
-
def test_tian_7T_6thgeneration(
|
517
|
-
tmp_path: Path, scale: int, n_label: int
|
518
|
-
) -> None:
|
481
|
+
def test_tian_7T_6thgeneration(scale: int, n_label: int) -> None:
|
519
482
|
"""Test Tian parcellation.
|
520
483
|
|
521
484
|
Parameters
|
522
485
|
----------
|
523
|
-
tmp_path : pathlib.Path
|
524
|
-
The path to the test directory.
|
525
486
|
scale : int
|
526
487
|
The parametrized scale values.
|
527
488
|
n_label : int
|
@@ -537,7 +498,6 @@ def test_tian_7T_6thgeneration(
|
|
537
498
|
img, lbl, fname, space = ParcellationRegistry().load(
|
538
499
|
name=f"TianxS{scale}x7TxMNI6thgeneration",
|
539
500
|
target_space="MNI152NLin6Asym",
|
540
|
-
parcellations_dir=tmp_path,
|
541
501
|
)
|
542
502
|
fname1 = f"Tian_Subcortex_S{scale}_7T.nii.gz"
|
543
503
|
assert img is not None
|
@@ -549,23 +509,16 @@ def test_tian_7T_6thgeneration(
|
|
549
509
|
)
|
550
510
|
|
551
511
|
|
552
|
-
def test_retrieve_tian_incorrect_space(
|
553
|
-
"""Test retrieve tian with incorrect space.
|
554
|
-
|
555
|
-
Parameters
|
556
|
-
----------
|
557
|
-
tmp_path : pathlib.Path
|
558
|
-
The path to the test directory.
|
559
|
-
|
560
|
-
"""
|
512
|
+
def test_retrieve_tian_incorrect_space() -> None:
|
513
|
+
"""Test retrieve tian with incorrect space."""
|
561
514
|
with pytest.raises(ValueError, match=r"The parameter `space`"):
|
562
515
|
_retrieve_tian(
|
563
|
-
|
516
|
+
dataset=check_dataset(), resolution=1, scale=1, space="wrong"
|
564
517
|
)
|
565
518
|
|
566
519
|
with pytest.raises(ValueError, match=r"MNI152NLin6Asym"):
|
567
520
|
_retrieve_tian(
|
568
|
-
|
521
|
+
dataset=check_dataset(),
|
569
522
|
resolution=1,
|
570
523
|
scale=1,
|
571
524
|
magneticfield="7T",
|
@@ -573,18 +526,11 @@ def test_retrieve_tian_incorrect_space(tmp_path: Path) -> None:
|
|
573
526
|
)
|
574
527
|
|
575
528
|
|
576
|
-
def test_retrieve_tian_incorrect_magneticfield(
|
577
|
-
"""Test retrieve tian with incorrect magneticfield.
|
578
|
-
|
579
|
-
Parameters
|
580
|
-
----------
|
581
|
-
tmp_path : pathlib.Path
|
582
|
-
The path to the test directory.
|
583
|
-
|
584
|
-
"""
|
529
|
+
def test_retrieve_tian_incorrect_magneticfield() -> None:
|
530
|
+
"""Test retrieve tian with incorrect magneticfield."""
|
585
531
|
with pytest.raises(ValueError, match=r"The parameter `magneticfield`"):
|
586
532
|
_retrieve_tian(
|
587
|
-
|
533
|
+
dataset=check_dataset(),
|
588
534
|
resolution=1,
|
589
535
|
scale=1,
|
590
536
|
magneticfield="wrong",
|
@@ -592,17 +538,10 @@ def test_retrieve_tian_incorrect_magneticfield(tmp_path: Path) -> None:
|
|
592
538
|
|
593
539
|
|
594
540
|
def test_retrieve_tian_incorrect_scale(tmp_path: Path) -> None:
|
595
|
-
"""Test retrieve tian with incorrect scale.
|
596
|
-
|
597
|
-
Parameters
|
598
|
-
----------
|
599
|
-
tmp_path : pathlib.Path
|
600
|
-
The path to the test directory.
|
601
|
-
|
602
|
-
"""
|
541
|
+
"""Test retrieve tian with incorrect scale."""
|
603
542
|
with pytest.raises(ValueError, match=r"The parameter `scale`"):
|
604
543
|
_retrieve_tian(
|
605
|
-
|
544
|
+
dataset=check_dataset(),
|
606
545
|
resolution=1,
|
607
546
|
scale=5,
|
608
547
|
space="MNI152NLin6Asym",
|
@@ -610,7 +549,7 @@ def test_retrieve_tian_incorrect_scale(tmp_path: Path) -> None:
|
|
610
549
|
|
611
550
|
|
612
551
|
@pytest.mark.parametrize("version", [1, 2])
|
613
|
-
def test_aicha(
|
552
|
+
def test_aicha(version: int) -> None:
|
614
553
|
"""Test AICHA parcellation.
|
615
554
|
|
616
555
|
Parameters
|
@@ -626,7 +565,6 @@ def test_aicha(tmp_path: Path, version: int) -> None:
|
|
626
565
|
img, label, img_path, space = ParcellationRegistry().load(
|
627
566
|
name=f"AICHA_v{version}",
|
628
567
|
target_space="IXI549Space",
|
629
|
-
parcellations_dir=tmp_path,
|
630
568
|
)
|
631
569
|
assert img is not None
|
632
570
|
assert img_path.name == "AICHA.nii"
|
@@ -635,18 +573,11 @@ def test_aicha(tmp_path: Path, version: int) -> None:
|
|
635
573
|
assert_array_equal(img.header["pixdim"][1:4], [2, 2, 2]) # type: ignore
|
636
574
|
|
637
575
|
|
638
|
-
def test_retrieve_aicha_incorrect_version(
|
639
|
-
"""Test retrieve AICHA with incorrect version.
|
640
|
-
|
641
|
-
Parameters
|
642
|
-
----------
|
643
|
-
tmp_path : pathlib.Path
|
644
|
-
The path to the test directory.
|
645
|
-
|
646
|
-
"""
|
576
|
+
def test_retrieve_aicha_incorrect_version() -> None:
|
577
|
+
"""Test retrieve AICHA with incorrect version."""
|
647
578
|
with pytest.raises(ValueError, match="The parameter `version`"):
|
648
579
|
_retrieve_aicha(
|
649
|
-
|
580
|
+
dataset=check_dataset(),
|
650
581
|
version=100,
|
651
582
|
)
|
652
583
|
|
@@ -666,7 +597,6 @@ def test_retrieve_aicha_incorrect_version(tmp_path: Path) -> None:
|
|
666
597
|
],
|
667
598
|
)
|
668
599
|
def test_shen(
|
669
|
-
tmp_path: Path,
|
670
600
|
resolution: float,
|
671
601
|
year: int,
|
672
602
|
n_rois: int,
|
@@ -677,8 +607,6 @@ def test_shen(
|
|
677
607
|
|
678
608
|
Parameters
|
679
609
|
----------
|
680
|
-
tmp_path : pathlib.Path
|
681
|
-
The path to the test directory.
|
682
610
|
resolution : float
|
683
611
|
The parametrized resolution values.
|
684
612
|
year : int
|
@@ -696,7 +624,6 @@ def test_shen(
|
|
696
624
|
img, label, img_path, space = ParcellationRegistry().load(
|
697
625
|
name=f"Shen_{year}_{n_rois}",
|
698
626
|
target_space="MNI152NLin2009cAsym",
|
699
|
-
parcellations_dir=tmp_path,
|
700
627
|
resolution=resolution,
|
701
628
|
)
|
702
629
|
assert img is not None
|
@@ -708,34 +635,20 @@ def test_shen(
|
|
708
635
|
)
|
709
636
|
|
710
637
|
|
711
|
-
def test_retrieve_shen_incorrect_year(
|
712
|
-
"""Test retrieve Shen with incorrect year.
|
713
|
-
|
714
|
-
Parameters
|
715
|
-
----------
|
716
|
-
tmp_path : pathlib.Path
|
717
|
-
The path to the test directory.
|
718
|
-
|
719
|
-
"""
|
638
|
+
def test_retrieve_shen_incorrect_year() -> None:
|
639
|
+
"""Test retrieve Shen with incorrect year."""
|
720
640
|
with pytest.raises(ValueError, match="The parameter `year`"):
|
721
641
|
_retrieve_shen(
|
722
|
-
|
642
|
+
dataset=check_dataset(),
|
723
643
|
year=1969,
|
724
644
|
)
|
725
645
|
|
726
646
|
|
727
|
-
def test_retrieve_shen_incorrect_n_rois(
|
728
|
-
"""Test retrieve Shen with incorrect ROIs.
|
729
|
-
|
730
|
-
Parameters
|
731
|
-
----------
|
732
|
-
tmp_path : pathlib.Path
|
733
|
-
The path to the test directory.
|
734
|
-
|
735
|
-
"""
|
647
|
+
def test_retrieve_shen_incorrect_n_rois() -> None:
|
648
|
+
"""Test retrieve Shen with incorrect ROIs."""
|
736
649
|
with pytest.raises(ValueError, match="The parameter `n_rois`"):
|
737
650
|
_retrieve_shen(
|
738
|
-
|
651
|
+
dataset=check_dataset(),
|
739
652
|
year=2015,
|
740
653
|
n_rois=10,
|
741
654
|
)
|
@@ -758,7 +671,6 @@ def test_retrieve_shen_incorrect_n_rois(tmp_path: Path) -> None:
|
|
758
671
|
],
|
759
672
|
)
|
760
673
|
def test_retrieve_shen_incorrect_param_combo(
|
761
|
-
tmp_path: Path,
|
762
674
|
resolution: float,
|
763
675
|
year: int,
|
764
676
|
n_rois: int,
|
@@ -779,7 +691,7 @@ def test_retrieve_shen_incorrect_param_combo(
|
|
779
691
|
"""
|
780
692
|
with pytest.raises(ValueError, match="The parameter combination"):
|
781
693
|
_retrieve_shen(
|
782
|
-
|
694
|
+
dataset=check_dataset(),
|
783
695
|
resolution=resolution,
|
784
696
|
year=year,
|
785
697
|
n_rois=n_rois,
|
@@ -852,7 +764,6 @@ def test_retrieve_shen_incorrect_param_combo(
|
|
852
764
|
],
|
853
765
|
)
|
854
766
|
def test_yan(
|
855
|
-
tmp_path: Path,
|
856
767
|
resolution: float,
|
857
768
|
n_rois: int,
|
858
769
|
yeo_networks: int,
|
@@ -862,8 +773,6 @@ def test_yan(
|
|
862
773
|
|
863
774
|
Parameters
|
864
775
|
----------
|
865
|
-
tmp_path : pathlib.Path
|
866
|
-
The path to the test directory.
|
867
776
|
resolution : float
|
868
777
|
The parametrized resolution values.
|
869
778
|
n_rois : int
|
@@ -893,7 +802,6 @@ def test_yan(
|
|
893
802
|
img, label, img_path, space = ParcellationRegistry().load(
|
894
803
|
name=parcellation_name,
|
895
804
|
target_space="MNI152NLin6Asym",
|
896
|
-
parcellations_dir=tmp_path,
|
897
805
|
resolution=resolution,
|
898
806
|
)
|
899
807
|
assert img is not None
|
@@ -905,20 +813,13 @@ def test_yan(
|
|
905
813
|
)
|
906
814
|
|
907
815
|
|
908
|
-
def test_retrieve_yan_incorrect_networks(
|
909
|
-
"""Test retrieve Yan with incorrect networks.
|
910
|
-
|
911
|
-
Parameters
|
912
|
-
----------
|
913
|
-
tmp_path : pathlib.Path
|
914
|
-
The path to the test directory.
|
915
|
-
|
916
|
-
"""
|
816
|
+
def test_retrieve_yan_incorrect_networks() -> None:
|
817
|
+
"""Test retrieve Yan with incorrect networks."""
|
917
818
|
with pytest.raises(
|
918
819
|
ValueError, match="Either one of `yeo_networks` or `kong_networks`"
|
919
820
|
):
|
920
821
|
_retrieve_yan(
|
921
|
-
|
822
|
+
dataset=check_dataset(),
|
922
823
|
n_rois=31418,
|
923
824
|
yeo_networks=100,
|
924
825
|
kong_networks=100,
|
@@ -928,59 +829,38 @@ def test_retrieve_yan_incorrect_networks(tmp_path: Path) -> None:
|
|
928
829
|
ValueError, match="Either one of `yeo_networks` or `kong_networks`"
|
929
830
|
):
|
930
831
|
_retrieve_yan(
|
931
|
-
|
832
|
+
dataset=check_dataset(),
|
932
833
|
n_rois=31418,
|
933
834
|
yeo_networks=None,
|
934
835
|
kong_networks=None,
|
935
836
|
)
|
936
837
|
|
937
838
|
|
938
|
-
def test_retrieve_yan_incorrect_n_rois(
|
939
|
-
"""Test retrieve Yan with incorrect ROIs.
|
940
|
-
|
941
|
-
Parameters
|
942
|
-
----------
|
943
|
-
tmp_path : pathlib.Path
|
944
|
-
The path to the test directory.
|
945
|
-
|
946
|
-
"""
|
839
|
+
def test_retrieve_yan_incorrect_n_rois() -> None:
|
840
|
+
"""Test retrieve Yan with incorrect ROIs."""
|
947
841
|
with pytest.raises(ValueError, match="The parameter `n_rois`"):
|
948
842
|
_retrieve_yan(
|
949
|
-
|
843
|
+
dataset=check_dataset(),
|
950
844
|
n_rois=31418,
|
951
845
|
yeo_networks=7,
|
952
846
|
)
|
953
847
|
|
954
848
|
|
955
|
-
def test_retrieve_yan_incorrect_yeo_networks(
|
956
|
-
"""Test retrieve Yan with incorrect Yeo networks.
|
957
|
-
|
958
|
-
Parameters
|
959
|
-
----------
|
960
|
-
tmp_path : pathlib.Path
|
961
|
-
The path to the test directory.
|
962
|
-
|
963
|
-
"""
|
849
|
+
def test_retrieve_yan_incorrect_yeo_networks() -> None:
|
850
|
+
"""Test retrieve Yan with incorrect Yeo networks."""
|
964
851
|
with pytest.raises(ValueError, match="The parameter `yeo_networks`"):
|
965
852
|
_retrieve_yan(
|
966
|
-
|
853
|
+
dataset=check_dataset(),
|
967
854
|
n_rois=100,
|
968
855
|
yeo_networks=27,
|
969
856
|
)
|
970
857
|
|
971
858
|
|
972
|
-
def test_retrieve_yan_incorrect_kong_networks(
|
973
|
-
"""Test retrieve Yan with incorrect Kong networks.
|
974
|
-
|
975
|
-
Parameters
|
976
|
-
----------
|
977
|
-
tmp_path : pathlib.Path
|
978
|
-
The path to the test directory.
|
979
|
-
|
980
|
-
"""
|
859
|
+
def test_retrieve_yan_incorrect_kong_networks() -> None:
|
860
|
+
"""Test retrieve Yan with incorrect Kong networks."""
|
981
861
|
with pytest.raises(ValueError, match="The parameter `kong_networks`"):
|
982
862
|
_retrieve_yan(
|
983
|
-
|
863
|
+
dataset=check_dataset(),
|
984
864
|
n_rois=100,
|
985
865
|
kong_networks=27,
|
986
866
|
)
|
@@ -1001,7 +881,6 @@ def test_retrieve_yan_incorrect_kong_networks(tmp_path: Path) -> None:
|
|
1001
881
|
],
|
1002
882
|
)
|
1003
883
|
def test_brainnetome(
|
1004
|
-
tmp_path: Path,
|
1005
884
|
resolution: float,
|
1006
885
|
threshold: int,
|
1007
886
|
) -> None:
|
@@ -1009,8 +888,6 @@ def test_brainnetome(
|
|
1009
888
|
|
1010
889
|
Parameters
|
1011
890
|
----------
|
1012
|
-
tmp_path : pathlib.Path
|
1013
|
-
The path to the test directory.
|
1014
891
|
resolution : float
|
1015
892
|
The parametrized resolution values.
|
1016
893
|
threshold : int
|
@@ -1030,7 +907,6 @@ def test_brainnetome(
|
|
1030
907
|
img, label, img_path, space = ParcellationRegistry().load(
|
1031
908
|
name=parcellation_name,
|
1032
909
|
target_space="MNI152NLin6Asym",
|
1033
|
-
parcellations_dir=tmp_path,
|
1034
910
|
resolution=resolution,
|
1035
911
|
)
|
1036
912
|
assert img is not None
|
@@ -1042,18 +918,11 @@ def test_brainnetome(
|
|
1042
918
|
)
|
1043
919
|
|
1044
920
|
|
1045
|
-
def test_retrieve_brainnetome_incorrect_threshold(
|
1046
|
-
"""Test retrieve Brainnetome with incorrect threshold.
|
1047
|
-
|
1048
|
-
Parameters
|
1049
|
-
----------
|
1050
|
-
tmp_path : pathlib.Path
|
1051
|
-
The path to the test directory.
|
1052
|
-
|
1053
|
-
"""
|
921
|
+
def test_retrieve_brainnetome_incorrect_threshold() -> None:
|
922
|
+
"""Test retrieve Brainnetome with incorrect threshold."""
|
1054
923
|
with pytest.raises(ValueError, match="The parameter `threshold`"):
|
1055
924
|
_retrieve_brainnetome(
|
1056
|
-
|
925
|
+
dataset=check_dataset(),
|
1057
926
|
threshold=100,
|
1058
927
|
)
|
1059
928
|
|
@@ -1214,7 +1083,7 @@ def test_get_single() -> None:
|
|
1214
1083
|
bold_img = bold["data"]
|
1215
1084
|
# Get tailored parcellation
|
1216
1085
|
tailored_parcellation, tailored_labels = ParcellationRegistry().get(
|
1217
|
-
parcellations=["
|
1086
|
+
parcellations=["Shen_2015_268"],
|
1218
1087
|
target_data=bold,
|
1219
1088
|
)
|
1220
1089
|
# Check shape and affine with original element data
|
@@ -1222,9 +1091,9 @@ def test_get_single() -> None:
|
|
1222
1091
|
assert_array_equal(tailored_parcellation.affine, bold_img.affine)
|
1223
1092
|
# Get raw parcellation
|
1224
1093
|
raw_parcellation, raw_labels, _, _ = ParcellationRegistry().load(
|
1225
|
-
"
|
1094
|
+
name="Shen_2015_268",
|
1226
1095
|
target_space="MNI152NLin2009cAsym",
|
1227
|
-
resolution=
|
1096
|
+
resolution=4,
|
1228
1097
|
)
|
1229
1098
|
resampled_raw_parcellation = resample_to_img(
|
1230
1099
|
source_img=raw_parcellation,
|
@@ -1266,7 +1135,9 @@ def test_get_multi_same_space() -> None:
|
|
1266
1135
|
]
|
1267
1136
|
for name in parcellations_names:
|
1268
1137
|
img, labels, _, _ = ParcellationRegistry().load(
|
1269
|
-
name=name,
|
1138
|
+
name=name,
|
1139
|
+
target_space="MNI152NLin2009cAsym",
|
1140
|
+
resolution=4,
|
1270
1141
|
)
|
1271
1142
|
# Resample raw parcellations
|
1272
1143
|
resampled_img = resample_to_img(
|