Skip to content

Commit

Permalink
add number of peaks features to sharpwaves (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
timonmerk authored Aug 30, 2024
1 parent c7f7192 commit bd06edc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions py_neuromodulation/nm_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ sharpwave_analysis_settings:
sharpwave_features:
peak_left: false
peak_right: false
num_peaks: false
trough: false
width: false
prominence: true
Expand Down
6 changes: 6 additions & 0 deletions py_neuromodulation/nm_sharpwaves.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class PeakDetectionSettings(NMBaseModel):
class SharpwaveFeatures(BoolSelector):
peak_left: bool = False
peak_right: bool = False
num_peaks: bool = False
trough: bool = False
width: bool = False
prominence: bool = True
Expand Down Expand Up @@ -368,6 +369,11 @@ def analyze_waveform(self, data) -> dict:
# results["sharpness"] = ((trough_height - left_height) + (trough_height - right_height)) / 2
results["sharpness"] = trough_height - 0.5 * (left_height + right_height)

if self.sw_settings.sharpwave_features.num_peaks:
results["num_peaks"] = [
trough_idx.shape[0]
] # keep list to the estimator can be applied

if self.need_steepness:
# steepness is calculated as the first derivative
steepness: np.ndarray = np.concatenate((np.zeros(1), np.diff(data)))
Expand Down

0 comments on commit bd06edc

Please sign in to comment.