- Timestamp:
- Dec 14, 2011, 1:33:18 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/fileparts_uvmat.m
r333 r334 4 4 % 5 5 %OUTPUT: 6 %RootPath: path to the base file 7 %SubDir: name of the SubDirectory for netcdf files (NomTypes with index pairs 1-2 or ab ) 6 8 %RootFile: FileName without appendix 7 9 %i1: first number i … … 9 11 %j1: first number j 10 12 %j2: second number j (only for .nc files) 11 % Ext: file Extension13 %FileExt: file Extension 12 14 %NomType: char chain characterizing the file nomenclature: with values 13 % NomType='': constant name [filebase Ext] (default output if 'NomType' is undefined)15 % NomType='': constant name [filebase FileExt] (default output if 'NomType' is undefined) 14 16 % NomType='*':constant name for a file representing a series (e.g. avi movie) 15 17 % NomType='1','01',or '001'...': series of files with a single index i without separator(e.g. 'aa045.png'). … … 17 19 % NomType='1_1','01_1',...: matrix of files with two indices i and j separated by '_'(e.g. 'aa45_2.png') 18 20 % NomType='1-1': from pairs from a single index (e.g. 'aa_45-47.nc') 19 % NomType='1_1- 1': pairs of j indices (e.g. 'aa_45_2-3.nc')20 % NomType='1- 1_1': pairs of i indices (e.g. 'aa_45-46_2.nc')21 % NomType='1_ab','01_ab','01 _a-b'..., from pairs of '#' images (e.g.'aa045bc.nc'),Ext='.nc'21 % NomType='1_1-2': pairs of j indices (e.g. 'aa_45_2-3.nc') 22 % NomType='1-2_1': pairs of i indices (e.g. 'aa_45-46_2.nc') 23 % NomType='1_ab','01_ab','01ab'..., from pairs of '#' images (e.g.'aa045bc.nc'), FileExt='.nc' 22 24 %SubDir: name of the SubDirectory for netcdf files 23 24 % OLD TYPES, not supported anymore25 % NomType='_1','_01','_001'...': series of files with a single index i with separator '_'(e.g. 'aa_045.png').26 % NomType='_1a','_1A','_01a','_01A',...: idem, with a separator '_' before the index27 % NomType='_1_1','_01_1',...: matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')28 % NomType='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc')29 % NomType='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc')30 % NomType='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc')31 % NomType='_1_ab','1_ab','01_ab'..., from pairs of '#' images (e.g.'aa045bc.nc'), Ext='.nc'32 33 25 % 34 26 %INPUT: 35 27 %FileInput: complete name of the file, including path 36 28 37 function [RootPath,SubDir,RootFile,i1,i2,j1,j2,Ext,NomType]=fileparts_uvmat(FileInput) 38 29 function [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(FileInput) 30 RootPath=''; 31 SubDir=''; 32 RootFile=''; 39 33 i1=[]; 40 34 i2=[]; 41 35 j1=[]; 42 36 j2=[]; 37 FileExt=''; 43 38 NomType=''; 44 SubDir=''; 45 RootFile=''; 46 39 40 41 42 %% display help and test function in the absence of input arument 47 43 if ~exist('FileInput','var') 48 44 help fileparts_uvmat; … … 51 47 end 52 48 53 54 [RootPath,FileName,Ext]=fileparts(FileInput); 55 56 switch Ext 57 case '.avi' 58 NomType='*'; 59 return 60 case {'.tif','.tiff'} 61 if exist(FileInput,'file') 62 info=iminfo(FileInput); 63 if length(info)>1 64 NomType='*'; 65 return 66 end 67 end 68 end 49 [RootPath,FileName,FileExt]=fileparts(FileInput); 50 RootFile=FileName;%default 51 % switch FileExt 52 % case '.avi' 53 % NomType='*'; 54 % return 55 % case {'.tif','.tiff'} 56 % if exist(FileInput,'file') 57 % info=iminfo(FileInput); 58 % if length(info)>1 59 % NomType='*'; 60 % return 61 % end 62 % end 63 % end 69 64 70 65 % \D not a digit … … 72 67 73 68 74 %% recursive test on FileName stqrting from the end 75 69 %% recursive test on FileName starting from the end 70 % case of pure number 71 if ~isnan(str2double(FileName)) 72 RootFile=''; 73 i1=str2double(FileName); 74 return 75 end 76 76 % test whether FileName ends with a number or not 77 r=regexp(FileName,'.*\D(?<num1>\d+) \>','names');77 r=regexp(FileName,'.*\D(?<num1>\d+)$','names');% \D = not a digit, \d =digit 78 78 79 79 if ~isempty(r)% FileName end matches num1 80 80 num1=r.num1; 81 r=regexp(FileName,['.*\D(?<num2>\d+)(?<delim1>[-_])' num1 ' \>'],'names');81 r=regexp(FileName,['.*\D(?<num2>\d+)(?<delim1>[-_])' num1 '$'],'names'); 82 82 if ~isempty(r)% FileName end matches num2+delim1+num1 83 83 delim1=r.delim1; 84 84 num2=r.num2; 85 r=regexp(FileName,['.*\D(?<num3>\d+)(?<delim2>[-_])' num2 delim1 num1 ' \>'],'names');85 r=regexp(FileName,['.*\D(?<num3>\d+)(?<delim2>[-_])' num2 delim1 num1 '$'],'names'); 86 86 if ~isempty(r) % FileName end matches delim2 num2 delim1 num1 87 87 delim2=r.delim2; … … 117 117 RootFile=regexprep(FileName,[num2 delim1 num1],''); 118 118 end 119 NomType=regexprep(NomType,'-1','-2'); %set 1-2 instead of 1-1 119 120 else% only one number at the end 120 121 i1=str2double(num1); … … 123 124 end 124 125 else% FileName ends with a letter 125 r=regexp(FileName,'.*[^a^b^A^B](?<end_string>ab|AB|[abAB])\>','names'); 126 %r=regexp(FileName,'.*[^a^b^A^B](?<end_string>ab|AB|[abAB])\>','names'); 127 NomType=''; 128 r=regexp(RootFile,'\D(?<num1>\d+)(?<end_string>[a-z]|[A-Z]|[a-z][a-z]|[A-Z][A-Z])$','names'); 126 129 if ~isempty(r) 127 end_string=r.end_string; 128 r=regexp(FileName,['.+(?<delim1>[_-])' end_string '\>'],'names'); 130 NomType=get_type(r.end_string); 131 RootFile=regexprep(RootFile,[r.num1 r.end_string '$'],''); 132 else % case with separator '_' 133 r=regexp(RootFile,'\D(?<num1>\d+)_(?<end_string>[a-z]|[A-Z]|[a-z][a-z]|[A-Z][A-Z])$','names'); 129 134 if ~isempty(r) 130 delim1=r.delim1; 131 r=regexp(FileName,['.*\D(?<num1>\d+)' delim1 end_string '\>'],'names'); 132 if ~isempty(r) 133 num1=r.num1; 134 NomType=[get_type(num1) delim1 get_type(end_string)]; 135 i1=str2double(num1); 136 [j1,j2]=get_value(end_string); 137 RootFile=regexprep(FileName,[num1 delim1 end_string],''); 138 139 else 140 NomType=get_type(end_string); 141 [j1,j2]=get_value(end_string); 142 RootFile=regexprep(FileName,end_string,''); 143 144 end 145 else 146 r=regexp(FileName,['.*\D(?<num1>\d+)' end_string '\>'],'names'); 147 if ~isempty(r) 148 num1=r.num1; 149 % r=regexp(FileName,['.+(?<delim1>[-_])' num1 end_string '\>'],'names'); 150 % if ~isempty(r) 151 % delim1=r.delim1; 152 % i1=num1; 153 % str_a=end_string; 154 % NomType=[delim1 get_type(num1) get_type(end_string)]; 155 % RootFile=regexprep(FileName,[delim1 num1 end_string],''); 156 % else 157 i1=str2double(num1); 158 [j1,j2]=get_value(end_string); 159 NomType=[get_type(num1) get_type(end_string)]; 160 RootFile=regexprep(FileName,[num1 end_string],''); 161 % end 162 else 163 end 164 165 166 167 end 168 else 169 end 170 end 171 172 if ~isempty(regexp(NomType,'-|ab|AB')) 173 r=regexp(RootPath,'\<(?<newrootpath>.+)(\\|/)(?<subdir>[^\\^/]+)(\\|/)*\>','names'); 174 if ~isempty(r) 175 SubDir=r.subdir; 176 RootPath=r.newrootpath; 177 end 178 end 135 NomType=['_' get_type(r.end_string)]; 136 RootFile=regexprep(RootFile,[r.num1 '_' r.end_string '$'],''); 137 end 138 end 139 if ~isempty(NomType) 140 [j1,j2]=get_value(r.end_string); 141 i1=str2double(r.num1); 142 NomType=[get_type(r.num1) NomType]; 143 r=regexp(RootPath,'\<(?<newrootpath>.+)(\\|/)(?<subdir>[^\\^/]+)(\\|/)*\>','names'); 144 if ~isempty(r) 145 SubDir=r.subdir; 146 RootPath=r.newrootpath; 147 end 148 end 149 end 150 151 %% suppress '_' at the end of RootFile, put it on NomType 152 if strcmp(RootFile(end),'_') 153 RootFile(end)=[]; 154 NomType=['_' NomType]; 155 end 156 157 % if ~isempty(regexp(NomType,'-|ab|AB')) 158 % r=regexp(RootPath,'\<(?<newrootpath>.+)(\\|/)(?<subdir>[^\\^/]+)(\\|/)*\>','names'); 159 % if ~isempty(r) 160 % SubDir=r.subdir; 161 % RootPath=r.newrootpath; 162 % end 163 % end 179 164 180 165 … … 184 169 % returns the type of a label string: 185 170 % for numbers, whether filled with 0 or not. 186 % for letters, either a, A or ab, AB. 187 188 switch s 189 case {'a','b'} 190 type='a'; 191 case {'A','B'} 192 type='A'; 193 case 'ab' 194 type='ab'; 195 case 'AB' 196 type='AB'; 197 otherwise 198 if ~isempty(regexp(s,'\<\d+\>','ONCE')) 199 % switch s(1) 200 % case '0' 201 type=num2str(1,['%0' num2str(length(s)) 'd']); 202 % otherwise 203 % type='1'; 204 % end 205 else 206 type=''; 207 return 208 end 209 end 171 type='';%default 172 173 if ~isempty(regexp(s,'\<\d+\>','ONCE')) 174 type=num2str(1,['%0' num2str(length(s)) 'd']); 175 else 176 code=double(s); % ascii code of the input string 177 if code >= 65 & code <= 90 % test on ascii code for capital letters 178 if length(s)==1 179 type='A'; 180 elseif length(s)==2 181 type='AB'; 182 end 183 elseif code >= 97 & code <= 122 % test on ascii code for small letters 184 if length(s)==1 185 type='a'; 186 elseif length(s)==2 187 type='ab'; 188 end 189 end 190 end 191 210 192 211 193 212 194 function [j1,j2]=get_value(s) 213 % returns the type of a label string:195 % returns the value of a label string: 214 196 % for numbers, whether filled with 0 or not. 215 197 % for letters, either a, A or ab, AB. 216 198 j1=[]; 217 199 j2=[]; 218 219 switch lower(s) 220 case {'a'} 221 j1=1; 222 case {'b','B'} 223 j1=2; 224 case 'ab' 225 j1=1;j2=2; 226 otherwise 227 return 228 end 229 200 code=double(s); % ascii code of the input string 201 if code >= 65 & code <= 90 % test on ascii code for capital letters 202 index=double(s)-64; %change capital letters to corresponding number in the alphabet 203 elseif code >= 97 & code <= 122 % test on ascii code for small letters 204 index=double(s)-96; %change small letters to corresponding number in the alphabet 205 else 206 index=str2num(s); 207 end 208 if ~isempty(index) 209 j1=index(1); 210 if length(index)==2 211 j2=index(2); 212 end 213 end 230 214 231 215 … … 256 240 'Image_5_3-4.jpg'... 257 241 'Image_3_ab.jpg'... 258 'Image005A B.jpg'...259 'Image_3_a b.jpg'...242 'Image005AD.jpg'... 243 'Image_3_ac.jpg'... 260 244 'Image_3a-b.jpg'... 261 245 'Image3_a.jpg'... … … 265 249 266 250 for FileName=FileName_list 267 % [RootPath,RootFile,i1,i2,str_a,str_b, Ext,NomType,SubDir]=name2display(FileName{1});268 [~, RootFile,i1,i2,j1,j2,~,NomType,SubDir]=...251 % [RootPath,RootFile,i1,i2,str_a,str_b,FileExt,NomType,SubDir]=name2display(FileName{1}); 252 [~,SubDir,RootFile,i1,i2,j1,j2,~,NomType]=... 269 253 fileparts_uvmat(FileName{1}); 270 254 fprintf([... -
trunk/src/find_file_series.m
r332 r334 1 %'find_file_series': check the content onf an input fiel and find the corresponding file series1 %'find_file_series': check the content onf an input field and find the corresponding file series 2 2 %-------------------------------------------------------------------------- 3 3 % function [i1,i2,j1,j2,NomType,FileType,Object]=find_file_series(fileinput) … … 36 36 function [i1,i2,j1,j2,NomType,FileType,Object]=find_file_series(fileinput) 37 37 %------------------------------------------------------------------------ 38 i1= NaN;%default39 i2= NaN;%default40 j1= NaN;%default41 j2= NaN;%default38 i1=[];%default 39 i2=[];%default 40 j1=[];%default 41 j2=[];%default 42 42 43 43 %% get input root name and nomenclature type 44 [RootPath,RootFile,~,~,~,~,FileExt,NomType,SubDir]=name2display(fileinput); 44 % [RootPath,RootFile,~,~,~,~,FileExt,NomType,SubDir]=name2display(fileinput); 45 [RootPath,SubDir,RootFile,~,~,~,~,FileExt,NomType]=fileparts_uvmat(fileinput); 45 46 46 47 %% check for particular file types: images, movies, civ data 47 48 FileType=''; 48 49 Object=[]; 49 if ~isempty(FileExt)&& ~isempty(imformats(FileExt(2:end))) 50 imainfo=imfinfo(fileinput); 51 FileType='image'; 52 if length(imainfo) >1 %case of image with multiple frames 53 NomType='*'; 54 FileType='multimage'; 55 i1=1; 56 i2=length(imainfo); 57 [RootPath,RootFile]=fileparts(fileinput); 58 end 50 switch FileExt 51 % ancillary files, no field indexing 52 case {'.civ','.log','.cmx','.cmx2','.txt','.bat'} 53 FileType='txt'; 54 NomType=''; 55 case '.fig' 56 FileType='figure'; 57 NomType=''; 58 case '.xml' 59 FileType='xml'; 60 NomType=''; 61 case '.xls' 62 FileType='xls'; 63 NomType=''; 64 otherwise 65 if ~isempty(FileExt)&& ~isempty(imformats(FileExt(2:end))) 66 imainfo=imfinfo(fileinput); 67 FileType='image'; 68 if length(imainfo) >1 %case of image with multiple frames 69 NomType='*'; 70 FileType='multimage'; 71 i1=1; 72 i2=length(imainfo); 73 [RootPath,RootFile]=fileparts(fileinput); 74 end 75 else 76 try 77 Data=nc2struct(fileinput,'ListGlobalAttribute','absolut_time_T0','Conventions'); 78 if ~isempty(Data.absolut_time_T0') 79 FileType='civx'; % test for civx velocity fields 80 elseif strcmp(Data.Conventions','uvmat/civdata') 81 FileType='civdata'; % test for civx velocity fields 82 else 83 FileType='netcdf'; 84 end 85 end 86 try 87 Object=VideoReader(fileinput); 88 NomType='*'; 89 FileType='video'; 90 i1=1; 91 i2=get(Object,'NumberOfFrames'); 92 [RootPath,RootFile]=fileparts(fileinput); 93 end 94 end 95 end 96 if strcmp(NomType,'')||strcmp(NomType,'*') 97 [RootPath,RootFile]=fileparts(fileinput);% case of constant name (no indexing) 98 %% get the list of existing files 59 99 else 60 try61 Data=nc2struct(fileinput,'ListGlobalAttribute',{'absolut_time_T0','Conventions'});62 if ~isempty(Data,'absolut_time_T0')63 FileType='civx'; % test for civx velocity fields64 elseif strcmp(Data.Conventions','uvmat/civdata')65 FileType='civdata'; % test for civx velocity fields66 else67 FileType='netcdf';68 end69 end70 try71 Object=VideoReader(fileinput);72 NomType='*';73 FileType='video';74 i1=1;75 i2=get(Object,'NumberOfFrames');76 [RootPath,RootFile]=fileparts(fileinput);77 end78 end79 80 %% get the list of existing files81 if ~strcmp(NomType,'*')82 100 if strcmp(SubDir,'') 83 101 filebasesub=fullfile(RootPath,RootFile); … … 95 113 end 96 114 dirpair=dir([filebasesub detect_string FileExt]); 97 % switch NomType %TODO: complement for other cases98 % case '_0001'99 % dirpair=dir([filebasesub '_*' FileExt]);100 % case '_1'101 % dirpair=dir([filebasesub '_*' FileExt]);102 % case '_1_1'103 % dirpair=dir([filebasesub '_*_*' FileExt]);104 % case '_i1-i2'105 % dirpair=dir([filebasesub '_*-*' FileExt]);106 % case '1_ab'107 % dirpair=dir([filebasesub '*_*' FileExt]);108 % case '_i_j1-j2'109 % dirpair=dir([filebasesub '*_*-*' FileExt]);110 % case '_i1-i2_j'111 % dirpair=dir([filebasesub '*-*_*' FileExt]);112 % end113 115 for ifile=1:length(dirpair) 114 [~,~,str_1,str_2,str_a,str_b]=name2display(dirpair(ifile).name); 115 i1(ifile)=str2double(str_1); 116 i2(ifile)=str2double(str_2); 117 if isnan(i2(ifile)) 116 % [~,~,str_1,str_2,str_a,str_b]=name2display(dirpair(ifile).name); 117 dirpair(ifile).name 118 [~,~,~,i1_ifile,i2_ifile,j1_ifile,j2_ifile]=fileparts_uvmat(dirpair(ifile).name); 119 if isempty(i1_ifile) 120 i1(ifile)=1; 121 else 122 i1(ifile)=i1_ifile; 123 end 124 if isempty(i2_ifile) 118 125 i2(ifile)=i1(ifile); 126 else 127 i2(ifile)=i2_ifile; 119 128 end 120 j1(ifile)=stra2num(str_a);121 if is nan(j1(ifile))129 end 130 if isempty(j1_ifile) 122 131 j1(ifile)=1; 132 else 133 j1(ifile)=j1_ifile; 123 134 end 124 j2(ifile)=stra2num(str_b); 125 if isnan(j2(ifile)) 135 if isempty(j2_ifile) 126 136 j2(ifile)=j1(ifile); 137 else 138 j2(ifile)=j2_ifile; 127 139 end 128 end 129 140 end 141 % TODO : sort by reference index 130 142 % update the NomType from the minimal index detected (to deal with number strings beginning by 0) 131 143 [~,ifile]=min(i1); 132 [~,~,~,~,~,~,~,NomType]=name2display(dirpair(ifile).name); 144 %[~,~,~,~,~,~,~,NomType]=name2display(dirpair(ifile).name); 145 if ~isempty(i1) 146 [~,ifile]=min(i1); 147 [~,~,~,~,~,~,~,~,NomType]=fileparts_uvmat(dirpair(ifile).name); 148 end 133 149 end -
trunk/src/plot_field.m
r313 r334 480 480 PlotParam=[]; 481 481 end 482 if ~isfield(PlotParam,'Coordinates') 483 PlotParam.Coordinates=[]; 484 end 482 485 if ~isfield(PlotParam,'Scalar') 483 486 PlotParam.Scalar=[]; … … 1014 1017 YMin=[]; 1015 1018 YMax=[]; 1016 fix_lim=isfield(PlotParam ,'CheckFixLimits') && PlotParam.CheckFixLimits;1019 fix_lim=isfield(PlotParam.Coordinates,'CheckFixLimits') && PlotParam.Coordinates.CheckFixLimits; 1017 1020 if fix_lim 1018 if ~isfield(PlotParam,'MinX')||~isfield(PlotParam,'MaxX')||~isfield(PlotParam,'MinY')||~isfield(PlotParam,'MaxY') 1019 fix_lim=0; %free limits if limits are not set, 1020 else 1021 XMin=PlotParam.MinX 1022 XMax=PlotParam.MaxX; 1023 YMin=PlotParam.MinY; 1024 YMax=PlotParam.MaxY; 1021 if isfield(PlotParam.Coordinates,'MinX')&&isfield(PlotParam.Coordinates,'MaxX')&&isfield(PlotParam.Coordinates,'MinY')&&isfield(PlotParam.Coordinates,'MaxY') 1022 XMin=PlotParam.Coordinates.MinX; 1023 XMax=PlotParam.Coordinates.MaxX; 1024 YMin=PlotParam.Coordinates.MinY; 1025 YMax=PlotParam.Coordinates.MaxY; 1025 1026 end %else PlotParamOut.XMin =PlotParam.XMin... 1026 1027 else … … 1046 1047 % PlotParamOut.RangeY=[YMin YMax]; %range of x, to be stored in the user data of the plot axes 1047 1048 % if ~fix_lim 1048 PlotParamOut. MinX=XMin;1049 PlotParamOut. MaxX=XMax;1050 PlotParamOut. MinY=YMin;1051 PlotParamOut. MaxY=YMax;1049 PlotParamOut.Coordinates.MinX=XMin; 1050 PlotParamOut.Coordinates.MaxX=XMax; 1051 PlotParamOut.Coordinates.MinY=YMin; 1052 PlotParamOut.Coordinates.MaxY=YMax; 1052 1053 if XMax>XMin 1053 1054 set(haxes,'XLim',[XMin XMax]);% set x limits of frame in axes coordinates … … 1060 1061 set(get(haxes,'XLabel'),'String',[XName ' (' x_units ')']); 1061 1062 set(get(haxes,'YLabel'),'String',[YName ' (' y_units ')']); 1062 PlotParamOut. x_units=x_units;1063 PlotParamOut. y_units=y_units;1063 PlotParamOut.Coordinates.x_units=x_units; 1064 PlotParamOut.Coordinates.y_units=y_units; 1064 1065 end 1065 1066 %------------------------------------------------------------------- -
trunk/src/read_field.m
r273 r334 34 34 VelType=ParamIn.VelType; 35 35 end 36 37 %% case of netcdf input file 38 if strcmp(FileType,'netcdf') %read the first nc field 39 ParamOut.FieldName=ParamIn.FieldName; 40 GUIName='get_field'; %default name of the GUI get_field 41 if isfield(ParamIn,'GUIName') 42 GUIName=ParamIn.GUIName; 43 end 44 test_civx=0; 45 if ~strcmp(ParamIn.FieldName,'get_field...')% if get_field is not requested, look for Civx data 46 FieldList=calc_field;%list of possible fields for Civx data 47 ParamOut.ColorVar='';%default 48 field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data 49 if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist 50 Data=nc2struct(ObjectName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ'); 51 % case of new civdata conventions 52 if isequal(Data.Conventions,'uvmat/civdata') 53 ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default 54 ParamOut.ColorVar='ima_cor'; 55 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 56 [Field,ParamOut.VelType]=read_civdata(ObjectName,InputField,ParamIn.VelType); 57 test_civx=Field.CivStage; 58 %case of old civx conventions 59 elseif ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0) 60 ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default 61 ParamOut.ColorVar='ima_cor'; 62 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 63 [Field,ParamOut.VelType]=read_civxdata(ObjectName,InputField,ParamIn.VelType); 36 A=[]; 37 %% distingush different input file types 38 switch FileType 39 case {'civx','civdata','netcdf'} %read the first nc field 40 ParamOut.FieldName=ParamIn.FieldName; 41 GUIName='get_field'; %default name of the GUI get_field 42 if isfield(ParamIn,'GUIName') 43 GUIName=ParamIn.GUIName; 44 end 45 test_civx=0; 46 if ~strcmp(ParamIn.FieldName,'get_field...')% if get_field is not requested, look for Civx data 47 FieldList=calc_field;%list of possible fields for Civx data 48 ParamOut.ColorVar='';%default 49 field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data 50 if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist 51 Data=nc2struct(ObjectName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ'); 52 % case of new civdata conventions 53 if isequal(Data.Conventions,'uvmat/civdata') 54 ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default 55 ParamOut.ColorVar='ima_cor'; 56 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 57 [Field,ParamOut.VelType]=read_civdata(ObjectName,InputField,ParamIn.VelType); 58 test_civx=Field.CivStage; 59 %case of old civx conventions 60 elseif ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0) 61 ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default 62 ParamOut.ColorVar='ima_cor'; 63 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 64 [Field,ParamOut.VelType]=read_civxdata(ObjectName,InputField,ParamIn.VelType); 65 test_civx=Field.CivStage; 66 ParamOut.CivStage=Field.CivStage; 67 % not cvix file, fields will be chosen through the GUI get_field 68 else 69 ParamOut.FieldName='get_field...'; 70 hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI 71 if ~isempty(hget_field) 72 delete(hget_field)%delete get_field for reinitialisation 73 end 74 end 75 else 76 InputField={ParamOut.FieldName}; 77 if isfield(ParamIn,'ColorVar') 78 ParamOut.ColorVar=ParamIn.ColorVar; 79 InputField=[InputField {ParamOut.ColorVar}]; 80 end 81 [Field,ParamOut.VelType,errormsg]=read_civxdata(ObjectName,InputField,ParamIn.VelType); 82 if ~isempty(errormsg) 83 return 84 end 64 85 test_civx=Field.CivStage; 65 86 ParamOut.CivStage=Field.CivStage; 66 % not cvix file, fields will be chosen through the GUI get_field 67 else 68 ParamOut.FieldName='get_field...'; 69 hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI 70 if ~isempty(hget_field) 71 delete(hget_field)%delete get_field for reinitialisation 72 end 73 end 87 end 88 end 89 if ~test_civx% read the field names on the interface get_field. 90 hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI 91 if isempty(hget_field)% open the GUI get_field if it is not found 92 hget_field= get_field(ObjectName);%open the get_field GUI 93 set(hget_field,'Name',GUIName)%update the name of get_field (e.g. get_field_1) 94 end 95 hhget_field=guidata(hget_field); 96 %% update the get_field GUI 97 set(hhget_field.inputfile,'String',ObjectName) 98 set(hhget_field.list_fig,'Value',1) 99 if exist('num','var')&&~isnan(num) 100 set(hhget_field.TimeIndexValue,'String',num2str(num)) 101 end 102 funct_list=get(hhget_field.ACTION,'UserData'); 103 funct_index=get(hhget_field.ACTION,'Value'); 104 funct=funct_list{funct_index};%select the current action in get_field, e;g. PLOT 105 Field=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot 106 Tabchar={''};%default 107 Tabcell=[]; 108 set(hhget_field.inputfile,'String',ObjectName) 109 if isfield(Field,'ListGlobalAttribute')&& ~isempty(Field.ListGlobalAttribute) 110 for iline=1:length(Field.ListGlobalAttribute) 111 Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; 112 if isfield(Field, Field.ListGlobalAttribute{iline}) 113 eval(['val=Field.' Field.ListGlobalAttribute{iline} ';']) 114 if ischar(val); 115 Tabcell{iline,2}=val; 116 else 117 Tabcell{iline,2}=num2str(val); 118 end 119 end 120 end 121 if ~isempty(Tabcell) 122 Tabchar=cell2tab(Tabcell,'='); 123 Tabchar=[{''};Tabchar]; 124 end 125 end 126 %set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field 127 ParamOut.CivStage=0; 128 ParamOut.VelType=[]; 129 if isfield(Field,'TimeIndex') 130 ParamOut.TimeIndex=Field.TimeIndex; 131 end 132 if isfield(Field,'TimeValue') 133 ParamOut.TimeValue=Field.TimeValue; 134 end 135 end 136 if test_civx 137 ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}]; 74 138 else 75 InputField={ParamOut.FieldName}; 76 if isfield(ParamIn,'ColorVar') 77 ParamOut.ColorVar=ParamIn.ColorVar; 78 InputField=[InputField {ParamOut.ColorVar}]; 79 end 80 [Field,ParamOut.VelType,errormsg]=read_civxdata(ObjectName,InputField,ParamIn.VelType); 81 if ~isempty(errormsg) 82 return 83 end 84 test_civx=Field.CivStage; 85 ParamOut.CivStage=Field.CivStage; 86 end 87 end 88 if ~test_civx% read the field names on the interface get_field. 89 hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI 90 if isempty(hget_field)% open the GUI get_field if it is not found 91 hget_field= get_field(ObjectName);%open the get_field GUI 92 set(hget_field,'Name',GUIName)%update the name of get_field (e.g. get_field_1) 93 end 94 hhget_field=guidata(hget_field); 95 %% update the get_field GUI 96 set(hhget_field.inputfile,'String',ObjectName) 97 set(hhget_field.list_fig,'Value',1) 98 if exist('num','var')&&~isnan(num) 99 set(hhget_field.TimeIndexValue,'String',num2str(num)) 100 end 101 funct_list=get(hhget_field.ACTION,'UserData'); 102 funct_index=get(hhget_field.ACTION,'Value'); 103 funct=funct_list{funct_index};%select the current action in get_field, e;g. PLOT 104 Field=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot 105 Tabchar={''};%default 106 Tabcell=[]; 107 set(hhget_field.inputfile,'String',ObjectName) 108 if isfield(Field,'ListGlobalAttribute')&& ~isempty(Field.ListGlobalAttribute) 109 for iline=1:length(Field.ListGlobalAttribute) 110 Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; 111 if isfield(Field, Field.ListGlobalAttribute{iline}) 112 eval(['val=Field.' Field.ListGlobalAttribute{iline} ';']) 113 if ischar(val); 114 Tabcell{iline,2}=val; 115 else 116 Tabcell{iline,2}=num2str(val); 117 end 118 end 119 end 120 if ~isempty(Tabcell) 121 Tabchar=cell2tab(Tabcell,'='); 122 Tabchar=[{''};Tabchar]; 123 end 124 end 125 %set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field 126 ParamOut.CivStage=0; 127 ParamOut.VelType=[]; 128 if isfield(Field,'TimeIndex') 129 ParamOut.TimeIndex=Field.TimeIndex; 130 end 131 if isfield(Field,'TimeValue') 132 ParamOut.TimeValue=Field.TimeValue; 133 end 134 end 135 if test_civx 136 ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}]; 137 else 138 ParamOut.FieldList={'get_field...'}; 139 end 140 else 141 142 %% case of image 139 ParamOut.FieldList={'get_field...'}; 140 end 141 142 case 'movie' 143 try 144 A=read(ObjectName,num); 145 FieldName='image'; 146 catch ME 147 errormsg=ME.message; 148 return 149 end 150 case 'avi' 151 try 152 mov=aviread(ObjectName,num); 153 catch ME 154 errormsg=ME.message; 155 return 156 end 157 A=frame2im(mov(1)); 158 FieldName='image'; 159 case 'vol' 160 A=imread(ObjectName); 161 Npz=size(A,1)/ParamIn.Npy; 162 A=reshape(A',ParamIn.Npx,ParamIn.Npy,Npz); 163 A=permute(A,[3 2 1]); 164 FieldName='image'; 165 case 'multimage' 166 A=imread(ObjectName,num); 167 FieldName='image'; 168 case 'image' 169 A=imread(ObjectName); 170 FieldName='image'; 171 end 172 %% case of image 173 if ~isempty(A) 143 174 ParamOut.FieldName='image'; 144 175 ParamOut.FieldList={'image'}; 145 176 Npz=1;%default 146 switch FileType147 case 'movie'148 try149 A=read(ObjectName,num);150 FieldName='image';151 catch ME152 errormsg=ME.message;153 return154 end155 case 'avi'156 try157 mov=aviread(ObjectName,num);158 catch ME159 errormsg=ME.message;160 return161 end162 A=frame2im(mov(1));163 FieldName='image';164 case 'vol'165 A=imread(ObjectName);166 Npz=size(A,1)/ParamIn.Npy;167 A=reshape(A',ParamIn.Npx,ParamIn.Npy,Npz);168 A=permute(A,[3 2 1]);169 FieldName='image';170 case 'multimage'171 A=imread(ObjectName,num);172 FieldName='image';173 case 'image'174 A=imread(ObjectName);175 FieldName='image';176 end177 177 npxy=size(A); 178 178 Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers … … 213 213 214 214 215 -
trunk/src/uvmat.m
r332 r334 468 468 function display_file_name(hObject, eventdata, handles,fileinput) 469 469 %------------------------------------------------------------------------ 470 %% analyse the input file 470 471 if ~exist(fileinput,'file') 471 472 msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) 472 473 return 473 474 end 474 [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);%extract information from the file name 475 ext_test=''; %default 476 if ~isempty(ext) % if a file extension is detected 477 form=imformats(ext(2:end));%test valid Matlab image formats 478 if ~isempty(form) 479 ext_test='.image'; 480 imainfo=imfinfo(fileinput); 481 if length(imainfo) >1 %case of image with multiple frames 482 i1='1'; % set the frame counter to 1 by default 483 i2=''; 484 str_a=''; 485 str_b=''; 486 NomType='*'; %indicate a set of indexed frames within a single file 487 [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file 488 end 489 elseif isequal(lower(ext),'.avi')%case of avi movie file 490 ext_test='.image'; 491 i1='1'; % set the frame counter to 1 by default 492 i2=''; 493 str_a=''; 494 str_b=''; 495 NomType='*'; %indicate a set of indexed frames within a single file 496 [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file 497 else 498 ext_test=lower(ext); 499 end 500 end 501 switch ext_test 502 case {'.civ','.log','.cmx','.cmx2','.txt','.bat'} %display text file 475 % detect root name, nomenclature and indices in the input file name: 476 [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt]=fileparts_uvmat(fileinput); 477 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 478 [i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput); 479 480 % open the file or fill the GUI uvmat according to the detected file type 481 switch FileType 482 case '' 483 msgbox_uvmat('ERROR','invalid input file type') 484 case 'txt' 503 485 edit(fileinput) 504 case ' .fig' %display matlab figure486 case 'figure' %display matlab figure 505 487 hfig=open(fileinput); 506 488 set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio 507 489 set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function 508 490 set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function 509 case {' .xml','.xls'} % edit xml or Excel files491 case {'xml','xls'} % edit xml or Excel files 510 492 editxml(fileinput); 511 case {'.avi','.image','.vol','.nc','.cdf'}493 otherwise 512 494 set(handles.RootPath,'String',RootPath); 513 495 if isequal(SubDir,'') … … 520 502 set(handles.RootFile,'String',['/' RootFile]); %display the separator 521 503 indices=fileinput(length(rootname)+1:end); 522 indices(end-length( ext)+1:end)=[]; %remove extension504 indices(end-length(FileExt)+1:end)=[]; %remove extension 523 505 set(handles.FileIndex,'String',indices); 524 506 % set(handles.FileIndex,'UserData',NomType); 525 set(handles.NomType,'String',NomType);526 set(handles.FileExt,'String', ext);507 set(handles.NomType,'String',NomType); 508 set(handles.FileExt,'String',FileExt); 527 509 % fill file index counters 528 set(handles.i1,'String', i1);529 set(handles.i2,'String', i2);530 set(handles.j1,'String', str_a);531 set(handles.j2,'String', str_b);510 set(handles.i1,'String',num2str(i1)); 511 set(handles.i2,'String',num2str(i2)); 512 set(handles.j1,'String',num2str(j1)); 513 set(handles.j2,'String',num2str(j2)); 532 514 533 515 % synchronise indices of the second input file if it exists … … 536 518 NomType_1=get(handles.NomType_1,'String'); 537 519 % NomType_1=get(handles.FileIndex_1,'UserData'); 538 FileName_1=name_generator(FileBase_1, str2double(i1),str2double(i2),FileExt_1,NomType_1,1,stra2num(str_a),stra2num(str_b),SubDir_1);520 FileName_1=name_generator(FileBase_1,i1,i2,FileExt_1,NomType_1,1,j1,j2,SubDir_1); 539 521 if exist(FileName_1,'file') 540 FileIndex_1=name_generator('', str2double(i1),str2double(i2),'',NomType_1,1,stra2num(str_a),stra2num(str_b),'');522 FileIndex_1=name_generator('',i1,i2,'',NomType_1,1,j1,j2,''); 541 523 set(handles.FileIndex_1,'String',FileIndex_1) 542 524 else … … 561 543 set(handles.ListObject,'Visible','on') 562 544 set(handles.frame_object,'Visible','on') 563 %%%%%% initiate input file: 564 update_rootinfo(hObject,eventdata,handles); 565 otherwise 566 msgbox_uvmat('ERROR',['invalid input file extension' ext]) 545 546 % initiate input file series and refresh the current field view: 547 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject); 567 548 end 568 549 … … 571 552 function RootPath_Callback(hObject,eventdata,handles) 572 553 %------------------------------------------------------------------------ 573 update_rootinfo(hObject,eventdata,handles); 554 % read the current input file name: 555 fileinput=read_file_boxes(handles); 556 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 557 [i1_series,i2_series,j1_series,j2_series,~,FileType,MovieObject]=find_file_series(fileinput); 558 % initiate the input file series and refresh the current field view: 559 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject); 574 560 575 561 %------------------------------------------------------------------------ … … 579 565 %refresh the menu of input fields 580 566 Fields_Callback(hObject, eventdata, handles); 581 % refresh the current field 567 % refresh the current field view 582 568 run0_Callback(hObject, eventdata, handles); 583 569 … … 586 572 function RootFile_Callback(hObject, eventdata, handles) 587 573 %------------------------------------------------------------------------ 588 update_rootinfo(hObject,eventdata,handles)574 RootPath_Callback(hObject,eventdata,handles) 589 575 590 576 %------------------------------------------------------------------------ … … 592 578 function FileIndex_Callback(hObject, eventdata, handles) 593 579 %------------------------------------------------------------------------ 594 FileIndices=get(handles.FileIndex,'String'); 595 if isempty(str2num(FileIndices)) 596 [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices); 597 else 598 str1=FileIndices; 599 str2=''; 600 str_a=''; 601 str_b=''; 602 end 603 set(handles.i1,'String',str1); 604 set(handles.i2,'String',str2); 605 set(handles.j1,'String',str_a); 606 set(handles.j2,'String',str_b); 580 [~,~,~,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); 581 set(handles.i1,'String',num2str(i1)); 582 set(handles.i2,'String',num2str(i2)); 583 set(handles.j1,'String',num2str(j1)); 584 set(handles.j2,'String',num2str(j2)); 585 586 % refresh the current field view 607 587 run0_Callback(hObject, eventdata, handles) 608 588 … … 610 590 % --- Update information about a new field series (indices to scan, timing, 611 591 % calibration from an xml file, then refresh current plots 612 function update_rootinfo(h Object,eventdata,handles)592 function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject) 613 593 %------------------------------------------------------------------------ 614 594 set(handles.RootPath,'BackgroundColor',[1 1 0]) … … 618 598 UvData.NewSeries=1; %flag for run0: begin a new series 619 599 UvData.TestInputFile=1; 600 UvData.FileType=FileType; 620 601 set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window 621 602 set(handles.FixVelType,'Value',0); %desactivate fixed veltype 622 603 [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles); 604 623 605 if ~exist(FileName,'file') 624 606 msgbox_uvmat('ERROR',['input file ' FileName ' not found']); … … 626 608 end 627 609 nbfield=[];%default 628 nb urst=[];%default610 nbfield_j=[];%default 629 611 630 612 % read timing and total frame number from the current file (movie files) !! may be overrid by xml file … … 640 622 imainfo=aviinfo([FileBase FileIndices FileExt]); 641 623 nbfield=imainfo.NumFrames; 642 nb urst=1;624 nbfield_j=1; 643 625 set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FramesPerSecond) 'ms']);%display the elementary time interval in millisec 644 626 XmlData.Time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)'; … … 657 639 if length(imainfo) >1 %case of image with multiple frames 658 640 nbfield=length(imainfo); 659 nb urst=1;641 nbfield_j=1; 660 642 end 661 643 end … … 748 730 end 749 731 750 % store last index in handles.lat_i and .last_j 732 %% store last index in handles.lat_i and .last_j 733 nbfield=max(i2_series); 734 if isempty(nbfield) 735 nbfield=max(i1_series); 736 end 737 nbfield_j=max(j2_series); 738 if isempty(nbfield_j) 739 nbfield_j=max(j1_series); 740 end 751 741 if ~isempty(XmlData.Time) 752 742 nbfield=size(XmlData.Time,1); 753 nb urst=size(XmlData.Time,2);743 nbfield_j=size(XmlData.Time,2); 754 744 %transform .Time to a column vector if it is a line vector the nomenclature uses a single index 755 if isequal(nbfield,1) && ~isequal(nb urst,1)% .Time is a line vector745 if isequal(nbfield,1) && ~isequal(nbfield_j,1)% .Time is a line vector 756 746 NomType=get(handles.NomType,'String'); 757 747 % NomType=get(handles.FileIndex,'UserData'); 758 748 if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%')) 759 749 XmlData.Time=(XmlData.Time)'; 760 nbfield=nb urst;761 nb urst=1;750 nbfield=nbfield_j; 751 nbfield_j=1; 762 752 end 763 753 end … … 771 761 set(handles.last_i,'String',last_i_cell) 772 762 last_j_cell=get(handles.last_j,'String'); 773 if isempty(nb urst)763 if isempty(nbfield_j) 774 764 last_j_cell{1}=''; 775 765 else 776 last_j_cell{1}=num2str(nb urst);766 last_j_cell{1}=num2str(nbfield_j); 777 767 end 778 768 set(handles.last_j,'String',last_j_cell); … … 812 802 set(handles.nb_slice,'String',num2str(NbSlice)) 813 803 end 814 slices_Callback( hObject, eventdata, handles)804 slices_Callback([],[], handles) 815 805 end 816 806 end … … 824 814 UvData.XmlData=XmlData; 825 815 UvData.NewSeries=1; 826 816 UvData.MovieObject=MovieObject; 827 817 828 818 %display warning message … … 862 852 set(handles.RootPath,'BackgroundColor',[1 1 1]) 863 853 drawnow 864 set_scan_options(h Object, eventdata, handles)854 set_scan_options(handles) 865 855 866 856 %% update list of recent files in the menubar … … 886 876 %--- Set index navigation options for new series input and refresh plot 887 877 %------------------------------------------------------------------------ 888 function set_scan_options(h Object, eventdata, handles)878 function set_scan_options(handles) 889 879 890 880 % set the corresponding index navigation options … … 918 908 if isequal(scan_option,'i') 919 909 set(handles.scan_i,'Value',1) 920 scan_i_Callback( hObject, eventdata, handles);910 scan_i_Callback([],[], handles); 921 911 else 922 912 set(handles.scan_j,'Value',1) 923 scan_j_Callback( hObject, eventdata, handles);913 scan_j_Callback([],[], handles); 924 914 end 925 915 set(handles.scan_j,'Visible',state_j) … … 936 926 937 927 %% view the field 938 run0_Callback( hObject, eventdata, handles); %view field928 run0_Callback([],[], handles); %view field 939 929 mask_test=get(handles.CheckMask,'value'); 940 930 if mask_test … … 943 933 delete(MaskData.maskhandle) %delete old mask 944 934 end 945 CheckMask_Callback( hObject, eventdata,handles)935 CheckMask_Callback([],[],handles) 946 936 end 947 937 … … 1051 1041 1052 1042 %[path,name,ext]=fileparts(fileinput_1); 1053 [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1); 1054 nbfield_1=1; %default 1055 ext_test=FileExt_1;%default 1056 form=imformats(FileExt_1(2:end)); 1057 if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab 1058 imainfo=imfinfo(fileinput_1); 1059 nbfield_1=length(imainfo); 1060 ext_test='.image'; 1061 elseif isequal(lower(FileExt_1),'.avi') 1062 info=aviinfo(fileinput_1); 1063 nbfield_1=info.NumFrames; 1064 ext_test='.image'; 1065 end 1066 1067 %open directly fig or text files 1068 switch ext_test 1069 case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file 1043 [RootPath_1,SubDir_1,RootFile_1,i1,i2,j1,j2,FileExt_1]=fileparts_uvmat(fileinput_1); 1044 [i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput_1); 1045 % [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1); 1046 switch FileType 1047 case '' 1048 msgbox_uvmat('ERROR','invalid input file type') 1049 case 'txt' 1070 1050 edit(fileinput) 1071 return 1072 case '.fig' %display matlab figure 1051 case 'figure' %display matlab figure 1073 1052 hfig=open(fileinput); 1074 1053 set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio 1075 1054 set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function 1076 1055 set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function 1077 return 1078 case {'.xml','.xls'} % edit xml or Excel files 1079 heditxml=editxml(fileinput); 1080 return 1081 case {'.image','.nc','.cdf'} 1082 % set(handles.FileIndex,'UserData',NomType_1); 1056 case {'xml','xls'} % edit xml or Excel files 1057 editxml(fileinput); 1058 % case {'.avi','.image','.vol','.nc','.cdf'} 1083 1059 otherwise 1084 msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR') 1085 return 1086 end 1060 set(handles.RootPath,'String',RootPath); 1061 if isequal(SubDir,'') 1062 rootname=fullfile(RootPath,RootFile); 1063 else 1064 rootname=fullfile(RootPath,SubDir,RootFile); 1065 SubDir=['/' SubDir]; %display the separator 1066 end 1067 set(handles.SubDir,'String',SubDir); 1068 set(handles.RootFile,'String',['/' RootFile]); %display the separator 1069 indices=fileinput(length(rootname)+1:end); 1070 indices(end-length(FileExt)+1:end)=[]; %remove extension 1071 set(handles.FileIndex,'String',indices); 1072 % set(handles.FileIndex,'UserData',NomType); 1073 set(handles.NomType,'String',NomType); 1074 set(handles.FileExt,'String',FileExt); 1075 % fill file index counters 1076 set(handles.i1,'String',num2str(i1)); 1077 set(handles.i2,'String',num2str(i2)); 1078 set(handles.j1,'String',num2str(j1)); 1079 set(handles.j2,'String',num2str(j2)); 1080 1081 % synchronise indices of the second input file if it exists 1082 if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers 1083 [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles); 1084 NomType_1=get(handles.NomType_1,'String'); 1085 % NomType_1=get(handles.FileIndex_1,'UserData'); 1086 FileName_1=name_generator(FileBase_1,i1,i2,FileExt_1,NomType_1,1,j1,j2,SubDir_1); 1087 if exist(FileName_1,'file') 1088 FileIndex_1=name_generator('',i1,i2,'',NomType_1,1,j1,j2,''); 1089 set(handles.FileIndex_1,'String',FileIndex_1) 1090 else 1091 set(handles.SubField,'Value',0) 1092 SubField_Callback(hObject, eventdata, handles) 1093 end 1094 end 1095 end 1096 % 1097 % 1098 % nbfield_1=1; %default 1099 % ext_test=FileExt_1;%default 1100 % form=imformats(FileExt_1(2:end)); 1101 % if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab 1102 % imainfo=imfinfo(fileinput_1); 1103 % nbfield_1=length(imainfo); 1104 % ext_test='.image'; 1105 % elseif isequal(lower(FileExt_1),'.avi') 1106 % info=aviinfo(fileinput_1); 1107 % nbfield_1=info.NumFrames; 1108 % ext_test='.image'; 1109 % end 1110 % 1111 % %open directly fig or text files 1112 % switch ext_test 1113 % case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file 1114 % edit(fileinput) 1115 % return 1116 % case '.fig' %display matlab figure 1117 % hfig=open(fileinput); 1118 % set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio 1119 % set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function 1120 % set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function 1121 % return 1122 % case {'.xml','.xls'} % edit xml or Excel files 1123 % heditxml=editxml(fileinput); 1124 % return 1125 % case {'.image','.nc','.cdf'} 1126 % % set(handles.FileIndex,'UserData',NomType_1); 1127 % otherwise 1128 % msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR') 1129 % return 1130 % end 1087 1131 1088 1132 % test for image series in a single file and synchronise file indices of the two series … … 1186 1230 set(handles.FixVelType,'Value',0); %desactivate fixed veltype 1187 1231 nbfield_1=[];%default 1188 nb urst_1=[];%default1232 nbfield_j_1=[];%default 1189 1233 XmlData.Time=[]; 1190 1234 XmlData.GeometryCalib=[];%default … … 1199 1243 imainfo=aviinfo([FileBase FileIndices FileExt]); 1200 1244 nbfield_1=imainfo.NumFrames; 1201 nb urst_1=1;1245 nbfield_j_1=1; 1202 1246 set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec 1203 1247 time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)'; … … 1214 1258 if length(imainfo) >1 %case of image with multiple frames 1215 1259 nbfield_1=length(imainfo); 1216 nb urst_1=1;1260 nbfield_j_1=1; 1217 1261 end 1218 1262 end … … 1281 1325 if ~isempty(XmlData.Time) 1282 1326 nbfield_1=size(XmlData.Time,1); 1283 nb urst_1=size(XmlData.Time,2);1327 nbfield_j_1=size(XmlData.Time,2); 1284 1328 end 1285 1329 last_i_cell=get(handles.last_i,'String'); … … 1291 1335 set(handles.last_i,'String',last_i_cell) 1292 1336 last_j_cell=get(handles.last_j,'String'); 1293 if isempty(nb urst_1)1337 if isempty(nbfield_j_1) 1294 1338 last_j_cell{2}=''; 1295 1339 else 1296 last_j_cell{2}=num2str(nb urst_1);1340 last_j_cell{2}=num2str(nbfield_j_1); 1297 1341 end 1298 1342 set(handles.last_j,'String',last_j_cell); … … 1332 1376 drawnow 1333 1377 1334 set_scan_options(h Object, eventdata, handles)1378 set_scan_options(handles) 1335 1379 1336 1380 %------------------------------------------------------------------------ … … 1386 1430 set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7]) 1387 1431 if get(handles.SubField,'Value')==1 1388 NomType_1=get(handles. FileIndex_1,'String');1389 FileExt_1=get(handles.FileExt_1,'String');1390 [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);1432 NomType_1=get(handles.NomType_1,'String'); 1433 % FileExt_1=get(handles.FileExt_1,'String'); 1434 % [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]); 1391 1435 indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,''); 1392 1436 set(handles.FileIndex_1,'String',indices) … … 1478 1522 for ilist=1:length(maskfiles) 1479 1523 maskname=maskfiles(ilist).name;% take the first mask file in the list 1480 [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname); 1481 [Path2,Name,ext]=fileparts(maskname); 1524 [~,~,~,~,~,~,~,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname); 1525 % [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname); 1526 [~,Name]=fileparts(maskname); 1482 1527 Namedouble=double(Name); 1483 1528 val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters … … 1528 1573 errormsg='no file browsed'; 1529 1574 end 1530 [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname); 1575 [RootDir,~,RootFile,~,~,~,~,~,Mask.NomType]=fileparts_uvmat(maskname); 1576 % [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname); 1531 1577 Mask.Base=fullfile(RootDir,RootFile); 1532 1578 Mask.NbSlice=1; … … 1796 1842 if sub_value % a second input file has been entered 1797 1843 [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles); 1798 [pp,ff,i1_1_str,i2_1_str,j1_1_str,j2_1_str]=name2display(FileIndices_1); 1799 i1_1=stra2num(i1_1_str);%current set of indices for the second field (may be set different than the main indices) 1800 i2_1=stra2num(i2_1_str); 1801 j1_1=stra2num(j1_1_str); 1802 j2_1=stra2num(j2_1_str); 1844 [~,~,~,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndices_1); 1845 % [pp,ff,i1_1_str,i2_1_str,j1_1_str,j2_1_str]=name2display(FileIndices_1); 1846 % i1_1=stra2num(i1_1_str);%current set of indices for the second field (may be set different than the main indices) 1847 % i2_1=stra2num(i2_1_str); 1848 % j1_1=stra2num(j1_1_str); 1849 % j2_1=stra2num(j2_1_str); 1803 1850 NomType_1=get(handles.NomType_1,'String'); 1804 1851 % NomType_1=get(handles.FileIndex_1,'UserData'); … … 2090 2137 VelType=[];%default 2091 2138 Ext=get(handles.FileExt,'String'); 2092 if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf') 2093 FileType='netcdf'; 2094 list_fields=get(handles.Fields,'String');% list menu fields 2095 index_fields=get(handles.Fields,'Value');% selected string index 2096 FieldName= list_fields{index_fields}; % selected field 2097 if ~strcmp(FieldName,'get_field...') 2098 TestVelType=get(handles.FixVelType,'Value'); 2099 if TestVelType 2100 VelType=setfield(handles);% read the velocity type. 2101 end 2102 end 2103 if strcmp(FieldName,'velocity') 2104 list_code=get(handles.ListColorCode,'String');% list menu fields 2105 index_code=get(handles.ListColorCode,'Value');% selected string index 2106 if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') 2107 list_code=get(handles.ListColorScalar,'String');% list menu fields 2108 index_code=get(handles.ListColorScalar,'Value');% selected string index 2109 ParamIn.ColorVar= list_code{index_code}; % selected field 2139 FileType=UvData.FileType; 2140 switch FileType 2141 % if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf') 2142 case {'civx','civdata','netcdf'}; 2143 list_fields=get(handles.Fields,'String');% list menu fields 2144 index_fields=get(handles.Fields,'Value');% selected string index 2145 FieldName= list_fields{index_fields}; % selected field 2146 if ~strcmp(FieldName,'get_field...') 2147 TestVelType=get(handles.FixVelType,'Value'); 2148 if TestVelType 2149 VelType=setfield(handles);% read the velocity type. 2150 end 2110 2151 end 2111 end 2112 elseif isfield(UvData,'MovieObject') 2113 ObjectName=UvData.MovieObject; 2114 FileType='movie'; 2115 elseif isequal(lower(Ext),'.avi') 2116 FileType='avi'; 2117 elseif isequal(lower(Ext),'.vol') 2118 FileType='vol'; 2119 if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') 2120 ParamIn.Npy=UvData.XmlData.Npy; 2121 ParamIn.Npx=UvData.XmlData.Npx; 2122 else 2123 errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; 2124 return 2125 end 2126 else 2127 form=imformats(Ext(2:end)); 2128 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 2129 if isequal(NomType,'*'); 2130 FileType='multimage'; 2131 else 2132 FileType='image'; 2133 end 2134 end 2152 if strcmp(FieldName,'velocity') 2153 list_code=get(handles.ListColorCode,'String');% list menu fields 2154 index_code=get(handles.ListColorCode,'Value');% selected string index 2155 if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') 2156 list_code=get(handles.ListColorScalar,'String');% list menu fields 2157 index_code=get(handles.ListColorScalar,'Value');% selected string index 2158 ParamIn.ColorVar= list_code{index_code}; % selected field 2159 end 2160 end 2161 case 'video' 2162 ObjectName=UvData.MovieObject; 2163 2164 case 'vol' %TODO: update 2165 if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') 2166 ParamIn.Npy=UvData.XmlData.Npy; 2167 ParamIn.Npx=UvData.XmlData.Npx; 2168 else 2169 errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; 2170 return 2171 end 2135 2172 end 2136 2173 ParamIn.FieldName=FieldName; … … 2578 2615 %PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac 2579 2616 PlotParam{1}=read_GUI(handles.uvmat); 2617 PlotParam{1}.Coordinates 2580 2618 if ~isfield(PlotParam{1},'Vectors') 2581 2619 PlotParam{1}.Vectors.MaxVec=1; … … 2784 2822 end 2785 2823 if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time') 2786 [ P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);2787 num_i2=str2double(str2);2788 if is nan(num_i2)2824 [~,~,~,num_i1,num_i2,num_j1,num_j2]=fileparts_uvmat(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]); 2825 % [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]); 2826 if isempty(num_i2) 2789 2827 num_i2=num_i1; 2790 2828 end 2791 num_j1=str2double(str_a); 2792 if isnan(num_j1) 2829 if isempty(num_j1) 2793 2830 num_j1=1; 2794 2831 end 2795 num_j2=str2double(str_b); 2796 if isnan(num_j2) 2832 if isempty(num_j2) 2797 2833 num_j2=num_j1; 2798 2834 end 2799 num_i1=str2double(str1);2800 2835 siz=size(UvData.XmlData_1.Time); 2801 2836 if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2) … … 3146 3181 %read the rootfile input display 3147 3182 [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles); 3148 [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]); 3183 [~,~,~,i1,i2,j1,j2,~,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); 3184 % [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]); 3149 3185 NomTypeNew=NomType;%default 3150 3186 if isequal(field,'image') … … 3156 3192 NomTypeNew='_1'; 3157 3193 end 3158 imagename=name_generator(FileBase, str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');3194 imagename=name_generator(FileBase,i1,j1,'.png',NomTypeNew,1,i2,j2,''); 3159 3195 if ~exist(imagename,'file') 3160 3196 [FileName,PathName] = uigetfile( ... … … 3186 3222 end 3187 3223 end 3188 indices=name_generator('', str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');3224 indices=name_generator('',i1,j1,'',NomTypeNew,1,i2,j2,''); 3189 3225 set(handles.FileIndex,'String',indices) 3190 3226 set(handles.NomType,'String',NomTypeNew) … … 3226 3262 %read the rootfile input display 3227 3263 [FileName,RootPath,FileBase,FileIndices,FileExt_1]=read_file_boxes_1(handles); 3228 [P,F,str1,str2,str_a,str_b,E,NomType_1]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]); 3264 [~,~,~,i1,i2,j1,j2,~,NomType_1]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt_1]); 3265 % [P,F,str1,str2,str_a,str_b,E,NomType_1]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]); 3229 3266 if isempty(NomType_1)|| strcmp(NomType_1,'') 3230 3267 [FileName,RootPath,FileBase,FileIndices,FileExt_1]=read_file_boxes(handles); 3231 [P,F,str1,str2,str_a,str_b,E,NomType_1]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]); 3268 [~,~,~,i1,i2,j1,j2,~,NomType_1]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt_1]); 3269 % [P,F,str1,str2,str_a,str_b,E,NomType_1]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]); 3232 3270 end 3233 3271 NomTypeNew=NomType_1;%default … … 3280 3318 end 3281 3319 end 3282 imagename=name_generator(FileBase, str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');3320 imagename=name_generator(FileBase,i1,j1,'.png',NomTypeNew,1,i2,j2,''); 3283 3321 if ~exist(imagename,'file') 3284 3322 [FileName,PathName] = uigetfile( ...
Note: See TracChangeset
for help on using the changeset viewer.