Changeset 450 for trunk


Ignore:
Timestamp:
Jun 12, 2012, 12:27:42 AM (12 years ago)
Author:
sommeria
Message:

various bugs repaired

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_file_series.m

    r446 r450  
    3535    r.mode='';
    3636    if isfield (Param.IndexRange,'PairString')
     37        if ischar(Param.IndexRange.PairString)
     38            Param.IndexRange.PairString={Param.IndexRange.PairString};
     39        end
    3740        r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');
    3841        if isempty(r)
  • trunk/src/read_field.m

    r445 r450  
    22%'read_field': read input fields in different formats
    33%--------------------------------------------------------------------------
    4 %  function [Field,ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn)
     4%  function [Field,ParamOut,errormsg] = read_field(FileName,FileType,ParamIn,num)
    55%
    66% OUTPUT:
     
    2323%     = video: movie read with VideoReader (recent versions of Matlab)
    2424%     = vol: images representing scanned volume (images concatened in the y direction)
    25 % ParamIn: Matlab structure of input parameters
     25% ParamIn: movie object or Matlab structure of input parameters
    2626%     .FieldName: name (char string) of the input field (for Civx data)
    2727%     .VelType: char string giving the type of velocity data ('civ1', 'filter1', 'civ2'...)
    2828%     .ColorVar: variable used for vector color
    2929%     .Npx, .Npy: nbre of pixels along x and y (used for .vol input files)
    30 function [Field,ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num)
     30function [Field,ParamOut,errormsg] = read_field(FileName,FileType,ParamIn,num)
    3131Field=[];
    3232if ~exist('num','var')
     
    5757                field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data
    5858                if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist
    59                     Data=nc2struct(ObjectName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ','CivStage');
     59                    Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ','CivStage');
    6060                    % case of new civdata conventions
    6161                    if isequal(Data.Conventions,'uvmat/civdata')
     
    6363                        ParamOut.ColorVar='ima_cor';
    6464                        InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    65                         [Field,ParamOut.VelType,errormsg]=read_civdata(ObjectName,InputField,ParamIn.VelType,Data.CivStage);
     65                        [Field,ParamOut.VelType,errormsg]=read_civdata(FileName,InputField,ParamIn.VelType,Data.CivStage);
    6666                        CivStage=Field.CivStage;
    6767                        ParamOut.CivStage=Field.CivStage;
     
    7171                        ParamOut.ColorVar='ima_cor';
    7272                        InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    73                         [Field,ParamOut.VelType]=read_civxdata(ObjectName,InputField,ParamIn.VelType);
     73                        [Field,ParamOut.VelType]=read_civxdata(FileName,InputField,ParamIn.VelType);
    7474                        CivStage=Field.CivStage;
    7575                        ParamOut.CivStage=Field.CivStage;
     
    8888                        InputField=[InputField {ParamOut.ColorVar}];
    8989                    end
    90                     [Field,ParamOut.VelType,errormsg]=read_civxdata(ObjectName,InputField,ParamIn.VelType);
     90                    [Field,ParamOut.VelType,errormsg]=read_civxdata(FileName,InputField,ParamIn.VelType);
    9191                    if ~isempty(errormsg)
    9292                        return
     
    100100                hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI
    101101                if isempty(hget_field)% open the GUI get_field if it is not found
    102                     hget_field= get_field(ObjectName);%open the get_field GUI
     102                    hget_field= get_field(FileName);%open the get_field GUI
    103103                    set(hget_field,'Name',GUIName)%update the name of get_field (e.g. get_field_1)
    104104                end
    105105                hhget_field=guidata(hget_field);
    106106                %% update  the get_field GUI
    107                 set(hhget_field.inputfile,'String',ObjectName)
     107                set(hhget_field.inputfile,'String',FileName)
    108108                set(hhget_field.list_fig,'Value',1)
    109109                if exist('num','var')&&~isnan(num)
     
    116116                Tabchar={''};%default
    117117                Tabcell=[];
    118                 set(hhget_field.inputfile,'String',ObjectName)
     118                set(hhget_field.inputfile,'String',FileName)
    119119                if isfield(Field,'ListGlobalAttribute')&& ~isempty(Field.ListGlobalAttribute)
    120120                    for iline=1:length(Field.ListGlobalAttribute)
     
    145145            end
    146146        case {'video','mmreader'}
    147             A=read(ObjectName,num);
     147            A=read(ParamIn,num);
    148148        case 'vol'
    149             A=imread(ObjectName);
     149            A=imread(FileName);
    150150            Npz=size(A,1)/ParamIn.Npy;
    151151            A=reshape(A',ParamIn.Npx,ParamIn.Npy,Npz);
     
    153153        case 'multimage'
    154154            warning 'off'
    155             A=imread(ObjectName,num);
     155            A=imread(FileName,num);
    156156        case 'image'
    157             A=imread(ObjectName);
     157            A=imread(FileName);
    158158    end
    159159catch ME
  • trunk/src/series.m

    r448 r450  
    665665
    666666%% number of slices
     667NbSlice=MaxIndex_j-MinIndex_j+1;%default
    667668if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord')
    668669    siz=size(XmlData.GeometryCalib.SliceCoord);
    669670    if siz(1)>1
    670671        NbSlice=siz(1);
    671     else
    672         NbSlice=1;
    673     end
    674     set(handles.num_NbSlice,'String',num2str(NbSlice))
    675 end
    676 
     672    end
     673end
     674set(handles.num_NbSlice,'String',num2str(NbSlice))
     675   
    677676%% update pair menus
    678677set(handles.Pairs,'Visible','on')
     
    14171416    end
    14181417    detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if  the dir  already exist
     1418    check_create=1; %need to create the result directory by default
    14191419    while detect
    14201420        answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Series.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']);
     
    14381438    Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output
    14391439    set(handles.OutputDirExt,'String',Series.OutputDirExt)
    1440     Series=rmfield(Series,'OutputDirExt');%removes redondant information
     1440    %removes redondant information
     1441    Series=rmfield(Series,'OutputDirExt');
     1442    Series.IndexRange=rmfield(Series.IndexRange,'TimeTable');
     1443    Series.IndexRange=rmfield(Series.IndexRange,'MinIndex');
     1444    Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex');
    14411445    % create output directory
    14421446    if check_create
     
    14491453    filexml=fullfile(Series.OutputDir,[Series.InputTable{1,3} '.xml']);% name of the parameter xml file set in this directory
    14501454    t=struct2xml(Series);
     1455    t=set(t,1,'name','Series');
    14511456    save(t,filexml);
    14521457end
  • trunk/src/struct2xml.m

    r42 r450  
    2424fieldnames=fields(Object);
    2525for ilist=1:length(fieldnames)
    26    eval(['val=Object.' fieldnames{ilist} ';'])
     26   val=Object.(fieldnames{ilist});
    2727   if isstruct(val)
    2828      [t,uid]=add(t,root_uid,'element',fieldnames{ilist});
     
    6060           end
    6161       end
     62 elseif iscell(val)
     63      siz=size(val);
     64      if length(siz)<=2 %do not translate cell matrices with more than 2 indices
     65          separator='   '; %mark the separation of columns
     66          for iline=1:siz(1)
     67                val_str=cell2mat(cell2tab(val(iline,:),' & ')); % produce a line string with column separator ' & '
     68                [t,new_uid]=add(t,uid,'element',key);
     69                if siz(1)>1
     70                    t = attributes(t,'add',new_uid,'i',num2str(iline));
     71                end
     72                [t]=add(t,new_uid,'chardata',val_str);
     73          end
     74      end
    6275 end   
  • trunk/src/uvmat.m

    r446 r450  
    4141%     - Information defined from the interface:
    4242%           .NewSeries: =1 when the first view of a new field series is displayed, else 0
    43 %           .filename:(char string)
     43%           .FileName:(char string)
    4444%           .FieldName: (char string) main field selected('image', 'velocity'...)
    4545%           .CName: (char string)name of the scalar used for vector colors
    4646%          .MovieObject{1}: movie object representing an input movie
    4747%          .MovieObject{2}: idem for a second input series (_1)
    48 %          .filename_1 : last second input file name (to deal with a constant second input without reading again the file)
     48%          .FileName_1 : last second input file name (to deal with a constant second input without reading again the file)
    4949%          .ZMin, .ZMax: range of the z coordinate
    5050%..... to complement
     
    787787            else
    788788                msgbox_uvmat('WARNING','unable to synchronise the indices of the two series')
    789 %                 set(handles.SubField,'Value',0)
    790 %                 SubField_Callback([], [], handles)
    791789            end
    792790        end
     
    846844UvData.j1_series{index}=j1_series;
    847845UvData.j2_series{index}=j2_series;
    848 % set(handles.CheckFixPair,'Value',1) % activate by default the comp_input '-'input window
    849846set(handles.FixVelType,'Value',0); %desactivate fixed veltype
    850847if index==1
     
    924921    [XmlData,warntext]=imadoc2struct(filexml);
    925922    if ~isempty(warntext)
    926         msgbox_uvmat('WARNING',warntext)
     923        display(warntext)
     924%         msgbox_uvmat('WARNING',warntext)
    927925    end
    928926    if isfield(XmlData,'TimeUnit')
     
    19681966% Field: structure describing an optional input field (then replace the input file)
    19691967
    1970 function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
     1968function errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,Field)
    19711969%------------------------------------------------------------------------
    19721970
     
    19851983%% determine the main input file information for action
    19861984FileType=[];%default
    1987 if ~exist(filename,'file')
    1988     errormsg=['input file ' filename ' does not exist'];
     1985if ~exist(FileName,'file')
     1986    errormsg=['input file ' FileName ' does not exist'];
    19891987    return
    19901988end
     
    20102008ParamIn.ColorVar='';%default variable name for vector color
    20112009frame_index=1;%default
    2012 if ~isempty(filename)
    2013     ObjectName=filename;
     2010if ~isempty(FileName)
    20142011    FieldName='';%default
    20152012    VelType='';%default
     
    20362033            end
    20372034        case {'video','mmreader'}
    2038             ObjectName=UvData.MovieObject{1};     
     2035            ParamIn=UvData.MovieObject{1};     
    20392036            if ~strcmp(NomType,'*')
    20402037                frame_index=num_j1;%frame index for movies or multimage
     
    20602057    ParamIn.VelType=VelType;
    20612058    ParamIn.GUIName='get_field';
    2062     [Field{1},ParamOut,errormsg] = read_field(ObjectName,UvData.FileType{1},ParamIn,frame_index);
     2059    [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index);
    20632060    if ~isempty(errormsg)
    2064         errormsg=['error in reading ' filename ': ' errormsg];
     2061        errormsg=['error in reading ' FileName ': ' errormsg];
    20652062        return
    20662063    end 
     
    20772074end
    20782075
    2079 %% choose and read a second field filename_1 if defined
     2076%% choose and read a second field FileName_1 if defined
    20802077VelType_1=[];%default
    20812078FieldName_1=[];
    20822079ParamOut_1=[];
    20832080frame_index_1=1;
    2084 if ~isempty(filename_1)
    2085     if ~exist(filename_1,'file')
    2086         errormsg=['second file ' filename_1 ' does not exist'];
     2081if ~isempty(FileName_1)
     2082    if ~exist(FileName_1,'file')
     2083        errormsg=['second file ' FileName_1 ' does not exist'];
    20872084        return
    20882085    end
    2089     Name=filename_1;
     2086    Name=FileName_1;
    20902087    switch UvData.FileType{2}
    20912088        case {'civx','civdata','netcdf'};
     
    21082105            end
    21092106        case {'video','mmreader'}
    2110             Name=UvData.MovieObject{2};
     2107            ParamIn_1=UvData.MovieObject{2};
    21112108                        if ~strcmp(NomType_1,'*')
    21122109                frame_index_1=num_j1;%frame index for movies or multimage
     
    21362133    test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
    21372134    if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
    2138         if isfield(UvData,'filename_1')%&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
    2139             test_keepdata_1= strcmp(filename_1,UvData.filename_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1);
     2135        if isfield(UvData,'FileName_1')%&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
     2136            test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1);
    21402137        end
    21412138    end
     
    21492146        [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1);
    21502147        if ~isempty(errormsg)
    2151             errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg];
     2148            errormsg=['error in reading ' FieldName_1 ' in ' FileName_1 ': ' errormsg];
    21522149            return
    21532150        end
     
    21952192%% update the display menu for the second velocity type (second menuline)
    21962193test_veltype_1=0;
    2197 if isempty(filename_1)
     2194if isempty(FileName_1)
    21982195    set(handles.Fields_1,'Value',1); %update the field menu
    21992196    set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu
     
    23392336
    23402337%% store the current open names, fields and vel types in uvmat interface
    2341 UvData.filename_1=filename_1;
     2338UvData.FileName_1=FileName_1;
    23422339
    23432340%% apply coordinate transform or other user fct
     
    23542351transform=transform_list{choice_value};%selected function handles
    23552352% z index
    2356 if ~isempty(filename)
     2353if ~isempty(FileName)
    23572354    Field{1}.ZIndex=z_index;
    23582355end
     
    27222719                hget_field=findobj(allchild(0),'name','get_field');
    27232720                if isempty(hget_field)
    2724                     get_field(filename)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
     2721                    get_field(FileName)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
    27252722                end
    27262723                errormsg='The field defined by get_field cannot be plotted';
     
    29472944% [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
    29482945[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    2949 filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    2950 %filename=read_file_boxes(handles);
    2951 [erread,message]=fileattrib(filename);
     2946FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     2947%FileName=read_file_boxes(handles);
     2948[erread,message]=fileattrib(FileName);
    29522949if ~isempty(message) && ~isequal(message.UserWrite,1)
    2953      msgbox_uvmat('ERROR',['no writting access to ' filename])
     2950     msgbox_uvmat('ERROR',['no writting access to ' FileName])
    29542951     return
    29552952end
     
    29732970hhh=which('netcdf.open');% look for built-in matlab netcdf library
    29742971if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
    2975     nc=netcdf.open(filename,'NC_WRITE');
     2972    nc=netcdf.open(FileName,'NC_WRITE');
    29762973    netcdf.reDef(nc);
    29772974    netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1);
     
    29862983    netcdf.close(nc); 
    29872984else %old netcdf library
    2988     netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
     2985    netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname)
    29892986end
    29902987
     
    29922989%----Correct the netcdf file, using toolbox (old versions of Matlab).
    29932990%-------------------------------------------------------------------
    2994 function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
    2995 nc=netcdf(filename,'write'); %open netcdf file
     2991function netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname)
     2992nc=netcdf(FileName,'write'); %open netcdf file
    29962993result=redef(nc);
    29972994eval(['nc.' attrname '=1;']);
     
    30903087    set(handles.VelType_1,'visible','off')
    30913088    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    3092     filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    3093     %filename=read_file_boxes(handles);
     3089    FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     3090    %FileName=read_file_boxes(handles);
    30943091    hget_field=findobj(allchild(0),'name','get_field');
    30953092    if ~isempty(hget_field)
    30963093        delete(hget_field)
    30973094    end
    3098     hget_field=get_field(filename);
     3095    hget_field=get_field(FileName);
    30993096    set(hget_field,'Name','get_field')
    31003097    hhget_field=guidata(hget_field);
     
    31473144            '*.*',  'All Files (*.*)'}, ...
    31483145            'Pick a netcdf file',FileBase);
    3149         filename=[PathName FileName];
     3146        FullFileName=[PathName FileName];
    31503147        % display the selected field and related information
    3151         display_file_name( handles,filename)
     3148        display_file_name( handles,FullFileName)
    31523149        return
    31533150    end
     
    31863183    UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read)
    31873184end
    3188 UvData.filename_1='';% desactivate the use of a constant second file
     3185UvData.FileName_1='';% desactivate the use of a constant second file
    31893186list_fields=get(handles.Fields,'String');% list menu fields
    31903187field= list_fields{get(handles.Fields,'Value')}; % selected string
     
    32013198%% read the rootfile input display
    32023199[RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
    3203 filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
     3200FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
    32043201[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
    32053202% set(handles.FileIndex_1,'Visible','on')
     
    32123209            delete(hget_field)
    32133210        end
    3214         hget_field=get_field(filename_1);
     3211        hget_field=get_field(FileName_1);
    32153212        set(hget_field,'name','get_field_1')
    32163213        hhget_field=guidata(hget_field);
     
    33263323set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic)
    33273324UvData=get(handles.uvmat,'UserData');
    3328 %refresh field with a second filename=first file name
     3325%refresh field with a second FileName=first file name
    33293326set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
    33303327drawnow   
    33313328InputFile=read_GUI(handles.InputFile);
    33323329[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    3333 filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     3330FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    33343331
    33353332if isempty(InputFile.VelType_1)
    3336         filename_1='';% we plot the current field without the second field
     3333        FileName_1='';% we plot the current field without the second field
    33373334        set(handles.SubField,'Value',0)
    33383335        SubField_Callback(hObject, eventdata, handles)
    33393336elseif get(handles.SubField,'Value')% if subfield is already 'on'
    33403337      [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
    3341      filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
     3338     FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
    33423339else
    3343      filename_1=filename;% we compare two fields in the same file by default
     3340     FileName_1=FileName;% we compare two fields in the same file by default
    33443341     UvData.FileType{2}=UvData.FileType{1};
    33453342     set(handles.SubField,'Value',1)
     
    33483345    UvData=rmfield(UvData,'Field_1');% removes the stored second field if it exists
    33493346end
    3350 UvData.filename_1='';% desactivate the use of a constant second file
     3347UvData.FileName_1='';% desactivate the use of a constant second file
    33513348set(handles.uvmat,'UserData',UvData)
    33523349num_i1=stra2num(get(handles.i1,'String'));
     
    33553352num_j2=stra2num(get(handles.j2,'String'));
    33563353
    3357 errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
     3354errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2);
    33583355
    33593356if ~isempty(errormsg)
  • trunk/src/xml2struct.m

    r379 r450  
    1515
    1616
    17 function out=convert_string(s)
    18 info=whos('s');
     17function out=convert_string(ss)
     18info=whos('ss');
    1919switch info.class
    2020    case 'struct'
    21         names = fieldnames(s);
     21        names = fieldnames(ss);
    2222        for k=1:length(names)
    23             out.(names{k})=convert_string(s.(names{k}));
     23            out.(names{k})=convert_string(ss.(names{k}));
    2424        end
    2525    case 'char'   
    26         if isempty(regexp(s,'^(-*\d+\.*\d*\ *)+$'))% if the string contains a set of numbers (with possible sign and decimal) separated by blanks
    27             out=s;
     26        if isempty(regexp(ss,'^(-*\d+\.*\d*\ *)+$'))% if the string does not contains a set of numbers (with possible sign and decimal) separated by blanks
     27            sep_ind=regexp(ss,'\s&\s');% check for separator ' & ' which indicates column separation in tables
     28            if ~isempty(sep_ind)
     29                sep_ind=[-2 sep_ind length(ss)+1];
     30                for icolumn=1:length(sep_ind)-1
     31                    out{1,icolumn}=ss(sep_ind(icolumn)+3:sep_ind(icolumn+1)-1);
     32                end
     33            else
     34                out=ss; %reproduce the input string
     35            end
    2836        else
    29             out=str2num(s);
     37            out=str2num(ss);
    3038        end
    3139    case 'cell'
    32         for ilist=1:numel(s)
    33             out(ilist,:)=str2num(s{ilist});
     40        for ilist=1:numel(ss)
     41            out(ilist,:)=str2num(ss{ilist});
    3442        end
    3543    otherwise
    36         out=s;
     44        out=ss;
    3745end
    3846
Note: See TracChangeset for help on using the changeset viewer.