This code is intended to be used for the detection of High Frequency Oscillations (HFO) in the following data:
- Electroencephalogram EEG (Untested)
- Electrocorticography ECog (Tested)
- intra-cranial Electroencephalogram iEEG (Tested)
HFO are recognized as biomarkers for epileptogenic brain tissue. HFOs are generally viewed as spontaneous EEG patterns in the frequency range between 80 to 500 Hz that consist of at least four oscillations that clearly stand out of the background activity. HFO Review
Interictal HFOs have proven more specific in localizing the seizure onset zone (SOZ) than spikes and have presented a good association with the post-surgery outcome in epilepsy patients. We thus validated the clinical relevance of the HFO area in the individual patient with an automated procedure. This is a prerequisite before HFOs can guide surgical treatment in multi-centre studies.
Automatic detection of high frequency oscillations during epilepsy surgery predicts seizure outcome.
Human intracranial high frequency oscillations (HFOs) detected by automatic time-frequency analysis
Automatic detection of high frequency oscillations during epilepsy surgery predicts seizure outcome
Resection of high frequency oscillations predicts seizure outcome in the individual patient
High frequency oscillations in scalp EEG mirror seizure frequency in the individual patient.
The parameters are read from a pre-created "Para.mat" file. The .mat-file contains a struct called "DetPara". Within the struct DetPara the following variables can be found. See the excell file in the relevant folder.
The data file is stored as "Data.mat" with the read-variables given below as well as the computed variable below that.
%%
DataFileLocation % file location of the data, usually given in a script.
%% read
sampFreq = data.fs; % Sampling frequency (SCALAR VALUE)
channelNames = data.lab_bip; % Channel names (CELL OF STRINGS)
dataSetup = data.Datasetup; % Electrode dimensions (STRUCT)
signal = data.x_bip'; % Bipolar data (channel-by-sample ARRAY)
%% computed
maxIntervalToJoin = maxIntervalToJoinPARA*sampFreq;
MinHighEntrIntvLen = MinHighEntrIntvLenPARA*sampFreq;
minEventTime = minEventTimePARA*sampFreq;
sigDurTime = length(signal)/sampFreq;
nbChannels = length(channelNames);
Varaibles | Description |
---|---|
filtSig | The signal filtered using filter parameters specified in |
filtSignal | Filtered signal. |
Envelope | Envelope of the signal w.r.t the filtered signal. |
baseline: | The filtered signal is searched for intervals of high entropy. |
maxNoisemuV | filtered signal dependent threshold for selecting IndBaseline. |
baselineThr | A values used in event selection based on baseline(envelope). |
FiltbaselineThr | A values used in event selection based on baseline(filtered signal). |
IndBaseline | Indeces of the the signal that are taken for baseline calculation. |
HiEntropyIntv | Indexes of high entropy. |
Events: | Collects information on events of interest detected. |
EventNumber | Number of events detected per channel as entries (Cell containing integers). |
Markings.start | Start-index of events. |
Markings.end | End-index of events. |
Markings.len | Length in samples of events. |
EventProp | Cell of tables containing properties of the events detected per channel. |
Rates | EventNumber devided by duration of signal in minutes. |
The detector is based on thresholding the signal for various power, morphology and energy properties.
- Stage 0: Loading parameters, data and checking for specification inconsistencies.
- In this step all the pre-set parameters are centralized and loaded.
- The data is loaded and and meta-data parameters are computed.
- Several consistencies between parameters and data checked.
- Stage 1: Band-filter data and compute envelope.
- Here all channels are band filtered using a FIR filter with Frequency band and filter parameters specified in parameters.
- The upper envelope of the filtered signal is then computed.
- Stage 2: Find a baseline for the signal on every channel. *
- Stage 3: Find events of interest. *
- Stage 4: Post detections statistics.
The code is pretty much stand alone apart from obviously requiring MatLab. So just Clone and run.
For a nice overview of the functionality of this code run "HFOWalkthrough.m" section by section and read the commentary.
For a demonstration of the functionality run the file "RunDemoZurichSpec.m" located in the +Demo folder.
For a demonstration of the functionality run the file "RunDemoZurichMorph.m" located in the +Demo folder.
Finding HFO is sometimes described as an art. This is a lie, there simply is a lot of parameters that must be set in the detection process. In order to make this more manageable, all parameters are centralized. In the folder PresetParameters there is a script DetectorParameterMaker.m in it all the pre-set parameters are specified. There is also a file FIR_2KHz.mat which contains coefficient of a designed filter. To make you own parameter file just alter the values in the script DetectorParameterMaker.m and run the script. To use you own filter coefficients you will have to add this either manually or add a file that you read as FIR_2KHz.mat is read.
Alternatively if the constant creation of a parameter.mat file is too much. Then one can also manually alter the parameters in a pre-existing .mat file. This is done via the usual MatLab techniques.
- HFO.m
- ParaAndData.m
- FilterSignal.m
- Baseline.m
- EventsOfInterest.m
- CoOccurence.m
ParaAndData.m
├── loadParameters
├── loadData
└── testParameters
ParaAndData.m is used to load the parameters and data from the specified file paths. It has three sub functions:
- loadParameters: Takes as input a file location of a .mat file in the format given in DetectorParameterMaker.m.
- loadData: Takes as input a file location of a .mat file in the format given in the above section.
- testParameters: A test function to see if the parameters specified do not conflict with the data.
FilterSignal.m
├── filterSignal
├── getSignalEnvelope
└── getSmoothSignalEnvelope
FilterSignal.m is used to obtain the filtered signal aswell as the envelope. It has the following sub-functions:
- filterSignal: Zero-phase forward and reverse digital IIR filtering, Coefficients set in the parameters. None recursive.
- getSignalEnvelope: obtain the envelope of filtered signal.
Baseline.m
├── setBaselineMaxNoisemuV
├── getBaseline
│ ├── getWholeIndHighEntr
│ │ ├── getSignalSeg
│ │ ├── getStockwellData
│ │ │ └── Transform.StockwellTransform
│ │ ├── calcEntropy
│ │ ├── getIndAboveEntrThr
│ │ ├── trimIndBorder
│ │ ├── getIndBrake
│ │ └── getIndHighEntr
│ └── getChannelBaseline
└── setBaslineThreshold
Baseline.m is used to obtain the baseline of the signal. This function proceeds as follows:
- setBaselineMaxNoisemuV: returns a noise threshold as either a preset value or as a standard deviation of the signal.
- getBaseline ← getWholeIndHighEntr : finds intervals of high entropy in the signal.
- getSignalSeg : selects a segment of the signal as specified beforhand.
- getStockwellData ← Transform.StockwellTransform: see transforms section.
- calcEntropy: standard informational calculation of entropy
- getIndAboveEntrThr: Thresholding to select intervals of high entropy
- trimIndBorder: Corrective processing needed for the Stockwell transform.
- getIndBrake: Returns indeces in the signal
- getIndHighEntr: collects the indeces
- getChannelBaseline : sets the computed values in the class.
- setBaslineThreshold: Calculate a threshold from the baseline and the entropy for use in event detection
entropy should be lower during oscilations presence of a pattern.
EventsOfInteres
├── findEvents
│ └── findChannelEvents
│ ├──shiftEvelope
- Sergey Burnos
- Tommaso Fedele
Klinik für Neurochirurgie PhD student:
Andries Steenkamp
JohannesAndriesJacobus.Steenkamp@usz.ch
assisted by
Ece Boran
Supervised by
Sarnthein Johannes