flashvideosynchronization icon indicating copy to clipboard operation
flashvideosynchronization copied to clipboard

ramp detection not working well (with fix)

Open f-dy opened this issue 8 months ago • 0 comments

Hi, First, let me thank you for this code and the paper. I think this is a great problem and I like your solution. However, I found that there are issues with the ramp_detection function, even on the sample data: it sometimes detects small peaks that are far away from the actual ramp.

Let us inspect how the start of the flash is detected currently:

# wrong
start = np.flatnonzero(profile[:max_pos] > ramp_detection_thresh)[0]

The problem is that it will return any small peak above ramp_detection_thresh from the beginning of the image to the max of the profile (which is inside the flash).

Instead, it should detect the first value below ramp_detection_thresh from the max of the profile to the beginning of the image:

# ok
start = max_pos - np.flatnonzero(profile[max_pos::-1] <= ramp_detection_thresh)[0]

Similarly, for the end of the flash, the current code is:

# wrong
end = max_pos + np.flatnonzero(profile[max_pos:] > ramp_detection_thresh)[-1]

but should be:

# ok
end = max_pos + np.flatnonzero(profile[max_pos:] <= ramp_detection_thresh)[0]

Do you want to do the change yourself, or should I publish a PR?

f-dy avatar May 21 '25 15:05 f-dy