## subset using indices ...
dp=kcs20[[10]]
dp1=subset(dp, 1:50)
# ... or an expression
dp2=subset(dp, alpha>0.7)
front=subset(dp, points[,'Z']<40)
# use a helper function
between=function(x, lower, upper) x>=lower & x<=upper
middle=middle=subset(dp, between(points[,'Z'], 40, 60))
# plot results in 3D
# \donttest{
plot3d(front, col='red')
plot3d(middle, col='green')
plot3d(dp, col='blue')
# }
if (FALSE) {
## subset using an selection function
s3d=select3d()
dp1=subset(dp, s3d(points))
# special case of previous version
dp2=subset(dp, s3d)
# keep the points that were removed from dp2
dp2.not=subset(dp, s3d, invert=TRUE)
# (another way of doing the same thing)
dp2.not=subset(dp, Negate(s3d))
stopifnot(all.equal(dp1, dp2))
dp2=subset(dp, alpha>0.5 & s3d(pointd))
dp3=subset(dp, 1:10)
## subset each dotprops object in a whole neuronlist
plot3d(kcs20)
s3d=select3d()
kcs20.partial = nlapply(kcs20, subset, s3d)
clear3d()
plot3d(kcs20.partial, col='red')
plot3d(kcs20, col='grey')
}
Run the code above in your browser using DataLab