# Handling oscilloscope bitmap data

I'm using an oscilloscope from Tektronix; its output is formatted as a $n \times (m + 2)$ matrix, where $n$ is the number of vertical divisions and $m$ the temporal scale.

The first $9\times 2$ elements are a header:

sampleData[[1 ;; 9, 1 ;; 5]]


{{Total Rows,252,0,0,0},{Top Row ,0.05,0,0,0},{Row Increment,-0.0004,0,0,0},{Total Columns,1000,0,0,0},{Left Column ,-2.875*10^-10,0,0,0},{Column Increment,1.25*10^-12,0,0,0},{Trigger Point,230,0,0,0},{Trigger Time,0,0,0,0},{Sample Interval,1.25*10^-12,0,0,0}}

Where I have removed the columns after the sixth, being all zeroes. That is the reason why I put $m + 2$ as a dimension

The remaining rows and columns constitute a bitmap of the acquired signal (I can't show the actual signal, but it's irrelevant):

sampleData[[1;;-1, 3;;-1]] = Array[RandomReal[]&,{252,1000}];

ArrayPlot@sampleData[[1;;-1, 3;;-1]]


Now, my goal is to use the header rows to add a frame to the plot with the right values (i.e. showing the actual time scale instead of the column number on the x axis, and the amplitude instead of the row number on the y axis).

So far I've only managed to do it "manually", assigning a name to each component and then adding it by playing with the ArrayPlot ticks options:

timeScale = sampleData[[9,2]];
maxAmpl = sampleData[[2,2]];
amplScale = sampleData[[3,2]];

xticks=Transpose[{Select[Range[0,Length@interfData[[1]]],IntegerQ[#/100]&],timeScale*Select[Range[0,Length@interfData[[1]]],IntegerQ[#/100]&]*10^9}];
yticks=Transpose[{Select[Range[0,Length@interfData],IntegerQ[#/50]&],maxAmpl+amplScale*Select[Range[0,Length@interfData],IntegerQ[#/50]&]}];



Which gives me this:

I wonder if there is a neater way to handle it.

## EDIT:

As suggested, I tried using DataRange to achieve this result. However, the output plot gets distorted. My steps are as follows:

First, I extract from the headers the $x,y$ boundaries:

 xRange = topRow + rowIncr * totalRows;
yRange = leftCol + colIncr * totalCols;


where the six parameters on the right-hand side are the correspondent header values. Then, I add DataRange to the plot:

ArrayPlot[Array[RandomReal[]&, {252,1000}], PlotRangePadding->None, Frame->{True,True,False,False}, FrameLabel->{"Amplitude  (u.a.)", "Time (ns)"}, DataRange{{topRow, xRange}, {leftCol, yRange}}, ImageSize->1000, ColorFunction->Function[{x}, If[x>0, ColorData["NeonColors"][x] ,White]]]


But the result is a huge image which I won't attach here to avoid wasting space. It's like every element of the array, first correctly represented as a square, now becomes a rectangle. What I was expecting was just a rescaling of the two axes, as in ListPlot. If I add AspectRatio->Full, the image size comes back to normal, but only the $0$ ticks appear, even though they're set to Automatic:

• Have you tried using the DataRange option of ArrayPlot? You should be able to extract {{xmin, xmax}, {ymin, ymax}} values from your headers; the appropriate ticks would then be generated automatically. – MarcoB Jul 31 '17 at 15:25
• @MarcoB DataRange actually distorts the whole plot instead of just rescaling the axes. Unless I'm doing something wrong with DataRange->{{xmin, xmax}, {ymin, ymax}}. – Enzo Jul 31 '17 at 15:48
• I think it would be helpful if you could include the exact code you used and the distorted result you got in your post. – MarcoB Jul 31 '17 at 16:11
• @MarcoB done. I haven't uploaded the image because it'd just occupy space. Instead, I tried to describe what happens as well as I could, – Enzo Jul 31 '17 at 16:50
• Try adjusting the AspectRatio? Perhaps you should include the image, since it's really the point of the discussion... – MarcoB Jul 31 '17 at 16:52