Changeset 437


Ignore:
Timestamp:
Jun 4, 2012, 12:03:58 AM (12 years ago)
Author:
sommeria
Message:

rationalisation of civ parameter names
civ results now put in a directory outside the image directory.
*xml file management needs to be updated

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r435 r437  
    2424%TODO: search range
    2525
    26 % Last Modified by GUIDE v2.5 08-May-2012 22:14:39
     26% Last Modified by GUIDE v2.5 03-Jun-2012 22:16:42
    2727% Begin initialization code - DO NOT EDIT
    2828gui_Singleton = 1;
     
    271271set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    272272RootPath=get(handles.RootPath,'String');
     273SubdirImages=get(handles.SubdirImages,'String');
    273274RootFile=get(handles.RootFile,'String');
    274275ref_i=str2num(get(handles.ref_i,'String'));
     
    276277NomType=get(handles.NomType,'String');
    277278ImaExt=get(handles.ImaExt,'String');
    278 fileinput=fullfile_uvmat(RootPath,'',RootFile,ImaExt,NomType,ref_i,[],ref_j);
     279fileinput=fullfile_uvmat(RootPath,SubdirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j);
    279280errormsg=display_file_name(handles,fileinput);
    280281if ~isempty(errormsg)
     
    399400% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    400401% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    401 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomTypeIma,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName ImaExt]);
    402 
    403 % [RootPath,FileName,ImaExt]=fileparts(fileinput);
    404 % [RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,Object]=find_file_series(RootPath,[FileName ImaExt]);
    405 % if strcmp(NomTypeInput,'*')% movies will be opened at the first frame
    406 %     i1=1;
    407 %     i2=[];
    408 %     j1=[];
    409 %     j2=[];
    410 % end
     402[RootPath,SubDir,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName ImaExt]);
     403
    411404switch FileType
    412405    case {'image','multimage','video','mmreader'}
     
    415408        return
    416409end
    417 % RootName=fullfile(RootPath,RootFile);
    418410set(handles.RootPath,'String',RootPath)
     411set(handles.SubdirImages,'String',SubDir)
    419412set(handles.RootFile,'String',RootFile)
     413set(handles.SubdirCiv1,'String',[SubDir '.civ'])
    420414browse=get(handles.RootPath,'UserData');
    421 % browse.nom_type_nc=NomTypeNc;
    422415browse.incr_pair=[0 0];%default
    423416
     
    643636
    644637%% update the selection for civ1 and civ2
    645 if ~isempty(SubDir)% subdir for civ1 and civ2 initiated by the input
    646     SubdirCiv1=SubDir;
    647     SubdirCiv2=SubDir;
    648     set(handles.SubdirCiv1,'String',SubDir)
    649     set(handles.SubdirCiv2,'String',SubDir)
    650 else% currently selected subdir preserved
    651     SubdirCiv1=get(handles.SubdirCiv1,'String');
    652     SubdirCiv2=get(handles.SubdirCiv2,'String');
    653     if isempty(SubdirCiv1)% default subdir name='CIV'
    654         set(handles.SubdirCiv1,'String','CIV');
    655         SubdirCiv1='CIV';
    656     end
    657     if isempty(SubdirCiv2)% default subdir name='CIV'
    658         set(handles.SubdirCiv2,'String','CIV');
    659         SubdirCiv2='CIV';
    660     end
    661 end
     638% if ~isempty(SubDir)% subdir for civ1 and civ2 initiated by the input
     639%     SubdirCiv1=SubDir;
     640%     SubdirCiv2=SubDir;
     641%     set(handles.SubdirCiv1,'String',SubDir)
     642%     set(handles.SubdirCiv2,'String',SubDir)
     643% else% currently selected subdir preserved
     644%     SubdirCiv1=get(handles.SubdirCiv1,'String');
     645%     SubdirCiv2=get(handles.SubdirCiv2,'String');
     646%     if isempty(SubdirCiv1)% default subdir name='CIV'
     647%         set(handles.SubdirCiv1,'String','CIV');
     648%         SubdirCiv1='CIV';
     649%     end
     650%     if isempty(SubdirCiv2)% default subdir name='CIV'
     651%         set(handles.SubdirCiv2,'String','CIV');
     652%         SubdirCiv2='CIV';
     653%     end
     654% end
    662655
    663656%% update the subdirectory menus
    664 ValueCiv1=find(strcmp(SubdirCiv1,listdir));%search the index of subdir in the cell listdir
    665 if isempty(ValueCiv1)% if the input subdir is not found
    666     ValueCiv1=numel(listdir)+1;%new subdirectory requested for civ1
    667 end
    668 ValueCiv2=find(strcmp(SubdirCiv2,listdir));%search the index of subdir in the cell listdir
    669 if isempty(ValueCiv2)% if the input subdir is not found
    670     ValueCiv2=numel(listdir)+1;%new subdirectory requested for civ2
    671 end
    672 set(handles.ListSubdirCiv1,'String',[listdir;'new...'])
    673 set(handles.ListSubdirCiv2,'String',[listdir;'new...'])
    674 set(handles.ListSubdirCiv1,'Value',ValueCiv1)
    675 set(handles.ListSubdirCiv2,'Value',ValueCiv2)
    676 if isempty(listdir)
    677     set(handles.SubdirCiv1,'String','CIV')
    678     set(handles.SubdirCiv2,'String','CIV')
    679 end
     657% ValueCiv1=find(strcmp(SubdirCiv1,listdir));%search the index of subdir in the cell listdir
     658% if isempty(ValueCiv1)% if the input subdir is not found
     659%     ValueCiv1=numel(listdir)+1;%new subdirectory requested for civ1
     660% end
     661% ValueCiv2=find(strcmp(SubdirCiv2,listdir));%search the index of subdir in the cell listdir
     662% if isempty(ValueCiv2)% if the input subdir is not found
     663%     ValueCiv2=numel(listdir)+1;%new subdirectory requested for civ2
     664% end
     665% set(handles.ListSubdirCiv1,'String',[listdir;'new...'])
     666% set(handles.ListSubdirCiv2,'String',[listdir;'new...'])
     667% set(handles.ListSubdirCiv1,'Value',ValueCiv1)
     668% set(handles.ListSubdirCiv2,'Value',ValueCiv2)
     669% if isempty(listdir)
     670%     set(handles.SubdirCiv1,'String','CIV')
     671%     set(handles.SubdirCiv2,'String','CIV')
     672% end
    680673
    681674%% store info
     
    802795set(handles.PairIndices,'Visible','on')
    803796set(handles.SubdirCiv1,'Visible','on')
    804 set(handles.ListSubdirCiv1,'Visible','on')
     797%set(handles.ListSubdirCiv1,'Visible','on')
    805798set(handles.TitleSubdirCiv1,'Visible','on')
    806799if ~opening
     
    814807    set(handles.TitleSubdirCiv2,'Visible','on')
    815808    set(handles.SubdirCiv2,'Visible','on')
    816     set(handles.ListSubdirCiv2,'Visible','on')
     809    %set(handles.ListSubdirCiv2,'Visible','on')
    817810    set(handles.ListPairCiv2,'Visible','on')
    818811    if ~opening
     
    825818    set(handles.TitleSubdirCiv2,'Visible','off')
    826819    set(handles.SubdirCiv2,'Visible','off')
    827     set(handles.ListSubdirCiv2,'Visible','off')
     820   % set(handles.ListSubdirCiv2,'Visible','off')
    828821    set(handles.ListPairCiv2,'Visible','off')
    829822end
     
    12161209    return
    12171210end
    1218 [filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,nom_type_nc,xx,yy,compare]=...
     1211[filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,nom_type_nc,tild,tild,compare,errormsg]=...
    12191212    set_civ_filenames(handles,ref_i,ref_j,box_test);
    1220 
     1213if ~isempty(errormsg)
     1214    return
     1215end
     1216% if isempty(filecell)% (error message displayed in fct set_civ_filenames)
     1217%     return
     1218% end
    12211219Rootbat=fileparts(filecell.nc.civ1{1,1});%output netcdf file (without extention)
    12221220set(handles.civ,'UserData',filecell);%store for futur use of status callback
    1223 if isempty(filecell)% (error message displayed in fct set_civ_filenames)
    1224     return
    1225 end
    12261221nbfield=numel(i1_civ1);
    12271222nbslice=numel(j1_civ1);
     
    12831278                Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);%
    12841279            end
    1285             if strcmp(Param.Civ1.FileTypeA,'video')|| strcmp(Param.Civ1.FileTypeA,'mmreader')
     1280            if isfield(Param.Civ1,'FileTypeA')&&(strcmp(Param.Civ1.FileTypeA,'video')|| strcmp(Param.Civ1.FileTypeA,'mmreader'))
    12861281                %   ImageInfo=get(VideoReader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
    12871282                ImageInfo=get(Param.Civ1.ImageA);
     
    12961291                Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};
    12971292                Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j};
    1298                 form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
     1293               % form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
    12991294                ImageInfo=imfinfo(filecell.ima1.civ1{1,1});%read the first image to get the size
    13001295                Param.Civ1.ImageBitDepth=ImageInfo.BitDepth;
    13011296            end
    1302            
    13031297            Param.Civ1.ImageWidth=ImageInfo.Width;
    13041298            Param.Civ1.ImageHeight=ImageInfo.Height;
     
    14341428        end
    14351429        if Param.CheckCiv2==1
    1436             if strcmp(Param.Civ2.FileTypeA,'video')|| strcmp(Param.Civ2.FileTypeA,'mmreader')
     1430            if isfield(Param.Civ2,'FileTypeA') &&(strcmp(Param.Civ2.FileTypeA,'video')|| strcmp(Param.Civ2.FileTypeA,'mmreader'))
    14371431                %   ImageInfo=get(VideoReader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
    14381432                ImageInfo=get(Param.Civ2.ImageA);
     
    18481842Param=rmfield(Param,'xml');
    18491843t=struct2xml(Param);
    1850 t=set(t,1,'Name','CivDoc');% set the head label
    1851 save(t,[namedoc '.CivDoc.xml']); %save GUI  parameters as xml file
     1844t=set(t,1,'name','Civ');% set the head label
     1845save(t,[namedoc '.civ.xml']); %save GUI  parameters as xml file
    18521846saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER  .xml)
    18531847
     
    19121906%       .nc.civ1,.nc.civ2: netcdf files containing civ1 and civ2 data respectively (possibly different)
    19131907% i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2: arrays of files indices, needed for timing records
    1914 function [filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,NomType_nc,file_ref_fix1,file_ref_fix2,compare]=...
     1908function [filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,NomType_nc,file_ref_fix1,file_ref_fix2,compare,errormsg]=...
    19151909    set_civ_filenames(handles,ref_i,ref_j,checkbox)
    19161910%------------------------------------------------------------------------
    19171911filecell=[];%default
     1912errormsg='';
    19181913ListProgram=get(handles.ListProgram,'String');
    19191914CivMode=ListProgram{get(handles.ListProgram,'Value')};%Program to use , CivX or Matlab
     
    19211916%% get the root name and check dir
    19221917RootPath=get(handles.RootPath,'String');
     1918SubdirImages=get(handles.SubdirImages,'String');
    19231919RootFile=get(handles.RootFile,'String');
    1924 filecell.filebase=fullfile(RootPath,RootFile);
     1920filecell.filebase=fullfile(RootPath,SubdirImages,RootFile);
    19251921if isempty(filecell.filebase)
    1926     msgbox_uvmat('ERROR','please open an image with the upper menu option Open/Browse...')
     1922    errormsg='please open an image with the upper menu option Open/Browse...';
    19271923    return
    19281924end
    19291925if ~exist(RootPath,'dir')
    1930     msgbox_uvmat('ERROR',['path to images ' RootPath ' not found'])
     1926    errormsg=['path to images ' RootPath ' not found'];
    19311927    return
    19321928end
    19331929[tild,message]=fileattrib(RootPath);
    19341930if ~isempty(message) && ~isequal(message.UserWrite,1)
    1935     msgbox_uvmat('ERROR',['No writting access to ' RootPath])
     1931    errormsg=['No writting access to ' RootPath];
    19361932    return
    19371933end
     
    20612057                file_ref_fix1(ifile,j)={file_ref};
    20622058                if ~exist(file_ref,'file')
    2063                     msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1'])
    2064                     filecell=[];
     2059                    errormsg=['reference file ' file_ref ' not found for fix1'];
    20652060                    return
    20662061                end
     
    21132108                file_ref_fix2(ifile,j)={file_ref};
    21142109                if ~exist(file_ref,'file')
    2115                     msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2'])
    2116                     filecell={};
     2110                    errormsg=['reference file ' file_ref ' not found for fix2'];
    21172111                    return
    21182112                end
     
    21552149        if ~exist(fullfile(RootPath,subdir_civ1_new),'dir')     
    21562150            [xx,msg1]=mkdir(fullfile(RootPath,subdir_civ1_new));
    2157 
    21582151            if ~strcmp(msg1,'')
    2159                 msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation
    2160                 filecell={};
     2152                errormsg=['cannot create ' subdir_civ1_new ': ' msg1];%error message for directory creation
    21612153                return
    21622154            elseif isunix         
    21632155                [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g)
    21642156                if ~strcmp(msg2,'')
    2165                     msgbox_uvmat('ERROR',['pb of permission for  ' fullfile(RootPath,subdir_civ1_new) ': ' msg2])%error message for directory creation
    2166                     filecell={};
     2157                    errormsg=['pb of permission for  ' fullfile(RootPath,subdir_civ1_new) ': ' msg2];%error message for directory creation
    21672158                    return
    21682159                end
     
    21972188                [xx,msg1]=mkdir(fullfile(RootPath,subdir_civ1_new));
    21982189                if ~strcmp(msg1,'')
    2199                     msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])
    2200                     filecell={};
     2190                    errormsg=['cannot create ' subdir_civ1_new ': ' msg1];
    22012191                    return
    22022192                else
    22032193                    [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g)
    22042194                    if ~strcmp(msg2,'')
    2205                         msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation
    2206                         filecell={};
     2195                        errormsg=['pb of permission for ' subdir_civ1_new ': ' msg2];%error message for directory creation
    22072196                        return
    22082197                    end
     
    22152204    for ifile=1:nbfield
    22162205        for j=1:nbslice
    2217              filename=fullfile_uvmat(RootPath,'',RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j));
     2206             filename=fullfile_uvmat(RootPath,SubdirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j));
    22182207            idetect(j)=exist(filename,'file')==2;
    22192208            filecell.ima1.civ1(ifile,j)={filename}; %first image
    2220             filename=fullfile_uvmat(RootPath,'',RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j));
     2209            filename=fullfile_uvmat(RootPath,SubdirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j));
    22212210            idetect_1(j)=exist(filename,'file')==2;
    22222211            filecell.ima2.civ1(ifile,j)={filename};%second image
     
    22242213        [idetectmin,indexj]=min(idetect);
    22252214        if idetectmin==0,
    2226             msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found'])
    2227             filecell={};
     2215            errormsg=[filecell.ima1.civ1{ifile,indexj} ' not found'];
    22282216            return
    22292217        end
    22302218        [idetectmin,indexj]=min(idetect_1);
    22312219        if idetectmin==0,
    2232             msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found'])
    2233             filecell={};
     2220            errormsg=[filecell.ima2.civ1{ifile,indexj} ' not found'];
    22342221            return
    22352222        end
     
    22472234            [idetectmin,indexj]=min(idetect);
    22482235            if idetectmin==0,
    2249                 msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found'])
    2250                 filecell={};
    2251                % cd(currentdir)
     2236                errormsg=[filecell.imaA1.civ1{ifile,indexj} ' not found'];
    22522237                return
    22532238            end
    22542239            [idetectmin,indexj]=min(idetect_1);
    22552240            if idetectmin==0,
    2256                 msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found'])
    2257                 filecell={};
    2258                % cd(currentdir)
     2241                errormsg=[filecell.imaA2.civ1{ifile,indexj} ' not found'];
    22592242                return
    22602243            end
     
    22692252            detect=exist(filename,'file')==2;
    22702253            if detect==0
    2271                 msgbox_uvmat('ERROR',[filename ' not found'])
    2272                 filecell={};
    2273                % cd(currentdir)
     2254                errormsg=[filename ' not found'];
    22742255                return
    22752256            end
     
    22832264                filecell.ncA.civ1(ifile,j)={filename};
    22842265                if ~exist(filename,'file')
    2285                     msgbox_uvmat('ERROR',['input file ' filename ' not found'])
    2286                     set(handles.RUN, 'Enable','On')
    2287                     set(handles.RUN,'BackgroundColor',[1 0 0])
    2288                     filecell={};
    2289                     %cd(currentdir)
     2266                    errormsg=['input file ' filename ' not found'];
    22902267                    return
    22912268                end
     
    23302307            [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g)
    23312308            if ~isequal(m2,'')
    2332                 msgbox_uvmat('ERROR',['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2])
    2333                 filecell={};
     2309                errormsg=['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2];
    23342310                return
    23352311            end
     
    23632339                 [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g)
    23642340                if ~isequal(m2,'')
    2365                     msgbox_uvmat('ERROR', ['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2])%error message for directory creation
    2366                   %  cd(currentdir)
    2367                     filecell={};
     2341                    errormsg= ['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2];%error message for directory creation
    23682342                    return
    23692343                end
     
    23732347    subdir_civ2=subdir_civ2_new;
    23742348end
    2375 %cd(currentdir);%come back to the current working directory
    23762349
    23772350%%%%%%%%%%%%%  if checkciv2 results are obtained or used  %%%%%%%%%%%%%
     
    23842357                filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file
    23852358                if ~exist(filename,'file')
    2386                     msgbox_uvmat('ERROR',['input file ' filename ' not found'])
    2387                     filecell={};
     2359                    errormsg=['input file ' filename ' not found'];
    23882360                    return
    23892361                end
     
    23922364                        Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2');
    23932365                        if isfield(Data,'Txt')
    2394                             msgbox_uvmat('ERROR',Data.Txt);
     2366                            errormsg=Data.Txt;
    23952367                            return
    23962368                        elseif ~isempty(Data.CivStage)% case of new civ files
    23972369                            if Data.CivStage<4 %test for civ files
    2398                             msgbox_uvmat('ERROR',['no civ2 data in ' filename])
    2399                             filecell=[];
     2370                            errormsg=['no civ2 data in ' filename];
    24002371                            return
    24012372                            end
    24022373                        elseif isempty(Data.civ2)||isequal(Data.civ2,0)
    2403                             msgbox_uvmat('ERROR',['no civ2 data in ' filename])
    2404                             filecell=[];
     2374                            errormsg=['no civ2 data in ' filename];
    24052375                            return
    24062376                        end
    24072377                    elseif checkbox(3)==0; %check the existence of patch if it is not calculated
    24082378                        Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch');
    2409                         if ~isempty(Data.CivStage)
     2379                        if isfield(Data,'Txt')
     2380                            errormsg=Data.Txt;
     2381                            return
     2382                        elseif ~isempty(Data.CivStage)
    24102383                            if Data.CivStage<3 %test for civ files
    2411                                 msgbox_uvmat('ERROR',['no patch data in ' filename])
    2412                                 filecell=[];
     2384                                errormsg=['no patch data in ' filename];
    24132385                                return
    24142386                            end
    24152387                        elseif isempty(Data.patch)||isequal(Data.patch,0)
    2416                             msgbox_uvmat('ERROR',['no patch data in ' filename])
    2417                             filecell=[];
     2388                            errormsg=['no patch data in ' filename];
    24182389                            return
    24192390                        end
     
    24282399                    filecell.ncA.civ2(ifile,j)={filename};
    24292400                    if ~exist(filename,'file')
    2430                         msgbox_uvmat('ERROR',['input file ' filename ' not found'])
    2431                         set(handles.RUN, 'Enable','On')
    2432                         set(handles.RUN,'BackgroundColor',[1 0 0])
     2401                        errormsg=['input file ' filename ' not found'];
    24332402                        return
    24342403                    end
     
    24592428            [idetectmin,indexj]=min(idetect_2);
    24602429            if idetectmin==0,
    2461                 msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found'])
    2462                 filecell=[];
     2430               errormsg=['input image ' filecell.ima1.civ2{ifile,indexj} ' not found'];
    24632431                return
    24642432            end
     
    24782446            [idetectmin,indexj]=min(idetect_3);
    24792447            if idetectmin==0,
    2480                 msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found'])
    2481                 filecell=[];
     2448                errormsg=['input image ' filecell.ima2.civ2{ifile,indexj} ' not found'];
    24822449                return
    24832450            end
     
    24942461                filecell.nc.civ2(ifile,j)={filename};
    24952462                if ~exist(filename,'file')
    2496                     msgbox_uvmat('ERROR',['input file ' filename ' not found'])
    2497                     filecell=[];
     2463                    errormsg=['input file ' filename ' not found'];
    24982464                    return
    24992465                else
    25002466                    Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2');
    25012467                    if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files
    2502                             msgbox_uvmat('ERROR',['no civ2 data in ' filename])
    2503                             filecell=[];
     2468                            errormsg=['no civ2 data in ' filename];
    25042469                            return
    25052470                    elseif isempty(Data.civ2)||isequal(Data.civ2,0)
    2506                         msgbox_uvmat('ERROR',['no civ2 data in ' filename])
    2507                         filecell=[];
     2471                        errormsg=['no civ2 data in ' filename];
    25082472                        return
    25092473                    end
     
    33163280%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    33173281%------------------------------------------------------------------------
    3318 % --- Executes on button press in SearchRange: determine the search range num_Searchx,num_Searchy
     3282% --- Executes on button press in SearchRange: determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2
    33193283function SearchRange_Callback(hObject, eventdata, handles)
    33203284%------------------------------------------------------------------------
     
    33383302
    33393303%------------------------------------------------------------------------
    3340 % ---  determine the search range num_Searchx,num_Searchy and shift
     3304% ---  determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 and shift
    33413305function get_search_range(hObject, eventdata, handles)
    33423306%------------------------------------------------------------------------
     
    33943358    end
    33953359    dt=time(num2+1,num_b+1)-time(num1+1,num_a+1);
    3396     ibx=str2double(get(handles.num_Bx,'String'));
    3397     iby=str2double(get(handles.num_By,'String'));
     3360    ibx=str2double(get(handles.num_CorrBoxSize_1,'String'));
     3361    iby=str2double(get(handles.num_CorrBoxSize_2,'String'));
    33983362    umin=dt*pxcm*umin;
    33993363    umax=dt*pxcm*umax;
     
    34063370    isy=(vmax+2-shifty)*2+param_civ1.Bx;
    34073371    isy=2*ceil(isy/2)+1;
    3408     set(handles.num_Shiftx,'String',num2str(shiftx));
    3409     set(handles.num_Shifty,'String',num2str(shifty));
    3410     set(handles.num_Searchx,'String',num2str(isx));
    3411     set(handles.num_Searchy,'String',num2str(isy));
     3372    set(handles.num_SearchBoxShift_1,'String',num2str(shiftx));
     3373    set(handles.num_SearchBoxShift_2,'String',num2str(shifty));
     3374    set(handles.num_SearchBoxSize_1,'String',num2str(isx));
     3375    set(handles.num_SearchBoxSize_2,'String',num2str(isy));
    34123376end
    34133377
     
    39813945if isequal(get(hObject,'Value'),0)
    39823946    set(handles.num_SubdomainSize,'Visible','on')
    3983     set(handles.num_SmoothingParam,'Visible','on')
     3947    set(handles.num_FieldSmooth,'Visible','on')
    39843948else
    39853949    set(handles.num_SubdomainSize,'Visible','off')
    3986     set(handles.num_SmoothingParam,'Visible','off')
     3950    set(handles.num_FieldSmooth,'Visible','off')
    39873951end
    39883952
     
    39933957% if isequal(get(handles.CheckStereo,'Value'),0)
    39943958%     set(handles.num_SubdomainSize,'Visible','on')
    3995 %     set(handles.num_SmoothingParam,'Visible','on')
     3959%     set(handles.num_FieldSmooth,'Visible','on')
    39963960% else
    39973961%     set(handles.num_SubdomainSize,'Visible','off')
    3998 %     set(handles.num_SmoothingParam,'Visible','off')
     3962%     set(handles.num_FieldSmooth,'Visible','off')
    39993963% end
    40003964
     
    40133977        ref_j=1;%default j index
    40143978    end
    4015     [filecell,i1,i2,j1,j2,i1_civ2,i2_civ2,j1_civ2,j2_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
    4016         set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);% get the corresponding file name and indices
     3979    [filecell,i1,i2]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);% get the corresponding file name and indices
    40173980    Data.ListVarName={'ny','nx','A'};
    40183981    Data.VarDimName= {'ny','nx',{'ny','nx'}};
     
    41144077end
    41154078fprintf(fid,   ['ImageSize ' num2str(Param.Civ1.ImageWidth) ' ' num2str(Param.Civ1.ImageHeight) '\n' ]);   %VERIFIER CAS GENERAL ?
    4116 fprintf(fid,   ['CorrelationBoxesSize ' num2str(Param.Civ1.Bx) ' ' num2str(Param.Civ1.By) '\n' ]);
    4117 fprintf(fid,   ['SearchBoxeSize ' num2str(Param.Civ1.Searchx) ' ' num2str(Param.Civ1.Searchy) '\n' ]);
    4118 fprintf(fid,   ['RO ' num2str(Param.Civ1.Rho) '\n' ]);
     4079fprintf(fid,   ['CorrelationBoxesSize ' num2str(Param.Civ1.CorrBoxSize(1)) ' ' num2str(Param.Civ1.CorrBoxSize(2)) '\n' ]);
     4080fprintf(fid,   ['SearchBoxeSize ' num2str(Param.Civ1.SearchBoxSize(1)) ' ' num2str(Param.Civ1.SearchBoxSize(2)) '\n' ]);
     4081fprintf(fid,   ['RO ' num2str(Param.Civ1.CorrSmooth) '\n' ]);
    41194082if isfield(Param.Civ1,'Grid')
    41204083    fprintf(fid,   ['GridSpacing ' '25' ' ' '25' '\n' ]);
     
    41264089fprintf(fid,  ['PixCmXY ' '1' ' ' '1' '\n' ]);
    41274090fprintf(fid,  ['XX 1' '\n' ]);
    4128 fprintf(fid,   ['ShiftXY ' num2str(Param.Civ1.Shiftx) ' '  num2str(Param.Civ1.Shifty) '\n' ]);
     4091fprintf(fid,   ['ShiftXY ' num2str(Param.Civ1.SearchBoxShift(1)) ' '  num2str(Param.Civ1.SearchBoxShift(2)) '\n' ]);
    41294092if isfield(Param.Civ1,'Grid')
    41304093    fprintf(fid,  ['Grid ' 'y' '\n' ]);
     
    42034166    cmd=[Param.xml.PatchBin...
    42044167        ' -f ' filename '.nc -m ' num2str(Param.(patchname).Nx)...
    4205         ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).SmoothingParam)...
     4168        ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).FieldSmooth)...
    42064169        ' -nopt ' num2str(Param.(patchname).SubdomainSize) ...
    42074170        '  > ' filename '.' lower(patchname) '.log 2>&1']; % redirect standard output to the log file
     
    42094172    cmd=['"' Param.xml.PatchBin...
    42104173        '" -f "' filename '.nc" -m ' num2str(Param.(patchname).Nx)...
    4211         ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).SmoothingParam)...
     4174        ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).FieldSmooth)...
    42124175        ' -nopt ' num2str(Param.(patchname).SubdomainSize)...
    42134176        '  > "' filename '.' lower(patchname) '.log" 2>&1']; % redirect standard output to the log file
     
    42474210fprintf(fid,   ['ImageSize ' num2str(Param.Civ2.ImageWidth) ' ' num2str(Param.Civ2.ImageHeight) '\n' ]); 
    42484211% fprintf(fid, ['ImageSize ' num2str(Param.Civ2.npx) ' ' num2str(Param.Civ2.npy) '\n' ]);   %VERIFIER CAS GENERAL ?
    4249 fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n' ]);
    4250 fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n']);
    4251 fprintf(fid, ['RO ' num2str(Param.Civ2.Rho) '\n']);
     4212fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ2.CorrBoxSize(1)) ' ' num2str(Param.Civ2.CorrBoxSize(2)) '\n' ]);
     4213fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ2.CorrBoxSize(1)) ' ' num2str(Param.Civ2.CorrBoxSize(2)) '\n']);
     4214fprintf(fid, ['RO ' num2str(Param.Civ2.CorrSmooth) '\n']);
    42524215if isfield(Param.Civ2,'Grid')
    42534216    fprintf(fid,   ['GridSpacing ' '25' ' ' '25' '\n' ]);
     
    44064369        ref_j=1;%default
    44074370    end
    4408     [filecell,i1,i21,j1,j2,i1_civ2,i2_civ2,j1_civ2,j2_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
    4409         set_civ_filenames(handles,ref_i,ref_j,[0 0 1 0 0 0]);
    4410    
     4371    filecell=set_civ_filenames(handles,ref_i,ref_j,[0 0 1 0 0 0]);   
    44114372    Data.ListVarName={'ny','nx','A'};
    4412     Data.VarDimName= {'ny','nx',{'ny','nx'}};
    4413    
     4373    Data.VarDimName= {'ny','nx',{'ny','nx'}};   
    44144374    param_patch1=read_GUI(handles.Patch1);
    44154375    param_patch1.CivFile=filecell.nc.civ1{1};
     
    44214381            return
    44224382        end
    4423         SmoothingParam(irho)=Param.Patch1.SmoothingParam;
     4383        SmoothingParam(irho)=Param.Patch1.FieldSmooth;
    44244384        Data.Civ1_U_Diff=Data.Civ1_U_Diff(Data.Civ1_FF==0);
    44254385        Data.Civ1_V_Diff=Data.Civ1_V_Diff(Data.Civ1_FF==0);
    44264386        DiffVel(irho)=sqrt(mean(Data.Civ1_U_Diff.*Data.Civ1_U_Diff+Data.Civ1_V_Diff.*Data.Civ1_V_Diff))
    44274387        NbSites(irho,:)=Data.Civ1_NbSites*numel(Data.Civ1_NbSites)/numel(Data.Civ1_U_Diff);
    4428         Param.Patch1.SmoothingParam=2*Param.Patch1.SmoothingParam;
     4388        Param.Patch1.SmoothingParam=2*Param.Patch1.FieldSmooth;
    44294389    end
    44304390    figure
     
    45284488        set(handles.title_Ny,'Visible','on')
    45294489        set(handles.title_MaxDiff,'Visible','off')
    4530         set(handles.num_Rho,'Style','edit')
    4531         set(handles.num_Rho,'String','1')
     4490        set(handles.num_CorrSmooth,'Style','edit')
     4491        set(handles.num_CorrSmooth,'String','1')
    45324492        set(handles.BATCH,'Enable','on')
    45334493        set(handles.CheckThreshold,'Visible','off')
     
    45434503        set(handles.title_Nx,'Visible','off')
    45444504        set(handles.title_Ny,'Visible','off')
    4545         set(handles.num_Rho,'Style','popupmenu')
    4546         set(handles.num_Rho,'Value',1)
    4547         set(handles.num_Rho,'String',{'1';'2'})
     4505        set(handles.num_CorrSmooth,'Style','popupmenu')
     4506        set(handles.num_CorrSmooth,'Value',1)
     4507        set(handles.num_CorrSmooth,'String',{'1';'2'})
    45484508        set(handles.CheckThreshold,'Visible','on')
    45494509        set(handles.CheckDeformation,'Value',0)% desactivate (work in progress)
     
    45584518
    45594519function RootFile_Callback(hObject, eventdata, handles)
     4520
     4521
     4522
     4523function SubdirImages_Callback(hObject, eventdata, handles)
  • trunk/src/civ_matlab.m

    r435 r437  
    209209   
    210210    Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_Rho','Patch1_Threshold','Patch1_SubDomain'}];
    211     Data.Patch1_Rho=Param.Patch1.SmoothingParam;
     211    Data.Patch1_Rho=Param.Patch1.FieldSmooth;
    212212    Data.Patch1_Threshold=Param.Patch1.MaxDiff;
    213213    Data.Patch1_SubDomain=Param.Patch1.SubdomainSize;
     
    263263        par_civ2.ImageB=par_civ1.ImageB;
    264264    end
    265     ibx2=ceil(par_civ2.Bx/2);
    266     iby2=ceil(par_civ2.By/2);
     265    ibx2=ceil(par_civ2.CorrBoxSize(1)/2);
     266    iby2=ceil(par_civ2.CorrBoxSize(2)/2);
    267267    isx2=ibx2+4;% search ara +-4 pixels around the guess
    268268    isy2=iby2+4;
     
    308308        mask=imread(par_civ2.Mask);
    309309    end
    310     par_civ2.Searchx=2*isx2+1;
    311     par_civ2.Searchy=2*isy2+1;
    312     par_civ2.Shiftx=Shiftx(nbval>=1)./nbval(nbval>=1);
    313     par_civ2.Shifty=Shifty(nbval>=1)./nbval(nbval>=1);
    314     par_civ2.Grid=[GridX(nbval>=1)-par_civ2.Shiftx/2 GridY(nbval>=1)-par_civ2.Shifty/2];% grid taken at the extrapolated origin of the displacement vectors
     310    par_civ2.SearchBoxSize(1)=2*isx2+1;
     311    par_civ2.SearchBoxSize(2)=2*isy2+1;
     312    par_civ2.SearchBoxShift=[Shiftx(nbval>=1)./nbval(nbval>=1) Shifty(nbval>=1)./nbval(nbval>=1)];
     313%     par_civ2.SearchBoxShift(2)=Shifty(nbval>=1)./nbval(nbval>=1);
     314    par_civ2.Grid=[GridX(nbval>=1)-par_civ2.SearchBoxShift(:,1)/2 GridY(nbval>=1)-par_civ2.SearchBoxShift(:,2)/2];% grid taken at the extrapolated origin of the displacement vectors
    315315    if par_civ2.CheckDeformation
    316316        par_civ2.DUDX=DUDX./nbval;
     
    392392if isfield (Param,'Patch2')
    393393    Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch2_Rho','Patch2_Threshold','Patch2_SubDomain'}];
    394     Data.Patch2_Rho=Param.Patch2.SmoothingParam;
     394    Data.Patch2_Rho=Param.Patch2.FieldSmooth;
    395395    Data.Patch2_Threshold=Param.Patch2.MaxDiff;
    396396    Data.Patch2_SubDomain=Param.Patch2.SubdomainSize;
     
    454454
    455455%% prepare grid
    456 ibx2=ceil(par_civ.Bx/2);
    457 iby2=ceil(par_civ.By/2);
    458 isx2=ceil(par_civ.Searchx/2);
    459 isy2=ceil(par_civ.Searchy/2);
    460 shiftx=round(par_civ.Shiftx);
    461 shifty=-round(par_civ.Shifty);% sign minus because image j index increases when y decreases
     456ibx2=ceil(par_civ.CorrBoxSize(1)/2);
     457iby2=ceil(par_civ.CorrBoxSize(2)/2);
     458isx2=ceil(par_civ.SearchBoxSize(1)/2);
     459isy2=ceil(par_civ.SearchBoxSize(2)/2);
     460shiftx=round(par_civ.SearchBoxShift(:,1));
     461shifty=-round(par_civ.SearchBoxShift(:,2));% sign minus because image j index increases when y decreases
    462462if isfield(par_civ,'Grid')
    463463    if ischar(par_civ.Grid)%read the drid file if the input is a file name
     
    466466    end
    467467else% automatic measurement grid
    468     ibx2=ceil(par_civ.Bx/2);
    469     iby2=ceil(par_civ.By/2);
    470     isx2=ceil(par_civ.Searchx/2);
    471     isy2=ceil(par_civ.Searchy/2);
     468%     ibx2=ceil(par_civ.Bx/2);
     469%     iby2=ceil(par_civ.By/2);
     470%     isx2=ceil(par_civ.Searchx/2);
     471%     isy2=ceil(par_civ.Searchy/2);
    472472    miniy=max(1+isy2+shifty,1+iby2);
    473473    minix=max(1+isx2-shiftx,1+ibx2);
     
    609609            if ~isempty(y) && ~isempty(x)
    610610                try
    611                     if par_civ.Rho==1
     611                    if par_civ.CorrSmooth==1
    612612                        [vector,F(ivec)] = SUBPIXGAUSS (result_conv,x,y);
    613                     elseif par_civ.Rho==2
     613                    elseif par_civ.CorrSmooth==2
    614614                        [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y);
    615615                    end
  • trunk/src/fileparts_uvmat.m

    r405 r437  
    143143
    144144%% extract subdirectory for pairs i1-i2 or j1-j2 (or ab, AB)
    145 if ~isempty(i2) || ~isempty(j2)
     145% if ~isempty(i2) || ~isempty(j2)
    146146    r=regexp(RootPath,'\<(?<newrootpath>.+)(\\|/)(?<subdir>[^\\^/]+)(\\|/)*\>','names');
    147147    if ~isempty(r)
     
    149149        RootPath=r.newrootpath;
    150150    end
    151 end
    152 
    153 % if ~isempty(regexp(NomType,'-|ab|AB'))
    154 %     r=regexp(RootPath,'\<(?<newrootpath>.+)(\\|/)(?<subdir>[^\\^/]+)(\\|/)*\>','names');
    155 %     if ~isempty(r)
    156 %     SubDir=r.subdir;
    157 %     RootPath=r.newrootpath;
    158 %     end
    159151% end
     152
    160153
    161154
Note: See TracChangeset for help on using the changeset viewer.