test_annotation.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334
  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_label_index) == 155622
  7. assert annotation.vertex_label_index[64290] == 22
  8. assert annotation.vertex_label_index[72160] == 22
  9. assert annotation.vertex_label_index[84028] == 24
  10. assert annotation.vertex_label_index[97356] == 24
  11. assert annotation.vertex_label_index[123173] == 27
  12. assert annotation.vertex_label_index[140727] == 27
  13. assert annotation.vertex_label_index[93859] == 28
  14. assert annotation.vertex_label_index[78572] == 0
  15. assert annotation.vertex_label_index[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. assert vars(annotation.labels[28]) == {'index': 28, 'name': 'superiorfrontal',
  22. 'red': 20, 'green': 220, 'blue': 160, 'transparency': 0}
  23. precentral, = filter(lambda l: l.name == 'precentral', annotation.labels.values())
  24. postcentral, = filter(lambda l: l.name == 'postcentral', annotation.labels.values())
  25. assert vars(precentral) == {'index': 24, 'name': 'precentral',
  26. 'red': 60, 'green': 20, 'blue': 220, 'transparency': 0}
  27. assert vars(postcentral) == {'index': 22, 'name': 'postcentral',
  28. 'red': 220, 'green': 20, 'blue': 20, 'transparency': 0}
  29. superiorfrontal, = filter(lambda l: l.color_code == 10542100, annotation.labels.values())
  30. assert superiorfrontal.name == 'superiorfrontal'