PRO MAINWTC_EVENT, Event ;+ ;This routine handles the events from the Wavelet Transform ;Compression Widget. ;- COMMON WTC_common, FSLID3, BUTTON4, BUTTON5, FSLID4, BUTTON8, BUTTON9, $ BUTTON18, wc, wcmsort, thr, n, threshslider, numslider, orig_wc COMMON WWB_COMMON, $ TEXT_ANNOUNCE, wd, sig, len, st, noise_type, noise_lev, $ QMF, LD, shrinkage_type, WaveType, ParVal ;Color of text strings IF !p.background EQ 0 THEN cl = 255 ELSE cl = 0 type = TAG_NAMES(event, /structure_name) WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev CASE 1 OF ( type eq 'WIDGET_BUTTON' ) and ( ev eq 'Done' ): BEGIN WIDGET_CONTROL, event.top, /destroy END ELSE: BEGIN CASE ev OF 'FSLID3': BEGIN ;Print, 'Event for Threshold Value' WIDGET_CONTROL, Event.Id, get_value=f threshslider = f thr = EXP(f) ;find coeffs > threshold temp= WHERE((wcmsort GT thr) > 0) + 1 ;add 1 to get indices right i = MAX(temp) mini = MIN([n, i]) i = MAX( [mini, 1] ) END 'BUTTON4': BEGIN ;Print, 'Event for Thresh/2' f = threshslider thr = EXP(f)/2 f = ALOG(thr) ;find coeffs > threshold temp= WHERE((wcmsort GT thr) > 0) + 1 ;add 1 to get indices right i = MAX(temp) mini = MIN([n, i]) i = MAX( [mini, 1] ) END 'BUTTON5': BEGIN ;Print, 'Event for Thresh*2' f = threshslider thr = EXP(f)*2 f = ALOG(thr) ;find coeffs > threshold temp= WHERE((wcmsort Gt thr) > 0) + 1 ;add 1 to get indices right i = MAX(temp) mini = MIN([n, i]) i = MAX( [mini, 1] ) frac = (i-1) / n END 'FSLID4': BEGIN ;Print, 'Event for Number of Coefficients' WIDGET_CONTROL, Event.Id, get_value=i thr = wcmsort(i-1) f = ALOG(thr) END 'BUTTON8': BEGIN ;Print, 'Event for N_Coeffs/2' numslider = numslider / 2 i = numslider thr = wcmsort(i) f = ALOG(thr) END 'BUTTON9': BEGIN ;Print, 'Event for N_Coeff*2' numslider = numslider * 2 i = numslider thr = wcmsort(i) f = ALOG(thr) END 'Compute': BEGIN ;Print, 'Event for Compute' WIDGET_CONTROL, FSLID3, get_value=f WIDGET_CONTROL, FSLID4, get_value=i wc = WHARDTHR(orig_wc,thr); sthr = 'Coefficients above Threshold: ' + STRCOMPRESS(STRING(f)) signaltitle = sthr + ' for ' + st spiketitle = 'Dyadic '+ sthr + ' for ' + st ;Set up the plot window ;pt and d are dummy values pt = '' & d = FLTARR(2) WPLOTIT, pt, 4, d ;Stack two plots vertically on the page !p.multi = [0, 1, 2] ;Plot the coeffs in a spike plot for each of the dyads WPLWCOEF,wc,LD,0., spiketitle ;Plot the coefficients in bottom plot PLOT, wc, title = signaltitle, color = cl !p.multi = 0 ;reset to no multiple plots ;Reconstruct the signal or data recon = WIWTPO(wc,LD,QMF); rt = 'Reconstruction from N=' + STRCOMPRESS(STRING(i))+ ' Coefficients' signaltitle = rt + ' for ' + st ;Set up the plot window ;pt and d are dummy values pt = '' & d = FLTARR(2) WPLOTIT, pt, 5, d PLOT, recon, TITLE = signaltitle, color= cl END ;Compute button ENDCASE ;ev WIDGET_CONTROL, FSLID3, set_value=f threshslider = f WIDGET_CONTROL, FSLID4, set_value=i numslider = i END ;ELSE ENDCASE ;CASE 1.. Checking buttons and menu items END ;of procedure MAINWTC_Event ;**************************************************************** PRO WTC, GROUP=Group ;This procedure sets up the Wavelet Transform Compression widget. COMMON WTC_common, FSLID3, BUTTON4, BUTTON5, FSLID4, BUTTON8, BUTTON9, $ BUTTON18, wc, wcmsort, thr, n, threshslider, numslider, orig_wc COMMON WWB_COMMON, $ TEXT_ANNOUNCE, wd, sig, len, st, noise_type, noise_lev, $ QMF, LD, shrinkage_type, WaveType, ParVal ;----------Prep work------------------ ;Do Wavelet Transform and plot coefficients in a Spike Plot WINTWAVE, sig, WaveType, ParVal, QMF, LD ;Coarse (=LD?) = 3 wc = WFWTPO(sig,LD,QMF) orig_wc = wc plotwin = 3 WDODWT, sig, QMF, LD, st, plotwin, wc n = 512 ;max number of coefficients wcmsort = WCOMBINE( REVERSE(WMSORT(ABS(wc))) ) i = FLOOR(1 + .05 * (n-1)) thr = wcmsort(i-1) threshslider = ALOG(thr) numslider = i ;---------------------------------------- IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0 junk = { CW_PDMENU_S, flags:0, name:'' } MAINWTC = WIDGET_BASE(GROUP_LEADER=Group, $ ROW=3, $ MAP=1, $ TITLE='Wavelet Transform Compression', $ UVALUE='MAINWTC') BASE2 = WIDGET_BASE(MAINWTC, $ ROW=1, $ MAP=1, $ UVALUE='BASE2') FSLID3 = CW_FSLIDER( BASE2, $ DRAG=0, $ TITLE='Threshold Value', $ UVALUE='FSLID3', $ EDIT=1, $ VALUE= threshslider, $ XSIZE=200, $ MINIMUM=ALOG(wcmsort(0))-10, $ MAXIMUM=ALOG(wcmsort(0))) BUTTON4 = WIDGET_BUTTON( BASE2, $ UVALUE='BUTTON4', $ VALUE='Exp(Thresh)/2', $ XSIZE=110, $ YSIZE=40) BUTTON5 = WIDGET_BUTTON( BASE2, $ UVALUE='BUTTON5', $ VALUE='Exp(Thresh)*2', $ XSIZE=110, $ YSIZE=40) BUTTON6 = WIDGET_BUTTON( BASE2, $ UVALUE='Done', $ VALUE='Done') BASE6 = WIDGET_BASE(MAINWTC, $ ROW=1, $ MAP=1, $ UVALUE='BASE6') FSLID4 = WIDGET_SLIDER( BASE6, $ DRAG=0, $ TITLE='Number of Coefficients', $ UVALUE='FSLID4', $ VALUE=numslider, $ MINIMUM=0, $ MAXIMUM=n, $ XSIZE=200) BUTTON8 = WIDGET_BUTTON( BASE6, $ UVALUE='BUTTON8', $ VALUE='N_Coeffs/2', $ XSIZE=100, $ YSIZE=40) BUTTON9 = WIDGET_BUTTON( BASE6, $ UVALUE='BUTTON9', $ VALUE='N_Coeff*2', $ XSIZE=100, $ YSIZE=40) BASE17 = WIDGET_BASE(MAINWTC, $ ROW=1, $ MAP=1, $ TITLE='Compute', $ UVALUE='BASE17') BUTTON18 = WIDGET_BUTTON( BASE17, $ UVALUE='Compute', $ VALUE='Compute', $ XOFFSET=50, $ XSIZE=400, $ YSIZE=20) WIDGET_CONTROL, MAINWTC, /REALIZE XMANAGER, 'MAINWTC', MAINWTC END ;of Procedure WTC