DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

DIADEM script to determine rate of change of a signal based on local peaks and valley

Solved!
Go to solution

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:

joshilpa_0-1658496488681.png

 

The final x_peak is 37 but it wrongly detects it as 24.

0 Kudos
Message 11 of 29
(1,707 Views)

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.

Walter_Rick_0-1658498608976.png

 

But I found a bug in case the number of values is less that 65500. Attached is the fixed script.

 

Greetings

Walter

0 Kudos
Message 12 of 29
(1,700 Views)

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?

joshilpa_0-1658501497497.png

 

0 Kudos
Message 13 of 29
(1,695 Views)

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.

Walter_Rick_0-1658726657180.png

 

Greetings

Walter

Message 14 of 29
(1,674 Views)

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)?

0 Kudos
Message 15 of 29
(1,653 Views)

Hi joshilpa,

 

Please have a look at the attached script. Is this what you are expecting?

 

Greetings

Walter

0 Kudos
Message 16 of 29
(1,644 Views)

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?

0 Kudos
Message 17 of 29
(1,636 Views)

Hi joshilpa,

 

Tray this change

Replace

iNoOfFormerChunk = 3

with

iNoOfFormerChunk = 1

Greetings

Walter

0 Kudos
Message 18 of 29
(1,629 Views)

Hi Walter,

 

Observing negative dx values after this change, there is some issue with the logic. Could you please look into this?

0 Kudos
Message 19 of 29
(1,626 Views)

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

Message 20 of 29
(1,570 Views)