tomwalters@0: % procedure for 'aim-mat' tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % tomwalters@0: % tomwalters@0: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org bleeck@3: tomwalters@0: tomwalters@0: tomwalters@0: function handles=do_aim_updateparameters(handles) tomwalters@0: % return the pointer shape tomwalters@0: if handles.with_graphic==1 tomwalters@0: set(handles.figure1,'Pointer','watch'); tomwalters@0: wbh=waitbar(0,'Updating Parameters... Please Wait'); tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: % set the checkboxes according to the changes in the parameterfile. If tomwalters@0: % changes have occured from the parameterfile relativ to the options in tomwalters@0: % handles, the associated checkbox is checked. A further call to tomwalters@0: % aim_calculate then does the rest tomwalters@0: tomwalters@0: oldoptions=handles.all_options; tomwalters@0: parfile=handles.info.parameterfilename; tomwalters@0: tomwalters@0: olddir=pwd; tomwalters@0: [pathstr,name,ext] = fileparts(parfile); tomwalters@0: cd(pathstr); tomwalters@0: eval(name); % here it is evaluated tomwalters@0: cd(olddir); tomwalters@0: if handles.with_graphic==1 tomwalters@0: waitbar(0.2,wbh); tomwalters@0: end tomwalters@0: % tomwalters@0: % wo=strfind(parfile,'.m'); tomwalters@0: % if ~isempty(wo) tomwalters@0: % parfile=parfile(1:wo-1); tomwalters@0: % end tomwalters@0: % tomwalters@0: % [a,b,c]=fileparts(parfile); tomwalters@0: % cd(a); tomwalters@0: % parfile=parfile(strfind(parfile,'/')+1:end); tomwalters@0: % eval(parfile); tomwalters@0: % cd .. tomwalters@0: newoptions=all_options; tomwalters@0: tomwalters@0: % compare the old and the new parameters to see, what must be changed tomwalters@0: if ~structisequal(oldoptions.pcp,newoptions.pcp) tomwalters@0: set(handles.checkbox0,'Value',1); tomwalters@0: handles.info.calculate_pcp=1; tomwalters@0: else tomwalters@0: set(handles.checkbox0,'Value',0); tomwalters@0: handles.info.calculate_pcp=0; tomwalters@0: end tomwalters@0: if handles.with_graphic==1 tomwalters@0: waitbar(0.3,wbh); tomwalters@0: end tomwalters@0: if ~structisequal(oldoptions.bmm,newoptions.bmm) tomwalters@0: set(handles.checkbox1,'Value',1); tomwalters@0: handles.info.calculate_bmm=1; tomwalters@0: else tomwalters@0: set(handles.checkbox1,'Value',0); tomwalters@0: handles.info.calculate_bmm=0; tomwalters@0: end tomwalters@0: if handles.with_graphic==1 tomwalters@0: waitbar(0.4,wbh); tomwalters@0: end tomwalters@0: if ~structisequal(oldoptions.nap,newoptions.nap) tomwalters@0: set(handles.checkbox2,'Value',1); tomwalters@0: handles.info.calculate_nap=1; tomwalters@0: else tomwalters@0: set(handles.checkbox2,'Value',0); tomwalters@0: handles.info.calculate_nap=0; tomwalters@0: end tomwalters@0: if handles.with_graphic==1 tomwalters@0: waitbar(0.5,wbh); tomwalters@0: end tomwalters@0: if ~structisequal(oldoptions.strobes,newoptions.strobes) tomwalters@0: set(handles.checkbox3,'Value',1); tomwalters@0: handles.info.calculate_strobes=1; tomwalters@0: else tomwalters@0: set(handles.checkbox3,'Value',0); tomwalters@0: handles.info.calculate_strobes=0; tomwalters@0: end tomwalters@0: if handles.with_graphic==1 tomwalters@0: waitbar(0.6,wbh); tomwalters@0: end tomwalters@0: if ~structisequal(oldoptions.sai,newoptions.sai) tomwalters@0: set(handles.checkbox4,'Value',1); tomwalters@0: handles.info.calculate_sai=1; tomwalters@0: else tomwalters@0: set(handles.checkbox4,'Value',0); tomwalters@0: handles.info.calculate_sai=0; tomwalters@0: end tomwalters@0: if handles.with_graphic==1 tomwalters@0: waitbar(0.7,wbh); tomwalters@0: end tomwalters@0: if ~structisequal(oldoptions.usermodule,newoptions.usermodule) tomwalters@0: set(handles.checkbox8,'Value',1); tomwalters@0: handles.info.calculate_usermodule=1; tomwalters@0: else tomwalters@0: set(handles.checkbox8,'Value',0); tomwalters@0: handles.info.calculate_usermodule=0; tomwalters@0: end tomwalters@0: % if ~structisequal(oldoptions.movie,newoptions.movie) tomwalters@0: % set(handles.checkbox5,'Value',1); tomwalters@0: % handles.info.calculate_movie=1; tomwalters@0: % else tomwalters@0: % set(handles.checkbox5,'Value',0); tomwalters@0: % handles.info.calculate_movie=0; tomwalters@0: % end tomwalters@0: tomwalters@0: if handles.with_graphic==1 tomwalters@0: waitbar(0.8,wbh); tomwalters@0: end tomwalters@0: % check, if the signal time has changed, if, redo everything! tomwalters@0: changesig=0; tomwalters@0: if oldoptions.signal.start_time~=newoptions.signal.start_time tomwalters@0: changesig=1; tomwalters@0: end tomwalters@0: if oldoptions.signal.duration~=newoptions.signal.duration tomwalters@0: changesig=1; tomwalters@0: end tomwalters@0: if oldoptions.signal.samplerate~=newoptions.signal.samplerate tomwalters@0: changesig=1; tomwalters@0: end tomwalters@0: tomwalters@0: % if ~structisequal(oldoptions.signal,newoptions.signal) tomwalters@0: if changesig==1 tomwalters@0: new_duration=newoptions.signal.duration; tomwalters@0: new_start_time=newoptions.signal.start_time; tomwalters@0: new_sr=newoptions.signal.samplerate; tomwalters@0: tomwalters@0: % if new_start_time+new_duration>handles.all_options.signal.original_duration tomwalters@0: % error('fehler in do_aim_updateparameters '); tomwalters@0: % end tomwalters@0: tomwalters@0: tomwalters@0: if handles.info.pcp_loaded==1 tomwalters@0: set(handles.checkbox0,'Value',1); tomwalters@0: handles.info.calculate_pcp=1; tomwalters@0: end tomwalters@0: if handles.info.bmm_loaded==1 tomwalters@0: set(handles.checkbox1,'Value',1); tomwalters@0: handles.info.calculate_bmm=1; tomwalters@0: end tomwalters@0: if handles.info.nap_loaded==1 tomwalters@0: set(handles.checkbox2,'Value',1); tomwalters@0: handles.info.calculate_nap=1; tomwalters@0: end tomwalters@0: if handles.info.strobes_loaded==1 tomwalters@0: set(handles.checkbox3,'Value',1); tomwalters@0: handles.info.calculate_strobes=1; tomwalters@0: end tomwalters@0: if handles.info.sai_loaded==1 tomwalters@0: set(handles.checkbox4,'Value',1); tomwalters@0: handles.info.calculate_sai=1; tomwalters@0: end tomwalters@0: if handles.info.usermodule_loaded==1 tomwalters@0: set(handles.checkbox8,'Value',1); tomwalters@0: handles.info.calculate_usermodule=1; tomwalters@0: end tomwalters@0: if handles.info.movie_loaded==1 tomwalters@0: set(handles.checkbox5,'Value',1); tomwalters@0: handles.info.calculate_movie=1; tomwalters@0: end tomwalters@0: handles.info.calculate_signal=1; tomwalters@0: tomwalters@0: tomwalters@0: % change the slider etc... tomwalters@0: if new_duration>1 tomwalters@0: set(handles.displayduration,'String',num2str(fround(new_duration,2))); tomwalters@0: set(handles.text20,'String','sec'); tomwalters@0: else tomwalters@0: set(handles.displayduration,'String',num2str(fround(new_duration*1000,0))); tomwalters@0: set(handles.text20,'String','ms'); tomwalters@0: end tomwalters@0: % samplerate tomwalters@0: set(handles.text25,'String',num2str(fround(new_sr/1000,1))); tomwalters@0: % offset tomwalters@0: if new_start_time>0 tomwalters@0: set(handles.text29,'String',num2str(fround(new_start_time*1000,1))); tomwalters@0: set(handles.text29,'Visible','on'); tomwalters@0: set(handles.text30,'Visible','on'); tomwalters@0: else tomwalters@0: set(handles.text29,'Visible','off'); tomwalters@0: set(handles.text30,'Visible','off'); tomwalters@0: end tomwalters@0: handles.slideredit_start.minvalue=new_start_time; tomwalters@0: handles.slideredit_start.maxvalue=new_start_time+new_duration-0.04; tomwalters@0: handles.slideredit_start=slidereditcontrol_set_value(handles.slideredit_start,new_start_time); tomwalters@0: handles.slideredit_start=slidereditcontrol_set_range(handles.slideredit_start,new_duration/10); tomwalters@0: tomwalters@0: handles.slideredit_duration=slidereditcontrol_set_value(handles.slideredit_duration,0.04); tomwalters@0: handles.slideredit_duration.maxvalue=new_duration; tomwalters@0: handles.slideredit_duration=slidereditcontrol_set_range(handles.slideredit_duration,new_duration/10); tomwalters@0: tomwalters@0: handles.currentslidereditcombi=handles.slideredit_start; tomwalters@0: tomwalters@0: else tomwalters@0: handles.info.calculate_signal=0; tomwalters@0: end tomwalters@0: tomwalters@0: if handles.with_graphic==1 tomwalters@0: waitbar(0.9,wbh); tomwalters@0: end tomwalters@0: % set the current info in handles to the current values tomwalters@0: generating_module_string=get(handles.listbox0,'String'); tomwalters@0: generating_module=generating_module_string(get(handles.listbox0,'Value')); tomwalters@0: if ~isfield(handles.info,'current_pcp_module') || ~strcmp(handles.info.current_pcp_module,generating_module{1}) tomwalters@0: handles.info.calculate_pcp=1; tomwalters@0: set(handles.checkbox0,'Value',1); tomwalters@0: end tomwalters@0: handles.info.current_pcp_module=generating_module{1}; tomwalters@0: tomwalters@0: generating_module_string=get(handles.listbox1,'String'); tomwalters@0: generating_module=generating_module_string(get(handles.listbox1,'Value')); tomwalters@0: if ~isfield(handles.info,'current_bmm_module') || ~strcmp(handles.info.current_bmm_module,generating_module{1}) tomwalters@0: handles.info.calculate_bmm=1; tomwalters@0: set(handles.checkbox1,'Value',1); tomwalters@0: end tomwalters@0: handles.info.current_bmm_module=generating_module{1}; tomwalters@0: tomwalters@0: generating_module_string=get(handles.listbox2,'String'); tomwalters@0: generating_module=generating_module_string(get(handles.listbox2,'Value')); tomwalters@0: if ~isfield(handles.info,'current_nap_module') || ~strcmp(handles.info.current_nap_module,generating_module{1}) tomwalters@0: handles.info.calculate_nap=1; tomwalters@0: set(handles.checkbox2,'Value',1); tomwalters@0: end tomwalters@0: handles.info.current_nap_module=generating_module{1}; tomwalters@0: tomwalters@0: generating_module_string=get(handles.listbox3,'String'); tomwalters@0: generating_module=generating_module_string(get(handles.listbox3,'Value')); tomwalters@0: if ~isfield(handles.info,'current_strobes_module') || ~strcmp(handles.info.current_strobes_module,generating_module{1}) tomwalters@0: handles.info.calculate_strobes=1; tomwalters@0: set(handles.checkbox3,'Value',1); tomwalters@0: end tomwalters@0: handles.info.current_strobes_module=generating_module{1}; tomwalters@0: tomwalters@0: generating_module_string=get(handles.listbox4,'String'); tomwalters@0: generating_module=generating_module_string(get(handles.listbox4,'Value')); tomwalters@0: if ~isfield(handles.info,'current_sai_module') || ~strcmp(handles.info.current_sai_module,generating_module{1}) tomwalters@0: handles.info.calculate_sai=1; tomwalters@0: set(handles.checkbox4,'Value',1); tomwalters@0: end tomwalters@0: handles.info.current_sai_module=generating_module{1}; tomwalters@0: tomwalters@0: generating_module_string=get(handles.listbox6,'String'); tomwalters@0: generating_module=generating_module_string(get(handles.listbox6,'Value')); tomwalters@0: if ~isfield(handles.info,'current_usermodule_module') || ~strcmp(handles.info.current_usermodule_module,generating_module{1}) tomwalters@0: handles.info.calculate_usermodule=1; tomwalters@0: set(handles.checkbox8,'Value',1); tomwalters@0: end tomwalters@0: handles.info.current_usermodule_module=generating_module{1}; tomwalters@0: tomwalters@0: generating_module_string=get(handles.listbox5,'String'); tomwalters@0: generating_module=generating_module_string(get(handles.listbox5,'Value')); tomwalters@0: if ~isfield(handles.info,'current_movie_module') || ~strcmp(handles.info.current_movie_module,generating_module{1}) tomwalters@0: handles.info.calculate_movie=1; tomwalters@0: set(handles.checkbox5,'Value',1); tomwalters@0: end tomwalters@0: handles.info.current_movie_module=generating_module{1}; tomwalters@0: tomwalters@0: tomwalters@0: % put some additional information in the info-domain tomwalters@0: handles.info.save_pcp=1; tomwalters@0: handles.info.save_bmm=1; tomwalters@0: handles.info.save_nap=1; tomwalters@0: handles.info.save_sai=1; tomwalters@0: handles.info.save_strobes=1; tomwalters@0: handles.info.save_usermodule=1; tomwalters@0: handles.info.save_movie=1; tomwalters@0: tomwalters@0: tomwalters@0: % and update the new parameters tomwalters@0: handles.all_options=newoptions; tomwalters@0: tomwalters@0: if handles.with_graphic==1 tomwalters@0: waitbar(1,wbh); tomwalters@0: close(wbh); tomwalters@0: set(handles.figure1,'Pointer','arrow'); tomwalters@0: end