This is the research Title : Alzheimer’s disease detection from optimal electroencephalogram channels and tunable Q-wavelet transform
Authors are Digambar Puri, Sanjay Nalbalwar, Anil Nandgaonkar, Abhay Wagh
DOI: 10.11591/ijeecs.v25.i3.pp1420-1428
Below is the note i made from research paper, read both research paper and my notes to make me a complete code for this project that can run using python and on google colab
the dataset location is "C:\Users\Windows 10\Dataset\dataset\AD_Data_origanl mat file\Dataset 1"
in which in this these are the files

preproctrials01.mat
preproctrials02.mat
preproctrials03.mat
preproctrials04.mat
preproctrials05.mat
preproctrials06.mat
preproctrials07.mat
preproctrials08.mat
preproctrials09.mat
preproctrials10.mat
preproctrials11.mat
preproctrials12.mat
preproctrials13.mat
preproctrials14.mat
preproctrials15.mat
preproctrials16.mat
preproctrials17.mat
preproctrials18.mat
preproctrials19.mat
preproctrials20.mat
preproctrials21.mat
preproctrials22.mat
preproctrials23.mat

if i load "preproctrials01.mat" in matlab, workspace opens on right side
which has following info:
data  1x1 struct

and the in middle i get these info:
fsample 256
sampleinfo [1,1280]
trial	1x35 cell
time 	1x35 cell
label 	16x1 cell
cfg 	1x1 structure
from which "trial" and "time" is only thing that changes for everyfile,
other things like fsample, sampleinfo, label and cfg doesn't change
NOTES: 

a method to detect the AD patients from NC subjects using a novel
approach of channel optimization and TQWT based features extraction. Initially, the number of channels are
optimized using Shannon entropy to signal energy ratio. The EEG signals from 10 optimized channels were
decomposed into nine different SBs. The four different features are extracted from nine SBs to train and test
various classification models. The extracted features from SB7 with EBT produced the highest classification
accuracy of 96.20% with ten-fold cross-validation and it outperforms the state of the art methods.
Introduction
Proposed Method
	EEG dataset
		12-AD and 11-NC subjects
		16-electrods used named, Fz, Cz, Pz, O1, O2, F3, F8, Fp1, Fp2, F4, F7, C3, C4, T4, T3, T6 and T5
		captured eye-closed and resting state during day time in multiple sessions
		five seconds, 256Hz using 12-bit Analog to digital converter
		Flow diagram
			1. EEG Data
			2. Channel optimization
				1. Subband filtering
				2. Shannon Entropy (ShEn) and Signal Energy (E)
				3. ShEn by E ratio calculation
				4. Backward Elimination
			3. TQWT decomposition
			4. feature extraction
				1. Tsallis entropy (TsEn)
				2. Renyi's entropy (ReEn)
				3. Katz;s fractal dimension (KFD)
				4. Kurtosis (K)
			5. Classification
				1. AD
				or
				2. NC
	Channel selection method
		desire for optimal channel selection to reduce data redundancy and computational complexity
		from each channel is filtered into delta (δ: 0.5-4 Hz), theta (θ: 4-8 Hz), alpha (α: 8-13 Hz), and beta (β: 13-30 Hz) EEG SBs 
		SEREN is measured
			S E S E R=\frac{S h E n}{E}=\frac{-\sum P_m \log \left(P_m\right)}{\sum s(n)^2} ; Pm = probability of datum being in bin & s(n) = samples in EEG data sequence
		Out of 16 EEG channels only ten most significant channels ( Cz, Pz, O1, O2, Fp1, Fp2, C3, T4, T3 and T5) were selected for feature extraction followed by classification
		Pseudo code for channel optimization 
			1: Filter EEG signal into EEG SBs. Find ShEn/E ratio. Get max(ACC) = T H, channel count j = 16;
			2: while (1 ≤ i ≤ 16) do
			3: Remove Cj
			4: if ShEn/E ≥ TH then
			5: Reject the channel Ci;
			6: j ← j − 1;
			7: else
			8: j ← j − 1, Don’t reject Cj
			9: end if
			10: i ← i + 1;
			11: end while
			12: The value of j gives the number of optimal channels.
	Tunable Q-walelet transform
		TQWT consits of two variable parameters named Redundancy (R) and quality factor (Q), which can be changed to get required time-frequency resolution
		TQWT consist filter filter bank with two channels;
			1st: Lowpass filer (LPS) 
				H_0(w)=\left\{\begin{array}{cc} 1, & |w| \leq(1-\beta) \pi \\ \Theta\left(\frac{w+(\beta-1) \pi}{\alpha+\beta-1}\right), & (1-\beta) \pi<|w|<\alpha \pi \\ 0 & \alpha \pi \leq|w| \leq \pi \end{array}\right.
			and 2nd : Highpass filter (HPF)
				H_1(w)=\left\{\begin{array}{cc} 0, & |w| \leq(1-\beta) \pi \\ \Theta\left(\frac{\alpha \pi-w}{\alpha+\beta-1}\right), & (1-\beta) \pi<|w|<\alpha \pi \\ 1 & \alpha \pi \leq|w| \leq \pi \end{array}\right.
			expression for Θ(w) is
				\Theta(w)=\frac{1}{2}[\cos (w)+1][2-\cos (w)]^{0.5},|w| \leq \pi
			α and β are scaling parameter of LPF & HPF in range of 0 to 1, α+β>1
		Q is depending on SB central frequency F0 and Bandwith Bw; Q=F0/Bw
		β=2/Q+1 and α=1-β/R
		In decomposition of EEG using TQWT, authors selected parameters of Q=1, R=3 and J=8 after doing some testing
		Thus 9 different SBs have been evaluated
	Feature extraction
		decomposed in 9 different SBs using TQWT
		feature 1:TsEn measure has proved to be more robus compared to ShEn which detects spikes, bursts and EEG rhythms
			T s E n=\frac{1}{q-1}\left(1-\sum_{m=1}^N p_m(v)^q\right)
			where, 	q>0, 
					Pm are the probabilities of a datum being in bin
					N is number of samples in EEG
		feature 2:ReEn is used for epilepsy, drowsiness etc. Generalized the Hartley entropy, collision entropy, ShEn and min-entropy. Utilised to calculate entanglement
			\operatorname{ReEn}=\frac{1}{q-1}\left(\log \sum_{m=1}^N p_m(v)^q\right)
			where,	q is parameter value between 0 and 1.
					N is maximum number of segments in EEG
		feature 3: KFD is most important type of fractal dimension used to measure complexity. which can be defined as the sum and average of Euclidean distances between successive points of a sample D and b respectively, are measured also teh maximum distance between the first point and other point of the sample left
			K F D=\frac{\log (D / b)}{\log (l / a)}=\frac{\log (m)}{\log (m)+\log (l / b)}
			where, m=D/a
		feature 4: Kurtosis (K) can be expressed as a measure of how outlier-prone a distribution is
			K=\frac{E(x-\mu)^4}{\sigma^4}
			where, µ is mean and σ is standard deviation (STD)
Classification
	to detect the AD from NC using KFD, TsEn, ReEn and K feature setthe author used various classifiers namely fine-DT, cubic-SVM, cosine-KNN, wide-ANN and EBT.
	TQWT based time-frequency method has been used to overcome the limitations of wavelet and FFT. TQWT parameters Q=1, R=3, J=8 are selected to decompose EEG to produce nine SBs
	features are calculated from nine SBs.
	The statistical analysis of extracted feature sets has been performed using KW test, which provides the value of "p" probability; if value of p<0.05 are significant to discriminate the different classes. The p probability values for KFD, TsEn, ReEn andK features have shown in Table
	Table: Summary of p-values calculated using KW test for AD vs NC classes in each SB
	Subbands		 KFD 			TsEn 			ReEn 			K
	   SB1 		1.01×10^−33 	3.53×10^−118 	3.37×10^−45 	4.62×10^−14
	   SB2 		1.94×10^−15 	4.44×10^−122 	9.82×10^−64 	9.34×10^−21
	   SB3 		9.93×10^−17 	4.15×10^−87 	6.58×10^−42 	8.75×10^−7
	   SB4 		5.29×10^−15 	5.08×10^−62 	1.70×10^−48 	1.23×10^−5
	   SB5 		1.15×10^−110 	8.03×10^−29 	7.49×10^−16 	4.25×10^−8
	   SB6 		1.00×10^−139 	3.61×10^−4 		5.55×10^−24 	1.08×10^−17
	   SB7 		2.01×10^−143 	4.21×10^−6 		6.48×10^−15 	4.49×10^−11
	   SB8 		8.92×10^−127 	9.43×10^−8 		5.45×10^−17 	8.89×10^−5
	   SB9 		1.07×10^−150 	1.94×10^−4 		9.02×10^−14 	3.94×10^−12
	all features are having p < 0.05. Hence, all features were selected for further analysis
	The five different classifiers, namely Fine-DT, Cubic-SVM, KNN, Wide-ANN, and EBT are
trained and tested using the above evaluated feature sets. The model parameters and kernel functions for each
classifier have been adopted from various iterations. The ten number of splits in Fine-DT are selected. In
Cubic-SVM, the kernel was chosen as automatic. The parameter values such as k and number of splits are
50, and 10 were selected. The learning rate of 0.1 and the activation function as ReLu have been selected to
achieve maximum accuracy. In ANN, the layers and iteration limit were two and 500, respectively. Table 2
demonstrates the classification accuracy obtained from various classifiers for each SB. The EBT performs best
out of all five models with a classification accuracy of 96.2% using SB7 feature sets.
	After EBT, the KNN performs better and provides an accuracy of 94.1% for SB7. The highest accuracy
obtained from the DT model is 91.9% for SB7, and worst is 87% for SB9. In the case of SVM, higher ACC
obtained is 93.8% for SB7 and lower ACC is 84.8% for SB9. DT and NN perform poor compared to other
classification models. The EBT performs worst for the feature sets from SB9. Out of nine SBs, the seventh SB
have the highest discriminating ability compared to other SBs. The performance evaluation parameters ACC,
SEN, SPE, precision, F1-score, MCC, and κ-value for classifiers with SB7 have presented in Table
	The classification accuracy (%) for each SB evaluated by variety of classifiers with 10-fold cross validation technique when Q = 1, r = 3, and J = 8
Classifier 	SB1 	SB2 	SB3 	SB4 	SB5 	SB6 	SB7 	SB8 	SB9
Fine-DT 	89.3 	88.1 	89.1 	90.5 	91.1 	91.7 	91.9 	90.3 	87.0
Cubic-SVM 	93.7 	91.9 	93.1 	92.8 	93.5 	93.4 	93.8 	92.5 	84.8
Cosine-KNN 	93.1 	92.8 	92.6 	92.5 	91.9 	92.5 	94.1 	91.7 	83.0
EBT 		93.2 	91.7 	91.4 	92.2 	93.1 	93.1 	96.2 	93.7 	85.5
Wide-ANN 	92.3 	91.7 	92.3 	92.8 	92.9 	91.9 	91.7 	91.6 	84.5
	From Table 3, it is observed that EBT has the highest SEN 90.49% and SPE 97.5%. The worst SEN
and SPE noted by DT, i.e. 86.6% and 92.5% respectively. The precision, F1-score, MCC, and κ values for
EBT are 93.24%, 94.84%, 86.73%, and 80.64% respectively
	The comparison of the proposed method with state of the art techniques which have used same EEG
datasets have been shown in Table 4. Abasolo ´ et al. has developed various entropy based technique to detect
the AD from NC from EEG signals and obtained maximum ACC of 90.91% for ApEn and AMI [6], [7], [9],
[10]. Escuredo et al. proposed a MSE based method to overcome the limitations of ApEn and achieved the
ACC of 90.91%. Afterwords, Simons et al. used QSE and FuzzyEn to detect AD [8], [11]. The FuzzyEn
provided the 86.36% classification ACC. It must be noted that the above mentioned methods used only time
domain complexity features. The proposed method achieved the 96.20% ACC with TQWT and EBT from SB7.
	The comparison of proposed method with the recently reported methods which used different EEG
datasets have been shown in Table 5. All the methods mentioned in the Table 5 were used wavelet based features
to detect the AD from NC. Safi et al. used wavelet based HP features and achieved maximum ACC of 95.79%
with SVM among all other studies [14]. In the proposed method, EBT classifier has provided promising results
in detecting AD patients from NC subjects using the TQWT based features from the seventh SB.
	. The extracted features from SB7 with EBT produced the highest classification
accuracy of 96.20% with ten-fold cross-validation and it outperforms the state of the art methods


this is the note for research paper now generate full code for matlab, in which i just want to use knn method