These functions show the essential steps of using MOD for detecting EPSP/EPSCs as described in [1] and applied in [2].
The core of the method is available in the biosig git repository
git clone https://git.code.sf.net/p/biosig/code biosig-code
git clone https://git.ista.ac.at/alois.schloegl/biosig.git biosig-code
in the subdirectory
cd biosig-code/biosig4matlab/t340_MachineLearningOptimalDetection
The core functions of the MOD method are
% demo - applying the method to the example data available from
% https://pub.ist.ac.at/~schloegl/software/mod/
% results will be written into output/*
demo_mod.m
% An extended version with LOOM-based cross-validation, and two scorings
% is shown in
demo_modx.m
% this is the core function for obtaining the parameters % from the MOD method (filter coefficients, threshold, and delay)
mod_optimal_detection_filter.m
% storing the results in a GDF file for visualization with sigviewer
minidet2gdf.m
Different platforms (Matlab and Octave) and operating systems (Linux, Windows, MacOSX) are supported. Depending on your platform, the intallation procedure will differ. Essentially, we typically need:
Assuming you have matlab already installed, download and unpack biosig-3.9.5–windows64bit and add the following directories to your path. biosig-3.9.5-Windows-64bit/share/matlab/* biosig-3.9.5-Windows-64bit/matlab
Start matlab and
cd biosig-3.9.5-Windows-64bit/share/matlab/
% adds biosig directories to path
install
% add path to precompiled mexw* files for matlab
addpath ../../biosig-3.9.5-Windows-64bit/matlab
pkg install signal
pkg install "https://sourceforge.net/projects/biosig/files/Biosig%20for%20Octave/biosig4octave-3.9.5.src.tar.gz"
pkg load biosig
sudo apt install libbiosig-dev octave octave-dev octave-signal octave-biosig
The get the latest version of MOD, you might want to run in octave
pkg install "https://sourceforge.net/projects/biosig/files/Biosig%20for%20Octave/biosig4octave-3.9.5.src.tar.gz"
pkg load biosig
sudo apt install libbiosig-dev
Download and unpack
wget https://sourceforge.net/projects/biosig/files/BioSig%20for%20C_C%2B%2B/src/biosig-3.9.5.src.tar.xz
tar xvf biosig-3.9.5.src.tar.xz
cd biosig-3.9.5/biosig4matlab/
# start matlab and run
install
I recommend using homebrew, and then do
brew install octave
brew install biosig # install libbiosig
From within octave, you run
pkg install "https://sourceforge.net/projects/biosig/files/Biosig%20for%20Octave/biosig4octave-3.9.5.src.tar.gz"
pkg load biosig
brew install biosig # install libbiosig
Download and unpack
wget https://sourceforge.net/projects/biosig/files/BioSig%20for%20C_C%2B%2B/src/biosig-3.9.5.src.tar.xz
tar xvf biosig-3.9.5.src.tar.xz
cd biosig-3.9.5/biosig4matlab/
# start matlab and run
install
cd t340_MachineLearningOptimalDetection
[1] Zhang X, Schlögl A, Vandael D, Jonas P, MOD: A novel machine-learning optimal-filtering method for accurate and efficient detection of subthreshold synaptic events in vivo. Journal of Neuroscience Methods, 2021. https://doi.org/10.1016/j.jneumeth.2021.109125
[2] Xiaomin Zhang, Alois Schlögl, Peter Jonas Selective Routing of Spatial Information Flow from Input to Output in Hippocampal Granule Cells, Neuron, 2020. https://doi.org/10.1016/j.neuron.2020.07.006 http://www.sciencedirect.com/science/article/pii/S0896627320305237
[3] Biosig - an Free and Ppen source software library for biomedical signal processing http://biosig.sourceforge.net/index.html
[4] The NaN-toolbox: A statistics and machine learning toolbox for Octave and Matlab® for data with and w/o MISSING VALUES encoded as NaN’s. https://pub.ist.ac.at/~schloegl/matlab/NaN/
[5] SigViewer (v0.5.1 or later) https://github.com/cbrnr/sigviewer/releases https://github.com/schloegl/sigviewer/tree/dev
Binaries for windows are available here: https://pub.ist.ac.at/~schloegl/software/sigviewersigviewer-win64.LATEST.exe
[6] https://pub.ist.ac.at/~schloegl/software/mod/
This depends whether you want to build a detector for each cell, or whether you want to build a general classifier.
Check out demo_mod.m and address these items:
you need your raw data, and your scorings and adapt loading the data (lines 67-87) Please note, the scorings consists of two periods (one segment in the beginning, the other from the end) And you need to tell which periods are scored, when constructing the scoring trace lines 124-136.
In case you want to apply blanking of AP’s, you need to detect them and replace them with NaN’s (line 88-90, 115-123)
if you want to downsample your data, you can check the lines 92-114,
If you want to apply cross-validation, you should enable lines 140 - 194
That should do it. The main data processing of training the detection method happens in lines 199-213, the remainder storing the results, and in case you still have some HF noise in the raw detection trace, you might want to smooth it before doing the event detection.
Check out demo_modx.m and address these items:
loading of data, where is your data located, how to load it. define the grouping information, this is useful for the cross-validation later
get the scorings, identify which parts of the data is scored
proprocessing, detection artifacts, AP etc. and remove (blank) those.
run training and testing procedure on the scored data, use Leave-one-out-method for cross-validation.
Build the general classifier from all scored data.
Yes, the event timing can be found in multiple outputs.
on the workspace its in the variable “pos”,
and its also stored in all three output files, in one way or another.
output/*.mat contains various results, including the variable ‘pos’
output/*.txt is the event times in seconds
output/*.gdf is best viewed with sigviewer, but can be also loaded into matlab
2023-2026 several improvents in - handling of preprocessing (filtering) - better code structure to simplify usage
2022-09-26: v2.2 - fix filenames in demo_mod.m
2022-05-13: v2.1 add smoothing of raw detection trace to demo enable cross-validation by default; report kappa in addition to AUC improvements and cleanup of demo_mod{,x}
2022-03-02: - demo_modx added - shows the use of leave-one-out-method for crossvalidation - add 6 data sets, with 2 scorings each - use accovf_mex to speed up training step
2021-06-21: improve documentation
2021-03-12: first release: