test_annotation.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from conftest import ANNOTATION_FILE_PATH
  2. from freesurfer_surface import Annotation
  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 (
  16. annotation.colortable_path == b"/autofs/space/tanha_002/users/greve"
  17. b"/fsdev.build/average/colortable_desikan_killiany.txt"
  18. )
  19. assert len(annotation.labels) == 36
  20. assert vars(annotation.labels[0]) == {
  21. "index": 0,
  22. "name": "unknown",
  23. "red": 25,
  24. "green": 5,
  25. "blue": 25,
  26. "transparency": 0,
  27. }
  28. assert vars(annotation.labels[28]) == {
  29. "index": 28,
  30. "name": "superiorfrontal",
  31. "red": 20,
  32. "green": 220,
  33. "blue": 160,
  34. "transparency": 0,
  35. }
  36. (precentral,) = filter(lambda l: l.name == "precentral", annotation.labels.values())
  37. (postcentral,) = filter(
  38. lambda l: l.name == "postcentral", annotation.labels.values()
  39. )
  40. assert vars(precentral) == {
  41. "index": 24,
  42. "name": "precentral",
  43. "red": 60,
  44. "green": 20,
  45. "blue": 220,
  46. "transparency": 0,
  47. }
  48. assert vars(postcentral) == {
  49. "index": 22,
  50. "name": "postcentral",
  51. "red": 220,
  52. "green": 20,
  53. "blue": 20,
  54. "transparency": 0,
  55. }
  56. (superiorfrontal,) = filter(
  57. lambda l: l.color_code == 10542100, annotation.labels.values()
  58. )
  59. assert superiorfrontal.name == "superiorfrontal"