- Timestamp:
- Jun 12, 2012, 12:27:42 AM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_file_series.m
r446 r450 35 35 r.mode=''; 36 36 if isfield (Param.IndexRange,'PairString') 37 if ischar(Param.IndexRange.PairString) 38 Param.IndexRange.PairString={Param.IndexRange.PairString}; 39 end 37 40 r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); 38 41 if isempty(r) -
trunk/src/read_field.m
r445 r450 2 2 %'read_field': read input fields in different formats 3 3 %-------------------------------------------------------------------------- 4 % function [Field,ParamOut,errormsg] = read_field( ObjectName,FileType,ParamIn)4 % function [Field,ParamOut,errormsg] = read_field(FileName,FileType,ParamIn,num) 5 5 % 6 6 % OUTPUT: … … 23 23 % = video: movie read with VideoReader (recent versions of Matlab) 24 24 % = vol: images representing scanned volume (images concatened in the y direction) 25 % ParamIn: Matlab structure of input parameters25 % ParamIn: movie object or Matlab structure of input parameters 26 26 % .FieldName: name (char string) of the input field (for Civx data) 27 27 % .VelType: char string giving the type of velocity data ('civ1', 'filter1', 'civ2'...) 28 28 % .ColorVar: variable used for vector color 29 29 % .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)30 function [Field,ParamOut,errormsg] = read_field(FileName,FileType,ParamIn,num) 31 31 Field=[]; 32 32 if ~exist('num','var') … … 57 57 field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data 58 58 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'); 60 60 % case of new civdata conventions 61 61 if isequal(Data.Conventions,'uvmat/civdata') … … 63 63 ParamOut.ColorVar='ima_cor'; 64 64 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); 66 66 CivStage=Field.CivStage; 67 67 ParamOut.CivStage=Field.CivStage; … … 71 71 ParamOut.ColorVar='ima_cor'; 72 72 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); 74 74 CivStage=Field.CivStage; 75 75 ParamOut.CivStage=Field.CivStage; … … 88 88 InputField=[InputField {ParamOut.ColorVar}]; 89 89 end 90 [Field,ParamOut.VelType,errormsg]=read_civxdata( ObjectName,InputField,ParamIn.VelType);90 [Field,ParamOut.VelType,errormsg]=read_civxdata(FileName,InputField,ParamIn.VelType); 91 91 if ~isempty(errormsg) 92 92 return … … 100 100 hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI 101 101 if isempty(hget_field)% open the GUI get_field if it is not found 102 hget_field= get_field( ObjectName);%open the get_field GUI102 hget_field= get_field(FileName);%open the get_field GUI 103 103 set(hget_field,'Name',GUIName)%update the name of get_field (e.g. get_field_1) 104 104 end 105 105 hhget_field=guidata(hget_field); 106 106 %% update the get_field GUI 107 set(hhget_field.inputfile,'String', ObjectName)107 set(hhget_field.inputfile,'String',FileName) 108 108 set(hhget_field.list_fig,'Value',1) 109 109 if exist('num','var')&&~isnan(num) … … 116 116 Tabchar={''};%default 117 117 Tabcell=[]; 118 set(hhget_field.inputfile,'String', ObjectName)118 set(hhget_field.inputfile,'String',FileName) 119 119 if isfield(Field,'ListGlobalAttribute')&& ~isempty(Field.ListGlobalAttribute) 120 120 for iline=1:length(Field.ListGlobalAttribute) … … 145 145 end 146 146 case {'video','mmreader'} 147 A=read( ObjectName,num);147 A=read(ParamIn,num); 148 148 case 'vol' 149 A=imread( ObjectName);149 A=imread(FileName); 150 150 Npz=size(A,1)/ParamIn.Npy; 151 151 A=reshape(A',ParamIn.Npx,ParamIn.Npy,Npz); … … 153 153 case 'multimage' 154 154 warning 'off' 155 A=imread( ObjectName,num);155 A=imread(FileName,num); 156 156 case 'image' 157 A=imread( ObjectName);157 A=imread(FileName); 158 158 end 159 159 catch ME -
trunk/src/series.m
r448 r450 665 665 666 666 %% number of slices 667 NbSlice=MaxIndex_j-MinIndex_j+1;%default 667 668 if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') 668 669 siz=size(XmlData.GeometryCalib.SliceCoord); 669 670 if siz(1)>1 670 671 NbSlice=siz(1); 671 else 672 NbSlice=1; 673 end 674 set(handles.num_NbSlice,'String',num2str(NbSlice)) 675 end 676 672 end 673 end 674 set(handles.num_NbSlice,'String',num2str(NbSlice)) 675 677 676 %% update pair menus 678 677 set(handles.Pairs,'Visible','on') … … 1417 1416 end 1418 1417 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 1419 1419 while detect 1420 1420 answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Series.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); … … 1438 1438 Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output 1439 1439 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'); 1441 1445 % create output directory 1442 1446 if check_create … … 1449 1453 filexml=fullfile(Series.OutputDir,[Series.InputTable{1,3} '.xml']);% name of the parameter xml file set in this directory 1450 1454 t=struct2xml(Series); 1455 t=set(t,1,'name','Series'); 1451 1456 save(t,filexml); 1452 1457 end -
trunk/src/struct2xml.m
r42 r450 24 24 fieldnames=fields(Object); 25 25 for ilist=1:length(fieldnames) 26 eval(['val=Object.' fieldnames{ilist} ';'])26 val=Object.(fieldnames{ilist}); 27 27 if isstruct(val) 28 28 [t,uid]=add(t,root_uid,'element',fieldnames{ilist}); … … 60 60 end 61 61 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 62 75 end -
trunk/src/uvmat.m
r446 r450 41 41 % - Information defined from the interface: 42 42 % .NewSeries: =1 when the first view of a new field series is displayed, else 0 43 % . filename:(char string)43 % .FileName:(char string) 44 44 % .FieldName: (char string) main field selected('image', 'velocity'...) 45 45 % .CName: (char string)name of the scalar used for vector colors 46 46 % .MovieObject{1}: movie object representing an input movie 47 47 % .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) 49 49 % .ZMin, .ZMax: range of the z coordinate 50 50 %..... to complement … … 787 787 else 788 788 msgbox_uvmat('WARNING','unable to synchronise the indices of the two series') 789 % set(handles.SubField,'Value',0)790 % SubField_Callback([], [], handles)791 789 end 792 790 end … … 846 844 UvData.j1_series{index}=j1_series; 847 845 UvData.j2_series{index}=j2_series; 848 % set(handles.CheckFixPair,'Value',1) % activate by default the comp_input '-'input window849 846 set(handles.FixVelType,'Value',0); %desactivate fixed veltype 850 847 if index==1 … … 924 921 [XmlData,warntext]=imadoc2struct(filexml); 925 922 if ~isempty(warntext) 926 msgbox_uvmat('WARNING',warntext) 923 display(warntext) 924 % msgbox_uvmat('WARNING',warntext) 927 925 end 928 926 if isfield(XmlData,'TimeUnit') … … 1968 1966 % Field: structure describing an optional input field (then replace the input file) 1969 1967 1970 function errormsg=refresh_field(handles, filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)1968 function errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,Field) 1971 1969 %------------------------------------------------------------------------ 1972 1970 … … 1985 1983 %% determine the main input file information for action 1986 1984 FileType=[];%default 1987 if ~exist( filename,'file')1988 errormsg=['input file ' filename ' does not exist'];1985 if ~exist(FileName,'file') 1986 errormsg=['input file ' FileName ' does not exist']; 1989 1987 return 1990 1988 end … … 2010 2008 ParamIn.ColorVar='';%default variable name for vector color 2011 2009 frame_index=1;%default 2012 if ~isempty(filename) 2013 ObjectName=filename; 2010 if ~isempty(FileName) 2014 2011 FieldName='';%default 2015 2012 VelType='';%default … … 2036 2033 end 2037 2034 case {'video','mmreader'} 2038 ObjectName=UvData.MovieObject{1};2035 ParamIn=UvData.MovieObject{1}; 2039 2036 if ~strcmp(NomType,'*') 2040 2037 frame_index=num_j1;%frame index for movies or multimage … … 2060 2057 ParamIn.VelType=VelType; 2061 2058 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); 2063 2060 if ~isempty(errormsg) 2064 errormsg=['error in reading ' filename ': ' errormsg];2061 errormsg=['error in reading ' FileName ': ' errormsg]; 2065 2062 return 2066 2063 end … … 2077 2074 end 2078 2075 2079 %% choose and read a second field filename_1 if defined2076 %% choose and read a second field FileName_1 if defined 2080 2077 VelType_1=[];%default 2081 2078 FieldName_1=[]; 2082 2079 ParamOut_1=[]; 2083 2080 frame_index_1=1; 2084 if ~isempty( filename_1)2085 if ~exist( filename_1,'file')2086 errormsg=['second file ' filename_1 ' does not exist'];2081 if ~isempty(FileName_1) 2082 if ~exist(FileName_1,'file') 2083 errormsg=['second file ' FileName_1 ' does not exist']; 2087 2084 return 2088 2085 end 2089 Name= filename_1;2086 Name=FileName_1; 2090 2087 switch UvData.FileType{2} 2091 2088 case {'civx','civdata','netcdf'}; … … 2108 2105 end 2109 2106 case {'video','mmreader'} 2110 Name=UvData.MovieObject{2};2107 ParamIn_1=UvData.MovieObject{2}; 2111 2108 if ~strcmp(NomType_1,'*') 2112 2109 frame_index_1=num_j1;%frame index for movies or multimage … … 2136 2133 test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged 2137 2134 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); 2140 2137 end 2141 2138 end … … 2149 2146 [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1); 2150 2147 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]; 2152 2149 return 2153 2150 end … … 2195 2192 %% update the display menu for the second velocity type (second menuline) 2196 2193 test_veltype_1=0; 2197 if isempty( filename_1)2194 if isempty(FileName_1) 2198 2195 set(handles.Fields_1,'Value',1); %update the field menu 2199 2196 set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu … … 2339 2336 2340 2337 %% store the current open names, fields and vel types in uvmat interface 2341 UvData. filename_1=filename_1;2338 UvData.FileName_1=FileName_1; 2342 2339 2343 2340 %% apply coordinate transform or other user fct … … 2354 2351 transform=transform_list{choice_value};%selected function handles 2355 2352 % z index 2356 if ~isempty( filename)2353 if ~isempty(FileName) 2357 2354 Field{1}.ZIndex=z_index; 2358 2355 end … … 2722 2719 hget_field=findobj(allchild(0),'name','get_field'); 2723 2720 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) 2725 2722 end 2726 2723 errormsg='The field defined by get_field cannot be plotted'; … … 2947 2944 % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles); 2948 2945 [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);2946 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 2947 %FileName=read_file_boxes(handles); 2948 [erread,message]=fileattrib(FileName); 2952 2949 if ~isempty(message) && ~isequal(message.UserWrite,1) 2953 msgbox_uvmat('ERROR',['no writting access to ' filename])2950 msgbox_uvmat('ERROR',['no writting access to ' FileName]) 2954 2951 return 2955 2952 end … … 2973 2970 hhh=which('netcdf.open');% look for built-in matlab netcdf library 2974 2971 if ~isequal(hhh,'')% case of new builtin Matlab netcdf library 2975 nc=netcdf.open( filename,'NC_WRITE');2972 nc=netcdf.open(FileName,'NC_WRITE'); 2976 2973 netcdf.reDef(nc); 2977 2974 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1); … … 2986 2983 netcdf.close(nc); 2987 2984 else %old netcdf library 2988 netcdf_toolbox( filename,AxeData,attrname,nbname,flagname)2985 netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) 2989 2986 end 2990 2987 … … 2992 2989 %----Correct the netcdf file, using toolbox (old versions of Matlab). 2993 2990 %------------------------------------------------------------------- 2994 function netcdf_toolbox( filename,AxeData,attrname,nbname,flagname)2995 nc=netcdf( filename,'write'); %open netcdf file2991 function netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) 2992 nc=netcdf(FileName,'write'); %open netcdf file 2996 2993 result=redef(nc); 2997 2994 eval(['nc.' attrname '=1;']); … … 3090 3087 set(handles.VelType_1,'visible','off') 3091 3088 [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); 3094 3091 hget_field=findobj(allchild(0),'name','get_field'); 3095 3092 if ~isempty(hget_field) 3096 3093 delete(hget_field) 3097 3094 end 3098 hget_field=get_field( filename);3095 hget_field=get_field(FileName); 3099 3096 set(hget_field,'Name','get_field') 3100 3097 hhget_field=guidata(hget_field); … … 3147 3144 '*.*', 'All Files (*.*)'}, ... 3148 3145 'Pick a netcdf file',FileBase); 3149 filename=[PathName FileName];3146 FullFileName=[PathName FileName]; 3150 3147 % display the selected field and related information 3151 display_file_name( handles, filename)3148 display_file_name( handles,FullFileName) 3152 3149 return 3153 3150 end … … 3186 3183 UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read) 3187 3184 end 3188 UvData. filename_1='';% desactivate the use of a constant second file3185 UvData.FileName_1='';% desactivate the use of a constant second file 3189 3186 list_fields=get(handles.Fields,'String');% list menu fields 3190 3187 field= list_fields{get(handles.Fields,'Value')}; % selected string … … 3201 3198 %% read the rootfile input display 3202 3199 [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];3200 FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; 3204 3201 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); 3205 3202 % set(handles.FileIndex_1,'Visible','on') … … 3212 3209 delete(hget_field) 3213 3210 end 3214 hget_field=get_field( filename_1);3211 hget_field=get_field(FileName_1); 3215 3212 set(hget_field,'name','get_field_1') 3216 3213 hhget_field=guidata(hget_field); … … 3326 3323 set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic) 3327 3324 UvData=get(handles.uvmat,'UserData'); 3328 %refresh field with a second filename=first file name3325 %refresh field with a second FileName=first file name 3329 3326 set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow 3330 3327 drawnow 3331 3328 InputFile=read_GUI(handles.InputFile); 3332 3329 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 3333 filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];3330 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 3334 3331 3335 3332 if isempty(InputFile.VelType_1) 3336 filename_1='';% we plot the current field without the second field3333 FileName_1='';% we plot the current field without the second field 3337 3334 set(handles.SubField,'Value',0) 3338 3335 SubField_Callback(hObject, eventdata, handles) 3339 3336 elseif get(handles.SubField,'Value')% if subfield is already 'on' 3340 3337 [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]; 3342 3339 else 3343 filename_1=filename;% we compare two fields in the same file by default3340 FileName_1=FileName;% we compare two fields in the same file by default 3344 3341 UvData.FileType{2}=UvData.FileType{1}; 3345 3342 set(handles.SubField,'Value',1) … … 3348 3345 UvData=rmfield(UvData,'Field_1');% removes the stored second field if it exists 3349 3346 end 3350 UvData. filename_1='';% desactivate the use of a constant second file3347 UvData.FileName_1='';% desactivate the use of a constant second file 3351 3348 set(handles.uvmat,'UserData',UvData) 3352 3349 num_i1=stra2num(get(handles.i1,'String')); … … 3355 3352 num_j2=stra2num(get(handles.j2,'String')); 3356 3353 3357 errormsg=refresh_field(handles, filename,filename_1,num_i1,num_i2,num_j1,num_j2);3354 errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2); 3358 3355 3359 3356 if ~isempty(errormsg) -
trunk/src/xml2struct.m
r379 r450 15 15 16 16 17 function out=convert_string(s )18 info=whos('s ');17 function out=convert_string(ss) 18 info=whos('ss'); 19 19 switch info.class 20 20 case 'struct' 21 names = fieldnames(s );21 names = fieldnames(ss); 22 22 for k=1:length(names) 23 out.(names{k})=convert_string(s .(names{k}));23 out.(names{k})=convert_string(ss.(names{k})); 24 24 end 25 25 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 28 36 else 29 out=str2num(s );37 out=str2num(ss); 30 38 end 31 39 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}); 34 42 end 35 43 otherwise 36 out=s ;44 out=ss; 37 45 end 38 46
Note: See TracChangeset
for help on using the changeset viewer.