예제 #1
0
def test_hippocampal_subfields_volume_file_init(volume_file_path, expected_attrs):
    volume_file = HippocampalSubfieldsVolumeFile(path=volume_file_path)
    assert os.path.basename(volume_file_path) == os.path.basename(
        volume_file.absolute_path
    )
    for attr, value in expected_attrs.items():
        assert value == getattr(volume_file, attr)
예제 #2
0
def test_hippocampal_subfields_volume_file_find(root_dir_path, expected_file_paths):
    volume_files = list(
        HippocampalSubfieldsVolumeFile.find(root_dir_path=root_dir_path)
    )
    assert all(
        "hippoSfVolumes" in os.path.basename(f.absolute_path) for f in volume_files
    )
    assert expected_file_paths == set(f.absolute_path for f in volume_files)
예제 #3
0
def test_hippocampal_subfields_volume_file_find_pattern(
    root_dir_path, filename_pattern, expected_file_paths
):
    assert expected_file_paths == set(
        f.absolute_path
        for f in HippocampalSubfieldsVolumeFile.find(
            root_dir_path=root_dir_path, filename_regex=re.compile(filename_pattern)
        )
    )
예제 #4
0
def test_hippocampal_subfields_volume_file_read_volumes_dataframe(
    volume_file_path: str, expected_dataframe: pandas.DataFrame
):
    assert_volume_frames_equal(
        left=expected_dataframe,
        right=HippocampalSubfieldsVolumeFile(
            path=volume_file_path
        ).read_volumes_dataframe(),
    )
예제 #5
0
def test_hippocampal_subfields_volume_file_read_volumes_dataframe_not_found():
    volume_file = HippocampalSubfieldsVolumeFile(
        path=os.path.join(SUBJECTS_DIR, "non-existing", "lh.hippoSfVolumes-T1.v10.txt")
    )
    with pytest.raises(FileNotFoundError):
        volume_file.read_volumes_dataframe()
예제 #6
0
def test_hippocampal_subfields_volume_file_read_volumes_mm3(
    volume_file_path, expected_volumes
):
    volume_file = HippocampalSubfieldsVolumeFile(path=volume_file_path)
    assert volume_file.t1_input
    assert expected_volumes == volume_file.read_volumes_mm3()
예제 #7
0
def test_hippocampal_subfields_volume_file_init_invalid_path(volume_file_path):
    with pytest.raises(Exception):
        HippocampalSubfieldsVolumeFile(path=volume_file_path)