19 Calculating the confidence ranges of spectra and elution curves

19 Calculating the confidence ranges of spectra and elution curves

19 Calculating the confidence ranges of spectra and elution curves The program zzzdar2.m calculates the confidence ranges for the best point in constr...

873KB Sizes 0 Downloads 50 Views

19 Calculating the confidence ranges of spectra and elution curves The program zzzdar2.m calculates the confidence ranges for the best point in constraint space. The results from the AR process are inspected by the user who selects the best point in the constraint space as his final solution. For reasons of storage space the results from the AR process are limited to statistics. All intermediate solutions for spectra and elution curves cannot be kept. The zzzdar2 .m recalculates the intermediate values. %ZZZDAR2.M calculates the confidence intervals for spectra and elution curves found by AR. % Date: 30 Sep 1995 % ======================================= % Data analysis for hyphenated techniques % (c) Erkki & Ulla Karjalainen 1995 % ======================================= function zzzdar2(page,gui,action); global C global elpchoice global gcuriter global gcurrpt global gcurspec global gelpcur global gelpmax global gelprnin global gelpsteps %

· 8 · ----I.. •

Obs.mat params.txt -----t.~ kombi.mat

DAR2

-----I.~

current2.txt CCC;mat SSS.mat

Figure 19.1 Program zzzdar2 .mreads the data stored by programAR in matrix Obs . mat, the parameters stored in params. txt and the solution matrix stored in kombi . mat. It outputs the spectra in matrix sss . mat and the elution curves in matrix CCC .mat. The selected parameter values are stored in file current2. txt. 383

384

global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global global

gmaxiter gmaxspec gminspec grptct gspectcur gspectmax gspectmin gspectsteps gtotalsteps kombi nofile Obs S SavedFile spectchoice stepcount unichoice ed_STATrun_Stepct ed_STATset_CUriter ed_STATset_Currpt ed_STATset_CUrspec ed_STATset_Elpcurl ed_STATset_Elpcur2 ed_STATset_Elplinlog e~STATset_Elpmax

ed_STATset_Elpmin ed_STATset_Elpsteps ed_STATset_Maxspec ed_STATset_Minspec ed_STATset_8Pectcul ed_STATset_8Pectcu2 ed_STATset_8Pectlinlog ed_STATset_8Pectmax ed_STATset_8Pectmin ~STATset_8Pectsteps

ed_STATset_Uni fg_STATrun fg_STATset fr_STATset_CUrrentframe fr_STATset_Paramframe mi_STATrun_Back mi_STATrun_Help mi_STATrun_Qui t mi_STATrun_Save mi_STATrun_Save_as mi_STATrun_Save_curves mi_STATrun_Save_spectra mi_STATset_Help mi_STATset_Quit mi_STATset_Run mn_STATrun_Files mn_STATrun_GOTO mn_STATset_Files mn_STATset_GOTO

385 global pb_STATrun_Back global pb_STATrun_Help global pb_STATset_Help global pb_STATset_Load_Default global pb_STATset_Run global bcSTATset_CUritertx global tx_STATset_CUrrpttx global tx_STATset_CUrspectx global tx_STATset_Elpcurtxl global tx_STATset_Elpcurtx2 global tx_STATset_Elpmaxtx global tx_STATset_Elpmintx global tx_STATset_Elprof global tx_STATset_Elpstepstx global tx_STATset_Maxspectx global tx_STATset_Minspectx global tx_STATset_Paramheader global tx_STATset_5Pecies global tx_STATset_5Pectconst global tx_STATset_5Pectcurtxl global tx_STATset_5Pectcurtx2 global tx_STATset-5Pectmaxtx global tx_STATset_5Pectmintx global tx-pTATset_5Pectstepstx global tx_STATset_Subsetheader if nargin == 0 page = 'initpage'; gui = 'initgui'; action = 0; end if strcmp(page, 'initpage') fg_STATset = figure; fg_STATrun = figure; zzzdar2('STATrun', 'initgui',O); zzzdar2('STATset', 'initgui',O); page = " ; end if strcmp(page,'STATset') figure (fg_STATset) set (gcf, 'NumberTitle', 'off', 'Name', 'STATset', •.. 'backingstore', 'off'); if strcmp(gui, 'initgui') zzzdar2('STATset', 'STATset_Menul',O); zzzdar2('STATset', 'STATset_Menu2',O); zzzdar2 ( , STATset' , 'STATset_Paramframe' ., 0) ; zzzdar2('STATset', 'STATset_CUrrentframe',O); zzzdar2('STATset','STATset_Paramheader',O); zzzdar2('STATset', 'STATset_Subsetheader',O); zzzdar2('STATset', 'STATset_Elprof',O); zzzdar2('STATset', 'STATset_Uni',O); zzzdar2( , STATset' , 'STATset..JUpmin' , 0) ; zzzdar2('STATset', 'STATset_Elpmintx',O); zzzdar2('STATset', 'STATset_Elpcurtxl',O);

386

zzzdar2('STATset', 'STATset_Elpcur1',O)i zzzdar2('STATset', 'STATset_Elpmax',O)i zzzdar2('STATset', 'STATset_Elpmaxtx',O)i zzzdar2('STATset', 'STATset_Elpcur2',0)i zzzdar2('STATset', 'STATset_Elpcurtx2',0)i zzzdar2('STATset', 'STATset_Elplinlog',O)i zzzdar2('STATset', 'STATset_Elpsteps',O)i zzzdar2('STATset', 'STATset_Elpstepstx',O)i zzzdar2('STATset', 'STATset_Spectcurtx1',0)i zzzdar2('STATset', 'STATset_Spectcu1',0)i zzzdar2('STATset', 'STATset_Spectconst',O)i zzzdar2('STATset', 'STATset_Spectcu2',0)i zzzdar2('STATset', 'STATset_Spectcurtx2',0)i zzzdar2('STATset', 'STATset_Spectmin',O)i zzzdar2('STATset', 'STATset_Spectmintx',O)i zzzdar2('STATset', 'STATset_Spectmax',O)i zzzdar2('STATset', 'STATset_Spectmaxtx',O)i zzzdar2('STATset', 'STATset_Curspectx',O)i zzzdar2('STATset', 'STATset_CUrspec',O)i zzzdar2('STATset', 'STATset_Spectlinlog',O)i zzzdar2('STATset', 'STATset_Spectsteps',O)i zzzdar2('STATset', 'STATset_Spectstepstx',O)i zzzdar2('STATset', 'STATset_CUrrpttx',O)i zzzdar2('STATset', 'STATset_CUrrpt',O)i zzzdar2('STATset', 'STATset_Species',O)i zzzdar2('STATset', 'STATset_Minspec',O)i zzzdar2('STATset', 'STATset_Minspectx',O)i zzzdar2('STATset', 'STATset_Curitertx',O)i zzzdar2('STATset', 'STATset_CUriter',O)i zzzdar2('STATset', 'STATset_Maxspec',O)i zzzdar2('STATset', 'STATset_Maxspectx',O)i zzzdar2('STATset', 'STATset_Run',O)i zzzdar2('STATset', 'STATset_Load_Default',O)i zzzdar2('STATset', 'STATset_Help',O)i zzzdar2('STATset', 'STATset_Boot',1)i end if strcmp(gui, 'STATset_Paramframe') if action == 0 fr_STATset_Paramframe = uicontrol(fg_STATset, ... 'Style', 'frame', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.057 0.058 0.443 0.904])i end end if strcmp(gui, 'STATset_Currentframe') if action == 0 fr_STATset_Currentframe = uicontrol(fg_STATset, ... 'Style', 'frame','BackgroundColor', [0.50' 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.529 0.058 0.414 0.904])i end end if strcmp(gui, 'STATset_Menu1') if action == 0 mn_STATset_Files = uimenu(fg_STATset, ... 'Label', 'Files')i

387 mi_STATset_Quit = uimenu(mn~TATset_Files, ... 'Label', 'Quit', ... 'CallBack', 'zzzdar2(' 'STATset",' 'STATset_bye' ',1); '); end end i f strcnp (gui, 'STATsetJIenu2 ' ) if action == 0 mn_STATset_GOTO = uimenu(fg_STATset, .•. 'Label' , 'GOTO') ; mi_STATset_Run = uimenu (mn_STATset_GOTO, ... 'Label', 'Run', ... 'CallBack', 'zzzdar2(' 'STATset' " "STATset~runthem' ',1);'); mi_STATset_Help = uimenu(mn_STATset_GOTO, ... 'Label', 'Help', ... 'CallBack', 'zzzdar2(' 'STATset",' 'STATset_Help' ',1);'); end end if strcnp(gui, 'STATset_setthem') if action == 1 figure (fg_STATset) page = 1; end end i f strcnp (gui, 'STATset_runthem' ) if action == 1 figure (fg_STATrun) page = 2i end end if strcnp (gui, 'STATset_Save_s' ) if action == 1 [filename, path]=uiputfile('S.mat', 'Save spectra file:')i pit=length(filename)i if filename -= 0 vari=filename(1:pit-4); zapu=[vari, , = Si']; eval(zapu) rapu= [ 'save " vari,' , vari] i eval(rapu) end end end if strcnp(gui, 'STATset_Save_c') if action == 1 [filename, path]=uiputfile('CCC.mat', 'Save elution curves file:'); pit=length(filename)i if filename -= 0 pit=length(filename); vari=filename; i f pit> 4 vari=filename(1:pit-4); end zapu=[vari, ' = CCCi']i

388 eval(zapu) rapu= [ 'save' eval(rapu)

vari,' ,

vari] ;

end

end end

if strcmp(gui, 'STATset_Boot') if action == 1 %global gmaxiter %global grptct %global gminspec %global gmaxspec %global gspectsteps %global gspectmin %global gspectmax %global gelpsteps %global gelpmax %global gelpmin %global gtotalsteps %global elpchoice %global spectchoice %global unichoice %global kombi %global Obs fid = fopen( 'PARAMS.TXT', 'r'); gmaxiter = fscanf(fid,'%f', [1,1]); grptct = fscanf(fid, '%f', [1,1]); gmaxspec = fscanf(fid,'%f', [1,1]); gminspec = fscanf(fid,'%f', [1,1]); gspectsteps = fscanf(fid, '%f', [1,1]); gspectmax = fscanf(fid, '%f', [1,1]); gspectmin = fscanf(fid,'%f', [1,1]); gelpsteps = fscanf(fid, '%f',[l,l]); gelpmax = fscanf(fid, '%f', [1,1]); gelpmin = fscanf(fid, '%f', [1,1]); gtotalsteps = fscanf(fid,'%f', [1,1]); spectchoice = fscanf(fid, '%f', [1,1]); elpchoice = fscanf(fid, '%f', [1,1]); unichoice = fscanf(fid, '%f', [1,1]); status = fclose(fid); load KOMBI kombi=KOMBI; load OBS TObs=OBS; Obs=TObs' ; totalsteps = gspectsteps*gelpsteps*(gmaxspec-gminspec+1); set (ed_STATset_Elpmin, 'String',nunastr(gelpmin»; set(ed_STATset_Elpmax,'String',nunastr(gelpmax»; set (ed_STATset_Elpsteps, 'String',nunastr(gelpsteps»; set (ed_STATset_Spectmin, 'String',nunastr(gspectmin»; set (ed_STATset_Spectmax, 'String',nunastr(gspectmax»; set (ed_STATset_Spectsteps, 'String',nunastr(gspectsteps»; set (ed_STATset_Minspec, 'String',nunastr(gminspec»; set (ed_STATset_Maxspec, 'String',nunastr(gmaxspec»;

389 if elpchoice == 1 teksti= 'Lin' i else teksti= 'Log' i end set(ed_STATset_Elplinlog,'String',teksti)i if spectchoice == 1 teksti= 'Lin' i else teksti:::;: 'Log' ; end set (ed_STATset_Spectlinlog, 'String',teksti)i if unichoice == 1 teksti='Unimod'i else teksti='Polymod'; end set(ed_STATset_Uni, 'String',teksti); end end i f strcmp(gui, 'STATset_loadthem') if action == 1 %global SavedFile %global nofile [filename,pathname] = uigetfile('*.mat', ... 'Choose a MATLAB Data file',sO,sO); nofile=l; if (filename -= 0) savedFile = [pathname filename]; clear filename pathnamei eval(['load ' SavedFile 'i']); nofile=O; end end end i f strcmp(gui, 'STATset_savethem') if action == 1 %global SavedFile [filename,pathname] = uiputfile('*.mat', 'Data Filename', ... sO,50)i if filename -= a SavedFile = [pathname filename]; clear filename pathname; eval(['save ' SavedFile '; ']); end end end i f strcmp (gui, ' STATset-.saveasthem' ) if action == 1 %global SavedFile if (strcmp(SavedFile, "» [filename,pathname] = uiputfile('*.mat', 'Data Filename', ... 50,50); else

390 [filename,pathname] = uiputfile(SavedFile, ... 'Data Filename', ... 50,50); end if filename -= 0 SavedFile = [pathname filename]; clear filename pathname; eval(['save' SavedFile ';']); end end end if strcmp(gui, 'STATset_bye') if action == 1 close (fg_STATset) close (fg_STATrun) end end i f strcmp (gui, 'STATset_Run' ) if action == 0 pb_STATset_Run = uicontrol(fg_STATset, •.. 'Style', 'pushbutton', ... 'Units', 'normalized', 'Position', [0.057 0.000 0.171 0.058], ... 'String', 'Run', 'BackgroundColor', [0.8 0.8 0.8], ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Run' ',1); '); end if action == 1 %global gelpcur %global gspectcur %global gcurspec %global gcurrpt %global gcuriter gelpcur = str2nurn(get(ed_STATset_Elpcurl, 'String'»; if gelpcur == [] gelpcur = 1; end i f gelpcur < 1 gelpcur = 1; set (ed_STATset_Elpcurl, 'String' , num2str (gelpcur) ) ; end if gelpcur > gelpsteps gelpcur = gelpsteps; set (ed_STATset_Elpcurl, 'String',nurn2str(gelpcur»; end if elpchoice == 1 elpvector = linspace(gelpmin/l00,gelpmax/l00,gelpsteps); else elpmi = log10(gelpmin/l00); elpma = log10(gelpmax/l00); elpvector = logspace(elpmi,elpma,gelpsteps); end set(ed_STATset_Elpcur2,'String',nurn2str(100*elpvector(gelpcur»); gspectcur = str2nurn(get(ed_STATset_Spectcul, 'String'»; i f gspectcur == []

391 gspectcur = 1; end if gspectcur < 1 gspectcur = 1; set (ed_STATset_Spectcu1, 'String',numastr(gspectcur»; end if gspectcur > gspectsteps gspectcur = gspectsteps; set (ed_STATset_Spectcu1, 'String',numastr(gspectcur»; end if spectchoice == 1 spectvector = linspace(gspectmin/100, .•. gspectmax/100,gspectsteps); else spectmi = log10(gspectmin/100); spectma = log10(gspectmax/100); spectvector = logspace(spectmi,spectma,gspectsteps); end set (ed_STATset_Spectcu2, 'String',nurrastr(100*spectvector(gspectcur»); gcurspec = str2num(get(ed_STATset_Curspec, 'String'»; i f gcurspec == [] gcurspec = gminspeci end if gcurspec < gminspec gcurspec = gminspec; end if gcurspec > gmaxspec gcurspec = gmaxspec; end gcurrpt = s tr2num (get (ed_STATset_Currpt, 'String'»; i f gcurrpt == [] gcurrpt = 1; end i f gcurrpt <= 0 gcurrpt = 1; end set(ed_STATset_Currpt,'String',num2str(gcurrpt»; gcuriter = str2num(get(ed_STATset_Curiter, 'String'»; if gcuriter == [] gcuriter = 20; end i f gcuriter < 2 gcuriter = 2; end set (ed_STATset_Curiter, 'String',num2str(gcuriter»; fid = fopen( 'CURRENT2 . TXT , , 'w'); fprintf(fid, '%8.5f \n' ,gelpcur); fprintf(fid, '%8.5f \n',gspectcur); fprintf(fid, '%8.5f \n',gcurspec); fprintf (fid, '%8. 5f \n', gcurrpt) ; fprintf(fid, '%8.5f \n' ,gcuriter); status = fclose(fid); figure (fg_STATrun)

392 page = 2; zzzdar2('STATrun', 'STATrun_Execute',l); end end

if strcmp (gui, 'STATset_Save_s' ) if action == 1 [filename, path]=uiputfile('SSS.mat', 'Save spectra file:'); pit=length(filename); if filename -= 0 pit=length(filename); vari= filename; i f pit> 4 vari=filename(1:pit-4); end

zapu=[vari, , = SSS;']; eval(zapu) rapu= [ 'save " vari,' , eval(rapu)

vari] ;

end

end end i f strcmp (gui, 'STATset_Load_Defaul t ' ) if action == 0 pb_STATset_Loa~Default = uicontrol(fg_STATset, ... 'Style', 'pushbutton', ... 'Units', 'normalized', 'Position', [0.529 0.000 0.171 0.058], .. . 'String', 'Load_Default', 'BackgroundColor', [0.8 0.8 0.8], .. . 'CallBack', 'zzzdar2(' 'STATset' 'r' 'STATset_Load_Default' ',1);'); end if action == 1 gelpcur = 1; set (ed_STATset_Elpcurl, 'String' ,num2str(gelpcur»; set
gcurspec = gminspec; set(ed_STATset_curspec, 'String',num2str(gcurspec»; gcurrpt = 1; set(ed_STATset_CUrrpt,'String',num2str(gcurrpt»; gcuriter = 20; set (ed_STATset_curiter, 'String',num2str(gcuriter»; end end if strcmp(gui, 'STATset_Help') if action == 0 pb_STATset_Help = uicontrol(fg_STATset, ... 'Style', 'pushbutton', ... 'Units', 'normalized', 'Position', [0.771 0.000 0.171 0.058], ... 'String', 'Help','BackgroundColor', [0.8 0.8 0.8], ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Help' ',1);'); end if action == 1

393 help helpdar2; end end if strcnp(gui, 'STATset_Paramheader') if action == 0 tx_STATset_Paramheader = uicontrol(fg_STATset, ... 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], ... 'ForegroundC', [1 1 1], .•. 'Units', 'normalized', 'Position', [0.143 0.904 0.286 0.038], ... 'String', 'Parameters for Analysis', •.. 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Paramheader' ',1);'); end end

if strcnp (gui, 'STATset_SUbsetheader') if action == 0 tx_STATset_SUbsetheader = uicontrol(fg_STATset, ... 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], ..• 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'position', [0.629 0.904 0.200 0.038], ... 'String', 'Selected Subset', ... 'CallBack','zzzdar2(' 'STATset' ',' 'STATset_SUbsetheader' ',1);'); end end if strcnp(gui, 'STATset_Elprof') if action == 0 tx_STATset_Elprof = uicontrol(fg_STATset, .. . 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], .. . 'ForegroundC', [1 1 1], ..• 'Units', 'normalized', 'Position', [0.071 0.846 0.271 0.038], •.. 'String', 'Elution Curve Baseline', ..• 'CallBack' , 'zzzdar2 ( , 'STATset' , , , 'STATset_Elprof' , , 1) ; , ) ; end end if strcnp(gui, 'STATset_Uni') if action == 0 ed_STATset_Uni = uicontrol(fg_STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], •.. 'Units', 'normalized', 'Position', [0.100 0.769 0.100 0.058], ... 'String',", ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Uni",l);'); end end if strcnp(gui, 'STATset_Elpmin') if action == 0 ed_STATset_Elpmin = uicontrol(fg_STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], .•. 'Units', 'normalized', 'Position', [0.214 0.769 0.086 0.058], .•. 'String' , , " ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Elpmin",l); '); end end i f strcnp(gui, 'STATset_Elpmintx') if action == 0 ~STATset_Elpmintx = uicontrol(fg_STATset, ...

394

'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], ... 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'Position', [0.314 0.769 0.157 0.058], ... 'String', 'Minimum %', ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Elpmintx' ',1);'); end end i f strcnp (gui, 'STATset_Elpcurtx1' ) if action == 0 tx_STATset~lpcurtx1 = uicontrol(fg_STATset, .. . 'Style', 'text','BackgroundC', [0.5 0.5 0.5], .. . 'ForegroundC', [11 1], ... 'Units', 'normalized', 'Position', [0.557 0.673 0.171 0.154], ... 'String', 'Selected step for elution curve baseline', ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Elpcurtx1' ',1);'); end end i f strcnp (gui, 'STATset_Elpcur1' ) if action == 0 ed_STATset_Elpcur1 = uicontrol(fg_STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'position', [0.743 0.769 0.100 0.058], ... 'String',", ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset~lpcur1' ',1);'); end end i f strcnp (gui, 'STATset_Elpmax' ) if action == 0 ed_STATset_Elpmax = uicontrol(fg_STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.214 0.692 0.086 0.058], ... 'String',", ..• 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Elpmax' ',1); ,); end end if strcnp(gui, 'STATset_Elpmaxtx') if action == 0 tx_STATset_Elpmaxtx = uicontrol(fg_STATset, .. . 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], .. . 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'position', [0.314 0.692 0.157 0.058], ... 'String', 'Maximum %', ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Elpmaxtx' ',1);'); end end if strcnp(gui, 'STATset_Elpcur2') if action == 0 ed_STATset_Elpcur2 = uicontrol(fg_STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'position', [0.743 0.692 0.100 0.058], ... , String' 'CallBack' , 'zzzdar2 ( , 'STATset' , , , 'STATset_Elpcur2' , , 1) ; , ) ; end end I

'

, ,

•••

395 if strcmp(gui, 'STATset_Elpcurtx2') if action == 0 tx_STATset_Elpcurtx2 = uicontrol(fg_STATset, .. . 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], .. . 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'position', [0.857 0.692 0.057 0.058], ... , String' , ' (%) , , ••• 'CallBack' , 'zzzdar2 ( , 'STATset' , , ' 'STATset_Elpcurtx2 ' , , 1) ; , ) ; end end i f strcmp(gui, 'STATset_Elplinlog') if action == 0 ed_STATset_Elplinlog = uicontro1(fg_STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.100 0.615 0.100 0.058], ... 'String',", ... 'CallBack' , 'zzzdar2 ( , 'STATset' , , ' 'STATset_Elplinlog' , , 1) ; , ) ; end end i f strcmp (gui, 'STATset_Elpsteps' ) if action == 0 ed_STATset_E1psteps = uicontrol(fg_STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.214 0.615 0.086 0.058], ... 'String',", ... 'CallBack', 'zzzdar2(' 'STATset",' 'STATset_Elpsteps' ',1);'); end end if strcmp(gui, 'STATset_Elpstepstx') if action == 0 tx_STATset_Elpstepstx = uicontrol(fg_STATset, .. . 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], .. . 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'Position', [0.314 0.615 0.157 0.058], ... 'String', 'No. of steps', ... 'CallBack', 'zzzdar2(' 'STATset",' 'STATset_Elpstepstx' ',1);'); end end i f strcmp (gui, 'STATset_Spectcurtx1 ' ) if action == 0 tx_STATset_Spectcurtx1 = uicontrol(fg_STATset, ... 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], .•. 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'Position', [0.557 0.481 0.171 0.154], ... 'String', 'Selected step for spectral baseline', ... 'CallBack', 'zzzdar2(' 'STATset",' 'STATset_Spectcurtx1' ',1);'); end end if strcmp(gui, 'STATset_Spectcu1') if action == 0 ed_STATset_Spectcu1 = uicontrol(fg_STATset, .•. 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.743 0.577 0.100 0.058], ... , String' , ' , , ...

396

'CallBack', 'zzzdar2(' 'STATset", "STATset_Spectcul' ',1);'); end end if strCllll (gui, 'STATset_Spectconst' ) if action == 0 tx_STATset_Spectconst = uicontrol(fg_STATset, .. . 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], .. . 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'Position', [0.100 0.538 0.243 0.038], ... 'String', 'Spectral Baseline', •.. 'CallBack', 'zzzdar2("STATset' ',' 'STATset_Spectconst' ',1);'); end end i f strCllll(gui, 'STATset_Spectcu2') if action == 0 ed_STATset_Spectcu2 = uicontrol(f~STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'position', [0.743 0.500 0.100 0.058], .•. 'String', , " ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Spectcu2' ',1);'); end end if strCllll(gui, 'STATset_Spectcurtx2') if action == 0 tx_STATset_Spectcurtx2 = uicontrol(fg_STATset, ... 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], ... 'ForegroundC', [1 1 1], ••• 'Units', 'normalized', 'position', [0.857 0.500 0.057 0.058], ... 'String', , (%) " ••• 'CallBack', 'zzzdar2("STATset' ',' 'STATset_Spectcurtx2' ',1); '); end end i f strCllll (gui, 'STATset_Spectmin' ) if action == 0 ed_STATset_Spectmin = uicontrol(f~STATset, •.. 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.214 0.462 0.086 0.058], ... , String' , , , , •.. 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Spectmin' ',1);'); end end if strCllll(gui, 'STATset_Spectmintx') if action == 0 tx_STATset_Spectmintx = uicontrol(f~STATset, ... 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], •.. 'ForegroundC', [1 1 1], .•• 'Units', 'normalized', 'Position', [0.314 0.462 0.157 0.058], ... 'String', 'Minimum %', ... 'CallBack', 'zzzdar2("STATset' ',' 'STATset_Spectmintx' ',1);'); end end if strCllll(gui, 'STATset_Spectmax') if action == 0 ed_STATset_Spectmax = uicontrol(fg_STATset, ...

397 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], •.. 'Units', 'normalized', 'Position', [0.214 0.385 0.086 0.058], ... , String' , , , , ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Spectmax' ',1);'); end end i f strcmp(gui, 'STATset_Spectmaxtx') if action == 0 tx_STATset_Spectmaxtx = uicontrol(fg_STATset, ..• 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], ... 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'Position', [0.314 0.385 0.157 0.058], ... 'String', 'Maximum %', ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Spectmaxtx' ',1);'); end end if strcmp(gui, 'STATset_CUrspectx') if action == 0 tx_STATset_CUrspectx = uicontrol(fg_STATset, .. . 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], .. . 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'Position', [0.557 0.308 0.171 0.096], ... 'String', 'Number of species', ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_CUrspectx' ',1); '); end end if strcmp(gui,' STATset_CUrspec') if action == 0 ed_STATset_CUrspec = uicontrol(fg_STATset, ..• 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.743 0.346 0.100 0.OS8}, ... 'String', , , , ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_CUrspec' ',1);'); end end if strcmp(gui, 'STATset_Spectlinlog') if action == 0 ed_STATset_Spectl.inlog = uicontrol (fg_STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.100 0.308 0.100 0.058], ... 'String', , , , ... 'CallBack', 'zzzdar2(' 'STATset' " "STATset_Spectlinlog",l); '); end end i f strcmp (gui, 'STATset_Spectsteps' ) if action == 0 ed_STATset_Spectsteps = uicontrol(fg_STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'position', [0.214 0.308 0.086 0.058], ... 'String', ", ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Spectsteps' ',1); '); end end i f strcmp(gui, 'STATset_Spectstepstx')

398 if action == 0 tx_STATset_Spectstepstx = uicontrol(fg_STATset, '" 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], ... 'ForegroundC', [1 1 1], .•. 'Units', 'normalized', 'Position', [0.314 0.308 0.157 0.058], ... 'String', 'No. of steps', ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Spectstepstx' ',l)i')i end end i f strcmp (gui, 'STATset_Currpttx' ) if action == 0 tx_STATset_Currpttx = uicontrol(fg_STATset, .. . 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], .. . 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'Position', [0.557 0.192 0.171 0.096], ... 'String', 'Number of repeats', ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Currpttx' ',l)i')i end end i f strcmp(gui, 'STATset_Currpt') if action == 0 ed_STATset_Currpt = uicontrol(fg_STATset, .•• 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'position', [0.743 0.231 0.100 0.058], ..• 'String', ", ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Currpt' ',l)i ')i end end i f strcmp (gui, 'STATset_Species') if action == 0 tx_STATset_Species = uicontrol(fg_STATset, .. . 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], .. . 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'Position', [0.100 0.231 0.243 0.038], ... 'String', 'Number of Species', ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Species' ',l)i'); end end i f strcmp(gui, 'STATset_Minspec') if action == 0 ed_STATset_Minspec = uicontrol(f9-STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.214 0.154 0.086 0.058], ... , String' , , , , •.. 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Minspec' ',1);'); end end if strcmp(gui, 'STATset_Minspectx') if action == 0 tx_STATset_Minspectx = uicontrol(fg_STATset, .. . 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], .. . 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'Position', [0.314 0.154 0.157 0.058], ... 'String', 'Minimum', ...

399 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Minspectx' ',1); '); end end if strcmp(gui, 'STATset_CUritertx') if action == 0 tx_STATset_CUritertx = uicontrol(fg_STATset, ... 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], .•. 'ForegroundC', [1 1 1], ... 'Units', 'normalized', 'Position', [0.557 0.077 0.171 0.096], ... 'String', 'Number of AR iterations', ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_CUritertx' ',1); '); end end i f strcmp (gui, 'STATset_CUri ter ' ) if action == 0 ed_STATset_CUriter = uicontrol(fg_STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.743 0.115 0.100 0.058], ... , String' , , , , ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_CUriter' ',1);'); end end i f strcmp (gui, 'STATset_Maxspec')

if action == 0 ed_STATset_Maxspec = uicontrol(fg_STATset, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.214 0.077 0.086 0.058], •.. 'String',", ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Maxspec' ',1);'); end end if strcmp(gui, 'STATset_Maxspectx') if action == 0 tx_STATset_Maxspectx = uicontrol(fg_STATset, .. . 'Style', 'text', 'BackgroundC', [0.5 0.5 0.5], .. . 'ForegroundC', [1 1 1], •.. 'Units', 'normalized', 'Position', [0.314 0.077 0.157 0.058], ... 'String', 'Maximum', ... 'CallBack', 'zzzdar2(' 'STATset' ',' 'STATset_Maxspectx' ',1);'); end end end if strcmp(page, 'STATrun') figure (fg_STATrun) set (gcf, 'NUmberTitle', 'off', 'Name', 'STATrun', ... 'backingstore', 'off'); if strcmp(gui,'initgui') zzzdar2 ( , STATrun' , 'STATrun..)mNU1' , 0) ; zzzdar2 ( , STATrun' , 'STATrun_Menu2' , 0) ; zzzdar2('STATrun', 'STATrun_Back',O); zzzdar2('STATrun', 'STATrun_Stepct',O)i zzzdar2('STATrun', 'STATrun_Help',O)i zzzdar2('STATrun', 'STATrun_Boot',l)i

400

end i f strcmp (gui, 'STATrun_MENU1' ) if action == 0 mn_STATrun_Files = uirnenu(fg_STATrun, ... 'Label', 'Files'); mi_STATrun_Save = uimenu (mn_STATrun_Files, ... 'Label', 'save', ... 'CallBack', 'zzzdar2(' 'STATrun",' 'STATrun_savethem' ',1); '); mi_STATrun_save_as = uimenu (mn_STATrun_Files, .•. 'Label', 'save_as', ... 'CallBack', 'zzzdar2(' 'STATrun' ',' 'STATrun_saveasthem' ',1);'); mi_STATrun_Save_spectra = uimenu (mn_STATrun_Files, ... 'Label' , 'save_spectra' , .•. 'CallBack', 'zzzdar2(' 'STATrun' ',' 'STATrun_Save_s' ',1);'); mi_STATrun_Save_curves = uirnenu (mn_STATrun_Files, ... 'Label', 'Save_curves', ... 'CallBack', 'zzzdar2(' 'STATrun' ',' 'STATrun_Save_c",l);'); mi_STATrun_Qui t = uimenu (mn_STATrun_Files, ... 'Label', 'Quit', ... 'CallBack','zzzdar2(' 'STATrun' ',' 'STATrun_h¥e' ',1);'); end end if strcmp (gui, 'STATrun_Menu2 ' ) if action == 0 mn_STATrun_GOTO = uimenu(fg_STATrun, ... 'Label' , 'GOTO') ; mi_STATrun_Back = uimenu (mn_STATrun_GOTO, .•. 'Label', 'Back', ... 'CallBack', 'zzzdar2(' 'STATrun' ',' 'STATrun_setthem' ',1);'); mi_STATrun_Help = uimenu (mn_STATrun_GOTO, ... 'Label', 'Help', ... 'CallBack', 'zzzdar2(' 'STATrun' ',' 'STATrun_Help' ',1);'); end end if strcmp (gui, 'STATrun_setthem' ) if action == 1 figure (fg_STATset) page = 1; end end i f strcmp(gui, 'STATrun_runthem') if action == 1 figure (fg_STATrun) page = 2; end end i f strcmp(gui, 'STATrun_Back') if action == 0 pb_STATrun_Back = uicontrol (fg_STATrun, ... 'Style', 'pushbutton', ... 'units', 'normalized', 'Position', [0.000 0.000 0.186 0.058], ... 'String', 'Back', 'BackgroundColor', [0.8 0.8 0.8], ... 'CallBack', 'zzzdar2(' 'STATrun' ',' 'STATrun_Back' ',1);'); end

401 if action == 1 plot (1, 'k' ) axis ( 'off') figure (fg_STATset) page = 1; end end i f strCl'!l' (gui, 'STATrun_bye') if action == 1 close (fg_STATset) close (fg_STATrun) end end i f strCl'!l' (gui, 'STATrun_savethem' ) if action == 1 %global SavedFile [filename,pathname] = uiputfile('*.mat','Data Filename', ... 50,50); if filename -= 0 SavedFile = [pathname filename]; clear filename pathname; eval(['save ' SavedFile ';']); end end end if strCl'!l' (gui, 'STATrun_saveasthem') if action == 1 %global SavedFile if (strCl'!l'(SavedFile,' '» [filename,pathname] = uiputfile('*.mat','Data Filename', ... 50,50); else [filename,pathname] = uiputfile(SavedFile, ... 'Data Filename', ... 50,50); end if filename -= 0 savedFile = [pathname filename]; clear filename pathname; eval(['save' SavedFile ';']); end end end i f strCl'!l'(gui, 'STATrun_Execute') if action == 1 %global grptct %global gminspec %globalgmaxspec %global gmaxiter %global gspectmax %global gspectmin %global gspectsteps %global gelpsteps %global gelpmin

%global gelpmax %global stepcount %global S %global C load OBS TObs=OBS; Obs=TObs'; kount=O: [nk, mk] = size(kombi): totalsteps = gspectsteps*gelpsteps*(gmaxspecgminspec+l)*gcurrpt; SVF=zeros(l,l): SFF=zeros(l,l): tstp = gtotalsteps * grptct; fprintf('\n*** AutaAR/Statistics ***\n\n') fprintf('Max iterations: %3.0f Repeats: %3.0f sets:%3.0f\n', ... gmaxiter,grptct,tstp) if elpchoice == 1 fprintf('Elution curve baseline: %7.6f - %7.6f Lin steps:%4.0f\n', ... gelpmin/100,gelpmax/100,gelpsteps) else fprintf('Elution curve baseline: %7.6f - %7.6f Log steps:%4.0f\n', ... gelpmin/100,gelpmax/100,gelpsteps) ~d . if spectchoice == 1 fprintf('Spectral baseline: %7.6f - %7.6f Lin steps:%4.0f\n', ... gspectmin/100,gspectmax/100,gspectsteps) else fprintf('Spectral baseline: %7.6f - %7.6f Log steps:%4.0f\n', ... gspectmin/100,gspectmax/100,gspectsteps)

Total

~d

fprintf('No. of species: %2.0f -%2.0f\n\n',gminspec,gmaxspec) if elpchoice == 1 elpvector = linspace(gelpmin/100,gelpmax/100,gelpsteps); else elpmi = loglO(gelpmin/100); elpma = loglO(gelpmax/100)i elpvector = logspace(elpmi,elpma,gelpsteps); end

elp = elpvector(gelpcur); if spectchoice == 1 spectvector = linspace(gspectmin/100, ... gspectmax/100,gspectsteps); else spectmi = loglO(gspectmin/100); spectma = loglO(gspectmax/100); spectvector = logspace(spectmi,spectma,gspectsteps); ~d

spect = spectvector(gspectcur)i

403

siemen = 0; siemen2 = 0; fprintf ( , Selection: \n \n ' ) for ii = l:nk wnspec = kombi(ii,l); welp = kombi(ii,2); wspect = kombi(ii,3); wAF = kombi(ii,4); WSF = kombi(ii,5); wsiemen = kombi(ii,6)i wsiemen2 = kombi(ii,7); It = 0.00000001; if wnspec == gcurspec if abs(welp-elp) < It if abs(wspect-spect) < It siemen = wsiemen; siemen2 = wsiemen2 i end end end end%ii figure (fg_STATrun) stepcount = 0; iteration fit' ) disp('setel.curve spectral no. of %' ) disp('count baseline baseline species per level rand ( , seed' , siemen) ; randn( 'seed' ,siemen2); nspec = gcurspec; F=zeros(gcurrpt,l); TT=zeros(l,nspec)i TTT=zeros(gcurrpt,nspec)i [nlines, nscans]=size(Obs)i total=norm(Obs, 'fro'); for rr = l:gcurrpt S=rand(nlines,nspec)i bestfit=9999999i for iter=l:gcuriter S = (S> zeros(size(S»).*S; S = S+O.OOOOOOOOOOl*abs(randn(size(S»); for j=l:nspec S(l:nlines,j)=S(l:nlines,j)/sum(S(l:nlines,j»; end if iter == gcuriter P1=S*C; D1 = Obs-P1; diff = 100*norm(Dl,'fro')/total; stepcount = stepcount+1; fprintf('%5.0f %7.6f %7.6f %4.0f %4.0f %5.3f\n', ... stepcount,elp,spect,nspec,iter,diff) set(ed_STATrun_Stepct,'String',num2str(stepcount»; end C1 = pinv (S) ; C = C1*Obs; %solve concentrations

404

C = (C> zeros(size(C»).*Ci C = C + O.OOOOOOOOOOl*abs(randn(size(C»)i for j=l:nspec i f unichoice == 1 % Make monotonic temp=C(j,l:nscans); [arvo paikka] =max (temp) ; templs=sort(temp(l:paikka»i temprs=sort(temp(paikka:nscans»; C(j,l:nscans)=[templs temprs«nscans-paikka):-l:l)]; end

W=C(j,l:nscans)i wbig = max (W) ; wsmall = min (W) ; wlimit = wbig*elp; if wsmall < wlimit ero = wlimit-wsmalli W=W+eroi end

C(j,l:nscans) = W; end %j

% Last iteration: show & save results if iter == gcuriter if unichoice == 1 [WWW, KKK] = max(C'); [LLL,MMM]=sort(KKK); C = C (MMM, : ) i S = S ( : , MMM) ; else TT=sum(C' ) i [WWW, KKK] = sort (TT) i C = C(KKK,:); S = S (: ,KKK) i end

plot(C' ) title(['AR iteration #',num2str(iter), , num2str(diff)] ) xlabel ( 'Scan number') drawnow kount=kount+l; SSS(:,kount)=S(:)i CE=C' ; CCC(:,kount)=CE(:); end

G = pinv(C'); ST = G*TObs; ST = (ST> zeros(size(ST»).*STi ST = ST + O.OOOOOOOOOOl*abs(randn(size(ST»)i for j=l :nspec W=ST(j,l:nlines)i whig = max (W) ; wsmall = min (W) ; wlimit = wbig*specti i f wsmall < wlimit

Fit=',

405

ero = wlimit-wsmall; W=W+ero; end ST(j,l:nlines) = W; end %j S

= ST'

j

end %iter F(rr)=diff; 'l'T=sum (C ' ) ; TTT(rr, :)='l'Tj end %rr if gcurrpt == 1 W

= 0;

else W = std (TTT) ; end MM = mean(TTT); SVF(1)=100*sum(W)/sum(MM); SFF(l) =mean (F) ; fprintf ( , \nScatter: \n') fprintf('%6.4f %6.4f %6.4f %6.4f %6.4f %6.4f\n',SVF) fprintf ( , \nFit: \n' ) fprintf('%6.4f %6.4f %6.4f %6.4f %6.4f %6.4f\n',SFF) fprintf ( , \n' ) save SSS SSS save CCC CCC end end if strcnp(gui, 'STATrun_Help') if action == 0 pb_STATrun_Help = uicontrol(fg_STATrun, ... 'Style', 'pushbutton', ... 'Units', 'normalized', 'Position', [0.814 0.000 0.098 0.058], ... 'String', 'Help', 'BackgroundColor', [0.8 0.8 0.8], ... 'CallBack', 'zzzdar2(' 'STATrun' ',' 'STATrun_Help' ',1);'); end if action == 1 help helpdar2; end end if strcnp (gui, 'STATrun_Save_s' ) if action == 1 [filename, path]=uiputfile('SSS.mat','Save spectra file:'); pit=length(filename)j i f filename -= 0 pit=length(filename)j vari=filename; i f pit> 4 vari=filename(1:pit-4); end zapu=[vari, , = SSS;']; eval(zapu) rapu= [ 'save " vari,' , vari]; eval(rapu)

406 end end end if strcmp(gui, 'STATrun_Save_c') if action == 1 [filename, path]=uiputfile('CCC.mat', ... 'Save elution curves file:'); pit=length(filename); if filename -= 0 pit=length(filename); vari=filename ; i f pit> 4 vari=filename(1:pit-4); end zapu=[vari, , = cec;']; eval(zapu) rapu= [ 'save " vari,' , vari] ; eval(rapu) end end end if strcmp(gui, 'STATrun_Stepct') if action == 0 ed_STATrun_Stepct = uicontrol(fg_STATrun, ... 'Style', 'edit', 'BackgroundColor', [0.50 0.50 0.50], ... 'Units', 'normalized', 'Position', [0.686 0.000 0.100 0.058], ... 'String',' ', ... 'CallBack', 'zzzdar2(' 'STATrun' ',' 'STATrun_Stepct' ',1); '); end . end

end % iiiii End of program iiiii