Skip to content

swc to vtk converter for visualization of neuron and neural circuit simulation in ParaView

License

Notifications You must be signed in to change notification settings

DaisukeMiyamoto/swc2vtk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swc2vtk

travisci Coverage Status python-2.7,3.3,3.4-blue license paraview NEURON

SWC to VTK converter for visualizing neurons and neural circuit simulations in ParaView. This software helps making beautiful visualization of large scale multi-compartmental neuron simulations with a parallelized environment. If you need any further information, please check http://daisukemiyamoto.github.io/swc2vtk/ .

Dependency

  • tqdm
  • numpy
  • PyVTK

Install

  • $ pip install swc2vtk

Usage

Basic way to generate VTK file from one SWC file

import swc2vtk
vtkgen = swc2vtk.VtkGenerator()
vtkgen.add_swc('simple.swc')
vtkgen.write_vtk('simple.vtk')

generate a VTK file from multiple SWC files

import swc2vtk
vtkgen = swc2vtk.VtkGenerator()
vtkgen.add_swc('simple.swc')
vtkgen.add_swc('simple1.swc')
vtkgen.add_swc('simple2.swc')
vtkgen.write_vtk('combined.vtk')

set fixed value for coloring VTK file

import swc2vtk
vtkgen = swc2vtk.VtkGenerator()
vtkgen.add_swc('simple1.swc')
vtkgen.write_vtk('simple1.vtk', fixedval=0.5)

vtkgen2 = swc2vtk.VtkGenerator()
vtkgen2.add_swc('simple2.swc')
vtkgen2.write_vtk('simple2.vtk', fixedval=1.0)

set fixed value for coloring neuron in a VTK file

import swc2vtk
vtkgen = swc2vtk.VtkGenerator()
vtkgen.add_swc('simple.swc')
vtkgen.add_swc('simple1.swc')
vtkgen.add_swc('simple2.swc')
vtkgen.write_vtk('combined.vtk', coloring=True)

generate a VTK file from SWC file with simulation data

import swc2vtk
vtkgen = swc2vtk.VtkGenerator()
vtkgen.add_swc('simple.swc')
vtkgen.add_datafile('result.dat')
vtkgen.write_vtk('simple.vtk')
  • data example
    each rows correspondence to SWC compartments
-65.0
-65.0
-65.0
-65.0
  • data output example for NEURON
proc saveData() { local i localobj outfile strdef filename
    filename = $s1
    
    printf("filename: %s\n", filename)
    outfile = new File()
    outfile.wopen(filename)
    for(i=0; i<SectionNum; i=i+1){
    	  access Dend[i]
        outfile.printf("%f\n", v)
    }
    outfile.printf("\n")
    outfile.close()
}

generate VTK files from SWC file with sequential simulation data

import swc2vtk
vtkgen = swc2vtk.VtkGenerator()
vtkgen.add_swc('simple.swc')

vtkgen.add_datafile('result1.dat')
vtkgen.write_vtk('simple1.vtk')

vtkgen.clear_datafile()
vtkgen.add_datafile('result2.dat')
vtkgen.write_vtk('simple2.vtk')

vtkgen.clear_datafile()
vtkgen.add_datafile('result3.dat')
vtkgen.write_vtk('simple3.vtk')

Output Examples

Single Neuron Morphology

single

Coloring Multiple SWC Files

simulation

Single Neuron Simulation

Neural Circuit Simulation

Volume Rendering

References