test_annotation.py 1.8 KB

1234567891011121314151617181920212223242526272829303132
  1. import os
  2. from freesurfer_surface import Annotation
  3. from conftest import SUBJECTS_DIR
  4. def test_load_annotation():
  5. annotation = Annotation.read(os.path.join(SUBJECTS_DIR, 'fabian', 'label', 'lh.aparc.annot'))
  6. assert len(annotation.vertex_color_codes) == 155622
  7. assert annotation.vertex_color_codes[64290] == 1316060
  8. assert annotation.vertex_color_codes[72160] == 1316060
  9. assert annotation.vertex_color_codes[84028] == 14423100
  10. assert annotation.vertex_color_codes[97356] == 14423100
  11. assert annotation.vertex_color_codes[123173] == 8204875
  12. assert annotation.vertex_color_codes[140727] == 8204875
  13. assert annotation.vertex_color_codes[93859] == 10542100
  14. assert annotation.vertex_color_codes[78572] == 0
  15. assert annotation.vertex_color_codes[120377] == 0
  16. assert annotation.colortable_path == b'/autofs/space/tanha_002/users/greve' \
  17. b'/fsdev.build/average/colortable_desikan_killiany.txt'
  18. assert len(annotation.labels) == 36
  19. assert vars(annotation.labels[0]) == {'index': 0, 'name': 'unknown',
  20. 'red': 25, 'green': 5, 'blue': 25, 'transparency': 0}
  21. precentral, = filter(lambda l: l.name == 'precentral', annotation.labels)
  22. postcentral, = filter(lambda l: l.name == 'postcentral', annotation.labels)
  23. assert vars(precentral) == {'index': 24, 'name': 'precentral',
  24. 'red': 60, 'green': 20, 'blue': 220, 'transparency': 0}
  25. assert vars(postcentral) == {'index': 22, 'name': 'postcentral',
  26. 'red': 220, 'green': 20, 'blue': 20, 'transparency': 0}
  27. superiorfrontal, = filter(lambda l: l.color_code == 10542100, annotation.labels)
  28. assert superiorfrontal.name == 'superiorfrontal'