Browse Source

CorticalParcellationStats: rename attribute `general_measurements` -> `whole_brain_measurements`

Fabian Peter Hammerle 4 years ago
parent
commit
37548b27ce
3 changed files with 15 additions and 15 deletions
  1. 2 2
      README.rst
  2. 7 7
      freesurfer_stats/__init__.py
  3. 6 6
      tests/test_cortical_parcellation_stats.py

+ 2 - 2
README.rst

@@ -31,7 +31,7 @@ Usage
     'mris_anatomical_stats -th3 -mgz -cortex ../label/lh.cortex.label'
     >>> stats.hemisphere
     'left'
-    >>> stats.general_measurements['Estimated Total Intracranial Volume']
+    >>> stats.whole_brain_measurements['Estimated Total Intracranial Volume']
     (1670487.274486, 'mm^3')
-    >>> stats.general_measurements['White Surface Total Area']
+    >>> stats.whole_brain_measurements['White Surface Total Area']
     (98553.0, 'mm^2')

+ 7 - 7
freesurfer_stats/__init__.py

@@ -14,9 +14,9 @@ https://surfer.nmr.mgh.harvard.edu/
 >>> stats.headers['cmdline'][:64]
 'mris_anatomical_stats -th3 -mgz -cortex ../label/lh.cortex.label'
 >>> stats.hemisphere
->>> stats.general_measurements['Estimated Total Intracranial Volume']
+>>> stats.whole_brain_measurements['Estimated Total Intracranial Volume']
 (1670487.274486, 'mm^3')
->>> stats.general_measurements['White Surface Total Area']
+>>> stats.whole_brain_measurements['White Surface Total Area']
 (98553.0, 'mm^2')
 """
 
@@ -38,7 +38,7 @@ class CorticalParcellationStats:
     def __init__(self):
         self.headers \
             = {}  # type: typing.Dict[str, typing.Union[str, datetime.datetime]]
-        self.general_measurements \
+        self.whole_brain_measurements \
             = {}  # type: typing.Dict[str, typing.Tuple[float, int]]
 
     @property
@@ -79,16 +79,16 @@ class CorticalParcellationStats:
             == '# Table of FreeSurfer cortical parcellation anatomical statistics'
         assert stream.readline().rstrip() == '#'
         self._read_headers(stream)
-        self.general_measurements = {}
+        self.whole_brain_measurements = {}
         line = self._read_header_line(stream)
         while not line.startswith('NTableCols'):
             key, name, value, unit \
                 = self._GENERAL_MEASUREMENTS_REGEX.match(line).groups()
             if key == 'SupraTentorialVolNotVent' and name.lower() == 'supratentorial volume':
                 name += ' Without Ventricles'
-            assert name not in self.general_measurements, \
-                (key, name, self.general_measurements)
-            self.general_measurements[name] = (float(value), unit)
+            assert name not in self.whole_brain_measurements, \
+                (key, name, self.whole_brain_measurements)
+            self.whole_brain_measurements[name] = (float(value), unit)
             line = self._read_header_line(stream)
 
     @classmethod

+ 6 - 6
tests/test_cortical_parcellation_stats.py

@@ -7,7 +7,7 @@ from conftest import SUBJECTS_DIR
 from freesurfer_stats import CorticalParcellationStats
 
 
-@pytest.mark.parametrize(('path', 'headers', 'hemisphere', 'general_measurements'), [
+@pytest.mark.parametrize(('path', 'headers', 'hemisphere', 'whole_brain_measurements'), [
     (os.path.join(SUBJECTS_DIR, 'fabian', 'stats', 'lh.aparc.DKTatlas.stats'),
      {'CreationTime': datetime.datetime(2019, 5, 9, 21, 5, 54, tzinfo=datetime.timezone.utc),
       'generating_program': 'mris_anatomical_stats',
@@ -66,13 +66,13 @@ from freesurfer_stats import CorticalParcellationStats
       'Supratentorial volume Without Ventricles': (1164180.548920, 'mm^3'),
       'Estimated Total Intracranial Volume': (1670487.274486, 'mm^3')}),
 ])
-def test_read(path, headers, hemisphere, general_measurements):
+def test_read(path, headers, hemisphere, whole_brain_measurements):
     stats = CorticalParcellationStats.read(path)
     assert headers == stats.headers
     assert hemisphere == stats.hemisphere
-    assert general_measurements.keys() == stats.general_measurements.keys()
-    for key, expected_value_unit in general_measurements.items():
+    assert whole_brain_measurements.keys() == stats.whole_brain_measurements.keys()
+    for key, expected_value_unit in whole_brain_measurements.items():
         expected_value, expected_unit = expected_value_unit
         assert expected_value \
-            == pytest.approx(stats.general_measurements[key][0])
-        assert expected_unit == stats.general_measurements[key][1]
+            == pytest.approx(stats.whole_brain_measurements[key][0])
+        assert expected_unit == stats.whole_brain_measurements[key][1]