# doc-cache created by Octave 10.1.0
# name: cache
# type: cell
# rows: 3
# columns: 23
# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
Contents


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 561
 
 T250: Quality Control and Artifact Processing
 ---------------------------------------------
	ARTIFACT_SELECTION	converts artifact scorings into trial selections
 	EEG2HIST	calculates histogram
 	GETTRIGGER	gets trigger points
 	TRIGG		extract fixed-length trials around trigger points	
	DETECT_MUSCLE	detection of muscle artefacts using an inverse filter
	DETECT_SPIKES_BURSTS detect spikes and bursts in neural recordings
       REGRESS_EOG     reduce EOG artifacts with regression analysis 
       REMOVE5060HZ    methods for removing line interference
 



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 
 T250: Quality Control and Artifact Processing
 ---------------------------...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
artifact_selection


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 965
 ARTIFACT_SELECTION returns the selected triggered trials with 
 artifacts. The length of the trial is defined by t1 and t2 in 
 seconds.  

 [HDR] = artifact_selection(filename,[t1,t2])
 [HDR] = artifact_selection(HDR,[t1,t2])
    uses EVENT information in filename or HDR.EVENT. 

 The artifact selection is available in HDR.ArtifactSelection. 
 HDR.ArtifactSelection is vector with the same length than the list
 of trigger points (event 0x0300). A value of 1 indicates an
 artifact, a value of 0 means the trial is free from any artifacts.
 	
 In case the trigger information and the artifact scoring is 
 stored in separate files, the information of several files can be
 merged.

 [HDR] = artifact_selection({sourcefile,eventfile1,eventfile2,...},[t1,t2])

 All files can be defined by their filename, or by the BIOSIG HDR-struct.
 The header of the first file is merged with the Event information of 
    all other files. 

 see also: TLOAD, SLOAD, SOPEN,  



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 75
 ARTIFACT_SELECTION returns the selected triggered trials with 
 artifacts.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
burstanalysis


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 907
 BURSTANALYSIS extracts additional parameters from detection bursts 
 including:
	Peak Amplitude
	Peak time
	Minimum after peak
	Maximum of Minima after Peak

 usage: 
	[HDR, s] = burstanalysis(fn)
	...        burstanalysis(..., args)
		optional args for spike2bursts conversion

	...        burstanalysis(..., 'dT_Burst', dT_Burst)
	...        burstanalysis(..., 'dT_Exclude', dT_Exclude)

	dT_Burst	[default: 50e-3 s] am inter-spike-interval (ISI) exceeding this value,
		marks the beginning of a new burst
	dT_Exclude an interspike interval smaller than this value, indicates a
		double detection, and the second detection is deleted.
		in case of several consecutive ISI's smaller than this value,
		all except the first spikes are deleted.

	fn   name of file containing sample data and 
	visually corrected spike detections. The spike2burst 
	conversion 

 see also: DETECT_SPIKE_BURSTS, SPIKE2BURSTS



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 BURSTANALYSIS extracts additional parameters from detection bursts 
 includi...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
detect_sharp_wave_ripple


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 5522
 DETECT_SHARP_WAVE_RIPPLE detects ripples in neural recordings.

 HDR = detect_sharp_wave_ripple(filename, chan)
 ... = detect_sharp_wave_ripple(HDR, data)
 ... = detect_sharp_wave_ripple(... ,'-o', outputFilename)
 ... = detect_sharp_wave_ripple(... ,'-e', eventFilename)
 ... = detect_sharp_wave_ripple(... ,'-b', bandpassFilename)
 ... = detect_sharp_wave_ripple(... ,'-s', segmentFilename)
 ... = detect_sharp_wave_ripple(... ,'Threshold', Threshold)
 ... = detect_sharp_wave_ripple(... ,'winlen', winlen)
 ... = detect_sharp_wave_ripple(... ,'trigchan', trigger_channel)
 ... = detect_sharp_wave_ripple(... ,'method', method)
 [HDR, data] = detect_sharp_wave_ripple(...)

 Input:
 	filename: name of source file
	chan	list of channels that should be analyzed (default is 0: all channels)
	HDR	header structure obtained by SOPEN, SLOAD, or meXSLOAD
	data	signal data that should be analyzed
	Threshold	[default: 6] number of standard deviations
 	winlen	windowlength [default 400 ms (+-200ms)]
               should represent the approximate duration of a single event
		it determines in the default method (0) at which distance in time,
		time events are considered one or two separate events.
	trigger_channel: channel used for triggering/segmenting the data
	coincidenceWindow: [default: 40 ms]
		if defined, (TYP=4) indicates a ripple where the current-envelope-peak occured
               within a time window centered on the LFP-envelope peak. If this criteria is not
               met or the coincidence window is undefined (empty), TYP=3 is used.
               Only the first two channels are are used, if data set contains more than two
               channels, a warning is displayed. method=14 does not support coincidence detection
               and ignores this parameter.

	outputFilename
		name of file for storing the resulting data with the
		detected spikes and bursts in GDF format.
	eventFilename
		filename to store event inforamation in GDF format. this is similar to
		the outputFile, except that the signal data is not included and is, therefore,
		much smaller than the outputFile
	bandpassFilename
		filename for bandpass filtered data
	segmentFilename
		filename for segmented data, each segment is twice as large as winlen plus one sample
		going from -winlen*samplerate : +winlen*samplerate
		This file can be loaded into stimfit.
	method: 0 : default
			filter 100-250,
 			threshold = 6
               1 or 'maier2011' : see Maier et al 2011 [1]
			filter 120-300,
 			threshold = 6
               2 or 'tukker2013' : see Tukker et al 2013 [2]
			filter 90-140,
 			threshold = 5
               3 or 'lasz2011' : see Lasztoczi et al 2011 [3]
			filter 90-200,
 			threshold = 5
               4, or 'jiangan2015' : see Jian Gan et al 2017 [1]
			filter 90-200,
 			threshold = 4	-> HDR.EVENT.TYP=4
 			threshold = 6	-> HDR.EVENT.TYP=6
               5  : see Jian Gan et al 2017 [1]
			filter 100-250,
 			threshold = 6
               14 : see Jian Gan et al 2017 [1]
			filter 100-250,
 			threshold = 4	-> HDR.EVENT.TYP=4
 			threshold = 6	-> HDR.EVENT.TYP=6

	Arguments can appear in any order and multiple times (except for filename, chan, HDR and data),
	In case of conflicting definitions, the latest definition has highest precedence and is used.


 Output:
     HDR	header structure as defined in biosig
     HDR.EVENT includes the detected spikes and bursts.
     data	signal data, one channel per column
		between segments, NaN values for 0.1s are introduced

 see also:  DETECT_SPIKES_BURSTS, SPIKE2BURSTS, OPTIMUM_ISI_SPIKE_BURST_SEPARATION

 References:
 [0] bandpass 100-250 Hz, - 6 S.D. detection, - search with -200 - +200 ms for maximum positive peak for  alignment
     extract window -200 - +200 ms window of both channels.
 [1] Nikolaus Maier, Alvaro Tejero-Cantero, Anja L. Dorrn, Jochen Winterer, Prateep S. Beed,1 Genela Morris,
     Richard Kempter, James F.A. Poulet, Christian Leibold, and Dietmar Schmitz
     Coherent Phasic Excitation during Hippocampal Ripples
     Neuron 72, 137–152, October 6, 2011 p149.
     DOI 10.1016/j.neuron.2011.08.016
 [2] John J. Tukker, Balint Lasztoczi, Linda Katona, J. David B. Roberts, Eleftheria K. Pissadaki, Yannis Dalezios,
     Laszlo Marton, Limei Zhang, Thomas Klausberger, and Peter Somogyi1
     Distinct Dendritic Arborization and In Vivo Firing Patterns of Parvalbumin-Expressing Basket Cells in the Hippocampal Area CA3
     The Journal of Neuroscience, April 17, 2013 • 33(16):6809 – 6825 • p6810
     J. Neurosci., April 17, 2013 • 33(16):6809 – 6825 • 6811
 [3] Balint Lasztoczi, John J. Tukker, Peter Somogyi, and Thomas Klausberger
     Terminal Field and Firing Selectivity of Cholecystokinin-
     Expressing Interneurons in the Hippocampal CA3 Area
     The Journal of Neuroscience, December 7, 2011 • 31(49):18073–18093 • 18074
 [4] Maria Pangalos, José R. Donoso, Jochen Winterer, Aleksandar R. Zivkovic, Richard Kempter, Nikolaus Maier, and Dietmar Schmitz
     Recruitment of oriens-lacunosum-moleculare interneurons during hippocampal ripples.
     4398–4403 | PNAS | March 12, 2013 | vol. 110 | no. 11
     www.pnas.org/cgi/doi/10.1073/pnas.1215496110
 [5] Jian Gan, Shih-ming Weng, Alejandro J. Pernía-Andrade, Jozsef Csicsvari, Peter Jonas
     Phase-Locked Inhibition, but Not Excitation, Underlies Hippocampal Ripple Oscillations in Awake Mice In Vivo
     Neuron, Volume 93, Issue 2, 18 January 2017, Pages 308-314
     https://doi.org/10.1016/j.neuron.2016.12.018



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 63
 DETECT_SHARP_WAVE_RIPPLE detects ripples in neural recordings.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
detect_spikes_bursts


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3832
 DETECT_SPIKES_BURSTS detects spikes and bursts of spikes in
 neural recordings.
 Spikes are detected when voltages increase is larger than slopeThreshold
 (default 20 V/s) within a window of length winlen (default 0.0002 s). An interspike interval
 large than dT_Burst (default 75 ms) define the start of the next burst.


 HDR = detect_spikes_bursts(filename, chan)
 ... = detect_spikes_bursts(HDR, data)
 ... = detect_spikes_bursts(... ,'OptimumJK')
 ... = detect_spikes_bursts(... ,'-o',outputFilename)
 ... = detect_spikes_bursts(... ,'-e',eventFilename)
 ... = detect_spikes_bursts(... ,'-b',burstFilename)
 ... = detect_spikes_bursts(... ,'slopeThreshold',slopeThreshold)
 ... = detect_spikes_bursts(... ,'winlen',winlen)
 ... = detect_spikes_bursts(... ,'chan',chan)
 ... = detect_spikes_bursts(... ,'dT_Burst',dT_Burst)
 ... = detect_spikes_bursts(... ,'dT_Exclude',dT_Exclude)
 ... = detect_spikes_bursts(... ,[slopeThreshold [, winlen [, dT_Burst [,dT_Exclude ]]] ])
 ... = detect_spikes_bursts(... ,'OptimumJK')
 [HDR, data] = detect_spikes_bursts(...)

 Input:
 	filename: name of source file
	chan	list of channels that should be analyzed (default is 0: all channels)
	HDR	header structure obtained by SOPEN, SLOAD, or meXSLOAD
	data	signal data that should be analyzed
       chan 	channel number(s) in case HDR and data are not sufficient
		for specifying channel number
	slopeThreshold	[default: 10 V/s] Spike is detected when
		slope (over time winlen) exceeds this value
	winlen	[default: .2e-3 s] windowlength in seconds for computing slope
	dT_Burst	[default: 50e-3 s] am inter-spike-interval (ISI) exceeding this value,
		marks the beginning of a new burst
               'OPTIMUM_ISI' will use the function OPTIMUM_ISI_SPIKE_BURST_SEPARATION
               for identifying dT_Burst.
	dT_Exclude an interspike interval smaller than this value, indicates a
		double detection, and the second detection is deleted.
		in case of several consecutive ISI's smaller than this value,
		all except the first spikes are deleted.
	'OptimumJK' overrides previously defined settings, and uses the optimal setting based on
		an JK's data set. It sets slopeThreshold = 2.5, dT=450e-6, dT_Exclude = 2e-3;
		These settings were found based on 18 different recordings containing
		23999 spikes, 3967 bursts, and over 9700 seconds of recorded data.
	outputFilename
		name of file for storing the resulting data with the
		detected spikes and bursts in GDF format.
	eventFilename
		filename to store event inforamation in GDF format. this is similar to
		the outputFile, except that the signal data is not included and is, therefore,
		much smaller than the outputFile
	burstFilename
		filename for the "burst table", containing basic properties of each burst,
		(it is an ASCII file in <tab>-delimited format)

	Arguments can appear in any order and multiple times (except for filename, chan, HDR and data),
	In case of conflicting definitions, the latest definition has highest precedence and is used.


 Output:
     HDR	header structure as defined in biosig
     HDR.EVENT includes the detected spikes and bursts.
     HDR.BurstTable contains for each burst (each in a row) the following 6 numbers:
	channel number, sweep number, OnsetTime within sweep [s],
	number of spikes within burst, and average inter-spike interval (ISI) [ms],
	and minimum ISI [ms].
     data	signal data, one channel per column
		between segments, NaN values for 0.1s are introduced

 see also:  DETECT_SPIKES_BURSTS, SPIKE2BURSTS, OPTIMUM_ISI_SPIKE_BURST_SEPARATION

 References:
 [1] Janina Kowalski, Jian Gan, Peter Jonas, and Alejandro J. Pernía‐Andrade
     Intrinsic membrane properties determine hippocampal differential firing pattern in vivo in anesthetized rats
     Hippocampus. 2016 May; 26(5): 668–682.
     doi:10.1002/hipo.22550



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 DETECT_SPIKES_BURSTS detects spikes and bursts of spikes in
 neural recordin...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
detectmuscle


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1603
 Muscle detection with inverse filtering
 Artifacts are indicated with NaN's. 

 [INI,S,E] = detectmuscle(S [, iter [,1]])
 [INI,S,E] = detectmuscle(S, Fs, Mode)  with Mode>1
 [INI,S,E] = detectmuscle(S, arg2, Mode)

 iter		number of iterations [default:1]
 INI.MU	mean of S
 INI.InvFilter	coefficients of inverse filter (see [2-5])
 S		outlier replaced by NaN
 E		isnan(E) indicates muscle artifact
 Mode	1: [default] inverse filtering
	2: based on gradient, range and amplitude [BrainVision method]
 	3: slope > 11 uV/sample [1]
 	4: beta2 > 0.9 uV^2/Hz [1] 

 References: 
 [1] Van de Velde, M., Van Erp, G., Cluitmans, P., 1998.
     Detection of muscle artefact in the normal human awake EEG.
     Electroencephalography and Clinical Neurophysiology 107 (2), 149-158.
 [2] Lopes da Silva, F.H., van Hulten, K., Lommen, J.G. Stomr van Leeuwen, W., von Veelen, C.W.M. and Vliegenthart, W. (1977)
     Automatic detection and localization of epiliptic foci, Electroenceph. Clin. Neurophysiol. 43: 1-13.
 [3] Bodenstein G. and Praetorius H.M. (1977)
     Feature extraction from the electroencephalogram by adaptive segmentation,
     Proc. IEEE, 65: 642-657.
 [4] Praetorius H.M., Bodenstein G. and Creutzfeld O. (1977)
     Adaptive Segmentation of EEG records: A new approach to automatic EEG analysis.
     Electroenceph. Clin. Neurophysiol. 42: 84-94.
 [5] Alois Schlögl (2000)
     The electroencephalogram and the adaptive autoregressive model: theory and applications.
     Shaker Verlag, Aachen, Germany,(ISBN3-8265-7640-3).
     http://pub.ist.ac.at/~schloegl/publications/EEG_AAR_model.pdf



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 77
 Muscle detection with inverse filtering
 Artifacts are indicated with NaN's.



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1229
 EEG2HIST histogram analysis based on [1]
  It displays the histograms of the recorded data, 
  and allows editing of the thresholds for 
  the automated overflow detection. 
 
 [HDR]=EEG2HIST(FILENAME); 

 input: FILENAME   EEG-File
        CHAN       Channel select
 output: 
	 HDR	   header information
        HDR.HIS   histograms for each channel
	 HDR.RES   summary statistics based on the histogram analysis [1]
 	 HDR.THRESHOLD  Threshold values for overflow detection 

 
 see also: SOPEN, SLOAD, HIST2RES

 REFERENCES:
 [1] A. Schlögl, B. Kemp, T. Penzel, D. Kunz, S.-L. Himanen,A. Värri, G. Dorffner, G. Pfurtscheller.
   Quality Control of polysomnographic Sleep Data by Histogram and EntropyAnalysis. 
   Clin. Neurophysiol. 1999, Dec; 110(12): 2165 - 2170.
   http://dx.doi.org/10.1016/S1388-2457(99)00172-8

 [2] A. Schlögl, G. Klösch, W. Koele, J. Zeitlhofer, P.Rappelsberger, G. Pfurtscheller
 Qualitätskontrolle von Biosignalen,
 Jahrestagung der Österreichischen Gesellschaft für Klinische Neurophysiologie, 27. Nov. 1999, Vienna.

 [3] http://pub.ist.ac.at/~schloegl/lectures/Q/index.htm

 [4] A. Schlögl, Time Series Analysis toolbox for Matlab. 1996-2003
 http://pub.ist.ac.at/~schloegl/matlab/tsa/



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 EEG2HIST histogram analysis based on [1]
  It displays the histograms of the...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
get_inter_spike_intervals


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 387
 GET_INTER_SPIKE_INTERVALS compute series of interspike 
  intervals from the eventtable of  a biosignal data set 
  loaded with SOPEN or SLOAD. 

 Usage:
    [ISI] = get_inter_spike_intervals(F)
 
 Input:  
 	F filename
 Output:  
	ISI series (vector) of interspike intervals in seconds  

 See also: SOPEN, SLOAD, DETECT_SPIKES_BURSTS, SPIKE2BURSTS, OPTIMUM_ISI_SPIKE_BURST_SEPARATION



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 GET_INTER_SPIKE_INTERVALS compute series of interspike 
  intervals from the...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
get_regress_eog


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 4036
 GET_REGRESS_EOG tries to obtain the regression coefficients
    for EOG correction. According to [1], some extra recordings 
    with large eye movements (i.e. EOG artifacts) are needed. 
    GET_REGRESS_EOG tries to identify this data. 
 
   hdr = get_regress_eog(file)
   hdr = get_regress_eog(file, Mode)
 
 INPUT: 
   file	filename which should be corrected.
		usually, the eye movements are stored in a different file.
    		Some lab-specific heuristics is used to identify the file with the eye movements.
   Mode	'REG'	[default] regression with one or two bipolar EOG channels [1]
		'REG+CAR' regression and common average reference
			removes 2 bipolar + averaged monopolar EOG
		'REG+PCA' regression and PCA, 
			removes 3 "EOG" components
		'REG+ICA' regression + ICA [3]
			removes 3 "EOG" components 
		'PCA-k'	removes the k-largest PCA components, k must be a positive integer
		'ICA-k'	removes the k-largest ICA components [3], k must be a positive integer
       	others like 'NGCA-k','TDSEP-k','TDSEP3-k','TDSEP1','FFDIAG'
		'msec'	same as PCA-3, modified (without averaging) MSEC method [2]
		'bf-'	beamformer, assume zero-activity reference electrode
		'bf+'	beamformer, take into account activity of reference electrode 
		'Hurst'	ICA components selected by the method of[5]
		'Joyce2004' [6]
		'Barbati2004' [7]	
		'Meinecke2002' [8]	

	The following modifiers can be combined with any of the above	
		'FILT###-###Hz'  filtering between ### and ### Hz. ### must be numeric
		'Fs=###Hz'  downsampling to ### Hz, ### must be numeric 
		'x'  	2nd player of season2 data

 OUTPUT:
   hdr.REGRESS.r0 	correction coefficients

   The EOG correction will be applied to the channels CHAN with any of these commands: 
   	HDR = sopen(file,'r',hdr.REGRESS.r0(:,CHAN)); [s,HDR]=sread(HDR); HDR=sclose(HDR);
   	[s,HDR] = sload(file,hdr.REGRESS.r0(:,CHAN)); 
   	[s,HDR] = sload(file,CHAN,'EOG_CORRECTION','ON'); 

 See also: SLOAD, IDENTIFY_EOG_CHANNELS, BV2BIOSIG_EVENTS, REGRESS_EOG 

 Reference(s):
 [1] Schlogl A, Keinrath C, Zimmermann D, Scherer R, Leeb R, Pfurtscheller G. 
	A fully automated correction method of EOG artifacts in EEG recordings.
	Clin Neurophysiol. 2007 Jan;118(1):98-104. Epub 2006 Nov 7.
 	http://dx.doi.org/10.1016/j.clinph.2006.09.003
       http://pub.ist.ac.at/~schloegl/publications/schloegl2007eog.pdf
 [2] Berg P, Scherg M.
	A multiple source approach to the correction of eye artifacts.
	Electroencephalogr Clin Neurophysiol. 1994 Mar;90(3):229-41.
 [3] JADE algorithm, Jean-François Cardoso.
 [4] Boudet S., Peyrodie L., P Gallois, C Vasseur, 
 	Filtering by optimal projectsion and application to automatic artifact removal from EEG
 	Signal Processing 87 (2007) 1987-1992. 
 [5] Vorobyov and Cichocki (2002)
	Blind noise reduction for multisensory signals using ICA and subspace 
	filtering, with application to EEG analysis.
	Biol Cybern. 2002 Apr;86(4):293-303.
 [6] C.A. Joyce, I.F. Gorodnitsky, M.Kutas
	Automated removal of eye movement and blink artifats from EEG data using blind component separation.
	Psychobiology, 41 (2004), 313-325
 [7] Barbati et al (2004) 
 [8] Frank Meinecke, Andreas Ziehe, Motoaki Kawanabe, and Klaus-Robert Müller.
	A Resampling Approach to Estimate the Stability of One-Dimensional or Multidimensional Independent Components.
	IEEE Transactions on Biomedical Engineering, 49(12):1514-1525, 2002.
 [9] Blanchard G., Kawanabe M., Sugiyama M., Spokoiny V., Muller K.-R. (2006). 
	In search of non-gaussian components of a high-dimensional distribution. 
	Journal of Machine Learning Research 7, 247-282.
 [10] Kawanabe M., Sugiyama M., Blanchard G, Müller K.-R. (2007) 
	A new algorithm of non-Gaussian component analysis with radial kernel functions
	Annals of the Institute of Statistical Mathematics, 59(1):2007
 [11] K.H. Ting, P.C.W. Fung, C.Q.Chang, F.H.Z.Chan
	automatec correction of artifact from single-trial event-related potentials bz blind separation  using second order statistics only.
	Medical Engineering & Physics, 28, 780-794 (2006)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 GET_REGRESS_EOG tries to obtain the regression coefficients
    for EOG corr...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
gettrigger


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 332
 GETTRIGGER identifies trigger points 

 TRIG = gettrigger( s [,TH [,rfp]]); % trigger at ascending edge
 TRIG = gettrigger(-s [,TH [,rfp]]); % trigger at decending edge

 input : s   	signal
         TH	Threshold; default: (max+min)/2
	  rfp   refractory period (default=0)	
 output: TRIG	TRIGGER time points

 see also: TRIGG



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 GETTRIGGER identifies trigger points 

 TRIG = gettrigger( s [,TH [,rfp]])...



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 585
 HIST2LIMITS returns the threshold for detecting saturation artifacts. 

 Saturation thresholds can be obtained from the histogram [1]. This 
 routine tries to obtain the saturation threshold in an automated way. 
 
 The routine was tested with the histograms of 528 recordings with 
 three respiratory channels each. 


 Reference(s): 
 [1] A. Schlögl, B. Kemp, T. Penzel, D. Kunz, S.-L. Himanen,A. Värri, G. Dorffner, G. Pfurtscheller.
     Quality Control of polysomnographic Sleep Data by Histogram and Entropy Analysis.
     Clin. Neurophysiol. 1999, Dec; 110(12): 2165 - 2170.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 70
 HIST2LIMITS returns the threshold for detecting saturation artifacts.



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 700
 Evaluates Histogram data
 [R]=hist2res(H)

 [y]=hist2res(H,fun)
	estimates fun-statistic

 fun	'mean'	mean
	'std'	standard deviation
	'var'	variance
	'sem'	standard error of the mean
	'rms'	root mean square
	'meansq' mean of squares
	'sum'	sum
	'sumsq'	sum of squares
	'CM#'	central moment of order #
	'skewness' skewness 
	'kurtosis' excess coefficient (Fisher kurtosis)

 see also: NaN/statistic

 REFERENCES:
 [1] C.L. Nikias and A.P. Petropulu "Higher-Order Spectra Analysis" Prentice Hall, 1993.
 [2] C.E. Shannon and W. Weaver "The mathematical theory of communication" University of Illinois Press, Urbana 1949 (reprint 1963).
 [3] http://www.itl.nist.gov/
 [4] http://mathworld.wolfram.com/



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
 Evaluates Histogram data
 [R]=hist2res(H)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
identify_eog_channels


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 906
 IDENTIFY_EOG_CHANNELS returns bipolar EOG channels for 
  correcting of EOG artifacts using regression analysis
 
  EOGchan = IDENTIFY_EOG_CHANNELS(...) 

 EOGchan is a sparse matrix of size number_of_channels x 2. 
 The sparsity ensures that missing samples of unrelated channels 
 do not affect the data.  

  [...] = IDENTIFY_EOG_CHANNELS(filename) 
  [...] = IDENTIFY_EOG_CHANNELS(HDR) 
	filename or HDR struct can be used
  [...] = IDENTIFY_EOG_CHANNELS(...,'x') 
     looks for EOG channels whos Label start with x

 see also: GET_REGRESS_EOG, SLOAD

 Reference(s):
 [1] Schlogl A, Keinrath C, Zimmermann D, Scherer R, Leeb R, Pfurtscheller G. 
	A fully automated correction method of EOG artifacts in EEG recordings.
	Clin Neurophysiol. 2007 Jan;118(1):98-104. Epub 2006 Nov 7.
 	http://dx.doi.org/10.1016/j.clinph.2006.09.003
       http://pub.ist.ac.at/~schloegl/publications/schloegl2007eog.pdf



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 IDENTIFY_EOG_CHANNELS returns bipolar EOG channels for 
  correcting of EOG ...



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 697
 MAXDISTANCE finds the point with the largest distances from a line 
   connecting the two endpoints in 2-D space. 

  The function is used to find the onset of the a burst in function
  BURSTANALYSIS, but can be used for other examples too.

 usage: 
	[d,ix] = maxdistance(...)
	...    = maxdistance(s)
	...    = maxdistance(s, Q1)
	...    = maxdistance(s, Q1, Q2)

	d  normal distance of each point in s
	ix index of point with largest distance


 see also: BURSTANALYSIS

 REFERENCES:
 [1] http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html
 [2] http://www.mathworks.com/matlabcentral/newsreader/view_thread/164048
 [3] http://www.mathworks.de/support/solutions/en/data/1-1BYSR/



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 MAXDISTANCE finds the point with the largest distances from a line 
   conne...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
optimum_isi_spike_burst_separation


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1524
  OPTIMUM_ISI_SPIKE_BURST_SEPARATION tries to find an optimum
  threshold to separate spike from burst intervals. The problem is
  described in [1](pp.534-6). There are different proposed [2-5]
  described by equ. (45)-(47) in [1].
  All these methods are based on fitting a double exponential
  function to a binned histogram. The method used here does not
  require binned histograms; and is much more robust, especially
  when small sample sizes are used.

  The method is based on a polynomial fit of the log-logit transformed
  cumulative distribution function (CDF) of a given set of inter-spike
  intervals. The minimum of the first derivative is returned as
  the optimum threshold. The 2nd derivative is used to exclude the
  influnce of extremes/outliers.

  Usage:
    Topt = optimum_isi_spike_burst_separation(ISI);
    Topt = optimum_isi_spike_burst_separation(ISI, ORDER);

  ISI   list (i.e. vector) of interspike intervals
  ORDER order of polynomial used to approximate the
        linearized CDF function [default: 7]
  Topt  optimum time interval for identifying burst intervals.

 see also:  DETECT_SPIKES_BURSTS, SPIKE2BURSTS

 References:
 [1] David Colquhoun and F.J. Sigworth (1995)
   Chapter 19. Fitting and Statistical Analysis of Single-Channel Records.
   Eds. Bert Sakmann and Erwin Neher "Single-Channel Recording", 2nd Ed.
   Plenum Press, New York and London. p.535.
 [2] Jackson et al. (1983)
 [3] Magleby and Pallotta (1983)
 [4] Clapham and Neher (1984)
 [5] Colquhoun and Sakmann (1985)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
  OPTIMUM_ISI_SPIKE_BURST_SEPARATION tries to find an optimum
  threshold to ...



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 474
 QC_HISTO performs quality control using histogram and entropy analysis

  R = qc_histo(filename [,CHAN]); 

  plota(R); displays the result as in [1]

 References: 
 [1] A. Schlögl, B. Kemp, T. Penzel, D. Kunz, S.-L. Himanen, A. Värri, G. Dorffner, G. Pfurtscheller.
       Quality Control of polysomnographic Sleep Data by Histogram and Entropy Analysis.
       Clin. Neurophysiol. 1999, Dec; 110(12): 2165 - 2170.
       http://dx.doi.org/10.1016/S1388-2457(99)00172-8



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 71
 QC_HISTO performs quality control using histogram and entropy analysis



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2157
  REGRESS_EOG yields the regression coefficients for 
  correcting EOG artifacts in EEG recordings as described in [1]. 
  Typically, EOG correction is a two-step procedure. The first step
  estimates the correction coefficient, the second step uses them 
  for data correction. 
  
  Step 1: estimating the correction coefficients:       
   R = regress_eog(D, EL, OL)
   R = regress_eog(filename, EL, OL)
   R = regress_eog(filename)
   R = regress_eog(covm(D,'E'), EL, OL)
  NOTE: it is recommended that this data segments (D, filename) contain
  	segments with large eye movement artifacts only; other artifacts
	(e.g. saturation, electrode movement, muscle, etc) should be 
	excluded. 
       
  Step 2: Corrected data is obtained by
   S2 = S1 * R.r0;    % without offset correction
   S2 = [ones(size(S1,1),1),S1] * R.r1;    % with offset correction
  
  S1   recorded data
  EL   list of eeg channels: those channels will be corrected   
  OL   eog/ecg channels. 
       if OL is a vector, it represents the list of noise channels 
       if OL is a matrix, OL derives the noise channels through rereferencing. 
          This is useful if the EOG is recorded monopolar, but the bipolar EOG 
          should be used for for artefact reduction (because the global EEG should remain), 
          One can define OL = sparse([23,24,25,26],[1,1,2,2],[1,-1,1,-1]) 
	   resulting in two noise channels defined as bipolar channels #23-#24 and #25-#26
	A heuristic to get the proper OL is provided by identify_eog_channels.m 
	   OL = IDENTIFY_EOG_CHANNELS(filename)
  R.r1, R.r0    rereferencing matrix for correcting artifacts with and without offset correction
  R.b0	coefficients of EOG influencing EEG channels
  S2   corrected EEG-signal      

 see also: IDENTIFY_EOG_CHANNELS, SLOAD, GET_REGRESS_EOG

 Reference(s):
 [1] Schlogl A, Keinrath C, Zimmermann D, Scherer R, Leeb R, Pfurtscheller G. 
	A fully automated correction method of EOG artifacts in EEG recordings.
	Clin Neurophysiol. 2007 Jan;118(1):98-104. Epub 2006 Nov 7.
 	http://dx.doi.org/10.1016/j.clinph.2006.09.003
       http://pub.ist.ac.at/~schloegl/publications/schloegl2007eog.pdf



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
  REGRESS_EOG yields the regression coefficients for 
  correcting EOG artifa...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
remove5060hz


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1197
  REMOVE5060HZ removes line interference artifacts
    from biomedical signal data. Segmented data supported only 
    with an FFT-based method. 

   [s,HDR] = remove5060hz(fn, Mode)
   [s,HDR] = remove5060hz(fn, CHAN, Mode)
   [s,HDR] = remove5060hz(s, HDR, Mode)
             remove5060hz(..., '-o',outfile)
  

 INPUT:
 	fn	biosignal file
	CHAN	channel selection [default: 0 (all)]
	s	signal data
	HDR	header structure (contains labels, sampling rate etc)
	Mode    'PCA', 'PCA 50'	50 Hz PCA/SVD filter
		'NOTCH'  	50 Hz FIR Notch filter, order=3
               'FIT'           fit and remove 50 Hz sine/cosine wave
		'FFT'		fft filter - cancels 50+-0.5 Hz in Frequency domain (default)
		'FFT3'		fft filter - cancels also 3rd harmonic 50 and 150 Hz 
		'PCA 60'	60 Hz PCA/SVD filter
		'NOTCH 60' 	60 Hz FIR Notch filter, order=3
               'FIT 60'        fit and remove 60 Hz sine/cosine wave
		'FFT 60'	fft filter - cancels 60+-0.5 Hz in frequency domain
		'FFT3 60'	fft filter - cancels also 3rd harmonic 60 and 180 Hz 
       outfile	Name of file for storing corrected data. 

 OUTPUT:
	s	corrected signal data
	HDR	header structure


 see also: REGRESS_EOG, EVENTCODES

 Reference(s):




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
  REMOVE5060HZ removes line interference artifacts
    from biomedical signal...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 14
rotary_decoder


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1428
 ROTARY_DECODER decodes the spatial position from the
   two TTL signals from the spokes of a wheel
   This functions has been developed and used in [1,2] 
   for obtaining the spatial position. An earlier version of 
   of this functions was called GET_SPATIAL_POSITION.

 Usage:
   [e,v] = rotary_decoder(filename)
   [e,v] = rotary_decoder(filename,chan)
   e = rotary_decoder(data)

  Input:
 	filename: channel 7 and 8 need to contain the 
		TTL-signals from the spokes
	data: must a matrix with two columns, that 
		contain the TTL-signals of the two spokes
       chan: channels containing the TTL-signals
 		default: channels with labels 'Adc-9' 
               and 'Adc-10', or channel [7,8].

  Output:
       e: spatial position at each sample in time.
       v: velocity (estimated based on distance differenc within on 25ms) 

 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.  
     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 
 



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 ROTARY_DECODER decodes the spatial position from the
   two TTL signals from...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2
rs


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 268
 [y2] = rs(y1, T) resamples y1 to the target sampling rate y2 using T
 [y2] = rs(y1, f1, f2) resamples y1 with f1 to the target sampling rate f2 

 RS does not require overlap data. 

 see also: SOPEN, SREAD, SCLOSE, MAT2SEL, SAVE2TXT, SAVE2BKR

 Reference(s):



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 [y2] = rs(y1, T) resamples y1 to the target sampling rate y2 using T
 [y2] ...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
spatialfilter


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 541
 Spatial filter provides different spatial filters. 

 W = spatialfilter(NS,...)
 W = spatialfilter(s,...)
 W = spatialfilter(HDR,...)
 W = spatialfilter([.], Mode)
 W = spatialfilter(s,'CSP',s2)
 
 NS	number of channels
 s	data matrix (one column per channel)
 Mode	'Mono': monopolar
	'CAR':	common average reference
	'Laplace': Hjorth's Laplacian
	'bipolar': all posible combinations of bipolar channels
	'PCA': Principle Component Analysis
	'ICA': Independent Component Analysis
	'CSP': Common Spatial patterns
	'ALL': Combination of all



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 51
 Spatial filter provides different spatial filters.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
spikes2bursts


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2575
 spikes2bursts convert spike trains into bursts. 
  Spikes with an interspike interval smaller  
  than 75 ms are considered a burst. The results are stored as an 
 event table. 

 HDR = spikes2bursts(filename)
 ... = spikes2bursts(HDR)
 ... = spikes2bursts(... [, dT_Burst ])
 ... = spikes2bursts(... [, dT_Burst [, dT_Exclude] ])
 ... = spikes2bursts(... , 'dT_Burst', dT_Burst)
 ... = spikes2bursts(... , 'dT_Exclude', dT_Exclude)
 ... = spikes2bursts(filename, ... , '-o',outputFilename)
 ... = spikes2bursts(... , '-e',eventFilename)
 ... = spikes2bursts(... , '-b',burstFilename)
   
 Input: 
	filename  name of file containing spikes in the event table
	HDR	header structure obtained by SOPEN, SLOAD, or meXSLOAD
	dT_Burst	[default: 50e-3 s] am inter-spike-interval (ISI) exceeding this value, 
		marks the beginning of a new burst
               'OPTIMUM_ISI' will use the function OPTIMUM_ISI_SPIKE_BURST_SEPARATION
               for identifying dT_Burst.
	dT_Exclude an interspike interval smaller than this value, indicates a
		double detection, and the second detection is deleted.
		in case of several consecutive ISI's smaller than this value,
		all except the first spikes are deleted.
	outputFilename
		filename to store the original data together with the newly compuated
		burst information. (Remark: this option is only supported if
 		filename (not HDR) is given as first argument 
	eventFilename
		filename to store event inforamation in GDF format. this is similar to 
		the outputFile, except that the signal data is not included and is, therefore,
		much smaller than the outputFile
	burstFilename
		filename for the "burst table", containing basic properties of each burst,
		(it is an ASCII file in <tab>-delimited format)

 Output:
     HDR	header structure as defined in biosig
     HDR.EVENT includes the detected spikes and bursts. 
     HDR.BurstTable contains for each burst (each in a row) the following 6 numbers:
	channel number, sweep number, OnsetTime within sweep [s], 
	number of spikes within burst, average inter-spike interval (ISI) [ms], 
	and minimum ISI [ms].
     data	signal data, one channel per column
		between segments, NaN values for 0.1s are introduced
	
 see also:  DETECT_SPIKES_BURSTS, SPIKE2BURSTS, OPTIMUM_ISI_SPIKE_BURST_SEPARATION

 References: 
 [1] Janina Kowalski, Jian Gan, Peter Jonas, and Alejandro J. Pernía‐Andrade
     Intrinsic membrane properties determine hippocampal differential firing pattern in vivo in anesthetized rats
     Hippocampus. 2016 May; 26(5): 668–682.
     doi:10.1002/hipo.22550



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 48
 spikes2bursts convert spike trains into bursts.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 5
trigg


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 879
 TRIGG cuts continous sequence into segments.
 Missing values (in case s is to short) are substituted by NaN's.  

 [X,sz] = trigg(s, TRIG, PRE, PST [, GAP])

 INPUT:
  S	is the continous data sequence (1 channel per column)
  TRIG	defines the trigger points
  PRE 	offset of the start of each segment (relative to trigger) 
  PST 	offset of the end of each segment (relative to trigger) 
  GAP	number of NaN's to separate trials (default=0)
  	TRIG, pre, post and gap are counted in samples

 OUTPUT:
  X	is a matrix of size [sz(1), sz(2)*sz(3)]
  sz	[size(s,2), post-pre+1+gap, length(TRIG)]   
	sz(1) is the number of channels NS 
	sz(2) is the number of samples per trial 
	sz(3) is the number of trials i.e. length(TRIG)

 X3D = reshape(X,sz) returns a 3-dimensional matrix 
 X2D = reshape(X(K,:),sz(2:3)) returns channel K in a 2-dimensional matrix 

 see also: GETTRIGGER



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 45
 TRIGG cuts continous sequence into segments.





