# nts2swc.awk # an awk script by Giorgio A. Ascoli (ascoli@gmu.edu) # to convert ArborVitae "seg" files into Southampton's SWC format # Current version 1.1 # Last modified 5/29/2000 # Usage: awk -f nts2swc.awk inputname > outputname # # References: 1. Aho A.V., Kernighan B.W., Weinberger P.J. (1988): # The AWK Programming Language (Addison Wesley, New York). # # 2. Cannon R.C., Turner D.A., Pyapali G.K., Wheal H.V. (1998): # An on-line archive of reconstructed hippocampal neurons. # J. Neurosci. Methods 84(1-2):49-54. # # 3. Rapp M., Segev I., Yarom Y. (1994): # Physiology, morphology, and detailed passive models of guinea-pig cerebellar Purkinje cells. # J. Physiol. 474(1):101-118. # # BEGIN { print "# converted from amaral's file" print "# by GAA's nts2swc" print "#" print "" print " 1 1 0 0 0 0 -1" myid = 1 } $2 == "MTO" { skip = 0 if (substr($8, 1, 1) == "d") { if (substr($8, 2, 1) == "a") tag = 3 else tag = 4 } else tag = 5 if (skip == 0) { myid++ lastparid = myid myparid = 1 lastbra = 0 braid[0] = -1 print ("", myid, tag, $4, $5, $6, 0.5*$7, myparid) } } $2 == "CP" || $2 == "FS" { if (skip == 0) { myid++ myparid = lastparid lastparid = myid print ("", myid, tag, $4, $5, $6, 0.5*$7, myparid) } } $2 == "BP" { if (skip == 0) { myid++ myparid = lastparid lastparid = myid lastbra++ braid[lastbra] = myid print ("", myid, tag, $4, $5, $6, 0.5*$7, myparid) } } $2 == "NE" || $2 == "BAE" || $2 == "ES" || $2 == "MAE" || $2 == "TAE" { if (skip == 0) { myid++ myparid = lastparid lastparid = braid[lastbra] lastbra-- print ("", myid, tag, $4, $5, $6, 0.5*$7, myparid) } }