Changeset 358


Ignore:
Timestamp:
Jan 4, 2012, 12:49:29 PM (9 years ago)
Author:
sommeria
Message:

a few bug corrected in series (still work to do)

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r353 r358  
    213213InputTable=get(handles.InputTable,'Data');
    214214RootPathCell=InputTable(:,1);
    215 SubDirCell=InputTable(:,1);
    216 RootFileCell=InputTable(:,1);
     215SubDirCell=InputTable(:,2);
     216RootFileCell=InputTable(:,3);
    217217%RootPathCell=get(handles.RootPath,'String');
    218218%SubDirCell=get(handles.SubDir,'String'); 
     
    486486if isequal(lower(FileExt),'.avi') %.avi file
    487487    testima=1;
    488 %     info=aviinfo([FileBase FileExt]);
    489 %     time=(0:1/info.FramesPerSecond:(info.NumFrames-1)/info.FramesPerSecond)';
    490 %     num_MaxIndex_i=info.NumFrames;
    491 %     num_MaxIndex_j=1;
    492488elseif ~isempty(imformats(FileExt(2:end)))
    493489    testima=1;
    494 %     if isequal(NomType,'*')% multi-frame image
    495 %         imainfo=imfinfo([FileBase FileExt]);     
    496 %         if length(imainfo) >1 %case of image with multiple frames
    497 %             num_MaxIndex_i=length(imainfo);
    498 %             num_MaxIndex_j=1;
    499 %         end
    500 %     end
    501490elseif isequal(FileExt,'.vol')
    502491     testima=1;
     
    507496% insert the current file series at the head of the list
    508497InputTable=get(handles.InputTable,'Data');
    509 if addtest
    510 %     SeriesData=get(handles.series,'UserData');
    511 %   %  SeriesData.displ_num=[0 0 0 0;SeriesData.displ_num];
    512 %     SeriesData.CurrentInputFile_1=SeriesData.CurrentInputFile;
    513 %     SeriesData.i1_series=[SeriesData.i1_series;{i1_series}];
    514 %     SeriesData.i2_series=[SeriesData.i2_series;{i2_series}];
    515 %     SeriesData.j1_series=[SeriesData.j1_series;{j1_series}];
    516 %     SeriesData.j2_series=[SeriesData.j2_series;{j2_series}];
    517 InputTable=get(handles.InputTable,'Data');
    518  InputTable=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt};InputTable];
    519 %     RootPathCell=[{RootPath}; InputTable{] ;
    520 %     SubDirCell=[{SubDir}; get(handles.SubDir,'String')];
    521 %     RootFileCell=[{RootFile}; get(handles.RootFile,'String')];
    522 %     NomTypeCell=[{NomType}; SeriesData.NomType];
    523 %     FileExtCell=[{FileExt}; get(handles.FileExt,'String')];
    524 %     FileTypeCell=[{FileType};SeriesData.FileType];
    525 %     set(handles.NomType,'String',[{};get(handles.NomType,'String')])
    526    
    527 % or re-initialise the list of  input  file series   
    528 else
    529     InputTable=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     498if addtest %insert the new data at the first line of the table
     499     val=size(InputTable,1)+1;
     500     InputTable(val,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     501    check_lines=get(handles.REFRESH_INDICES,'UserData');
     502else % or re-initialise the list of  input  file series
     503    val=1;
     504    InputTable=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]
     505    set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}])
     506    set(handles.MinIndex,'Data',[{[]},{[]}])
     507    set(handles.MaxIndex,'Data',[{[]},{[]}])
    530508end
    531509set(handles.InputTable,'Data',InputTable)
    532 %     SeriesData=[];%re-initialisation
    533 %  %   SeriesData.displ_num=[0 0 0 0];
    534 % %     SeriesData.i1_series={i1_series};
    535 % %     SeriesData.i2_series={i2_series};
    536 % %     SeriesData.j1_series={j1_series};
    537 % %     SeriesData.j2_series={j2_series};
    538 %     RootPathCell={RootPath};
    539 %     SubDirCell={SubDir};
    540 %     RootFileCell={RootFile};   
    541 %     NomTypeCell={NomType};
    542 %     FileExtCell={FileExt};   
    543 % %    FileTypeCell={FileType};
    544 % end
    545 % SeriesData.NomType=NomTypeCell;
    546 %SeriesData.FileType=FileTypeCell;
    547 SeriesData.CurrentInputFile=fileinput;
    548 % set(handles.RootPath,'String',RootPathCell);
    549 % set(handles.SubDir,'String',SubDirCell);
    550 % set(handles.RootFile,'String',RootFileCell);
    551 % set(handles.NomType,'String',NomTypeCell);
    552 % set(handles.FileExt,'String',FileExtCell);
    553 %set(handles.InputTable,'Data',[RootPathCell SubDirCell RootFileCell NomTypeCell FileExtCell]) ;
    554 update_indices(handles,fileinput,1)
    555 
    556 
    557 % %% display times
    558 % if addtest
    559 %     SeriesData.Time=[{time} SeriesData.Time];
    560 % else
    561 %    SeriesData.Time={time};
    562 % end
    563 % set(handles.TimeUnit,'String',TimeUnit)
    564 % set(handles.series,'UserData',SeriesData);
    565 % time_display=[time(MinIndex_i,MinIndex_j) time(ref_i,ref_j) time(ref_i,ref_j) time(MaxIndex_i,MaxIndex_j);...
    566 %     time(MinIndex_i,MinIndex_j) time(ref_i,ref_j) time(ref_i,ref_j) time(MaxIndex_i,MaxIndex_j)];
    567 % set(handles.time_table,'Data',time_display)
    568 
    569 
     510check_lines(val)=1; %select the edited line for refresh
     511set(handles.REFRESH_INDICES,'UserData',check_lines);
     512REFRESH_INDICES_Callback([],[], handles)
    570513
    571514%store the root name for future opening of uvmat
     
    677620% handles    structure with handles and user data (see GUIDATA)
    678621eventdata
    679 list_lines=get(handles.REFRESH_INDICES,'UserData');
    680 list_lines(eventdata.Indices(1))=1; %select the edited line for refresh
    681 set(handles.REFRESH_INDICES,'UserData',list_lines);
     622check_lines=get(handles.REFRESH_INDICES,'UserData');
     623check_lines(eventdata.Indices(1))=1; %select the edited line for refresh
     624set(handles.REFRESH_INDICES,'UserData',check_lines);
    682625set(handles.REFRESH_INDICES,'Visible','on')
    683626
     
    692635        mode_value=get(handles.mode,'Value');
    693636        mode=mode_list{mode_value};
    694         NomType=[];
     637%         NomType=[];
    695638        % test_find_pair=0;
    696639        % if isfield(SeriesData,'NomType')
    697         NomTypeCell=SeriesData.NomType;
    698         Val=get(handles.NomType,'Value');
    699         NomType=NomTypeCell{Val};
    700         check_pairs=~isempty(SeriesData.i2_series{Val})||~isempty(SeriesData.j2_series{Val});
     640%         NomTypeCell=SeriesData.NomType;
     641%         Val=get(handles.NomType,'Value');
     642%         NomType=NomTypeCell{Val};
     643% check_pairs=0;
     644% for
     645%         check_pairs=~isempty(SeriesData.i2_series{Val})||~isempty(SeriesData.j2_series{Val});
    701646       
    702647        time=[];
     
    704649            time=SeriesData.Time{1}; %get the set of times
    705650        end
    706         siztime=size(time);
    707         nbfield=siztime(1);
    708         nbfield2=siztime(2);
     651%         siztime=size(time);
     652%         nbfield=siztime(1);
     653%         nbfield2=siztime(2);
    709654        % indchosen=1;  %%first pair selected by default
    710655        if isequal(mode,'bursts')
    711656            enable_i(handles,'On')
    712657            enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice)
    713         elseif  ~isempty(SeriesData.j2_series{Val})
    714             enable_i(handles,'On')
    715             enable_j(handles,'On') % allow both i and j index scanning
     658%         elseif  ~isempty(SeriesData.j2_series{Val})
     659%             enable_i(handles,'On')
     660%             enable_j(handles,'On') % allow both i and j index scanning
    716661        else
    717662            enable_i(handles,'On')
     
    719664        end
    720665        % set(handles.list_pair_civ,'Value',indchosen);%set the default choice of image pairs for civ1
    721         set(handles.series,'UserData',SeriesData)
     666%         set(handles.series,'UserData',SeriesData)
    722667       
    723668        %list pairs if relevant
    724         if check_pairs
    725             find_netcpair_civ(handles,Val)
    726         end
     669%         if check_pairs
     670            find_netcpair_civ(handles)
     671%         end
    727672
    728673%-------------------------------------
     
    732677set(handles.num_last_i,'Visible',state)
    733678set(handles.num_incr_i,'Visible',state)
    734 set(handles.num_MaxIndex_i,'Visible',state)
     679% set(handles.num_MaxIndex_i,'Visible',state)
    735680set(handles.ref_i,'Visible',state)
    736681set(handles.ref_i_text,'Visible',state)
     
    739684function enable_j(handles,state)
    740685set(handles.j_txt,'Visible',state)
    741 set(handles.num_MinIndex_j,'Visible',state)
     686% set(handles.num_MinIndex_j,'Visible',state)
    742687set(handles.num_first_j,'Visible',state)
    743688set(handles.num_last_j,'Visible',state)
    744689set(handles.num_incr_j,'Visible',state)
    745 set(handles.num_MaxIndex_j,'Visible',state)
     690% set(handles.num_MaxIndex_j,'Visible',state)
    746691set(handles.ref_j,'Visible',state)
    747692set(handles.ref_j_text,'Visible',state)
     
    768713% with the reference indices ref_i and ref_j
    769714%----------------------------------------------------------------
    770 function find_netcpair_civ(handles,Val)
     715function find_netcpair_civ(handles)
    771716SeriesData=get(handles.series,'UserData');
    772717% NomTypeCell=get(handles.NomType,'String');
    773 NomTypeCell=SeriesData.NomType;
    774 NomType=NomTypeCell{Val};
     718% NomTypeCell=SeriesData.NomType;
     719% NomType=NomTypeCell{Val};
    775720
    776721set(handles.Pairs,'Visible','on')% makes the panel "Pairs' visible
    777722%nomenclature types
    778 RootPathCell=get(handles.RootPath,'String');
    779 filepath=RootPathCell{Val};
    780 RootFileCell=get(handles.RootFile,'String');
    781 filename=RootFileCell{Val};
    782 filebase=fullfile(filepath,filename);
    783 SubDirCell=get(handles.SubDir,'String');
    784 subdir=SubDirCell{Val};
    785 if ~exist(fullfile(filepath,subdir),'dir')
    786          msgbox_uvmat('ERROR',['no civ file available: subdirectory ' subdir ' does not exist'])
    787          set(handles.list_pair_civ,'String',{''});
    788          return
    789 end
     723% RootPathCell=get(handles.RootPath,'String');
     724% filepath=RootPathCell{Val};
     725% RootFileCell=get(handles.RootFile,'String');
     726% filename=RootFileCell{Val};
     727% filebase=fullfile(filepath,filename);
     728% SubDirCell=get(handles.SubDir,'String');
     729% subdir=SubDirCell{Val};
     730% if ~exist(fullfile(filepath,subdir),'dir')
     731%          msgbox_uvmat('ERROR',['no civ file available: subdirectory ' subdir ' does not exist'])
     732%          set(handles.list_pair_civ,'String',{''});
     733%          return
     734% end
    790735mode_list=get(handles.mode,'String');
    791736mode_value=get(handles.mode,'Value');
     
    811756
    812757%% NEW
     758for Val=1:numel(SeriesData.i1_series)
     759   
    813760i1_series=SeriesData.i1_series{Val};
    814761i2_series=SeriesData.i2_series{Val};
     
    869816    end
    870817end
    871 
     818end
    872819%% display list of pairs
    873820displ_pair_list=get(handles.list_pair_civ,'String');
     
    18691816last_i=str2num(get(handles.num_last_i,'String'));
    18701817last_j=str2num(get(handles.num_last_j,'String'));
    1871 NomType=SeriesData.NomType;
     1818InputTable=get(handles.InputTable,'Data');
     1819NomType=InputTable(:,4);
     1820% NomType=SeriesData.NomType;
    18721821mode_list=get(handles.mode,'String');
    18731822index_mode=get(handles.mode,'Value');
     
    22442193
    22452194% --- Executes on button press in REFRESH_INDICES.
    2246 function REFRESH_INDICES_Callback(hObject, eventdata, handles)
     2195
     2196   
     2197    function REFRESH_INDICES_Callback(hObject, eventdata, handles)
    22472198% hObject    handle to REFRESH_INDICES (see GCBO)
    22482199% eventdata  reserved - to be defined in a future version of MATLAB
     
    22502201set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7])
    22512202InputTable=get(handles.InputTable,'Data');
    2252 list_lines=get(handles.REFRESH_INDICES,'UserData');
     2203check_lines=get(handles.REFRESH_INDICES,'UserData');
    22532204
    22542205%% check the indices and FileTypes for each series (limited to the new ones to save time)
    2255 for ind_list=1:length(list_lines)
    2256     if list_lines(ind_list)
    2257         InputLine=InputTable(list_lines(ind_list),:);
     2206for ind_list=1:length(check_lines)
     2207    if  check_lines(ind_list)
     2208        InputLine=InputTable(ind_list,:);
    22582209        detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data)
    2259         if ~isempty(detect_idem)&& list_lines(ind_list)>1
    2260             InputLine{detect_idem}=InputTable(list_lines(ind_list)-1,detect_idem);
     2210        detect_idem=detect_idem(detect_idem>0);
     2211        if ~isempty (detect_idem)
     2212            InputLine(detect_idem)=InputTable(ind_list-1,detect_idem);
    22612213            set(handles.InputTable,'Data',InputTable)
    22622214        end
    2263         fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2});
     2215        fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2);
     2216        %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2})
    22642217        %update file series defined by the selected line
    2265         [InputTable{list_lines(ind_list),1},InputTable{list_lines(ind_list),2},InputTable{list_lines(ind_list),4},errormsg]=update_indices(handles,fileinput,list_lines(ind_list));
     2218        [InputTable{ind_list,1},InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list);
    22662219        if ~isempty(errormsg)
    22672220                msgbox_uvmat('ERROR',errormsg)
     
    22762229state_Pairs='off';
    22772230state_InputFields='off';
     2231val=get(handles.ListView,'Value');
     2232ListViewString={''};
    22782233if ~isempty(SeriesData)
    2279 for ilist=1:size(InputTable,1)
    2280     SeriesData.j1_series{ilist}
    2281     if ~isempty(SeriesData.j1_series{ilist})
    2282         state_j='on';
    2283     end
    2284     if ~isempty(SeriesData.i2_series{ilist})||~isempty(SeriesData.j2_series{ilist})
    2285          state_Pairs='on';
    2286     end
    2287     if strcmp(SeriesData.FileType,'civx')||strcmp(SeriesData.FileType,'civdata')
    2288         state_InputFields='on';
    2289     end
    2290 end
    2291 end
    2292 set(handles.num_first_j,'Visible',state_j)
    2293 set(handles.num_last_j,'Visible',state_j)
    2294 set(handles.num_incr_j,'Visible',state_j)
     2234%     ListViewString={};
     2235    for ilist=1:size(InputTable,1)
     2236        if ~isempty(SeriesData.j1_series{ilist})
     2237            state_j='on';
     2238        end
     2239        if ~isempty(SeriesData.i2_series{ilist})||~isempty(SeriesData.j2_series{ilist})
     2240            state_Pairs='on';
     2241            ListViewString{ilist}=num2str(ilist);
     2242            if check_lines(ilist)
     2243                val=ilist;%select the last pair if it is a new entry
     2244            end
     2245        end
     2246        if strcmp(SeriesData.FileType,'civx')||strcmp(SeriesData.FileType,'civdata')
     2247            state_InputFields='on';
     2248        end
     2249    end
     2250end
     2251set(handles.ListView,'Value',val)
     2252set(handles.ListView,'String',ListViewString)
     2253if strcmp(state_Pairs,'on')
     2254    ListView_Callback(hObject,eventdata,handles)
     2255end
    22952256set(handles.Pairs,'Visible',state_InputFields)
    2296 
     2257enable_j(handles,state_j)
    22972258set(handles.REFRESH_INDICES,'BackgroundColor',[1 0 0])
    22982259set(handles.REFRESH_INDICES,'visible','off')
    22992260
    23002261% update min and max indices for a series
    2301 function [RootPath,RootFile,NomType,errormsg]=update_indices(handles,fileinput,index)
     2262function [RootPath,RootFile,NomType,errormsg]=update_indices(handles,fileinput,iview)
    23022263
    23032264%% look for min and max indices existing in the file series and update SeriesData
     
    23052266[RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(fileinput);
    23062267if isempty(RootFile)&&isempty(i1_series)
    2307     errormsg='not input file in the series';
     2268    errormsg='no input file in the series';
    23082269    return
    23092270end
     
    23242285    MaxIndex_j=max(j1_series(j1_series>0));
    23252286end
    2326 MinIndex{index,1}=MinIndex_i;
    2327 MinIndex{index,2}=MinIndex_j;
    2328 MaxIndex{index,1}=MaxIndex_i;
    2329 MaxIndex{index,2}=MaxIndex_j;
     2287MinIndex{iview,1}=MinIndex_i;
     2288MinIndex{iview,2}=MinIndex_j;
     2289MaxIndex{iview,1}=MaxIndex_i;
     2290MaxIndex{iview,2}=MaxIndex_j;
    23302291set(handles.MinIndex,'Data',MinIndex)
    23312292set(handles.MaxIndex,'Data',MaxIndex)
    23322293SeriesData=get(handles.series,'UserData');
    2333 SeriesData.i1_series{index}=i1_series;
    2334 SeriesData.i2_series{index}=i2_series;
    2335 SeriesData.j1_series{index}=j1_series;
    2336 SeriesData.j2_series{index}=j2_series;
    2337 SeriesData.FileType{index}=FileType;
     2294SeriesData.i1_series{iview}=i1_series;
     2295SeriesData.i2_series{iview}=i2_series;
     2296SeriesData.j1_series{iview}=j1_series;
     2297SeriesData.j2_series{iview}=j2_series;
     2298SeriesData.FileType{iview}=FileType;
    23382299
    23392300%% represents the set of existing files as an image
     
    25122473% end
    25132474% show index pairs if files exist
    2514 if isfield(SeriesData,'j1_series')&&(~isempty(SeriesData.i2_series{index})||~isempty(SeriesData.j2_series{index}))
    2515     testpair=1;
    2516     if ~isempty(SeriesData.i2_series{index}) %pairs with i index
    2517         set(handles.mode,'Value',1)
    2518         set(handles.mode,'String',{'series(Di)'})
    2519     else  %pairs with j index
    2520         set(handles.mode,'Value',1)
    2521         set(handles.mode,'String',{'bursts';'series(Dj)'})
    2522         if nbfield2>10 || nbfield==1
    2523             set(handles.mode,'Value',2);
    2524         else
    2525             set(handles.mode,'Value',1);
    2526         end
    2527     end
    2528     set(handles.mode,'Visible','on')
    2529 else
    2530     set(handles.mode,'Visible','off')
    2531 end
    2532 % if ~isempty(NomTypeCell)
    2533 %     NomType=NomTypeCell{Val};
    2534 %     switch NomType 
    2535 %             case {'_1-2_1', '_1-2'}
    2536 %                 set(handles.mode,'String',{'series(Di)'})
    2537 %                 set(handles.mode,'Value',1);
    2538 %                 set(handles.mode,'Visible','on')
    2539 %                 testpair=1;
    2540 %             case {'#_ab'}
    2541 %                 set(handles.mode,'String',{'bursts'})
    2542 %                 set(handles.mode,'Value',1);
    2543 %                 testpair=1;
    2544 %             case '_1_1-2'
    2545 %                 set(handles.mode,'String',{'bursts';'series(Dj)'})%multiple choice
    2546 %                 if ~isempty(nbfield) && ~isempty(nbfield2) && ((nbfield2>10) || (nbfield==1))
    2547 %                     set(handles.mode,'Value',2);
    2548 %                 else
    2549 %                     set(handles.mode,'Value',1);% advice 'bursts' for small bursts
    2550 %                 end
    2551 %                 set(handles.mode,'Visible','on')
    2552 %                 testpair=1;
    2553 %     end
    2554 %     switch NomType   
    2555 %             case {'_1_1','_1_1-2','_1-2_1','1_ab','01_ab'},% two navigation indices
    2556 %                 state_j='on';
    2557 %     end
    2558 % end
    25592475set(handles.series,'UserData',SeriesData)
    2560 if testpair
    2561     mode_Callback([],[], handles) 
    2562 else
    2563 %     set(handles.NomType,'String',NomTypeCell)
    2564 %     set(handles.j_txt,'Visible',state_j)
    2565 %     set(handles.num_MinIndex_j,'Visible',state_j)
    2566 %     set(handles.num_first_j,'Visible',state_j)
    2567 %     set(handles.num_incr_j,'Visible',state_j)
    2568 %     set(handles.num_last_j,'Visible',state_j)
    2569 %     set(handles.num_MaxIndex_j,'Visible',state_j)
    2570 end
     2476
    25712477
    25722478
     
    26072513
    26082514
     2515% --- Executes on selection change in txt_Pairs
     2516function txt_Pairs_Callback(hObject, eventdata, handles)
     2517
     2518%------------------------------------------------------------------------
     2519% --- Executes on selection change in ListView.
     2520function ListView_Callback(hObject, eventdata, handles)
     2521%------------------------------------------------------------------------   
     2522ListViewString=get(handles.ListView,'String');
     2523if isempty(ListViewString)
     2524    ListViewString={''};
     2525end
     2526ListViewValue=get(handles.ListView,'Value');
     2527View=str2double(ListViewString{ListViewValue});
     2528if isnan(View)
     2529    set(handles.Pairs,'Visible','off')
     2530else
     2531    set(handles.Pairs,'Visible','on')
     2532    SeriesData=get(handles.series,'UserData');
     2533    if isfield(SeriesData,'j1_series')&&(~isempty(SeriesData.i2_series{View})||~isempty(SeriesData.j2_series{View}))
     2534        if ~isempty(SeriesData.i2_series{View}) %pairs with i View
     2535            set(handles.mode,'Value',1)
     2536            set(handles.mode,'String',{'series(Di)'})
     2537        else  %pairs with j View
     2538            nbfield=size(SeriesData.j2_series{View},1);
     2539            nbfield2=size(SeriesData.j2_series{View},2);
     2540            set(handles.mode,'Value',1)
     2541            set(handles.mode,'String',{'bursts';'series(Dj)'})
     2542            if nbfield2>10 || nbfield==1
     2543                set(handles.mode,'Value',2);
     2544            else
     2545                set(handles.mode,'Value',1);
     2546            end
     2547        end
     2548    end
     2549    mode_Callback([],[], handles)
     2550end
     2551
     2552   
Note: See TracChangeset for help on using the changeset viewer.