def test_intracranial_volume_file_read_volume_series_single(
        volume_file_path, expected_series):
    volume_file = IntracranialVolumeFile(path=volume_file_path)
    pandas.testing.assert_series_equal(
        left=expected_series,
        right=volume_file.read_volume_series(),
        check_dtype=True,
        check_names=True,
    )
def test_intracranial_volume_file_find_pattern(root_dir_path, filename_pattern,
                                               expected_file_paths):
    volume_files_iterator = IntracranialVolumeFile.find(
        root_dir_path=root_dir_path,
        filename_regex=re.compile(filename_pattern))
    assert expected_file_paths == set(f.absolute_path
                                      for f in volume_files_iterator)
def test_intracranial_volume_file_read_volume_series_concat(
        volume_file_paths, expected_series):
    volume_series = pandas.concat(
        IntracranialVolumeFile(path=p).read_volume_series()
        for p in volume_file_paths)
    pandas.testing.assert_series_equal(left=expected_series,
                                       right=volume_series,
                                       check_dtype=True,
                                       check_names=True)
def test_intracranial_volume_file_read_volume_mm3_not_found(volume_file_path):
    volume_file = IntracranialVolumeFile(path=volume_file_path)
    with pytest.raises(FileNotFoundError):
        volume_file.read_volume_mm3()
def test_intracranial_volume_file_read_volume_mm3(volume_file_path,
                                                  expected_volume):
    volume_file = IntracranialVolumeFile(path=volume_file_path)
    assert expected_volume == pytest.approx(volume_file.read_volume_mm3())
def test_intracranial_volume_file_init_invalid_filename(volume_file_path):
    with pytest.raises(Exception):
        IntracranialVolumeFile(path=volume_file_path)
def test_intracranial_volume_file_init(volume_file_path, expected_subject):
    volume_file = IntracranialVolumeFile(path=volume_file_path)
    assert os.path.abspath(volume_file_path) == volume_file.absolute_path
    assert expected_subject == volume_file.subject
def test_intracranial_volume_file_find(root_dir_path, expected_file_paths):
    volume_files_iterator = IntracranialVolumeFile.find(
        root_dir_path=root_dir_path)
    assert expected_file_paths == set(f.absolute_path
                                      for f in volume_files_iterator)