|
@@ -1,6 +1,7 @@
|
|
import datetime
|
|
import datetime
|
|
import os
|
|
import os
|
|
|
|
|
|
|
|
+import pandas.util.testing
|
|
import pytest
|
|
import pytest
|
|
|
|
|
|
from conftest import SUBJECTS_DIR, assert_approx_equal
|
|
from conftest import SUBJECTS_DIR, assert_approx_equal
|
|
@@ -38,39 +39,36 @@ from freesurfer_stats import CorticalParcellationStats
|
|
'Supratentorial volume': (1172669.548920, 'mm^3'),
|
|
'Supratentorial volume': (1172669.548920, 'mm^3'),
|
|
'Supratentorial volume Without Ventricles': (1164180.548920, 'mm^3'),
|
|
'Supratentorial volume Without Ventricles': (1164180.548920, 'mm^3'),
|
|
'Estimated Total Intracranial Volume': (1670487.274486, 'mm^3')},
|
|
'Estimated Total Intracranial Volume': (1670487.274486, 'mm^3')},
|
|
- {'caudalanteriorcingulate': {
|
|
|
|
- 'Structure Name': 'caudalanteriorcingulate',
|
|
|
|
- 'Number of Vertices': 2061,
|
|
|
|
- 'Surface Area': 1472.0,
|
|
|
|
- 'Gray Matter Volume': 4258.0,
|
|
|
|
- 'Average Thickness': 2.653,
|
|
|
|
- 'Thickness StdDev': 0.644,
|
|
|
|
- 'Integrated Rectified Mean Curvature': 0.135,
|
|
|
|
- 'Integrated Rectified Gaussian Curvature': 0.020,
|
|
|
|
- 'Folding Index': 27,
|
|
|
|
- 'Intrinsic Curvature Index': 1.6},
|
|
|
|
- 'caudalmiddlefrontal': {
|
|
|
|
- 'Structure Name': 'caudalmiddlefrontal',
|
|
|
|
- 'Number of Vertices': 4451,
|
|
|
|
- 'Surface Area': 3039.0,
|
|
|
|
- 'Gray Matter Volume': 8239.0,
|
|
|
|
- 'Average Thickness': 2.456,
|
|
|
|
- 'Thickness StdDev': 0.486,
|
|
|
|
- 'Integrated Rectified Mean Curvature': 0.116,
|
|
|
|
- 'Integrated Rectified Gaussian Curvature': 0.020,
|
|
|
|
- 'Folding Index': 42,
|
|
|
|
- 'Intrinsic Curvature Index': 3.7},
|
|
|
|
- 'insula': {
|
|
|
|
- 'Structure Name': 'insula',
|
|
|
|
- 'Number of Vertices': 3439,
|
|
|
|
- 'Surface Area': 2304.0,
|
|
|
|
- 'Gray Matter Volume': 7594.0,
|
|
|
|
- 'Average Thickness': 3.193,
|
|
|
|
- 'Thickness StdDev': 0.620,
|
|
|
|
- 'Integrated Rectified Mean Curvature': 0.116,
|
|
|
|
- 'Integrated Rectified Gaussian Curvature': 0.027,
|
|
|
|
- 'Folding Index': 33,
|
|
|
|
- 'Intrinsic Curvature Index': 3.5}}),
|
|
|
|
|
|
+ [{'Structure Name': 'caudalanteriorcingulate',
|
|
|
|
+ 'Number of Vertices': 2061,
|
|
|
|
+ 'Surface Area (mm^2)': 1472,
|
|
|
|
+ 'Gray Matter Volume (mm^3)': 4258,
|
|
|
|
+ 'Average Thickness (mm)': 2.653,
|
|
|
|
+ 'Thickness StdDev (mm)': 0.644,
|
|
|
|
+ 'Integrated Rectified Mean Curvature (mm^-1)': 0.135,
|
|
|
|
+ 'Integrated Rectified Gaussian Curvature (mm^-2)': 0.020,
|
|
|
|
+ 'Folding Index': 27,
|
|
|
|
+ 'Intrinsic Curvature Index': 1.6},
|
|
|
|
+ {'Structure Name': 'caudalmiddlefrontal',
|
|
|
|
+ 'Number of Vertices': 4451,
|
|
|
|
+ 'Surface Area (mm^2)': 3039,
|
|
|
|
+ 'Gray Matter Volume (mm^3)': 8239,
|
|
|
|
+ 'Average Thickness (mm)': 2.456,
|
|
|
|
+ 'Thickness StdDev (mm)': 0.486,
|
|
|
|
+ 'Integrated Rectified Mean Curvature (mm^-1)': 0.116,
|
|
|
|
+ 'Integrated Rectified Gaussian Curvature (mm^-2)': 0.020,
|
|
|
|
+ 'Folding Index': 42,
|
|
|
|
+ 'Intrinsic Curvature Index': 3.7},
|
|
|
|
+ {'Structure Name': 'insula',
|
|
|
|
+ 'Number of Vertices': 3439,
|
|
|
|
+ 'Surface Area (mm^2)': 2304,
|
|
|
|
+ 'Gray Matter Volume (mm^3)': 7594,
|
|
|
|
+ 'Average Thickness (mm)': 3.193,
|
|
|
|
+ 'Thickness StdDev (mm)': 0.620,
|
|
|
|
+ 'Integrated Rectified Mean Curvature (mm^-1)': 0.116,
|
|
|
|
+ 'Integrated Rectified Gaussian Curvature (mm^-2)': 0.027,
|
|
|
|
+ 'Folding Index': 33,
|
|
|
|
+ 'Intrinsic Curvature Index': 3.5}]),
|
|
(os.path.join(
|
|
(os.path.join(
|
|
SUBJECTS_DIR, 'fabian', 'stats', 'rh.aparc.pial.stats.short'),
|
|
SUBJECTS_DIR, 'fabian', 'stats', 'rh.aparc.pial.stats.short'),
|
|
{'CreationTime': datetime.datetime(2019, 5, 9, 21, 3, 42, tzinfo=datetime.timezone.utc),
|
|
{'CreationTime': datetime.datetime(2019, 5, 9, 21, 3, 42, tzinfo=datetime.timezone.utc),
|
|
@@ -100,28 +98,26 @@ from freesurfer_stats import CorticalParcellationStats
|
|
'Supratentorial volume': (1172669.548920, 'mm^3'),
|
|
'Supratentorial volume': (1172669.548920, 'mm^3'),
|
|
'Supratentorial volume Without Ventricles': (1164180.548920, 'mm^3'),
|
|
'Supratentorial volume Without Ventricles': (1164180.548920, 'mm^3'),
|
|
'Estimated Total Intracranial Volume': (1670487.274486, 'mm^3')},
|
|
'Estimated Total Intracranial Volume': (1670487.274486, 'mm^3')},
|
|
- {'bankssts': {
|
|
|
|
- 'Structure Name': 'bankssts',
|
|
|
|
- 'Number of Vertices': 1344,
|
|
|
|
- 'Surface Area': 825.0,
|
|
|
|
- 'Gray Matter Volume': 2171.0,
|
|
|
|
- 'Average Thickness': 2.436,
|
|
|
|
- 'Thickness StdDev': 0.381,
|
|
|
|
- 'Integrated Rectified Mean Curvature': 0.115,
|
|
|
|
- 'Integrated Rectified Gaussian Curvature': 0.028,
|
|
|
|
- 'Folding Index': 19,
|
|
|
|
- 'Intrinsic Curvature Index': 1.7},
|
|
|
|
- 'transversetemporal': {
|
|
|
|
- 'Structure Name': 'transversetemporal',
|
|
|
|
- 'Number of Vertices': 651,
|
|
|
|
- 'Surface Area': 545.0,
|
|
|
|
- 'Gray Matter Volume': 1061.0,
|
|
|
|
- 'Average Thickness': 2.251,
|
|
|
|
- 'Thickness StdDev': 0.317,
|
|
|
|
- 'Integrated Rectified Mean Curvature': 0.110,
|
|
|
|
- 'Integrated Rectified Gaussian Curvature': 0.021,
|
|
|
|
- 'Folding Index': 3,
|
|
|
|
- 'Intrinsic Curvature Index': 0.6}})],
|
|
|
|
|
|
+ [{'Structure Name': 'bankssts',
|
|
|
|
+ 'Number of Vertices': 1344,
|
|
|
|
+ 'Surface Area (mm^2)': 825,
|
|
|
|
+ 'Gray Matter Volume (mm^3)': 2171,
|
|
|
|
+ 'Average Thickness (mm)': 2.436,
|
|
|
|
+ 'Thickness StdDev (mm)': 0.381,
|
|
|
|
+ 'Integrated Rectified Mean Curvature (mm^-1)': 0.115,
|
|
|
|
+ 'Integrated Rectified Gaussian Curvature (mm^-2)': 0.028,
|
|
|
|
+ 'Folding Index': 19,
|
|
|
|
+ 'Intrinsic Curvature Index': 1.7},
|
|
|
|
+ {'Structure Name': 'transversetemporal',
|
|
|
|
+ 'Number of Vertices': 651,
|
|
|
|
+ 'Surface Area (mm^2)': 545,
|
|
|
|
+ 'Gray Matter Volume (mm^3)': 1061,
|
|
|
|
+ 'Average Thickness (mm)': 2.251,
|
|
|
|
+ 'Thickness StdDev (mm)': 0.317,
|
|
|
|
+ 'Integrated Rectified Mean Curvature (mm^-1)': 0.110,
|
|
|
|
+ 'Integrated Rectified Gaussian Curvature (mm^-2)': 0.021,
|
|
|
|
+ 'Folding Index': 3,
|
|
|
|
+ 'Intrinsic Curvature Index': 0.6}])],
|
|
)
|
|
)
|
|
def test_read(path, headers, hemisphere, whole_brain_measurements, structure_measurements):
|
|
def test_read(path, headers, hemisphere, whole_brain_measurements, structure_measurements):
|
|
stats = CorticalParcellationStats.read(path)
|
|
stats = CorticalParcellationStats.read(path)
|
|
@@ -129,16 +125,22 @@ def test_read(path, headers, hemisphere, whole_brain_measurements, structure_mea
|
|
assert hemisphere == stats.hemisphere
|
|
assert hemisphere == stats.hemisphere
|
|
assert_approx_equal(whole_brain_measurements,
|
|
assert_approx_equal(whole_brain_measurements,
|
|
stats.whole_brain_measurements)
|
|
stats.whole_brain_measurements)
|
|
- assert stats.structure_measurement_units == {
|
|
|
|
- 'Structure Name': None,
|
|
|
|
- 'Number of Vertices': None,
|
|
|
|
- 'Surface Area': 'mm^2',
|
|
|
|
- 'Gray Matter Volume': 'mm^3',
|
|
|
|
- 'Average Thickness': 'mm',
|
|
|
|
- 'Thickness StdDev': 'mm',
|
|
|
|
- 'Integrated Rectified Mean Curvature': 'mm^-1',
|
|
|
|
- 'Integrated Rectified Gaussian Curvature': 'mm^-2',
|
|
|
|
- 'Folding Index': None,
|
|
|
|
- 'Intrinsic Curvature Index': None,
|
|
|
|
- }
|
|
|
|
- assert_approx_equal(structure_measurements, stats.structure_measurements)
|
|
|
|
|
|
+ assert list(stats.structure_measurements.columns) == [
|
|
|
|
+ 'Structure Name',
|
|
|
|
+ 'Number of Vertices',
|
|
|
|
+ 'Surface Area (mm^2)',
|
|
|
|
+ 'Gray Matter Volume (mm^3)',
|
|
|
|
+ 'Average Thickness (mm)',
|
|
|
|
+ 'Thickness StdDev (mm)',
|
|
|
|
+ 'Integrated Rectified Mean Curvature (mm^-1)',
|
|
|
|
+ 'Integrated Rectified Gaussian Curvature (mm^-2)',
|
|
|
|
+ 'Folding Index',
|
|
|
|
+ 'Intrinsic Curvature Index',
|
|
|
|
+ ]
|
|
|
|
+ pandas.util.testing.assert_frame_equal(
|
|
|
|
+ left=pandas.DataFrame(structure_measurements),
|
|
|
|
+ right=stats.structure_measurements,
|
|
|
|
+ check_like=True, # ignore the order of index & columns
|
|
|
|
+ check_dtype=True,
|
|
|
|
+ check_names=True,
|
|
|
|
+ )
|