Changeset 493 for trunk/src/civ.m


Ignore:
Timestamp:
Jul 16, 2012, 10:44:12 AM (12 years ago)
Author:
sommeria
Message:

various bugs repaired, tests in Windows OS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r492 r493  
    341341
    342342%% case of netcdf file as input, get the civ processing stage and look for a coresponding image
     343imageinput=fileinput;%default
    343344if strcmp(ExtInput,'.nc')
    344345    NomTypeNc=NomTypeInput;
     
    351352        set(handles.RootFile_1,'Visible','Off');
    352353    end
     354    imageinput='';
    353355    Data=nc2struct(fileinput,'ListGlobalAttribute','Conventions','absolut_time_T0','CivStage','Civ2_ImageA','Civ1_ImageA','Civ2_ImageB','Civ1_ImageB','fix','patch','civ2','fix2');
    354356    if isfield(Data,'Txt')
     
    359361    if strcmp(Data.Conventions,'uvmat/civdata')% case of new civ data,
    360362        set(handles.Program,'Value',2) %select civ/Matlab by default
    361         ListProgram_Callback([],[], handles)
     363        Program_Callback([],[], handles)
    362364        if ~isempty(Data.CivStage)%test for civ files
    363365            ind_opening=Data.CivStage;
     
    404406        end
    405407    end
     408    if ~exist(imageinput,'file')
    406409    imageinput=fullfile_uvmat(RootPath,regexprep(SubDir,'.civ(_?)(\d*)$',''),RootFile,'.png',NomTypeIma,i1,[],j1);
     410    end
    407411end
    408412
     
    419423            '*.*',  'All Files (*.*)'};
    420424        [FileName, PathName] = uigetfile( menu, 'Pick an input image file',fileparts(fileparts(fileinput)));
    421         fileinput=[PathName FileName];%complete file name
    422         if ~exist(fileinput,'file')
     425        imageinput=[PathName FileName];%complete file name
     426        if ~exist(imageinput,'file')
    423427            return %abandon of the browser is cancelled
    424428        end
     
    428432
    429433%% scan the image file series
    430 [FilePath,FileName,ImaExt]=fileparts(fileinput);
     434[FilePath,FileName,ImaExt]=fileparts(imageinput);
    431435% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    432436% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    433 [RootPath,SubdirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName ImaExt]);
     437[RootPath,SubdirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]);
    434438switch FileType
    435439    case {'image','multimage','video','mmreader'}
     
    442446set(handles.RootFile,'String',RootFile)
    443447if strcmp(ExtInput,'.nc')
    444     SubDirCiv=regexprep(SubDir,[SubdirImages '^'],'');%suppress the root  SuddirImages;
     448    SubDirCiv=regexprep(SubDir,['^' SubdirImages],'');%suppress the root  SuddirImages;
    445449else
    446450    SubDirCiv= '.civ';
     
    450454browse=get(handles.RootPath,'UserData');
    451455browse.incr_pair=[0 0];%default
    452 
    453 %% fill reference indices from the input file indices
    454 num_ref_i=i1;%efaulmt ref index
    455 if ~isempty(i2)
    456     num_ref_i=floor((num_ref_i+i2)/2);
    457 end
    458 num_ref_j=j1;
    459 if ~isempty(j2)
    460     num_ref_j=floor((num_ref_j+j2)/2);
    461 end
    462456
    463457%% scan the images if a civ file has been opened
     
    467461MaxIndex_j=max(j1_series(j1_series>0));
    468462
     463%% fill reference indices from the input file indices
     464num_ref_i=str2num(get(handles.ref_i,'String'));
     465num_ref_j=str2num(get(handles.ref_j,'String'));
     466% for movies don't modify except if the current ref is outside index bounds
     467if strcmp(ExtInput,'.nc')|| ~(strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader') && num_ref_i<=MaxIndex_i && num_ref_j<=MaxIndex_j)
     468    num_ref_i=i1;%default ref index
     469    if ~isempty(i2)
     470        num_ref_i=floor((num_ref_i+i2)/2);
     471    end
     472    num_ref_j=j1;
     473    if ~isempty(j2)
     474        num_ref_j=floor((num_ref_j+j2)/2);
     475    end
     476end
     477
    469478%% look for an image documentation file
    470479XmlFileName=find_imadoc(RootPath,SubDir,RootFile,ImaExt);
    471 % SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
    472 % filexml=fullfile(RootPath,[SubDirBase '.xml']);% new convention: xml above the image dir
    473 % if ~exist(filexml,'file')
    474 %     filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy
    475 %     if ~exist(filexml,'file')
    476 %         filexml=fullfile(RootPath,SubDir,[RootFile '.civ']);%very old convention: .civ file
    477 %         if ~exist(filexml,'file')
    478 %             filexml='';
    479 %         end
    480 %     end
    481 % end
    482480if isempty(XmlFileName)
    483481    if (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
     
    501499    [XmlData,warntext]=imadoc2struct(XmlFileName);
    502500    nom_type_read=[];
    503 %     if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file
    504 %         [~,tild,tild,tild,tild,tild,tild,tild,nom_type_read]=fileparts_uvmat(XmlData.Heading.ImageName);
    505 %         fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file,
    506 %         if ~exist(fullname,'file')
    507 %             msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist'])
    508 %         end
    509 %     end
    510501    if isfield(XmlData,'Time') && ~isempty(XmlData.Time)
    511502        time=XmlData.Time;
     
    10791070end% default configuration
    10801071if ~isfield(s,'RunParam')
    1081     s.RunParam.Civ1Bin='bin/civ1';
    1082     s.RunParam.Civ2Bin='bin/civ2';
    1083     s.RunParam.FixBin='bin/fix_flag';
    1084     s.RunParam.PatchBin='bin/patch_up';
    1085     s.RunParam.CivmBin='bin/civ_matlab';
     1072    Param.xml.Civ1Bin=fullfile('bin','civ1');
     1073    Param.xml.Civ2Bin=fullfile('bin','civ2');
     1074    Param.xml.FixBin=fullfile('bin','fix_flag');
     1075    Param.xml.PatchBin=fullfile('bin','patch_up');
     1076    Param.xml.CivmBin=fullfile('bin','civ_matlab');
    10861077end
    10871078if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster
     
    10961087        end
    10971088    else
    1098         %standard configuration
    1099         Param.xml.Civ1Bin='bin/civ1';
    1100         Param.xml.Civ2Bin='bin/civ2';
    1101         Param.xml.FixBin='bin/fix_flag';
    1102         Param.xml.PatchBin='bin/patch_up';
    1103         s.RunParam.CivmBin='bin/civ_matlab';
     1089        %default configuration
     1090        Param.xml.Civ1Bin=fullfile('bin','civ1');
     1091        Param.xml.Civ2Bin=fullfile('bin','civ2');
     1092        Param.xml.FixBin=fullfile('bin','fix_flag');
     1093        Param.xml.PatchBin=fullfile('bin','patch_up');
     1094        Param.xml.CivmBin=fullfile('bin','civ_matlab');
    11041095        Param.xml.BatchMode='oar';% TODO : allow choice for sge
    11051096    end
     
    11071098    if isfield(s,'RunParam')
    11081099        Param.xml=s.RunParam;
    1109     else %standard default configuration
    1110         s.RunParam.Civ1Bin='bin/civ1';
    1111         s.RunParam.Civ2Bin='bin/civ2';
    1112         s.RunParam.FixBin='bin/fix_flag';
    1113         s.RunParam.PatchBin='bin/patch_up';
    1114         s.RunParam.CivmBin='bin/civ_matlab';
     1100    else %default configuration
     1101        Param.xml.Civ1Bin=fullfile('bin','civ1');
     1102        Param.xml.Civ2Bin=fullfile('bin','civ2');
     1103        Param.xml.FixBin=fullfile('bin','fix_flag');
     1104        Param.xml.PatchBin=fullfile('bin','patch_up');
     1105        Param.xml.CivmBin=fullfile('bin','civ_matlab');
    11151106    end
    11161107end
    11171108
    11181109%% check if the binaries exist : to move in civ_opening
    1119 % ListProgram=get(handles.Program,'String');
    1120 % Param.CivMode=ListProgram{get(handles.Program,'Value')};
    11211110binary_list={};
    11221111switch Param.Program
     
    19501939                for j=1:nbslice
    19511940                     filename=fullfile_uvmat(RootPath,subdir_civ1_new,RootFile_A,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j));
    1952                    % filename=name_generator(filebase_A,i1_civ1(ifile),j1_civ1(j),'.nc',NomType_nc,1,i2_civ1(ifile),j2_civ1(j),subdir_civ1_new);%
    19531941                    detect=exist(filename,'file')==2;
    19541942                    if detect% if a netcdf file already exists
     
    28282816
    28292817%% reads .nc subdirectoy and image numbers from the interface
    2830 subdir_civ1=get(handles.SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data
    2831 subdir_civ2=get(handles.SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data
     2818SubDirImages=get(handles.SubdirImages,'String');
     2819subdir_civ1=[SubDirImages get(handles.SubdirCiv1,'String')];%subdirectory subdir_civ1 for the netcdf data
     2820subdir_civ2=[SubDirImages get(handles.SubdirCiv2,'String')];%subdirectory subdir_civ2 for the netcdf data
    28322821ref_i=str2double(get(handles.ref_i,'String'));
    28332822if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
Note: See TracChangeset for help on using the changeset viewer.