LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

peak alignment

Solved!
Go to solution

I am calculating peak position for several graphs which vary slightly. This slight variation causes the position of peaks to move around. What I want to be able to do is take this peak information and realign it in columns of an array.The way I need to align my peaks is that peaks must not vary more than 5 between each graph. So if this is my raw data:

 

Raw Data.jpg

 

I want to try and align it something like this. The difference from the previous value must not be more than 5.

 

0                   236.92        281.124        303.104        325.021        366.529        0
51.2476        234.159        0                 0                   0                 366.804           402.156
52.1135        234.633        0                 0                   0                366.938        404.016
55.8257        234.826        0                 0                   0                 366.99          404.995
49.8949        234.759        276.989       0                  0                 366.993        407.033

What I want to be able to do I align peaks in such a way that only those peaks with a difference of 5 points or less from the previous sample are in the same column. I am having trouble creating columns for new peaks, and dealing with peaks when they disappear and reappear. If anyone can look at my code and
give me any tips I would be very grateful.

 

 

So far I have managed to do this however I am having trouble creating columns for new peaks. If anyone can look over my code and give me any tips I would be very grateful.

 

Thanks

 

P.S. Also in a different message someone posted http://forums.ni.com/ni/attachments/ni/170/494181/1/Sort%20Data.png This works well except the column sorting is based on the first row, not the difference between adjacent rows.

Message Edited by LVStudent on 05-02-2010 08:02 AM
Download All
0 Kudos
Message 1 of 11
(4,271 Views)
So nobody has any ideas of how I might be able to do this?
0 Kudos
Message 2 of 11
(4,247 Views)

Hi LVStudent,

 

I'm not quite sure what the pattern is here.  Can you provide a few more details? 

 

It looks like in your aligned array, you are pulling from different columns.  (ex: 236.92 is coming from the 1st column, and 234.633 is coming fom the 2nd column)

 

What does the original 2D array represent exactly? 

Tejinder Gill
National Instruments
Applications Engineer
Visit ni.com/gettingstarted for step-by-step help in setting up your system.
0 Kudos
Message 3 of 11
(4,213 Views)

Each row in the array contains the position of peaks from a signal. The position of peaks in row 1 are extracted from an acoustic signal at 0 degrees, the position of peaks in row 2 are extracted from an acoustic signal at 1 degree, the position of peaks in row 3 are extracted from an acoustic signal at 2 degrees and so on up to 360 degrees. As these acoustic signals obviously vary slightly with degrees, the position of peaks also move slightly (say no more than 5 points from one signal to the next), or these peaks disappear and reappear. This means if I want to track the behaviour of a certain peak, they don't neatly line up in columns. So basically what I am trying to do is put peak positions into columns where there is no more than a 5 point difference between peaks extracted from adjacent signals.  So if there is a peak positon of 236.92 in row 1, and in row 2 their is a value that is within +5 or -5 from 236.92, then it would be put in the same column. Next I would check the value 234.633 in row 2 and see if there is a value in row 3 that is within +5 or -5, then that would also be put in the same column. So 236.92 from row 1 would be in column 1, and 234.633 from row 2 would also be in column 1. Does that kinda make sense?

 

0 Kudos
Message 4 of 11
(4,190 Views)

Hi LV,

 

Your example data of how you want the aligned array to look doesnt appear right. You seem to be moving data from 1 row to another. Are you sure this is what you want. I would of thought that you need to keep the data within its original row but move it according to data within its column.

 

If this is what you want then this should do it:

 

Peak Align Snippet.png

 

 

 Peak Align FP.JPG

 

 

I have tested it using the data that you show in your array and it works how i think it should be done.

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 5 of 11
(4,168 Views)
Solution
Accepted by topic author eword

Hi LV,

 

I posted the wrong snippet. Use this one. This one also removes any columns that are all 0's, which can happen once they get shifted around.

 

Peak Align Snippet.png

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 6 of 11
(4,157 Views)
Thanks so much, thats just what I have been trying to do. Fabulous. Many Kudos to you.
0 Kudos
Message 7 of 11
(4,145 Views)

No Worries, glad its what your after.

Message Edited by Lucither on 05-04-2010 07:03 AM
------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 8 of 11
(4,141 Views)

Hi Lucither,

 

I was just looking over that code snippet you sent me and its very helpful, however how would I adjust it so I put data into columns where instead of the condition for adding data to a column being a difference of 5 (or whatever value) from the lowest value in the column, values are put into columns based on the difference of a value from 1 row to the next?

0 Kudos
Message 9 of 11
(4,120 Views)

Hi LV,

 

Unfortunately i am just on my way out. I will be flying to Singapore tomorrow so wont be able to look at this for you for a couple of days.

 

I will have a look at what you want though when i get time.

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 10 of 11
(4,116 Views)