Comments (8)
It looks like the file is a mix of tab and space separators. See this:
>>> # With default separator
>>> pd.read_csv('VFB_00023647_snt_skel-000.swc', header=None, skiprows=6)
0
0 1\t0\t231.908032 219.526534 88.631724 0.000000...
1 2\t0\t232.426842 219.007559 88.631724 0.000000\t1
2 3\t0\t232.945652 219.007559 88.631724 0.000000\t2
3 4\t0\t233.464462 219.007559 88.631724 0.000000\t3
4 5\t0\t233.983271 219.007559 88.631724 0.000000\t4
>>> # With tab separator
>>> pd.read_csv('VFB_00023647_snt_skel-000.swc', header=None, skiprows=6, sep='\t')
0 1 2 3
0 1 0 231.908032 219.526534 88.631724 0.000000 -1
1 2 0 232.426842 219.007559 88.631724 0.000000 1
2 3 0 232.945652 219.007559 88.631724 0.000000 2
3 4 0 233.464462 219.007559 88.631724 0.000000 3
4 5 0 233.983271 219.007559 88.631724 0.000000 4
Bottom line: that's an issue with pandas (or the underlying Python csv parser) not being able to disentangle the mix of separators. Is there a way to change the output of the simple neurite tracer? Alternatively, you could write a little script to clean up the file(s). navis.read_swc
has a delimiter
parameter which defaults to ' '
whitespace and is passed directly to pandas.read_csc
.
from navis.
Ah: a workaround is using a regex separator.
pd.read_csv('VFB_00023647_snt_skel-000.swc', header=None, skiprows=6, sep='\s+')
n = navis.read_swc('VFB_00023647_snt_skel-000.swc', delimiter='\s+')
from navis.
By-the-by: it struck me that the neuron has one one root and one end node - no branch points. Did you realize that this is one continuous line? I.e. when a neurite "ends" the skeleton just turns around, forms a loop and tracks back.
from navis.
Thanks, I just realised that the file seems to have arbitary number of spaces as delims and your solution to set the seperator as \s+
, seems to have done the trick.
The neuron (tracing) actually looks fine when i plot it see below:
Perhaps I need to reroot it, somehow to produce the branch points?
I was just trying to do some covisualisation of gal4line
, hemibrain
, flywire
neuron ( ilPN
) as an example here:
https://github.com/SridharJagannathan/pyroglancer/blob/master/pyroglancer/examples/gal4line2flywire.ipynb
from navis.
It will plot just fine but anything that requires correct topology will fail or produce nonsensical results.
from navis.
I tried to cut the neuron and then stitch them back together, that seems to have produced branches, however i can see that there are loops inside the neuron, do you know how to eliminate them, basically i'm thinking of an approach to use the pts to construct a graph, and then use the graph to construct the neuron.
vfb_neuron = navis.read_swc(swc_files, delimiter='\s+')
fragments = navis.cut_neuron(vfb_neuron, 500)
stitched = navis.stitch_neurons(fragments, method='ALL')
from navis.
With 84cfe9f I just pushed a first pass implementation for a function that resolves this (albeit not perfectly):
>>> n = navis.read_swc('VFB_00023647_snt_skel-000.swc', delimiter='\s+')
>>> fx = navis.graph.clinic.merge_duplicate_nodes(n)
>>> fx
type navis.TreeNeuron
name VFB_00023647_snt_skel-000
n_nodes 1422
n_connectors None
n_branches 59
n_leafs 61
cable_length 1106.133057
soma None
units 1 micrometer
You can see it now has proper leafs and branches. However when co-visualizing it, you will notice that some edges got removed (red) to break up cycles after node collapse. It's better than before but not perfect.
from navis.
I'll close this issue. Re-open if you feel this is unresolved.
from navis.
Related Issues (20)
- cut_skeleton memory issues HOT 2
- Minor: documentation on navis.Volume HOT 1
- Thoughts on synblast HOT 1
- Set DYLD_LIBRARY_PATH for elastix on MacOS HOT 2
- Custom colored connectors in plot2d is broken
- New numpy version leads to AttributeError HOT 5
- Traversal model make new nodes which is not in edges HOT 5
- feature request: cable_overlap returns neuron or node_list HOT 2
- Error in navis.plot3d when radius = True HOT 3
- Handle symlinked `transformix` executables HOT 1
- Excitatory / Inhibitory information about synapses in neuprint HOT 2
- Advice for M1 mac installation HOT 8
- Mapping TreeNeuron presynapses to postsynaptic bodyID HOT 2
- improve strahler_index HOT 4
- read_swc: strange behaviour when file path contains typo HOT 2
- New feature: split connectivity HOT 3
- Bug changing connector size in navis.2d_plot() HOT 2
- Make function signatures more consistent
- New system for ultrastructural features
- Make nbl.smat.LookupNdBuilder more generic HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from navis.