LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Thresholding 1D array

Solved!
Go to solution

Hello everyone,

I have a relatively simple task that I'm banging my head to try and solve.  Basically, I have a 1D array of doubles, and I need to delete the outliers from this array.  I'm defining an outlier as 1.5 times the standard deviation of the array.  Any thoughts?  This should be simple, but the only solutions I can come up with involve Case Structures inside of For loops and multiple copies of my array.  I should think there would be an efficient way of doing this, but I just can't think of it.  Thanks for the help!

 

Matt

0 Kudos
Message 1 of 9
(4,245 Views)
Solution
Accepted by topic author McMurray
0 Kudos
Message 2 of 9
(4,239 Views)

Saverio already provided you with a good link. Please read it! 🙂

 

Still, please define what you mean by "remove". If you simply delete these outliers, you will change the indices of all other elements, thus you change the x information, which is now no longer linear.

 

Another option would be to replace the outliers with something else (e.g. the SD value of the array, the average of the immediate neightbors, etc) while keeping the array size (and X information!) constant.

 

Can you tell us a bit more about your application?

Message 3 of 9
(4,226 Views)

Thanks for all the help you two!  I wonder why my search didn't bring that up...

 

As for an overview of the application, I'm working with a previously recorded ECG signal, which has numerous artifacts due to subject movement, etc.  I'm trying to cull out the extremely odd data based on the interval between each peak (called the R-R inteval).  For example, an interval of 0.15 seconds would be ridiculous, as would an interval of 40 seconds.  I have about 10 minutes of data recorded, so I'm basing the "culling" on the mean R-R interval and standard deviation.

 

I've adapted the code from the link smercurio suggested, but for some reason the array indexing isn't working.  The output is an array of the correct size, but composed entirely of the first number repeating.  I've attached the vi.  Thoughts?

0 Kudos
Message 4 of 9
(4,191 Views)

You use the wrong VI in the case structure. Replace "insert into array" with "replace array subset" and you should be all good. 😄

 

Still, since you change the size of the array, your timing will be off. Instead, you should do someting along the lines I mentioned above.

0 Kudos
Message 5 of 9
(4,182 Views)

Oh, I'm dumb.  Thanks.

 

I'm not too interested in the timing, just the R-R interval.  I don't mind that loss of data if it means my R-R estimates will be better.  Thanks.

0 Kudos
Message 6 of 9
(4,174 Views)
I don't understand why the estimates would be better if you remove points. With each deletion you are moving the data closer together, thus shrinking the intervals.
0 Kudos
Message 7 of 9
(4,167 Views)

I probably should have explained the 1D array a little better.  That might help explain why this is helpful.  The array is currently only composed of the intervals, and has no relationship to the order or time at which they were collected.  So, deleting a few extraneous points doesn't change the intervals themselves, just the mean and standard deviation since the outliers have been removed.

0 Kudos
Message 8 of 9
(4,161 Views)
Ah, ok. Now it makes sense. 🙂
0 Kudos
Message 9 of 9
(4,157 Views)