Changeset 89 for trunk/src/series.m


Ignore:
Timestamp:
May 20, 2010, 1:48:25 AM (11 years ago)
Author:
sommeria
Message:

many bug corrections and cleaning. Activation of the BW option in uvmat. Improvement of the interaction of get_field with uvmat.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r76 r89  
    430430update_file(hObject, eventdata, handles,fileinput,1)
    431431
    432 % --------------------------------------------------------------------
    433 % refresh the GUI data after introduction of a new file series
     432%------------------------------------------------------------------------
     433% ---  refresh the GUI data after introduction of a new file series
    434434function update_file(hObject, eventdata, handles,fileinput,addtest)
    435 %hseries=get(handles.RootPath,'parent'); 
     435%------------------------------------------------------------------------ 
    436436if ~exist(fileinput,'file')
    437437    msgbox_uvmat('ERROR',['input file ' fileinput  ' does not exist'])
    438438    return
    439439end
    440 hseries=handles.figure1;
     440
    441441% refresh input root name, indices, file extension and nomenclature
    442442[RootPath,RootFile,field_count,str2,str_a,str_b,FileExt,NomType,SubDir]=name2display(fileinput);
     443
    443444%check for movie image files
    444445if ~isempty(FileExt)
    445 if ~isempty(imformats(FileExt(2:end)))
    446     imainfo=imfinfo(fileinput);     
    447     if length(imainfo) >1 %case of image with multiple frames
    448         NomType='*';
    449         [RootPath,RootFile]=fileparts(fileinput);
    450     end
    451 end
     446    if ~isempty(imformats(FileExt(2:end)))
     447        imainfo=imfinfo(fileinput);
     448        if length(imainfo) >1 %case of image with multiple frames
     449            NomType='*';
     450            [RootPath,RootFile]=fileparts(fileinput);
     451        end
     452    end
    452453end
    453454NcType='none';%default
     
    467468set(handles.nb_field2,'Value',1)
    468469if addtest
    469     SeriesData=get(hseries,'UserData');
     470    SeriesData=get(handles.figure1,'UserData');
    470471    SeriesData.displ_num=[0 0 0 0;SeriesData.displ_num];
    471472    SeriesData.CurrentInputFile_1=SeriesData.CurrentInputFile;
     
    520521set(handles.first_j,'String',num2str(ref_j))
    521522set(handles.last_j,'String',num2str(ref_j));
    522 %set(hseries,'UserData',SeriesData);
    523523
    524524%enable other menus and uicontrols
     
    544544FileBase=fullfile(RootPath,RootFile);
    545545
    546 % nb_field{icell,1}='?';%default
    547 % nb_field2{icell,1}='?';%default
    548546testima=0; %test for image input
    549547if isequal(lower(FileExt),'.avi') %.avi file
     
    681679    [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
    682680    time=XmlData.Time;
    683     size(time)
    684     GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
    685     GeometryCalib.Tx=0;
    686     GeometryCalib.Ty=0;
    687     GeometryCalib.Tz=1;
    688     GeometryCalib.dpx=1;
    689     GeometryCalib.dpy=1;
    690     GeometryCalib.sx=1;
    691     GeometryCalib.Cx=0;
    692     GeometryCalib.Cy=0;
    693     GeometryCalib.f=1;
    694     GeometryCalib.kappa1=0;
    695     GeometryCalib.CoordUnit='cm';
    696     XmlData.GeometryCalib=GeometryCalib;
    697681    if error==2, warntext=['no file ' FileBase '.civ'];
    698682    elseif error==1, warntext='inconsistent number of fields in the .civ file';
     
    705689end
    706690
    707 if ~isempty(time)
    708     siztime=size(time);
    709     nb_field=siztime(1);
    710     nb_field2=siztime(2);
    711 end   
     691
     692% if ~isempty(time)
     693%     siztime=size(time);
     694%     nb_field=siztime(1);
     695%     nb_field2=siztime(2);
     696% end   
    712697set(handles.TimeUnit,'String',TimeUnit)
     698%look for max indices
     699if ~strcmp(NomType,'*')
     700    [num_i1,num_i2,num_j1,num_j2]=find_indexseries(fileinput);
     701    nb_field=max(floor((max(num_i1)+max(num_i2))/2));
     702    nb_field2=max(floor((max(num_j1)+max(num_j2))/2));
     703end
    713704if isempty(nb_field)
    714705    nb_field_str='?';
     
    727718set(handles.nb_field,'String',nb_field_cell);
    728719set(handles.nb_field2,'String',nb_field2_cell);
    729 set(hseries,'UserData',SeriesData);
     720set(handles.figure1,'UserData',SeriesData);
    730721
    731722%number of slices
     
    743734NomType_Callback(hObject, eventdata, handles)
    744735
     736%store the root name for future opening of uvmat
    745737dir_perso=prefdir;
    746738profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    747 % save(profil_perso, 'FileBase'); %store the root name for future opening of uvmat
    748739if exist(profil_perso,'file')
    749740    save (profil_perso,'RootPath','SubDir','RootFile','NomType', '-append'); %store the root name for future opening of uvmat
     
    839830NomType_Callback(hObject, eventdata, handles)
    840831
     832%------------------------------------------------------------------------
    841833function NomType_Callback(hObject, eventdata, handles)
     834%------------------------------------------------------------------------
    842835hseries=get(handles.ProjObject,'Parent');
    843836SeriesData=get(hseries,'UserData');
     
    897890                state_j='on';
    898891    end
    899 end  
     892end
    900893if testpair
    901894    mode_Callback(hObject, eventdata, handles) 
    902895else
    903896    set(handles.NomType,'String',NomTypeCell)
    904 end
    905 set(handles.first_j,'Visible',state_j)
    906 set(handles.incr_j,'Visible',state_j)
    907 set(handles.last_j,'Visible',state_j)
    908 set(handles.nb_field2,'Visible',state_j)
     897    set(handles.first_j,'Visible',state_j)
     898    set(handles.incr_j,'Visible',state_j)
     899    set(handles.last_j,'Visible',state_j)
     900    set(handles.nb_field2,'Visible',state_j)
     901end
     902
    909903
    910904%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%????????????
     
    926920    test_find_pair=isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2')|| isequal(NomType,'#_ab');
    927921end
    928 % displ_num=[];%default
    929 % first_i=str2num(get(handles.first_i,'String'));
    930 % last_i=str2num(get(handles.last_i,'String'));
    931922time=[];
    932923if isfield(SeriesData,'Time')
     
    939930if isequal(mode,'bursts')
    940931    enable_i(handles,'On')
    941     enable_j(handles,'Off')   
     932    enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) 
    942933elseif  isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')
    943934    enable_i(handles,'On')
    944     enable_j(handles,'On')
     935    enable_j(handles,'On') % allow both i and j index scanning
    945936else
    946937    enable_i(handles,'On')
     
    993984
    994985%--------------------------------------------------------------
    995 % determine the menu for civ1 pairs depending on existing netcdf file at the middle of
    996 % the field series set by first_i, incr, last_i
     986% determine the menu for civ1 pairs depending on existing netcdf files
     987% with the reference indices ref_i and ref_j
    997988%----------------------------------------------------------------
    998989function find_netcpair_civ(hObject, eventdata, handles,Val)
     
    10871078                displ_num(4,ind_exist)=0;
    10881079                %[cte_detect,vdt,cte_read]=read_netcdf(filename,{'dt','dt2','absolut_time_T0','absolute_time_TO_2'});
    1089                 [Cte,var_detect,ichoice]=nc2struct(nc,{});
     1080                [Cte,var_detect,ichoice]=nc2struct(filename,{});
    10901081                if isfield(Cte,'dt2')
    10911082                    dt=Cte.dt2;
     
    13571348end
    13581349Series.hseries=handles.figure1; % handles to the series GUI
    1359 % if isequal(get(handles.ParamVal,'Visible'),'on')
    1360 %     ParamKey=get(handles.ParamKey,'String');
    1361 %     if ischar(ParamKey)
    1362 %         ParamKey{1}=ParamKey;
    1363 %     end
    1364 %     ParamString=get(handles.ParamVal,'String');
    1365 %     if ischar(ParamString)
    1366 %         for ilist=1:size(ParamString,1)
    1367 %             ParamVal{ilist}=ParamString(ilist,:);
    1368 %         end
    1369 %     else
    1370 %         ParamVal=ParamString;
    1371 %     end   
    1372 % end
    13731350
    13741351%read the set of field numbers
     
    14331410    %case of pairs (.nc files)
    14341411   
    1435     if isequal(NomType{iview},'_i_j1-j2')| isequal(NomType{iview},'_i1-i2_j')| isequal(NomType{iview},'_i1-i2')| isequal(NomType{iview},'#_ab')
     1412    if isequal(NomType{iview},'_i_j1-j2')|| isequal(NomType{iview},'_i1-i2_j')|| isequal(NomType{iview},'_i1-i2')|| isequal(NomType{iview},'#_ab')
    14361413        ind_shift=SeriesData.displ_num(iview,:);
    14371414        if isequal(ind_shift,[0 0 0 0]) % undefined pairs
     
    19281905        end
    19291906
    1930 %----------------------------------------------------
    1931 %  determine the list of index pairs of processing file
    1932 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1907%------------------------------------------------------------------------
     1908% --- determine the list of index pairs of processing file
    19331909function [num_i1,num_i2,num_j1,num_j2,num_i_out,num_j_out]=find_file_indices(num_i,num_j,ind_shift,NomType,mode)
     1910%------------------------------------------------------------------------
    19341911num_i1=num_i;% set of first image numbers by default
    19351912num_i2=num_i;
     
    19381915num_i_out=num_i;
    19391916num_j_out=num_j;
    1940 if isequal (NomType,'_i1-i2_j') |isequal (NomType,'_i1-i2')
     1917if isequal (NomType,'_i1-i2_j') || isequal (NomType,'_i1-i2')
    19411918    num_i1_line=num_i+ind_shift(3);% set of first image numbers
    19421919    num_i2_line=num_i+ind_shift(4);
     
    22112188set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
    22122189
    2213 %-------------------------------------------------------------
    2214 %generates a series of file names with reference numbers between range1 and
    2215 %range2 with increment incr. The reference number num_ref is the image number at the middle of the
    2216 %image pair. The set of first numbers num1 of the image pairs is also
    2217 %given as output
    2218 %------------------------------------------------------
     2190%------------------------------------------------------------------------
     2191% --- generates a series of file names with reference numbers between range1 and
     2192% --- range2 with increment incr. The reference number num_ref is the image number at the middle of the
     2193% --- image pair. The set of first numbers num1 of the image pairs is also
     2194% --- given as output
    22192195function [num_i1,num_i2,num_j1,num_j2,nbmissing]=netseries_generator(filebase,subdir,mode,first_i,incr_i,last_i,first_j,incr_j,last_j)
     2196%------------------------------------------------------------------------
    22202197[Path,Name]=fileparts(filebase);
    22212198filebasesub=fullfile(Path,subdir,Name);
     
    22362213    dirpair=dir([filebasesub '_*-*_*.nc']);
    22372214else
    2238     errordlg('option *|* not yet implemented')
     2215    msgbox_uvmat('ERROR','option *|* not yet implemented')
    22392216    return
    22402217end
    22412218if isempty(dirpair)
    2242         errordlg('no pair detected in the selected range')
     2219        msgbox_uvmat('ERROR','no pair detected in the selected range')
    22432220        return
    22442221end
    2245     %ind0_i=first_i:incr_i:last_i;
    2246     %nbcolumn=length(ind0_i);
    2247     %dirpair=dir([filebasesub '_*_*-*.nc']);
    2248 if isequal(mode,'bursts')|isequal(mode,'#_ab')
     2222
     2223if isequal(mode,'bursts')||isequal(mode,'#_ab')
    22492224    icount=0;
    22502225    for ifile=1:length(dirpair)
    22512226        [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name);
    2252        
    2253 %         if isempty(str2num(str_1))
    2254 %             dirpair(ifile).name
    2255 %         end
    22562227        num1_r=str2num(str_1);
    22572228        if isequal(RootFile,Name) & ~isempty(num1_r)   
     
    22592230            num_a(ifile)=stra2num(str_a);
    22602231            num_b(ifile)=stra2num(str_b);
    2261 %             icount=icount+1;
    22622232        end     
    22632233    end
    2264     length(dirpair)
    2265 %     num_j=floor((num_a+num_b)/2); %list of reference indices of the detected files
    22662234    test_range= (num_i1 >=first_i)&(num_i1<= last_i);% =1 when both numbers are in the range
    22672235    ind_i=((num_i1-first_i)/incr_i)+1;%indices i in the list of prescribed file indices
     
    23092277    num_i1_r=num_i1_r(select);
    23102278    num_i2_r=num_i2_r(select);
    2311 %     num_j=num_j(select);
    23122279    dirpair=dirpair(select);
    23132280    [ind_remove]=find_pairs(dirpair,ind_ij,nbcolumn*nbline) ;
     
    23252292    nbmissing=nbline*nbcolumn-length(ind_ij);
    23262293elseif isequal(mode,'series(Dj)')
    2327  %   ind0_i=first_i:incr_i:last_i;
    2328  %   nbcolumn=length(ind0_i);
    2329  %   ind0_j=first_j:incr_j:last_j;
    2330   %  nbline=length(ind0_j);
    2331   %  dirpair=dir([filebasesub '_*_*-*.nc']);
    23322294    for ifile=1:length(dirpair)
    23332295        [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name);
     
    23622324    num_i2=num_i1;
    23632325    nbmissing=nbline*nbcolumn-length(ind_ij);
    2364 %     for i=1:length(indsel);%A SUPPRIMER ULTERIEUREMENT
    2365 %         if indsel(i)==0
    2366 %             filecell{i}='';
    2367 %         else
    2368 %             Name=dirpair(indsel(i)).name;
    2369 %             filecell{i}=fullfile(Path,subdir,Name);
    2370 %         end
    2371 %     end
    2372 %else
    2373 %    errordlg('option *|* not yet implemented')
    2374 %    return
    2375 end
    2376 
    2377 function path_transform_Callback(hObject, eventdata, handles)
    2378 % hObject    handle to path_transform (see GCBO)
    2379 % eventdata  reserved - to be defined in a future version of MATLAB
    2380 % handles    structure with handles and user data (see GUIDATA)
    2381 
    2382 % Hints: get(hObject,'String') returns contents of path_transform as text
    2383 %        str2double(get(hObject,'String')) returns contents of path_transform as a double
    2384 
    2385 
    2386 % --- Executes during object creation, after setting all properties.
    2387 function path_transform_CreateFcn(hObject, eventdata, handles)
    2388 % hObject    handle to path_transform (see GCBO)
    2389 % eventdata  reserved - to be defined in a future version of MATLAB
    2390 % handles    empty - handles not created until after all CreateFcns called
    2391 
    2392 % Hint: edit controls usually have a white background on Windows.
    2393 %       See ISPC and COMPUTER.
    2394 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    2395     set(hObject,'BackgroundColor','white');
    2396 end
    2397 
    2398 
     2326end
     2327
     2328%------------------------------------------------------------------------
     2329% --- generates series of file indices corresponding to a file fileinput
     2330function [num_i1,num_i2,num_j1,num_j2]=find_indexseries(fileinput)
     2331%------------------------------------------------------------------------
     2332num_i1=NaN;%default
     2333num_i2=NaN;%default
     2334num_j1=NaN;%default
     2335num_j2=NaN;%default
     2336% refresh input root name, indices, file extension and nomenclature
     2337[RootPath,RootFile,field_count,str2,str_a,str_b,FileExt,NomType,SubDir]=name2display(fileinput);
     2338if strcmp(SubDir,'')
     2339    filebasesub=fullfile(RootPath,RootFile);
     2340else
     2341    filebasesub=fullfile(RootPath,SubDir,RootFile);
     2342end
     2343dirpair=[]; %default
     2344switch NomType
     2345    case '_i'
     2346        dirpair=dir([filebasesub '_*' FileExt]);
     2347    case '_i_j'
     2348        dirpair=dir([filebasesub '_*_*' FileExt]);
     2349    case '_i1-i2'
     2350        dirpair=dir([filebasesub '_*-*' FileExt]);
     2351    case '#_ab'
     2352        dirpair=dir([filebasesub '*_*' FileExt]);
     2353    case '_i_j1-j2'
     2354        dirpair=dir([filebasesub '*_*-*' FileExt]);   
     2355    case '_i1-i2_j'
     2356        dirpair=dir([filebasesub '*-*_*' FileExt]);   
     2357end
     2358%       nom_type='#' series of indexed images wich is not series_i
     2359%       [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
     2360%       nom_type='#a','#A' with a numerical index and an index letter(e.g.'aa045b.png'), OBSOLETE (replaced by 'series_i_j')
     2361%       nom_type='%03d' or '%04d', series of indexed images with numbers completed with zeros to 3 or 4 digits, e.g.'aa045.tif'
     2362%       nom_type='_%03d', '_%04d', or '_%05d', series of indexed images with _ and numbers completed with zeros to 3, 4 or 5 digits, e.g.'aa_045.tif'
     2363%       nom_type='raw_SMD', same as '#a' but with no extension ext='', OBSOLETE
     2364%       nom_type='#_ab' from pairs of '#a' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D')
     2365%       nom_type='%3dab' from pairs of '%3da' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D')
     2366for ifile=1:length(dirpair)
     2367    [RootPath,RF,str_1,str_2,str_a,str_b]=name2display(dirpair(ifile).name);
     2368    num_i1(ifile)=str2double(str_1);
     2369    num_i2(ifile)=str2double(str_2);
     2370    if isnan(num_i2(ifile))
     2371        num_i2(ifile)=num_i1(ifile);
     2372    end
     2373    num_j1(ifile)=stra2num(str_a);
     2374    if isnan(num_j1(ifile))
     2375        num_j1(ifile)=1;
     2376    end
     2377    num_j2(ifile)=stra2num(str_b);
     2378    if isnan(num_j2(ifile))
     2379        num_j2(ifile)=num_j1(ifile);
     2380    end
     2381end
     2382
Note: See TracChangeset for help on using the changeset viewer.