On 12-11-17 1:51 PM, John Muschelli wrote:
That works! Thanks for the help, but I can't seem to figure out why
this happens with even one contour in the example below:
Disclaimer: using MNI template from FSL
(http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Atlases).
Firefox still has array initialiser too large for this one contour, but
Safari and Chrome both will render it, but again it comes out half of a
brain and the vertices are connected across the brain and not a surface.
The code is the same as with the example from AnalyzeFMRI, but a
different dimension for the array and a different level (Also attached).
There's a thread from last year here:
https://www.khronos.org/webgl/public-mailing-list/archives/1102/msg00093.html
that says that WebGL is limited to 65535 vertices in any object. I
assume that limit is still in effect, and your scenes probably have too
many vertices.
The writeWebGL function doesn't do any checks for things like this.
I'll think about having it split up objects as required, but in the
meantime, you'll need to do it yourself.
Duncan Murdoch
template<- f.read.nifti.volume("MNI152_T1_2mm_brain.nii")
template<-template[,,,1]
contour3d(template,x=1:dim(template)[1],y=1:dim(template)[2],z=1:dim(template)[3],level=c(1000),alpha
=c(0.2),color =c("white"))
browseURL(paste("file://",writeWebGL(dir=file.path(tempdir(),"webGL"),
width=500), sep=""))
On Fri, Nov 16, 2012 at 8:37 PM, Duncan Murdoch
<murdoch.dun...@gmail.com <mailto:murdoch.dun...@gmail.com>> wrote:
On 12-11-16 7:09 PM, John Muschelli wrote:
The contour its just half a brain and the vertices are not
surfaces and
are filled in
Sounds like a bug in the browser. When I try it in Firefox 16.0.2
it doesn't display properly; the error log (found via Tools | Web
developer | Error console has several errors in it, the first of
which is:
Error: array initialiser too large
That's clearly a limitation of the browser. You might be able to
work around it by plotting one layer at a time; writeWebGL will
write each rgl object in separate arrays of data. If the layers are
separate, the browser might be able to handle them. I just tried
this, and it works on my system, using this code:
contour3d(a, 1:64, 1:64, 1.5*(1:21), lev=c(3000),
alpha = c(0.2), color = c("white"))
contour3d(a, 1:64, 1:64, 1.5*(1:21), lev=c(8000),
alpha = c(0.5), color = c("red"), add=TRUE)
contour3d(a, 1:64, 1:64, 1.5*(1:21), lev=c(10000),
alpha = c(1), color = c("green"), add=TRUE)
followed by the browseURL call you already had.
Duncan Murdoch
This was sent from a mobile phone so please excuse any
misspellings or
typos.
On Nov 16, 2012 6:55 PM, "Duncan Murdoch"
<murdoch.dun...@gmail.com <mailto:murdoch.dun...@gmail.com>
<mailto:murdoch.duncan@gmail.__com
<mailto:murdoch.dun...@gmail.com>>> wrote:
On 12-11-16 5:59 PM, John Muschelli wrote:
I saw that in rgl:::writeWebGL that "Polygons will only be
rendered as
filled; there is no support in WebGL for wireframe or point
rendering.". I
found that you can easily use contour3d to make
reproducible
contour web
figures, such as (taken from contour3d help)
library(AnalyzeFMRI)
a <-
f.read.analyze.volume(system.____file("example.img", package=
"AnalyzeFMRI"))
a <- a[,,,1]
contour3d(a, 1:64, 1:64, 1.5*(1:21), lev=c(3000),
alpha = c(0.2), color = c("white"))
browseURL(paste("file://",
writeWebGL(dir=file.path(____tempdir(),
"webGL"),
width=500), sep=""))
But I found problems with multiple levels, such as
contour3d(a, 1:64, 1:64, 1.5*(1:21), lev=c(3000,
8000, 10000),
alpha = c(0.2, 0.5, 1), color =
c("white", "red",
"green"))
browseURL(paste("file://",
writeWebGL(dir=file.path(____tempdir(),
"webGL"),
width=500), sep=""))
Does anyone know why this happens, or a way to fix it
(maybe
using separate
= TRUE for contour3d)?
Why what happens?
Duncan Murdoch
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.