# doc-cache created by Octave 10.1.0
# name: cache
# type: cell
# rows: 3
# columns: 7
# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
apply_general_classifier


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1792
 APPLY_GENERAL_CLASSIFIER shows how to apply a precomputed classifier
 to new data sets described in [1] and applied in [2]. It is assumed that
 that classifier has been obtained with DEMO_MODY, such that the same
 preprocessing method is used.

 In order to run this demo, the following software packages
 are needed:
 - Octave (or Matlab) and the Signal Processing toolbox or package
 - Biosig [3]
 - NaN-toolbox [4]
 - SigViewer [5] - for scoring the data and visualization of the
    resulting detections
 - Data (recordings and scorings from [1,2] are available [6]

 Copyright (C) 2016-2023 Alois Schlögl, Institue of Science and Technology Austria (ISTA)

 References:
 [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.
     doi: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.51, or v0.65)
     https://git.ist.ac.at/alois.schloegl/sigviewer.git
     https://pub.ist.ac.at/~schloegl/software/sigviewer/sigviewer-0.6.4-win64.exe
 [6] https://pub.ist.ac.at/~schloegl/software/mod/



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 APPLY_GENERAL_CLASSIFIER shows how to apply a precomputed classifier
 to new...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
demo_mod


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1563
 demo_mod shows the essential steps of using MOD for  
 detecting EPSP/EPSCs as described in [1] and applied in [2]. 
 
 In order to run this demo, the following software packages 
 are needed: 
 - Octave (or Matlab) and the Signal Processing toolbox or package
 - Biosig [3]
 - NaN-toolbox [4] 
 - SigViewer [5] - for scoring the data and visualization of the 
    resulting detections

 Copyright (C) 2016-2021 Alois Schlögl, IST Austria

 References:
 [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.
     doi: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.51, or v0.65)
     https://github.com/cbrnr/sigviewer
     https://git.ist.ac.at/alois.schloegl/sigviewer.git 
     https://pub.ist.ac.at/~schloegl/software/sigviewer/sigviewer-0.6.4-win64.exe



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 demo_mod shows the essential steps of using MOD for  
 detecting EPSP/EPSCs ...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
demo_modx


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1842
 DEMO_MODX shows the essential steps of using MOD for  
 detecting EPSP/EPSCs as described in [1] and applied in [2]. 
 
 DEMO_MODX is an extended version of the simpler version of DEMO_MOD for  
 and add the LOOM-crossvalidation procedure and handling the scoring
 from two experts. 
 
 In order to run this demo, the following software packages 
 are needed: 
 - Octave (or Matlab) and the Signal Processing toolbox or package
 - Biosig [3]
 - NaN-toolbox [4] 
 - SigViewer [5] - for scoring the data and visualization of the 
    resulting detections
 - Data (recordings and scorings from [1,2] are available [6] 

 Copyright (C) 2016-2022 Alois Schlögl, Institue of Science and Technology Austria (ISTA)

 References:
 [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.
     doi: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.51, or v0.65)
     https://git.ist.ac.at/alois.schloegl/sigviewer.git 
     https://pub.ist.ac.at/~schloegl/software/sigviewer/sigviewer-0.6.4-win64.exe
 [6] https://pub.ist.ac.at/~schloegl/software/mod/



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 DEMO_MODX shows the essential steps of using MOD for  
 detecting EPSP/EPSCs...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
demo_mody


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2008
 DEMO_MODY shows the essential steps of using MOD for
 detecting EPSP/EPSCs as described in [1] and applied in [2].

 DEMO_MODY replaces DEMO_MODX, and uses SLOAD4MOD to load the data, and
 apply preprocessing methods. It is an extended version of the simpler
 version of DEMO_MOD and adds the LOOM-crossvalidation procedure and
 handling the scoring from two experts.
 DEMO_MODY is also useful to investigate the influence of different
 preprocessing methods.

 In order to run this demo, the following software packages
 are needed:
 - Octave (or Matlab) and the Signal Processing toolbox or package
 - Biosig [3]
 - NaN-toolbox [4]
 - SigViewer [5] - for scoring the data and visualization of the
    resulting detections
 - Data (recordings and scorings from [1,2] are available [6]

 Copyright (C) 2016-2023 Alois Schlögl, Institue of Science and Technology Austria (ISTA)

 References:
 [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.
     doi: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.51, or v0.65)
     https://git.ist.ac.at/alois.schloegl/sigviewer.git
     https://pub.ist.ac.at/~schloegl/software/sigviewer/sigviewer-0.6.4-win64.exe
 [6] https://pub.ist.ac.at/~schloegl/software/mod/



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 DEMO_MODY shows the essential steps of using MOD for
 detecting EPSP/EPSCs a...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
minidet2gdf


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1852
 MINIDET2GDF writes results of miniature detection results to a GDF file. 
   

 Usage: 
     HDR = minidet2gdf(S,POS,pos,Twin,Fs,fn, AP_Events)
     HDR = minidet2gdf([S, D, D>TH], [], pos, Twin, Fs, H0, []);
  
  Input: 
    S: raw data
    D: raw detection trace
    TH: detection threshold, such that (D>TH) produced binary detection trace
    POS: (optional) export scoring
    pos: detected event times, typically these are obtained by
	  pos = get_local_maxima_above_threshold(D,TH,1,0.01*Fs);         
    Twin: windows length when translating expert scoring into scoring trace. 
    Fs:  sampling rate in Hertz
    HDR: out file structure such that 
       HDR.FileName indicates the output file name. 
 	The resulting file will be stored in GDF format [2,3], which can be read
	by Biosig, Sigviewer and other software. 
    AP_Events: if AP's have been detected
	and should be indicated as such in the output file.  

  Output: 
    HDR: header structure of the output file HDR.FileName. 


 see also: 
	AUC, MINIDET2GDF, GET_LOCAL_MAXIMA_ABOVE_THRESHOLD, 

 References: 
 [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.
     doi: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] A. Schlögl, GDF - A general dataformat for biosignals, Technical Report.
     Version 2.x (2006) available at: GDF 2.0
 [4] ON K2204:2015 A general dataformat for biosignals, Austrian Standards, 2015



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 73
 MINIDET2GDF writes results of miniature detection results to a GDF file.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
mod_optimal_detection_filter


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2969
 MOD_OPTIMAL_DETECTION_FILTER for detections miniature events [1,2]. The parameters
    of the detection method (e.g. filter coefficents, detection thresheld, and the 
    time shift) are estimated from events defined as "training set", and 
    and was tested on events declared as "test set". Several performances 
    measures (including AUC and Cohen's kappa) are reported. In case the training
    and test set did not overlap, crossvalidation is implemented and
    it can be expeted that the the obtained performance can be reached 
    also on unseen data. Several methods are implemented, the default and 
    recommended method ('wopt2') is based on an a-causal Wiener filter 
    as described in [1,2]. The method tries different time shift values for 
    training the wiener filter, and uses the filter that leads to the 
    largest AUC. 

 Usage:
    RES = get_minidet_classification(data, C, maxlag, ixtrain, ixtest, method): 
    Input:  
	data: raw data trace (single column vector) 
  		the data may contain NaN's indicating missing values.
       C:    scoring trace 
       maxlag: maximum lag numbers for computing the correlation functions 
 		it should be the some of the filter length (typically 1000 samples)
 		and the maximum timeshift.
	ixtrain: list of sample numbers used for training the detector

	ixtest:  list of sample numbers for testing the performance of the detector

 	method: 'wopt2' (a.k.a. 'MOD') is the default method, and the recommended method
		because it provides the best performance [1] so far.  
		other approaches were used for comparison and are not recommended. 
   Output:
	RES.CLASSIFIER.delay
		time shift for making the a-causal filter causal.  
	RES.CLASSIFIER.A
		coefficients of the Wiener filter  used for 
		u = filter(RES.CLASSIFIER.A, 1, data)

 	RES.WOPT.DLIST =
		list of time shift values used to train the optimum filter
		currently this list is [-maxlag/4:25:maxlag], 
	RES.WOPT.AUC   = AUC;
		AUC result of the corresponding time shift values. 
	plot(RES.WOPT.DLIST/Fs, RES.WOPT.AUC) can be used to produce 
       Suppl Figure 3 [1].  

 see also: 
	AUC, MINIDET2GDF, GET_LOCAL_MAXIMA_ABOVE_THRESHOLD, 

 Requirements: 
 - Octave or Matlab
	http://www.octave.org
 - NaN toolbox
       https://pub.ist.ac.at/~schloegl/matlab/NaN/	
	https://octave.sourceforge.io/nan/index.html
 - Biosig for Octave and Matlab
	http://biosig.sourceforge.net/download.html

 References: 
 [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.
     doi:10.1016/j.jneumeth.2021.109125
 [2] Zhang X., Schloegl A., Vandael D., Jonas P. (2020)
      A novel machine learning-based method for accurate and efficient detection of
      subthreshold synaptic events in vivo and in vitro (in revision).
      Journal of Neuroscience Methods. 



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 68
 MOD_OPTIMAL_DETECTION_FILTER for detections miniature events [1,2].



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
sload4mod


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1881
 sload_mod is a function that loads biosignal data and
   and does all preprocessing steps for the MOD method.
 Preprocessing steps consist of
 - AP detection and blanking of AP's
 - Resampling to a common target sampling rate (default: 25kHz)
 - detrending and/or highpass filtering
 - lowpass filtering

 Usage:
  [data,HDR,rawdata,HDRraw]=sload4mod(filename,chan,Fs,Mode);
  [data,HDR,rawdata,HDRraw]=sload4mod(filename,chan,Fs,Mode,TemplateLength);
  [data,HDR,rawdata,HDRraw]=sload4mod(filename,chan,Fs,Mode,TemplateLength,BlankingPeriod);

 Fs:  target sampling rate (default: 25000 Hz)
 TemplateLength: 
 	Window length for planking of AP events. 1/4 of the window before the
       and 3/4 of the window after the fiducial points of the AP will be
       blanked (i.e. replaced with NaN's).
 	default (-1) : no AP blanking
                 0  : will remove exactly 1 sample at the fiducial AP point
 BlankingPeriod:
       []: default, no blaninking
       +t   if t>0, from the beginning of each sweep until t is blanked
            if t<0  from end-t to the end is blanked
       [t1,t2]  interval [t1,t2] is blanked

 Mode:
	'fir1:0:1000'	fir filter
	'D1a:0:1000'	fir1-forward-backward filter
	'D1a:-1:1000'	1st order difference filter + fir1-forward-backward filter
	'D1b:0:1000'	fir1-forward-backward filter
	'D1b:-1:1000'	1st order difference filter + fir1-forward-backward filter
       'gauss2_3_1000' highpass 3Hz, lowpass 1000 Hz
       'gauss2_-1_1000'  no highpass, lowpass 1000 Hz
       'gauss2_3_-1'     highpass 3Hz, no lowpass

 Additional properties:
 + downsampling using fft (for Gauss and FFT filter)
 + check whether AP detection returns all events or only AP events
 + merge AP events with all other events, this is done in minidet2gdf
 Desirable but not yet implemented are the following features:
 - identify RS pulses
 - remove marked artifacts -



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 sload_mod is a function that loads biosignal data and
   and does all prepro...





