Skip to content

Commit

Permalink
Merge pull request #60 from brainglobe/remove-swc-repair
Browse files Browse the repository at this point in the history
Remove SWC file repair method
  • Loading branch information
alessandrofelder authored Apr 26, 2024
2 parents 9cd4a8b + fb9bea5 commit 118c7e7
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions morphapi/morphology/morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,44 +73,10 @@ def load_from_file(self):
else:
self.load_from_swc()

def repair_swc_file(self):
"""
Fixes this: https://github.com/BlueBrain/NeuroM/issues/835
"""
with open(self.data_file, "r") as read:
content = read.readlines()

clean = []
for line in content:
if not len(line):
clean.append(line)
continue

line = line.replace("\n", "").replace("\t", " ")
vals = line.split(" ")
if len(vals) < 2:
clean.append(line)
continue

if vals[1] != "1" and vals[-1] == "-1":
vals[-1] = "0"
clean.append(" ".join(vals))
else:
clean.append(line)

if len(clean) != len(content):
raise ValueError

with open(self.data_file, "w") as write:
for line in clean:
write.write(f"{line}\n")

def load_from_swc(self):
if self.neuron_name is None:
self.neuron_name = self.data_file.name

self.repair_swc_file()

nrn = nm.load_morphology(self.data_file)

# Get position and radius of some
Expand Down

0 comments on commit 118c7e7

Please sign in to comment.