Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More detectors: MorphologyDetector #3

Open
adam2392 opened this issue Jan 7, 2021 · 4 comments
Open

More detectors: MorphologyDetector #3

adam2392 opened this issue Jan 7, 2021 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@adam2392
Copy link
Member

adam2392 commented Jan 7, 2021

Describe the problem

These are detectors that kind of have some open-source matlab code, so we can make an attempt at porting this over into mne-hfo.

Describe your solution

Import over morphologydetector: https://github.com/HFO-detect/HFO-detect-matlab/blob/master/hfo-detect-toolbox/Morphology%20Detector/func_doMorphologyDetector.m

Describe possible alternatives

Both detectors seem to have a very large number of hyperparameters, so it might be difficult to match them perfectly.

@adam2392 adam2392 added the enhancement New feature or request label Jan 7, 2021
@adam2392
Copy link
Member Author

Zurich was kind enough to send over the following detector matlab repo:

https://github.com/ZurichNCH/Automatic-High-Frequency-Oscillation-Detector

@adam2392
Copy link
Member Author

It seems the morphology detector has quite a bit of hyperparmaeters, and pipelines including a baseline step, so it would be good to sketch this out first.

@adam2392
Copy link
Member Author

Hyperparameters list I'm getting:

  1. (optional) baseline signal: passed in baseline signal, else algorithm tries to compute baseline by itself
  2. maxNoisemuV: threshold for selecting indices of the baseline signal. Either preset, or set as a standard deviation of the signal (probably best to set it as a standard deviation)
  3. baselineThreshold: threshold used for event selection based on the baseline envelope
  4. Filtbaselinethreshold: value for event selection based on baseline filtered signal

General algorithm:

  1. Load data (scikit-learn API style) and perform checks. See other detectors for how data validiation takes place.
  2. Band-pass filter and compute the envelope: BP filter with FIR filter for all channels. Upper envelope of the filtered signal is then computed.
  3. Find baseline for signal on every channel
  4. Find events of interest
  5. Post detection statistics

Sub-Functions to implement

  1. compute_envelope (I think already implemented, but needs to verify that it is the same)
  2. filterSignal is zero-phase forward/reverse IIR filtering, with coefficients set in parameters, non-recursive.

Baseline

A big chunk of code seems to be dedicated to "defining" a baseline.

  1. stockwelltransform
  2. calculate entropy (not sure if this is on the stockwell, or raw signal)
  3. get time intervals with threshold high entropy
  4. compute the channel baseline
  5. set baseline threshold

@adam2392
Copy link
Member Author

Hi @cleemesser! if you're interested in helping develop this repo out, I managed to refactor RMS/Linelenght detectors into a scikit-learn API and just working on the entire pipeline now.

Thsi isssue is one of the main ones now in my head to get this repo operational. The Morphology detector has some open-access validation data online and it's also available in matlab (just needs Python conversion).

If you're interested in contributing more, perhaps we should setup a call?

@adam2392 adam2392 added good first issue Good for newcomers help wanted Extra attention is needed labels Feb 27, 2021
@adam2392 adam2392 changed the title More detectors: CSDetector and MorphologyDetector More detectors: MorphologyDetector Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant