Arrange slanted raster data into square matrix
3 views (last 30 days)
Show older comments
I have data produced by a mass spectrometry imaging experiment that I would like to plot using Matlab. The problem I have encountered is that when accumulating data, the raster scan used by the instrument doesn’t make straight lines back and forth across the sample, but rather slanted ones. This results in lists of x and y locations that look something like this (here, a 9x2 matrix):
[1.1 1.1; 1.2 2.1; 1.3 3.1; 2.1 3.2; 2.2 2.2; 2.3 1.2; 3.1 1.3; 3.2 2.3; 3.3 3.3;
I have an algorithm that will take this data and arrange a matrix with the pixel number (in this case the row number) in the appropriate location relative to the other values and it gives me something like this (a 9x9 matrix):
[1 NaN NaN NaN NaN NaN NaN NaN NaN; NaN NaN NaN NaN NaN 6 NaN NaN NaN; NaN NaN NaN NaN NaN NaN 7 NaN NaN; NaN 2 NaN NaN NaN NaN NaN NaN NaN; NaN NaN NaN NaN 5 NaN NaN NaN NaN; NaN NaN NaN NaN NaN NaN NaN 8 NaN; NaN NaN 3 NaN NaN NaN NaN NaN NaN; NaN NaN NaN 4 NaN NaN NaN NaN NaN; NaN NaN NaN NaN NaN NaN NaN NaN 9;]
What I’d really like is to have a user-input that allows me to set a range so that values that vary by less than that would be grouped together, rather than being treated as unique values that merit their own row/column. For instance, I could say that if two x- or y-values vary by less than .5, they are the same and get a matrix that looks like (3x3 matrix):
[1 6 7; 2 5 8; 3 4 9;]
This is only a sample data set – my actual data sets are much larger – and it's not straight-forward to tell how many rows and columns are appropriate up front. If the script would recognize as it goes down the x- and y- data a jump larger than the defined range and use that to start the new column, that would be great. Any ideas or help you can give me is greatly appreciated!
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!