Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:freesurfer/freesurfer into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglas Greve committed Feb 22, 2022
2 parents 226211c + bab46fb commit 548b6d0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions python/freesurfer/lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,28 @@ def __init__(self):
def add_target(self, index, name=None, color=None):
self.target_lut.add(index, name, color)

@classmethod
def read(cls, filename):
rlut = cls()
with open(filename, 'r') as file:
lines = file.readlines()
for line in lines:
split = line.lstrip().split()
if not split or split[0].startswith('#'):
continue
elif len(split) == 3:
rlut.mapping[int(split[0])] = int(split[1])
else:
# goes to target lookup table
idx, name = split[:2]
if len(split) >= 5:
color = list(map(int, split[2:6]))
color[3] = 255 - color[3] # invert alpha value
else:
color = None
rlut.target_lut.add(int(idx), name, color)
return rlut


def default():
"""
Expand Down

0 comments on commit 548b6d0

Please sign in to comment.