scijs / ndarray-unpack

Converts an ndarray into an array-of-arrays
MIT License
5 stars 0 forks source link

TypeError: a0.get is not a function #1

Open dvenkatsagar opened 8 years ago

dvenkatsagar commented 8 years ago

I have 245 images, each size 512x512(A ct scan set containing a series of dicom images). I created a image volume out them using an external library and converted that to a ndarray which is in this format:

View3dgeneric {
  data: ArrayBuffer {},
  shape: [ 512, 512, 245 ],
  stride: [ 125440, 245, 1 ],
  offset: 0 
}

From there I have taken a slice of an image in the series (as they are dcm set and are in the form of a volume) like this :

var img = volume.pick(null,256,null);

and I get the output of img as this :

View2dgeneric {
  data: ArrayBuffer {},
  shape: [ 512, 245 ],
  stride: [ 125440, 1 ],
  offset: 62720 
}

Now when I try to unpack the image like this :

console.log(unpack(img))

It gives me an error message as given in the title :

undefined:13
    _inline_1_v[index[index.length-1]]=a0.get(p0)
                                          ^

TypeError: a0.get is not a function
    at unpackCwise_cwise_loop_1s0m2g (eval at generateCWiseOp (/usr/lib/node_modules/ndarray-unpack/node_modules/cwise/node_modules/cwise-compiler/lib/compile.js:351:11), <anonymous>:13:43)
    at unpackCwise_cwise_thunk (eval at createThunk (/usr/lib/node_modules/ndarray-unpack/node_modules/cwise/node_modules/cwise-compiler/lib/thunk.js:82:15), <anonymous>:7:53)
    at Function.unpack (/usr/lib/node_modules/ndarray-unpack/unpack.js:19:3)
    at /home/sagar/Repositories/Scripts/Projects/node/boneAR/boneAR/CTGen.js:121:27
    at daikon.Series.concatenateNextImageData (/home/sagar/Repositories/Scripts/Projects/node/boneAR/boneAR/daikon-min.js:17:1252)
    at null.<anonymous> (/home/sagar/Repositories/Scripts/Projects/node/boneAR/boneAR/daikon-min.js:17:1671)
    at null._onTimeout (/home/sagar/Repositories/Scripts/Projects/node/boneAR/boneAR/daikon-min.js:17:22391)
    at Timer.listOnTimeout (timers.js:92:15)

Is there way to get around this problem. The basic example given in the docs work, but when it comes to this, it doesnt work for some reason.

With regards, Sagar DV

mikolalysenko commented 8 years ago

It is because your data type is an arraybuffer. If you convert it to an array or array-like object, then everything should be ok. For example, just converting it into a Uint8Array by doing var array = new Uint8Array(arraybuffer) should work.

dvenkatsagar commented 8 years ago

Ok that worked. Thank you.