swc data to test with
Closed this issue · 17 comments
Got any .swc files for me to experiment with?
Here are two files, but you can download many other at
http://neuromorpho.org/
Best,
Martin
On 03.06.2015 11:58, Dealga McArdle wrote:
Got any .swc files for me to experiment with?
—
Reply to this email directly or view it on GitHub
#1.
ok, sorry, for this post. was not aware, that my attachments would be depicted as plain text. added two example files to the repository.
cool thank you!
do you have any issues? the entorhinal neuron has a long ranging projection. therefore it looks a bit wired. the other neurons looks much more like a "classical" neuron.
no it works fine, I'd use the csv importer with ' ' delimiter though instead of rolling your own file parser..
thanks for your suggestion. I was worried, that the csv-importer can't handle the comments and empty lines which usually precede the data. therefore, I used my own parser. but I will give it a try.
Yes, that could be a problem. i'm trying now :)
ok, after trying it is a little messy. never mind me.
import csv
import os
import bpy
''' read swc file '''
filepath = '/home/zeffii/Downloads/swc/swc_files/entho.CNG.swc'
with open(filepath, 'r', newline='') as csvfile:
ofile = csv.reader(csvfile, delimiter=' ')
# this makes a generator of the remaining non-empty lines
# assumes there's always a lead and trailing space.. [1:-1] , this may be evil
rows = (r[1:-1] for r in ofile if r and not r[0].startswith('#'))
# convert string representation of each line to dict of list-floats
neurons = {float(r[0].strip()): [float(i) for i in r] for r in rows}
but i'm making assumptions here about the formatting of the file, which is probably not cool.
hey, thanks for the code. When I am back at work, I will try to integrate it into the importer
in any case you have a working importer, if the csv route fails there is no loss :)
jep, the next step will be to integrate the code of https://github.com/ajayramak/BlenderSWCVizualizer into this addon. I am already in contact with ajayramak about that.
another repo with no images! :/
changed that for my repo ;)
as it should be. OK. back to work :)
btw:
rows = ([j for j in r if j] for r in ofile if r and not r[0].startswith('#'))
may be better, it doesn't assume anything, but does add iff the list item is not empty. I don't know if this is faster than your original code... it may not be..