11"""Integration tests for functional workflow."""
22
33from types import SimpleNamespace
4+ from typing import cast
45
56import nibabel as nib
67import pytest
1617
1718def test_truncate_trs (test_subject : SimpleNamespace ) -> None :
1819 """Test truncating initial TRs from BOLD timeseries."""
19- original_count = nib .load (test_subject .bold ).shape [3 ]
20+ original_count = cast ( " nib.Nifti1Image" , nib . load (test_subject .bold ) ).shape [3 ]
2021
2122 start_tr = 4
2223 reoriented = reorient (
@@ -29,13 +30,13 @@ def test_truncate_trs(test_subject: SimpleNamespace) -> None:
2930 )
3031 # Test truncated BOLD file exists & volume count is reduced
3132 assert truncated_bold .output_file .exists ()
32- new_shape = nib .load (truncated_bold .output_file ).shape
33+ new_shape = cast ( " nib.Nifti1Image" , nib . load (truncated_bold .output_file ) ).shape
3334 assert new_shape [3 ] == original_count - start_tr
3435
3536
3637def test_truncate_to_min_volume (test_subject : SimpleNamespace ) -> None :
3738 """Test truncating to minimum volume count of 1."""
38- original_count = nib .load (test_subject .bold ).shape [3 ]
39+ original_count = cast ( " nib.Nifti1Image" , nib . load (test_subject .bold ) ).shape [3 ]
3940
4041 start_tr = original_count - 1
4142 truncated_bold = truncate_trs (
@@ -44,7 +45,7 @@ def test_truncate_to_min_volume(test_subject: SimpleNamespace) -> None:
4445 start_tr = start_tr ,
4546 )
4647 # Test truncated BOLD file volume count is 1
47- new_shape = nib .load (truncated_bold .output_file ).shape
48+ new_shape = cast ( " nib.Nifti1Image" , nib . load (truncated_bold .output_file ) ).shape
4849 nvols = new_shape [3 ] if len (new_shape ) > 3 else 1
4950 assert nvols == 1
5051
@@ -55,7 +56,7 @@ def test_motion_reference_volume_count(test_subject: SimpleNamespace) -> None:
5556 in_file = test_subject .bold , output_fname = "test_motion_ref.nii.gz"
5657 )
5758 # Test motion reference file has 1 volume
58- ref_shape = nib .load (reference .output_file ).shape
59+ ref_shape = cast ( " nib.Nifti1Image" , nib . load (reference .output_file ) ).shape
5960 nvols = ref_shape [3 ] if len (ref_shape ) > 3 else 1
6061 assert nvols == 1
6162
@@ -82,7 +83,9 @@ def test_motion_correction_10vols(test_subject: SimpleNamespace) -> None:
8283 output_prefix = "test_mc_10v" ,
8384 )
8485 assert motion_corrected .bold .with_suffix (".nii.gz" ).exists ()
85- mc_shape = nib .load (motion_corrected .bold .with_suffix (".nii.gz" )).shape
86+ mc_shape = cast (
87+ "nib.Nifti1Image" , nib .load (motion_corrected .bold .with_suffix (".nii.gz" ))
88+ ).shape
8689 assert mc_shape [3 ] == 10
8790
8891 assert motion_corrected .par .exists ()
0 commit comments