Skip to content

Instantly share code, notes, and snippets.

@mhl
Created February 22, 2011 14:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mhl/838695 to your computer and use it in GitHub Desktop.
In Fiji display SWC files in the 3D Viewer
import re
import os
from java.awt import Color
from ij3d import Image3DUniverse
univ = Image3DUniverse(512, 512)
univ.show()
# d = '/home/mark/painting-demo/static/data'
d = '/home/mark/tracing-examples/'
swc_files = [ os.path.join(d,x) for x in os.listdir(d) if re.search('(?i)\.swc',x) ]
# Just take the first 3 largest files:
swc_files.sort( key=os.path.getsize, reverse=True )
swc_files[-3:len(swc_files)]
from tracing import PathAndFillManager
pafm = PathAndFillManager(500, # width
500, # height
50, # depth
1, # x spacing
1, # y spacing
1, # z spacing
"micrometres")
for swc_file in swc_files:
if not pafm.importSWC(swc_file,False): # second parameter is ignoreCalibration
IJ.error("Failed to load: "+swc_file)
for i in range(pafm.size()):
path = pafm.getPath(i)
path.addTo3DViewer(univ, Color.blue, None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment