07-22-2022 08:29 AM - edited 07-22-2022 08:30 AM
Hi Walter,
Thanks for sharing the script but there is some issue with the logic where it is skipping the first valley and the last peak, could you please explain why does this happen and how to fix it?
From the data 3 is the first valley but x_valley starts with 1 as below:
The final x_peak is 37 but it wrongly detects it as 24.
07-22-2022 09:04 AM
Hi joshilpa
What is the dataset you have use for the test? If I use the test data that you have provided is seems to be OK.
But I found a bug in case the number of values is less that 65500. Attached is the fixed script.
Greetings
Walter
07-22-2022 09:44 AM - edited 07-22-2022 09:52 AM
Hi Walter,
I am using the test.csv data set(attaching it again), here 3 is the first valley but it detects 1:
Signal | x_peak | x_valley |
3 | 13 | 1 |
13 | 32 | 5 |
1 | 34 | 14 |
32 | 16 | 6 |
5 | 26 | 9 |
34 | 31 | 27 |
32 | 36 | 12 |
14 | 30 | 11 |
Below is the end of the signal data here 14 & 37 are the final valley and peak which got missed as well:
40 |
24 |
37 |
14 |
Could you please tell me how are you plotting the below graph?
07-25-2022 12:24 AM
Hi joshilpa,
The DIAdem PeakFind function calculates local minima and maxima. A local minimum requires a higher value before and one behind the minimum. A local maximum requires a smaller value before and one after the maximum. By definition, the first and the last value can neither be a local minimum nor a local maximum.
Greetings
Walter
07-25-2022 04:15 PM
Hi Walter,
Thanks for explaining the definitions of peaks and valleys.
Here we are trying to calculate the dx = xpeak - xvalley where the xvalley occurs 1st followed by a peak so tpeak> tvalley
How can we fix the script so it makes sure it is subtracting 2 consecutive peaks and valleys where the valley occurs before the peak (ie tvalley < tpeak)?
07-26-2022 01:10 AM
Hi joshilpa,
Please have a look at the attached script. Is this what you are expecting?
Greetings
Walter
07-26-2022 03:26 AM
Hi Walter,
The script works for only few scenario. When testing the script on the attached sample (test_error_sample.csv) I am seeing negative dt values in the output which is not expected.
Could you please suggest a fix for this in the script?
07-26-2022 07:13 AM
Hi joshilpa,
Tray this change
Replace
iNoOfFormerChunk = 3
with
iNoOfFormerChunk = 1
Greetings
Walter
07-26-2022 07:21 AM
Hi Walter,
Observing negative dx values after this change, there is some issue with the logic. Could you please look into this?
08-01-2022 12:37 AM
Hi joshilpa,
Depending on the data, there was still a problem at the chunk boundaries. Here is a new version.
Please note that this is only an example that shows how I would solve such a problem.
Greetings
Walter