Closed dvenkatsagar closed 8 years ago
Well, for now the only work around is to go for the traditional approach or use the module ndarrays.js to get things done.
...
series.buildSeries();
var r = series.images[0].getRows();
var c = series.images[0].getCols();
var no = series.images.length;
var volume_buffer = new Array(no);
var i = no, j = 0,k = 0;
while(i--){
var slice_buffer = series.images[j++].getInterpretedData(true);
volume_buffer[j-1] = slice_buffer;
}
var slice = ndarray(new Float32Array(volume_buffer[115]),[r,c]);
...
The weird thing is that, if I try to convert all the images to a single Float32Array
/Array
like this :
...
series.buildSeries();
var r = series.images[0].getRows();
var c = series.images[0].getCols();
var no = series.images.length;
var volume_buffer = new Array(r*c*no);
var i = no, j = 0,k = 0;
while(i--){
var slice_buffer = series.images[j++].getInterpretedData(true);
var l = slice_buffer.length, m = 0;
while(l--){
volume_buffer[k++] = slice_buffer[m++]; // A single stream
}
}
var volume = ndarray(new Float32Array(volume_buffer),[r,c,no]);
var slice = volume.pick(null,null,115);
...
The images dont show up correct. I dont know what I am doing wrong here.
Can you post a screenshot of what it looks like? Is it just noise or do you see some pattern?
It comes as a pattern i guess. Here is the link
Based on the image, it looks like somewhere the dimensions are wrong. Try swapping c and r? The data is usually ordered by column then row.
var volume = ndarray(new Float32Array(volume_buffer),[c,r,no]);
I think that wouldnt help as the ndarray.shape
is a array. from the looks of it, the images are of size 512x512, so because of that, it will give the same result i guess.
Ok I was able to fix it.... it was the way the array is stored in the ndarray, i changed the order as [no,r,c]
and it worked
I assume that the function
series.concatenateImageData
gives a single stream of data of all the images as a raw ArrayBuffer.Is there a way to convert this buffer to sensible data like something similar to the image.getInterpretedData()? Or simple by creating a Float32Array out of it would suffice?