Changeset 469


Ignore:
Timestamp:
Jun 22, 2012, 3:45:06 PM (12 years ago)
Author:
sommeria
Message:

several bugs corrected
introductyion of functions find_imadoc and read_multimadoc which simplifiy the functions under series

Location:
trunk/src
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r468 r469  
    2424%TODO: search range
    2525
    26 % Last Modified by GUIDE v2.5 21-Jun-2012 20:22:39
     26% Last Modified by GUIDE v2.5 21-Jun-2012 23:37:47
    2727% Begin initialization code - DO NOT EDIT
    2828gui_Singleton = 1;
     
    302302set(handles.RUN, 'Enable','On')
    303303set(handles.RUN,'BackgroundColor',[1 0 0])%set RUN button to red color
    304 set(handles.BATCH,'Enable','On')
    305 set(handles.BATCH,'BackgroundColor',[1 0 0])%set BATCH button to red color
     304% set(handles.BATCH,'Enable','On')
     305% set(handles.BATCH,'BackgroundColor',[1 0 0])%set BATCH button to red color
    306306if isfield(handles,'status')
    307307    set(handles.status,'Value',0);       %suppress the 'status' display
     
    339339    % settings for  new civ data,
    340340    if strcmp(Data.Conventions,'uvmat/civdata')% case of new civ data,
    341         set(handles.ListProgram,'Value',2) %select civ/Matlab by default
     341        set(handles.Program,'Value',2) %select civ/Matlab by default
    342342        ListProgram_Callback([],[], handles)
    343343        if ~isempty(Data.CivStage)%test for civ files
     
    355355        % settings for civx data,
    356356    elseif ~isempty(Data.absolut_time_T0')% case of  civx data,
    357         set(handles.ListProgram,'Value',1) %select Cix by default
     357        set(handles.Program,'Value',1) %select Cix by default
    358358        ListProgram_Callback([],[], handles)
    359359        if ~isempty(Data.fix2)
     
    388388end
    389389
    390 %no corresponding image found, select manually with the browser
     390%% no corresponding image found, select manually with the browser
    391391ImaExt=ExtInput;
    392392if ~isempty(NomTypeNc)
     
    400400            '*.*',  'All Files (*.*)'};
    401401        [FileName, PathName] = uigetfile( menu, 'Pick an input image file',fileparts(fileparts(fileinput)));
    402         imageinput=[PathName FileName];%complete file name
    403      
     402        fileinput=[PathName FileName];%complete file name
     403        if ~exist(fileinput,'file')
     404            return %abandon of the browser is cancelled
     405        end
    404406    end   
    405     fileinput=imageinput;
     407    %fileinput=imageinput;
    406408end
    407409
     
    410412% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    411413% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    412 [RootPath,SubdirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName ImaExt]);
    413 
     414[RootPath,SubdirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName ImaExt]);
    414415switch FileType
    415416    case {'image','multimage','video','mmreader'}
     
    448449
    449450%% look for an image documentation file
    450 ext_imadoc='';%default
    451 SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
    452 filexml=fullfile(RootPath,[SubDirBase '.xml']);% new convention: xml above the image dir
    453 if ~exist(filexml,'file')
    454     filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy
    455 end
    456 RootName=fullfile(RootPath,RootFile);
    457 if exist(filexml,'file')
    458     ext_imadoc='.xml';
    459 elseif exist(fullfile(RootPath,SubDir,[RootFile '.civ']),'file')
    460     ext_imadoc='.civ';
    461     fileciv=fullfile(RootPath,SubDir,[RootFile '.civ']);
    462 elseif exist([RootName '.avi'],'file')
    463     ext_imadoc='.avi';
    464 elseif exist([RootName '.AVI'],'file')
    465     ext_imadoc='.AVI';
     451XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt);
     452% SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
     453% filexml=fullfile(RootPath,[SubDirBase '.xml']);% new convention: xml above the image dir
     454% if ~exist(filexml,'file')
     455%     filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy
     456%     if ~exist(filexml,'file')
     457%         filexml=fullfile(RootPath,SubDir,[RootFile '.civ']);%very old convention: .civ file
     458%         if ~exist(filexml,'file')
     459%             filexml='';
     460%         end
     461%     end
     462% end
     463if isempty(XmlFileName)
     464    if (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
     465        ext_imadoc=ImaExt;% the timing from the video movie is used
     466    else
     467        ext_imadoc='';
     468    end
     469else
     470    [tild,tild,ext_imadoc]=fileparts(XmlFileName);
    466471end
    467472set(handles.ImaDoc,'String',ext_imadoc)% display the extension name for the image documentation file used
     
    472477CoordUnit='';%default
    473478pxcm_search=1;
    474 if ~isempty(ext_imadoc)
     479if ~isempty(XmlFileName)
    475480    set(handles.ImaDoc,'BackgroundColor',[1 1 0]) % set edit box to yellow cloro to indicate that the file reading is beginning
    476481    drawnow
    477     switch ext_imadoc
    478         case '.xml'
    479             [XmlData,warntext]=imadoc2struct(filexml);
    480             ext_ima_read=[];
    481             nom_type_read=[];
    482             if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file
    483                 %[PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName);
    484                 [~,tild,tild,tild,tild,tild,tild,tild,nom_type_read]=fileparts_uvmat(XmlData.Heading.ImageName);
    485                 fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file,
    486                 if ~exist(fullname,'file')
    487                     msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist'])
    488                 end
    489             end
    490             if isfield(XmlData,'Time') && ~isempty(XmlData.Time)
    491                 time=XmlData.Time;
    492                 %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml
    493                 if isequal(MaxIndex_i,1) && ~isequal(MaxIndex_j,1)% .Time is a line vector
    494                     if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once'))
    495                         time=time';
    496                         MaxIndex_i=MaxIndex_j;
    497                         MaxIndex_j=1;
    498                     end
    499                 end
    500             end
    501             if isfield(XmlData,'TimeUnit')
    502                 TimeUnit=XmlData.TimeUnit;
    503             end
    504            
    505             if isfield(XmlData,'GeometryCalib')
    506                 tsai=XmlData.GeometryCalib;
    507                 if isfield(tsai,'fx_fy')
    508                     pxcm_search=max(tsai.fx_fy(1),tsai.fx_fy(2));%pixels:cm estimated for the search range
    509                 end
    510                 if isfield(tsai,'CoordUnit')
    511                     CoordUnit=tsai.CoordUnit;
    512                 end
    513             end
    514         case '.civ'% OBSOLETE: case of .civ image documentation file
    515             [error,time,TimeUnit,mode,npx,npy]=read_imatext(fileciv);
    516             if error==2, msgbox_uvmat('WARNING',['no file ' fileciv]);
    517             elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
    518             end
    519             nom_type_ima='001a';
    520     end
    521     if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
    522         nom_type_ima='*';
    523         %ImaExt=ext_imadoc;
    524         set(handles.ListPairMode,'Value',1);
    525         set(handles.ListPairMode,'String',{'series(Di)'})
    526         dt=0.04;%default
    527         hhh=which('videoreader');
    528         if strcmp(FileType,'mmreader')%use old video function of matlab
    529             imainfo=aviinfo(fileinput);%read infos on the avi movie TO REPLACE mmreader
    530             dt=1/imainfo.FramesPerSecond;%time interval between successive frames
    531             MaxIndex_i=imainfo.NumFrames;%number of frames
    532         else %use video function videoreader of matlab
    533             imainfo=get(videoreader(fileinput));%read infos on the avi movie
    534             dt=1/imainfo.FrameRate;%time interval between successive frames
    535             MaxIndex_i=imainfo.NumberOfFrames;%number of frames
    536         end       
    537         time=(dt*(0:MaxIndex_i-1))';%list of image times
    538         TimeUnit='s';
    539         set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter
    540     end
    541 end
     482    [XmlData,warntext]=imadoc2struct(XmlFileName);
     483    nom_type_read=[];
     484    if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file
     485        [~,tild,tild,tild,tild,tild,tild,tild,nom_type_read]=fileparts_uvmat(XmlData.Heading.ImageName);
     486        fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file,
     487        if ~exist(fullname,'file')
     488            msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist'])
     489        end
     490    end
     491    if isfield(XmlData,'Time') && ~isempty(XmlData.Time)
     492        time=XmlData.Time;
     493        %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml
     494        if isequal(MaxIndex_i,1) && ~isequal(MaxIndex_j,1)% .Time is a line vector
     495            if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once'))
     496                time=time';
     497                MaxIndex_i=MaxIndex_j;
     498                MaxIndex_j=1;
     499            end
     500        end
     501    end
     502    if isfield(XmlData,'TimeUnit')
     503        TimeUnit=XmlData.TimeUnit;
     504    end
     505    if isfield(XmlData,'GeometryCalib')
     506        tsai=XmlData.GeometryCalib;
     507        if isfield(tsai,'fx_fy')
     508            pxcm_search=max(tsai.fx_fy(1),tsai.fx_fy(2));%pixels:cm estimated for the search range
     509        end
     510        if isfield(tsai,'CoordUnit')
     511            CoordUnit=tsai.CoordUnit;
     512        end
     513    end
     514end
     515if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
     516    set(handles.ListPairMode,'Value',1);
     517    set(handles.ListPairMode,'String',{'series(Di)'})
     518    dt=1/get(MovieObject,'FrameRate');%time interval between successive frames
     519    MaxIndex_i=get(MovieObject,'NumberOfFrames');
     520    time=(dt*(0:MaxIndex_i-1))';%list of image times
     521    TimeUnit='s';
     522    set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter
     523end
     524
    542525%% timing display
    543526%show the reference image edit box if relevant (not needed for movies or in the absence of time information
     
    547530    time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices)
    548531    time=[zeros(1,size(time,2)); time]; %insert a horizontal line of zeros
    549     set(handles.ImaDoc,'UserData',time); %store the matrix of times
    550     set(handles.dt_unit,'String',['dt in m' TimeUnit]);
    551     set(handles.TimeUnit,'String',TimeUnit);
    552532else
    553533    set(handles.ImaDoc,'String',''); %xml file not used for timing
     
    801781set(handles.RUN, 'Enable','Off')
    802782set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
    803 batch=get(handles.RunMode,'Value');
     783%batch=get(handles.RunMode,'Value');
    804784% batch=0;
    805 errormsg=launch_jobs(hObject, eventdata, handles,batch);
     785errormsg=launch_jobs(hObject, eventdata, handles);
    806786set(handles.RUN, 'Enable','On')
    807787set(handles.RUN,'BackgroundColor',[1 0 0])
     
    10211001%------------------------------------------------------------------------
    10221002% --- Main lauch command, called by RUN and BATCH
    1023 function errormsg=launch_jobs(hObject, eventdata, handles, batch)
     1003function errormsg=launch_jobs(hObject, eventdata, handles)
    10241004%------------------------------------------------------------------------
    10251005errormsg='';%default
     
    10871067    return
    10881068end
    1089 test_interp=0; %eviter les variables test_ (LG)
    1090 if batch==3 %computation dispatched on a cluster
     1069% test_interp=0; %eviter les variables test_ (LG)
     1070if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster
    10911071    if isfield(s,'BatchParam')
    10921072        Param.xml=s.BatchParam;
     
    11121092
    11131093%% check batch mode supported
    1114 if batch==3 %computation dispatched on a cluster
     1094if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster
    11151095    switch batch_mode
    11161096        case 'sge'
     
    11271107
    11281108%% check if the binaries exist
    1129 ListProgram=get(handles.ListProgram,'String');
    1130 Param.CivMode=ListProgram{get(handles.ListProgram,'Value')};
     1109% ListProgram=get(handles.Program,'String');
     1110% Param.CivMode=ListProgram{get(handles.Program,'Value')};
    11311111binary_list={};
    1132 switch Param.CivMode
     1112switch Param.Program
    11331113    case 'CivX'
    11341114        binary_list={'Civ1Bin','Civ2Bin','PatchBin','FixBin'};
    11351115    case 'CivAll'% desactivated option
    11361116        binary_list={'Civ'};
    1137     case 'Matlab'
     1117    case 'civ_matlab.sh'% compiled version of civ_matlab
    11381118        if batch
    11391119            binary_list={'CivmBin'};
     
    11941174
    11951175   
    1196 %% PARTIE A VERIFIER
    1197 %output netcdf file (without extention) Joel what does this mean ?
     1176%% get information on input images or movies
    11981177nbfield=numel(i1_civ1);
    11991178nbslice=numel(j1_civ1);
    1200 if ~strcmp(Param.CivMode,'CivX')
     1179% if strcmp(Param.Program,'civ_matlab')
    12011180    if Param.CheckCiv1
    1202         [Param.Civ1.FileTypeA,FileInfo,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1});
    1203         [Param.Civ1.FileTypeB,FileInfo,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1});
     1181        [Param.Civ1.FileTypeA,ImageInfoA_civ1,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1});
     1182        [Param.Civ1.FileTypeB,ImageInfoB_civ1,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1});
    12041183    end
    12051184    if Param.CheckCiv2
    1206         [Param.Civ2.FileTypeA,FileInfo,Param.Civ2.ImageA]=get_file_type(filecell.ima1.civ2{1});
    1207         [Param.Civ2.FileTypeB,FileInfo,Param.Civ2.ImageB]=get_file_type(filecell.ima2.civ2{1});
    1208     end
    1209 end
     1185        [Param.Civ2.FileTypeA,FileInfoA_civ2,Param.Civ2.ImageA]=get_file_type(filecell.ima1.civ2{1});
     1186        [Param.Civ2.FileTypeB,FileInfoB_civ2,Param.Civ2.ImageB]=get_file_type(filecell.ima2.civ2{1});
     1187    end
     1188% end
    12101189
    12111190%% MAIN LOOP
     
    12171196for ifile=1:nbfield
    12181197    for j=1:nbslice
    1219 
    12201198           
    12211199        % define output file name
     
    12361214            end
    12371215            Param.Civ1.Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2);
    1238             if strcmp(Param.CivMode,'CivX')
     1216            if strcmp(Param.Program,'CivX')
    12391217                Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE?
    12401218                Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);%
    12411219            end
    1242             if isfield(Param.Civ1,'FileTypeA')&&(strcmp(Param.Civ1.FileTypeA,'video')|| strcmp(Param.Civ1.FileTypeA,'mmreader'))
    1243                 %   ImageInfo=get(VideoReader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
    1244                 ImageInfo=get(Param.Civ1.ImageA);
    1245                 %                 elseif strcmp(Param.Civ1.FileTypeA,'mmreader')
    1246                 %                     ImageInfo=get(mmreader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
    1247                 Param.Civ1.ImageBitDepth=ImageInfo.BitsPerPixel/3;
    1248                 if batch
    1249                     Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};%file name must be used for batch instead of video object
    1250                     Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j};
    1251                 end
    1252             else
    1253                 Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};
    1254                 Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j};
    1255                % form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
    1256                 ImageInfo=imfinfo(filecell.ima1.civ1{1,1});%read the first image to get the size
    1257                 Param.Civ1.ImageBitDepth=ImageInfo.BitDepth;
    1258             end
    1259             Param.Civ1.ImageWidth=ImageInfo.Width;
    1260             Param.Civ1.ImageHeight=ImageInfo.Height;
     1220            Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};
     1221            Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j};
     1222            Param.Civ1.ImageBitDepth=FileInfoA_civ1.BitDepth;
     1223            Param.Civ1.ImageWidth=FileInfoA_civ1.Width;
     1224            Param.Civ1.ImageHeight=FileInfoA_civ1.Height;
    12611225            Param.Civ1.FrameIndexA=i1_civ1(ifile);
    12621226            Param.Civ1.FrameIndexB=i2_civ1(ifile);
     
    12781242                        i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1;
    12791243                        Param.Civ1.Grid=[filecell.filebase '_' fullfile_uvmat('','',Param.Civ1.Grid,'.grid','_1',i1_grid)];
    1280                         %                         Param.Civ1.Grid=[filecell.filebase '_' name_generator(Param.Civ1.Grid,i1_grid,1,'.grid','_i')];
    12811244                        if ~exist(Param.Civ1.GridName,'file')
    12821245                            errormsg='grid file absent for civ1';
     
    12931256       
    12941257        if Param.CheckCiv2==1
    1295             if isfield(Param.Civ2,'FileTypeA') &&(strcmp(Param.Civ2.FileTypeA,'video')|| strcmp(Param.Civ2.FileTypeA,'mmreader'))
    1296                 %   ImageInfo=get(VideoReader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
    1297                 ImageInfo=get(Param.Civ2.ImageA);
    1298                 %                 elseif strcmp(Param.Civ1.FileTypeA,'mmreader')
    1299                 %                     ImageInfo=get(mmreader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
    1300                 Param.Civ2.ImageBitDepth=ImageInfo.BitsPerPixel/3;
    1301                 if batch
    1302                     Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};%file name must be used for batch instead of video object
    1303                     Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j};
    1304                 end
    1305             else
    1306                 Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};
    1307                 Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j};
    1308                 form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
    1309                 ImageInfo=imfinfo(filecell.ima1.civ2{1,1});%read the first image to get the size
    1310                 Param.Civ2.ImageBitDepth=ImageInfo.BitDepth;
    1311             end
    1312            
     1258            Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};
     1259            Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j};         
    13131260            if ~checkframe %&& size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j)
    13141261                Param.Civ2.Dt=time(i2_civ2(ifile)+1,j2_civ2(j)+1)-time(i1_civ2(ifile)+1,j1_civ2(j)+1);
     
    13171264            end
    13181265            Param.Civ2.Time=(time(i2_civ2(ifile)+1,j2_civ2(j)+1)+time(i1_civ2(ifile)+1,j1_civ2(j)+1))/2;
    1319             if strcmp(Param.CivMode,'CivX')
     1266            if strcmp(Param.Program,'CivX')
    13201267                Param.Civ2.term_a=num2stra(j1_civ2(j),nom_type_nc);
    13211268                Param.Civ2.term_b=num2stra(j2_civ2(j),nom_type_nc);
     
    13461293                end
    13471294            end
    1348             form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
    1349             if isempty(form)
    1350                 % ImageInfo=get(VideoReader(fullfile());
    1351                 Param.Civ2.ImageBitDepth=ImageInfo.BitsPerPixel/3;
    1352             else
    1353                 ImageInfo=imfinfo(filecell.ima1.civ2{1,1});%read the first image to get the size
    1354                 Param.Civ2.ImageBitDepth=ImageInfo.BitDepth;
    1355             end
    1356             Param.Civ2.ImageWidth=ImageInfo.Width;
    1357             Param.Civ2.ImageHeight=ImageInfo.Height;
     1295
     1296            Param.Civ2.ImageBitDepth=FileInfoA_civ2.BitDepth;
     1297            Param.Civ2.ImageWidth=FileInfoA_civ2.Width;
     1298            Param.Civ2.ImageHeight=FileInfoA_civ2.Height;
    13581299            Param.Civ2.FrameIndexA=i1_civ2(ifile);
    1359             Param.Civ2.FrameIndexB=i2_civ2(ifile);
    1360            
    1361         end
    1362        
    1363        
     1300            Param.Civ2.FrameIndexB=i2_civ2(ifile);           
     1301        end
     1302       
    13641303        % write the command and eventually the cmx, xml or nml files
    1365         cmd=write_cmd(Param,batch);
     1304        cmd=write_cmd(Param);
    13661305        write_param(Param);
    1367        
    1368 
    1369        
     1306             
    13701307        % create the file used in run or batch
    1371         switch Param.CivMode
    1372             case 'Matlab'
     1308        switch Param.Program
     1309            case {'civ_matlab','civ_matlab.sh'}
    13731310                filename_bat=regexprep(Param.OutputFile,'(\w+)([/\\])(\w+$)','$1$20_BAT$2$3.m');
    13741311            case {'CivX','CivAll'}
     
    13931330
    13941331%% start calculation
    1395 
    1396 if batch ==3
     1332%computation on cluster
     1333%if batch ==3
     1334 if  strcmp(Param.RunMode,'cluster')
    13971335    switch batch_mode   
    13981336        case 'sge' %at the moment only psmn ENS Lyon uses it
     
    15261464            end
    15271465    end
    1528 else
    1529     switch Param.CivMode
    1530         case 'Matlab'
    1531            
    1532             background=1;
    1533             if background
     1466 else %computation on local computer
     1467    switch Param.Program
     1468        case {'civ_matlab','civ_matlab.sh'}
     1469%            
     1470%             background=1;
     1471            if strcmp(Param.RunMode,'background')
    15341472                filename_superbat=fullfile(RootBat,'job_list.m');
    15351473                fid=fopen(filename_superbat,'w');
     
    16891627filecell=[];%default
    16901628errormsg='';
    1691 ListProgram=get(handles.ListProgram,'String');
    1692 CivMode=ListProgram{get(handles.ListProgram,'Value')};%Program to use , CivX or Matlab
     1629ListProgram=get(handles.Program,'String');
     1630CivMode=ListProgram{get(handles.Program,'Value')};%Program to use , CivX or Matlab
    16931631
    16941632%% get the root name and check dir
     
    38913829set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
    38923830
    3893 % --- Executes on selection change in ListProgram.
    3894 function ListProgram_Callback(hObject, eventdata, handles)
    3895 ListProgram=get(handles.ListProgram,'String');
    3896 Program=ListProgram{get(handles.ListProgram,'value')};
     3831% --- Executes on selection change in Program.
     3832function Program_Callback(hObject, eventdata, handles)
     3833ListProgram=get(handles.Program,'String');
     3834Program=ListProgram{get(handles.Program,'value')};
    38973835switch Program
    38983836    case 'CivX'
     
    39113849        set(handles.CheckDeformation,'Value',1)
    39123850        set(handles.CheckDecimal,'Value',1)
    3913     case 'Matlab'
     3851    case {'civ_matlab','civ_matlab.sh'}
    39143852        set(handles.num_MaxDiff,'Visible','on')
    39153853        set(handles.num_MaxVel,'Visible','on')
     
    39873925%changes : filename_cmx -> filename ( no extension )
    39883926errormsg='';
    3989 switch Param.CivMode
     3927switch Param.Program
    39903928    case 'CivX'
    39913929        if Param.CheckCiv1
     
    41294067            fclose(fid);
    41304068        end
    4131     case 'Matlab'
     4069    case {'civ_matlab','civ_matlab.sh'}
    41324070        filename=regexprep(Param.OutputFile,'(\w+)([/\\])(\w+$)','$1$20_XML$2$3.xml');
    41334071        save(struct2xml(Param),filename);
     
    41354073
    41364074
    4137 function cmd=write_cmd(Param,batch)
     4075function cmd=write_cmd(Param)
    41384076
    41394077% initiate system command
    41404078cmd=[];
    41414079
    4142 switch Param.CivMode
     4080switch Param.Program
    41434081    case 'CivX'
    41444082        if isunix % check: necessaire aussi en RUN?
     
    41604098
    41614099if Param.CheckCiv1
    4162     switch Param.CivMode
     4100    switch Param.Program
    41634101        case 'CivX'
    41644102            if(isunix) %unix (or Mac) system
     
    41894127
    41904128if Param.CheckFix1
    4191     switch Param.CivMode
     4129    switch Param.Program
    41924130        case 'CivX'
    41934131            cmd=[cmd...
     
    42164154%CheckPatch1
    42174155if Param.CheckPatch1
    4218     switch Param.CivMode
     4156    switch Param.Program
    42194157        case 'CivX'
    42204158            cmd=[cmd...
     
    42674205
    42684206if Param.CheckCiv2
    4269     switch Param.CivMode
     4207    switch Param.Program
    42704208        case 'CivX'
    42714209            if(isunix)
     
    42974235% CheckFix2
    42984236if Param.CheckFix2==1
    4299     switch Param.CivMode
     4237    switch Param.Program
    43004238        case 'CivX'
    43014239            cmd=[cmd...
     
    43244262if Param.CheckPatch2==1
    43254263   
    4326     switch Param.CivMode
     4264    switch Param.Program
    43274265       
    43284266        case 'CivX'
     
    43754313end
    43764314
    4377 if isequal(Param.CivMode,'CivAll')
     4315if isequal(Param.Program,'CivAll')
    43784316    save(CivAllxml,[Param.OutputFile '.xml']);
    43794317    cmd=[cmd sparam.CivBin ' -f ' Param.OutputFile '.xml '  CivAllCmd ' >' Param.OutputFile '.log' '\n'];
    43804318end
    43814319
    4382 if isequal(Param.CivMode,'Matlab')
    4383     if batch>1
     4320if isequal(Param.Program,'civ_matlab')
     4321    if strcmp(Param.RunMode,'cluster')||strcmp(Param.RunMode,'background')
    43844322        cmd=['#!/bin/bash \n '...
    43854323            '#$ -cwd \n '...
     
    44024340   
    44034341
    4404 if isequal(Param.CivMode,'MatlabCompile')
     4342if isequal(Param.Program,'civ_matlab.sh')
    44054343        cmd=['#!/bin/bash \n '...
    44064344            '#$ -cwd \n '...
     
    44114349
    44124350
    4413 if isequal(Param.CivMode,'MatlabNonCompile')
     4351if isequal(Param.Program,'MatlabNonCompile')
    44144352%         cmd=[regexprep(which(civ_matlab),'.m$','')...
    44154353%             '(' regexprep(filename,'(\w+)/(\w+$)','$1/0_XML$2.xml,')...
  • trunk/src/find_file_series.m

    r468 r469  
    5656switch FileType
    5757    case 'multimage'
    58 %    NomType='*';
    59 %    i1_series=(1:FileInfo.NbFrame)';
    60     NbFrame=FileInfo.NbFrame;
     58    NbFrame=FileInfo.NumberOfFrames;
    6159    case {'video','mmreader'}
    6260    NomType='*';
    6361    NbFrame=FileInfo.NumberOfFrames;
    64 %     i1_series=(1:FileInfo.NumberOfFrames)';
    6562end
    66 % if strcmp( FileType,'multimage')||strcmp( FileType,'video')||strcmp( FileType,'mmreader')
    67 %     NomType='*';
    68 %     i1_series=(1:FileInfo.NumberOfFrames)';
    69 % end
     63
    7064RootFile_i='';
    7165NomTypePref='';
     
    9185        end
    9286        if ~isempty(rr)
    93             RootFile_i=[RootFile rr.i1];
    94            % checkpair=~isempty(regexp(NomType,'-','once'))||~isempty(regexp(NomType,'ab$','once'))||~isempty(regexp(NomType,'AB$','once'));%case of PIV results
    95             if exist(fullfile(RootPath,SubDir,[RootFile_i '.xml']),'file') || exist(fullfile(RootPath,[RootFile_i '.xml']),'file')
     87            RootFile_i=[RootFile rr.i1];% new root file
     88            if exist(fullfile(RootPath,SubDir,[RootFile_i '.xml']),'file') || (strcmp(FileExt,'.nc') && exist(fullfile(RootPath,[RootFile_i '.xml']),'file'))
    9689                RootFile=RootFile_i;
    9790                NomTypePref=r.tiretnum;
  • trunk/src/get_file_type.m

    r446 r469  
    55% OUTPUT:
    66% FileType: type of file
    7 % FileInfo: structure containing info on the file (case of images)
     7% FileInfo: structure containing info on the file (case of images or video), in particular
     8%      .Height: image height in pixels
     9%      .Width:  image width in pixels
     10%      .BitDepth: nbre of bits per pixel  (8 of 16)
     11%      .ColorType: 'greyscale' or 'color'
     12%      .NumberOfFrames
     13%      .FrameRate: nbre of frames per second, =[] for images
    814% Object: in case of video
    915%
     
    2632        FileType='xls';
    2733    otherwise
    28         if ~isempty(FileExt)&& ~isempty(imformats(FileExt(2:end)))
     34        if ~isempty(imformats(regexprep(FileExt,'^.','')))
    2935            try
    30                 FileType='image';
    3136                imainfo=imfinfo(fileinput);
    3237                if length(imainfo) >1 %case of image with multiple frames
    3338                    FileType='multimage';
    34                     FileInfo=imainfo{1};%take info from the first frame
    35                     FileInfo.NbFrame=length(imainfo);
     39                    FileInfo=imainfo(1);%take info from the first frame
     40                    FileInfo.NumberOfFrames=length(imainfo);
    3641                else
     42                    FileType='image';
    3743                    FileInfo=imainfo;
     44                    FileInfo.NumberOfFrames=1;
    3845                end
    3946            end
     
    7582                    if exist('VideoReader.m','file')%recent version of Matlab
    7683                        VideoObject=VideoReader(fileinput);
    77                         FileInfo.NumberOfFrames=get(VideoObject,'NumberOfFrames');
     84                        FileInfo=get(VideoObject);
    7885                        FileType='video';
    7986                    elseif exist('mmreader.m','file')% Matlab 2009a
    8087                        VideoObject=mmreader(fileinput);
    81                         FileInfo.NumberOfFrames=get(VideoObject,'NumberOfFrames');
     88                        FileInfo=get(VideoObject);
    8289                        FileType='mmreader';
    83                     end             
     90                    end 
     91                    FileInfo.BitDepth=FileInfo.BitsPerPixel/3;
    8492                end
    8593            end
  • trunk/src/uvmat.m

    r460 r469  
    906906
    907907%% read parameters (time, geometric calibration..) from a documentation file (.xml advised)
    908 SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
    909 filexml=fullfile(RootPath,[SubDirBase '.xml']);% new convention: xml above the image dir
    910 DocExt='.xml';
    911 if ~exist(filexml,'file')
    912     filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy
    913     if ~exist(filexml,'file')
    914         filexml=fullfile(RootPath,SubDir,[RootFile '.civ']); % very old convention: .civ file
    915         if exist(filexml,'file')
    916             DocExt='.civ';
    917         else
    918             filexml='';
    919         end
    920     end
    921 end
     908XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt);
     909[tild,tild,DocExt]=fileparts(XmlFileName);
    922910warntext='';%default warning message
    923911NbSlice=1;%default
    924912set(handles.RootPath,'BackgroundColor',[1 1 1])
    925 if ~isempty(filexml)
     913if ~isempty(XmlFileName)
    926914    set(handles.view_xml,'Visible','on')
    927915    set(handles.view_xml,'BackgroundColor',[1 1 0])
    928916    set(handles.view_xml,'String','view .xml')
    929917    drawnow
    930     [XmlDataRead,warntext]=imadoc2struct(filexml);
     918    [XmlDataRead,warntext]=imadoc2struct(XmlFileName);
    931919    if ~isempty(warntext)
    932920        msgbox_uvmat('WARNING',warntext)
     
    951939            if ~isempty(hgeometry_calib)
    952940                GUserData=get(hgeometry_calib,'UserData');
    953                 if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml))
     941                if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,XmlFileName))
    954942                    answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?');
    955943                    if strcmp(answer,'Yes')
    956                         geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib
     944                        geometry_calib(XmlFileName);%diplay the new calibration points and parameters in geometry_calib
    957945                    end
    958946                end
Note: See TracChangeset for help on using the changeset viewer.