Get Pixel Data as an array and plot it in Plotly
dvenkatsagar opened this issue · 4 comments
Hi there,
I have a set of Dicom images and I need to plot a Heatmap of a slice using the plotly.js
. I am reading the images as given in your driver.js
file. But I am not able to understand how I can pass this data as an array to the plotly library. If it was python-pydicom, there is a way to read the image as numpy array and from there, proceed with it, but when it comes to using this, I am stuck at converting the ArrayBuffer to a ndarray or standard array or typed array.
With regards
Sagar DV
I've added a new function, getInterpretedData()
, that I think may help. It was true that Daikon was only returning the raw data, which then needed to be interpreted using the header in order to make sense of it. But I agree having some kind of convenience method to do this would be handy.
The new function will handle things like byte order, number of bytes per voxel, datatype, data scales, etc. It returns an array of floating point values. So far this is only working for plain intensity data, not RGB.
Here's the usage:
var output = image.getInterpretedData([asArray [, asObject]]);
If you don't specify any arguments, it will return a Float32Array. If asArray
is true, it will return a standard JavaScript array of Numbers. If asObject
is true, it will return an object with the following properties: data
, min
, max
, minIndex
, maxIndex
.
Ok I will try it out. Thank you..
Ok, it is working now... but another small question/issue. The thing is, as I am getting the data as an array, Im passing this array to plotly Heapmap. But when I look at the plot, it shows nothing(a white screen). What I understood is that, the array is 1D and when comparing to the array retrieved by using pydicom, it gives out a 2D array.
So, is there a way to rearrange the data is such a way that it would be a multi-dimensional array the represents the image?
Ok I was able to do that... Thank you for the help.