Changeset 472 for trunk


Ignore:
Timestamp:
Jun 25, 2012, 12:12:24 AM (13 years ago)
Author:
sommeria
Message:

many bugs repaired. series set to work in mode background

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/fill_GUI.m

    r461 r472  
    55errormsg='';
    66fields=fieldnames(Param);%list of fields in Param
     7% loop on the elements of the input structure Param
    78for ifield=1:numel(fields)
    8     if isstruct(Param.(fields{ifield}))
     9    if isstruct(Param.(fields{ifield}))% case of sa sub-structure
    910        if isfield(handles,fields{ifield})
    1011            set(handles.(fields{ifield}),'Visible','on')
     
    1314                hchild.(get(children(ichild),'tag'))=children(ichild);
    1415            end
    15             errormsg=fill_GUI(Param.(fields{ifield}),hchild);
     16            errormsg=fill_GUI(Param.(fields{ifield}),hchild);% apply the function to the substructure
    1617        end
    1718    else
    1819        hh=[];
    19         input_data=Param.(fields{ifield});
     20        input_data=Param.(fields{ifield})
    2021        check_done=0;
    2122        if isfield(handles,fields{ifield})
    22             hh=handles.(fields{ifield});
     23            hh=handles.(fields{ifield})
    2324            if strcmp(get(hh,'Type'),'uitable')
    2425                set(hh,'Visible','on')
     
    4546                    end
    4647                    set(hh,'String',input_data)
    47                 case{'Listbox','popupmenu'}
     48                case{'listbox','popupmenu'}
     49                    input_data
    4850                    if isnumeric(input_data)
    4951                        input_data=num2str(input_data);
    5052                    end
    5153                    menu=get(hh,'String');
    52                     iline=find(strcmp(input_data,menu));
    53                     if isempty(iline)
    54                         iline=numel(menu)+1;
    55                         set(hh,'String',[menu;{input_data}])
     54                    if ischar(input_data)
     55                        input_data={input_data};
    5656                    end
    57                     set(hh,'Value',iline)
     57                    values=zeros(size(input_data));
     58                    for idata=1:numel(input_data)
     59                        iline=find(strcmp(input_data{idata},menu));
     60                        if isempty(iline)
     61                            values(idata)=numel(menu)+1;
     62                            menu=[menu;input_data(idata)];
     63                        else
     64                            values(idata)=iline;
     65                        end
     66                    end
     67                    set(hh,'String',[menu;input_data(idata)])
     68                    set(hh,'Value',values)
    5869            end
    5970        end
  • trunk/src/find_file_series.m

    r469 r472  
    1515%       = 'netcdf' other netcdf files
    1616%       = 'video': movie recognised by VideoReader (e;g. avi)
    17 % Object: video object (=[] otherwise)
     17% MovieObject: video object (=[] otherwise)
    1818%
    1919%INPUT
     
    3737%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    3838
    39 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput)
     39function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput)
    4040%------------------------------------------------------------------------
    4141
     
    5050j1_series=zeros(1,1,1);
    5151j2_series=zeros(1,1,1);
    52 % ifile_min=1;%default
    53 [FileType,FileInfo,Object]=get_file_type(fullfileinput);
    54 NbFrame=1;
    55 
    56 switch FileType
    57     case 'multimage'
    58     NbFrame=FileInfo.NumberOfFrames;
    59     case {'video','mmreader'}
    60     NomType='*';
    61     NbFrame=FileInfo.NumberOfFrames;
    62 end
    63 
    64 RootFile_i='';
     52[FileType,FileInfo,MovieObject]=get_file_type(fullfileinput);
     53if ~exist(FilePath,'dir')
     54    return % don't go further if the dir path does not exist
     55end
     56% NbFrame=1;
     57% switch FileType
     58%     case 'multimage'
     59%     NbFrame=FileInfo.NumberOfFrames;
     60%     case {'video','mmreader'}
     61%     NomType='*';
     62%     NbFrame=FileInfo.NumberOfFrames;
     63% end
     64
     65% RootFile_i='';
    6566NomTypePref='';
    6667if strcmp(NomType,'')||strcmp(NomType,'*')
     
    7071        RootFile='';
    7172    end
    72     i1_input=1;% the index now refer to the frame in the movie, choose 1 at opening
    73     i2_input=[];
    74     j1_input=[];
    75     j2_input=[];
     73%     i1_input=1;% the index now refer to the frame in the movie, choose 1 at opening
     74%     i2_input=[];
     75%     j1_input=[];
     76%     j2_input=[];
    7677else
    7778    %% possibly include the first index in the root name, if there exists a corresponding xml file
     
    101102    i1_str='(?<i1>)';%will set i1=[];
    102103    i1_star='';
    103     %     r.sep2='';
    104104    i2_str='(?<i2>)';%will set i2=[];
    105105    i2_star='';
    106     %     sep3='';
    107106    j1_str='(?<j1>)';%will set j1=[];
    108107    j1_star='';
    109     %     sep4='';
    110108    j2_str='(?<j2>)';%will set j2=[];
    111109    j2_star='';
    112     %   NomTypeStr=NomType;
    113110    %Look for cases with letter indexing for the second index
    114111    r=regexp(NomType,'^(?<sep1>_?)(?<i1>\d+)(?<j1>[a|A])(?<j2>[b|B]?)$','names');
     
    240237    %% update the file type if the input file does not exist (pb of 0001)
    241238    if isempty(FileType)
    242         [FileType,tild,Object]=get_file_type(dirpair(ifile_min).name);
     239        [FileType,tild,MovieObject]=get_file_type(fullfile(FilePath,dirpair(ifile_min).name));
    243240    end
    244241end
     
    251248
    252249%% introduce the frame index in case of movies or multimage type
    253 if NbFrame>1
     250if isfield(FileInfo,'NumberOfFrames')>1 && FileInfo.NumberOfFrames >1
    254251    if isempty(i1_series)
    255         i1_series=(1:NbFrame)';
     252        i1_series=(1:FileInfo.NumberOfFrames)';
    256253        i1_input=1;
    257254    else
    258        j1_series=(1:NbFrame)';
     255       j1_series=(1:FileInfo.NumberOfFrames)';
    259256       j1_input=1;
    260257    end
     
    289286end
    290287
    291 % %% deals with frame index in movies
    292 % switch FileType
    293 %     case 'multimage'
    294 %    NomType='*';
    295 %    i1_series=(1:FileInfo.NbFrame)';
    296 %     case {'video','mmreader'}
    297 %     NomType='*';
    298 %     i1_series=(1:FileInfo.NumberOfFrames)';
    299 % end
    300 
     288
  • trunk/src/get_file_type.m

    r469 r472  
    3232        FileType='xls';
    3333    otherwise
    34         if ~isempty(imformats(regexprep(FileExt,'^.','')))
     34        if ~isempty(FileExt) && ~isempty(imformats(regexprep(FileExt,'^.','')))
    3535            try
    3636                imainfo=imfinfo(fileinput);
  • trunk/src/msgbox_uvmat.m

    r421 r472  
    4545set(handles.figure1,'Units','pixels')
    4646FigPos=[100 150 500 50];%default position
    47 if exist('Position','var')
     47if exist('Position','var') && numel(Position)>=2
    4848    FigPos(1)=Position(1);
    4949    FigPos(2)=Position(2)-FigPos(4);% upper left corner set by input Position
  • trunk/src/read_civxdata.m

    r420 r472  
    5353DataTest=nc2struct(filename,'ListGlobalAttribute','Conventions','CivStage');
    5454if isfield(DataTest,'Txt')
    55     errormsg=DataTest.Txt;
     55    errormsg=['nc2struct:' DataTest.Txt];
    5656    return
    5757elseif isequal(DataTest.Conventions,'uvmat/civdata')%test for new civ format
    5858     [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,DataTest.CivStage);
    59 %      if ~isempty(errormsg)
    60 %          msgbox_uvmat('ERROR',errormsg)
    61 %      end
     59      if ~isempty(errormsg),errormsg=['read_civdata:' errormsg];end
    6260     return
    6361end
     
    7977[Field,vardetect,ichoice]=nc2struct(filename,var);%read the variables in the netcdf file
    8078if isfield(Field,'Txt')
    81     errormsg=Field.Txt;
     79    errormsg=['nc2struct:' Field.Txt];
    8280    return
    8381end
  • trunk/src/read_field.m

    r466 r472  
    5757                FieldList=calc_field;%list of possible fields for Civx data
    5858                ParamOut.ColorVar='';%default
    59                 field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data
     59                if ischar(ParamIn.FieldName)
     60                    FieldName=ParamIn.FieldName;
     61                else
     62                    FieldName=ParamIn.FieldName{1};
     63                end
     64                field_index=strcmp(FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data
    6065                if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist
    6166                    Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ','CivStage');
     
    6671                        InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    6772                        [Field,ParamOut.VelType,errormsg]=read_civdata(FileName,InputField,ParamIn.VelType,Data.CivStage);
     73                        if ~isempty(errormsg),errormsg=['read_civdata:' errormsg];return,end
    6874                        CivStage=Field.CivStage;
    6975                        ParamOut.CivStage=Field.CivStage;
     
    7480                        InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    7581                        [Field,ParamOut.VelType]=read_civxdata(FileName,InputField,ParamIn.VelType);
     82                        if ~isempty(errormsg),errormsg=['read_civxdata:' errormsg];return,end
    7683                        CivStage=Field.CivStage;
    7784                        ParamOut.CivStage=Field.CivStage;
     
    8491                        end
    8592                    end
    86                 else
    87                     InputField={ParamOut.FieldName};
     93                else             
     94                    InputField=ParamOut.FieldName;
     95                    if ischar(InputField)
     96                        InputField={InputField};
     97                    end
    8898                    if isfield(ParamIn,'ColorVar')
    8999                        ParamOut.ColorVar=ParamIn.ColorVar;
     
    91101                    end
    92102                    [Field,ParamOut.VelType,errormsg]=read_civxdata(FileName,InputField,ParamIn.VelType);
    93                     if ~isempty(errormsg)
    94                         return
    95                     end
     103                    if ~isempty(errormsg),errormsg=['read_civxdata:' errormsg];return,end
    96104                    CivStage=Field.CivStage;
    97105                    ParamOut.CivStage=Field.CivStage;
     
    123131                        Tabcell{iline,1}=Field.ListGlobalAttribute{iline};
    124132                        if isfield(Field, Field.ListGlobalAttribute{iline})
    125                             eval(['val=Field.' Field.ListGlobalAttribute{iline} ';'])
     133                            val=Field.(Field.ListGlobalAttribute{iline});
    126134                            if ischar(val);
    127135                                Tabcell{iline,2}=val;
     
    160168    end
    161169catch ME
    162     errormsg=ME.message;
     170    errormsg=[FileType ' input: ' ME.message];
    163171    return
    164172end
  • trunk/src/series.m

    r471 r472  
    8181          for ifile=1:min(length(h.MenuFile),5)
    8282              eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});'])
    83 %               eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});'])
    8483          end
    8584     end
    86 %      if isfield(h,'MenuFile')
    87 %           for ifile=1:min(length(h.MenuFile),5)
    88 %               eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});'])
    89 %                eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});'])
    90 %           end
    91 %       end
    92      
    9385     test_profil_perso=1;
    94 %      if isfield(h,'MenuFile_1') && exist(h.MenuFile_1,'file')
    95 %           set(handles.MenuFile_1,'Label',h.MenuFile_1);
    96 %           set(handles.MenuFile_insert_1,'Label',h.MenuFile_1);
    97 %      end
    98 %      if isfield(h,'MenuFile_2')&& exist(h.MenuFile_2,'file')
    99 %           set(handles.MenuFile_2,'Label',h.MenuFile_2);
    100 %           set(handles.MenuFile_insert_2,'Label',h.MenuFile_2);
    101 %      end
    102 %      if isfield(h,'MenuFile_3')&& exist(h.MenuFile_3,'file')
    103 %           set(handles.MenuFile_3,'Label',h.MenuFile_3);
    104 %           set(handles.MenuFile_insert_3,'Label',h.MenuFile_3);
    105 %      end
    106 %      if isfield(h,'MenuFile_4')&& exist(h.MenuFile_4,'file')
    107 %           set(handles.MenuFile_4,'Label',h.MenuFile_4);
    108 %           set(handles.MenuFile_insert_4,'Label',h.MenuFile_4);
    109 %      end
    110 %      if isfield(h,'MenuFile_5')&& exist(h.MenuFile_5,'file')
    111 %           set(handles.MenuFile_5,'Label',h.MenuFile_5);
    112 %           set(handles.MenuFile_insert_5,'Label',h.MenuFile_5);
    113 %      end
    11486end
    11587
     
    135107        display_file_name(handles,param.FileName,0)
    136108    end
     109    InputTable={'','','','',''};
     110    set(handles.InputTable,'Data',InputTable)
    137111end 
    138112
     
    141115    set(handles.FieldName,'String',param.list_fields);% list menu fields
    142116    set(handles.FieldName,'Value',param.index_fields);% selected string index
    143     FieldCell{1}=param.list_fields{param.index_fields};
     117%     FieldCell{1}=param.list_fields{param.index_fields};
    144118end
    145119
     
    209183set(handles.TransformName,'UserData',fct_handle)% store the list of path in UserData of ACTION
    210184
     185%% Adjust the GUI according to the binaries available in PARAM.xml
     186path_uvmat=fileparts(which('uvmat')); %path to civ
     187addpath (path_uvmat) ; %add the path to civ, (useful in case of change of working directory after civ has been s opened in the working directory)
     188errormsg=[];%default error message
     189xmlfile='PARAM.xml';
     190if exist(xmlfile,'file')
     191    try
     192        t=xmltree(xmlfile);
     193        sparam=convert(t);
     194    catch ME
     195        errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message};
     196    end
     197else
     198    errormsg=[xmlfile ' not found: path to civx binaries undefined'];
     199end
     200if ~isempty(errormsg)
     201    msgbox_uvmat('WARNING',errormsg);
     202end
     203test_batch=0;%default: ,no batch mode available
     204if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode')
     205    test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod
     206end
     207RUNVal=get(handles.RunMode,'Value');
     208if test_batch==0
     209   if RUNVal>2
     210       set(handles.RunMode,'Value',1)
     211   end
     212   set(handles.RunMode,'String',{'local';'background'})
     213else
     214    set(handles.RunMode,'String',{'local';'background';'cluster'})
     215end
     216% if isfield(sparam.RunParam,'CivBin')
     217%     if ~exist(sparam.RunParam.CivBin,'file')
     218%         sparam.RunParam.CivBin=fullfile(path_uvmat,sparam.RunParam.CivBin);
     219%     end
     220% else
     221%     sparam.RunParam.CivBin='';
     222% end
    211223% display the GUI for the default actionname 'check_data_files'
    212 ActionName_Callback(hObject, eventdata, handles)
     224% ActionName_Callback(hObject, eventdata, handles)
    213225
    214226%------------------------------------------------------------------------
     
    235247%------------------------------------------------------------------------   
    236248InputTable=get(handles.InputTable,'Data');
    237 RootPathCell=InputTable(:,1);
    238 SubDirCell=InputTable(:,2);
    239 RootFileCell=InputTable(:,3);
     249if isempty(InputTable)
     250    RootPathCell={};
     251else
     252    RootPathCell=InputTable(:,1);
     253end
    240254oldfile=''; %default
    241255if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box
     
    251265         end
    252266     end
    253  else
     267else
     268     SubDirCell=InputTable(:,2);
     269    RootFileCell=InputTable(:,3);
    254270     oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1});
    255271 end
     
    265281        'Pick a file',oldfile);
    266282fileinput=[PathName FileName];%complete file name
    267 sizf=size(fileinput);
    268 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
     283if isempty(fileinput),return;end %abandon if no file is introduced by the browser
    269284[path,name,ext]=fileparts(fileinput);
    270 SeriesData=[];%dfault
    271285if isequal(ext,'.xml')
    272      Param=xml2struct(fileinput);
    273     fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file
    274     if isfield(Param,'CheckObject')&& Param.CheckObject
    275         set_object(Param.ProjObject)
    276     end
    277     return
     286    [Param,Heading]=xml2struct(fileinput);
     287    if ~strcmp(Heading,'Series')
     288        msg_box_uvmat('ERROR','xml file heading is not <Series>')
     289    else
     290        fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file
     291        if isfield(Param,'CheckObject')&& Param.CheckObject
     292            set_object(Param.ProjObject)
     293        end
     294        set(handles.REFRESH,'UserData',[1:size(Param.InputTable,1)])
     295        REFRESH_Callback([],[], handles)
     296        return
     297    end
    278298elseif isequal(ext,'.xls')
    279299    msg_box_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    280300else
    281301    display_file_name(handles,fileinput,0)
    282      %update list of recent files in the menubar
    283 %     MenuFile_1=fileinput;
    284 %     MenuFile_2=get(handles.MenuFile_1,'Label');
    285 %     MenuFile_3=get(handles.MenuFile_2,'Label');
    286 %     MenuFile_4=get(handles.MenuFile_3,'Label');
    287 %     MenuFile_5=get(handles.MenuFile_4,'Label');
    288 %     set(handles.MenuFile_1,'Label',MenuFile_1)
    289 %     set(handles.MenuFile_2,'Label',MenuFile_2)
    290 %     set(handles.MenuFile_3,'Label',MenuFile_3)
    291 %     set(handles.MenuFile_4,'Label',MenuFile_4)
    292 %     set(handles.MenuFile_5,'Label',MenuFile_5)
    293 %     set(handles.MenuFile_insert_1,'Label',MenuFile_1)
    294 %     set(handles.MenuFile_insert_2,'Label',MenuFile_2)
    295 %     set(handles.MenuFile_insert_3,'Label',MenuFile_3)
    296 %     set(handles.MenuFile_insert_4,'Label',MenuFile_4)
    297 %     set(handles.MenuFile_insert_5,'Label',MenuFile_5)
    298 %     dir_perso=prefdir;
    299 %     profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    300 %     if exist(profil_perso,'file')
    301 %         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
    302 %     else
    303 %     txt=ver('MATLAB');
    304 %     Release=txt.Release;
    305 %         relnumb=str2num(Release(3:4));
    306 %         if relnumb >= 14
    307 %             save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
    308 %         else
    309 %             save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
    310 %         end
    311 %     end
    312302end
    313303
     
    377367    msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    378368else
    379     display_file_name(handles,fileinput,1)
     369    display_file_name(handles,fileinput,'append')
    380370end
    381371
     
    384374% --------------------------------------------------------------------   
    385375fileinput=get(handles.MenuFile_insert_1,'Label');
    386 display_file_name(handles,fileinput,1)
     376display_file_name(handles,fileinput,'append')
    387377
    388378% --------------------------------------------------------------------
     
    390380% --------------------------------------------------------------------   
    391381fileinput=get(handles.MenuFile_insert_2,'Label');
    392 display_file_name(handles,fileinput,1)
     382display_file_name(handles,fileinput,'append')
    393383
    394384% --------------------------------------------------------------------
     
    396386% --------------------------------------------------------------------   
    397387fileinput=get(handles.MenuFile_insert_3,'Label');
    398 display_file_name( handles,fileinput,1)
     388display_file_name( handles,fileinput,'append')
    399389
    400390% --------------------------------------------------------------------
     
    402392% --------------------------------------------------------------------   
    403393fileinput=get(handles.MenuFile_insert_4,'Label');
    404 display_file_name( handles,fileinput,1)
     394display_file_name( handles,fileinput,'append')
    405395
    406396% --------------------------------------------------------------------
     
    408398% --------------------------------------------------------------------   
    409399fileinput=get(handles.MenuFile_insert_5,'Label');
    410 display_file_name(handles,fileinput,1)
     400display_file_name(handles,fileinput,'append')
    411401
    412402%------------------------------------------------------------------------
     
    414404function InputTable_CellEditCallback(hObject, eventdata, handles)
    415405%------------------------------------------------------------------------
     406set(handles.REFRESH,'Visible','on')
    416407iview=eventdata.Indices(1);
     408view_set=get(handles.REFRESH,'UserData');
     409if isempty(find(view_set==iview))
     410    set(handles.REFRESH,'UserData',[view_set iview])
     411end
     412%% enable other menus and uicontrols
     413set(handles.MenuOpen_insert,'Enable','on')
     414set(handles.MenuFile_insert_1,'Enable','on')
     415set(handles.MenuFile_insert_2,'Enable','on')
     416set(handles.MenuFile_insert_3,'Enable','on')
     417set(handles.MenuFile_insert_4,'Enable','on')
     418set(handles.MenuFile_insert_5,'Enable','on')
     419set(handles.RUN, 'Enable','On')
     420set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
     421
     422%update the output dir
     423% SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order
     424% SubDirOut=SubDir{1};
     425% if numel(SubDir)>1
     426%     for ilist=2:numel(SubDir)
     427%         SubDirOut=[SubDirOut '-' SubDir{ilist}];
     428%     end
     429% end
     430% set(handles.OutputSubDir,'String',SubDirOut)
     431
     432%------------------------------------------------------------------------
     433% --- Executes on button press in REFRESH.
     434function REFRESH_Callback(hObject, eventdata, handles)
     435%------------------------------------------------------------------------
    417436InputTable=get(handles.InputTable,'Data');
    418 fileinput=fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]);
    419 display_file_name(handles,fileinput,0)
    420 %update the output dir
    421 SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order
    422 SubDirOut=SubDir{1};
    423 if numel(SubDir)>1
    424     for ilist=2:numel(SubDir)
    425         SubDirOut=[SubDirOut '-' SubDir{ilist}];
    426     end
    427 end
    428 set(handles.OutputSubDir,'String',SubDirOut)
    429 
    430 %------------------------------------------------------------------------
    431 % ---  refresh the GUI data after introduction of a new file
     437view_set=get(handles.REFRESH,'UserData');
     438set(handles.REFRESH,'BackgroundColor',[0.7 0.7 0.7])% set REFRESH  button to grey color
     439drawnow
     440for iview=view_set
     441    RootPath=fullfile(InputTable{iview,1},InputTable{iview,2});
     442    if ~exist(RootPath,'dir')
     443        i1_series=[];
     444        RootPath=fileparts(RootPath); %will try the upped forldr
     445    else
     446        [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=...
     447            find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]);
     448    end
     449    if isempty(i1_series)
     450        [FileName, PathName, filterindex] = uigetfile( ...
     451            {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)';
     452            '*.xml',  '.xml files '; ...
     453            '*.xls',  '.xls files '; ...
     454            '*.png','.png image files'; ...
     455            '*.tif','.tif image files'; ...
     456            '*.avi;*.AVI','.avi movie files'; ...
     457            '*.nc','.netcdf files'; ...
     458            '*.*',  'All Files (*.*)'}, ...
     459            ['unvalid entry at line ' num2str(iview) ', pick a file'],RootPath);
     460        fileinput=[PathName FileName];%complete file name
     461        if isempty(fileinput),return;end %abandon if the operation has been cancelled: no input from browser
     462        [path,name,ext]=fileparts(fileinput);
     463        display_file_name(handles,fileinput,iview)
     464    else
     465        update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,iview)
     466    end
     467end
     468set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH  button to grey color
     469set(handles.REFRESH,'Visible','off')
     470set(handles.REFRESH,'UserData',[])
     471
     472%------------------------------------------------------------------------
     473% --- Function called when a new file is opened, either by series_OpeningFcn or by the browser
     474function display_file_name(handles,fileinput,iview)
     475%------------------------------------------------------------------------ 
     476%
    432477% INPUT:
    433 % handles: handles of the elements in the GUI series
    434 % fileinput: name of the input file
    435 % append: =0 to refresh the list of file series, =1 to append a new series to the list (from the menu bar option 'Open_insert')
    436 function display_file_name(handles,fileinput,append)
    437 %------------------------------------------------------------------------ 
     478% handles: handles of elements in the GUI
     479% fielinput: input file name, including path
     480% append =0 (refresh the Input table with the new file), ='append' append a new line in the table
    438481
    439482%% get the input root name, indices, file extension and nomenclature NomType
     
    467510%% fill the list of file series
    468511InputTable=get(handles.InputTable,'Data');
    469 if append % display the input data as a new line in the table
    470      lastview=size(InputTable,1)+1;
    471      InputTable(lastview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    472     set(handles.ListView,'String',[get(handles.ListView,'String');{num2str(lastview)}])
    473     set(handles.ListView,'Value',lastview)
    474 
    475 else % or re-initialise the list of  input  file series
    476     lastview=1;
    477     InputTable=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     512if strcmp(iview,'append') % display the input data as a new line in the table
     513     iview=size(InputTable,1);
     514     InputTable(iview+1,:)={'','','','',''};
     515     InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     516elseif iview==0 % or re-initialise the list of  input  file series
     517    iview=1;
     518    InputTable=[{'','','','',''};{'','','','',''}];
     519     InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    478520    set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}])
    479521    set(handles.MinIndex,'Data',[{[]},{[]}])
     
    482524    set(handles.ListView,'String',{'1'})
    483525end
     526nbview=size(InputTable,1);
     527set(handles.ListView,'String',mat2cell((1:nbview)',ones(nbview,1)))
     528set(handles.ListView,'Value',iview)
    484529set(handles.InputTable,'Data',InputTable)
     530
     531%% determine the selected reference field indices for pair display
     532ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV
     533if ~isempty(i1)
     534    ref_i=i1;
     535    if ~isempty(i2)
     536        ref_i=floor((ref_i+i2)/2);% reference image number corresponding to the file
     537    end
     538end
     539set(handles.num_ref_i,'String',num2str(ref_i));
     540ref_j=1; %default  ref_j is a reference frame index used to find existing pairs from PIV
     541if ~isempty(j1)
     542    ref_j=j1;
     543    if ~isempty(j2)
     544        ref_j=floor((j1+j2)/2);
     545    end         
     546end
     547set(handles.num_ref_j,'String',num2str(ref_j));
     548
     549%% update the list of recent files in the menubar and save it for future opening
     550MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
     551    {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
     552str_find=strcmp(fileinput,MenuFile);
     553if isempty(find(str_find,1))
     554    MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list
     555end
     556for ifile=1:min(length(MenuFile),5)
     557    eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
     558    eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
     559end
     560dir_perso=prefdir;
     561profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     562if exist(profil_perso,'file')
     563    save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat
     564else
     565    save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat
     566end
     567
     568set(handles.InputTable,'BackgroundColor',[1 1 1])
     569
     570%% initiate input file series and refresh the current field view:     
     571update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,iview);
     572
     573%------------------------------------------------------------------------
     574% --- Update information about a new field series (indices to scan, timing,
     575%     calibration from an xml file
     576function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,iview)
     577%------------------------------------------------------------------------
     578%% update the output dir
     579InputTable=get(handles.InputTable,'Data');
     580SubDir=sort(InputTable(1:end-1,2)); %set of subdirectories sorted in alphabetical order
     581SubDirOut=SubDir{1};
     582if numel(SubDir)>1
     583    for ilist=2:numel(SubDir)
     584        SubDirOut=[SubDirOut '-' SubDir{ilist}];
     585    end
     586end
     587set(handles.OutputSubDir,'String',SubDirOut)
    485588
    486589%% display the min and max indices for all the file series
    487590i_sum=sum(sum(i1_series,2),3);%sum of i1_series on the last index
    488 MaxIndex_i=max(find(i_sum>0))-1;
    489 MinIndex_i=min(find(i_sum>0))-1;
     591MaxIndex_i=max(find(i_sum>0))-1;% max ref index i
     592MinIndex_i=min(find(i_sum>0))-1;% min ref index i
    490593i2_min=[];
    491594if ~isempty(i2_series)
     
    500603    j2_min=j2_series(1,2);
    501604end
    502 if isequal(MinIndex_i,1) && exist (fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,0,i2_min, j1_min,j2_min),'file')
     605if isequal(MinIndex_i,1) &&...
     606        exist (fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},0,i2_min, j1_min,j2_min),'file')
    503607    MinIndex_i=0;
    504608end
     
    508612MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex
    509613MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex
    510 MinIndex{lastview,1}=MinIndex_i;
    511 MinIndex{lastview,2}=MinIndex_j;
    512 MaxIndex{lastview,1}=MaxIndex_i;
    513 MaxIndex{lastview,2}=MaxIndex_j;
     614MinIndex{iview,1}=MinIndex_i;
     615MinIndex{iview,2}=MinIndex_j;
     616MaxIndex{iview,1}=MaxIndex_i;
     617MaxIndex{iview,2}=MaxIndex_j;
    514618
    515619set(handles.MinIndex,'Data',MinIndex)%display the min indices in the table MinIndex
     
    547651set(handles.num_last_i,'String',num2str(last_i));
    548652set(handles.num_last_j,'String',num2str(last_j));
    549 
    550 
    551 %% update the output dir
    552 SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order
    553 SubDirOut=SubDir{1};
    554 if numel(SubDir)>1
    555     for ilist=2:numel(SubDir)
    556         SubDirOut=[SubDirOut '-' SubDir{ilist}];
    557     end
    558 end
    559 set(handles.OutputSubDir,'String',SubDirOut)
    560 
    561 %% determine the selected reference field indices for pair display
    562 ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV
    563 if ~isempty(i1)
    564     ref_i=i1;
    565     if ~isempty(i2)
    566         ref_i=floor((ref_i+i2)/2);% reference image number corresponding to the file
    567     end
    568 end
    569 set(handles.num_ref_i,'String',num2str(ref_i));
    570 ref_j=1; %default  ref_j is a reference frame index used to find existing pairs from PIV
    571 if ~isempty(j1)
    572     ref_j=j1;
    573     if ~isempty(j2)
    574         ref_j=floor((j1+j2)/2);
    575     end         
    576 end
    577 set(handles.num_ref_j,'String',num2str(ref_j));
    578 
    579 %% update the list of recent files in the menubar and save it for future opening
    580 MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
    581     {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
    582 str_find=strcmp(fileinput,MenuFile);
    583 if isempty(find(str_find,1))
    584     MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list
    585 end
    586 for ifile=1:min(length(MenuFile),5)
    587     eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
    588     eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
    589 end
    590 dir_perso=prefdir;
    591 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    592 if exist(profil_perso,'file')
    593     save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat
    594 else
    595     save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat
    596 end
    597 
    598 set(handles.InputTable,'BackgroundColor',[1 1 1])
    599 
    600 %% initiate input file series and refresh the current field view:     
    601 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,lastview);
    602 
    603 %------------------------------------------------------------------------
    604 % --- Update information about a new field series (indices to scan, timing,
    605 %     calibration from an xml file, then refresh current plots
    606 function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,iview)
    607 %------------------------------------------------------------------------
    608 
    609 %% enable j index visibility
    610 if isempty(j1_series)
    611     state='off';
    612 else
    613     state='on';
    614 end
    615 enable_j(handles,state)
    616653
    617654%% read timing and total frame number from the current file (movie files) !! may be overrid by xml file
     
    726763ListView=get(handles.ListView,'String');
    727764ListView{iview}=num2str(iview);
    728 set(handles.ListView,'String');
     765set(handles.ListView,'String',ListView);
    729766set(handles.ListView,'Value',iview)
    730767update_mode(handles,i1_series,i2_series,j1_series,j2_series,time)
     
    755792set(handles.waitbar_frame,'Units','normalized')
    756793
    757 %% enable field and veltype menus
     794
     795%% update the series info in 'UserData'
    758796SeriesData=get(handles.series,'UserData');
    759 SeriesData.FileType{iview}=FileType;
    760 check_civ=0;
    761 check_netcdf=0;
    762 for iview=1:length(SeriesData.FileType)
    763     switch SeriesData.FileType{iview}
    764         case {'civx','civdata'}
    765             check_civ=check_civ+1;
    766         case 'netcdf'
    767             check_netcdf=check_netcdf+1;
    768     end
    769 end
    770 if check_civ
    771     enable='on';
    772 else
    773     enable='off';
    774 end
    775 set(handles.VelType,'Visible',enable)
    776 set(handles.VelType_text,'Visible',enable)
    777 if check_civ>=2
    778     enable='on';
    779 else
    780     enable='off';
    781 end
    782 set(handles.VelType_1,'Visible',enable)
    783 set(handles.VelType_text_1,'Visible',enable)
    784 if check_civ || check_netcdf
    785     enable='on';
    786 else
    787     enable='off';
    788 end
    789 set(handles.FieldName,'Visible',enable)
    790 set(handles.Field_text,'Visible',enable)
    791 if check_civ+ check_netcdf>=2
    792     enable='on';
    793 else
    794     enable='off';
    795 end
    796 set(handles.FieldName_1,'Visible',enable)
    797 set(handles.Field_text_1,'Visible',enable)
    798 FieldString={''};
    799 if check_civ
    800     FieldString=[calc_field;{'get_field...'}];
    801 elseif check_netcdf
    802     FieldString={'get_field...'};
    803 end
    804 set(handles.FieldName,'String',FieldString)
    805 FieldString={''};
    806 if check_civ>=2
    807     FieldString=[calc_field;{'get_field...'}];
    808 elseif check_civ+check_netcdf>=2
    809     FieldString={'get_field...'};
    810 end
    811 set(handles.FieldName_1,'String',{'get_field...'})
    812 
    813 
    814 %% store the series info in 'UserData'
    815797SeriesData.i1_series{iview}=i1_series;
    816798SeriesData.i2_series{iview}=i2_series;
     
    820802SeriesData.Time{iview}=time;
    821803set(handles.series,'UserData',SeriesData)
     804
     805%% enable j index visibility
     806state='off';
     807check_jindex=~cellfun(@isempty,SeriesData.j1_series); %look for non empty j indices
     808if isempty(find(check_jindex))
     809    enable_j(handles,'off') % no j index needed
     810else
     811    enable_j(handles,'on')
     812end
     813
     814%% enable field and veltype menus, in accordance with the current action
     815ActionName_Callback([],[], handles)
    822816
    823817%% check for pair display
     
    902896% mode_Callback(hObject, eventdata, handles)
    903897%
    904 % set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7])
     898% set(handles.REFRESH,'BackgroundColor',[0.7 0.7 0.7])
    905899% InputTable=get(handles.InputTable,'Data');
    906 % check_lines=get(handles.REFRESH_INDICES,'UserData');
     900% check_lines=get(handles.REFRESH,'UserData');
    907901%
    908902% %% check the indices and FileTypes for each series (limited to the new ones to save time)
     
    11711165mode=mode_list{get(handles.mode,'Value')};
    11721166ref_i=str2num(get(handles.num_ref_i,'String'));
    1173 ref_j=str2num(get(handles.num_ref_j,'String'));
    11741167if isempty(ref_i)
    11751168    ref_i=1;
    11761169end
    1177 if isempty(ref_j)
     1170if strcmp(get(handles.num_ref_j,'Visible'),'on')
     1171    ref_j=str2num(get(handles.num_ref_j,'String'));
     1172    if isempty(ref_j)
     1173        ref_j=1;
     1174    end
     1175else
    11781176    ref_j=1;
    11791177end
     
    11981196            pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
    11991197            if ~isempty(time)
     1198                if ref_i<=floor(ipair/2)
     1199                    ref_i=floor(ipair/2)+1;% shift ref_i to get the first pair
     1200                end
    12001201                Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j);
    12011202                pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit];
     
    12191220            pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
    12201221            if ~isempty(time)
     1222                if ref_j<=floor(ipair/2)
     1223                    ref_j=floor(ipair/2)+1;% shift ref_i to get the first pair
     1224                end
    12211225                Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2));
    12221226                pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit];
     
    12491253    end
    12501254end
     1255set(handles.num_ref_i,'String',num2str(ref_i)) % update ref_i and ref_j
     1256set(handles.num_ref_j,'String',num2str(ref_j))
    12511257
    12521258%% display list of pairstring
     
    12861292
    12871293%-----------------------------------
    1288 function view_FieldMenu(handles,state)
    1289 % set(handles.FieldName,'Visible',state)
    1290 % set(handles.Field_text,'Visible',state)
    1291 set(handles.InputFields,'Visible',state)
    1292 
    1293 %-----------------------------------
    1294 function view_FieldMenu_1(handles,state)
    1295 set(handles.FieldName_1,'Visible',state)
    1296 set(handles.Field_text_1,'Visible',state)
     1294% function view_FieldMenu(handles,state)
     1295% % set(handles.FieldName,'Visible',state)
     1296% % set(handles.Field_text,'Visible',state)
     1297% set(handles.InputFields,'Visible',state)
     1298
     1299% %-----------------------------------
     1300% function view_FieldMenu_1(handles,state)
     1301% set(handles.FieldName_1,'Visible',state)
     1302% set(handles.Field_text_1,'Visible',state)
    12971303
    12981304
     
    13121318if ~isempty(errormsg)
    13131319    msgbox_uvmat('ERROR',errormsg)
    1314 else
    1315   %Series.Specific=h_fun(Series);   
    1316    Series=h_fun(Series); 
    1317    if ~isempty(filexml)
    1318    t=struct2xml(Series);
    1319     t=set(t,1,'name','Series');
    1320     save(t,filexml);
    1321    end
    1322 %     h_fun(Series);
    1323 end
     1320    return
     1321end
     1322RunModeList=get(handles.RunMode,'String');
     1323RunMode=RunModeList{get(handles.RunMode,'Value')};
     1324
     1325switch RunMode
     1326    case 'local'
     1327        Series=h_fun(Series);
     1328        if ~isempty(filexml)
     1329            t=struct2xml(Series);
     1330            t=set(t,1,'name','Series');
     1331            save(t,filexml);
     1332        end
     1333    case 'background'
     1334        if isempty(filexml)
     1335            Series=h_fun(Series);% no background in the absence of output file
     1336        else
     1337        % update the xml file after interactive input with the function
     1338        Series.Specific='?';
     1339        Series=h_fun(Series);
     1340        t=struct2xml(Series);
     1341        t=set(t,1,'name','Series');
     1342        save(t,filexml);
     1343        path_uvmat=fileparts(which('uvmat'));
     1344       
     1345        filename_bat=regexprep(filexml,'.xml$','.bat');
     1346        [fid,message]=fopen(filename_bat,'w');
     1347        if isequal(fid,-1)
     1348            msgbox_uvmat('ERROR', ['creation of .bat file: ' message]);
     1349            return
     1350        end
     1351        path_fct=get(handles.ActionPath,'String');
     1352        filelog=regexprep(filexml,'.xml$','.log');
     1353        text_matlabscript=[...
     1354            '#!/bin/bash \n'...
     1355            '. /etc/sysprofile \n'...
     1356            'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'...
     1357            'addpath(''' path_uvmat '''); \n'...
     1358            'addpath(''' Series.Action.ActionPath '''); \n'...
     1359            '' Series.Action.ActionName  '( ''' filexml '''); \n'...
     1360            'exit \n'...
     1361            'END_MATLAB \n'];
     1362        fprintf(fid,text_matlabscript);
     1363        fclose(fid);
     1364        if isunix
     1365            system(['chmod +x ' filename_bat]);% set the file to executable
     1366            system(['. ' filename_bat ' &']);%execute fct
     1367        else
     1368            system(filename_bat);
     1369        end
     1370        end
     1371end
     1372
    13241373set(handles.RUN, 'Enable','On')
    13251374set(handles.RUN,'BackgroundColor',[1 0 0])
     
    13311380set(handles.RUN,'BackgroundColor',[1 0 0])
    13321381set(handles.RUN,'enable','on')
    1333 set(handles.BATCH,'BackgroundColor',[1 0 0])
    1334 set(handles.BATCH,'enable','on')
     1382% set(handles.BATCH,'BackgroundColor',[1 0 0])
     1383% set(handles.BATCH,'enable','on')
    13351384
    13361385%------------------------------------------------------------------------
     
    13381387function BATCH_Callback(hObject, eventdata, handles)
    13391388%------------------------------------------------------------------------   
    1340 set(handles.BATCH, 'Enable','Off')
    1341 set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])
    1342 [h_fun,Series,filexml,errormsg]=prepare_jobs(handles);
    1343 if ~isempty(errormsg)
    1344     msgbox_uvmat('ERROR',errormsg)
    1345     return
    1346 end
    1347 % update the xml file after interactive input with the function
    1348 Series.Specific='?';
    1349 Series=h_fun(Series);   
    1350 t=struct2xml(Series);
    1351 t=set(t,1,'name','Series');
    1352 save(t,filexml);
    1353 path_series=fileparts(which('series'));
    1354 filename_xml=fullfile(Series.OutputDir,[Series.OutputRootFile '.xml']);
    1355 filename_bat=fullfile(Series.OutputDir,[Series.OutputRootFile '.bat']);
    1356 [fid,message]=fopen(filename_bat,'w');
    1357 if isequal(fid,-1)
    1358     msgbox_uvmat('ERROR', ['creation of .bat file: ' message]);
    1359     return
    1360 end
    1361 path_fct=get(handles.ActionPath,'String');
    1362 text_matlabscript=[...
    1363     '#!/bin/bash \n'...
    1364     '. /etc/sysprofile \n'...
    1365     'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n'...
    1366     'cd(''' path_series '''); \n'...
    1367     'addpath(''' path_fct '''); \n'...
    1368     '' Series.Action  '( ''' filename_xml '''); \n'...
    1369     'exit \n'...
    1370     'END_MATLAB \n'];
    1371 fprintf(fid,text_matlabscript);
    1372 fclose(fid);
    1373 if isunix
    1374     system(['chmod +x ' filename_bat]);% set the file to executable
    1375     system(['. ' filename_bat ' &']);%execute fct
    1376 else
    1377     system(filename_bat);
    1378 end
    1379 set(handles.BATCH, 'Enable','On')
    1380 set(handles.BATCH,'BackgroundColor',[1 0 0])
    1381 
    1382 %------------------------------------------------------------------------
    1383 % --- Executes on button press in BIN.
    1384 function BIN_Callback(hObject, eventdata, handles)
    1385 %------------------------------------------------------------------------
    1386     cmd=['#!/bin/bash \n '...
    1387         '#$ -cwd \n '...
    1388         'hostname && date \n '...
    1389         'umask 002 \n'...
    1390         Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' OutputFile '.nc'];
    1391    
     1389
     1390
     1391% %------------------------------------------------------------------------
     1392% % --- Executes on button press in BIN.
     1393% function BIN_Callback(hObject, eventdata, handles)
     1394% %------------------------------------------------------------------------
     1395%     cmd=['#!/bin/bash \n '...
     1396%         '#$ -cwd \n '...
     1397%         'hostname && date \n '...
     1398%         'umask 002 \n'...
     1399%         Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' OutputFile '.nc'];
     1400%     
    13921401%------------------------------------------------------------------------
    13931402% --- Main launch command, called by RUN and BATCH
    13941403function [h_fun,Series,filexml,errormsg]=prepare_jobs(handles,run)
     1404%INPUT:
     1405% handles: handles of graphic objects on the GUI series
     1406% run=0, just to display parameters for MenuExport/GUI config
     1407% run=1 (default) prepare the computation
     1408
    13951409%------------------------------------------------------------------------
    13961410h_fun=[];
     
    15121526    end
    15131527    Series.OutputDirExt=regexprep(SubDirOutNew,Series.OutputSubDir,'');
    1514     Series.OutputSubDir=SubDirOutNew;
    1515     Series.OutputDir=fullfile(Series.InputTable{1,1},Series.OutputSubDir);%directory set for output results
     1528 %   Series.OutputSubDir=SubDirOutNew;
     1529 %   Series.OutputDir=fullfile(Series.InputTable{1,1},Series.OutputSubDir);%directory set for output results
    15161530    Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output
    15171531    set(handles.OutputDirExt,'String',Series.OutputDirExt)
    1518     %removes redondant information
    1519     Series=rmfield(Series,'OutputDirExt');
    1520     Series.IndexRange=rmfield(Series.IndexRange,'TimeTable');
    1521     Series.IndexRange=rmfield(Series.IndexRange,'MinIndex');
    1522     Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex');
    15231532    % create output directory
     1533    OutputDir=fullfile(Series.InputTable{1,1},[Series.OutputSubDir Series.OutputDirExt]);
    15241534    if check_create
    1525         [tild,msg1]=mkdir(Series.OutputDir);
     1535        [tild,msg1]=mkdir(OutputDir);
    15261536        if ~strcmp(msg1,'')
    1527             errormsg=['cannot create ' Series.OutputDir ': ' msg1];%error message for directory creation
     1537            errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation
    15281538            return
    15291539        end
    15301540    end
    1531     filexml=fullfile(Series.OutputDir,[Series.InputTable{1,3} '.xml']);% name of the parameter xml file set in this directory
    1532 %     t=struct2xml(Series);
    1533 %     t=set(t,1,'name','Series');
    1534 %     save(t,filexml);
    1535 end
     1541    filexml=fullfile(OutputDir,[Series.InputTable{1,3} '.xml']);% name of the parameter xml file set in this directory
     1542end
     1543%removes redondant information
     1544Series.IndexRange=rmfield(Series.IndexRange,'TimeTable');
     1545Series.IndexRange=rmfield(Series.IndexRange,'MinIndex');
     1546Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex');
     1547%removes empty lines of InputTable
     1548empty_line=zeros(size(Series.InputTable,1),1);
     1549for iline=1:size(Series.InputTable,1)
     1550    empty_line(iline)=isequal(Series.InputTable(iline,1:3),{'','',''});
     1551end
     1552Series.InputTable(find(empty_line),:)=[];
    15361553
    15371554%------------------------------------------------------------------------
     
    16121629set(handles.VelType_1,'Visible','off');
    16131630set(handles.VelType_text_1,'Visible','off');
    1614 view_FieldMenu(handles,'off')
    1615 view_FieldMenu_1(handles,'off')
     1631set(handles.InputFields,'Visible','off')
     1632set(handles.FieldName_1,'Visible','off')
     1633%view_FieldMenu_1(handles,'off')
    16161634set(handles.FieldTransform,'Visible','off')
    16171635set(handles.CheckObject,'Visible','off');
     
    16191637set(handles.CheckMask,'Visible','off')
    16201638set(handles.Mask,'Visible','off')
    1621 % set(handles.OutputDirExt,'Visible','off');
    1622 % set(handles.ParamKey,'Visible','off')
    1623 % set(handles.ParamVal,'Visible','off')
    1624 ParamKey={};
    1625 set(handles.FieldName,'Enable','off')
    1626 set(handles.VelType,'Enable','off')
    1627 set(handles.FieldName_1,'Enable','off')
    1628 set(handles.VelType_1,'Enable','off')
    1629 set(handles.TransformName,'Enable','off')
    16301639set(handles.OutputDirExt,'Visible','off')
    16311640set(handles.OutputSubDir,'Visible','off')
     
    16491658
    16501659InputTable=get(handles.InputTable,'Data');
    1651 nb_series=size(InputTable,1);
    1652 testima_series=1; %test for a list of images only
    1653 testima=1;
    1654 testima_1=1;
    1655 testciv_series=1;
    1656 for iview=1:nb_series
    1657      ext=InputTable{iview,5};
    1658     if length(ext)<2
    1659         ext='.none';
    1660     end
    1661     testimaview=~isempty(imformats(ext(2:end))) || isequal(lower(ext),'.avi');
    1662     if ~testimaview
    1663         if iview==1
    1664             testima=0;
    1665         end
    1666         if iview==2
    1667             testima_1=0;
    1668         end
    1669         testima_series=0;
    1670     end
    1671 end
     1660nbview=size(InputTable,1);
     1661SeriesData=get(handles.series,'UserData');
     1662nb_civ=numel(find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType)));
     1663nb_netcdf=numel(find(strcmp('netcdf',SeriesData.FileType)));
    16721664for ilist=1:length(varargout)-1
    16731665    switch varargout{ilist}
    1674         case 'NbViewMax'
    1675             if ~isempty (varargout{ilist+1})
    1676                 if size(InputTable,1)>varargout{ilist+1}
    1677                 InputTable=InputTable(1:varargout{ilist+1},:);
    1678                 set(handles.InputTable,'Data',InputTable)
    1679                 end
    1680             end
    16811666        case 'AllowInputSort'
    16821667            if isequal(lower(varargout{ilist+1}),'on')% sort the input table by alphabetical order of the SubDir
    1683                 SeriesData=get(handles.series,'UserData');
    16841668                SeriesData.AllowInputSort=1;
    16851669                set(handles.series,'UserData',SeriesData)
    16861670            end                     
    16871671        case 'WholeIndexRange'
    1688             if isequal(lower(varargout{ilist+1}),'on')% sort the input table by alphabetical order of the SubDir
     1672            if isequal(lower(varargout{ilist+1}),'on')% set by default the input index range from min to max
    16891673                MinIndex=get(handles.MinIndex,'Data');
    16901674                MaxIndex=get(handles.MaxIndex,'Data');
     
    17071691        case 'VelType'   %hidden by default
    17081692             if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two')
    1709                 set(handles.VelType,'Enable','on')
    1710                 if nb_series >=1 && ~testima_series
     1693                if nb_civ>=1
    17111694                    set(handles.VelType,'Visible','on')
    17121695                    set(handles.VelType_text,'Visible','on');
     
    17141697             end
    17151698            if isequal(lower(varargout{ilist+1}),'two')
    1716                 set(handles.VelType_1,'Enable','on')
    1717                 if nb_series >=2 && ~testima_series
     1699                if nb_civ>=2
    17181700                    set(handles.VelType_1,'Visible','on')
    17191701                    set(handles.VelType_text_1,'Visible','on');
     
    17221704        case 'FieldName'   %hidden by default
    17231705            if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two')
    1724                 set(handles.FieldName,'Enable','on') % test for MenuBorser
    1725                 if nb_series >=1 && ~testima_series
    1726                     view_FieldMenu(handles,'on')
     1706                if (nb_civ+nb_netcdf)>=1
     1707                 set(handles.FieldName,'Visible','on') % test for MenuBorser
     1708                 set(handles.InputFields,'Visible','on')
    17271709                end
    17281710            end
    17291711            if isequal(lower(varargout{ilist+1}),'two')
    1730                 set(handles.FieldName_1,'Enable','on')
    1731                 if nb_series >=2 && ~testima_1
    1732                     view_FieldMenu_1(handles,'on')
     1712                if (nb_civ+nb_netcdf)>=1
     1713                set(handles.FieldName_1,'Visible','on')
    17331714                end
    17341715            end
     
    17471728                set(handles.Mask,'Visible','on')
    17481729                 set(handles.CheckMask,'Visible','on');
    1749             end
    1750         case 'PARAMETER'  % NOT USED
    1751             set(handles.PARAMETERS_frame,'Visible','on')
    1752             set(handles.PARAMETERS_title,'Visible','on')
    1753             set(handles.ParamKey,'Visible','on')
    1754             %set(handles.ParamVal,'Visible','on')
    1755             Param_str=varargout{ilist+1};
    1756             Param_list=[Param_list; {Param_str}];   
     1730            end 
    17571731        case 'OutputDirExt'
    17581732            if ~isempty(varargout{ilist+1})
     
    20231997
    20241998% %------------------------------------------------------------------------
    2025 % % --- Executes on button press in REFRESH_INDICES.
     1999% % --- Executes on button press in REFRESH.
    20262000%     function REFRESH_INDICES_Callback(hObject, eventdata, handles)
    20272001% %------------------------------------------------------------------------       
    2028 % % hObject    handle to REFRESH_INDICES (see GCBO)
     2002% % hObject    handle to REFRESH (see GCBO)
    20292003% % eventdata  reserved - to be defined in a future version of MATLAB
    20302004% % handles    structure with handles and user data (see GUIDATA)
    2031 % set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7])
     2005% set(handles.REFRESH,'BackgroundColor',[0.7 0.7 0.7])
    20322006% InputTable=get(handles.InputTable,'Data');
    2033 % check_lines=get(handles.REFRESH_INDICES,'UserData');
     2007% check_lines=get(handles.REFRESH,'UserData');
    20342008%
    20352009% %% check the indices and FileTypes for each series (limited to the new ones to save time)
     
    20862060% set(handles.PairString,'Visible',state_Pairs)
    20872061% enable_j(handles,state_j)
    2088 % set(handles.REFRESH_INDICES,'BackgroundColor',[1 0 0])
    2089 % set(handles.REFRESH_INDICES,'visible','off')
     2062% set(handles.REFRESH,'BackgroundColor',[1 0 0])
     2063% set(handles.REFRESH,'visible','off')
    20902064
    20912065% -----------------------------------------------------------------------
     
    21622136
    21632137%% enable field and veltype menus
    2164 testfield=isequal(get(handles.FieldName,'enable'),'on');
    2165 testfield_1=isequal(get(handles.FieldName_1,'enable'),'on');
    2166 testveltype=isequal(get(handles.VelType,'enable'),'on');
    2167 testveltype_1=isequal(get(handles.VelType_1,'enable'),'on');
    2168 testtransform=isequal(get(handles.TransformName,'Enable'),'on');
     2138% testfield=isequal(get(handles.FieldName,'enable'),'on');
     2139% testfield_1=isequal(get(handles.FieldName_1,'enable'),'on');
     2140% testveltype=isequal(get(handles.VelType,'enable'),'on');
     2141% testveltype_1=isequal(get(handles.VelType_1,'enable'),'on');
     2142% testtransform=isequal(get(handles.TransformName,'Enable'),'on');
    21692143% testnc=0;
    21702144% testnc_1=0;
     
    21972171switch FileType
    21982172    case {'civx','civdata'}
    2199     view_FieldMenu(handles,'on')
     2173    %view_FieldMenu(handles,'on')
    22002174    menustr=get(handles.FieldName,'String');
    22012175    if isequal(menustr,{'get_field...'})
     
    22202194    %     view_FieldMenu_1(handles,'off')
    22212195    case 'netcdf'
    2222     view_FieldMenu(handles,'on')
     2196  %  view_FieldMenu(handles,'on')
    22232197    set(handles.FieldName,'Value',1)
    22242198    set(handles.FieldName,'String',{'get_field...'})
     
    22262200    %     view_TRANSFORM(handles,'off')
    22272201    case {'image','multimage','video'}
    2228     view_FieldMenu(handles,'off')
    2229     view_FieldMenu_1(handles,'off')
     2202%    view_FieldMenu(handles,'off')
     2203 %   view_FieldMenu_1(handles,'off')
    22302204    set(handles.VelType,'Visible','off')
    22312205    set(handles.VelType_text,'Visible','off');
     
    23272301evalin('base','Series') %display CurData in the workspace
    23282302commandwindow; %brings the Matlab command window to the front
     2303
     2304
     2305% --- Executes on selection change in RunMode.
     2306function RunMode_Callback(hObject, eventdata, handles)
  • trunk/src/xml2struct.m

    r471 r472  
    99% filename: name of the xml file
    1010
    11 function s=xml2struct(filename)
     11function [s,Heading]=xml2struct(filename)
    1212t=xmltree(filename);
     13Heading=get(t,1,'name');
    1314ss=convert(t);
    1415s=convert_string(ss);
     
    4041    case 'cell'
    4142        out=[];%default
    42         for ilist=1:numel(ss)
    43             if ~isempty(str2num(ss{ilist}))
    44             out(ilist,:)=str2num(ss{ilist});
     43        if isequal(cellfun(@isnumeric,ss),ones(size(ss)))% if the all the cell content is  numeric
     44            out=cell2mat(ss);
     45        else
     46            for ilist=1:numel(ss)
     47                sep_ind=regexp(ss{ilist},'\s&\s');% check for separator ' & ' which indicates column separation in tables
     48                if ~isempty(sep_ind)
     49                    sep_ind=[-2 sep_ind length(ss{ilist})+1];
     50                    for icolumn=1:length(sep_ind)-1
     51                        out{ilist,icolumn}=ss{ilist}(sep_ind(icolumn)+3:sep_ind(icolumn+1)-1);
     52                    end
     53                else
     54                    out{ilist,1}=ss{ilist}; %reproduce the input string
     55                end
    4556            end
    4657        end
     58%         for ilist=1:numel(ss)
     59%             if ~isempty(str2num(ss{ilist}))
     60%             out(ilist,:)=str2num(ss{ilist});% convert to numeric
     61%             end
     62%         end
    4763    otherwise
    4864        out=ss;
Note: See TracChangeset for help on using the changeset viewer.