Changeset 343 for trunk/src


Ignore:
Timestamp:
Dec 21, 2011, 10:12:13 AM (13 years ago)
Author:
sommeria
Message:

-bugs repaired in civ
-change in find_file_series to account for possible file index 0
-name2display suppressed in all functions, replaced by fileparts_uvmat (except incorporated in civ_3D)
-open_uvmat introduced to open files from a list

Location:
trunk/src
Files:
1 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r339 r343  
    2323%TODO: search range
    2424
    25 % Last Modified by GUIDE v2.5 04-Dec-2011 18:52:13
     25% Last Modified by GUIDE v2.5 21-Dec-2011 00:34:49
    2626% Begin initialization code - DO NOT EDIT
    2727gui_Singleton = 1;
     
    119119function MenuBrowse_Callback(hObject, eventdata, handles)
    120120%------------------------------------------------------------------------
    121 %get the current input root file name to initiate the browser
     121%% get the current input root file name to initiate the browser
    122122filebase=get(handles.RootName,'String');
    123123oldfile=''; %default
     
    137137    oldfile=filebase;
    138138end
    139 ind_opening=1;%default
    140 browse.incr_pair=[0 0]; %default
     139% ind_opening=1;%default
     140% browse.incr_pair=[0 0]; %default
     141%% get the new input fiel with the browser
    141142menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)';
    142143    '*.xml',  '.xml files '; ...
     
    153154if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    154155
    155 %% prepare the GUI with parameters from the input file if opened from uvmat
    156 errormsg=display_file_name(handles,fileinput);
    157 if ~isempty(errormsg)
    158     msgbox_uvmat('ERROR',erromsg)
    159 end
    160 
     156%% case of the xml file opened as input (TODO: check and see whether it is useful)
    161157[path,name,ext]=fileparts(fileinput);
    162158testeditxml=0;
     
    186182[~,~,~,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput);
    187183% filebase=fullfile(RootPath,RootFile);
    188 if isempty(i1),i1=1;end
    189 if isempty(i2),i2=i1;end
    190 if isempty(j1),j1=1;end
    191 if isempty(j2),j2=j1;end
    192 if isequal(get(handles.ListCompareMode,'Value'),1)
    193     browse=[];%initialisation
    194 else
    195     browse=get(handles.RootName,'UserData');
    196 end
    197 browse.num_i1=i1;
    198 browse.num_i2=i2;
    199 browse.num_j1=j1;
    200 browse.num_j2=j2;
    201 if length(FileExt)>1 && (~isempty(imformats(FileExt(2:end)))||strcmpi(FileExt,'.avi'));%if an image file has been opened by uvmat
    202     browse.nom_type_ima=NomType;
    203     browse.ext_ima=FileExt;
    204     set(handles.ImaExt,'String',FileExt)
    205 end
    206 set(handles.ImaDoc,'String',FileExt);
    207 
    208 set(handles.RootName,'UserData',browse);% store information from browser
     184
     185%% record the information obtained from the input file
     186% if isempty(i1),i1=1;end
     187% if isempty(i2),i2=i1;end
     188% if isempty(j1),j1=1;end
     189% if isempty(j2),j2=j1;end
     190% if isequal(get(handles.ListCompareMode,'Value'),1)
     191%     browse=[];%initialisation
     192% else
     193%     browse=get(handles.RootName,'UserData');
     194% end
     195% browse.num_i1=i1;
     196% browse.num_i2=i2;
     197% browse.num_j1=j1;
     198% browse.num_j2=j2;
     199% if length(FileExt)>1 && (~isempty(imformats(FileExt(2:end)))||strcmpi(FileExt,'.avi'));%if an image file has been opened by uvmat
     200%     browse.nom_type_ima=NomType;
     201%     browse.ext_ima=FileExt;
     202%     set(handles.ImaExt,'String',FileExt)
     203% end
     204% set(handles.RootName,'UserData',browse);% store information from browser
     205
     206%% prepare the GUI with parameters from the input file
     207errormsg=display_file_name(handles,fileinput);
     208if ~isempty(errormsg)
     209    msgbox_uvmat('ERROR',erromsg)
     210end
     211
    209212
    210213%------------------------------------------------------------------------
     
    332335nom_type_ima='';%default
    333336nom_type_nc='';
    334 [RootPath,RootFile,i1_str,i2_str,j1_str,j2_str,ext_input,nom_type_input,subdir]=name2display(fileinput);
    335 %[RootPath,subdir,RootFile,i1,i2,j1,j2,ext_input,nom_type_input]=fileparts_uvmat(fileinput);TODO: use to replace name2display
     337%[RootPath,RootFile,i1_str,i2_str,j1_str,j2_str,ext_input,nom_type_input,SubDir]=name2display(fileinput);
     338[RootPath,SubDir,RootFile,i1,i2,j1,j2,ext_input,nom_type_input]=fileparts_uvmat(fileinput);
    336339RootName=fullfile(RootPath,RootFile);
    337340set(handles.RootName,'String',RootName)
    338341set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    339 i1=str2double(i1_str);
    340 i2=str2double(i2_str);
    341 j1=str2double(j1_str);
    342 j2=str2double(j2_str);
     342% i1=str2double(i1_str);
     343% i2=str2double(i2_str);
     344% j1=str2double(j1_str);
     345% j2=str2double(j2_str);
    343346num_ref_i=i1;%efaulmt ref index
    344347num_ref_j=j1;
     
    350353    ext_ima=ext_input;
    351354    nom_type_ima=nom_type_input;
     355    imagename=fileinput;
    352356else %case of netcdf input file, look for corresponding images
    353357    nom_type_nc=nom_type_input;
     358    imagename=name_generator(fullfile(RootPath,RootFile),1,1,ext_ima,nom_type_ima);
     359    i1_str='';
     360    j1_str='';
    354361    if ~isnan(i2)
    355362        num_ref_i=floor((num_ref_i+i2)/2);% reference image number corresponding to the file
     
    359366    %TODO: read the image name in the netcdf file (if documented)
    360367    %look for double image series '_i_j'
     368    check_letter=regexp(nom_type_nc,'[ab|AB]$');%detect pair label by letter
     369    if ~isempty(check_letter)
     370        j1_str=nom_type_nc(end-1);
     371        r=regexp(nom_type_nc,'_(?<num1>\d+)','names');
     372        if ~isempty(r)
     373            i1_str=r.num1;
     374        end
     375    else
     376        NomTypeIma=regexprep(nom_type_nc,'-\d','');%
     377        r_end=regexp(NomTypeIma,'.\D(?<num2>\d+$','names');
     378        if ~isempty(r_end)
     379            j1_str=r.num2
     380        end
     381    end
     382    r=regexp(NomTypeIma,'_(?<num1>\d+)','names');
     383    if ~isempty(r)
     384        i1_str=r.num1;
     385    end 
    361386    dirima=dir([RootName '_' i1_str '_' j1_str '.*']);
    362387    if isempty(dirima)
     
    374399    end
    375400    for ilist=1:numel(dirima)
    376         [pp,ff,i1_str,i2_str,j1_str,j2_str,ext_list,nom_type_list]=name2display(dirima(ilist).name);
     401        %[pp,ff,i1_str,i2_str,j1_str,j2_str,ext_list,nom_type_list]=name2display(dirima(ilist).name);
     402        [~,~,~,i1,i2,j1,j2,ext_list,nom_type_list]=fileparts_uvmat(dirima(ilist).name);
    377403        form=imformats(ext_list(2:end));
    378404        if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    379405            ext_ima=ext_list;
    380406            nom_type_ima=nom_type_list;
    381             i1=str2double(i1_str);
    382             j1=str2double(j1_str);
    383             i2=str2double(i2_str);
    384             j2=str2double(j2_str);         
     407%             i1=str2double(i1_str);
     408%             j1=str2double(j1_str);
     409%             i2=str2double(i2_str);
     410%             j2=str2double(j2_str);         
    385411            % set the range of fields (1:1 by default) and selected pair
    386             if isequal(i2,i1)||isnan(i2)
     412            if isempty(i2)
    387413                num_ref_i=i1;
    388414            else
     
    391417                browse.incr_pair(2)=0;
    392418            end
    393             if isequal(j1,j2)||isnan(j2)
    394                 if isnan(j1)
     419            if isempty(j2)
     420                if isempty(j1)
    395421                    num_ref_j=1;
    396422                else
     
    405431    end
    406432end
     433[RootPath,RootFile,i1_series,~,j1_series,~,NomType,FileType,Object]=find_file_series(imagename);
     434MaxIndex_i=max(i1_series(i1_series>0));
     435MaxIndex_j=max(j1_series(j1_series>0));
    407436
    408437%% look for an image documentation file
     
    420449end
    421450set(handles.ImaDoc,'String',ext_imadoc)% display the extension name for the image documentation file used
    422 set(handles.ImaDoc,'BackgroundColor',[1 1 0])
    423 drawnow
    424 %%%%%%%%   read image documentation file  %%%%%%%%%%%%%%%%%%%%%%%%%%%
     451
     452
     453%%  read the time in the image documentation file 
    425454mode=''; %default
    426455time=[];
    427 TimeUnit='frame'; %default
    428 CoordUnit='px';%default
     456TimeUnit=''; %default
     457CoordUnit='';%default
    429458pxcmx_search=[];%default
    430459pxcmy_search=[];%default
    431 if isequal(ext_imadoc,'.civxml')%TO ABANDON
    432     [nbfield,nbfield2,time]=read_civxml([RootName '.civxml']);
    433     mode='pair j1-j2';
    434     if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat
    435         nom_type_ima='_i_j';
    436     end
    437 elseif isequal(ext_imadoc,'.xml')
    438     [XmlData,warntext]=imadoc2struct([RootName '.xml']);
    439     ext_ima_read=[];
    440     nom_type_read=[];
    441     if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file
    442         [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName);
    443         fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file,
    444         if ~exist(fullname,'file')
    445             msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist'])
    446         end
    447     end
    448     if isfield(XmlData,'Time')
    449         time=XmlData.Time;
    450         nbfield=size(time,1);
    451         nbfield2=size(time,2);
    452         %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml
    453         if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector
    454             if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once'))
    455                 time=time';
    456                 nbfield=nbfield2;
    457                 nbfield2=1;
    458             end
    459         end
    460     end
    461     if isfield(XmlData,'TimeUnit')
    462         TimeUnit=XmlData.TimeUnit;
    463     end
    464     pxcmx_search=1;
    465     pxcmy_search=1;
    466     if isfield(XmlData,'GeometryCalib')
    467         tsai=XmlData.GeometryCalib;
    468         if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R')
    469             rot2D=tsai.R(1:2,[1,2]);
    470             pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx);
    471             pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy);
    472         end
    473         if isfield(tsai,'CoordUnit')
    474             CoordUnit=tsai.CoordUnit;
    475         end
    476     end
    477 elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file
    478     [error,time,TimeUnit,mode,npx,npy]=read_imatext([RootName '.civ']);
    479     if error==2, msgbox_uvmat('WARNING',['no file ' RootName '.civ']);
    480     elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
    481     end
    482     nom_type_ima='001a';
    483 elseif strcmpi(ext_imadoc,'.avi')
    484     nom_type_ima='*';
    485     ext_ima=ext_imadoc;
    486     set(handles.ListPairMode,'Value',1);
    487     set(handles.ListPairMode,'String',{'series(Di)'})
    488     dt=0.04;%default
    489     if exist([RootName ext_imadoc],'file')==2
    490         info=aviinfo([RootName ext_imadoc]);%read infos on the avi movie
    491         dt=1/info.FramesPerSecond;%time interval between successive frames
    492         nbfield=info.NumFrames;%number of frames
    493     end
    494     time=(dt*(0:nbfield-1))';%list of image times
    495 end
    496 if isempty(time)
    497     set(handles.ImaDoc,'String',''); %xml file not used for timing
    498 end
    499 set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box to yellow color
    500 
     460if ~isempty(ext_imadoc)
     461    set(handles.ImaDoc,'BackgroundColor',[1 1 0]) % set edit box to yellow cloro to indicate that the file reading is beginning
     462    drawnow
     463    switch ext_imadoc
     464        case '.civxml'%OBSOLETE
     465            [~,~,time]=read_civxml([RootName '.civxml']);
     466            mode='pair j1-j2';
     467            if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat
     468                nom_type_ima='_i_j';
     469            end
     470        case '.xml'
     471            [XmlData,warntext]=imadoc2struct([RootName '.xml']);
     472            ext_ima_read=[];
     473            nom_type_read=[];
     474            if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file
     475                %[PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName);
     476                [~,~,~,~,~,~,~,~,nom_type_read]=fileparts_uvmat(XmlData.Heading.ImageName);
     477                fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file,
     478                if ~exist(fullname,'file')
     479                    msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist'])
     480                end
     481            end
     482            if isfield(XmlData,'Time')
     483                time=XmlData.Time;
     484                %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml
     485                if isequal(MaxIndex_i,1) && ~isequal(MaxIndex_j,1)% .Time is a line vector
     486                    if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once'))
     487                        time=time';
     488                        MaxIndex_i=MaxIndex_j;
     489                        MaxIndex_j=1;
     490                    end
     491                end
     492            end
     493            if isfield(XmlData,'TimeUnit')
     494                TimeUnit=XmlData.TimeUnit;
     495            end
     496            pxcmx_search=1;
     497            pxcmy_search=1;
     498            if isfield(XmlData,'GeometryCalib')
     499                tsai=XmlData.GeometryCalib;
     500                if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R')
     501                    rot2D=tsai.R(1:2,[1,2]);
     502                    pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx);
     503                    pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy);
     504                end
     505                if isfield(tsai,'CoordUnit')
     506                    CoordUnit=tsai.CoordUnit;
     507                end
     508            end
     509        case '.civ'% OBSOLETE: case of .civ image documentation file
     510            [error,time,TimeUnit,mode,npx,npy]=read_imatext([RootName '.civ']);
     511            if error==2, msgbox_uvmat('WARNING',['no file ' RootName '.civ']);
     512            elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
     513            end
     514            nom_type_ima='001a';
     515        case {'.avi','.AVI'}
     516            nom_type_ima='*';
     517            ext_ima=ext_imadoc;
     518            set(handles.ListPairMode,'Value',1);
     519            set(handles.ListPairMode,'String',{'series(Di)'})
     520            dt=0.04;%default
     521            if exist([RootName ext_imadoc],'file')==2
     522                info=aviinfo([RootName ext_imadoc]);%read infos on the avi movie
     523                dt=1/info.FramesPerSecond;%time interval between successive frames
     524                MaxIndex_i=info.NumFrames;%number of frames
     525            end
     526            time=(dt*(0:MaxIndex_i-1))';%list of image times
     527            TimeUnit='s';
     528    end
     529    set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter
     530end
    501531
    502532%% timing display
    503533%show the reference image edit box if relevant (not needed for movies or in the absence of time information
    504 if ~isempty(time)
    505     if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt
    506         nbfield=size(time,1);
    507         nbfield2=size(time,2);
    508         set(handles.ImaDoc,'UserData',time); %store the set of times
    509         set(handles.dt_unit,'String',['dt in m' TimeUnit]);
    510         set(handles.TimeUnit,'String',TimeUnit);
    511         set(handles.nb_field,'String',num2str(nbfield));
    512         set(handles.nb_field2,'String',num2str(nbfield2));
    513     end
    514 end
     534if numel(time)>=2 % if there are at least two time values to define dt
     535    MaxIndex_i=min(size(time,1),MaxIndex_i);
     536    MaxIndex_j=min(size(time,2),MaxIndex_j);
     537    time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices)
     538    time=[zeros(1,size(time,2)); time]; %insert a horizontal line of zeros
     539    set(handles.ImaDoc,'UserData',time); %store the matrix of times
     540    set(handles.dt_unit,'String',['dt in m' TimeUnit]);
     541    set(handles.TimeUnit,'String',TimeUnit);
     542else
     543    set(handles.ImaDoc,'String',''); %xml file not used for timing
     544    time=(i1_series(:,1)+0:size(i1_series,1)-1);% time=index i
     545    time=time'*ones(1,size(i1_series,2),1); %makes a time matrix with the same time for all j indices
     546    TimeUnit='frame';
     547end
     548set(handles.ImaDoc,'UserData',time); %store the matrix of times
     549set(handles.dt_unit,'String',['dt in m' TimeUnit]);%display dt in unit 10-3 of the time (e.g ms)
     550set(handles.TimeUnit,'String',TimeUnit);
     551set(handles.nb_field,'String',num2str(MaxIndex_i));
     552set(handles.nb_field2,'String',num2str(MaxIndex_j));
    515553set(handles.CoordUnit,'String',CoordUnit)
    516554set(handles.SearchRange,'UserData',[pxcmx_search pxcmy_search]);
     
    545583    set(handles.(ListOptions{index}),'value',1)
    546584end
    547 update_CivOptions(handles)
     585update_CivOptions(handles,1)
    548586
    549587
    550588%%  set the menus of image pairs and default selection for civ   %%%%%%%%%%%%%%%%%%%
    551 test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing
    552 if test_ima_i || isequal(nom_type_nc,'_1-2')||~(exist('nbfield2','var')&&(nbfield2~=1))
     589check_letter=~isempty(regexp(nom_type_ima,'[a|A]$'));
     590check_separator=~isempty(regexp(nom_type_ima,'_'));
     591% test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'))%=1 for images with single indexing
     592% TODO: determine MaxIndex_i and MaxIndex_j using find_file_series (in the absence of xml file)
     593if (~check_letter&&~check_separator)|| isequal(nom_type_nc,'_1-2')|| (exist('MaxIndex_j','var')&&(MaxIndex_j==1))
    553594    set(handles.ListPairMode,'Value',1)
    554595    set(handles.ListPairMode,'String',{'series(Di)'})   
    555 elseif (nbfield==1)% simple series in j
    556     set(handles.ListPairMode,'Value',1)
    557     set(handles.ListPairMode,'String',{'series(Dj)'})
     596elseif  MaxIndex_i==1 && MaxIndex_j% simple series in j
     597    set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)'})
     598    if  MaxIndex_j <= 10
     599        set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large
     600    end
    558601else
    559602    set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice
    560     if nbfield2 <= 10
    561         set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' for small burst
     603    if  MaxIndex_j <= 10
     604        set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large
    562605    end
    563606end
     
    577620    end
    578621end
    579 Value=find(strcmp(subdir,listdir));%search the index of subdir in the cell listdir
     622Value=find(strcmp(SubDir,listdir));%search the index of subdir in the cell listdir
    580623if isempty(Value)% if the input subdir is not found
    581624    ValueCiv1=get(handles.ListSubdirCiv1,'Value');%read the currrently selected dir name
     
    610653%% list the possible index pairs, depending on the option set in ListPairMode
    611654ListPairMode_Callback([], [], handles)
     655'TESTin'
     656browse=get(handles.RootName,'UserData')
    612657
    613658%% store the root input filename for future opening
     
    632677function txt_SubdirCiv1_Callback(hObject, eventdata, handles)
    633678%------------------------------------------------------------------------
    634 subdir=get(handles.txt_SubdirCiv1,'String');
     679SubDir=get(handles.txt_SubdirCiv1,'String');
    635680menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update
    636 ichoice=find(strcmp(subdir,menu_str),1);
     681ichoice=find(strcmp(SubDir,menu_str),1);
    637682if isempty(ichoice)
    638683    ilist=numel(menu_str); %select 'new...' in the menu
     
    642687set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu
    643688if get(handles.CheckCiv1,'Value')% if Civ1 is performed
    644     set(handles.txt_SubdirCiv2,'String',subdir);% set by default civ2 directory the same as civ1
     689    set(handles.txt_SubdirCiv2,'String',SubDir);% set by default civ2 directory the same as civ1
    645690    set(handles.ListSubdirCiv2,'Value',ilist)
    646691else % if Civ1 data already exist
     
    649694
    650695%------------------------------------------------------------------------
    651 % --- Executes on carriage return on the subdir checkciv1 edit window
     696% --- Executes on carriage return on the SubDir checkciv1 edit window
    652697function txt_SubdirCiv2_Callback(hObject, eventdata, handles)
    653698%------------------------------------------------------------------------
    654 subdir=get(handles.txt_SubdirCiv1,'String');
     699SubDir=get(handles.txt_SubdirCiv1,'String');
    655700menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update
    656 ichoice=find(strcmp(subdir,menu_str),1);
     701ichoice=find(strcmp(SubDir,menu_str),1);
    657702if isempty(ichoice)
    658703    ilist=numel(menu_str); %select 'new...' in the menu
     
    670715function CheckCiv1_Callback(hObject, eventdata, handles)
    671716%------------------------------------------------------------------------
    672 update_CivOptions(handles)
     717update_CivOptions(handles,0)
    673718
    674719%------------------------------------------------------------------------
     
    676721function CheckFix1_Callback(hObject, eventdata, handles)
    677722%------------------------------------------------------------------------
    678 update_CivOptions(handles)
     723update_CivOptions(handles,0)
    679724
    680725%------------------------------------------------------------------------
     
    682727function CheckPatch1_Callback(hObject, eventdata, handles)
    683728%------------------------------------------------------------------------
    684 update_CivOptions(handles)
     729update_CivOptions(handles,0)
    685730
    686731%------------------------------------------------------------------------
     
    688733function CheckCiv2_Callback(hObject, eventdata, handles)
    689734%------------------------------------------------------------------------
    690 update_CivOptions(handles)
     735update_CivOptions(handles,0)
    691736
    692737%------------------------------------------------------------------------
     
    694739function CheckFix2_Callback(hObject, eventdata, handles)
    695740%------------------------------------------------------------------------
    696 update_CivOptions(handles)
     741update_CivOptions(handles,0)
    697742
    698743%------------------------------------------------------------------------
     
    700745function CheckPatch2_Callback(hObject, eventdata, handles)
    701746%------------------------------------------------------------------------
    702 update_CivOptions(handles)
     747update_CivOptions(handles,0)
    703748
    704749%------------------------------------------------------------------------
    705750% --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2
    706 function update_CivOptions(handles)
     751function update_CivOptions(handles,opening)
    707752%------------------------------------------------------------------------
    708753checkbox=zeros(1,6);
     
    718763    if isempty(RootName)
    719764         msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...')
    720         return
     765        returnopening
    721766    end
    722767end
     
    724769set(handles.txt_SubdirCiv1,'Visible','on')
    725770set(handles.ListSubdirCiv1,'Visible','on')
     771if ~opening
    726772find_netcpair_civ1(handles) % select the available netcdf files
     773end
    727774if max(checkbox(4:6))% case of civ2 pair choice needed
    728775    set(handles.TitlePairCiv2,'Visible','on')
     
    731778    set(handles.ListSubdirCiv2,'Visible','on')
    732779    set(handles.ListPairCiv2,'Visible','on')
     780    if ~opening
    733781    find_netcpair_civ2(handles) % select the available netcdf files
     782    end
    734783else
    735784    set(handles.TitleSubdirCiv2,'Visible','off')
     
    829878end
    830879[root,filename,ext]=fileparts(civ_files{1});
    831 [rootroot,subdir,extdir]=fileparts(root);
     880[rootroot,SubDir,extdir]=fileparts(root);
    832881hfig=findobj(allchild(0),'name','civ_status');
    833882if isempty(hfig)
    834883    hfig=figure('DeleteFcn',@stop_status);
    835884    set(hfig,'name','civ_status')
    836     hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list');
     885    %hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list');
     886     uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list');
    837887    uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...');
    838888    uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
     
    895945        end
    896946        [rr,filename,ext]=fileparts(civ_files{ifile});
    897         Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext  '...' option_str];
     947        Tabchar{ifile,1}=[fullfile([SubDir extdir],filename) ext  '...' option_str];
    898948    end
    899949    datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     
    11031153%% MAIN LOOP
    11041154time=get(handles.ImaDoc,'UserData'); %get the set of times
     1155TimeUnit=get(handles.TimeUnit,'String');
     1156checkframe=strcmp(TimeUnit,'frame');
    11051157batch_file_list=[];%should be renamed file_list, can be used for xml or bash files
    11061158 
     
    11361188            Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};
    11371189            Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j};
    1138             if size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j)
    1139                 Param.Civ1.Dt=(time(i2_civ1(ifile),j2_civ1(j))-time(i1_civ1(ifile),j1_civ1(j)));
    1140                 Param.Civ1.Time=((time(i2_civ1(ifile),j2_civ1(j))+time(i1_civ1(ifile),j1_civ1(j)))/2);
     1190            if ~checkframe% && size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j)
     1191                Param.Civ1.Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)-time(i1_civ1(ifile)+1,j1_civ1(j)+1));
    11411192            else
    11421193                Param.Civ1.Dt=1;
    1143                 Param.Civ1.Time=0;
    1144             end
     1194            end
     1195            Param.Civ1.Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2);
    11451196            Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE?
    11461197            Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);%   
     
    12741325            Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};
    12751326            Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j};
    1276             if size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j)
    1277                 Param.Civ2.Dt=num2str(time(i2_civ2(ifile),j2_civ2(j))-time(i1_civ2(ifile),j1_civ2(j)));
    1278                 Param.Civ2.Time=num2str((time(i2_civ2(ifile),j2_civ2(j))+time(i1_civ2(ifile),j1_civ2(j)))/2);
     1327            if ~checkframe %&& size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j)
     1328                Param.Civ2.Dt=num2str(time(i2_civ2(ifile)+1,j2_civ2(j)+1)-time(i1_civ2(ifile)+1,j1_civ2(j)+1));
    12791329            else
    12801330                Param.Civ2.Dt=1;
    1281                 Param.Civ2.Time=0;
    1282             end
     1331            end
     1332            Param.Civ2.Time=num2str((time(i2_civ2(ifile)+1,j2_civ2(j)+1)+time(i1_civ2(ifile)+1,j1_civ2(j)+1))/2);
    12831333            Param.Civ2.term_a=num2stra(j1_civ2(j),nom_type_nc);
    12841334            Param.Civ2.term_b=num2stra(j2_civ2(j),nom_type_nc);
     
    16201670    end
    16211671end
    1622 [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu);
    1623 namedoc=fullfile(RootPath,subdir,RootFile);
     1672%[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,SubDir]=name2display(fileresu);
     1673[RootPath,SubDir,RootFile]=fileparts_uvmat(fileresu);
     1674namedoc=fullfile(RootPath,SubDir,RootFile);
    16241675detect=1;
    16251676while detect==1
     
    25672618     end
    25682619%     set(handles.RootName_1,'String',name);
    2569     [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name);
     2620    %[RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,SubDir]=name2display(name);
     2621    [~,~,RootFile,~,~,~,~,~,nom_type]=fileparts_uvmat(name);
    25702622    set(handles.RootName_1,'String',RootFile);
    25712623    browse=get(handles.RootName,'UserData');
     
    26402692% last_i=str2num(get(handles.last_i,'String'));
    26412693time=get(handles.ImaDoc,'UserData'); %get the set of times
     2694TimeUnit=get(handles.TimeUnit,'String');
     2695checkframe=strcmp(TimeUnit,'frame');
    26422696siztime=size(time);
    2643 nbfield=siztime(1);
    2644 nbfield2=siztime(2);
     2697nbfield=siztime(1)-1;
     2698nbfield2=siztime(2)-1;
    26452699indchosen=1;  %%first pair selected by default
    26462700%displ_num used to define the indices of the civ pairs
     
    26482702% are relative to the reference indices ref_i and ref_j respectively.
    26492703if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2')
     2704
    26502705    dt=1;
    26512706    displ='';
     
    26612716            numlist_a(index)=numod_a;
    26622717            numlist_b(index)=numod_b;
    2663             if ~isempty(time)
    2664                 dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt
     2718            if size(time,2)>1 && ~checkframe
     2719                dt(numod_a,numod_b)=time(ref_i+1,numod_b+1)-time(ref_i+1,numod_a+1);%first time interval dt
    26652720                displ_dt(index)=dt(numod_a,numod_b);
    26662721            else
     
    26992754    set(handles.nb_field2,'Visible','On')
    27002755    set(handles.ref_j,'Visible','On')
    2701     if nbfield > 1
    2702         set(handles.itext,'Visible','On')
    2703         set(handles.first_i,'Visible','On')
    2704         set(handles.last_i,'Visible','On')
    2705         set(handles.incr_i,'Visible','On')
    2706         set(handles.nb_field,'Visible','On')
    2707         set(handles.ref_i,'Visible','On')
    2708     else
    2709         set(handles.itext,'Visible','Off')
    2710         set(handles.first_i,'Visible','Off')
    2711         set(handles.last_i,'Visible','Off')
    2712         set(handles.incr_i,'Visible','Off')
    2713         set(handles.nb_field,'Visible','Off')
    2714         set(handles.ref_i,'Visible','Off')
    2715     end
     2756%     if nbfield > 1
     2757%         set(handles.itext,'Visible','On')
     2758%         set(handles.first_i,'Visible','On')
     2759%         set(handles.last_i,'Visible','On')
     2760%         set(handles.incr_i,'Visible','On')
     2761%         set(handles.nb_field,'Visible','On')
     2762%         set(handles.ref_i,'Visible','On')
     2763%     else
     2764%         set(handles.itext,'Visible','Off')
     2765%         set(handles.first_i,'Visible','Off')
     2766%         set(handles.last_i,'Visible','Off')
     2767%         set(handles.incr_i,'Visible','Off')
     2768%         set(handles.nb_field,'Visible','Off')
     2769%         set(handles.ref_i,'Visible','Off')
     2770%     end
    27162771elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)')
    27172772    index=1:200;
     
    27852840find_netcpair_civ1( handles)
    27862841find_netcpair_civ2(handles)
     2842'TESTin'
     2843browse=get(handles.RootName,'UserData')
    27872844
    27882845%------------------------------------------------------------------------
     
    29473004end
    29483005time=get(handles.ImaDoc,'UserData');%get the set of times
    2949 if isempty(time)
    2950     time=[0 1];
    2951 end
    2952 dt_unit=1000;%default
     3006% if isempty(time)
     3007%     time=[0 1];
     3008% end
     3009TimeUnit=get(handles.TimeUnit,'String');
     3010checkframe=strcmp(TimeUnit,'frame');
     3011
    29533012displ_num=get(handles.ListPairCiv1,'UserData');
    29543013
     
    30223081            if select(ipair)
    30233082                displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))];
    3024                 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    3025                     dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
    3026                     displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
     3083                if ~checkframe && size(time,1)>=ref_i+1+displ_num(4,ipair) && size(time,2)>=ref_j+1+displ_num(2,ipair)&&displ_num(2,ipair)>=1 &&displ_num(1,ipair)>=1
     3084                    dt=time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%time interval dt
     3085                else
     3086                    dt=1;
    30273087                end
     3088                 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    30283089            else
    30293090                displ_pair{ipair}='...'; %pair not displayed in the menu
     
    30383099            if select(ipair)
    30393100                displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))];
    3040                 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    3041                     dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
     3101                if ~checkframe && size(time,1)>=ref_i+1+displ_num(4,ipair) && size(time,2)>=ref_j+1+displ_num(2,ipair)
     3102                    dt=time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%time interval dt
    30423103                    displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    30433104                end
     
    30503111    for ipair=1:nbpair
    30513112        if select(ipair)
    3052             dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt
     3113            if ~checkframe && size(time,2)>1
     3114            dt=time(ref_i+1+displ_num(4,ipair),displ_num(2,ipair)+1)-time(ref_i+1+displ_num(3,ipair),displ_num(1,ipair)+1);%time interval dt
     3115            else % time set by default to i index
     3116                dt=1;
     3117            end
    30533118            displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ...
    30543119                ' :dt= ' num2str(dt*1000)];
     
    31403205end
    31413206time=get(handles.ImaDoc,'UserData'); %get the set of times
    3142 if isempty(time)
    3143     time=[0 1];%default
    3144 end
     3207TimeUnit=get(handles.TimeUnit,'String');
     3208checkframe=strcmp(TimeUnit,'frame');
     3209% if isempty(time)
     3210%     time=[0 1];%default
     3211% end
    31453212displ_num=get(handles.ListPairCiv1,'UserData');
    31463213
     
    31983265        if select(ipair)
    31993266            displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
    3200             if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    3201                 dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
     3267            if  ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
     3268                dt=time(ref_i+displ_num(4,ipair)+1,ref_j+displ_num(2,ipair)+1)-time(ref_i+displ_num(3,ipair)+1,ref_j+displ_num(1,ipair)+1);%time interval dt
    32023269                displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    32033270            end
     
    32103277        if select(ipair)
    32113278            displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
    3212             if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
    3213                 dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt
     3279            if ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)&& displ_num(1,ipair)>=1 && displ_num(2,ipair)>=1
     3280                dt=time(ref_i+displ_num(4,ipair)+1,ref_j+displ_num(2,ipair)+1)-time(ref_i+displ_num(3,ipair)+1,ref_j+displ_num(1,ipair)+1);%time interval dt
     3281            else
     3282                dt=1;
     3283            end
    32143284                displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    3215             end
    32163285        else
    32173286            displ_pair{ipair}='...'; %pair not displayed in the menu
     
    32213290    for ipair=1:nbpair
    32223291        if select(ipair)
    3223             dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt
    3224             displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ...
     3292            if  ~checkframe && size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) && displ_num(1,ipair)>=1 && displ_num(2,ipair)>=1
     3293            dt=time(ref_i+displ_num(4,ipair)+1,displ_num(2,ipair)+1)-time(ref_i+displ_num(3,ipair)+1,displ_num(1,ipair)+1);%time interval dt
     3294            else
     3295                dt=1;
     3296            end
     3297            displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair)+1,nom_type_ima) '-' num2stra(displ_num(2,ipair)+1,nom_type_ima) ...
    32253298                ' :dt= ' num2str(dt*1000)];
     3299               
    32263300        else
    32273301            displ_pair{ipair}='...'; %pair not displayed in the menu
     
    36233697list_subdir_civ1=get(handles.ListSubdirCiv1,'String');
    36243698val=get(handles.ListSubdirCiv1,'Value');
    3625 subdir=list_subdir_civ1{val};
    3626 if strcmp(subdir,'new...')
     3699SubDir=list_subdir_civ1{val};
     3700if strcmp(SubDir,'new...')
    36273701    if get(handles.CheckCiv1,'Value')
    3628         subdir='CIV'; %default subdirectory
     3702        SubDir='CIV'; %default subdirectory
    36293703    else
    36303704        msgbox_uvmat('ERROR','select CheckCiv1 to perform a new Civ operation')
     
    36323706    end   
    36333707end
    3634 set(handles.txt_SubdirCiv1,'String',subdir);
     3708set(handles.txt_SubdirCiv1,'String',SubDir);
    36353709find_netcpair_civ1(handles)
    36363710
     
    36413715list_subdir_civ2=get(handles.ListSubdirCiv2,'String');
    36423716val=get(handles.ListSubdirCiv2,'Value');
    3643 subdir=list_subdir_civ2{val};
    3644 if strcmp(subdir,'new...')
     3717SubDir=list_subdir_civ2{val};
     3718if strcmp(SubDir,'new...')
    36453719    if get(handles.CheckCiv2,'Value')
    3646         subdir='CIV'; %default subdirectory
     3720        SubDir='CIV'; %default subdirectory
    36473721    else
    36483722        msgbox_uvmat('ERROR','select CheckCiv2 to perform a new Civ operation')
     
    36503724    end
    36513725end
    3652 set(handles.txt_SubdirCiv2,'String',subdir);
     3726set(handles.txt_SubdirCiv2,'String',SubDir);
    36533727
    36543728%------------------------------------------------------------------------
     
    38603934sizf=size(fileinput);
    38613935if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    3862 [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
     3936%[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
     3937[Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput);
    38633938ref.filebase=fullfile(Path,File);
    3864 ref.num_a=stra2num(str_a);
    3865 ref.num_b=stra2num(str_b);
    3866 ref.num1=str2double(field_count);
    3867 ref.num2=str2double(str2);
     3939% ref.num_a=stra2num(str_a);
     3940% ref.num_b=stra2num(str_b);
     3941% ref.num1=str2double(field_count);
     3942% ref.num2=str2double(str2);
    38683943browse=[];%initialisation
    38693944if ~isequal(ref.ext,'.nc')
     
    39043979    sizf=size(fileinput);
    39053980    if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    3906     [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
     3981    %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
     3982    [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput);
    39073983    ref.filebase=fullfile(Path,File);
    3908     ref.num_a=stra2num(str_a);
    3909     ref.num_b=stra2num(str_b);
    3910     ref.num1=str2num(field_count);
    3911     ref.num2=str2num(str2);
     3984%     ref.num_a=stra2num(str_a);
     3985%     ref.num_b=stra2num(str_b);
     3986%     ref.num1=str2num(field_count);
     3987%     ref.num2=str2num(str2);
    39123988    browse=[];%initialisation
    39133989    if ~isequal(ref.ext,'.nc')
     
    40914167errormsg=''; %default
    40924168filename=regexprep(filename,'.nc',''); %file name for the result
    4093 if isequal(Param.Civ1.Dt,'0')
    4094     Param.Civ1.Dt='1' ;%case of 'displacement' mode
     4169if isequal(Param.Civ1.Dt,0)
     4170    Param.Civ1.Dt=1 ;%case of 'displacement' mode
    40954171end
    40964172Param.Civ1.ImageA=regexprep(Param.Civ1.ImageA,'.png','');
     
    44444520    end
    44454521end
    4446 
  • trunk/src/civ_3D.m

    r147 r343  
    30863086%        str2double(get(hObject,'String')) returns contents of npx as a double
    30873087
    3088 
    3089 
    3090 
     3088%TODO: replace name2display by fileparts_uvmat:
     3089
     3090
     3091%'name2display': extracts the root name and field numbers from an input filename
     3092%--------------------------------------------------------------------
     3093%[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)
     3094%
     3095%OUTPUT:
     3096%filebasesub: filename without appendix
     3097%field_count: string for the first number i
     3098%str2: string for the second number i (only for .nc files)
     3099%str_a: string for the first number j
     3100%str_b:string for the second number j (only for .nc files)
     3101%ext: file extension
     3102%nom_type: char chain characterizing the file nomenclature: with values
     3103%   nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
     3104%   nom_type='*':constant name for a file representing a series (e.g. avi movie)
     3105%   nom_type='1','01',or '001'...': series of files with a single index i without separator(e.g. 'aa045.png').
     3106%   nom_type='_1','_01','_001'...':  series of files with a single index i with separator '_'(e.g. 'aa_045.png').
     3107%   nom_type='1a','1A','01a','01A',... with a numerical index and an index letter(e.g.'aa45b.png') (lower or upper case)
     3108%   nom_type='_1a','_1A','_01a','_01A',...: idem, with a separator '_' before the index
     3109%   nom_type='_1_1','_01_1',...: matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
     3110%   nom_type='_1-2': from pairs from a single index (e.g. 'aa_45-47.nc')
     3111%   nom_type='_1_1-2': pairs of j indices (e.g. 'aa_45_2-3.nc')
     3112%   nom_type='_1-2_j': pairs of i indices (e.g. 'aa_45-46_2.nc')
     3113%   nom_type='_1_ab','1_ab','01_ab'..., from pairs of '#' images (e.g.'aa045bc.nc'), ext='.nc'
     3114%subdir: name of the subdirectory for netcdf files
     3115%
     3116%INPUT:
     3117%fileinput: complete name of the file, including path
     3118
     3119function [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)
     3120% siz=length(fileinput);
     3121% indcur=siz;
     3122% default values:
     3123% test_=0;
     3124field_count='';%character string
     3125str2='';
     3126str_a='';
     3127str_b='';
     3128% ext='';
     3129nom_type='';
     3130subdir='';
     3131        %select file extension
     3132[RootPath,RootFile,ext]=fileparts(fileinput);
     3133indcur=length(RootFile);% nbre of characters in fileraw
     3134
     3135        %recognize the name form
     3136% filerawascii=double(RootFile);%ascci code
     3137% val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters
     3138indsel=regexp(RootFile,'\D');% character indices of non numerical characters
     3139filelit=RootFile(indsel);% fileraw name with numbers removed
     3140nbchar=length(indsel);
     3141if nbchar<4% put '*' before the name (remove at the end)
     3142   prefilelit(1:4-nbchar)='*';%insert 3_nbchar '*' in the file name
     3143   filelit=[prefilelit filelit];
     3144   indsel=[1:4-nbchar indsel+4-nbchar];
     3145   RootFile=[prefilelit RootFile];
     3146   indcur=indcur+4-nbchar;
     3147end
     3148separ3=indsel(end);% index of last non numerical character in fileraw
     3149separ2=indsel(end-1);% index of previous non numerical character
     3150separ1=indsel(end-2);
     3151separ0=indsel(end-3);
     3152num1='';num2='';num3='';
     3153if separ1>=separ0+1,num0=RootFile(separ0+1:separ1-1);end
     3154if separ2>=separ1+1,num1=RootFile(separ1+1:separ2-1);end
     3155if separ3>=separ2+1,num2=RootFile(separ2+1:separ3-1);end
     3156if indcur>=separ3+1,num3=RootFile(separ3+1:indcur);end
     3157last_str=RootFile(indcur);%last character in fileraw
     3158last=double(last_str);%corresponding ascii code
     3159penult=double(RootFile(indcur-1));%ascii code of the penultimate character
     3160testsub=0; %default
     3161% % case of an indexed series in a single file
     3162% if strcmpi(ext,'.avi')
     3163%      nom_type='*';
     3164% %case of a numerical index follewed by a lower case letter (e.g. a,b,c):
     3165% %the penultimate character is a number and the last one a letter (lower case: last >= 97 && last <= 122
     3166% %                                                                 capital
     3167% %                                                                 letter:  last >= 65 && last <= 90) 
     3168if  penult >= 48 && penult <= 57 && ((last >= 65 && last <= 90)||(last >= 97 && last <= 122))
     3169    str_a=last_str; %extract appendix a,b,c... or A,B,C... as output.
     3170    ind_end=indcur-1; %current index just before the suffix letter
     3171    indices_root=regexp(RootFile(1:indcur-1),'\D');%detect non digit characters
     3172    indcur=max(indices_root);
     3173    field_count=RootFile(indcur+1:ind_end);
     3174    charstring=['%0' num2str(length(field_count)) 'd'];
     3175    nom_type=num2str(1,charstring);
     3176    if strcmp(RootFile(indcur),'_')
     3177       nom_type=['_' nom_type];
     3178       indcur=indcur-1;
     3179    end
     3180    if (last >= 65 && last <= 90)
     3181        nom_type=[nom_type 'A'];
     3182    else
     3183        nom_type=[nom_type 'a'];
     3184    end   
     3185elseif strcmp(filelit(end-2:end),'-_-_')%new  nomenclature appendix num1-num2_num_a-num_b
     3186    field_count=num0;
     3187    str2=num1;
     3188    str_a=num2;
     3189    str_b=num3;
     3190    nom_type='_1-2_1-2';
     3191    testsub=1;
     3192    indcur=separ0-1;
     3193elseif strcmp(filelit(end-2:end),'_-_')%new  nomenclature appendix num1-num2_num_a
     3194    field_count=num1;
     3195    str2=num2;
     3196    str_a=num3;
     3197    nom_type='_1-2_1';
     3198    testsub=1;
     3199    indcur=separ1-1;
     3200elseif strcmp(filelit(end-2:end),'__-')%new  nomenclature appendix num1_num2-num2
     3201    indcur=separ1-1;
     3202    field_count=num1;
     3203    str_a=num2;
     3204    str_b=num3;
     3205    nom_type='_1_1-2';
     3206    testsub=1;
     3207elseif strcmp(filelit(end-1:end),'_-')
     3208    indcur=separ2-1;
     3209    field_count=num2;
     3210    str2=num3;
     3211    str_a='';
     3212    nom_type='_1-2';
     3213    testsub=1;
     3214elseif strcmp(filelit(end-1:end),'__')
     3215    indcur=separ2-1;
     3216    field_count=num2;
     3217    str2='';
     3218    str_a=num3;
     3219    nom_type='_1_1';
     3220elseif strcmp(filelit(end),'_')
     3221    indcur=separ3-1;
     3222    str2='';
     3223    str_a='';
     3224    %detect zeros before the number
     3225    field_count=RootFile(separ3+1:end);% set the selected field number'%03d'
     3226    charstring=['%0' num2str(length(field_count)) 'd'];
     3227    nom_type=['_' num2str(1,charstring)];
     3228elseif RootFile(indcur-2)=='_'% search appendix a,b,c,d
     3229    lasts=RootFile(indcur-1:indcur);
     3230%     if isequal(length(last),2)
     3231        str_a=lasts(1);%put appendix a,b,c, ou d
     3232        str_b=lasts(2);%put appendix a,b,c, ou d
     3233        separ0=indsel(end-3);
     3234        field_count=RootFile(separ0+1:separ1-1);
     3235        indcur=separ0;
     3236        if double(lasts) >= 97 & double(lasts)<= 122
     3237            nom_type='_ab';
     3238            testsub=1;
     3239        elseif double(lasts) >= 65 & double(lasts) <= 90
     3240            nom_type='_AB';
     3241            testsub=1;
     3242        end
     3243        charstring=['%0' num2str(length(field_count)) 'd'];
     3244        nom_type=[num2str(1,charstring) nom_type];
     3245%     end
     3246%search for other names with counter
     3247else
     3248    if length(ext)>1     
     3249            num=1;count=0; % extract the numerical appendix
     3250            while num==1;
     3251                filascii=double(RootFile(indcur));
     3252                if (48>filascii)||(filascii>57); % select the non-numerical characters
     3253                    num=0;
     3254                else
     3255                    indcur=indcur-1; count=count+1;
     3256                end
     3257            end
     3258            if count~=0   
     3259                field_count=RootFile(indcur+1:indcur+count);% set the selected field number'%03d'
     3260                charstring=['%0' num2str(length(field_count)) 'd'];
     3261                nom_type=num2str(1,charstring);
     3262            end
     3263    end
     3264end
     3265            %select the root name in the file_input window
     3266RootFile=RootFile(1:indcur);
     3267if nbchar<4% put '*' before the name (remove at the end)
     3268   RootFile(1:4-nbchar)=[];
     3269end
     3270if testsub
     3271    [RootPath,subdir,extdir]=fileparts(RootPath);
     3272    subdir=[subdir extdir];
     3273end
     3274
  • trunk/src/find_file_series.m

    r342 r343  
    55% OUTPUT:
    66% RootPath,RootFile: root path and root name detected in fileinput, possibly modified for movies (indexing is then done on image view, not file)
    7 % i1_series(ref_i, ref_j,pair),i2_series,j1_series,j2_series: set of indices (i1,i2,j1,j2) sorted by ref index ref_i, ref_j, and pairindex in case of multiple pairs with the same ref
     7% i1_series(ref_i+1, ref_j+1,pair),i2_series,j1_series,j2_series: set of indices (i1,i2,j1,j2) sorted by ref index ref_i, ref_j, and pairindex in case of multiple pairs with the same ref
     8%  (ref_i+1 is used to deal with the image index zero sometimes used)
    89% NomType: nomenclature type corrected after checking the first file (problem of 0 before the number string)
    910% FileType: type of file, =
     
    129130    for ifile=1:nbpair
    130131        [~,~,~,i1,i2,j1,j2]=fileparts_uvmat(dirpair(ifile).name);
    131         %             i1_series(ifile)=i1;
    132132        ref_i=i1;
    133133        if isempty(i2_input)
     
    162162        nb_pairs=0;
    163163        if ~isempty(i2_input)|| ~isempty(j2_input) %deals with  pairs
    164             if size(i1_series,1)>=ref_i && size(i1_series,2)>=ref_j
    165                 nb_pairs=numel(find(i1_series(ref_i,ref_j,:)~=0));
    166             end
    167         end
    168         i1_series(ref_i,ref_j,nb_pairs+1)=i1;
     164            if size(i1_series,1)>=ref_i+1 && size(i1_series,2)>=ref_j+1
     165                nb_pairs=numel(find(i1_series(ref_i+1,ref_j+1,:)~=0));
     166            end
     167        end
     168        i1_series(ref_i+1,ref_j+1,nb_pairs+1)=i1;
    169169        if ~isempty(i2_input)
    170             i2_series(ref_i,ref_j,nb_pairs+1)=i2;
     170            i2_series(ref_i+1,ref_j+1,nb_pairs+1)=i2;
    171171        end
    172172        if ~isempty(j1_input)
    173             j1_series(ref_i,ref_j,nb_pairs+1)=j1;
     173            j1_series(ref_i+1,ref_j+1,nb_pairs+1)=j1;
    174174        end
    175175        if ~isempty(j2_input)
    176             j1_series(ref_i,ref_j,nb_pairs+1)=j1;
    177             j2_series(ref_i,ref_j,nb_pairs+1)=j2;
     176            j1_series(ref_i+1,ref_j+1,nb_pairs+1)=j1;
     177            j2_series(ref_i+1,ref_j+1,nb_pairs+1)=j2;
    178178        end
    179179    end
  • trunk/src/read_xls.m

    r19 r343  
    185185                       testrecord=0;%we have an image series without 'record' subdir
    186186                    elseif isequal(Ext,'.png')
    187                        [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
     187                       %[Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
     188                       [~,~,Root]=fileparts_uvmat(fname{ifile});
    188189                       if ~isequal(Root,RootIma)%only one image recorded for each root name
    189190                           [t,ImaDocElement]=add(t,DeviceElement,'element','Image');
     
    194195                       testrecord=0;%we have an image series without 'record' subdir
    195196                    elseif isequal(Ext,'.nc')
    196                        [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
     197                       %[Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
     198                       [~,~,Root]=fileparts_uvmat(fname{ifile});
    197199                       if ~isequal(Root,RootNc)%only one image recorded for each root name
    198200                           [t,ImaDocElement]=add(t,DeviceElement,'element','Ncdata');
     
    240242                               t=attributes(t,'add',ImaDocElement,'source','file');
    241243                            elseif isequal(Ext,'.png')
    242                                [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
     244                              % [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
     245                                [~,~,Root]=fileparts_uvmat(fname{ifile});
    243246                               if ~isequal(Root,RootIma)
    244247                                   [t,ImaDocElement]=add(t,DeviceElement,'element','Image');
     
    248251                               end
    249252                            elseif isequal(Ext,'.nc')
    250                                [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
     253                               %[Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
     254                               [~,~,Root]=fileparts_uvmat(fname{ifile});
    251255                               if ~isequal(Root,RootNc)%only one image recorded for each root name
    252256                                  [t,ImaDocElement]=add(t,DeviceElement,'element','Ncdata');
     
    290294                            [Path,Name,Ext]=fileparts(fname{ifile});
    291295                            if isequal(Ext,'.xml')
    292                                [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
     296                               %[Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
     297                               [~,~,Root]=fileparts_uvmat(fname{ifile});
    293298                               if ~isequal(Root,RootXml)%only one image recorded for each root name
    294299                                   [t,ImaDocElement]=add(t,RecordElement,'element','CivDoc');
     
    298303                               end
    299304                            elseif isequal(Ext,'.nc')
    300                                [Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
     305                               %[Path,Root,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fname{ifile});
     306                               [~,~,Root]=fileparts_uvmat(fname{ifile});
    301307                               if ~isequal(Root,RootNc)%only one image recorded for each root name
    302308                                  [t,ImaDocElement]=add(t,RecordElement,'element','Ncdata');
  • trunk/src/series.m

    r342 r343  
    449449
    450450%% look for min and max indices existing in the file series and update NomType
    451 [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(fileinput);
     451[RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(fileinput)
    452452MinIndex_i=min(i1_series(i1_series>0));
    453453if ~isempty(i2_series)
Note: See TracChangeset for help on using the changeset viewer.