test_annotation.py 2.0 KB

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