junifer 0.0.6.dev422__py3-none-any.whl → 0.0.6.dev459__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- junifer/_version.py +2 -2
- junifer/cli/tests/test_cli_utils.py +1 -2
- junifer/data/coordinates/_coordinates.py +123 -104
- junifer/data/coordinates/tests/test_coordinates.py +1 -2
- junifer/data/masks/_masks.py +74 -58
- junifer/data/parcellations/_parcellations.py +238 -684
- junifer/data/parcellations/tests/test_parcellations.py +66 -213
- junifer/data/template_spaces.py +15 -89
- junifer/data/utils.py +28 -2
- junifer/typing/_typing.py +1 -1
- {junifer-0.0.6.dev422.dist-info → junifer-0.0.6.dev459.dist-info}/METADATA +2 -2
- {junifer-0.0.6.dev422.dist-info → junifer-0.0.6.dev459.dist-info}/RECORD +17 -17
- {junifer-0.0.6.dev422.dist-info → junifer-0.0.6.dev459.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.6.dev422.dist-info → junifer-0.0.6.dev459.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.6.dev422.dist-info → junifer-0.0.6.dev459.dist-info}/WHEEL +0 -0
- {junifer-0.0.6.dev422.dist-info → junifer-0.0.6.dev459.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.6.dev422.dist-info → junifer-0.0.6.dev459.dist-info}/top_level.txt +0 -0
@@ -18,7 +18,6 @@ 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,
|
@@ -247,12 +246,6 @@ def test_load_incorrect() -> None:
|
|
247
246
|
ParcellationRegistry().load("wrongparcellation", "MNI152NLin6Asym")
|
248
247
|
|
249
248
|
|
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
249
|
@pytest.mark.parametrize(
|
257
250
|
"resolution, n_rois, yeo_networks",
|
258
251
|
[
|
@@ -299,7 +292,6 @@ def test_retrieve_parcellation_incorrect() -> None:
|
|
299
292
|
],
|
300
293
|
)
|
301
294
|
def test_schaefer(
|
302
|
-
tmp_path: Path,
|
303
295
|
resolution: float,
|
304
296
|
n_rois: int,
|
305
297
|
yeo_networks: int,
|
@@ -308,8 +300,6 @@ def test_schaefer(
|
|
308
300
|
|
309
301
|
Parameters
|
310
302
|
----------
|
311
|
-
tmp_path : pathlib.Path
|
312
|
-
The path to the test directory.
|
313
303
|
resolution : float
|
314
304
|
The parametrized resolution values.
|
315
305
|
n_rois : int
|
@@ -329,7 +319,6 @@ def test_schaefer(
|
|
329
319
|
img, label, img_path, space = ParcellationRegistry().load(
|
330
320
|
name=parcellation_name,
|
331
321
|
target_space="MNI152NLin6Asym",
|
332
|
-
parcellations_dir=tmp_path,
|
333
322
|
resolution=resolution,
|
334
323
|
)
|
335
324
|
assert img is not None
|
@@ -341,36 +330,20 @@ def test_schaefer(
|
|
341
330
|
)
|
342
331
|
|
343
332
|
|
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
|
-
"""
|
333
|
+
def test_retrieve_schaefer_incorrect_n_rois() -> None:
|
334
|
+
"""Test retrieve Schaefer with incorrect ROIs."""
|
353
335
|
with pytest.raises(ValueError, match=r"The parameter `n_rois`"):
|
354
336
|
_retrieve_schaefer(
|
355
|
-
parcellations_dir=tmp_path,
|
356
337
|
resolution=1,
|
357
338
|
n_rois=101,
|
358
339
|
yeo_networks=7,
|
359
340
|
)
|
360
341
|
|
361
342
|
|
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
|
-
"""
|
343
|
+
def test_retrieve_schaefer_incorrect_yeo_networks() -> None:
|
344
|
+
"""Test retrieve Schaefer with incorrect Yeo networks."""
|
371
345
|
with pytest.raises(ValueError, match=r"The parameter `yeo_networks`"):
|
372
346
|
_retrieve_schaefer(
|
373
|
-
parcellations_dir=tmp_path,
|
374
347
|
resolution=1,
|
375
348
|
n_rois=100,
|
376
349
|
yeo_networks=8,
|
@@ -381,13 +354,11 @@ def test_retrieve_schaefer_incorrect_yeo_networks(tmp_path: Path) -> None:
|
|
381
354
|
"space_key, space",
|
382
355
|
[("SUIT", "SUIT"), ("MNI", "MNI152NLin6Asym")],
|
383
356
|
)
|
384
|
-
def test_suit(
|
357
|
+
def test_suit(space_key: str, space: str) -> None:
|
385
358
|
"""Test SUIT parcellation.
|
386
359
|
|
387
360
|
Parameters
|
388
361
|
----------
|
389
|
-
tmp_path : pathlib.Path
|
390
|
-
The path to the test directory.
|
391
362
|
space_key : str
|
392
363
|
The parametrized space values for the key.
|
393
364
|
space : str
|
@@ -399,7 +370,6 @@ def test_suit(tmp_path: Path, space_key: str, space: str) -> None:
|
|
399
370
|
img, label, img_path, parcellation_space = ParcellationRegistry().load(
|
400
371
|
name=f"SUITx{space_key}",
|
401
372
|
target_space=space,
|
402
|
-
parcellations_dir=tmp_path,
|
403
373
|
)
|
404
374
|
assert img is not None
|
405
375
|
assert img_path.name == f"SUIT_{space_key}Space_1mm.nii"
|
@@ -408,33 +378,20 @@ def test_suit(tmp_path: Path, space_key: str, space: str) -> None:
|
|
408
378
|
assert_array_equal(img.header["pixdim"][1:4], [1, 1, 1]) # type: ignore
|
409
379
|
|
410
380
|
|
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
|
-
"""
|
381
|
+
def test_retrieve_suit_incorrect_space() -> None:
|
382
|
+
"""Test retrieve SUIT with incorrect space."""
|
420
383
|
with pytest.raises(ValueError, match=r"The parameter `space`"):
|
421
|
-
_retrieve_suit(
|
422
|
-
parcellations_dir=tmp_path, resolution=1.0, space="wrong"
|
423
|
-
)
|
384
|
+
_retrieve_suit(resolution=1.0, space="wrong")
|
424
385
|
|
425
386
|
|
426
387
|
@pytest.mark.parametrize(
|
427
388
|
"scale, n_label", [(1, 16), (2, 32), (3, 50), (4, 54)]
|
428
389
|
)
|
429
|
-
def test_tian_3T_6thgeneration(
|
430
|
-
tmp_path: Path, scale: int, n_label: int
|
431
|
-
) -> None:
|
390
|
+
def test_tian_3T_6thgeneration(scale: int, n_label: int) -> None:
|
432
391
|
"""Test Tian parcellation.
|
433
392
|
|
434
393
|
Parameters
|
435
394
|
----------
|
436
|
-
tmp_path : pathlib.Path
|
437
|
-
The path to the test directory.
|
438
395
|
scale : int
|
439
396
|
The parametrized scale values.
|
440
397
|
n_label : int
|
@@ -447,44 +404,38 @@ def test_tian_3T_6thgeneration(
|
|
447
404
|
assert "TianxS3x3TxMNI6thgeneration" in parcellations
|
448
405
|
assert "TianxS4x3TxMNI6thgeneration" in parcellations
|
449
406
|
# Load parcellation
|
450
|
-
img, lbl, fname,
|
407
|
+
img, lbl, fname, space = ParcellationRegistry().load(
|
451
408
|
name=f"TianxS{scale}x3TxMNI6thgeneration",
|
452
|
-
|
453
|
-
target_space="MNI152NLin2009cAsym",
|
409
|
+
target_space="MNI152NLin2009cAsym", # force highest resolution
|
454
410
|
)
|
455
|
-
|
411
|
+
expected_fname = f"Tian_Subcortex_S{scale}_3T_1mm.nii.gz"
|
456
412
|
assert img is not None
|
457
|
-
assert fname.name ==
|
458
|
-
assert
|
413
|
+
assert fname.name == expected_fname
|
414
|
+
assert space == "MNI152NLin6Asym"
|
459
415
|
assert len(lbl) == n_label
|
460
|
-
assert_array_equal(img.header["pixdim"][1:4], [1, 1, 1])
|
416
|
+
assert_array_equal(img.header["pixdim"][1:4], [1, 1, 1])
|
461
417
|
# Load parcellation
|
462
|
-
img, lbl, fname,
|
418
|
+
img, lbl, fname, space = ParcellationRegistry().load(
|
463
419
|
name=f"TianxS{scale}x3TxMNI6thgeneration",
|
464
420
|
target_space="MNI152NLin6Asym",
|
465
|
-
parcellations_dir=tmp_path,
|
466
421
|
resolution=2,
|
467
422
|
)
|
468
|
-
|
423
|
+
expected_fname = f"Tian_Subcortex_S{scale}_3T.nii.gz"
|
469
424
|
assert img is not None
|
470
|
-
assert fname.name ==
|
471
|
-
assert
|
425
|
+
assert fname.name == expected_fname
|
426
|
+
assert space == "MNI152NLin6Asym"
|
472
427
|
assert len(lbl) == n_label
|
473
|
-
assert_array_equal(img.header["pixdim"][1:4], [2, 2, 2])
|
428
|
+
assert_array_equal(img.header["pixdim"][1:4], [2, 2, 2])
|
474
429
|
|
475
430
|
|
476
431
|
@pytest.mark.parametrize(
|
477
432
|
"scale, n_label", [(1, 16), (2, 32), (3, 50), (4, 54)]
|
478
433
|
)
|
479
|
-
def test_tian_3T_nonlinear2009cAsym(
|
480
|
-
tmp_path: Path, scale: int, n_label: int
|
481
|
-
) -> None:
|
434
|
+
def test_tian_3T_nonlinear2009cAsym(scale: int, n_label: int) -> None:
|
482
435
|
"""Test Tian parcellation.
|
483
436
|
|
484
437
|
Parameters
|
485
438
|
----------
|
486
|
-
tmp_path : pathlib.Path
|
487
|
-
The path to the test directory.
|
488
439
|
scale : int
|
489
440
|
The parametrized scale values.
|
490
441
|
n_label : int
|
@@ -497,31 +448,38 @@ def test_tian_3T_nonlinear2009cAsym(
|
|
497
448
|
assert "TianxS3x3TxMNInonlinear2009cAsym" in parcellations
|
498
449
|
assert "TianxS4x3TxMNInonlinear2009cAsym" in parcellations
|
499
450
|
# Load parcellation
|
451
|
+
img, lbl, fname, space = ParcellationRegistry().load(
|
452
|
+
name=f"TianxS{scale}x3TxMNInonlinear2009cAsym",
|
453
|
+
target_space="MNI152NLin6Asym", # force highest resolution
|
454
|
+
)
|
455
|
+
expected_fname = f"Tian_Subcortex_S{scale}_3T_2009cAsym_1mm.nii.gz"
|
456
|
+
assert img is not None
|
457
|
+
assert fname.name == expected_fname
|
458
|
+
assert space == "MNI152NLin2009cAsym"
|
459
|
+
assert len(lbl) == n_label
|
460
|
+
assert_array_equal(img.header["pixdim"][1:4], [1, 1, 1])
|
461
|
+
# Load parcellation
|
500
462
|
img, lbl, fname, space = ParcellationRegistry().load(
|
501
463
|
name=f"TianxS{scale}x3TxMNInonlinear2009cAsym",
|
502
464
|
target_space="MNI152NLin2009cAsym",
|
503
|
-
|
465
|
+
resolution=2,
|
504
466
|
)
|
505
|
-
|
467
|
+
expected_fname = f"Tian_Subcortex_S{scale}_3T_2009cAsym.nii.gz"
|
506
468
|
assert img is not None
|
507
|
-
assert fname.name ==
|
469
|
+
assert fname.name == expected_fname
|
508
470
|
assert space == "MNI152NLin2009cAsym"
|
509
471
|
assert len(lbl) == n_label
|
510
|
-
assert_array_equal(img.header["pixdim"][1:4], [2, 2, 2])
|
472
|
+
assert_array_equal(img.header["pixdim"][1:4], [2, 2, 2])
|
511
473
|
|
512
474
|
|
513
475
|
@pytest.mark.parametrize(
|
514
476
|
"scale, n_label", [(1, 16), (2, 34), (3, 54), (4, 62)]
|
515
477
|
)
|
516
|
-
def test_tian_7T_6thgeneration(
|
517
|
-
tmp_path: Path, scale: int, n_label: int
|
518
|
-
) -> None:
|
478
|
+
def test_tian_7T_6thgeneration(scale: int, n_label: int) -> None:
|
519
479
|
"""Test Tian parcellation.
|
520
480
|
|
521
481
|
Parameters
|
522
482
|
----------
|
523
|
-
tmp_path : pathlib.Path
|
524
|
-
The path to the test directory.
|
525
483
|
scale : int
|
526
484
|
The parametrized scale values.
|
527
485
|
n_label : int
|
@@ -537,7 +495,6 @@ def test_tian_7T_6thgeneration(
|
|
537
495
|
img, lbl, fname, space = ParcellationRegistry().load(
|
538
496
|
name=f"TianxS{scale}x7TxMNI6thgeneration",
|
539
497
|
target_space="MNI152NLin6Asym",
|
540
|
-
parcellations_dir=tmp_path,
|
541
498
|
)
|
542
499
|
fname1 = f"Tian_Subcortex_S{scale}_7T.nii.gz"
|
543
500
|
assert img is not None
|
@@ -549,23 +506,13 @@ def test_tian_7T_6thgeneration(
|
|
549
506
|
)
|
550
507
|
|
551
508
|
|
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
|
-
"""
|
509
|
+
def test_retrieve_tian_incorrect_space() -> None:
|
510
|
+
"""Test retrieve tian with incorrect space."""
|
561
511
|
with pytest.raises(ValueError, match=r"The parameter `space`"):
|
562
|
-
_retrieve_tian(
|
563
|
-
parcellations_dir=tmp_path, resolution=1, scale=1, space="wrong"
|
564
|
-
)
|
512
|
+
_retrieve_tian(resolution=1, scale=1, space="wrong")
|
565
513
|
|
566
514
|
with pytest.raises(ValueError, match=r"MNI152NLin6Asym"):
|
567
515
|
_retrieve_tian(
|
568
|
-
parcellations_dir=tmp_path,
|
569
516
|
resolution=1,
|
570
517
|
scale=1,
|
571
518
|
magneticfield="7T",
|
@@ -573,18 +520,10 @@ def test_retrieve_tian_incorrect_space(tmp_path: Path) -> None:
|
|
573
520
|
)
|
574
521
|
|
575
522
|
|
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
|
-
"""
|
523
|
+
def test_retrieve_tian_incorrect_magneticfield() -> None:
|
524
|
+
"""Test retrieve tian with incorrect magneticfield."""
|
585
525
|
with pytest.raises(ValueError, match=r"The parameter `magneticfield`"):
|
586
526
|
_retrieve_tian(
|
587
|
-
parcellations_dir=tmp_path,
|
588
527
|
resolution=1,
|
589
528
|
scale=1,
|
590
529
|
magneticfield="wrong",
|
@@ -592,17 +531,9 @@ def test_retrieve_tian_incorrect_magneticfield(tmp_path: Path) -> None:
|
|
592
531
|
|
593
532
|
|
594
533
|
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
|
-
"""
|
534
|
+
"""Test retrieve tian with incorrect scale."""
|
603
535
|
with pytest.raises(ValueError, match=r"The parameter `scale`"):
|
604
536
|
_retrieve_tian(
|
605
|
-
parcellations_dir=tmp_path,
|
606
537
|
resolution=1,
|
607
538
|
scale=5,
|
608
539
|
space="MNI152NLin6Asym",
|
@@ -610,7 +541,7 @@ def test_retrieve_tian_incorrect_scale(tmp_path: Path) -> None:
|
|
610
541
|
|
611
542
|
|
612
543
|
@pytest.mark.parametrize("version", [1, 2])
|
613
|
-
def test_aicha(
|
544
|
+
def test_aicha(version: int) -> None:
|
614
545
|
"""Test AICHA parcellation.
|
615
546
|
|
616
547
|
Parameters
|
@@ -626,7 +557,6 @@ def test_aicha(tmp_path: Path, version: int) -> None:
|
|
626
557
|
img, label, img_path, space = ParcellationRegistry().load(
|
627
558
|
name=f"AICHA_v{version}",
|
628
559
|
target_space="IXI549Space",
|
629
|
-
parcellations_dir=tmp_path,
|
630
560
|
)
|
631
561
|
assert img is not None
|
632
562
|
assert img_path.name == "AICHA.nii"
|
@@ -635,18 +565,10 @@ def test_aicha(tmp_path: Path, version: int) -> None:
|
|
635
565
|
assert_array_equal(img.header["pixdim"][1:4], [2, 2, 2]) # type: ignore
|
636
566
|
|
637
567
|
|
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
|
-
"""
|
568
|
+
def test_retrieve_aicha_incorrect_version() -> None:
|
569
|
+
"""Test retrieve AICHA with incorrect version."""
|
647
570
|
with pytest.raises(ValueError, match="The parameter `version`"):
|
648
571
|
_retrieve_aicha(
|
649
|
-
parcellations_dir=tmp_path,
|
650
572
|
version=100,
|
651
573
|
)
|
652
574
|
|
@@ -666,7 +588,6 @@ def test_retrieve_aicha_incorrect_version(tmp_path: Path) -> None:
|
|
666
588
|
],
|
667
589
|
)
|
668
590
|
def test_shen(
|
669
|
-
tmp_path: Path,
|
670
591
|
resolution: float,
|
671
592
|
year: int,
|
672
593
|
n_rois: int,
|
@@ -677,8 +598,6 @@ def test_shen(
|
|
677
598
|
|
678
599
|
Parameters
|
679
600
|
----------
|
680
|
-
tmp_path : pathlib.Path
|
681
|
-
The path to the test directory.
|
682
601
|
resolution : float
|
683
602
|
The parametrized resolution values.
|
684
603
|
year : int
|
@@ -696,7 +615,6 @@ def test_shen(
|
|
696
615
|
img, label, img_path, space = ParcellationRegistry().load(
|
697
616
|
name=f"Shen_{year}_{n_rois}",
|
698
617
|
target_space="MNI152NLin2009cAsym",
|
699
|
-
parcellations_dir=tmp_path,
|
700
618
|
resolution=resolution,
|
701
619
|
)
|
702
620
|
assert img is not None
|
@@ -708,34 +626,18 @@ def test_shen(
|
|
708
626
|
)
|
709
627
|
|
710
628
|
|
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
|
-
"""
|
629
|
+
def test_retrieve_shen_incorrect_year() -> None:
|
630
|
+
"""Test retrieve Shen with incorrect year."""
|
720
631
|
with pytest.raises(ValueError, match="The parameter `year`"):
|
721
632
|
_retrieve_shen(
|
722
|
-
parcellations_dir=tmp_path,
|
723
633
|
year=1969,
|
724
634
|
)
|
725
635
|
|
726
636
|
|
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
|
-
"""
|
637
|
+
def test_retrieve_shen_incorrect_n_rois() -> None:
|
638
|
+
"""Test retrieve Shen with incorrect ROIs."""
|
736
639
|
with pytest.raises(ValueError, match="The parameter `n_rois`"):
|
737
640
|
_retrieve_shen(
|
738
|
-
parcellations_dir=tmp_path,
|
739
641
|
year=2015,
|
740
642
|
n_rois=10,
|
741
643
|
)
|
@@ -758,7 +660,6 @@ def test_retrieve_shen_incorrect_n_rois(tmp_path: Path) -> None:
|
|
758
660
|
],
|
759
661
|
)
|
760
662
|
def test_retrieve_shen_incorrect_param_combo(
|
761
|
-
tmp_path: Path,
|
762
663
|
resolution: float,
|
763
664
|
year: int,
|
764
665
|
n_rois: int,
|
@@ -779,7 +680,6 @@ def test_retrieve_shen_incorrect_param_combo(
|
|
779
680
|
"""
|
780
681
|
with pytest.raises(ValueError, match="The parameter combination"):
|
781
682
|
_retrieve_shen(
|
782
|
-
parcellations_dir=tmp_path,
|
783
683
|
resolution=resolution,
|
784
684
|
year=year,
|
785
685
|
n_rois=n_rois,
|
@@ -852,7 +752,6 @@ def test_retrieve_shen_incorrect_param_combo(
|
|
852
752
|
],
|
853
753
|
)
|
854
754
|
def test_yan(
|
855
|
-
tmp_path: Path,
|
856
755
|
resolution: float,
|
857
756
|
n_rois: int,
|
858
757
|
yeo_networks: int,
|
@@ -862,8 +761,6 @@ def test_yan(
|
|
862
761
|
|
863
762
|
Parameters
|
864
763
|
----------
|
865
|
-
tmp_path : pathlib.Path
|
866
|
-
The path to the test directory.
|
867
764
|
resolution : float
|
868
765
|
The parametrized resolution values.
|
869
766
|
n_rois : int
|
@@ -893,7 +790,6 @@ def test_yan(
|
|
893
790
|
img, label, img_path, space = ParcellationRegistry().load(
|
894
791
|
name=parcellation_name,
|
895
792
|
target_space="MNI152NLin6Asym",
|
896
|
-
parcellations_dir=tmp_path,
|
897
793
|
resolution=resolution,
|
898
794
|
)
|
899
795
|
assert img is not None
|
@@ -905,20 +801,12 @@ def test_yan(
|
|
905
801
|
)
|
906
802
|
|
907
803
|
|
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
|
-
"""
|
804
|
+
def test_retrieve_yan_incorrect_networks() -> None:
|
805
|
+
"""Test retrieve Yan with incorrect networks."""
|
917
806
|
with pytest.raises(
|
918
807
|
ValueError, match="Either one of `yeo_networks` or `kong_networks`"
|
919
808
|
):
|
920
809
|
_retrieve_yan(
|
921
|
-
parcellations_dir=tmp_path,
|
922
810
|
n_rois=31418,
|
923
811
|
yeo_networks=100,
|
924
812
|
kong_networks=100,
|
@@ -928,59 +816,34 @@ def test_retrieve_yan_incorrect_networks(tmp_path: Path) -> None:
|
|
928
816
|
ValueError, match="Either one of `yeo_networks` or `kong_networks`"
|
929
817
|
):
|
930
818
|
_retrieve_yan(
|
931
|
-
parcellations_dir=tmp_path,
|
932
819
|
n_rois=31418,
|
933
820
|
yeo_networks=None,
|
934
821
|
kong_networks=None,
|
935
822
|
)
|
936
823
|
|
937
824
|
|
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
|
-
"""
|
825
|
+
def test_retrieve_yan_incorrect_n_rois() -> None:
|
826
|
+
"""Test retrieve Yan with incorrect ROIs."""
|
947
827
|
with pytest.raises(ValueError, match="The parameter `n_rois`"):
|
948
828
|
_retrieve_yan(
|
949
|
-
parcellations_dir=tmp_path,
|
950
829
|
n_rois=31418,
|
951
830
|
yeo_networks=7,
|
952
831
|
)
|
953
832
|
|
954
833
|
|
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
|
-
"""
|
834
|
+
def test_retrieve_yan_incorrect_yeo_networks() -> None:
|
835
|
+
"""Test retrieve Yan with incorrect Yeo networks."""
|
964
836
|
with pytest.raises(ValueError, match="The parameter `yeo_networks`"):
|
965
837
|
_retrieve_yan(
|
966
|
-
parcellations_dir=tmp_path,
|
967
838
|
n_rois=100,
|
968
839
|
yeo_networks=27,
|
969
840
|
)
|
970
841
|
|
971
842
|
|
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
|
-
"""
|
843
|
+
def test_retrieve_yan_incorrect_kong_networks() -> None:
|
844
|
+
"""Test retrieve Yan with incorrect Kong networks."""
|
981
845
|
with pytest.raises(ValueError, match="The parameter `kong_networks`"):
|
982
846
|
_retrieve_yan(
|
983
|
-
parcellations_dir=tmp_path,
|
984
847
|
n_rois=100,
|
985
848
|
kong_networks=27,
|
986
849
|
)
|
@@ -1001,7 +864,6 @@ def test_retrieve_yan_incorrect_kong_networks(tmp_path: Path) -> None:
|
|
1001
864
|
],
|
1002
865
|
)
|
1003
866
|
def test_brainnetome(
|
1004
|
-
tmp_path: Path,
|
1005
867
|
resolution: float,
|
1006
868
|
threshold: int,
|
1007
869
|
) -> None:
|
@@ -1009,8 +871,6 @@ def test_brainnetome(
|
|
1009
871
|
|
1010
872
|
Parameters
|
1011
873
|
----------
|
1012
|
-
tmp_path : pathlib.Path
|
1013
|
-
The path to the test directory.
|
1014
874
|
resolution : float
|
1015
875
|
The parametrized resolution values.
|
1016
876
|
threshold : int
|
@@ -1030,7 +890,6 @@ def test_brainnetome(
|
|
1030
890
|
img, label, img_path, space = ParcellationRegistry().load(
|
1031
891
|
name=parcellation_name,
|
1032
892
|
target_space="MNI152NLin6Asym",
|
1033
|
-
parcellations_dir=tmp_path,
|
1034
893
|
resolution=resolution,
|
1035
894
|
)
|
1036
895
|
assert img is not None
|
@@ -1042,18 +901,10 @@ def test_brainnetome(
|
|
1042
901
|
)
|
1043
902
|
|
1044
903
|
|
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
|
-
"""
|
904
|
+
def test_retrieve_brainnetome_incorrect_threshold() -> None:
|
905
|
+
"""Test retrieve Brainnetome with incorrect threshold."""
|
1054
906
|
with pytest.raises(ValueError, match="The parameter `threshold`"):
|
1055
907
|
_retrieve_brainnetome(
|
1056
|
-
parcellations_dir=tmp_path,
|
1057
908
|
threshold=100,
|
1058
909
|
)
|
1059
910
|
|
@@ -1214,7 +1065,7 @@ def test_get_single() -> None:
|
|
1214
1065
|
bold_img = bold["data"]
|
1215
1066
|
# Get tailored parcellation
|
1216
1067
|
tailored_parcellation, tailored_labels = ParcellationRegistry().get(
|
1217
|
-
parcellations=["
|
1068
|
+
parcellations=["Shen_2015_268"],
|
1218
1069
|
target_data=bold,
|
1219
1070
|
)
|
1220
1071
|
# Check shape and affine with original element data
|
@@ -1222,9 +1073,9 @@ def test_get_single() -> None:
|
|
1222
1073
|
assert_array_equal(tailored_parcellation.affine, bold_img.affine)
|
1223
1074
|
# Get raw parcellation
|
1224
1075
|
raw_parcellation, raw_labels, _, _ = ParcellationRegistry().load(
|
1225
|
-
"
|
1076
|
+
name="Shen_2015_268",
|
1226
1077
|
target_space="MNI152NLin2009cAsym",
|
1227
|
-
resolution=
|
1078
|
+
resolution=4,
|
1228
1079
|
)
|
1229
1080
|
resampled_raw_parcellation = resample_to_img(
|
1230
1081
|
source_img=raw_parcellation,
|
@@ -1266,7 +1117,9 @@ def test_get_multi_same_space() -> None:
|
|
1266
1117
|
]
|
1267
1118
|
for name in parcellations_names:
|
1268
1119
|
img, labels, _, _ = ParcellationRegistry().load(
|
1269
|
-
name=name,
|
1120
|
+
name=name,
|
1121
|
+
target_space="MNI152NLin2009cAsym",
|
1122
|
+
resolution=4,
|
1270
1123
|
)
|
1271
1124
|
# Resample raw parcellations
|
1272
1125
|
resampled_img = resample_to_img(
|