Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
CorticalParcellationStats._parse_whole_brain_measurements_line: incre…
Browse files Browse the repository at this point in the history
…ase coverage
  • Loading branch information
fphammerle committed May 6, 2020
1 parent 3a2481c commit 759c02d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- fixed parsing of `BrainVolStatsFixed` header
(https://github.com/fphammerle/freesurfer-stats/pull/1,
https://github.com/fphammerle/freesurfer-stats/pull/9,
@soichih)
(https://github.com/fphammerle/freesurfer-stats/pull/1 @soichih,
https://github.com/fphammerle/freesurfer-stats/pull/9)

## [1.1.0] - 2020-05-06
### Added
Expand Down
33 changes: 33 additions & 0 deletions tests/test_cortical_parcellation_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import datetime
import os

import numpy
import pandas.util.testing
import pytest

Expand All @@ -26,6 +27,7 @@

# pylint: disable=too-many-arguments


@pytest.mark.parametrize(
('path', 'headers', 'hemisphere',
'whole_brain_measurements', 'structural_measurements_length',
Expand Down Expand Up @@ -255,3 +257,34 @@ def test_read_structural_measurements_length(path, structural_measurements_lengt
# simple test to verify no exception gets raised, see test_read for comprehensive test
stats = CorticalParcellationStats.read(path)
assert len(stats.structural_measurements) == structural_measurements_length


@pytest.mark.parametrize(
("line", "expected_column_name", "expected_value"),
[
(
"Measure Cortex, CortexVol Total cortical gray matter volume, 553998.311189, mm^3",
"total_cortical_gray_matter_volume_mm^3",
553998.311189,
)
],
)
def test__parse_whole_brain_measurements_line(
line, expected_column_name, expected_value
):
# pylint: disable=protected-access
column_name, value = CorticalParcellationStats._parse_whole_brain_measurements_line(
line,
)
assert column_name == expected_column_name
assert numpy.allclose(value, [expected_value])


@pytest.mark.parametrize(
"line",
["Measure Cortex, CortexVol Total cortical gray matter volume, 553998.311189",],
)
def test__parse_whole_brain_measurements_line_parse_error(line):
# pylint: disable=protected-access
with pytest.raises(ValueError):
CorticalParcellationStats._parse_whole_brain_measurements_line(line)

0 comments on commit 759c02d

Please sign in to comment.