WIDEFIELD: Add TraceMetrics integration to WidefieldAnalysis for trace analysis#93
WIDEFIELD: Add TraceMetrics integration to WidefieldAnalysis for trace analysis#93iezqrom wants to merge 2 commits intowidefield-devfrom
Conversation
iezqrom
commented
Dec 18, 2025
- Updated init.pyi to include TraceMetrics in exports.
- Implemented get_trace_metrics method in WidefieldAnalysis for analyzing 1D traces with detailed documentation and error handling.
- Updated __init__.pyi to include TraceMetrics in exports. - Implemented get_trace_metrics method in WidefieldAnalysis for analyzing 1D traces with detailed documentation and error handling.
| if len(trace_segment) < 3: | ||
| return None, None | ||
|
|
||
| first_deriv = np.diff(trace_segment) |
There was a problem hiding this comment.
I have a question here is np.diff better than np.derivative for the detection of the first derivative or is it the same ?
There was a problem hiding this comment.
can't find np.derivative as a function in numpy? did you mean something else
There was a problem hiding this comment.
okay i looked for this and turns out the np.diff calculates the differences between each point and it produces always shorter array by one value where np.gradient calclulates the slop and it is always the same lenght array as the input so i guess depends where you use it
There was a problem hiding this comment.
so maybe np.diff makes sense to see the latency to the peak for example but np.gradient to see how fast the response reaches the peak ? maybe i am thinking this too much
There was a problem hiding this comment.
you are right to question diff vs gradient, but i think they can both be used for the same things and it seems like np.gradient is slightly better for a few reasons like what you mention and it is less noise-sensitive
i'll change it