I'm using xtk to read remote NIfTI volumes into an application. My sole objective is to obtain a volume object so I can extract its data; I don't need to render anything. The examples I've seen all initialize a renderer and attach a volume before accessing its contents. E.g. (from http://jsfiddle.net/QxMSt/5/):
var r = new X.renderer3D();
r.init();
var v = new X.volume();
v.file = 'http://www.cogitatum.org/mprage003.nii.gz';
r.add(v);
r.render();
r.onShowtime = function() {
r.destroy();
// get the image data
var data = v.image;
}
This works very nicely, but I'd rather not have to go to the trouble of creating a renderer for nothing, and would also prefer not to require WebGL support. Is there any way to initialize the volume and access its properties without rendering? I've looked through the codebase but don't see any place an onLoad() event or comparable is fired at the moment, though X.loader clearly tracks loading completion internally. It looks as though setting the volume's file property is sufficient to trigger volume loading, but I don't see any way to pass a callback function that gets triggered on completion. Any suggestions?
Unfortunately this is currently the only solution. The file loading starts when adding the object to the renderer.
To avoid the WebGL requirement, just use a X.renderer2D
.
A separate and generic i/o library externally from XTK is planned and should be available in the next couple of weeks.