; PRO WAVE_EEG, NOPRINT=noprint, EPS=eps, LINE=line, NOLOG=nolog, $ ; NODELTA=nodelta, ERROR=err, BATCH=batch, TERMI=termi, $ ; TEST=test, TO_MENU=to_menu ;=============================================================================== ; PRO:WAVE_EEG.PRO K.-H. Dittberner - 25.FEB.1992 ; V 04.15 P 476/60 - 28.AUG.1997 ;=============================================================================== ; Autoren: ; WAVE_EEG.PRO -- V 3.14 L. Fuhry - 14.JAN.1993 ; aus WLEO_EEG.PRO -- V 3.3 L. Fuhry - 3.NOV.1992 ; aus WAVE_EEG.PRO -- V 00.3 K.-H. Dittberner - 17.SEP.1992 ; aus EEG.PRO -- V 322 Przybyszewski - 5.SEP.1992 ; ; IDL(V2.1)-Routine: Wavelet-Analyse von EEG-Signalen (Evoked Potentials): ; Berechnung und Ausgabe von 3D-Plots sowie Contour-Plots ; der Wavelet-Analyse mit der Option ; der Ermittlung des Unterschiedes zu Bezugs-Signalen ; ("random shuffled" EEG's). Dieser wird durch verschieden- ; artigen Schattierungen bzw. Rasterungen der signifikanten ; Flaechen dargestellt. ; ; HINWEISE: o W i c h t i g ! Vor dem Start von AVE_EEG eingeben: ; IDL> .SIZE 32000 8000 <<<<<<<<<<<<<<<<<<<<<<<<<< ; o Beschreibung dieses Programms: "wdv-notes" Nr.129. ; o Die Berechnung der Bezugs-Signale ("random shuffled" ; EEG's) m u s s v o r h e r aufgrund der gleichen ; Datenbasis mit dem IDL-Programm AVE_EEG (P 476/37) ; erfolgt sein. Dieses Programm ist in den wdv-notes ; Nr.102 beschrieben. ;=============================================================================== ; Quelle: Programm Merkposten: o WAVE_EEG.PRO => PRO umwandeln? ; "eeg.pro;322" o ; vom 5/9/92-12.10h von o On_Error, 2 aktivieren ? ; A. W. Przybyszewski. o ; WDV-Projekt: C92 253 o Keywords festlegen. ; o Save memory: VAR=0. ; Aufruf: > SET DEFAULT directory o ; > IDL o UP "WAVELET" verwenden. ; > .SIZE 32000 8000 (leider!) o ; (gleich Key F20) o ; > .RUN Wave_EEG o Nichtbenutzung Kw. /T3D ? ; o ; o ;=============================================================================== ; Liste der verwendeten IDL-Programme der Abt. Wiss. Datenverarbeitung am IFP: ; ; o Common_EEGS P 476/49 Def. eines gemeinsamen Datenbereichs fuer EEG's. ; o F_Element P 476/33 Extrahieren von Teilen aus einer Zeichenkette. ; o Get_EEG_Data P 476/34 Lesen strukturierter EEG-Daten (Potentiale). ; o Get_Number P 476/50 Eingabe einer Zahl mit Pruefung der Wertegrenzen. ; o Get_Reply P ? /? Eingabe eines Strings mit Pruefung. ; o Image_Overlay P 476/48 Ein Bild mit einem Rahmen versehen. ; ; o Ask P 476/10 Befragung des Benutzer mit Ja/Nein-Verzweigung. ; o Expand P ? /? Veraenderung der Groesse eines Arrays mit Interpol. ; o Find_File P ? /? ; o Get_Reply P 476/51 Eingabe einer Antwort mit Pruefung der Gueltigkeit. ; o Print_Plot P 476/2 PostScript-Ausgabe einer Grafik-Datei. ; o Print_Pot P 476/52 PostScript-Ausgabe eines (EEG-) Potentials. ; o Read_FileName P 476/30 Eingabe einer Dateibezeichnung mit Pruefung. ; o Simp_Stat P 476/40 Einfache Statistikberechnungen. ;=============================================================================== ; Aenderungen: [Ab 8/9/92-khd] => V 00.1: ; - Diverse Tests von Aenderungen, Korrekturen und totalen ; Umstrukturierungen im ersten Teil der Vorlage "eeg.pro;322" ; von Przybyszewski vom 5/9/92; dieses ======> WAVE_EEG.PRO. ; - Common-Bereiche EEGS, DEVI, PLOTS (wie bei AVE_EEG V 02.15c) ; eingefuehrt sowie das Menue geaendert (1.Stufe). ; - Deshalb Umbenennungen von VAR: str => ans | ... ; - Pkt.0 - 7 zur Strukturierung eingefuehrt. ; - Statt Przy's UP "IMAGE_CONT0" das dokumentierte Bibliotheks- ; UP "IMAGE_OVERLAY" (P 476/48) verwendet (Check am 15/9/92). ; - Laden einer Graustufen-Farbtabelle zugefuegt. ; - Bereits einige Achsentitel verbessert. ; - UP "GET_DATA" zum Lesen diverser Daten-Files eingefuehrt. ; - 1. Tests mit Daten DEMO:PI_R2.TXT umgestellt auf "AVE"-Typ ; ===> DEMO:TEST.TXT. Diese Tests sind alle ok. ; - Hinweis: Das externe UP "Get_EEG_Data" (P 476/34) ist ab der ; Version V01.10 vom 16/9/92 in der Lage die erste Zeile mit ; den Basis-Parametern einer "AVE"-Datei auszuwerten. ; [17/9/92-khd] => V 00.2: (Experimentalfassung => FUHRY + PRZY) ; - Die Grundeinrichtung der Pkt.0 - 7 ist erfolgt. ; - Damit ist nun das Lesen der Dateien vom Typ "AVE" + "EVP" ; moeglich. Den Tests (siehe unter Merkposten) zu den offenen ; Fragen (an Przy...) steht nichts mehr im Wege ... ; - Einige Fehlermoeglichkeiten abgefangen; sicher nicht alle. ; [27/10/92-fuhry] => V 03.10: ; - Das Programm ist vollstaendig umgekrempelt worden, was hier ; (leider) nicht alles notiert wurde. ; - Das Programm muesste jetzt laufen! ; - Sicherlich sind noch einige Macken zu beheben und Tests von ; anderen Anwendern durchzufuehren. ; - Moeglicherweise laesst sich der Ablauf weiter automatisie- ; ren. ; - Die Bounding Box bei EPS-Ausgabe stimmt noch nicht! ; - Einige Fehler in den Plots sind mit Sicherheit auf Fehler ; in IDL zurueckzufuehren! ; [9/12/92-khd] => V 03.11: ; - Den Common EEGS auf die erweiterte Form (+ 7 VARs) ; umgestellt. ; [14/1/93-fuhry/khd] => V 03.12-14: ; - Diverse Kleinkorrekturen, die hier nicht alle notiert ; wurden. ; [28/8/97-khd] => V04.15: ; - Alles: R e l e a s e ===> 4, was V03.14 entspricht. ; Es sind nur einige Kommentare minimal ergaenzt worden. ;=============================================================================== ; 0. Definition von Hilfs-Routinen: ;=============================================================================== ; PRO GET_DATA, fehler,TYPUS=typus, DATEN=daten On_Error, 2 On_IOerror, IO_Error COMMON EEGS, project, job, file, time, sp, name, dev, ans, $ tvor, tnach, tsamp, points, nx, n_pot, fileTypus, $ anzahl, n_vpn, n_cat, n_loc, n_dif, t, proj ;============================== ????????? ==================================== ; Was ist eigentlich der fundamentale Unterschied zwischen nx und points? ; Antwort: Verschiedene Autoren lieben unterschiedliche Variablennamen. ;============================== ????????? ==================================== fehler=0 ; Boolean line = "" fileTypus = typus Ask_File: IF daten eq "REF" $ THEN Read, $ "* Enter file name for Random shuffled Data (program adds .TXT) > ", $ file $ ELSE Read, "* Enter data file name (program adds .TXT) > ",file file = StrUpcase(file) IF (file eq "") THEN GOTO, Ask_File job = F_Element(1, ":", file) ; Evtl. vorhand. Device entfernen. IF (job eq ":") THEN job = file Check_File: filNam = file + ".TXT" answer = FindFile(filNam) ; Ist File vorhanden ? IF answer(0) eq "" $ THEN $ BEGIN print,"" print,"Data-File does not exist!" ans=Get_Reply("Do you want to try again?","Y|N","Y",/NoCase) IF ans eq "Y" $ THEN GOTO, Ask_File $ ELSE $ BEGIN fehler=1 GOTO, Ende ENDELSE ENDIF If (Daten eq "REF") $ ; Anzahl der Datenpunkte pro THEN $ ; Potential aus der 1. Zeile Begin ; einer Datei vom Typ "AVE" lesen. OpenR, in, filNam, /Get_LUN ReadF, in, line IF daten eq "REF" THEN nx = Fix(F_Element(1, " ", line)) ; Hinweis: VAR points wird bereits Free_LUN, in ; im UP "Get_EEG_Data" ermittelt. Endif Get_EEG_Data, filNam ; Daten laufen via COMMON EEGS! Return IO_Error: Print, !Err_String Free_LUN, in Ende: END ; Get_Data ; ;=============================================================================== ; Pro Wavelet_Transform, sp,tsamp,tvor,tnach,extent,ppoints,ams,mas,steps, $ Max_Amp,Min_Amp,Akt_Amp, $ Max_Wave_Ext,Min_Wave_Ext,Akt_Wave_Ext, $ Max_Wave_t,Min_Wave_t,Akt_Wave_t, $ y,wx1,wy1,name1,fehler, $ Termi_Job,Batch_Job fehler=0 ; Boolean FOR i=0,steps DO $ ; 1. Mal ; steps + 1 Durchgaenge BEGIN print,"Processing",i+1,". of",steps+1, $ "Wavelets...",Format="(A10,I4,A4,I4,A12)" mag=2*mas*(1+i/2.) Akt_Amp=ams*(1+i/2.) ; frueher: amp ; halbe aktuelle Waveletbreite, skaliert Akt_Wave_Ext=2*Akt_Amp ; aktuelle Waveletbreite, skaliert Akt_Wave_t=Akt_Wave_Ext*tsamp/extent ; Breite des aktuellen Wavelets in ms ; nach Reskalierung sigma=Akt_Amp/4 ; sigma ist Sigma der Gauss-Funktion x=(Findgen(2*Akt_Amp+1)-Akt_Amp)/sigma ; x immer von -4 bis +4, ; 2*Akt_Amp+1 Punkte Fun=10/(sigma^2)*(1-x^2)*exp(-(x^2)/2) ; Waveletfunktion: Mexican-hat mit ; Wichtungsfunktion w=sigma*Sqrt(2*!pi) , ; denn Mexican-hat eigentlich: ; Fun=10/((sigma^3)*Sqrt(2*!pi))*(1-x^2)*exp(-(x^2)/2) IF Termi_Job OR Batch_Job THEN GOTO, Wavelet_Cut IF i eq 1 $ ; erst im 2. Durchgang (ohne Bedeutung) THEN $ BEGIN wset,1 plot,fun,/xstyle,xtitle="Number of Points",title="Analysing Wavelet" ENDIF Wavelet_Cut: a1=Fix(Max_Amp-Akt_Amp) ; gibt Anfang fuer Waveletberechnung an ; Dadurch wird erreicht, dass fuer alle i die gleichen Punkte ; berechnet werden und das analysierende Wavelet nicht aus dem Be- ; reich geht ; entspricht alter Berechnungsweise a2=ppoints-1-a1 ; gibt Ende fuer Waveletberechnung an ; ppoints: Gesamtzahl der Punkte eines Potentials nach Skalierung ; analog zu a1 ; entspricht alter Berechnungsweise ; ; Veranschaulichung: ; ; ^ ^ ; Beginn des Potentials ppoints Ende des Potentials ; ; ^ ^ ^ ^ ^ ^ ; halbes halbes max. Wavelet halbes halbes ; ; ^ ^ ; Beginn der Berechnung, Ende der Berechnung ; ; ^ ^ ^ ^ ^ ^ ; aktuelles Wavelet ; ; ^ ^ ; Beginn des aktuellen Fensters Ende IF a2 le a1+20 $ ; damit mindestens 20 Punkte zur Wavelet-Transformierung ; vorhanden sind THEN $ BEGIN print,"There are not enough points for Wavelet-Transformation!" fehler=1 GOTO, Ende ENDIF c=convol(sp(a1:a2),fun) ; da kein Keyword Center gesetzt, wird ; das Kernel ueber jedem Datenpunkt zen- ; triert! c=c(Fix(Akt_Amp) : ppoints-1+Fix(Akt_Amp-Max_Wave_Ext)) ; hierdurch werden wieder die ueberstehenden ; Raender abgeschnitten, naemlich vorne und hinten ; die halbe aktuelle Waveletbreite ; entspricht nicht ganz der alten Berechnung (dort ; war der Term vor dem Doppelpunkt um -1 zu gross!) ; zum Verstaendnis: N_Elements(c)= a2-a1+1 ; N_Elements(Fun)=Max_Wave_Ext+1 ; ==> (N_Elements(Fun)-1)/2.=Akt_Amp IF i eq 0 THEN y=c $ ELSE y=[[y],[c]] ; y: ; 1.dim: ppoints-Max_Wave_Ext ; 2.dim: alle steps ENDFOR ; i=0,steps 1. Mal IF Termi_Job THEN GOTO, Ende ; Image-Ausgabe wird unterdrueckt print,"Producing image..." IF steps eq 1 $ ; falls einzelnes Wavelet betrachtet werden soll THEN $ BEGIN z1=c plot,z1,/xstyle,xtitle="Time",ytitle="Amplitude",title="Wavelet" ENDIF $ ELSE $ BEGIN ysum=bytscl(y) ;rescale all together!!!!!!!!!!!! ysum=congrid(ysum,wx1,wy1) ; congrid nicht durch expand ersetzt, weil an ; dieser Stelle der Rechenaufwand bei weitem ; zu gross ist. Die Rechenzeit betraegt meh- ; rere Minuten mit expand, weil wx und wy=412 ; An dieser Stelle ist eine genaue Interpola- ; tion auch gar nicht notwendig, weil die Be- ; rechnung nur der Bildschirmdarstellung ; dient !p.title=name1+" steps = "+string(steps,"(i3)") !x.range=[-tvor+Max_Wave_t/2,tnach-Max_Wave_t/2] !y.range=[1,steps] !y.ticks=6 !x.margin=[10,10] Image_Overlay, ysum, /NoData ; warum /NoData? Wird hier nun ysum angezeigt? wsize=[!x.window(1)-!x.window(0),!y.window(1)-!y.window(0)] x_window=!x.window y_window=!y.window axis,yaxis=1,yrange=[Min_Wave_t,Max_Wave_t], $ ystyle=1, ytitle="Width of analysing wavelet [ms]" !x.range=0 !y.range=0 !y.ticks=0 ENDELSE Ende: END ; Wavelet_Transform ; ;=============================================================================== ; Pro Noise_Store, ysm,ysd,anz_noise,pardiff, $ nx,tsamp,tvor,tnach,extent,steps,ppoints,ams,mas,SkFak,Dev_F, $ Max_Amp,Min_Amp, $ Max_Wave_Ext,Min_Wave_Ext, $ Max_Wave_t,Min_Wave_t On_Error,2 On_IOerror,IO_Error Noise_File_Eingabe: Noise_file="" read,"Filename for Noise-File (Program adds .NSE)? ",Noise_file IF StrPos(Noise_File," ") ne -1 OR $ StrPos(Noise_File,"/") ne -1 OR $ StrPos(Noise_File,",") ne -1 OR $ StrPos(Noise_File,"!") ne -1 OR $ StrPos(Noise_File,"?") ne -1 $ THEN $ BEGIN print,"File name is not valid!" GOTO, Noise_File_Eingabe ENDIF Noise_file=F_Element(0,".",Noise_file)+".NSE" openw,noise,noise_file,/Get_LUN printf,noise,nx,tsamp,tvor,tnach printf,noise,ppoints,ams,mas,pardiff printf,noise,extent,steps,SkFak,Anz_Noise,Dev_F printf,noise,size(ysm) print,"Writing mean of noise..." printf,noise,ysm,Format="(5(F15.6))" print,"Writing standard deviation of noise..." printf,noise,ysd,Format="(5(F15.6))" Free_LUN,noise Return IO_Error: print,!Err_String Free_LUN,noise END ; ;=============================================================================== ; Pro Noise_Load, fehler,ysm,ysd,anz_noise,pardiff, $ nx,tsamp,tvor,tnach,extent,steps,ppoints,ams,mas,SkFak,Dev_F, $ Max_Amp,Min_Amp, $ Max_Wave_Ext,Min_Wave_Ext, $ Max_Wave_t,Min_Wave_t, $ am,ma On_Error,2 On_IOerror,IO_Error fehler=0 ; BOOLEAN Ask_Noise_File: Noise_file="" read,"Filename for Noise-File (Program adds .NSE)? ",Noise_file Noise_file=F_Element(0,".",Noise_file)+".NSE" ans=FindFile(noise_file) IF ans(0) eq "" $ THEN $ BEGIN print,"" print,"Noise-File does not exist!" ans=Get_Reply("Do you want to try again?","Y|N","Y",/NoCase) IF ans eq "Y" $ THEN GOTO, Ask_Noise_File $ ELSE $ BEGIN fehler=1 GOTO, Ende ENDELSE ENDIF openr,noise,noise_file,/Get_LUN readf,noise,nx,tsamp,tvor,tnach readf,noise,ppoints,ams,mas,pardiff readf,noise,extent,steps,SkFak,Anz_Noise,Dev_F line="" readf,noise,line IF F_Element(1," ",line) ne '2' $ THEN $ BEGIN print,"Noise does not have standard format! Abort!" fehler=1 Free_LUN,noise GOTO, Ende ENDIF ysm=FltArr(Fix(F_Element(2," ",line)),Fix(F_Element(3," ",line))) ysd=ysm ; nur zum Aufbauen eines gleichgrossen Arrays print,"Reading mean of noise..." readf,noise,ysm print,"Reading standard deviation of noise..." readf,noise,ysd Free_LUN,noise print,"" ams=am*SkFak mas=ma*SkFak Max_Amp=ams*(1+steps/2.) Min_Amp=ams*1. Max_Wave_Ext=2*Max_Amp Min_Wave_Ext=2*Min_Amp Max_Wave_t=Max_Wave_Ext*tsamp/extent Min_Wave_t=Min_Wave_Ext*tsamp/extent IF pardiff $ THEN print,"Noise of differences of categories." $ ELSE print,"Noise of 'normal' files." print,"Extension of Potentials: ",extent print,"Width of minimal wavelet (ms): ",Min_Wave_t print,"Width of maximal wavelet (ms): ",Max_Wave_t print,"Number of different Wavelet steps: ",steps+1 print,"Number of random-shuffeled files in noise: ",anz_noise print,"Factor for standard deviation: ",Dev_F print,"" Ende: Return IO_Error: print,!Err_String Free_LUN,noise END ; ;=============================================================================== ; 1. Prolog, Typdeklarationen, Variablen und Konstanten: ;=============================================================================== ; ; On_Error, 2 ; Return => Ruf. Programm. On_IOerror, IO_Error ; Siehe Pkt.??. COMMON EEGS, project, job, file, time, sp, name, dev, ans, $ tvor, tnach, tsamp, points, nx, n_pot, fileTypus, $ anzahl, n_vpn, n_cat, n_loc, n_dif, t, proj COMMON DEVI, OldDevice, Out, Batch_Job COMMON PLOTS, xr_lo$, xr_hi$, yr_lo$, yr_hi$, $ xr_lo, xr_hi, yr_lo, yr_hi, xplotr, yplotr, thick, linst Print, "" Print, "*********** WAVE_EEG: Wavelet Analysis of Evoked Potentials V 4.15", $ " **********" Print, "" User=GetEnv("CURR_USER") ; aktueller User file = "" filetypus = "" Ref_Data_Read = 0 ; Boolean => False. Data_Read = 0 ; Boolean => False. ; Ref_Data_Read und Data_Read werden je einmal auf ; TRUE gesetzt, wenn die entsprechenden Daten ge- ; lesen worden sind Ref_Data_Wave = 0 ; True, wenn Wavelets von Referenzdaten berechnet ; wurden Data_Wave = 0 ; True, wenn Wavelets von zu analysierenden Daten ; berechnet wurden Noise_Calc = 0 ; True, wenn aus Referenz-Wavelets Noise berechnet ; wurde New_Parameter=0 ; True, wenn neue Parameter im Untermenue ; "Changing Parameters" eingegeben wurden New_Points=0 ; True, kurzzeitig wenn neue xpoints im Untermenue ; "Changing Parameters" eingegeben wurden ; Am Ende des Untermenues wird dann FUUNCTION ; expand eingesetzt, um ysur/yupp/ylow auf neue ; Resolution zu bringen. Danach New_Points wieder ; false. New_Potential=1 ; True, wenn das erstemal ein neues Potential in ; Menuepunkt Compare... geschickt wird. Dort Um- ; schaltung auf False EPS_Ausgabe=0 ; True, wenn EPS-Files produziert werden sollen ans="" pardiff=0 ; Boolean: 1, falls Kategoriediff. gerechnet werden ysum=0 num=0 am=1 ; Konstante fuer die Waveletbreite extent=5 ma=am/6.5 ; Konstante fuer die Waveletgroesse ;=============================================================================== ; folgende Variablen sind nur vom Typ definiert ;=============================================================================== fehler=0 Anz_Noise=0 nx=0 tsamp=0. tvor=0 tnach=0 steps=0 ppoints=0 ams=0 mas=0 SkFak=0 Dev_F=0. ; Faktor fuer Standardabweichung Max_Amp=0. Min_Amp=0. Max_Wave_Ext=0. Min_Wave_Ext=0. Max_Wave_t=0. Min_Wave_t=0. ; ;=============================================================================== ; 2. Behandlung der Keywords (Default-Werte): ;=============================================================================== ; Termi_Job=1 ; Boolean, wenn true, dann werden die Images bei Wavelet-Trans- ; formation nicht angezeigt - das spart eine Menge Zeit! Batch_Job=0 ; ;=============================================================================== ; 3. Setzen von Parametern fuer die Ausgaben: ;=============================================================================== ; !X.Ticklen = -0.02 & !Y.Ticklen = -0.02 & !Z.Ticklen = -0.02 x_Tit = "time after stimulus change [ms]" y_Tit1 = "number of steps of wavelet function" y_Tit2 = "wavelet width [ms]" z_Tit = "W-transform" Times_Font=0 ; Ueberschrift/Untertitel (PS) Helvet_Font=1 Palat_Font=0 School_Font=0 Bold_Font=1 Italic_Font=0 Oblique_Font=0 Title_Size=14 SubTitle_Size=10 Font_Type="!5" ; Beschriftung (IDL): Helvetica Bold als Default Char_Size=1.5 ; ;=============================================================================== ; 4. Window- und Menue-Steuerung: ;=============================================================================== ; Window_Control: W_Titel1 = "Wavelets" wx1 = 600 wy1 = 410 Set_Plot,"X" Window,1,XPos=2,YPos=4,Xs=wx1,Ys=wy1,Title=W_Titel1,Retain=2 LoadCT, 0, /Silent ; Graustufen-Farbtabelle laden. Mark = " > " NoMark= " " Menu_Title="Wave-EEG - Main Menu" Num_Menu = 7 menu = StrArr(Num_Menu) menu(0) = " > Read me" menu(1) = " > EEG Random shuffled Data" menu_2 = "EEG Data" menu_3 = "Compare Data with Noise" menu(4) = "" menu(5) = " > Quit - Return to IDL" menu(6) = Menu_Title IF Noise_Calc THEN menu(2)=Mark+menu_2 $ ELSE menu(2)=NoMark+menu_2 IF Noise_Calc AND Data_Wave THEN menu(3)=Mark+menu_3 $ ELSE menu(3)=NoMark+menu_3 Subm_1_Title="Menu: EEG Random shuffled Data" Num_Subm_1=10 subm_1=StrArr(Num_Subm_1) subm_1(0)=" > Read me" subm_1(1)=" > Read EEG Random shuffled Data File" subm_1_2 ="Perform Wavelet Transformation" subm_1_3 ="Compute Noise" subm_1(4)="" subm_1(5)=" > Load Noise" subm_1_6 ="Store Noise" subm_1(7)="" subm_1(8)=" > Return to Main Menu" subm_1(9)=Subm_1_Title IF Ref_Data_Read THEN subm_1(2)=Mark+subm_1_2 $ ELSE subm_1(2)=NoMark+subm_1_2 IF Ref_Data_Wave THEN subm_1(3)=Mark+subm_1_3 $ ELSE subm_1(3)=NoMark+subm_1_3 IF Noise_Calc $ THEN subm_1(6)=Mark+subm_1_6 $ ELSE subm_1(6)=NoMark+subm_1_6 Subm_2_Title="Menu: EEG Data" Num_Subm_2=6 subm_2=StrArr(Num_Subm_2) subm_2(0)=" > Read me" subm_2(1)=" > Read EEG Data File" subm_2_2 ="Perform Wavelet Transformation" subm_2(3)="" subm_2(4)=" > Return to Main Menu" subm_2(5)=Subm_2_Title IF Data_Read THEN subm_2(2)=Mark+subm_2_2 $ ELSE subm_2(2)=NoMark+subm_2_2 Subm_3_Title="Menu: Compare Data with Noise" Num_Subm_3=7 subm_3=StrArr(Num_Subm_3) subm_3(0)=" > Read me" subm_3(1)=" > Surface-Plot" subm_3(2)=" > Contour-Plot" subm_3(3)=" > Change Plot-Parameters" subm_3(4)="" subm_3(5)=" > Return to Main Menu" subm_3(6)=Subm_3_Title Pos_Radio_Button=" + " Neg_Radio_Button=" " Subm_33_Title="Menu: Change Plot-Parameters" Num_Subm_33=14 subm_33=StrArr(Num_Subm_33) subm_33(0)=" > Read me" subm_33(1)=" > Plot-Range x-axis" subm_33(2)=" > Plot-Range y-axis" subm_33(3)=" > Plot-Range z-axis" subm_33(4)=" > Viewpoint" subm_33(5)=" > Resolution x-axis" subm_33(6)=" > Standard Deviation" subm_33_7= "PS-File" subm_33_8= "EPS-File" subm_33(9)="" subm_33(10)=" Font and size of characters" subm_33(11)="" subm_33(12)=" > Return to Plot..." subm_33(13)=Subm_33_Title IF Eps_Ausgabe $ THEN $ BEGIN subm_33(7)=Neg_Radio_Button+subm_33_7 subm_33(8)=Pos_Radio_Button+subm_33_8 ENDIF $ ELSE $ BEGIN subm_33(7)=Pos_Radio_Button+subm_33_7 subm_33(8)=Neg_Radio_Button+subm_33_8 ENDELSE Menu: Menu_Loop=1 ; Boolean fuer grosse Menue-Schleife Repeat $ ; Start der grossen Menue-Schleife. CASE Wmenu(menu,Title=6) OF ; ;=============================================================================== ; 5. Read me (Main Menu) Menue-Punkt 0 ;=============================================================================== ; 0: $ BEGIN Print, " This WAVE_EEG.PRO is now a revised version of" Print, " the famous *eeg.pro* program (version 322 as of 9/5/92)" Print, " written by A. W. Przybyszewski." print, " Revision by L. Fuhry and K.H. Dittberner." Print, " -----------------------------------------" Print, " WAVELET ANALYSIS OF EVOKED POTENTIALS" Print, " -----------------------------------------" Print, "" print,"In general: Select marked items ('>') only." print," 1. Process EEG Random shuffled Data." print," 2. Process EEG Data." print," 3. Compare Data with Noise." print," 4. Optionally process other Data and/or Random shuffled Data." print," 5. Finally quit." print,"" ENDCASE ; Menue-Punkt 0 ; ;=============================================================================== ; 6. EEG Random shuffled Data Menue-Punkt 1 ;=============================================================================== ; 1: $ BEGIN SubMenu_1_Loop=1 ; Boolean REPEAT $ CASE WMenu(Subm_1,Title=9) OF ; ;=============================================================================== ; 7. Read me (EEG Random shuffled Data) Menue-Punkt 1.0 ;=============================================================================== ; 0: $ BEGIN print,"" print,"Info: EEG Random shuffled Data" print,"There are two possibilities to obtain noise:" print," 1.a) Read EEG Random shuffled Data File." print," Answer question whether Files are original (normal) or whether" print," they are differences between categories." print," Wave_EEG automatically will handle EEG Data in the right way." print," b) Transform Random shuffled Data File by Wavelets. print," Extension: Factor to enlarge number of points in each potential" print," in order to make Wavelet Transformation more efficient. The" print," new points are interpolated." print," Wavelet steps: Number of different Wavelets (different width)" print," for transformation." print," Scale Factor: Factor for width of Wavelets. print," The default values of these variables might be appropriate." print," c) Process noise: After you finished with noise processing you can" print," store the noise for other sessions." print," 2. If you stored desired noise before you can load it again." print,"After you obtained noise you will be in the Main Menu." print,"" ENDCASE ; Menue-Punkt 1.0 ; ;=============================================================================== ; 8. Read EEG Random shuffled Data File Menue-Punkt 1.1 ;=============================================================================== ; 1: $ BEGIN ;--------------------------------------------- ; Bisher kommen folgende Basis-Parameter vor: ; ; Projekt von points tvor tnach tsamp ; ------------------------------------------- ; SEEK 180 100 800 5.00 ; FUHRY 200 200 800 5.00 ; SEIDLER 200 100 900 5.00 ;--------------------------------------------- Read_Ref_Data: Get_Data, fehler,Typus="AVE", DATEN="REF" ; Random-Daten sind immer vom Typ "AVE", da diese ; vom Programm AVE_EEG erzeugt werden. IF fehler THEN GOTO,End_SubMenu_11 sp_ref=sp name_ref=name sp=0 pardiff_dummy=pardiff ans=Get_Reply( $ "Are the categories 'normal' (N) or differences (D) between categories?", $ "N|D","N",/NoCase) IF ans eq "N" THEN pardiff=0 $ ELSE pardiff=1 IF Data_Read $ THEN $ IF pardiff_dummy ne pardiff $ THEN $ BEGIN print,"Type of EEG Data does not fit. EEG Datas are deleted from memory." Data_Read=0 Data_Wave=0 Subm_2(2)=NoMark+Subm_2_2 ENDIF Ref_Data_Read = 1 ; Boolean => True. Ref_Data_Wave = 0 Noise_Calc = 0 ylow=0 yupp=0 ysm=0 ysd=0 ysuma=0 menu(2)=NoMark+menu_2 menu(3)=NoMark+menu_3 subm_1(2)=Mark+subm_1_2 subm_1(3)=NoMark+subm_1_3 subm_1(6)=NoMark+subm_1_6 End_SubMenu_11: ENDCASE ; Menue-Punkt 1.1 ; ;=============================================================================== ; 9. Perform Wavelet Transformation (EEG Random shuffled Data) Menue-Punkt 1.2 ;=============================================================================== ; 2: $ BEGIN IF not Ref_Data_Read $ THEN $ BEGIN print,"" print,"Random shuffled datas have to be read before performing Wavelet ", $ "Transformation." print,"Select 'Read EEG Random shuffled Data File' in this Menu first!" GOTO, End_SubMenu_12 ENDIF IF Data_Read $ THEN $ BEGIN print,"" print,"Using new Parameters (Width of minimal/maximal ", $ "wavelets)" print," deletes Wavelet Transformation of EEG Data." ans=Get_Reply( $ "Do you want to change Parameters, though? (Y/N), Abort (A)", $ "Y|N|A","N",/NoCase) CASE ans OF "N" : GOTO, N_Locations "A" : GOTO, End_SubMenu_12 "Y" : ENDCASE ENDIF Data_Wave = 0 IF Data_Read THEN subm_2(2)=Mark+subm_2_2 $ ELSE subm_2(2)=NoMark+subm_2_2 auto=0 ; Boolean - automatische Potentialverarbeitung ppoints=nx*extent ; Anzahl der Punkte pro Potential nach ; Extention Parameter_Eingabe: Min_Wave_t=Get_Number("Width of minimal wavelet (ms)?",1,tvor+tnach-tsamp, $ 20.,/Real) Max_Wave_t=Get_Number("Width of maximal wavelet (ms)?",Min_Wave_t, $ tvor+tnach-tsamp,300.,/Real) SkFak=Fix(Min_Wave_t*extent/(2.*am*tsamp)) IF (SkFak Mod 2) ne 0 $ THEN SkFak=SkFak-1 SkFak=SkFak > 2 ams=am*SkFak ;Amplitude skaliert - das ist Breite mas=ma*SkFak ;Vergroserung skaliert - das ist Groesse steps=1.*Max_Wave_t*extent/(ams*tsamp) - 2 ; denn Max_Wave_t=2*ams*(1+steps/2.)*tsamp/extent ; ==> steps=Max_Wave_t*extent/(ams*tsamp)-2 IF steps ne Fix(steps) THEN steps=Fix(steps+1) $ ELSE steps=Fix(steps) IF steps eq 0 THEN steps=1 Max_Amp=ams*(1+steps/2.) ; halbe maximale Waveletbreite, skaliert, Min_Amp=ams*1. ; halbe minimale Waveletbrete, skaliert, ; eigentlich: ams*(1+i/2.) mit i=0 ==> ams*1. ; halbe Waveletbreiten: ; immer ganzzahlig, denn ams ist geradzahlig, ; Typ Real ; 1+steps/2. ... bzw. 1+i/2. ..., weil auf diese Weise die Ver- ; groesserung von ams und mas nicht linear erfolgt --> dadurch ; werden in einem bestimmten Bereich mehr Wavelets durchgerech- ; net, ansonsten kein mathematisch zwingender Grund. ; Die Verwendung von 1+steps/2. ... hier und weiter unten er- ; folgt immer nur aus diesem Grund! Max_Wave_Ext=2*Max_Amp ; Breite des maximalen Wavelets, skaliert Min_Wave_Ext=2*Min_Amp ; Breite des minimalen Wavelets, skaliert ; Waveletbreiten: ; immer geradzahlig ; Typ Real ; jeweils = N_Elements(Fun)-1 (entspricht Anzahl ; der Punkte) Max_Wave_t=Max_Wave_Ext*tsamp/extent ; Breite des maximalen Wavelets in ms ; nach Reskalierung Min_Wave_t=Min_Wave_Ext*tsamp/extent ; Breite des minimalen Wavelets in ms ; nach Reskalierung print,"The widths of analysing Wavelets will range between ", $ Fix(Min_Wave_t)," and ",Fix(Max_Wave_t)," ms.",Format="(A,I0,A,I0,A)" print,"For this range of analysing wavelets ",steps+1," different wavelets", $ " have to be",Format="(A,I0,A,A)" print," calculated." ans=Get_Reply("Is this ok?","Y|N","Y",/NoCase) IF ans eq "N" THEN GOTO, Parameter_Eingabe N_Locations: print,"" n_pot_ref=N_Elements(name_ref) ; Anzahl der Potentiale in gelesenem ; File print,"Number of potentials: ",n_pot_ref n_locs=Get_Number("Number of locations",1,n_pot_ref,/Integer) IF (n_pot_ref MOD n_locs) ne 0 $ THEN $ BEGIN print,"Number of locations does not fit with number of potentials" GOTO, N_Locations ENDIF print,"" print,"Do you want to get screen images?" ans=Get_Reply("(You don't need them and it takes time. L.F.)","Y|N","N", $ /NoCase) IF ans eq "Y" THEN Termi_Job = 0 $ ELSE Termi_Job = 1 ans=Get_Reply( $ "Do you want to perform WT automatically (A) or stepwise (S)","A|S","A", $ /NoCase) IF ans eq "A" $ ; 0. Mal THEN $ BEGIN auto = 1 first_pot=Get_Number("Number of first potential",1,n_pot_ref,/Integer) jump=Get_Number("Number of jump",1,n_pot_ref-first_pot,n_locs,/Integer) max_anz_noise=(n_pot_ref-first_pot)/jump+1 IF max_anz_noise lt 2 $ THEN $ BEGIN print,"The constellation of parameters does not fit with number of ", $ "potentials!" print,"Minimum number of potentials for noise is two!" GOTO, N_Locations ENDIF default_anz_noise=n_pot_ref/jump default_anz_noise=max_anz_noise < default_anz_noise ENDIF $ ; ans 0. Mal ELSE default_anz_noise=30 < max_anz_noise anz_noise=Get_Number("How many files do you want to analyse",2, $ max_anz_noise,default_anz_noise,/Integer) print,"" FOR lauf=1,anz_noise DO $ BEGIN Potential_Eingabe: ; frueher: en IF NOT auto $ THEN $ BEGIN num = Get_Number ("Which potential do you want to analyse?",1, $ n_pot_ref,/Integer) ENDIF $ ; NOT (pardiff OR auto) ELSE num=first_pot+(lauf-1)*jump print,"" print,"Name of potential being analysed: ",num," ",name_ref(num-1) sp1=expand([[sp_ref((num-1)*nx:num*nx-1)],[sp_ref((num-1)*nx:num*nx-1)]], $ nx*extent,2) ; hier muessen die einzelnen Potentiale ; ausgeschnitten werden ; Die FUNCTION rebin durch FUNCTION expand ersetzt, weil rebin nicht ; optimal interpoliert. Da expand nur 2-Dim-Arrays bearbeitet, wird ; 1-Dim_Array sp1 kurzfristig zu 2-Dim-Array, als solches expandiert ; (die 2. Dimension wird nicht veraendert!) und anschliessend wieder ; in ein 1-Dim_Array zurueckgefuehrt. sp1=sp1(*,0) name3=name_ref(num-1) Wavelet_Transform, sp1,tsamp,tvor,tnach,extent,ppoints,ams,mas,steps, $ Max_Amp,Min_Amp,Akt_Amp, $ Max_Wave_Ext,Min_Wave_Ext,Akt_Wave_Ext, $ Max_Wave_t,Min_Wave_t,Akt_Wave_t, $ y,wx1,wy1,name3,fehler, $ Termi_Job,Batch_Job IF fehler THEN GOTO, End_SubMenu_12 IF auto $ THEN ans = "S" $ ELSE $ BEGIN print,"The ",StrCompress(lauf),". file for noise" ans = Get_Reply( $ "Summing this file to noise (S), Ignoring (I)","S|I","S",/NoCase) ENDELSE IF ans eq "I" $ THEN GOTO, Potential_Eingabe $ ; Potential wird ignoriert, naechstes ; Potential kann fuer noise aufgerufen ; werden ELSE $ BEGIN ; Aufsummierung des aktuellen Potentials zum Noise IF lauf eq 1 $ THEN $ BEGIN print,"Processing first potential to noise" ysuma=y(indgen(n_elements(y))) ; mit dieser Zeile wird ; aus einem Array ein ; Vektor mit gleichen ; Werten ysm=ysuma ; nur zum Aufbauen eines Arrays ysd=ysuma ; mit gleicher Struktur wie ysuma im ersten ; Durchgang - also Vektor der Laenge ; ppoints * steps. Einzelne Werte egal ENDIF $ ; lauf eq 1 ELSE $ BEGIN print,"Adding ",StrCompress(lauf),". potential to noise..." ysuma1=y(indgen(n_elements(y))) ysuma=[[ysuma],[ysuma1]] ; Wts verschiedener Potentiale ; werden in ein Array ge- ; schrieben (ysuma) ; ysuma: ; 1.dim: ppoints (ohne Raen- ; der) fuer alle steps ; 2.dim: alle Potentiale ENDELSE ; lauf eq 1 ENDELSE ; ans eq "I" ENDFOR ; lauf Ref_Data_Wave = 1 Noise_Calc=0 menu(2)=NoMark+menu_2 menu(3)=NoMark+menu_3 subm_1(3)=Mark+subm_1_3 subm_1(6)=NoMark+subm_1_6 print,"" End_SubMenu_12: ENDCASE ; Menue-Punkt 1.2 ; ;=============================================================================== ; 10. Compute Noise Menue-Punkt 1.3 ;=============================================================================== ; 3: $ BEGIN IF NOT Ref_Data_Wave $ THEN $ BEGIN print,"" print,"Wavelet transformation has to be performed before Computing noise!" print,"Select 'Read me' in this Menu first" GOTO, End_SubMenu_13 ENDIF Dev_F=Get_Number("Factor for standard deviation",1.,10.,3.,/Real) print,"Calculating standard deviation..." std_lauf=N_Elements(ysuma(*,0)) dezi=0 FOR i=0L,std_lauf-1 DO $ BEGIN prodezi=(i+1)*10/std_lauf IF prodezi gt dezi $ ; damit man am Terminal nicht einschlaeft... THEN $ BEGIN dezi=prodezi print,prodezi,'0 %' ENDIF ysd(i)=stdev(ysuma(i,*),ysm(i)) ENDFOR ypomoc=FltArr(N_Elements(y(*,0)),N_Elements(y(0,*))) ; "Y_Hilfe" ysd=ypomoc+ysd ; auf diese Weise bekommen ysd/ysm gleiche Struktur ysm=ypomoc+ysm ; wie ypomoc - Daten werden aus Vektor in Array ; ueberschrieben - entspricht also Struktur von ; y (1.dim: ppoints - Max_Wave_Ext, 2.dim: steps) ylow=ysm-Dev_F*ysd yupp=ysm+Dev_F*ysd ypomoc=0.0 print,"Noise processing finished." ans=Get_Reply("Do you want to store the noise?","Y|N","Y",/NoCase) IF ans eq "Y" $ THEN $ Noise_Store, ysm,ysd,anz_noise,pardiff, $ nx,tsamp,tvor,tnach,extent,steps,ppoints,ams,mas,SkFak,Dev_F, $ Max_Amp,Min_Amp, $ Max_Wave_Ext,Min_Wave_Ext, $ Max_Wave_t,Min_Wave_t Noise_Calc=1 New_Potential=1 menu(2)=Mark+menu_2 subm_1(6)=Mark+subm_1_6 IF Data_Read THEN subm_2(2)=Mark+subm_2_2 $ ELSE subm_2(2)=NoMark+subm_2_2 IF Data_Wave THEN menu(3)=Mark+menu_3 $ ELSE menu(3)=NoMark+menu_3 SubMenu_1_Loop=0 ; Nach Berechnung von Noise geht es direkt ins Main Menu! End_SubMenu_13: ENDCASE ; Menue-Punkt 1.3 ; ;=============================================================================== ; 11. Leerzeile Menue-Punkt 1.4 ;=============================================================================== ; 4: ; ;=============================================================================== ; 12. Load Noise Menue-Punkt 1.5 ;=============================================================================== ; 5: $ BEGIN IF Data_Wave $ THEN $ BEGIN print,"" print,"Loading noise deletes Wavelet Transformation of EEG Data." ans=Get_Reply("Do you want to load noise, though?","Y|N","Y",/NoCase) IF ans eq "N" THEN GOTO, End_SubMenu_15 ENDIF pardiff_dummy=pardiff nx_dummy=nx tsamp_dummy=tsamp tvor_dummy=tvor tnach_dummy=tnach Noise_Load, fehler,ysm,ysd,anz_noise,pardiff, $ nx,tsamp,tvor,tnach,extent,steps,ppoints,ams,mas,SkFak,Dev_F, $ Max_Amp,Min_Amp, $ Max_Wave_Ext,Min_Wave_Ext, $ Max_Wave_t,Min_Wave_t, $ am,ma IF fehler THEN GOTO, End_SubMenu_15 yupp=ysm+Dev_F*ysd ylow=ysm-Dev_F*ysd Noise_Calc=1 Data_Wave=0 New_Potential=1 Menu(2)=Mark+Menu_2 Menu(3)=NoMark+Menu_3 IF Data_Read $ THEN $ IF pardiff_dummy ne pardiff OR $ nx_dummy ne nx OR $ tsamp_dummy ne tsamp OR $ tvor_dummy ne tvor OR $ tnach_dummy ne tnach $ THEN $ BEGIN print,"EEG Data File does not fit with noise. EEG Data deleted." Data_Read=0 Subm_2(2)=NoMark+Subm_2_2 ; EEG-Daten gelesen, andere Parameter ENDIF $ ELSE Subm_2(2)=Mark+Subm_2_2 $ ; EEG-Daten gelesen, gleiche Parameter ELSE Subm_2(2)=NoMark+Subm_2_2 ; EEG-Daten noch nicht gelesen SubMenu_1_Loop=0 ; Nach Laden von Noise geht es direkt ins Main Menu! End_SubMenu_15: ENDCASE ; Menue-Punkt 1.5 ; ;=============================================================================== ; 13. Store Noise Menue-Punkt 1.6 ;=============================================================================== ; 6: $ BEGIN IF NOT Noise_Calc $ THEN $ BEGIN print,"" print,"Noise has to be calculated before storing." GOTO, End_SubMenu_16 ENDIF Noise_Store, ysm,ysd,anz_noise,pardiff, $ nx,tsamp,tvor,tnach,extent,steps,ppoints,ams,mas,SkFak,Dev_F, $ Max_Amp,Min_Amp, $ Max_Wave_Ext,Min_Wave_Ext, $ Max_Wave_t,Min_Wave_t End_SubMenu_16: ENDCASE ; Menue-Punkt 1.6 ; ;=============================================================================== ; 14. Leerzeile Menue-Punkt 1.7 ;=============================================================================== ; 7: ; ;=============================================================================== ; 15. Return to Main Menu Menue-Punkt 1.8 ;=============================================================================== ; 8: $ BEGIN SubMenu_1_Loop=0 ENDCASE ; Menue-Punkt 1.8 ; ;=============================================================================== ; 6. EEG Random shuffled Data Menue-Punkt 1 (Schluss) ;=============================================================================== ; ENDCASE $ ; WMenu(Subm_1) UNTIL NOT SubMenu_1_Loop End_SubMenu_1: ENDCASE ; Menu-Punkt 1 ; ;=============================================================================== ; 16. EEG Data Menue-Punkt 2 ;=============================================================================== ; 2: $ BEGIN IF NOT Noise_Calc $ THEN $ BEGIN print,"" print,"Noise has to be computed before processing EEG Data." print,"Select 'EEG Random shuffled Data' in Main Menu first" Goto, End_SubMenu_2 ENDIF SubMenu_2_Loop=1 ; Boolean REPEAT $ CASE WMenu(Subm_2,Title=5) OF ; ;=============================================================================== ; 17. Read me (EEG Data) Menue-Punkt 2.0 ;=============================================================================== ; 0: $ BEGIN print,"" print,"Info: EEG Data" print," 1. Read EEG Data File." print," 2. Transform Data File by Wavelets. The same parameters as for" print," Random shuffled File will be used." print," If you declared that Random shuffled Data File is the difference" print," between categories you have to select two potentials of the" print," Data File." print," The first potential ('Minuend'), which will be stored for" print," further differences unless you select a new first potential." print," The second one ('Subtrahend')." print,"After you transformed Data File you will be in the Main Menu." print,"" ENDCASE ; Menue-Punkt 2.0 ; ;=============================================================================== ; 18. Read EEG Data File Menue-Punkt 2.1 ;=============================================================================== ; 1: $ BEGIN Read_Data: FileTyp="" FileTyp=Get_Reply("File-Typus (AVE or EVP)","AVE|EVP","AVE",/NoCase) Get_Data, fehler,Typus=FileTyp, DATEN="DAT" IF fehler THEN GOTO, End_SubMenu_21 sp_dat=sp sp=0 name_dat=name Data_Read = 1 ; Boolean => True. Data_Wave = 0 subm_2(2)=Mark+subm_2_2 menu(3)=NoMark+menu_3 End_SubMenu_21: ENDCASE ; 2 ; ;=============================================================================== ; 19. Perform Wavelet Transformation (EEG Data) Menue-Punkt 2.2 ;=============================================================================== ; 2: $ BEGIN IF NOT Data_Read $ THEN $ BEGIN print,"" print,"EEG Datas have to be read before processing them." print,"Select 'Read EEG Data File' in the Menu first!" Goto, End_SubMenu_22 ENDIF print,"Names of potentials: ",name_dat IF pardiff $ THEN $ BEGIN IF Data_Wave $ THEN ans=Get_Reply("First Potential (F) or Second Potential (S)?", $ "S|F",/NoCase) IF NOT Data_Wave OR ans eq "F" $ THEN $ BEGIN num = Get_Number( $ "Which potential do you want to store (first potential)",1, $ n_elements(name_dat),/Integer) diffsp=sp_dat((num-1)*nx:num*nx-1) ; nx: hier frueher points name2=name_dat(num-1) print,name2 ENDIF num = Get_Number("Number of the second potential",1, $ N_Elements(name_dat),/Integer) sp1=diffsp-sp_dat((num-1)*nx:num*nx-1) ; nx: hier frueher points name1=name2+"-"+name_dat(num-1) print,name_dat(num-1)," diff:",name1 plot,diffsp,linestyle=1,title=name1 oplot,sp1 ENDIF ; pardiff n_pot_dat=N_Elements(name_dat) ; Anzahl der Potentiale in gelesenem ; File print,"Number of potentials: ",n_pot_dat print,"" IF NOT pardiff $ THEN $ BEGIN num = Get_Number ("Which potential do you want to analyse?",1,n_pot_dat, $ /Integer) ENDIF ; NOT pardiff print,"" print,"Name of potential being analysed: ",num," ",name_dat(num-1) IF pardiff $ ; Vergroesserung von sp mit expand im Sinne ; von Extention, ; also aus nx --> ppoints ; Die FUNCTION rebin durch FUNCTION expand ersetzt, weil rebin nicht ; optimal interpoliert. Da expand nur 2-Dim-Arrays bearbeitet, wird ; 1-Dim_Array sp1 kurzfristig zu 2-Dim-Array, als solches expandiert ; (die 2. Dimension wird nicht veraendert!) und anschliessend wieder ; in ein 1-Dim_Array zurueckgefuehrt. THEN sp1=expand([[sp1],[sp1]],nx*extent,2) $ ; die einzelnen Potentiale schneidet sich ; das Unterprogramm fuer Kategoriedifferen- ; zen selbstaendig raus - sp1 in THEN ist ; bereits die Differenz der beiden zu unter- ; suchenden Potentiale ELSE sp1=expand([[sp_dat((num-1)*nx:num*nx-1)],[sp_dat((num-1)*nx:num* $ nx-1)]],nx*extent,2) ; hier muessen die einzelnen Potentiale ; ausgeschnitten werden sp1=sp1(*,0) IF NOT pardiff THEN name1=name_dat(num-1) Wavelet_Transform, sp1,tsamp,tvor,tnach,extent,ppoints,ams,mas,steps, $ Max_Amp,Min_Amp,Akt_Amp, $ Max_Wave_Ext,Min_Wave_Ext,Akt_Wave_Ext, $ Max_Wave_t,Min_Wave_t,Akt_Wave_t, $ ysur,wx1,wy1,name1,fehler, $ Termi_Job,Batch_Job IF fehler THEN GOTO, End_SubMenu_22 print,"The data file has been analysed." Data_Wave=1 IF Noise_Calc THEN menu(3)=Mark+menu_3 $ ELSE menu(3)=NoMark+menu_3 print,"" SubMenu_2_Loop=0 ; Nach Wavelet-Transformierung geht es direkt ins Main Menu! New_Potential=1 ; Boolean, true bedeutet, dass in compare neu gerechnet ; werden muss End_SubMenu_22: ENDCASE ; Menue-Punkt 2.2 ; ;=============================================================================== ; 20. Leerzeile Menue-Punkt 2.3 ;=============================================================================== ; 3: ; ;=============================================================================== ; 21. Return to Main Menu Menue-Punkt 2.4 ;=============================================================================== ; 4: $ BEGIN SubMenu_2_Loop=0 ENDCASE ; Menue-Punkt 2.4 ; ;=============================================================================== ; 16. EEG Data Menue-Punkt 2 (Schluss) ;=============================================================================== ; ENDCASE $ ; WMenu(Subm_2) UNTIL NOT SubMenu_2_Loop End_SubMenu_2: ENDCASE ; Menu-Punkt 2 ; ;=============================================================================== ; 22. Compare Data with Noise Menue-Punkt 3 ;=============================================================================== ; 3: $ BEGIN IF NOT (Noise_Calc AND Data_Wave) $ THEN $ BEGIN print,"" print,"Noise has to be computed and EEG Data to be processed before ", $ "comparing both." print,"Select 'Read me' in Main Menu first" Goto, End_SubMenu_3 ENDIF IF NOT New_Parameter $ ; also nur am Anfang zur Definition der Defaults THEN $ BEGIN New_Potential=0 xpoints=200 ; Anzahl der Punkte auf der x-Achse verringert, damit ; man mehr sehen kann ypoints=steps+1 xpl=45 ; xpl und zpl zpl=5 ; vertauscht y_lo=Min_Wave_t y_hi=Max_Wave_t plotr_y=[y_lo,y_hi] IF User eq "FUHRY" $ THEN $ BEGIN x_lo=0 > (-tvor+Fix(Max_Wave_t/2)) x_hi=400 < (Fix(tnach-Max_Wave_t/2)) ; zunaechst z_lo=-12 ; Default fuer User FUHRY z_hi=12 ENDIF $ ELSE $ BEGIN x_lo=-tvor+Fix(Max_Wave_t/2) ; entspricht x_min (kleinstes moegliches x) x_hi=Fix(tnach-Max_Wave_t/2) ; entspricht x_max (groesstes moegliches x) z_lo=-3 ; zunaechst z_hi=3 ; Default fuer andere User ausser FUHRY ENDELSE plotr_x=[x_lo,x_hi] plotr_z=[z_lo,z_hi] ENDIF ; NOT New_Parameter IF (NOT New_Parameter) OR New_Potential $ THEN $ ; also nur am Anfang oder mit neuen Potentialen (dann ; allerdings mit den veraenderten Parametern) BEGIN y_lo=Min_Wave_t > y_lo y_hi=Max_Wave_t < y_hi plotr_y=[y_lo,y_hi] IF User eq "FUHRY" $ THEN $ BEGIN x_lo=0 > (-tvor+Fix(Max_Wave_t/2)) > x_lo x_hi=400 < (Fix(tnach-Max_Wave_t/2)) < x_hi ENDIF $ ELSE $ BEGIN x_lo=-tvor+Fix(Max_Wave_t/2) ; entspricht x_min (kleinstes moegliches x) x_hi=Fix(tnach-Max_Wave_t/2) ; entspricht x_max (groesstes moegliches x) z_lo=-3 ; zunaechst z_hi=3 ; Default fuer andere User ausser FUHRY ENDELSE plotr_x=[x_lo,x_hi] Tick_Diff=Fix((x_hi-x_lo)/300)*100 IF Tick_Diff eq 0 THEN Tick_Diff=100 factor=Fix(x_lo/Tick_Diff) IF x_lo gt 0 THEN factor=factor+1 tick_value=factor*Tick_Diff IF (tick_value - x_lo) lt (Tick_Diff*2/3) $ THEN tick_value=tick_value+Tick_Diff X_Tick_Values=[x_lo,tick_value] WHILE (tick_value+Tick_Diff) le x_hi DO $ BEGIN tick_value=tick_value+Tick_Diff X_Tick_Values=[X_Tick_Values,tick_value] ENDWHILE X_Ticks=N_Elements(X_Tick_Values)-1 plotr_z=[z_lo,z_hi] i_hi=1.*y_hi*extent/(ams*tsamp) - 2 ; denn Akt_Wave_t=2*ams*(1+i/2.)*tsamp/extent ; ==> i=Akt_Wave_t*extent/(ams*tsamp)-2 IF i_hi ne Fix(i_hi) THEN i_hi=Fix(i_hi+1) $ ELSE i_hi=Fix(i_hi) i_lo=Fix(1.*y_lo*extent/(ams*tsamp) - 2) ypoints=i_hi-i_lo+1 IF ypoints eq 1 $ THEN $ IF i_lo ne steps $ THEN $ BEGIN ypoints=2 i_hi=i_hi+1 ENDIF $ ELSE $ BEGIN ypoints=2 i_lo=i_lo-1 ENDELSE plotr_y=[Min_Wave_t*(1+i_lo/2.),Min_Wave_t*(1+i_hi/2.)] IF plotr_y(0) eq 20 AND plotr_y(1) eq 300 $ THEN $ BEGIN Y_Tick_Values=[20,100,150,200,250,300] Y_Ticks=5 Y_TickName="" ENDIF $ ELSE $ BEGIN Y_Tick_Values=0 Y_Ticks=0 Y_TickName="" ENDELSE y1=(Findgen(steps+1)/2.+1)*Min_Wave_t y1=y1(i_lo:i_hi) ; Die y-Achse: ; Sie besteht aus ypoints=i_hi-i_lo+1 Punkten. ; Jedes Wavelet ist ein Vielfaches von Min_Wave_t ; Denn: Min_Wave_t = 2*tsamp*ams* 1 /extent (1+0/2.=1) und ; i. Wave_t = 2*tsamp*ams*(1+i/2.)/extent ; Max_Wave_t = 2*tsamp*ams*(1+steps/2.)/extent ; Den jeweiligen Faktor (1+i/2.) erhaelt man, weil ; Findgen(ypoints)=[0.,1.,2.,...,steps] ... und das entspricht ; genau dem i in(1+i/2.)! Somit wird fuer jedes Wavelet die ; richtige Breite angegeben. xprzy=(0.+x_hi-x_lo)/(xpoints-1) ; xprzy: "Vergroesserung", Reskalierung der x-Achse, weil nur ; ein Teil der Potentiale benutzt wird. ; Der Term in Klammern gibt die gesamte verfuegbare Dauer an, ; er wird durch die Anzahl der Intervalle (gleich Anzahl der ; zu plottenden Punkte minus 1) geteilt, damit man weiss, wie ; gross der Zeitabstand zwischen 2 Punkten ist. x1=x_lo+Findgen(xpoints)*xprzy ; Die x-Achse: bestehend aus xpoints Punkten. ; Der erste Punkt beginnt bei x_lo. ; Alle folgenden Punkte sind um je xprzy groesser offset_t=tvor-Max_Wave_t/2+x_lo ; Zeit zwischen Beginn des Berechnungs- ; fensters und x_lo offset_ext=Fix(offset_t*extent/tsamp) ; 1. skalierter Punkt, der geplottet ; werden soll ende_ext=Fix(offset_ext-1+(x_hi-x_lo)*extent/tsamp) ; letzter skalierter ; Punkt zum Plotten print,"Expanding Data for resolution applicated..." ysur1=expand(ysur(offset_ext:ende_ext,i_lo:i_hi),xpoints,ypoints) print,"Expanding upper margin for resolution applicated..." yupp1=expand(yupp(offset_ext:ende_ext,i_lo:i_hi),xpoints,ypoints) print,"Expanding lower margin for resolution applicated..." ylow1=expand(ylow(offset_ext:ende_ext,i_lo:i_hi),xpoints,ypoints) ; --> congrid durch expand ersetzt ; ysur durch ysur1 (yupp durch yupp1, ; ylow durch ylow1) ersetzt, damit bei ; Wiederholung immer wieder vom ; Ausgangspunkt ausgegangen werden ; kann Signif_Upp=IntArr(xpoints,ypoints) Signif_Low=IntArr(xpoints,ypoints) Not_Signif=IntArr(xpoints,ypoints) Signif=Where(ysur1 gt yupp1,N_Signif) FOR i=0,N_Signif-1 DO Signif_Upp(Signif(i))=1 ; Signif_Upp/_Low sind Arrays Signif=Where(ysur1 lt ylow1,N_Signif) ; mit Nullen (signifikant) FOR i=0,N_Signif-1 DO Signif_Low(Signif(i))=1 ; und Einsen (nicht signif.) Signif=Where(((ysur1 le yupp1) AND (ysur1 ge ylow1)),N_Signif) FOR i=0,N_Signif-1 DO Not_Signif(Signif(i))=1 ; Sub_Title=F_Element(1," ",String(Anz_Noise))+" moves, "+ $ F_Element(1," ",String(Dev_F))+" times standard deviation." ENDIF ; (NOT New_Parameter) OR New_Potential SubMenu_3_Loop=1 ; Boolean REPEAT $ CASE WMenu(Subm_3,Title=6) OF ; ;=============================================================================== ; 23. Read me (Compare Data with Noise) Menue-Punkt 3.0 ;=============================================================================== ; 0: $ BEGIN print,"" print,"Info: Compare Data with Noise" print,"Results can be displayed as Surface-Plots (quasi-3-dimensional) and as" print," Contour-Plots." print,"Areas which are beyond noise are filled." print,"Parameters can be changed." print,"" ENDCASE ; Menue-Punkt 3.0 ; ;=============================================================================== ; 24. Surface-Plot Menue-Punkt 3.1 ;=============================================================================== ; 1: $ BEGIN wset,1 !X.Ticklen = -0.04 ;================================= ???????????? ============================== ; Gibt es eine Moeglichkeit, bei Surface-Plot die Achsen an andere Stellen zu ; versetzen? Sicher mit T3D - ist mir aber zu kompliziert! ; Wahrscheinlich nicht! ; IF zpl gt 180 $ ; THEN $ ; BEGIN ; Y_Style=5 ; Z_Style=5 ; ENDIF $ ; ELSE $ ; BEGIN ;================================= ???????????? ============================== Y_Style=1 Z_Style=1 ;================================= ???????????? ============================== ; ENDELSE ; IF zpl gt 90 AND zpl lt 270 $ ; THEN X_Style=5 $ ; ELSE $ ;================================= ???????????? ============================== X_Style=1 back_miss=0 right_miss=0 Surface_Plot: print,"" print,"Processing shades..." Shade_Surf,ysur1,x1,y1,/Save, $ XRange=plotr_x,YRange=plotr_y,ZRange=plotr_z, $ XStyle=X_Style,YStyle=Y_Style,ZStyle=Z_Style, $ AX=xpl,AZ=zpl, $ XTicks=X_Ticks,XTickV=X_Tick_Values,XTickName="", $ YTicks=Y_Ticks,YTickV=Y_Tick_Values,YTickName="", $ Shades=Bytscl(Signif_Upp,Top=200)+Bytscl(Signif_Low,Top=150)+ $ Bytscl(Not_Signif,Top=0), $ Title=Font_Type+name1,SubTit=Font_Type+Sub_Title, $ XTitle=Font_Type+x_Tit,YTitle=Font_Type+y_Tit2,ZTitle=Font_Type+z_Tit, $ Charsize=1.25*Char_Size, $ /Upper_Only Polyfill,[x1(0),x1,x1(xpoints-1)],[Replicate(y1(0),xpoints+2)], $ [z_lo,ysur1(*,0),z_lo],/T3D,/Data,Color=0 IF not back_miss $ THEN $ Polyfill,[x1(0),x1,x1(xpoints-1)],[Replicate(y1(ypoints-1),xpoints+2)], $ [z_hi,ysur1(*,ypoints-1),z_hi],/T3D,/Data,Color=0 Polyfill,[Replicate(x1(0),ypoints+2)],[y1(0),y1,y1(ypoints-1)], $ [z_lo,Transpose(ysur1(0,*)),z_lo],/T3D,/Data,Color=0 IF not right_miss $ THEN $ Polyfill,[Replicate(x1(xpoints-1),ypoints+2)],[y1(0),y1,y1(ypoints-1)], $ [z_hi,Transpose(ysur1(xpoints-1,*)),z_hi],/T3D,/Data,Color=0 print,"Processing surface..." Surface,ysur1,x1,y1,/NoErase, $ XRange=plotr_x,YRange=plotr_y,ZRange=plotr_z, $ XStyle=X_Style,YStyle=Y_Style,ZStyle=Z_Style, $ Ax=xpl,Az=zpl, $ XTicks=X_Ticks,XTickV=X_Tick_Values,XTickName="", $ YTicks=Y_Ticks,YTickV=Y_Tick_Values,YTickName="", $ Charsize=1.25*Char_Size,Title="",$ Bottom=150,Color=200,/Upper_Only Surface,ysur1,x1,y1,/NoErase,/NoData, $ ; fuer die Achsen XRange=plotr_x,YRange=plotr_y,ZRange=plotr_z, $ XStyle=X_Style,YStyle=Y_Style,ZStyle=Z_Style, $ Ax=xpl,Az=zpl, $ XTicks=X_Ticks,XTickV=X_Tick_Values,XTickName="", $ YTicks=Y_Ticks,YTickV=Y_Tick_Values,YTickName="", $ Charsize=1.25*Char_Size,Title="",$ Bottom=150,Color=200,/Upper_Only Plots,[x_lo,x_lo],[y_lo,y_lo],[z_lo,ysur1(0,0)],/Data,/T3D Plots,[x_hi,x_hi],[y_lo,y_lo],[z_lo,ysur1(xpoints-1,0)],/Data,/T3D ;================================= ???????????? ============================== ; Gibt es eine Moeglichkeit, bei Surface-Plot die Achsen an andere Stellen zu ; versetzen? Sicher mit T3D - ist mir aber zu kompliziert! ; Wahrscheinlich nicht! ; IF zpl gt 180 THEN axis,YAxis=1,/YStyle,YRange=plotr_y, $ ; Chars=1.25*Char_Size,ZAxis=1,/ZStyle,ZRange=plotr_z ; IF zpl gt 90 AND zpl lt 270 THEN axis,XAxis=1,/XStyle,XRange=plotr_X, $ ; Chars=1.25*Char_Size ;================================= ???????????? ============================== ans=Get_Reply("Is something of the shadings missing?","Y|N","N",/NoCase) IF ans eq "Y" $ THEN $ BEGIN ans=Get_Reply("In the back (B), on the right side (R), both (O)?", $ "B|R|O",/NoCase) CASE ans OF "B" : back_miss=1 "R" : right_miss=1 "O" : BEGIN back_miss=1 right_miss=1 ENDCASE ENDCASE GOTO, Surface_Plot ENDIF Surface_Print: IF Eps_Ausgabe $ THEN ans=Get_Reply("Do you want to encapsulate Surface-Plot?","Y|N","N", $ /NoCase) $ ELSE ans=Get_Reply("Do you want to print Surface-Plot?","Y|N","N",/NoCase) IF ans eq "Y" $ THEN $ BEGIN Surf_File="" IF Eps_Ausgabe $ THEN read,"File name for Surface-Plot (Program adds .EPS): ",Surf_File $ ELSE read,"File name for Surface-Plot (Program adds .PS): ",Surf_File IF StrPos(Surf_File," ") ne -1 OR $ StrPos(Surf_File,"/") ne -1 OR $ StrPos(Surf_File,",") ne -1 OR $ StrPos(Surf_File,"!") ne -1 OR $ StrPos(Surf_File,"?") ne -1 $ THEN $ BEGIN print,"File name is not valid!" GOTO, Surface_Print ENDIF IF Surf_File eq "" THEN Surf_File="IDL" $ ELSE Surf_File=F_Element(0,".",Surf_File) ; um womoeg- ; lich vorhandene Suffixe ; zu entfernen IF Eps_Ausgabe $ THEN $ BEGIN Surf_File=Surf_File+".EPS" ENDIF $ ELSE $ BEGIN Surf_File=Surf_File+".PS" ENDELSE Surf_Title="" read,"Title for Surface-Plot: ",Surf_Title Set_Plot,"PS" Device,Font_Size=10,Encapsulated=Eps_Ausgabe,Filename=Surf_File,/Portrait print,"" print,"Processing shades..." Shade_Surf,ysur1,x1,y1,/Save, $ XRange=plotr_x,YRange=plotr_y,ZRange=plotr_z, $ XStyle=X_Style,YStyle=Y_Style,ZStyle=Z_Style, $ AX=xpl,AZ=zpl, $ XTicks=X_Ticks,XTickV=X_Tick_Values,XTickName="", $ YTicks=Y_Ticks,YTickV=Y_Tick_Values,YTickName="", $ Shades=Bytscl(Signif_Upp,Top=100)+Bytscl(Signif_Low,Top=100)+ $ Bytscl(Not_Signif,Top=255), $ XTitle=Font_Type+x_tit,YTitle=Font_Type+y_tit2,ZTitle=Font_Type+z_tit, $ Chars=2.5, $ YMargin=[1,4],XMargin=[6,3], $ /Upper_Only Polyfill,[x1(0),x1,x1(xpoints-1)],[Replicate(y1(0),xpoints+2)], $ [z_lo,ysur1(*,0),z_lo],/T3D,/Data,Color=255 IF not back_miss $ THEN $ Polyfill,[x1(0),x1,x1(xpoints-1)],[Replicate(y1(ypoints-1),xpoints+2)], $ [z_hi,ysur1(*,ypoints-1),z_hi],/T3D,/Data,Color=255 Polyfill,[Replicate(x1(0),ypoints+2)],[y1(0),y1,y1(ypoints-1)], $ [z_lo,Transpose(ysur1(0,*)),z_lo],/T3D,/Data,Color=255 IF not right_miss $ THEN $ Polyfill,[Replicate(x1(xpoints-1),ypoints+2)],[y1(0),y1,y1(ypoints-1)], $ [z_hi,Transpose(ysur1(xpoints-1,*)),z_hi],/T3D,/Data,Color=255 print,"Processing surface..." Surface,ysur1,x1,y1,/NoErase, $ XRange=plotr_x,YRange=plotr_y,ZRange=plotr_z, $ XStyle=X_Style,YStyle=Y_Style,ZStyle=Z_Style, $ AX=xpl,AZ=zpl, $ XTicks=X_Ticks,XTickV=X_Tick_Values,XTickName="", $ YTicks=Y_Ticks,YTickV=Y_Tick_Values,YTickName="", $ Chars=2.5, $ Bottom=150,/Upper_Only, $ YMargin=[1,4],XMargin=[6,3] Surface,ysur1,x1,y1,/NoErase,/NoData, $ ; damit die Achsen noch einmal ; uebergezeichnet werden XRange=plotr_x,YRange=plotr_y,ZRange=plotr_z, $ XStyle=X_Style,YStyle=Y_Style,ZStyle=Z_Style, $ AX=xpl,AZ=zpl, $ XTicks=X_Ticks,XTickV=X_Tick_Values,XTickName="", $ YTicks=Y_Ticks,YTickV=Y_Tick_Values,YTickName="", $ Chars=2.5, $ Bottom=150,/Upper_Only,$ YMargin=[1,4],XMargin=[6,3] Plots,[x_lo,x_lo],[y_lo,y_lo],[z_lo,ysur1(0,0)],/Data,/T3D Plots,[x_hi,x_hi],[y_lo,y_lo],[z_lo,ysur1(xpoints-1,0)],/Data,/T3D Device,Times=Times_Font,Helvetica=Helvet_Font,Palatino=Palat_Font, $ Schoolbook=School_Font, $ Bold=Bold_Font,Italic=Italic_Font,Oblique=Oblique_Font, $ Font_Size=Title_Size XYOuts,0.5,0.95,/Norm,Surf_Title,Alignment=0.5,Font=0 Device,Times=Times_Font,Helvetica=Helvet_Font,Palatino=Palat_Font, $ Schoolbook=School_Font, $ Bold=Bold_Font,Italic=Italic_Font,Oblique=Oblique_Font, $ Font_Size=SubTitle_Size Dev_String=F_Element(0,".",StrCompress(Dev_F,/Remove_All),/All) SubTit1=Dev_String(0)+"."+StrMid(Dev_String(1),0,1)+" s.d. random" SubTit2="shuffled EPs (n="+StrCompress(Anz_Noise,/Remove_All)+")" XYOuts,0.63,-0.2,/Norm,"Criterion:",Font=0 XYOuts,0.73,-0.193,/Norm,"+",Font=0 XYOuts,0.73,-0.207,/Norm,"-",Font=0 XYOuts,0.735,-0.207,/Norm,"-",Font=0 XYOuts,0.75,-0.2,/Norm,SubTit1,Font=0 XYOuts,0.73,-0.25,/Norm,SubTit2,Font=0 Plots,[0.6,0.94,0.94,0.6,0.6],[-0.15,-0.15,-0.275,-0.275,-0.15],/Norm ;================================= ???????????? ============================== ; Gibt es eine Moeglichkeit, bei Surface-Plot die Achsen an andere Stellen zu ; versetzen? Sicher mit T3D - ist mir aber zu kompliziert! ; Wahrscheinlich nicht!! ; IF zpl gt 180 THEN axis,YAxis=1,/YStyle,YRange=plotr_y, $ ; ZAxis=1,/ZStyle,ZRange=plotr_z, $ ; Chars=1.25*Char_Size ; IF zpl gt 90 AND zpl lt 270 THEN axis,XAxis=1,/XStyle,XRange=plotr_X, $ ; Chars=1.25*Char_Size ;================================= ???????????? ============================== IF Eps_Ausgabe $ THEN $ BEGIN print,"Encapsulating Surface-Plot..." Device,/Close_File ENDIF $ ELSE $ BEGIN print,"Sending Surface-Plot to printer..." IF Surf_File eq "IDL.PS" THEN Print_Plot $ ELSE Print_Plot,Surf_File ENDELSE Set_Plot,"X" print,"" ENDIF ENDCASE ; Menue-Punkt 3.1 ; ;=============================================================================== ; 25. Contour-Plot Menue-Punkt 3.2 ;=============================================================================== ; 2: $ BEGIN !X.Ticklen = -0.02 ycont_upp=Signif_Upp ycont_low=Signif_Low print,"" ans=Get_Reply( $ "Do you want to spline Contour-Plot. (I cannot recommend splining. L.F.)", $ "Y|N","N",/NoCase) IF ans eq "Y" $ THEN Splining=1 $ ; Boolean ELSE Splining=0 y1c=[y1(0),y1,y1(N_Elements(y1)-1)] x1c=[x1(0),x1,x1(N_Elements(x1)-1)] IF max(ycont_upp) eq 0 AND max(ycont_low) eq 0 $ THEN $ BEGIN print,"" print,"There is no data exceeding noise level! Contour-Plot is not ", $ "possible!" print,"" ENDIF $ ELSE $ BEGIN ycont1_Upp=Replicate(0.0,n_elements(ycont_upp(*,1))+2,n_elements( $ ycont_upp(1,*))+2) ; Vergroesserung von ycont ycont1_Upp(1,1)=ycont_upp ; ycont_upp in Mitte von ycont1_upp, um ; Flaechen fuer Polycontour zu schliessen ycont1_Low=Replicate(0.0,n_elements(ycont_Low(*,1))+2,n_elements( $ ycont_Low(1,*))+2) ; Vergroesserung von ycont ycont1_Low(1,1)=ycont_Low ; ycont_Low in Mitte von ycont1_Low, um ; Flaechen fuer Polycontour zu schliessen Cont_Filename_Upp="UPP.CONT" Cont_Filename_Low="LOW.CONT" print,"" print,"Processing Contour..." Contour,ycont1_Upp,x1c,y1c, $ XRange=plotr_x,YRange=plotr_y, $ /XStyle,/YStyle, $ XTicks=X_Ticks,XTickV=X_Tick_Values,XTickName="", $ YTicks=Y_Ticks,YTickV=Y_Tick_Values,YTickName="", $ Levels=[1],Spline=Splining, $ Path=Cont_Filename_Upp, $ Title=Font_Type+name1,SubTit=Font_Type+Sub_Title, $ XTitle=Font_Type+x_tit,YTitle=Font_Type+y_tit2,$ Chars=0.85*Char_Size, $ YMargin=[5,2] Contour,ycont1_Low,x1c,y1c,/NoErase, $ XRange=plotr_x,YRange=plotr_y, $ /XStyle,/YStyle, $ XTicks=X_Ticks,XTickV=X_Tick_Values,XTickName="", $ YTicks=Y_Ticks,YTickV=Y_Tick_Values,YTickName="", $ Levels=[1],Spline=Splining, $ Path=Cont_Filename_Low, $ XTitle=Font_Type+x_tit,YTitle=Font_Type+y_tit2,$ Chars=0.85*Char_Size, $ YMargin=[5,2] print,"Processing Fillings..." PolyContour,Cont_Filename_Upp,Color_Index=[0,200] PolyContour,Cont_Filename_Low,Color_Index=[0,150] ENDELSE Contour_Print: IF Eps_Ausgabe $ THEN ans=Get_Reply("Do you want to encapsulate Contour-Plot","Y|N","N", $ /NoCase) $ ELSE ans=Get_Reply("Do you want to print Contour-Plot","Y|N","N",/NoCase) IF ans eq "Y" $ ; 8. Mal THEN $ BEGIN Cont_File="" IF Eps_Ausgabe $ THEN read,"File name for Contour-Plot (Program adds .EPS)? ",Cont_File $ ELSE read,"File name for Contour-Plot (Program adds .PS)? ",Cont_File IF StrPos(Cont_File," ") ne -1 OR $ StrPos(Cont_File,"/") ne -1 OR $ StrPos(Cont_File,",") ne -1 OR $ StrPos(Cont_File,"!") ne -1 OR $ StrPos(Cont_File,"?") ne -1 $ THEN $ BEGIN print,"File name is not valid!" GOTO, Contour_Print ENDIF IF Cont_File eq "" THEN Cont_File="IDL" $ ELSE Cont_File=F_Element(0,".",Cont_File) IF Eps_Ausgabe $ THEN $ BEGIN Cont_File=Cont_File+".EPS" ENDIF $ ELSE $ BEGIN Cont_File=Cont_File+".PS" ENDELSE Cont_Title="" read,"Title for Contour-Plot: ",Cont_Title Set_Plot,"PS" Device,Font_Size=20,Encapsulated=Eps_Ausgabe,Filename=Cont_File, $ /Portrait,/Helvetica print,"Processing Contour..." Contour,ycont1_Upp,x1c,y1c, $ XRange=plotr_x,YRange=plotr_y, $ /XStyle,/YStyle, $ XTicks=X_Ticks,XTickV=X_Tick_Values,XTickName="", $ YTicks=Y_Ticks,YTickV=Y_Tick_Values,YTickName="", $ Levels=[1],Spline=Splining, $ Path=Cont_Filename_Upp, $ XTitle=x_tit,YTitle=y_tit2,$ Font=0 Contour,ycont1_Low,x1c,y1c,/NoErase, $ XRange=plotr_x,YRange=plotr_y, $ /XStyle,/YStyle, $ XTicks=X_Ticks,XTickV=X_Tick_Values,XTickName="", $ YTicks=Y_Ticks,YTickV=Y_Tick_Values,YTickName="", $ Levels=[1],Spline=Splining, $ Path=Cont_Filename_Low, $ XTitle="", $ YTitle="", $ Font=0 print,"Processing Fillings..." PolyContour,Cont_Filename_Upp, Color_Index=[0,200] PolyContour,Cont_Filename_Low, Color_Index=[0,100] Contour,ycont1_Low,x1c,y1c,/NoErase,/NoData, $ ; nur fuer die Achsen XRange=plotr_x,YRange=plotr_y, $ /XStyle,/YStyle, $ XTicks=X_Ticks,XTickV=X_Tick_Values,XTickName="", $ YTicks=Y_Ticks,YTickV=Y_Tick_Values,YTickName="", $ Levels=[1],Spline=Splining, $ XTitle="", $ YTitle="", $ Font=0 Device,Times=Times_Font,Helvetica=Helvet_Font,Palatino=Palat_Font, $ Schoolbook=School_Font, $ Bold=Bold_Font,Italic=Italic_Font,Oblique=Oblique_Font, $ Font_Size=Title_Size XYOuts,0.5,1.10,/Norm,Cont_Title,Alignment=0.5,Font=0 Device,Times=Times_Font,Helvetica=Helvet_Font,Palatino=Palat_Font, $ Schoolbook=School_Font, $ Bold=Bold_Font,Italic=Italic_Font,Oblique=Oblique_Font, $ Font_Size=SubTitle_Size Dev_String=F_Element(0,".",StrCompress(Dev_F,/Remove_All),/All) SubTit1=Dev_String(0)+"."+StrMid(Dev_String(1),0,1)+" s.d. random" SubTit2="shuffled EPs (n="+StrCompress(Anz_Noise,/Remove_All)+")" XYOuts,0.63,-0.2,/Norm,"Criterion:",Font=0 XYOuts,0.73,-0.193,/Norm,"+",Font=0 XYOuts,0.73,-0.207,/Norm,"-",Font=0 XYOuts,0.735,-0.207,/Norm,"-",Font=0 XYOuts,0.75,-0.2,/Norm,SubTit1,Font=0 XYOuts,0.73,-0.25,/Norm,SubTit2,Font=0 Plots,[0.6,0.94,0.94,0.6,0.6],[-0.15,-0.15,-0.275,-0.275,-0.15],/Norm IF Eps_Ausgabe $ THEN $ BEGIN print,"" print,"Encapsulating Contour-Plot..." Device,/Close_File ENDIF $ ELSE $ BEGIN print,"" print,"Sending Contour-Plot to printer..." IF Cont_File eq "IDL.PS" THEN Print_Plot $ ELSE Print_Plot,Cont_File ENDELSE Set_Plot,"X" print,"" ENDIF ; ans 8. Mal ENDCASE ; Menue-Punkt 3.2 ; ;=============================================================================== ; 26. Change Plot-Parameters Menue-Punkt 3.3 ;=============================================================================== ; 3: $ BEGIN SubMenu_33_Loop=1 ; Boolean REPEAT $ CASE WMenu(Subm_33,Title=13) OF ; ;=============================================================================== ; 27. Read me (Change Plot-Parameters) Menue-Punkt 3.3.0 ;=============================================================================== ; 0: $ BEGIN print,"" print,"Info: Change Plot-Parameters" print,"Viewpoint: Angle of view in degrees." print," Rotation around x-axis: The higher the number the steeper the view." print," Rotation around z-axis: The higher the number the more rotation" print," clockwise." print,"Resolution: Number of points on x-axis. The higher the number the" print," better the resolution. BUT: With Surface-Plots a high resolution" print," (more than about 250) leeds to a grid with lines close together." print," The 3-dimensional impression gets worse!" print,"PS-/EPS-File: These items are the only ones to be selected while un-" print," marked. Always one of both is labeled with a '+'. Imagine these" print," items as 'Radio buttons': Selecting one turns off the other." print,"Font and size of characters: Default is Helvetica Bold. You can change" print," font and size of characters and of the title. Be careful while chan-" print," ging the size, because the size of characters influences the plot- print," size. This menu-point is not activated at the moment." print,"" ENDCASE ; Menue-Punkt 3.3.0 ; ;=============================================================================== ; 28. Plot-Range x-axis Menue-Punkt 3.3.1 ;=============================================================================== ; 1: $ BEGIN x_min=-tvor+Fix(Max_Wave_t/2) x_max=Fix(tnach-Max_Wave_t/2) IF User eq "FUHRY" $ THEN $ BEGIN x_lo=Get_Number("X-range: lower margin",x_min,x_max,0 > x_min,/Integer) x_hi=Get_Number("X-range: upper margin",x_min,x_max,400 < x_max,/Integer) ENDIF $ ELSE $ BEGIN x_lo=Get_Number("X-range: lower margin",x_min,x_max,x_min,/Integer) x_hi=Get_Number("X-range: upper margin",x_min,x_max,x_max,/Integer) ENDELSE plotr_x=[x_lo,x_hi] Tick_Diff=Fix((x_hi-x_lo)/300)*100 IF Tick_Diff eq 0 THEN Tick_Diff=100 factor=Fix(x_lo/Tick_Diff) IF x_lo gt 0 THEN factor=factor+1 tick_value=factor*Tick_Diff IF (tick_value - x_lo) lt (Tick_Diff*2/3) $ THEN tick_value=tick_value+Tick_Diff X_Tick_Values=[x_lo,tick_value] WHILE (tick_value+Tick_Diff) le x_hi DO $ BEGIN tick_value=tick_value+Tick_Diff X_Tick_Values=[X_Tick_Values,tick_value] ENDWHILE X_Ticks=N_Elements(X_Tick_Values)-1 New_Points=1 ; Boolean New_Parameter=1 ; Boolean ENDCASE ; Menue-Punkt 3.3.1 ; ;=============================================================================== ; 29. Plot-Range y-axis Menue-Punkt 3.3.2 ;=============================================================================== ; 2: $ BEGIN y_lo=Get_Number("Y-range: lower margin",0,Max_Wave_t,Min_Wave_t,/Integer) y_hi=Get_Number("Y-range: upper margin",0,Max_Wave_t,Max_Wave_t,/Integer) plotr_y=[y_lo,y_hi] New_Points=1 ; Boolean New_Parameter=1 ; Boolean ENDCASE ; Menue-Punkt 3.3.1 ; ;=============================================================================== ; 30. Plot-Range z-axis Menue-Punkt 3.3.3 ;=============================================================================== ; 3: $ BEGIN IF User eq "FUHRY" $ THEN $ BEGIN z_lo_default=-12 ; zunaechst z_hi_default=12 ; Default fuer User FUHRY ENDIF $ ELSE $ BEGIN z_lo_default=-3 ; zunaechst z_hi_default=3 ; Default fuer andere User ausser FUHRY ENDELSE z_lo=Get_Number("Z-range: lower margin",-10000,0,z_lo_default,/Integer) z_hi=Get_Number("Z-range: upper margin",0,10000,z_hi_default,/Integer) plotr_z=[z_lo,z_hi] New_Points=1 ; Boolean New_Parameter=1 ; Boolean ENDCASE ; Menue-Punkt 3.3.1 ; ;=============================================================================== ; 31. Viewpoint Menue-Punkt 3.3.4 ;=============================================================================== ; 4: $ BEGIN print,"Rotation around x-axis: ",xpl,", around z-axis: ",zpl xpl=Get_Number("Rotation around x-axis",0.,90.,45.,/Real) zpl=Get_Number("Rotation around z-axis",0.,360.,5.,/Real) IF zpl ge 90 THEN print,"Sorry, but there will be problems with the axis!" New_Parameter=1 ; Boolean ENDCASE ; Menue-Punkt 3.3.4 ; ;=============================================================================== ; 32. Resolution x-axis Menue-Punkt 3.3.5 ;=============================================================================== ; 5: $ BEGIN print,"Number of points on x-axis: ",xpoints,", on y-axis ",ypoints xpoints=Get_Number("New number of points on x-axis?",10,3000,200,/Integer) New_Parameter=1 ; Boolean New_Points=1 ; Boolean ENDCASE ; Menue-Punkt 3.3.5 ; ;=============================================================================== ; 33. Standard Deviation Menue-Punkt 3.3.6 ;=============================================================================== ; 6: $ BEGIN Dev_F=Get_Number("Factor for Standard Deviation?",1.,10.,3.,/Real) yupp=ysm+Dev_F*ysd ylow=ysm-Dev_F*ysd New_Parameter=1 ; Boolean New_Points=1 ; Boolean ENDCASE ; Menue-Punkt 3.3.6 ; ;=============================================================================== ; 34. PS-File Menue-Punkt 3.3.7 ;=============================================================================== ; 7: $ BEGIN EPS_Ausgabe=0 subm_33(7)=Pos_Radio_Button+subm_33_7 subm_33(8)=Neg_Radio_Button+subm_33_8 New_Parameter=1 ; Boolean ENDCASE ; Menue-Punkt 3.3.7 ; ;=============================================================================== ; 35. EPS-File Menue-Punkt 3.3.8 ;=============================================================================== ; 8: $ BEGIN EPS_Ausgabe=1 subm_33(7)=Neg_Radio_Button+subm_33_7 subm_33(8)=Pos_Radio_Button+subm_33_8 New_Parameter=1 ; Boolean ENDCASE ; Menue-Punkt 3.3.8 ; ;=============================================================================== ; 36. Leerzeile Menue-Punkt 3.3.9 ;=============================================================================== ; 9: ; ;=============================================================================== ; 37. Font and size of characters Menue-Punkt 3.3.10 ;=============================================================================== ; 10: $ BEGIN print, $ "Not activated at the moment - you can only use default-font (Helvetica)!" GOTO, Ende_Font Font_Eingabe: print,"Font for charcters:" ans=Get_Reply("Times Roman (T) or Helvetica (H)?","T|H","H",/NoCase) IF ans eq "T" THEN Times=1 $ ELSE Times=0 ans=Get_Reply("Bold?","Y|N","Y",/NoCase) IF ans eq "Y" THEN Bold=1 $ ELSE Bold=0 IF Times $ THEN $ BEGIN ans=Get_Reply("Italic?","Y|N","N",/NoCase) IF ans eq "Y" THEN Italic=1 $ ELSE Italic=0 IF Bold $ THEN $ IF Italic THEN Font_Type="!18" $ ; Times Roman Bold Italic ELSE Font_Type="!17" $ ; Times Roman Bold ELSE $ IF Italic THEN Font_Type="!8" $ ; Times Roman Italic ELSE Font_Type="!6" ; Times Roman ENDIF $ ELSE $ IF Bold THEN Font_Type="!5" $ ; Helcetica Bold ELSE Font_Type="!3" ; Helvetica Char_Size=Get_Number("Size of charcters?",0.,3.,1.5,/Real) print,"Font for title:" ans=Get_Reply( $ "Times Roman (T), Helvetica (H), Palatino (P) or Schoolbook (S)?", $ "T|H|P|S","H",/NoCase) Times_Font=0 Helvet_Font=0 Palat_Font=0 School_Font=0 CASE ans OF "T" : Times_Font=1 "H" : Helvet_Font=1 "P" : Palat_Font=1 "S" : School_Font=1 ENDCASE ans=Get_Reply("Bold?","Y|N","Y",/NoCase) IF ans eq "Y" THEN Bold_Font=1 $ ELSE Bold_Font=0 ans=Get_Reply("Italic?","Y|N","N",/NoCase) IF Helvet_Font $ THEN $ BEGIN Italic_Font=0 IF ans eq "Y" THEN Oblique_Font=1 $ ELSE Oblique_Font=0 ENDIF $ ELSE $ BEGIN Oblique_Font=0 IF ans eq "Y" THEN Italic_Font=1 $ ELSE Italic_Font=0 ENDELSE Title_Size=Get_Number("Font-Size for title? (Be careful)",5,40,14,/Integer) IF Font_Type eq "!17" OR Font_Type eq "!18" $ ; weil in diesen beiden THEN $ ; Fonts geschweifte Klam- BEGIN ; mern sind, in 5 eckige! x_Tit = "time after stimulus change !5["+Font_Type+"ms!5]"+ $ Font_Type y_Tit2 = "wavelet width !5["+Font_Type+"ms!5]"+Font_Type ENDIF New_Parameter=1 ; Boolean Ende_Font: ENDCASE ; Menue-Punkt 3.3.10 ; ;=============================================================================== ; 38. Leerzeile Menue-Punkt 3.3.11 ;=============================================================================== ; 11: ; ;=============================================================================== ; 39. Return to Plot Menue-Punkt 3.3.12 ;=============================================================================== ; 12: $ BEGIN SubMenu_33_Loop=0 ENDCASE ; Menue-Punkt 3.3.12 ; ;=============================================================================== ; 26. Change Plot-Parameters Menue-Punkt 3.3 (Schluss) ;=============================================================================== ; ENDCASE $ ; WMenu(Subm_33) UNTIL NOT SubMenu_33_Loop IF New_Points $ THEN $ BEGIN i_hi=1.*y_hi*extent/(ams*tsamp) - 2 IF i_hi gt Fix(i_hi) THEN i_hi=Fix(i_hi+1) $ ELSE i_hi=Fix(i_hi) i_lo=Fix(1.*y_lo*extent/(ams*tsamp) - 2) ypoints=i_hi-i_lo+1 IF ypoints eq 1 $ THEN $ IF i_lo ne steps $ THEN $ BEGIN ypoints=2 i_hi=i_hi+1 ENDIF $ ELSE $ BEGIN ypoints=2 i_lo=i_lo-1 ENDELSE y1=(Findgen(steps+1)/2.+1)*Min_Wave_t y1=y1(i_lo:i_hi) plotr_y=[Min_Wave_t*(1+i_lo/2.),Min_Wave_t*(1+i_hi/2.)] IF plotr_y(0) eq 20 AND plotr_y(1) eq 300 $ THEN $ BEGIN Y_Tick_Values=[20,100,150,200,250,300] Y_Ticks=5 Y_TickName="" ENDIF $ ELSE $ BEGIN Y_Tick_Values=0 Y_Ticks=0 Y_TickName="" ENDELSE xprzy=(0.+x_hi-x_lo)/(xpoints-1) x1=x_lo+Findgen(xpoints)*xprzy offset_t=tvor-Max_Wave_t/2+x_lo offset_ext=Fix(offset_t*extent/tsamp) ende_ext=Fix(offset_ext-1+(x_hi-x_lo)*extent/tsamp) print,"Expanding Data for resolution applicated..." ysur1=expand(ysur(offset_ext:ende_ext,i_lo:i_hi),xpoints,ypoints) print,"Expanding upper margin for resolution applicated..." yupp1=expand(yupp(offset_ext:ende_ext,i_lo:i_hi),xpoints,ypoints) print,"Expanding lower margin for resolution applicated..." ylow1=expand(ylow(offset_ext:ende_ext,i_lo:i_hi),xpoints,ypoints) Signif_Upp=IntArr(xpoints,ypoints) Signif_Low=IntArr(xpoints,ypoints) Not_Signif=IntArr(xpoints,ypoints) Signif=Where(ysur1 gt yupp1,N_Signif) FOR i=0,N_Signif-1 DO Signif_Upp(Signif(i))=1 ; Signif_Upp/_Low sind Arrays Signif=Where(ysur1 lt ylow1,N_Signif) ; mit Nullen (signifikant) FOR i=0,N_Signif-1 DO Signif_Low(Signif(i))=1 ; und Einsen (nicht signif.) Signif=Where(((ysur1 le yupp1) AND (ysur1 ge ylow1)),N_Signif) FOR i=0,N_Signif-1 DO Not_Signif(Signif(i))=1 ; Sub_Title=F_Element(1," ",String(Anz_Noise))+" moves, "+ $ F_Element(1," ",String(Dev_F))+" times standard deviation." ENDIF ; New_Points New_Points=0 ENDCASE ; Menu-Punkt 33 ; ;=============================================================================== ; 38. Leerzeile Menue-Punkt 3.4 ;=============================================================================== ; 4: ; ;=============================================================================== ; 39. Return to Main Menu Menue-Punkt 3.5 ;=============================================================================== ; 5: $ BEGIN SubMenu_3_Loop=0 ENDCASE ; Menue-Punkt 3.5 ; ;=============================================================================== ; 22. Compare Data with Noise Menue-Punkt 3 (Schluss) ;=============================================================================== ; ENDCASE $ ; WMenu(Subm_3) UNTIL NOT SubMenu_3_Loop End_SubMenu_3: ENDCASE ; Menu-Punkt 3 ; ;=============================================================================== ; 40. Leerzeile Menue-Punkt 4 ;=============================================================================== ; 4: ; ;=============================================================================== ; 41. Quit - Return to IDL Menue-Punkt 5 ;=============================================================================== ; 5: $ BEGIN ans=Get_Reply("Do you really want to quit WAVE_EEG?","Y|N","N",/NoCase) IF ans eq "Y" THEN Menu_Loop=0 ENDCASE ; Menue-Punkt 5 ; ;=============================================================================== ; 4. Window- und Menue-Steuerung (Schluss) ;=============================================================================== ; ENDCASE $ ; WMenu(Menu) UNTIL NOT Menu_Loop ; Hauptmenue GOTO, Ende ; ;=============================================================================== ; 42. Fehlerbehandlung und Schluss: ;=============================================================================== ; IO_Error: Print, !Err_String Goto, Menu ; Zurueck zum Haupt-Menue. Ende: END ;===============================================================================