Changeset 620 for trunk/src/series.m


Ignore:
Timestamp:
Apr 25, 2013, 10:25:20 PM (8 years ago)
Author:
sommeria
Message:

bugs repaired in series + cleaning.
Introducing of a demo program (test stage)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r615 r620  
    6767
    6868%% initial settings
     69% position and  size of the GUI at opening
    6970set(0,'Unit','points')
    70 ScreenSize=get(0,'ScreenSize');%size of the current screen
     71ScreenSize=get(0,'ScreenSize');%size of the current screen, in points (1/72 inch)
    7172Width=900;% prefered width of the GUI in points (1/72 inch)
    72 Height=624;
     73Height=624;% prefered height of the GUI in points (1/72 inch)
    7374%adjust to screen size (reduced by a min margin)
    7475RescaleFactor=min((ScreenSize(3)-80)/Width,(ScreenSize(4)-80)/Height);
     
    8283LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen
    8384set(hObject,'Units','points')
    84 set(hObject,'Position',[LeftX LowY Width Height])
     85set(hObject,'Position',[LeftX LowY Width Height])% position and size of the GUI at opening
     86
     87% settings of table MinIndex_j
     88set(handles.MinIndex_i,'ColumnFormat',{'numeric'})
     89set(handles.MinIndex_i,'ColumnEditable',false)
     90set(handles.MinIndex_i,'ColumnName',{'i min'})
     91
     92% settings of table MinIndex_j
     93set(handles.MinIndex_j,'ColumnFormat',{'numeric'})
     94set(handles.MinIndex_j,'ColumnEditable',false)
     95set(handles.MinIndex_j,'ColumnName',{'j min'})
     96
     97% settings of table MaxIndex_i
     98set(handles.MaxIndex_i,'ColumnFormat',{'numeric'})
     99set(handles.MaxIndex_i,'ColumnEditable',false)
     100set(handles.MaxIndex_i,'ColumnName',{'i max'})
     101
     102% settings of table MaxIndex_j
     103set(handles.MaxIndex_j,'ColumnFormat',{'numeric'})
     104set(handles.MaxIndex_j,'ColumnEditable',false)
     105set(handles.MaxIndex_j,'ColumnName',{'j max'})
     106
     107% settings of table PairString
    85108set(handles.PairString,'ColumnName',{'pairs'})
    86109set(handles.PairString,'ColumnEditable',false)
    87110set(handles.PairString,'ColumnFormat',{'char'})
    88111set(handles.PairString,'Data',{''})
     112
    89113series_ResizeFcn(hObject, eventdata, handles)%resize table according to series GUI size
    90114set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display)
     115
    91116% check default input data
    92117if ~exist('Param','var')
     
    237262    set(handles.InputTable,'Data',InputTable)
    238263    if isfield(Param,'FileName_1')
    239         display_file_name(handles,Param.FileName_1,0)
    240         display_file_name(handles,Param.FileName,1)
     264        display_file_name(handles,Param.FileName,'one')%refresh the input table
     265        display_file_name(handles,Param.FileName_1,1)
    241266    else
    242         display_file_name(handles,Param.FileName,0)
     267        display_file_name(handles,Param.FileName,'one')%refresh the input table
    243268    end
    244269end 
     
    289314    end
    290315end
    291 fileinput=uigetfile_uvmat('file browser',oldfile);
     316fileinput=uigetfile_uvmat('pick a file to refresh the input table',oldfile);
    292317if ~isempty(fileinput)
    293      display_file_name(handles,fileinput,0)
    294 end
    295 %
    296 % [FileName, PathName] = uigetfile( ...
    297 %        {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)';
    298 %        '*.xml',  '.xml files '; ...
    299 %         '*.xls',  '.xls files '; ...
    300 %         '*.png','.png image files'; ...
    301 %         '*.tif','.tif image files'; ...
    302 %         '*.avi;*.AVI','.avi movie files'; ...
    303 %         '*.nc','.netcdf files'; ...
    304 %         '*.*',  'All Files (*.*)'}, ...
    305 %         'Pick a file',oldfile);
    306 % fileinput=[PathName FileName];%complete file name
    307 % [path,name,ext]=fileparts(fileinput);
    308 % if isequal(ext,'.xml')
    309 %     [Param,Heading]=xml2struct(fileinput);
    310 %     if ~strcmp(Heading,'Series')
    311 %         msg_box_uvmat('ERROR','xml file heading is not <Series>')
    312 %     else
    313 %         fill_GUI(Param,handles.series);%fill the GUI with the parameters retrieved from the xml file
    314 %         if isfield(Param,'CheckObject')&& Param.CheckObject
    315 %             set_object(Param.ProjObject)
    316 %         end
    317 %         set(handles.REFRESH,'UserData',1:size(Param.InputTable,1))
    318 %         REFRESH_Callback([],[], handles)
    319 %         return
    320 %     end
    321 % elseif isequal(ext,'.xls')
    322 %     msg_box_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    323 % else
    324 %     display_file_name(handles,fileinput,0)
    325 % end
     318     display_file_name(handles,fileinput,'one')
     319end
     320
    326321
    327322% --------------------------------------------------------------------
    328323function MenuFile_1_Callback(hObject, eventdata, handles)
    329324fileinput=get(handles.MenuFile_1,'Label');
    330 display_file_name(handles,fileinput,0)
     325display_file_name(handles,fileinput,'one')
    331326
    332327% --------------------------------------------------------------------
    333328function MenuFile_2_Callback(hObject, eventdata, handles)
    334329fileinput=get(handles.MenuFile_2,'Label');
    335 display_file_name(handles,fileinput,0)
     330display_file_name(handles,fileinput,'one')
    336331
    337332% --------------------------------------------------------------------
    338333function MenuFile_3_Callback(hObject, eventdata, handles)
    339334fileinput=get(handles.MenuFile_3,'Label');
    340 display_file_name( handles,fileinput,0)
     335display_file_name( handles,fileinput,'one')
    341336
    342337% --------------------------------------------------------------------
    343338function MenuFile_4_Callback(hObject, eventdata, handles)
    344339fileinput=get(handles.MenuFile_4,'Label');
    345 display_file_name(handles,fileinput,0)
     340display_file_name(handles,fileinput,'one')
    346341
    347342% --------------------------------------------------------------------
    348343function MenuFile_5_Callback(hObject, eventdata, handles)
    349344fileinput=get(handles.MenuFile_5,'Label');
    350 display_file_name(handles,fileinput,0)
     345display_file_name(handles,fileinput,'one')
    351346
    352347% --------------------------------------------------------------------
     
    449444%------------------------------------------------------------------------
    450445InputTable=get(handles.InputTable,'Data');
    451 view_set=get(handles.REFRESH,'UserData');
     446view_set=get(handles.REFRESH,'UserData');% list of lines to refresh
    452447set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH  button to yellow color (indicate activation)
    453448drawnow
     
    462457    end
    463458    if isempty(i1_series)
    464         [FileName, PathName] = uigetfile( ...
    465             {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)';
    466             '*.xml',  '.xml files '; ...
    467             '*.xls',  '.xls files '; ...
    468             '*.png','.png image files'; ...
    469             '*.tif','.tif image files'; ...
    470             '*.avi;*.AVI','.avi movie files'; ...
    471             '*.nc','.netcdf files'; ...
    472             '*.*',  'All Files (*.*)'}, ...
    473             ['unvalid entry at line ' num2str(iview) ', pick a new input file'],RootPath);
    474         fileinput=[PathName FileName];%complete file name
    475         if isempty(fileinput) %abandon if the operation has been cancelled: no input from browser
     459        fileinput=uigetfile_uvmat(['wrong input at line ' num2str(iview) ':pick a new input file'],RootPath);
     460        if isempty(fileinput)
    476461            set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH  back to red color
    477             return;
    478         end
    479         [path,name,ext]=fileparts(fileinput);
    480         display_file_name(handles,fileinput,iview)
     462            return
     463        else
     464            display_file_name(handles,fileinput,iview)
     465        end
    481466    else
    482         update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,FileInfo,MovieObject,iview)
     467       update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,FileInfo,MovieObject,iview)
    483468    end
    484469end
     
    496481% fileinput: input file name, including path
    497482% iview: line index in the input table
     483%       or 'one': refresh the list
     484%       'append': add a new line to the list
    498485
    499486%% get the input root name, indices, file extension and nomenclature NomType
     
    527514%% fill the list of file series
    528515InputTable=get(handles.InputTable,'Data');
     516SeriesData=get(handles.series,'UserData');
    529517if strcmp(iview,'append') % display the input data as a new line in the table
    530      iview=size(InputTable,1);
    531      InputTable(iview+1,:)={'','','','',''};
    532      InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    533 elseif iview==0 % or re-initialise the list of  input  file series
    534     iview=1;
     518    iview=size(InputTable,1);% the next line in InputTable becomes the current line
     519    InputTable(iview+1,:)={'','','','',''};
     520    InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     521elseif strcmp(iview,'one') % refresh the list of  input  file series
     522    iview=1; %the first line in InputTable becomes the current line
    535523    InputTable=[{'','','','',''};{'','','','',''}];
    536      InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    537     set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}])
    538     set(handles.MinIndex,'Data',[{[]},{[]}])
    539     set(handles.MaxIndex,'Data',[{[]},{[]}])
     524    InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     525    set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}])
     526    set(handles.MinIndex_i,'Data',[{[]}])
     527    set(handles.MaxIndex_i,'Data',[{[]}])
     528    set(handles.MinIndex_j,'Data',[{[]}])
     529    set(handles.MaxIndex_j,'Data',[{[]}])
    540530    set(handles.ListView,'Value',1)
    541531    set(handles.ListView,'String',{'1'})
    542 end
    543 nbview=size(InputTable,1);
     532    set(handles.PairString,'Data',{''})
     533    SeriesData.i1_series={};
     534    SeriesData.i2_series={};
     535    SeriesData.j1_series={};
     536    SeriesData.j2_series={};
     537    SeriesData.FileType={};
     538    SeriesData.FileInfo={};
     539    SeriesData.Time={};
     540end
     541nbview=size(InputTable,1)-1;% rmq: the last line is set blank to allow manual addition of a line
    544542set(handles.ListView,'String',mat2cell((1:nbview)',ones(nbview,1)))
    545543set(handles.ListView,'Value',iview)
     
    585583end
    586584% save the opened file to initiate future opening
    587 SeriesData=get(handles.series,'UserData');
    588 SeriesData.RefFile{iview}=fileinput;
     585SeriesData.RefFile{iview}=fileinput;% reference opening file for line iview
     586SeriesData.Ref_i1=i1;
     587SeriesData.Ref_i2=i2;
     588SeriesData.Ref_j1=j1;
     589SeriesData.Ref_j2=j2;
    589590set(handles.series,'UserData',SeriesData)
    590591
     
    599600function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,FileInfo,VideoObject,iview)
    600601%------------------------------------------------------------------------
    601 %% update the output dir
    602602InputTable=get(handles.InputTable,'Data');
    603 SubDir=sort(InputTable(1:end-1,2)); %set of subdirectories sorted in alphabetical order
    604 SubDirOut=SubDir{1};
    605 if numel(SubDir)>1
    606     for ilist=2:numel(SubDir)
    607         SubDirOut=[SubDirOut '-' SubDir{ilist}];
    608     end
    609 end
    610 set(handles.OutputSubDir,'String',SubDirOut)
    611 
    612 %% display the min and max indices for the file series
     603
     604%% display the min and max indices for the whole file series
    613605if size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0
    614606    MinIndex_j=1;% index j set to 1 by default
     
    633625    end
    634626end
    635 MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex
    636 MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex
    637627if isequal(MinIndex_i,-1)
    638628    MinIndex_i=0;
     
    641631    MinIndex_j=0;
    642632end
    643 MinIndex{iview,1}=MinIndex_i;
    644 MinIndex{iview,2}=MinIndex_j;
    645 MaxIndex{iview,1}=MaxIndex_i;
    646 MaxIndex{iview,2}=MaxIndex_j;
    647 
    648 set(handles.MinIndex,'Data',MinIndex)%display the min indices in the table MinIndex
    649 set(handles.MaxIndex,'Data',MaxIndex)%display the max indices in the table MaxIndex
    650 
    651 %% adjust the first and last indices, only if requested by the bounds
     633MinIndex_i_cell=get(handles.MinIndex_i,'Data');%retrieve the min indices in the table MinIndex
     634MinIndex_j_cell=get(handles.MinIndex_j,'Data');%retrieve the min indices in the table MinIndex
     635MaxIndex_i_cell=get(handles.MaxIndex_i,'Data');%retrieve the min indices in the table MinIndex
     636MaxIndex_j_cell=get(handles.MaxIndex_j,'Data');%retrieve the min indices in the table MinIndex
     637MinIndex_i_cell{iview,1}=MinIndex_i;
     638MinIndex_j_cell{iview,1}=MinIndex_j;
     639MaxIndex_i_cell{iview,1}=MaxIndex_i;
     640MaxIndex_j_cell{iview,1}=MaxIndex_j;
     641set(handles.MinIndex_i,'Data',MinIndex_i_cell)%display the min indices in the table MinIndex
     642set(handles.MinIndex_j,'Data',MinIndex_j_cell)%display the max indices in the table MaxIndex
     643set(handles.MaxIndex_i,'Data',MaxIndex_i_cell)%display the min indices in the table MinIndex
     644set(handles.MaxIndex_j,'Data',MaxIndex_j_cell)%display the max indices in the table MaxIndex
     645
     646%% adjust the first and last indices for the selected series, only if requested by the bounds
    652647% i index, compare input to min index i
    653648first_i=str2num(get(handles.num_first_i,'String'));%retrieve previous first i
     
    693688set(handles.num_last_j,'String',num2str(last_j));
    694689
    695 %% read timing and total frame number from the current file (movie files) may be overrid by xml file
     690%% number of slices set by default
     691NbSlice=1;%default
     692% read  value set by the first series for the append mode (iwiew >1)
     693if iview>1 && strcmp(get(handles.num_NbSlice,'Visible'),'on')
     694    NbSlice=str2num(get(handles.num_NbSlice,'String'));
     695end
     696
     697%% default time unit
     698TimeUnit='';
     699% read  value set by the first series for the append mode (iwiew >1)
     700if iview>1
     701    TimeUnit=get(handles.TimeUnit,'String');
     702end
     703TimeSource='';
     704Time=[];%default
     705
     706%%  read image documentation file if found
     707XmlData=[];
     708check_calib=0;
     709XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5});
     710if ~isempty(XmlFileName)
     711    [XmlData,errormsg]=imadoc2struct(XmlFileName);
     712    if ~isempty(errormsg)
     713         msgbox_uvmat('WARNING',['error in reading ' XmlFileName ': ' errormsg]);
     714    end
     715    % read time if available
     716    if isfield(XmlData,'Time')
     717        Time=XmlData.Time;
     718        TimeSource='xml';
     719    end
     720    if isfield(XmlData,'Camera')
     721        if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
     722            if iview>1 && ~isempty(NbSlice) && ~strcmp(NbSlice,XmlData.Camera.NbSlice)
     723                msgbox_uvmat('WARNING','inconsistent number of slices with the first field series');
     724            end
     725            NbSlice=XmlData.Camera.NbSlice;% Nbre of slices from camera
     726        end
     727        if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
     728            if iview>1 && ~isempty(TimeUnit) && ~strcmp(TimeUnit,XmlData.Camera.TimeUnit)
     729                msgbox_uvmat('WARNING','inconsistent time unit with the first field series');
     730            end
     731            TimeUnit=XmlData.Camera.TimeUnit;
     732        end
     733    end
     734    % number of slices
     735    if isfield(XmlData,'GeometryCalib')
     736        check_calib=1;
     737        if isfield(XmlData.GeometryCalib,'SliceCoord')
     738            siz=size(XmlData.GeometryCalib.SliceCoord);
     739            if siz(1)>1
     740                if iview>1 && ~isempty(NbSlice) && ~strcmp(NbSlice,siz(1))
     741                    msgbox_uvmat('WARNING','inconsistent number of Z indices with the first field series');
     742                end
     743                NbSlice=siz(1);
     744            end
     745        end
     746    end
     747    set(handles.num_NbSlice,'String',num2str(NbSlice))
     748end
     749
     750%% read timing and total frame number from the current file (movie files) if not already set by the xml file (prioritary)
    696751InputTable=get(handles.InputTable,'Data');
    697 FileBase=fullfile(InputTable{iview,1},InputTable{iview,3});
    698 Time=[];%default
    699 TimeSource='';
     752% FileBase=fullfile(InputTable{iview,1},InputTable{iview,3});
     753
    700754% case of movies
    701755% if strcmp(InputTable{iview,4},'*')
    702 if ~isempty(VideoObject)
    703     imainfo=get(VideoObject);
    704     if isempty(j1_series); %frame index along i
    705         Time=zeros(imainfo.NumberOfFrames+1,2);
    706         Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
    707     else
    708         Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
    709     end
    710     TimeSource='video';
    711     % set(han:dles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
    712     ColorType='truecolor';
    713 elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image
    714     if ~isempty(InputTable{iview,2})
    715         imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}]));
    716     else
    717         imainfo=imfinfo([FileBase InputTable{iview,5}]);
    718     end
    719     ColorType=imainfo.ColorType;%='truecolor' for color images
    720     if length(imainfo) >1 %case of image with multiple frames
    721         nbfield=length(imainfo);
    722         nbfield_j=1;
    723     end
    724 end
    725 % end
    726 
    727 %%  read image documentation file  if found
    728 XmlData=[];
    729 NbSlice_calib={};
    730 XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5});
    731 TimeUnit='';
    732 if ~isempty(XmlFileName)
    733         [XmlData,warntext]=imadoc2struct(XmlFileName);
    734         if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName)
    735             [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName);
    736         end
    737         if isfield(XmlData,'Time')
    738             Time=XmlData.Time;
    739             TimeSource='xml';
    740         end
    741         if isfield(XmlData,'Camera')
    742             if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
    743                 NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform
    744                 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
    745                     msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');
    746                 end
    747             end
    748             if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
    749                 TimeUnit=XmlData.Camera.TimeUnit;
    750             end
    751         end
    752         if ~isempty(warntext)
    753             msgbox_uvmat('WARNING',warntext)
    754         end 
     756if isempty(Time)
     757    if ~isempty(VideoObject)
     758        imainfo=get(VideoObject);
     759        if isempty(j1_series); %frame index along i
     760            Time=zeros(imainfo.NumberOfFrames+1,2);
     761            Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
     762        else
     763            Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
     764        end
     765        TimeSource='video';
     766        % set(han:dles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
     767        %     ColorType='truecolor';
     768%     elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image
     769%         if ~isempty(InputTable{iview,2})
     770%             imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}]));
     771%         else
     772%             imainfo=imfinfo([FileBase InputTable{iview,5}]);
     773%         end
     774%         %     ColorType=imainfo.ColorType;%='truecolor' for color images
     775% %         if length(imainfo) >1 %case of image with multiple frames
     776% %             nbfield=length(imainfo);
     777% %             nbfield_j=1;
     778% %         end
     779    end
    755780end
    756781
     
    758783if ~isempty(Time)
    759784    TimeTable=get(handles.TimeTable,'Data');
    760     first_i=str2num(get(handles.num_first_i,'String'));
    761     last_i=str2num(get(handles.num_last_i,'String'));
    762     first_j=str2num(get(handles.num_first_j,'String'));
    763     last_j=str2num(get(handles.num_last_j,'String'));
    764     MinIndexTable=get(handles.MinIndex,'Data');
    765     MinIndex_i=MinIndexTable{iview,1};
    766     MinIndex_j=MinIndexTable{iview,2};
    767     MaxIndexTable=get(handles.MaxIndex,'Data');
    768     MaxIndex_i=MaxIndexTable{iview,1};
    769     MaxIndex_j=MaxIndexTable{iview,2};
    770     if ~isempty(Time)
    771         TimeTable{iview,1}=Time(MinIndex_i+1,MinIndex_j+1);
    772         if size(Time)>=[first_i+1 first_j+1]
     785    %     first_i=str2num(get(handles.num_first_i,'String'));
     786    %     last_i=str2num(get(handles.num_last_i,'String'));
     787    %     first_j=str2num(get(handles.num_first_j,'String'));
     788    %     last_j=str2num(get(handles.num_last_j,'String'));
     789    %     MinIndex_i=get(handles.MinIndex_i,'Data');
     790    %     MinIndex_j=get(handles.MinIndex_j,'Data');
     791    %     MaxIndex_i=get(handles.MaxIndex_i,'Data');
     792    %     MaxIndex_j=get(handles.MaxIndex_j,'Data');
     793    TimeTable{iview,1}=Time(MinIndex_i+1,MinIndex_j+1);
     794    if size(Time)>=[first_i+1 first_j+1]
    773795        TimeTable{iview,2}=Time(first_i+1,first_j+1);
    774         end
    775         if size(Time)>=[last_i+1 last_j+1]
    776             TimeTable{iview,3}=Time(last_i+1,last_j+1);
    777         end
    778         if size(Time)>=[MaxIndex_i+1 MaxIndex_j+1];
    779             TimeTable{iview,4}=Time(MaxIndex_i+1,MaxIndex_j+1);
    780         end
     796    end
     797    if size(Time)>=[last_i+1 last_j+1]
     798        TimeTable{iview,3}=Time(last_i+1,last_j+1);
     799    end
     800    if size(Time)>=[MaxIndex_i+1 MaxIndex_j+1];
     801        TimeTable{iview,4}=Time(MaxIndex_i+1,MaxIndex_j+1);
    781802    end
    782803    set(handles.TimeTable,'Data',TimeTable)
    783804end
    784 
    785 %% number of slices
    786 NbSlice=1;%default
    787 check_calib=0;
    788 if isfield(XmlData,'GeometryCalib')
    789     check_calib=1;
    790     if isfield(XmlData.GeometryCalib,'SliceCoord')
    791     siz=size(XmlData.GeometryCalib.SliceCoord);
    792     if siz(1)>1
    793         NbSlice=siz(1);
    794     end
    795     end
    796 end
    797 set(handles.num_NbSlice,'String',num2str(NbSlice))
    798805   
    799 %% update pair menus
    800 set(handles.Pairs,'Visible','on')
    801 set(handles.PairString,'Visible','on')
    802 ListView=get(handles.ListView,'String');
    803 ListView{iview}=num2str(iview);
    804 set(handles.ListView,'String',ListView);
    805 set(handles.ListView,'Value',iview)
    806 update_mode(handles,i1_series,i2_series,j1_series,j2_series,Time)
    807806
    808807%% update the series info in 'UserData'
     
    818817    SeriesData.TimeSource=TimeSource;
    819818end
    820 if ~isempty(TimeUnit)
    821     SeriesData.TimeUnit=TimeUnit;
    822 end
     819% if ~isempty(TimeUnit)
     820%     SeriesData.TimeUnit=TimeUnit;
     821% end
    823822if check_calib
    824 SeriesData.GeometryCalib{iview}=XmlData.GeometryCalib;
     823    SeriesData.GeometryCalib{iview}=XmlData.GeometryCalib;
    825824end
    826825set(handles.series,'UserData',SeriesData)
    827826
     827%% update pair menus
     828ListView=get(handles.ListView,'String');
     829ListView{iview}=num2str(iview);
     830set(handles.ListView,'String',ListView);
     831set(handles.ListView,'Value',iview)
     832update_mode(handles,i1_series,i2_series,j1_series,j2_series,Time)
     833
    828834%% enable j index visibilitycellfun(@isempty,regexp(PairString,'^j'))
    829 % state='off';
    830835check_jindex=~cellfun(@isempty,SeriesData.j1_series); %look for non empty j indices
    831836if isempty(find(check_jindex))
     
    833838else
    834839    PairString=get(handles.PairString,'Data');
    835     if isempty(find(cellfun(@isempty,regexp(PairString,'^j'))))% if all pair string begins by j (burst)
     840    % ~cellfun(@isempty,regexp(PairString,'^j'): gives 1 when the pair string begins by 'j' (burst case)
     841    % cellfun(@isempty,PairString): gives 1 when the pair string is empty
     842    if isempty(find(~cellfun(@isempty,regexp(PairString,'^j'))&cellfun(@isempty,PairString)))% if all pair string begins by j (burst) or empty
    836843        enable_j(handles,'off') % no j index needed
    837844    else
     
    11721179    end
    11731180end
    1174 % if check_burst
    1175 %     enable_i(handles,'On')
    1176 %     enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice)
    1177 % else
    1178 %     enable_i(handles,'On')
    1179 %     if isempty(j1_series)
    1180 %          enable_j(handles,'Off')
    1181 %     else
    1182 %         enable_j(handles,'On')
    1183 %     end
    1184 % end
    11851181fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time)
    11861182ListPairs_Callback([],[],handles)
    11871183
    11881184%--------------------------------------------------------------
    1189 % determine the menu for civ1 pairstring depending on existing netcdf files
     1185% determine the menu for pairstring depending on existing netcdf files
    11901186% with the reference indices num_ref_i and num_ref_j
    11911187%----------------------------------------------------------------
     
    13061302set(handles.num_last_i,'Visible',state)
    13071303set(handles.num_incr_i,'Visible',state)
    1308 % set(handles.num_MaxIndex_i,'Visible',state)
    13091304set(handles.num_ref_i,'Visible',state)
    13101305set(handles.ref_i_text,'Visible',state)
     
    13181313set(handles.num_ref_j,'Visible',state)
    13191314set(handles.ref_j_text,'Visible',state)
    1320 % if strcmp(state,'off')
    1321 %     set(handles.MinIndex,'ColumnName',{'imax'})
    1322 % set(handles.MinIndex,'ColumnEditable',logical(0))
    1323 % else
    1324 %         set(handles.MinIndex,'ColumnName',{'imax','jmax'})
    1325 % end
     1315set(handles.MinIndex_j,'Visible',state)
     1316set(handles.MaxIndex_j,'Visible',state)
    13261317
    13271318
     
    17151706    SubDirOutNew=SubDirOut;
    17161707    SeriesData=get(handles.series,'UserData');
    1717     if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && SeriesData.AllowInputSort
    1718         [tild,iview]=sort(Series.InputTable(:,2)); %subdirectories sorted in alphabetical order
    1719         Series.InputTable=Series.InputTable(iview,:);
    1720     end
     1708%     if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && SeriesData.AllowInputSort
     1709%         [tild,iview]=sort(Series.InputTable(:,2)); %subdirectories sorted in alphabetical order
     1710%         Series.InputTable=Series.InputTable(iview,:);
     1711%     end
    17211712    detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if  the dir  already exist
    17221713    check_create=1; %need to create the result directory by default
     
    17591750end
    17601751Series.IndexRange=rmfield(Series.IndexRange,'TimeTable');
    1761 % Series.IndexRange=rmfield(Series.IndexRange,'MinIndex');
    1762 % Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex');
     1752% Series.IndexRange=rmfield(Series.IndexRange,'MinIndex_j');
     1753% Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex_i');
    17631754empty_line=false(size(Series.InputTable,1),1);
    17641755for iline=1:size(Series.InputTable,1)
     
    17871778ActionList=get(handles.ActionName,'String');% list menu fields
    17881779ActionIndex=get(handles.ActionName,'Value');
    1789 if ~isequal(ActionIndex,1)
     1780if ~isequal(ActionIndex,1)% if we are not just opening series
    17901781    InputTable=get(handles.InputTable,'Data');
    17911782    if isempty(InputTable{1,4})
     
    19181909
    19191910%% Check whether alphabetical sorting of input Subdir is alowed by the Action fct  (for multiples series entries)
    1920 SeriesData.AllowInputSort=0;%default
    1921 if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')
    1922     SeriesData.AllowInputSort=1;
     1911if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')&& size(Series.InputTable,1)>1
     1912    [tild,iview]=sort(InputTable(:,2)); %subdirectories sorted in alphabetical order
     1913    set(handles.InputTable,'Data',InputTable(iview,:));
     1914    MinIndex_i=get(handles.MinIndex_i,'Data');
     1915    MinIndex_j=get(handles.MinIndex_j,'Data');
     1916    MaxIndex_i=get(handles.MaxIndex_i,'Data');
     1917    MaxIndex_j=get(handles.MaxIndex_j,'Data');
     1918    set(handles.MinIndex_i,'Data',MinIndex_i(iview,:));
     1919    set(handles.MinIndex_j,'Data',MinIndex_j(iview,:));
     1920    set(handles.MaxIndex_i,'Data',MaxIndex_i(iview,:));
     1921    set(handles.MaxIndex_j,'Data',MaxIndex_j(iview,:));
     1922    TimeTable=get(handles.TimeTable,'Data');
     1923    set(handles.TimeTable,'Data',TimeTable(iview,:));
     1924    PairString=get(handles.PairString,'Data');
     1925    set(handles.PairString,'Data',PairString(iview,:));
    19231926end
    19241927
    19251928%% Impose the whole input file index range if requested
    19261929if isfield(ParamOut,'WholeIndexRange')&&isequal(ParamOut.WholeIndexRange,'on')
    1927     MinIndex=get(handles.MinIndex,'Data');
    1928     MaxIndex=get(handles.MaxIndex,'Data');
    1929     if ~isempty(MinIndex)
    1930         set(handles.num_first_i,'String',num2str(MinIndex{1}))
    1931         set(handles.num_last_i,'String',num2str(MaxIndex{1}))
    1932         set(handles.num_incr_i,'String','1')
    1933         if size(MinIndex,2)>=2
    1934             set(handles.num_first_j,'String',num2str(MinIndex{1,2}))
    1935             set(handles.num_last_j,'String',num2str(MaxIndex{1,2}))
    1936             set(handles.num_incr_j,'String','1')
    1937         end
    1938     end
    1939 else
    1940 % check index ranges
    1941 first_i=1;last_i=1;first_j=1;last_j=1;
    1942 if isfield(Series.IndexRange,'first_i')
    1943     first_i=Series.IndexRange.first_i;
    1944     incr_i=Series.IndexRange.incr_i;
    1945     last_i=Series.IndexRange.last_i;
    1946 end
    1947 if isfield(Series.IndexRange,'first_j')
    1948     first_j=Series.IndexRange.first_j;
    1949      incr_j=Series.IndexRange.incr_j;
    1950     last_j=Series.IndexRange.last_j;
    1951 end
    1952 if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
    1953     set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
     1930    MinIndex_i=get(handles.MinIndex_i,'Data');
     1931    MinIndex_j=get(handles.MinIndex_j,'Data');
     1932    MaxIndex_i=get(handles.MaxIndex_i,'Data');
     1933    MaxIndex_j=get(handles.MaxIndex_j,'Data');
     1934    set(handles.num_first_i,'String',num2str(MinIndex_i{1}))% set first as the min index (for the first line)
     1935    set(handles.num_last_i,'String',num2str(MaxIndex_i{1}))% set last as the max index (for the first line)
     1936    set(handles.num_incr_i,'String','1')
     1937    set(handles.num_first_j,'String',num2str(MinIndex_j{1}))% set first as the min index (for the first line)
     1938    set(handles.num_last_j,'String',num2str(MaxIndex_j{1}))% set last as the max index (for the first line)
     1939    set(handles.num_incr_j,'String','1')
     1940else  % check index ranges
     1941    first_i=1;last_i=1;first_j=1;last_j=1;
     1942    if isfield(Series.IndexRange,'first_i')
     1943        first_i=Series.IndexRange.first_i;
     1944       % incr_i=Series.IndexRange.incr_i;
     1945        last_i=Series.IndexRange.last_i;
     1946    end
     1947    if isfield(Series.IndexRange,'first_j')
     1948        first_j=Series.IndexRange.first_j;
     1949       % incr_j=Series.IndexRange.incr_j;
     1950        last_j=Series.IndexRange.last_j;
     1951    end
     1952    if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
     1953            set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
    19541954end
    19551955
     
    20472047    set(handles.OutputDirExt,'String',ParamOut.OutputDirExt)
    20482048    OutputDirVisible='on';
     2049    SubDir=InputTable(1:end-1,2); %set of subdirectories sorted in alphabetical order
     2050    SubDirOut=SubDir{1};
     2051    if numel(SubDir)>1
     2052        for ilist=2:numel(SubDir)
     2053            SubDirOut=[SubDirOut '-' SubDir{ilist}];
     2054        end
     2055    end
     2056    set(handles.OutputSubDir,'String',SubDirOut)
    20492057end
    20502058set(handles.OutputDirExt,'Visible',OutputDirVisible)
     
    20552063set(handles.RunMode_title,'Visible',OutputDirVisible)
    20562064set(handles.ActionExt_title,'Visible',OutputDirVisible)
     2065
    20572066
    20582067%% Expected nbre of output files
     
    23892398commandwindow; %brings the Matlab command window to the front
    23902399
    2391 
    23922400% --------------------------------------------------------------------
    23932401function MenuImportConfig_Callback(hObject, eventdata, handles)
     
    24102418function Coord_x_Callback(hObject, eventdata, handles)
    24112419
    2412 
    24132420% --- Executes on selection change in Coord_y.
    24142421function Coord_y_Callback(hObject, eventdata, handles)
    24152422
    2416 
    2417 
     2423% --------------------------------------------------------------------
    24182424% --- Executes when series is resized.
    24192425function series_ResizeFcn(hObject, eventdata, handles)
     2426% --------------------------------------------------------------------
    24202427%% input table
    24212428set(handles.InputTable,'Unit','pixel')
     
    24262433set(handles.InputTable,'ColumnWidth',ColumnWidth)
    24272434
    2428 %% MinIndex and MaxIndex
    2429 set(handles.MinIndex,'Unit','pixel')
    2430 Pos=get(handles.MinIndex,'Position');
    2431 set(handles.MinIndex,'Unit','normalized')
    2432 ColumnWidth=get(handles.MinIndex,'ColumnWidth');
    2433 if numel(ColumnWidth)==2
    2434     ColumnWidth=num2cell(floor([0.5 0.5]*(Pos(3)-20)));
    2435 else
    2436     ColumnWidth={Pos(3)-5};
    2437 end   
    2438 set(handles.MinIndex,'ColumnWidth',ColumnWidth)
    2439 set(handles.MaxIndex,'ColumnWidth',ColumnWidth)
     2435%% MinIndex_j and MaxIndex_i
     2436unit=get(handles.MinIndex_i,'Unit');
     2437set(handles.MinIndex_i,'Unit','pixel')
     2438Pos=get(handles.MinIndex_i,'Position');
     2439set(handles.MinIndex_i,'Unit',unit)
     2440set(handles.MinIndex_i,'ColumnWidth',{Pos(3)-18})
     2441set(handles.MaxIndex_i,'ColumnWidth',{Pos(3)-18})
     2442set(handles.MinIndex_j,'ColumnWidth',{Pos(3)-18})
     2443set(handles.MaxIndex_j,'ColumnWidth',{Pos(3)-18})
    24402444
    24412445%% TimeTable
     
    24432447Pos=get(handles.TimeTable,'Position');
    24442448set(handles.TimeTable,'Unit','normalized')
    2445 ColumnWidth=get(handles.TimeTable,'ColumnWidth');
     2449% ColumnWidth=get(handles.TimeTable,'ColumnWidth');
    24462450ColumnWidth=num2cell(floor([0.25 0.25 0.25 0.25]*(Pos(3)-20)));
    24472451set(handles.TimeTable,'ColumnWidth',ColumnWidth)
Note: See TracChangeset for help on using the changeset viewer.