Changeset 177 for trunk/src/civ.m


Ignore:
Timestamp:
Jan 7, 2011, 1:53:05 AM (13 years ago)
Author:
sommeria
Message:

bug with mouse object editing resolved. Display feature 'satus' for PIV task advancement introduced. Various bug repair and cleaning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r174 r177  
    2222function varargout = civ(varargin)
    2323
    24 % Last Modified by GUIDE v2.5 01-Dec-2010 23:19:15
     24% Last Modified by GUIDE v2.5 05-Jan-2011 16:19:30
    2525% Begin initialization code - DO NOT EDIT
    2626gui_Singleton = 1;
     
    335335browse.num_j2=num_j2;
    336336if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat
    337 %     set(handles.ImaExt,'String',ext)
    338337    browse.nom_type_ima=nom_type;
    339338    browse.ext_ima=ext;
     339    set(handles.ImaExt,'String',ext)
    340340end
    341341set(handles.ImaDoc,'String',ext);
     
    593593        end
    594594    end
    595 %     if ~isempty(ext_ima_read) && ~isempty(nom_type_read)
    596 % %         if isempty(ext_ima)
    597 % %             ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously
    598 % %         else   %keep the image extension
    599 % %             if  ~strcmp(ext_ima_read,ext_ima)
    600 % %                 msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image'])
    601 % %             end
    602 % %         end
    603 %         nom_type_ima=nom_type_read;
    604 %     end
    605595elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file
    606596    [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']);
     
    612602    nom_type_ima='*';
    613603    ext_ima=ext_imadoc;
     604    set(handles.mode,'Value',1);
    614605    set(handles.mode,'String',{'series(Di)'})
    615606    dt=0.04;%default
     
    620611    end
    621612    time=(dt*(0:nbfield-1))';%list of image times
    622     %set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images
    623613end
    624614if isempty(time)
     
    698688        field_i=browse.num_i1;
    699689        field_j=browse.num_j2;
     690        imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search);
    700691        imagename_plus='';
    701692        jdetect=1;
     
    716707    time=(0:nbfield-1)';% time=file index -1  by default
    717708    if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j
    718 %     switch nom_type_search 
    719 %         case {'_i_j','%01dA','%02dA','%03dA','%04dA'}
    720         % time=[0:nb_field-1]'*ones(1,nb_field_j);% time=file index -1  by default
    721709        [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1);
    722710        time=x+y;
    723 %         time=[0:nb_field-1]'*[0:nb_field_j-1];% time=file index -1  by default
    724     end
    725 %     set(handles.mode,'String',{'series(Di)'})
     711    end
    726712end
    727713
     
    750736
    751737%%%%%%%%%%%  set the menus of image pairs and default selection for civ   %%%%%%%%%%%%%%%%%%%
    752 test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D'));%images with single indexing
     738test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing
    753739if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1))
    754     set(handles.mode,'String',{'series(Di)'})
    755740    set(handles.mode,'Value',1)
     741    set(handles.mode,'String',{'series(Di)'})   
    756742elseif (nbfield==1)% simple series in j
     743    set(handles.mode,'Value',1)
    757744    set(handles.mode,'String',{'series(Dj)'})
    758     set(handles.mode,'Value',1)
    759745else
    760746    set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice
     
    788774mode_Callback(hObject, eventdata, handles)
    789775
    790 %%%%%% initialize waitbars and RUN button
     776%% desable status and RUN button
    791777% set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001])
    792778% set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001])
     
    797783set(handles.BATCH,'Enable','On')
    798784set(handles.BATCH,'BackgroundColor',[1 0 0])
    799 
    800 %%%%% store the root input filename for future opening
     785set(handles.status,'Value',0);%suppress status display
     786status_Callback(hObject, eventdata, handles)
     787
     788%% store the root input filename for future opening
    801789dir_perso=prefdir;
    802790profil_perso=fullfile(prefdir,'uvmat_perso.mat');
     
    814802    end
    815803end
    816 % save(profil_perso, 'filebase'); %store the root name for future opening of uvmat
    817 set(gcf,'Pointer','arrow')
    818804
    819805%------------------------------------------------------------------------
     
    15651551end
    15661552
     1553%------------------------------------------------------------------------
     1554% --- Executes on button press in RUN: processing on local computer
    15671555function RUN_Callback(hObject, eventdata, handles)
    15681556%------------------------------------------------------------------------
    1569 % global civ1_exe civ2_exe patch_exe patch_new_exe sge
    15701557set(handles.RUN, 'Enable','Off')
    15711558set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
     
    15751562set(handles.RUN,'BackgroundColor',[1 0 0])
    15761563
     1564% start status callback to visualise results
     1565set(handles.status,'Value',1);%suppress status display
     1566status_Callback(hObject, eventdata, handles)
     1567
    15771568%------------------------------------------------------------------------
    15781569% --- Executes on button press in BATCH: remote processing
    15791570function BATCH_Callback(hObject, eventdata, handles)
    1580 %% -----------------------------------------------------------------------
    1581 %global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe % probabely to remove
     1571% -----------------------------------------------------------------------
    15821572set(handles.BATCH, 'Enable','Off')
    15831573set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])
     
    15871577set(handles.BATCH,'BackgroundColor',[1 0 0])
    15881578
     1579% start status callback to visualise results
     1580set(handles.status,'Value',1);%suppress status display
     1581status_Callback(hObject, eventdata, handles)
    15891582%------------------------------------------------------------------------
    15901583% --- Lauch command called by RUN and BATCH: remote processing
     
    16131606end
    16141607
    1615 %check mask if selecetd
     1608%% check mask if selecetd
    16161609if isequal(get(handles.get_mask_civ1,'Value'),1)
    16171610    maskname=get(handles.mask_civ1,'String');
     
    16391632end
    16401633
    1641 %% initialize the waitbars: TO suppress, waitbar not used
    1642 % set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001])
    1643 % set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001])
    1644 % set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001])
    1645 % set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001])
    1646 % drawnow
     1634%% reinitialise status callback
     1635set(handles.status,'Value',0);%suppress status display
     1636status_Callback(hObject, eventdata, handles)
    16471637
    16481638%% set the list of files and check them
     
    16511641[filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=...
    16521642    set_civ_filenames(handles,box_test);
     1643set(handles.civ,'UserData',filecell);%store for futur use of status callback
    16531644if isempty(filecell)% (error message displayed in fct set_civ_filenames)
    16541645    return
     
    18791870        %filename_cur=filecell.nc.civ1{ifile,j};%output netcdf file
    18801871        [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extention)
     1872        flname=fullfile(Rootbat,Filebat);
    18811873        %filename_cmx(end-1:end+6)='civ1.cmx';%name of cmx file
    18821874        if batch
     
    18841876            filename_bat=fullfile(Rootbat,['job_' Filebat]);
    18851877         else
    1886             filename_bat=fullfile(Rootbat,Filebat);
     1878            filename_bat=flname;
    18871879        end
    18881880        filename_bat=[filename_bat '.bat'];
     
    18921884            par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j};
    18931885            par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j};
    1894             namelog=[fullfile(Rootbat,Filebat) '.civ1.log'];
     1886            %namelog=[fullfile(Rootbat,Filebat) '.civ1.log'];
    18951887            par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j)));
    18961888            par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2);
     
    20652057            %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension
    20662058            [Rootbat,Filebat]=fileparts(filecell.nc.civ2{ifile,j});%output netcdf file (without extention)
    2067             namelog=[fullfile(Rootbat,Filebat) '.civ2.log'];
     2059            %namelog=[fullfile(Rootbat,Filebat) '.civ2.log'];
    20682060            par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j)));
    20692061            par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2);
     
    21192111            %endTESTgrid
    21202112            i_cmd=i_cmd+1;
    2121             cmd_CIV2=CIV2_CMD(fullfile(Rootbat,Filebat),[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx]
     2113            flname=fullfile(Rootbat,Filebat);
     2114            cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx]
    21222115            if isequal(civAll,0)
    2123                 flname=fullfile(Rootbat,Filebat);
    21242116                if(isunix)
    21252117                     cmd=[cmd 'cp -f ' flname '.civ2.cmx ' flname '.cmx\n' cmd_CIV2 '\n'];
     
    22532245                    pvalue=num2str((1-ind_answer)*500);
    22542246                    %namelog=[filename_bat '.patch.log'];
    2255                     display(['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]);
    2256                     eval(  ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]);
     2247                    display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]);
     2248                    eval(  ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]);
    22572249            end
    22582250        else
     
    23052297end
    23062298saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER  .xml)
     2299
    23072300
    23082301
     
    44174410    set(handles.RootName_1,'String',[]);
    44184411    mode_store=get(handles.compare,'UserData');
     4412    set(handles.mode,'Value',1)
    44194413    set(handles.mode,'String',mode_store)
    44204414    set(handles.test_stereo1,'Value',0)
     
    46034597end
    46044598
    4605 
    4606 
    4607 
    4608 
    4609 
     4599%-------------------------------------------------------------------
     4600% --- Executes on button press in status.
     4601function status_Callback(hObject, eventdata, handles)
     4602%-------------------------------------------------------------------
     4603val=get(handles.status,'Value');
     4604if val==0
     4605    hfig=findobj(allchild(0),'name','civ_status');
     4606    if ~isempty(hfig)
     4607        delete(hfig)
     4608    end
     4609    return
     4610end
     4611listtype={'civ1','fix1','patch1','civ2','fix2','patch2'};
     4612box_test(1)=get(handles.CIV1,'Value');
     4613box_test(2)=get(handles.FIX1,'Value');
     4614box_test(3)=get(handles.PATCH1,'Value');
     4615box_test(4)=get(handles.CIV2,'Value');
     4616box_test(5)=get(handles.FIX2,'Value');
     4617box_test(6)=get(handles.PATCH2,'Value');
     4618option=listtype{max(box_test(find(box_test)))};
     4619filecell=get(handles.civ,'UserData');
     4620if ~isfield(filecell,'nc')
     4621    filecell=set_civ_filenames(handles,box_test);%determine the list of output files expected from the GUI status
     4622end
     4623
     4624if ~isequal(box_test(4:6),[0 0 0])
     4625    civ_files=filecell.nc.civ2;
     4626else
     4627    civ_files=filecell.nc.civ1;
     4628end
     4629[root,filename,ext]=fileparts(civ_files{1});
     4630[rootroot,subdir,extdir]=fileparts(root);
     4631hfig=findobj(allchild(0),'name','civ_status');
     4632if isempty(hfig)
     4633    hfig=figure;
     4634    set(hfig,'name','civ_status')
     4635    hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.05 0.9 0.75], 'Callback', @open_view_field,'tag','list');
     4636    uicontrol('Style','listbox','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox');
     4637    uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
     4638    BarPosition=[0.05 0.81 0.01 0.05];
     4639    hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
     4640end
     4641datnum=[];
     4642Tabchar={};
     4643nbfiles=numel(civ_files);
     4644count=0;
     4645while count<nbfiles
     4646    count=0;
     4647    for ifile=1:nbfiles
     4648        detect=exist(civ_files{ifile},'file'); % check the existence of the file
     4649        if detect==0
     4650            lastfield='not created';
     4651        else
     4652            datfile=dir(civ_files{ifile});
     4653            datnum(ifile)=datenum(datfile.date);
     4654            filefound(ifile)={datfile.name};
     4655            lastfield='';
     4656            % check the content  netcdf file
     4657            Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix');
     4658            if ~isempty(Data.patch2) && isequal(Data.patch2,1)
     4659                lastfield='patch2';
     4660            elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
     4661                lastfield='fix2';
     4662            elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
     4663                lastfield='civ2';
     4664            elseif ~isempty(Data.patch) && isequal(Data.patch,1);
     4665                lastfield='patch1';
     4666            elseif ~isempty(Data.fix) && isequal(Data.fix,1);
     4667                lastfield='fix1';
     4668            else
     4669                lastfield='civ1';
     4670            end
     4671        end
     4672        if strcmp(lastfield,option)
     4673            count=count+1;
     4674        end
     4675        [rr,filename,ext]=fileparts(civ_files{ifile});
     4676        Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext  '...' lastfield];
     4677    end
     4678    if isempty(datnum)
     4679         message='no civ result created yet';
     4680    else
     4681        datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files
     4682        [first,ind]=min(datnum);
     4683        [last,indlast]=max(datnum);
     4684        message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
     4685            ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
     4686    end
     4687    hfig=findobj(allchild(0),'name','civ_status');
     4688    if isempty(hfig)
     4689        set(handles.status,'Value',0)%stop program if the figure has been suppressed
     4690        return
     4691    else
     4692        hlist=findobj(hfig,'tag','list');
     4693        hmsgbox=findobj(hfig,'tag','msgbox');
     4694        hwaitbar=findobj(hfig,'tag','waitbar');
     4695        set(hlist,'String',Tabchar)
     4696        set(hmsgbox,'String', message)
     4697        if count>0
     4698            BarPosition(3)=0.9*count/nbfiles;
     4699            set(hwaitbar,'Position',BarPosition)
     4700        end
     4701    end
     4702    set(hlist,'UserData',rootroot)
     4703    pause(5)% wait 5 seconds for next check
     4704end
     4705
     4706   
     4707%-------------------------------------------------------------------   
     4708% call 'view_field.fig' to display the selected field
     4709function open_view_field(hObject, eventdata)
     4710%-------------------------------------------------------------------
     4711     list=get(gcbo,'String');
     4712     index=get(gcbo,'Value');
     4713     rootroot=get(gcbo,'UserData');
     4714     filename=list{index};
     4715     ind_dot=findstr(filename,'...');
     4716     filename=filename(1:ind_dot-1);
     4717      filename=fullfile(rootroot,filename);
     4718      if exist(filename,'file')%visualise the vel field if it exists
     4719        [Field,VelTypeOut]=read_civxdata(filename);
     4720        view_field(Field)
     4721      end
     4722
     4723
Note: See TracChangeset for help on using the changeset viewer.