You are on page 1of 6

~ ~-- .

~ BEL 41f? tJo.5


4.=;::; \3'V'l vY\L ~I\f

#!/usr/local/bin/perl
sw.pl
~.~
#Smith-Waterman Algorithm

# Requires two command line arguments


#Inputs in the form seql and seq2
#Inputs in the form seql and seq2
printfCftEnter sequencel:");
$seql = <>;
printfCft\nEnter sequence2:");
$seq2 = <>;
$lenl = length(Sseql);
$len2 = lengthCSseq2);

#Initialize firit row and column with multiples of gap penalty


$gp=O;
forC$i=O;Si<=$len2;$i++)
{
$table[O][Si] = $gp*$i;
}
for($j=O;Sj<=Slenl;$j++)
{ . .
$table[$j][O] = $ gp*$ J;
}

$gp=-l; #Gap pena hy

#Coopfor \1&i,n~ t:hr~ugh each


forC$i=l;$l<=$ienl;$i++)
{ ,
entry
- -- -- - -- --
forC$j=1;$j<=$len2;$j++)
{ .
#Calculate match bonus or mlsmatch penalty
$mb=l;
$misp=-l;
$a=substr($seql,$i-l,l);
$b=substr($seq2,Sj-l,1);
if (Sa eq $b)
{
$match= $mb;

}
else
{
$match=$misp;
}

my $l=$table[$i] [$j-l]+$gp; #From left


my $r=$table[$i-l]l$j]+$gp; #From above
my $d=$table[$i-l] [$j-l] + $match; #From Diagonal
#compute maximum of three values
if(C$l>$r) && C$l>$d))
{
$table[$i] [$j]=$l;
$arrow[$i] [$J] =ft rft;
}
elsif«$r>$l) && ($r>$d))
Page 1
The experiment paradigm used for the present study is function has the form of a sum of square (as is typical in
similar to an earlier researeh done in our laboratory training feed forward network). then the Hessian matri.\
r10]. The subject was asked to comfortably lie down can be approximate as H=JTJ and gradient can be
in a relaxed position Ilith eyes closed- Initiall~ the computed as g=.ITe.Were J is the jacobian matrix that
subject was asked to relax II)r 5 min- Alier assuring contains first derivatives of the network errors \\ith
the normal relaxed state by checking the status of the respect to the weights and biases, and e is a vector of
alpha waves. the EEG I\-asrecorded fl)r ::.session of 5
s epoch each for relaxed state- This is used as basic net\\ork errors. The Levenberg-Marquardt algorithm
uses this approximation to the Hessian matri:..:in the
n:ferenee for further analysis of the planning data. The ttJIIO\\-ingNewton-like update:
subject was asked to mentally plan to mO\-e the right
handed thumb. on presentation of an audio eue. both at
Xk+l=X,,_pTJ+/-IIJ,1 JT e
the start and cnd of a session- 5 sessil)fJ of each
planning and relaxed data were reeorded each with a
time gap of 180s .The I\-hole e:\periment including a... aff"""'~.
preparation of the subjects last flJI' I hr. collecting
EEG data II)r the, 5 sessions- The 5s epochs related
normal rel<L"\edand planning period were first pruned
for artifacts and then analyzed as the foJlml"ingsetting
high pass lilter 5Hz and loIVpass tilter 1.6 Hz. notch
lilter 50 Hz .sensitivity 70 IIvfml11and a sampling rate
of 256-

As the first step. Frequency spectrum of the signal was


analyzed with FFT plots. The FFT plots IVere
observed to compare changes in mu activity during
relaxcd state and movement imagery - The peaks for
C3 & C4 almost coincide in alpha band (7-13 Hz) at a ~~

particular base frequency for relaxed st2.te.~\\Jlj..!ea. ~


maximum of 500/o...band '-Power ath:nuation was
~ observed in C3 IV.r.t.C4 (I)r movement imagery. at the
same base frequency. [11-121- The data was further
processed using Wavelet packet transt()fm to extract
the most relevant feature vector froln the signal which -.
could bccome a base vector II)r the dassitication of
the two stages'I3-14J. Walekt codtieients are used
as the ifp vector for ANN. Fig 2 -Architecture of ANN

8. .-frlljicial Neural Net1\'ork


When the scalar /-Iis zero, this is just Newton -s method-
using the appro:..:imate Hessian matrix- When ~l is large.
The main advantage of choosing the neural network this hecomes gradient descent with a small step size-
1()r classitieation of such data is that ANN-s can be NewlUn-s method is faster and more accurate near an
used to soh-e difficult problem. \I-here description I()r crror minimum. so the aim is to shift to\\ard Ne\1 tOll-s
the data is not computable. ANN can be trained using method as quickly as possible. Thus. ~I is decreased
example to discriminate the realu.-e II)r analysis wc alkr each successful step (reduction in perll)ffllanCe
ha\-e used the mat lab \-et"sion 7 II)r the analysis- fUllction) and is increased only whcn a tentatile step
Topology specit~- the neural net\lork architectUre in Ilouid increase the performance function- In Ihis \\ a~,
Figure21J5-171 the pertl)ffl1anCe function is always reduced at each
iteratioll of the algorithm. Thc value of training
Follo\\ing is a desniption of thc methods used in p<lr<lmetersII)r present study given in table 1-
this im-estigation

('. I.(,J"<!/Iberg- lIul"<l/I,-<l1

rhe Ie\enherg -l\larquardt algorillull \\ as design to


approach second ordn training 'pced II ithoul hal ing
to cnmpule the I k,sian m~i!ri_'\-\\he'll Ih\' perll)l"Illanee

~"
- ",....-----
SW.pl
{
$table[$i] [$jJ=$r;
Sarrow[$i] [$j]="u";
}
# elsif«$d>$r) && ($d>$l))
else
{
$table[$i] [$j]=$d;
$arrow[$i] [$j]="d";
}
#If resulting value<O, make it zero.
i f($tab 1 e [$i J [$j] <0)
{
$table[$i] [$j]=O;
}
}
}
$max=O;
#Display table and find maximum entry value
for($i=O;$i<=$lenl;$i++)
{
for($j=0;$j<=$len2;$j++)
{
pri ntf("Stab 1 e [$i] [$j] \ t") ; #For displaying the table

if($table[$i] [$j]>$max) #For finding Maximmum value


{ $i1=$i;
$j2=Sj;
$max=Stable[$i] [$j];
}
} -
printf("\n");
} .
printf("Maximum value is $max\n");

#For finding the alignment


$len=O;
#LOOp till substring of max length is found.
for(Si=Sil;(Si>O) && (Smax>O);)
{
for(Sj=$j2; (Sj>O) && (Stable[Si][$j]!=O) && ($max>O);)
{ #printf("loop");
#printf("$arrow[$i] [$j]\n");

$x=$arrow[$i] [$j];
if($x eq "d") #Go to diaconal element
{
$i--;
$j--;
$disl[$len]=substr($seql,$i,l);
$dis2[$len]=substr($seq2,$j,l);
}
elsif($x eq "U") #Go to above element
{
$i--;
$dis2[$len]="-";
$dis1[$len]=substr($seql,Si,l);
}
#elsif($x eq "r") #Go to left element

page 2
Pa 1">1
JlwtCI' Valuc
1\1;11..grad 1e.5 nctwork classifier to classify planlJing of right hand
_.- movement and relaxed state. For the present stucl~
Epoch 5000
Lev.:nberg-Marquardt showed better compare to RBI'.
I\lu 0001
--- Figure 3 showed eomparisolJ of classitication accurac~
!\lu dee 01 for LM and RBI' methods
!\Ill..ine 10
Gn1 Classification Accuracv (%)
Ie.O6
Session Le\'enberg- Radial basis
'"krn redue
marquard! function
!\1, Mu I 1e10 I 78.84 75.00
T~hlc I Dirferent valuc ofparanl<'I<'r 2 75.00 7058
3 6703 66.66
D. Radia! basis jill1cliol1l1cllI'(wk 4 65.384 6315
5 63.46 60,00
A typical RBI' Iletworks consist of three layer of Average 69.94 67.07
-
neuron (input. hiddell. output) which arc compollenl of T~ble2; colt)p~rison of accuracy ofLM&RBF method
fuUy connccted feed forwurd archita:ture. The special
IV. DISCUSSION AND CONCLUStON
radial b1Jj;;SbLl~avior is performed hy the single layer
of hidden neurons. The activation of a hiddcn neuron
is dcterrnined in 1\\0 steps. The !irs! js cOl11puti"~gthe The present studies evaluate tlte performance of t\\'o
distance '(USU,ll!y by using the Euclidean norm). ANN methods. We compared the perfonnance of
hetween tl1\; two veclOrs which arc yielding by the n.:uralnctwork (NN) method Levenbcrg-Mnrquardt and
activation of the input layer (x) and th.: link IV.:ight Radial basis function netwQrk for planning of right hand
between the input layer and the current hidd.:n layer, movement w,r.t. relaxed state. Levenberg-Marquardt
second n function h which is bcll shaped (c.g. method showed the highest penormance with the
Gaussian) is applied. using the obtained distance to accuracy 01'78.8%.
"
get the Uilitl activation of the hidden neuron. The
~H;tjvation of ;ll1euron in the ()utputla~..;r is t1Clcnnincd
liS usual h~ C{}11-1pm:ing "tile w.:ighted sum ofinpul.
Radii\1 basis \\"(}rkbest when many training \.:ctors ar.:
available. A RBI' network can be described as a linear
combination of basis function i.c. 8° -.'I---;
~,..60
" r
.'-==~~~j::~7~"r;;;:
~ I
/. 0"0.f(xl'~ ~ 0,11>, (x) ~ 401
Whae
=;: /? Ihe output variab!.:: j i
X): I? thc input variable: ~20
G
(I, the optimal \\'.:ight~:
</'(.\"I the radial basis functiolJ. oL
3
Session

Fig 3-classilicatio accuracy Ii>.'I.M and RBI'


There arc m"l1~ choicc~ II)r thi: radial ba~i~ function.
\\' I.'~el.:ct<.:dth\.' (iaussiall fu11\.'tion defined as
Aft\.'r successfully discriminating the t\\'o cognith\.'
stales as awak.: relaxed and a planning of right hand
-'x - x, mOlelllent. Wavelet packct transform used to <':xlractth,~
l1lo~1 rele\ant feature vector from the signal which
<P.(.\" I '"' ('.IP.( 2cr:' ) could b\.'coille a base vector for th\.' classification of the
I 1\0 ~tages. /\ comparison 1\as made b\.'ll\ \.'\.'n
rhe parall1c't.;r ," cOIJII"OI~;
Ihe radius of jnllu\.'nc\.' of 1.\.'\'\.'llberg-l'vlarquardt and Radial basis fUllction

":.11.'11hasi, t"lIIJC!jOIl. ,111<1.1, rl'j'r\.'s\.'nlS its c\.'lller IIX- 1l\.'lllork. Wher\.' the perfi.)f"Jnance giv<.:n b~ Le\ \.'nberg-
191, \Iarquardt method i~ signilicantly bett\.'r than oth<:r.

III RESUL T

1,lble :2 sholl Ihl' L"lll!',lli,olJ of the p,'rl('nndllcc of


I 1.'1,'lJh,'I'!: - \ l"re!lI,II<lt 8: Radial ha,j, (lIIlCI jplJ
ACKNOWLEDMENT

Thc author's acknO\lkdge Iheir gratitude tOIlard,


math \lorks for \I alekt alld Ileural Ilct\lork tooll1o.\ ['II .I R \\','Ipa\\. D. J. Me Far!and. T 1\1 Vaughan. 'Ihe \lads
\\hich helpcd 10 compik Ihe result. '\l>rtP Cemre Brain l'omp'Her inler!;,ee leseareh and
Dc, olopment Program."IEIT Trans on Ncural S'Slem and
,ehab Eng" 1112))20-l..207.200}
REFERENCE II (II .I", ashree Santhosh. Mall\ ir Bhalla. S.Sahli Slieh Anand
"(,)ua"tuali\e ITG analysis for assessmelll tt>plall a ta,k ut ,\IS
palletH' a silidy of exeellti, e flilleh"11 Iplalillon~) III ..\LS."
III .I.R.Wolpa". NBirbaumer. I)) Mc Farland. G.Plurtschelkr. C"gllni\e braill fl'search 22.59..66. 20()-I.
T M. Vaughan. "Brain computer Inter!"acesfor communication
and controL" Clinical Nurophl's. .113.767-791,2002 II1I T"II«.1 Ebrah,m,. .lcan marc Vesill. and (ira, (ia,(la "Bram
121 (;.Pfurtschelk. DFh,tzlllger. and .lKalchcr. "Brain Computer \'('mpllter inlert",e ill mullimedia rommllllleation."IEEE
inter!"ace-A .ne\\ communication device Ii" handicappcd. SIgnal rrneessing magazine. 1-1/20.2000.
people" .I Micn>compul..<\pplicate"vol. 16..1'1'.293-2')<).1
'No 1121 Ii Pfllrtseheller. CNeliper. /\ Sehlogl. an.u K Lugger
[31 .lR Wolp"". TlVLVaughan and E.Dunchin. "U..:(; Ba,,'d
"~epalabihly o!" EEG signals recorded dllring roght and :en
Communicat;on prospects and problems.""T!'..
n"'tor imagen' using adaptive allto regre<.SI\e parameters:'
Trans. Rehah.J:ng,,\OIA..ppA25--I30, Dec. 1996.
liTE. Tmns. on rehabilitation Ellgineering. fl..:;. rp316..3~5
1-11 II.Ramoser. JMullkr (;erking and G. Purftscheller. "Optin"'l 1"9~.
spatia' liltering of single trial EEG during Imagined 11.~I \1 Aka\. Walelet in biomedICal en!,lnwrilig. allnatsin
handmovement."IElT Trans .Rehab.Eng. vol.8, -1-11..-1-16 Ih,'medkal Engineering, 23 (5). 5:; 1..~-I2.IW~
Dee.1000. 11-11 Ci,lI",rt Strallg and Troung Ngllgen. Wa\elel and Ftll<r E5ar.ks
\\'dksley.Cambridge pre;s, 1997.
(5J AElean, Curran and Jamaica Strokes learning to control bram II ~I 1\c'ural N':lwork toolbox. Ihe math works Inc 1998.
activity' ../\ Revie\\' of the production and control of FE(i 1161 S.lIa\ kin Neural Net\\'ork.. /\ Comprehensi\\.' t.'undatim). 2""
components for driving Bain computer inter!;,ce FJmon .Prentice Ilall, 2000.
systems"Brain aoJ cognition. 51.326-3362003. [171 i\t Hag"n. II Demuth. and M. beale. Nellral Nel\\'ork dcsign
[6) L.l.eocani. C Tom. P.Lhuang. CGerllT and M.HalieH. "hent
H,'slt'n MA.. PWS Publishing. 1996.
related Jesyncronizationin reation time paradigm a I!XI K. Warwick. J!\hlson" arKIESutanto., "Centre Selection lor
comparision "ith event related potential and cortical Ra.1",; Basis Function Network". Artif,,'ial Network and
"",.itOhili!):'-cl~cal Neuroph"siology, 112,923-930,200 I. Genetk algurithms. proceeding of Ihe international conference
[7] B.Grainmann. J.E. Huggms S.P. Levin and C;.Pfurtseheller.
"V,sualiz.ation of signification ERD/ERS pattern III
multicanncl E[G and EcoG data," clinical Neurophysiology. IllJl
31)<J:3 11. . -
...\ks. France ,D. l'earsnn.N.Sc'Ctlc and R Albr.:ehl(Eos)
~- -~ ~
S.l'hcn. . C.F.N. Cowan, and P. M Grant.""'i)nh,~JOri'i!ILeasl
-13..47.2001.
18) G. Pfurtschctler and 1'.11. Lopes da silva,"Event ..rclatc-J S..;",!!,;, Learning Algnrithnl for Radial Oasis runction
N~l\\t)fks." IEEE Transactions on Nellral Networks, \'tll. 2. n<l.
EEG/EMG dynamic Synchronous and desynchronous basic 2. pp. 301..3()<).March 19'11. 1995.
principlt:s." cli_;>$ Neurophysiology, 110, 18-12..IX52..930.
1999.
-~
~
sw.pl
else
{
$j--;
$disl[$lenJ="-";
$dis2[$lenJ=substr($seq2,$j,1);
}
$len++;
$max--;
}
}

#Display, the alignment.


printf('Alignment\n");
for($z=$len;$z>=O;$z--)
{
printf("$disl[$z]");
}
pri ntf("\n").;
for($z=$len;$z>=O;$z--)
{
printf("$dis2[$z]");
}
<STDIN>;

.~ -=-
=~~
=-=-. ""' = = =="'" ~".~
'"
""

Page 3

You might also like