diff -r 19aaf0f68bc1 share/lib/hoc/import3d/import3d_sec.hoc --- a/share/lib/hoc/import3d/import3d_sec.hoc Sun Apr 24 09:00:59 2011 -0400 +++ b/share/lib/hoc/import3d/import3d_sec.hoc Thu May 05 11:07:00 2011 -0400 @@ -115,7 +115,11 @@ proc mkglyph() {local i, d1, d2 localobj x, y, norm, x1, y1, i1 g = new Glyph() - if (xyz.ncol - first < 2) { return } + if (xyz.ncol - first < 2) { + // must be single point soma from swc + circle(xyz.x[0][0], xyz.x[1][0], d.x[0]/2) + return + } // normal x1 = xyz.getrow(0) y1 = xyz.getrow(1) @@ -383,4 +387,28 @@ return x } +proc circle() { + x = $1 + y = $2 + r = $3 + + p0 = 1.00000000 * r + p1 = 0.89657547 * r // cos 30 * sqrt(1 + tan 15 * tan 15) + p2 = 0.70710678 * r // cos 45 + p3 = 0.51763809 * r // cos 60 * sqrt(1 + tan 15 * tan 15) + p4 = 0.26794919 * r // tan 15 + g.path() + g.m(x+p0, y) + g.curve(x+p2, y+p2, x+p0, y+p4, x+p1, y+p3) + g.curve(x, y+p0, x+p3, y+p1, x+p4, y+p0) + g.curve(x-p2, y+p2, x-p4, y+p0, x-p3, y+p1) + g.curve(x-p0, y, x-p1, y + p3, x-p0, y+p4) + g.curve(x-p2, y-p2, x-p0, y-p4, x-p1, y-p3) + g.curve(x, y-p0, x-p3, y-p1, x-p4, y-p0) + g.curve(x+p2, y-p2, x+p4, y-p0, x+p3, y-p1) + g.curve(x+p0, y, x+p1, y-p3, x+p0, y-p4) + g.close() + g.s(1,3) +} + endtemplate Import3d_Section diff -r 19aaf0f68bc1 share/lib/hoc/import3d/read_swc.hoc --- a/share/lib/hoc/import3d/read_swc.hoc Sun Apr 24 09:00:59 2011 -0400 +++ b/share/lib/hoc/import3d/read_swc.hoc Thu May 05 11:07:00 2011 -0400 @@ -13,6 +13,7 @@ double a[7] proc init() { + single_point_root = 0 filetype = "SWC" vectors = new List() header = new List() @@ -183,9 +184,9 @@ // however warn if the first two points do not have the same type if ( type.x[0] != type.x[1]) { err = 1 -printf("\nNotice: %s:\nThe first two points have different types (%d and %d) but\n a single point root section is not allowed.\n Changing point id %d so that it is type %d.\n If this is an incorrect repair, then change the file.\n"\ -, file.getname, type.x[0], type.x[1], pt2id(1), type.x[0]) - type.x[1] = type.x[0] +printf("\nNotice: %s:\nThe first two points have different types (%d and %d) but\n a single point root section is not allowed.\n Adding a few points of type %d before and after the first point\n so that it looks like a sphere.\n Children will be logically connected to the center point\n with pt3dstyle(1,...).\n If this is an incorrect repair, then change the file.\n"\ +, file.getname, type.x[0], type.x[1], type.x[0]) + single_point_root = 1 } $o1 = new Vector(id.size) @@ -228,6 +229,13 @@ if (pid.x[first] == 0) { sec.parentx = 0 } sec.append(0, pid.x[first], 1, x, y, z, d) sec.append(1, first, i-first, x, y, z, d) + if (single_point_root && pid.x[first] == 0) { + sec.parentx = 0.5 // middle + sec.first = 1 + } + }else if (single_point_root) { + sec = new Import3d_Section(first, 1) + sec.append(0, first, 1, x, y, z, d) }else{// pid not first point in root section sec = new Import3d_Section(first, i-first) sec.append(0, first, i-first, x, y, z, d)