- Timestamp:
- May 21, 2025, 6:14:05 PM (11 days ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_file_series.m
r1180 r1181 192 192 % update the detected index series 193 193 if ~isnan(ref_i)&&~isnan(ref_j) 194 if ref_i*ref_j>100000 195 disp('warning: inapropriate file name indexing: too large indices forscanning')194 if ref_i*ref_j>1000000 195 disp('warning: inapropriate file name indexing: too large values for index scanning') 196 196 ref_i_list(ifile)=i1_input; 197 197 if isempty(j1_input) … … 244 244 NomType=regexprep(NomType,['^' NomTypePref],''); 245 245 %% update the file type if the input file does not exist (pb of 0001) 246 if isempty(FileInfo.File Type)246 if isempty(FileInfo.FileName) 247 247 [FileInfo,MovieObject]=get_file_info(fullfile(FilePath,ListFiles{ifile_min})); 248 248 end -
trunk/src/get_file_info.m
r1180 r1181 1 %'ge t_file_info': determine info about a file (image, multimage, civdata,...) .1 %'gext_file_info': determine info about a file (image, multimage, civdata,...) . 2 2 %------------------------------------------------------------------------ 3 3 % [FileInfo,VideoObject]=get_file_info(fileinput) … … 5 5 % OUTPUT: 6 6 % FileInfo: structure containing info on the file (case of images or video), in particular 7 % .FileType: type of file, needed as input of read_field.m 8 % ='figure': Matlab figure 7 % .FileName: confirms the file name, ='' if the file is not detected 8 % .FileType: type of file, needed as input of read_field.m 9 % ='': unknown format 10 % ='bin': binary file without specific organisation 11 % ='dat': text file for data 12 % ='figure': Matlab figure file, ext .fig 9 13 % ='mat': Matlab data file 14 % ='netcdf': generic netcdf file 10 15 % ='xml': xml file 11 16 % ='xls': Excel file 12 % ='dat': text file for data, 17 % ='civdata': netcdf files provided by civ_series 18 % ='pivdata_fluidimage': PIV data from software 'fluidimage' 19 % different image and movie formats: 13 20 % ='image': image format recognised by Matlab 14 21 % ='multimage': image format recognised by Matlab with multiple frames … … 16 23 % ='mmreader': video from old versions of Matlab (<2009) 17 24 % ='rdvision': images in binary format from company rdvision 18 % ='image_DaVis': images from softwar DaVis (company LaVision) 25 % ='image_DaVis': images from softwar DaVis (company LaVision), requires specific conditions of Matlab version and computer system 19 26 % ='cine_phantom': images from fast camera Phantom 20 % ='bin': binary file without specific organisation 21 % ='netcdf': netcdf file 22 % ='civdata': netcdf files provided by civ_series 23 % ='civx': netcdf files provided by the obsolete program civx (in fortran) 24 % ='pivdata_fluidimage': PIV data from software 'fluidimage' 27 % ='telopsIR': Infrared images from company Telops 25 28 % .FieldType='image' for all kinds of images and movies, =FileType else 26 % .FileIndexing='on'/'off', for data files (when series of indexed files are expected)29 % .FileIndexing='on'/'off', = 'on' for series of indexed files or frames to scan 27 30 % .Height: image height in pixels 28 31 % .Width: image width in pixels … … 30 33 % .ColorType: 'greyscale' or 'color' 31 34 % .NumberOfFrames: defined for images or movies 32 % .FrameRate: nbre of frames per second, =[] for images35 % .FrameRate: nbre of frames per second, =[] if not documented 33 36 % VideoObject: in case of video 34 37 % … … 57 60 58 61 VideoObject=[]; 59 FileInfo.FileType='';% input file does not exist 62 FileInfo.FileName='';% file doe not exist, defautlt 63 FileInfo.FileType='';% input file type not detected 60 64 FileInfo.FieldType=''; %default output 61 65 if ~ischar(fileinput) 62 66 return 63 67 end 64 % check the existence (not possible for OpenDAP data) 68 69 %% check the existence (not possible for OpenDAP data) 65 70 if ~isempty(regexp(fileinput,'^http://','once'))|| exist(fileinput,'file') 66 71 FileInfo.FileName=fileinput; 67 FileInfo.FileType='txt'; %default72 % FileInfo.FileType='txt'; %default 68 73 else 69 74 return %input file does not exist. … … 71 76 [~,~,FileExt]=fileparts(fileinput);%get the file extension FileExt 72 77 78 %% look according to file extension 73 79 switch FileExt 74 case '.fig' 80 case '.fig'% Matlab figure assumed 75 81 FileInfo.FileType='figure'; 76 case '.mat' 82 case '.mat'% Matlab data format 77 83 FileInfo.FileType='mat'; 84 case {'.txt','.log','.stdout','.stderr','.sh'} 85 FileInfo.FileType='txt'; 78 86 case {'.xml','.xls','.dat','.bin'} 79 87 FileInfo.FileType=regexprep(FileExt,'^.','');% eliminate the dot of the extension; 80 case {'.seq','.sqb'} 88 case {'.seq','.sqb'}% data from rdvision 81 89 [~,FileInfo]=read_rdvision(fileinput,[]); 82 case '.im7' 90 case '.im7'% data from LaVision (DaVis), requires specific conditions of Matlab version and computer system 83 91 try 84 92 Input=readimx(fileinput); … … 98 106 end 99 107 catch ME 100 msgbox_uvmat('ERROR',{ME.message;'reading image from DaVis is possible only with Matlab version 2013 or earlier'})108 msgbox_uvmat('ERROR',{ME.message;'reading image from DaVis is not possible with this Matlab version and system'}) 101 109 return 102 110 end 103 case '.h5' 111 case '.h5'% format hdf5, used for specific case of PIV data from 'Fluidimage' 104 112 hinfo=h5info(fileinput); 105 113 FileInfo.CivStage=0; … … 127 135 FileInfo.BitDepth=BitmapInfoHeader.biBitCount; 128 136 FileInfo.TimeName='video'; 129 case '.hcc' 137 case '.hcc' % infrared camera Telops 130 138 installToolboxIRCAM 131 139 [~,InfoArray]=readIRCam(fileinput,'HeadersOnly',true); … … 273 281 end 274 282 275 if ismember (FileInfo.FileType,{'mat','image','image_DaVis','multimage','mmreader','cine_phantom','video','netcdf','civdata'})276 FileInfo.FileIndexing='on'; % allow to detect file index for scanning series277 else278 FileInfo.FileIndexing='off';279 end280 283 FileInfo.FieldType=FileInfo.FileType;%default 281 284 switch FileInfo.FileType 282 285 case {'image','multimage','video','mmreader','rdvision','image_DaVis','cine_phantom','telopsIR'} 283 286 FileInfo.FieldType='image'; 284 case {'civ x','civdata','pivdata_fluidimage'}287 case {'civdata','pivdata_fluidimage'} 285 288 FileInfo.FieldType='civdata'; 286 289 end 287 290 291 if strcmp(FileInfo.FieldType,'image') || ismember (FileInfo.FileType,{'mat','netcdf','civdata'}) 292 FileInfo.FileIndexing='on'; % allow to detect file index for scanning series 293 else 294 FileInfo.FileIndexing='off'; 295 end 296 297 -
trunk/src/nc2struct.m
r1162 r1181 27 27 % additional arguments: 28 28 % -no additional arguments: all the variables of the NetCDF file are read. 29 % - empty argument []: the field structure with the names of variables is read, without their values29 % - empty argument []: the output field structure is limited to the names of variables, without their values 30 30 % -a cell array, ListVarName, made of char strings {'VarName1', 'VarName2',...} ) 31 31 % if ListVarName=[] or {}, no variable value is read (only global attributes and list of variables and dimensions) … … 36 36 % - the string 'TimeVarName', a string (the name of the variable considered as time), an integer or vector with integer values 37 37 % representing time indices to select for each variable, the cell of other input variable names. 38 % - the string 'TimeDimName', a string (the name of the dimension considered as time), an integer or vector with integer values 39 % representing time indices to select for each variable, the cell of other input variable names. 38 40 39 41 40 %======================================================================= … … 291 290 end 292 291 end 292 % tstart = tic; 293 % disp(VarName) 293 294 Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1,ind_vec,ind_size); %read the variable data 295 % telapsed = toc(tstart) 294 296 Data.(VarName)=squeeze(Data.(VarName));%remove singeton dimension 297 295 298 else 296 299 Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1); %read the whole variable data 297 300 end 298 if xtype(var_index(ivar))==5 301 if xtype(var_index(ivar))==5% indicate single precision variable 299 302 Data.(VarName)=double(Data.(VarName)); %transform to double for single pecision 300 303 end -
trunk/src/script_readnc.m
r1131 r1181 1 DataFolder='.fsnet/project/coriolis/2024/24PLUME/VectorsEyemotion'; 2 fileinput={'Tore_a8b40_T22s_N047_A1cm.png.civ.mproj.tfilter_1'} 1 DataFolder='.fsnet/project/coriolis/2024/24PLUME/1_DATA/EXP27/JAI'; 2 fileinput_1='/im.sback.civ2.mproj.tfilter/img_1-19991.nc'; 3 fileinput_2='/im.sback.civ2.mproj.tfilter/img_1-19991.nc'; 3 4 fileinput=uigetfile_uvmat('pick an input file',DataFolder); 4 5 Data=nc2struct(fileinput); -
trunk/src/series/check_data_files.m
r1164 r1181 176 176 end 177 177 else 178 datnum=datnum(datnum );%keep the non zero values corresponding to existing files179 filefound=filefound(datnum );178 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 179 filefound=filefound(datnum~=0); 180 180 [first,ind]=min(datnum); 181 181 [last,indlast]=max(datnum); -
trunk/src/series/civ_input.m
r1180 r1181 91 91 if isfield(SeriesData,'FileInfo') 92 92 FileType=SeriesData.FileInfo{1}.FileType;% info on the first input file series 93 FieldType=SeriesData.FileInfo{1}.FieldType;% info on the first input file series93 %FieldType=SeriesData.FileInfo{1}.FieldType;% info on the first input file series 94 94 else 95 95 set(hhseries.REFRESH,'BackgroundColor',[1 0 1])% indicate that the file input in series needs to be refreshed … … 207 207 set(handles.TimeSource,'String',Param.IndexRange.TimeSource); 208 208 else 209 msgbox_uvmat('WARNING','timing not defined (check xml file), default values used') 209 210 set(handles.TimeSource,'String',''); %xml file not used for timing 210 211 TimeUnit='frame'; … … 377 378 %% list the possible index pairs, depending on the option set in ListPairMode 378 379 ListPairMode_Callback([], [], handles) 379 380 if isfield(Param,'ActionInput')&& isfield(Param.ActionInput,'PairIndices') 381 if isfield(Param.ActionInput.PairIndices,'ListPairCiv1') 382 PairChoiceCiv1=find(strcmp(Param.ActionInput.PairIndices.ListPairCiv1,get(handles.ListPairCiv1,'String'))); 383 if ~isempty(PairChoiceCiv1) 384 set(handles.ListPairCiv1,'Value',PairChoiceCiv1) 385 end 386 end 387 if isfield(Param.ActionInput.PairIndices,'ListPairCiv2') 388 PairChoiceCiv2=find(strcmp(Param.ActionInput.PairIndices.ListPairCiv2,get(handles.ListPairCiv2,'String'))); 389 if ~isempty(PairChoiceCiv2) 390 set(handles.ListPairCiv2,'Value',PairChoiceCiv2) 391 end 392 end 393 end 394 380 395 %% set the GUI to modal: wait for OK to close 381 396 set(handles.civ_input,'WindowStyle','modal')% Make the GUI modal … … 810 825 %reproduce by default the chosen pair in the checkciv2 menu 811 826 set(handles.ListPairCiv2,'Value',get(handles.ListPairCiv1,'Value'))%civ2 selection the same as civ1 by default 812 ListPairCiv2_Callback(hObject, eventdata, handles)813 814 % ------------------------------------------------------------------------815 % --- Executes on selection change in ListPairCiv2.816 function ListPairCiv2_Callback(hObject, eventdata, handles)817 % ------------------------------------------------------------------------827 %ListPairCiv2_Callback(hObject, eventdata, handles) 828 829 % %------------------------------------------------------------------------ 830 % % --- Executes on selection change in ListPairCiv2. 831 % function ListPairCiv2_Callback(hObject, eventdata, handles) 832 % %------------------------------------------------------------------------ 818 833 819 834 %------------------------------------------------------------------------ … … 1527 1542 set(obj,'Visible','off') 1528 1543 end 1544 set(handles.ConfigSource,'String','NEW') 1545 set(handles.OK,'BackgroundColor',[1 0 1]) 1546 1547 1548 %------------------------------------------------------------------------ 1549 % --- Executes on button press in CheckRescale. 1550 function CheckRescale_Callback(hObject, eventdata, handles) 1551 %------------------------------------------------------------------------ 1552 huipanel=get(hObject,'parent'); 1553 obj(1)=findobj(huipanel,'Tag','num_Maxtanh'); 1554 obj(2)=findobj(huipanel,'Tag','title_Maxtanh'); 1555 if get(hObject,'Value')% if chck box has been selected 1556 set(obj,'Visible','on') 1557 else 1558 set(obj,'Visible','off') 1559 end 1560 set(handles.ConfigSource,'String','NEW') 1561 set(handles.OK,'BackgroundColor',[1 0 1]) 1562 1563 %------------------------------------------------------------------------ 1564 % --- synchronise the image threshold for civ1 and civ2 1565 function num_MaxIma_Callback(hObject, eventdata, handles) 1566 MaxIma_string=get(hObject,'String'); 1567 set(handles.num_MaxIma,'String',MaxIma_string); 1568 set(handles.num_MaxIma,'Visible','on'); 1569 set(handles.title_Threshold,'Visible','on'); 1570 set(handles.CheckThreshold,'Value',true); 1571 1572 set(handles.ConfigSource,'String','NEW') 1573 set(handles.OK,'BackgroundColor',[1 0 1]) 1574 1575 %------------------------------------------------------------------------ 1576 % --- synchronise the image rescaling threshold for civ1 and civ2 1577 function num_Maxtanh_Callback(hObject, eventdata, handles) 1578 Maxtanh_string=get(hObject,'String'); 1579 set(handles.num_Maxtanh,'String',Maxtanh_string); 1580 set(handles.num_Maxtanh,'Visible','on'); 1581 set(handles.title_Maxtanh,'Visible','on'); 1582 set(handles.CheckRescale,'Value',true); 1583 1529 1584 set(handles.ConfigSource,'String','NEW') 1530 1585 set(handles.OK,'BackgroundColor',[1 0 1]) … … 1952 2007 1953 2008 1954 function edit108_Callback(hObject, eventdata, handles)1955 % hObject handle to edit108 (see GCBO)1956 % eventdata reserved - to be defined in a future version of MATLAB1957 % handles structure with handles and user data (see GUIDATA)1958 1959 % Hints: get(hObject,'String') returns contents of edit108 as text1960 % str2double(get(hObject,'String')) returns contents of edit108 as a double1961 1962 1963 2009 % --- Executes on button press in CheckBackground. 1964 2010 function CheckBackground_Callback(hObject, eventdata, handles) -
trunk/src/series/civ_series.m
r1180 r1181 69 69 Data.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) 70 70 Data.FieldName='on';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) 71 Data.FieldTransform = 'o n';%can use a transform function71 Data.FieldTransform = 'off';%can use a transform function 72 72 Data.ProjObject='off';%can use projection object(option 'off'/'on', 73 73 Data.Mask='off';%can use mask option (option 'off'/'on', 'off' by default) … … 258 258 CheckRelabel=isfield(Param,'FileSeries' );%=true for index relabeling (PCO) 259 259 260 % % introduce input image transform261 transform_fct=[];%default, no transform262 if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)263 currentdir=pwd;264 cd(Param.FieldTransform.TransformPath)265 transform_fct=str2func(Param.FieldTransform.TransformName);266 cd (currentdir)267 end260 % %% introduce input image transform 261 % transform_fct=[];%default, no transform 262 % if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName) 263 % currentdir=pwd; 264 % cd(Param.FieldTransform.TransformPath) 265 % transform_fct=str2func(Param.FieldTransform.TransformName); 266 % cd (currentdir) 267 % end 268 268 269 269 %%%%% MAIN LOOP %%%%%% … … 445 445 end 446 446 447 448 %% user defined image transform449 if ~isempty(transform_fct)450 par_civ1 =transform_fct(par_civ1,Param);447 % case of image luminosity rescaling 448 if par_civ1.CheckRescale &&~isempty(par_civ1.Maxtanh) 449 par_civ1.ImageA =par_civ1.Maxtanh*tanh(double(par_civ1.ImageA)/par_civ1.Maxtanh); 450 par_civ1.ImageB=par_civ1.Maxtanh*tanh(double(par_civ1.ImageB)/par_civ1.Maxtanh); 451 451 end 452 452 … … 672 672 end 673 673 674 %% user defined image transform 675 if ~isempty(transform_fct) 676 par_civ2 =transform_fct(par_civ2,Param); 677 end 678 674 % %% user defined image transform 675 % if ~isempty(transform_fct) 676 % par_civ2 =transform_fct(par_civ2,Param); 677 % end 678 %% case of image luminosity rescaling 679 if par_civ2.CheckRescale &&~isempty(par_civ2.Maxtanh) 680 par_civ2.ImageA =par_civ2.Maxtanh*tanh(double(par_civ2.ImageA)/par_civ2.Maxtanh); 681 par_civ2.ImageB=par_civ2.Maxtanh*tanh(double(par_civ2.ImageB)/par_civ2.Maxtanh); 682 end 679 683 680 684 % get the guess from patch1 or patch2 (case 'CheckCiv3') -
trunk/src/series/filter_time_singlefile.m
r1158 r1181 1 %'filter_time_single': apply a a sliding filter in a time series, put the time series in a single netcdf file (problematic...) 2 %------------------------------------------------------------------------ 1 %'filter_time_single': apply a a sliding filter to a time series and concatene the result in a single netcdf file 3 2 % function ParamOut=filter_time(Param) 4 3 % … … 149 148 150 149 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% 151 disp('loop for filtering started') 152 tstart = tic; 153 telapsed(zeros,1,NbField) 150 disp('loop for filtering started') 151 ncid=[]; 154 152 for index=1:NbField 155 153 index 156 157 Field= read_field(filecell{1,index},'netcdf',Param.InputFields); 158 154 155 [Field,~,errormsg]= read_field(filecell{1,index},'netcdf',Param.InputFields); 156 if ~isempty(errormsg) 157 disp(errormsg) 158 if ~isempty(ncid) 159 netcdf.close(ncid) 160 end 161 return 162 end 159 163 %%%%%%%%%%% MAIN RUNNING OPERATIONS %%%%%%%%%%%% 160 164 if index==1 %first field, initialisation output data 161 165 DataOut.ListGlobalAttribute= {'Conventions'}; 162 166 DataOut.Conventions='uvmat'; 163 DataOut.ListVarName={'Time','coord_y','coord_x','Ufilter','Vfilter'};164 DataOut.VarDimName={'Time','coord_y','coord_x',{'Time','coord_y','coord_x'},{'Time','coord_y','coord_x'}};165 167 npy=numel(Field.coord_y); 166 168 npx=numel(Field.coord_x); 167 169 ListDimName={'Time','coord_y','coord_x'}; 168 170 DimValue=[NbField npy npx]; 169 VarDimIndex={1,2,3,[1 2 3],[1 2 3]}; 171 ListFields=Param.InputFields.FieldName; 172 DataOut.ListVarName=[{'Time','coord_y','coord_x'} ListFields']; 173 %DataOut.VarDimName={'Time','coord_y','coord_x',{'Time','coord_y','coord_x'},{'Time','coord_y','coord_x'}}; 174 DataOut.VarDimName={'Time','coord_y','coord_x'}; 175 VarDimIndex={1,2,3}; 176 for ifield=1:numel(ListFields) 177 DataOut.VarDimName{ifield+3}={'coord_y','coord_x','Time'}; 178 Field_varid(ifield)=ifield+2; 179 VarDimIndex{ifield+3}=[2 3 1]; 180 end 181 182 % VarDimIndex={1,2,3,[1 2 3],[1 2 3]}; 183 170 184 DataOut.coord_x=Field.coord_x; 171 185 DataOut.coord_y=Field.coord_y; 172 186 DataOut.Time=0; 173 DataOut.Ufilter=0; 174 DataOut.Vfilter=0; 187 for ifield=1:numel(ListFields) 188 DataOut.(ListFields{ifield})=0; 189 end 175 190 [errormsg,ncid]=struct2nc(ncfile_out,DataOut,'keep_open',ListDimName,DimValue,VarDimIndex); 176 191 netcdf.putVar(ncid,0,0,1,0) 177 192 netcdf.putVar(ncid,1,0,npy,Field.coord_y) 178 193 netcdf.putVar(ncid,2,0,npx,Field.coord_x) 179 Uvarid=3;180 Vvarid=4;194 % Uvarid=3; 195 % Vvarid=4; 181 196 TimeBlock=zeros(Param.ActionInput.WindowLength,1); 182 Ublock=zeros(Param.ActionInput.WindowLength,npy,npx); 183 Vblock=zeros(Param.ActionInput.WindowLength,npy,npx); 184 end 197 Fieldblock=zeros(numel(ListFields),Param.ActionInput.WindowLength,npy,npx); 198 %Vblock=zeros(Param.ActionInput.WindowLength,npy,npx); 199 end 200 185 201 TimeBlock=circshift(TimeBlock,[-1 0 ]); 186 Ublock=circshift(Ublock,[-1 0 0]); %shift U by ishift along the first index187 Vblock=circshift(Vblock,[-1 0 0]); %shift U by ishift along the first index188 202 TimeBlock(end)=Field.Time; 189 Ublock(end,:,:)=Field.U;190 Vblock(end,:,:)=Field.V;191 203 sumindex=min(index,Param.ActionInput.WindowLength)-1; 192 204 Timefilter=mean(TimeBlock(end-sumindex:end,:,:));%mid time 193 Ufilter=squeeze(mean(Ublock(end-sumindex:end,:,:),1,'omitnan')); 194 Vfilter=squeeze(mean(Vblock(end-sumindex:end,:,:),1,'omitnan')); 205 Fieldblock=circshift(Fieldblock,[0 -1 0 0]); %shift U by ishift along the first index 206 % Vblock=circshift(Vblock,[-1 0 0]); %shift U by ishift along the first index 207 for ifield=1:numel(ListFields) 208 Fieldblock(ifield,end,:,:)=Field.(ListFields{ifield}); 209 end 210 %Vblock(end,:,:)=Field.V; 211 Fieldfilter=squeeze(mean(Fieldblock(:,end-sumindex:end,:,:),2,'omitnan')); 212 % Ufilter=squeeze(mean(Ublock(end-sumindex:end,:,:),1,'omitnan')); 213 % Vfilter=squeeze(mean(Vblock(end-sumindex:end,:,:),1,'omitnan')); 214 % Uerror=Ufilter-Ublock(end-floor(sumindex/2),:,:); 215 % Verror=Ufilter-Vblock(end-floor(sumindex/2),:,:); 195 216 %updating output the netcdf file 217 tstart = tic; 196 218 netcdf.putVar(ncid,0,(index-1),Timefilter) 197 netcdf.putVar(ncid,Uvarid,[(index-1) 0 0],[1 npy npx],Ufilter) 198 netcdf.putVar(ncid,Vvarid,[(index-1) 0 0],[1 npy npx],Vfilter) 199 200 telapsed(index) = toc(tstart); 219 for ifield=1:numel(ListFields) 220 netcdf.putVar(ncid,Field_varid(ifield),[ 0 0 (index-1)],[npy npx 1],squeeze(Fieldfilter(ifield,:,:))) 221 end 222 % netcdf.putVar(ncid,Uvarid,[ 0 0 (index-1)],[npy npx 1],Ufilter) 223 % netcdf.putVar(ncid,Vvarid,[0 0 (index-1)],[npy npx 1],Vfilter) 224 225 telapsed = toc(tstart)% time for writting the field 201 226 % writing the result file as netcdf file 202 227 % i1=i1_series{1}(index)-ceil(NpTime/2); … … 212 237 figure 213 238 plot(telapsed) 239 ylabel('time lapsed computation') 214 240 'END' -
trunk/src/transform_field/FFT2_detrend.m
r1168 r1181 85 85 spec2 = spec2(Iy,Ix); 86 86 spec2 = spec2(ss,:); 87 DataOut.(VarName) = log10(spec2);% take the log10 of spectrum88 %DataOut.(VarName) = spec2;87 %DataOut.(VarName) = log10(spec2);% take the log10 of spectrum 88 DataOut.(VarName) = spec2; 89 89 % spec_sum=sum(sum(spec2)); 90 90 % kx_mean=sum(sum(spec2.*kx))/spec_sum; -
trunk/src/uvmat.m
r1180 r1181 1946 1946 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 1947 1947 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; 1948 CheckAbort=false; 1949 if strcmp(get(handles.MenuRelabelFrames,'checked'),'off')% if the option is selected 1950 if strcmp(FileExt,'.tif') && ~isempty(regexp(RootFile,'^im', 'once'))% case of PCO images, document <FileSeries> in the xml file 1951 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; 1952 FileInfo=get_file_info(FileName); 1953 XmlFile=fullfile(RootPath,[SubDir '.xml']); 1954 [XmlData,errormsg]=imadoc2struct(XmlFile); 1955 if ~isempty(errormsg) 1956 disp(['a file ' XmlFile ' is needed to document the timing']) 1957 CheckAbort=true; 1958 elseif ~isfield(XmlData,'FileSeries')% fill the FleSeries if does not exist 1959 FileSeries.Convention='PCO'; 1960 FileSeries.FileName{1,1}='im.tif'; 1961 FileSeries.FileName{2,1}='im@0001.tif'; 1962 FileSeries.NbFramePerFile=FileInfo.NumberOfFrames; 1963 [checkupdate,xmlfile,errormsg]=update_imadoc(RootPath,SubDir,'FileSeries',FileSeries); 1964 if isempty(errormsg) 1965 disp([xmlfile 'updated with FileSeries']) 1966 else 1967 disp(errormsg) 1968 CheckAbort=true; 1969 end 1970 end 1971 end 1972 if ~CheckAbort 1973 set(handles.MenuRelabelFrames,'checked','on') 1974 end 1975 else 1948 CheckRelabel=false; 1949 % if the option is selected from previous 'off' state 1950 if strcmp(get(handles.MenuRelabelFrames,'checked'),'off') 1951 if strcmp(FileExt,'.seq') 1952 XmlFile=regexprep(FileName,'.seq$','.xml'); 1953 else 1954 XmlFile=fullfile(RootPath,[SubDir '.xml']); 1955 end 1956 [XmlData,errormsg]=imadoc2struct(XmlFile); 1957 if isempty(XmlData) || isempty(XmlData.Time) 1958 msgbox_uvmat('ERROR',['the timing needs to be documented in the file ' XmlFile]) 1959 return 1960 end 1961 FileInfo=get_file_info(FileName); 1962 switch FileInfo.FileType 1963 case 'multimage' 1964 if strcmp(FileExt,'.tif') && ~isempty(regexp(RootFile,'^im', 'once'))% case of PCO images, document <FileSeries> in the xml file 1965 FileSeries.Convention='PCO'; 1966 FileSeries.FileName{1,1}='im.tif'; 1967 FileSeries.FileName{2,1}='im@0001.tif'; 1968 FileSeries.NbFramePerFile=FileInfo.NumberOfFrames; 1969 [checkupdate,xmlfile,errormsg]=update_imadoc(RootPath,SubDir,'FileSeries',FileSeries); 1970 if isempty(errormsg) 1971 disp([xmlfile 'updated with FileSeries']) 1972 CheckRelabel=true; 1973 else 1974 disp(errormsg) 1975 end 1976 end 1977 case 'rdvision' 1978 check_time_rdvision(FileName,XmlData) 1979 end 1980 if CheckRelabel 1981 set(handles.MenuRelabelFrames,'checked','on') 1982 errormsg=update_series(handles,RootPath,SubDir,FileName,FileInfo,false,1); 1983 end 1984 else % option set to 'off' 1976 1985 set(handles.MenuRelabelFrames,'checked','off')%if the option was chcked, uncheck it 1977 end 1978 if ~CheckAbort 1979 errormsg=display_file_name(handles,FileName,1); 1980 if ~isempty(errormsg) 1981 disp(errormsg) 1982 end 1983 end 1984 1986 errormsg=update_series(handles,RootPath,SubDir,FileName,FileInfo,false,1); 1987 end 1988 if ~isempty(errormsg) 1989 disp(errormsg) 1990 end 1991 1992 % --------------------------------------- 1993 function check_time_rdvision(FileName,XmlData) 1994 s=ini2struct(FileName); 1995 SeqData=s.sequenceSettings; 1996 SeqData.width=str2double(SeqData.width); 1997 SeqData.height=str2double(SeqData.height); 1998 SeqData.bytesperpixel=str2double(SeqData.bytesperpixel); 1999 SeqData.nb_frames=str2double(s.sequenceSettings.numberoffiles); 2000 if isempty(SeqData.binrepertoire)%used when binrepertoire empty, strange feature of rdvision 2001 SeqData.binrepertoire=regexprep(s.sequenceSettings.bindirectory,'\\$','');%tranform Windows notation to Linux 2002 SeqData.binrepertoire=regexprep(SeqData.binrepertoire,'\','/'); 2003 [tild,binrepertoire,DirExt]=fileparts(SeqData.binrepertoire); 2004 SeqData.binrepertoire=[SeqData.binrepertoire DirExt]; 2005 end 2006 2007 %% reading the .sqb file 2008 SqbFile=regexprep(FileName,'.seq$','.sqb'); 2009 m = memmapfile(SqbFile,'Format', { 'uint32' [1 1] 'offset'; ... 2010 'uint32' [1 1] 'garbage1';... 2011 'double' [1 1] 'timestamp';... 2012 'uint32' [1 1] 'file_idx';... 2013 'uint32' [1 1] 'garbage2' },'Repeat',SeqData.nb_frames); 2014 2015 %%%%%%%BRICOLAGE in case of unreadable .sqb file: remplace lecture du fichier 2016 % ind=[111 114:211];%indices of bin files 2017 % w=1024;%w=width of images in pixels 2018 % h=1024;%h=height of images in pixels 2019 % bpp=2;% nbre of bytes per pixel 2020 % lengthimage=w*h*bpp;% lengthof an image record on the binary file 2021 % nbimages=32; %nbre of images of each camera in a bin file 2022 % for ii=1:32*numel(ind) 2023 % data(ii).offset=mod(ii-1,32)*2*lengthimage+lengthimage;%Dalsa_2 2024 % %data(ii).offset=mod(ii-1,32)*2*lengthimage;%Dalsa_1 2025 % data(ii).file_idx=ind(ceil(ii/32)); 2026 % data(ii).timestamp=0.2*(ii-1); 2027 % end 2028 % m.Data=data; 2029 %%%%%%% 2030 timestamp=zeros(1,numel(m.Data)); 2031 for ii=1: numel(m.Data) 2032 timestamp(ii)=m.Data(ii).timestamp; 2033 end 2034 difftime=XmlData.Time(2:end,2:end); 2035 difftime=timestamp'-reshape(difftime,[],1); 2036 disp(['time from xml and timestamp differ by ' num2str(max(max(abs(difftime))))]) 2037 if max(abs(difftime))>0.01 2038 figure(1) 2039 plot(timestamp,difftime) 2040 xlabel('time(s)') 2041 ylabel('timestamp-XmlData.Time(s)') 2042 end 2043 2044 %% checking consistency with the xml file 2045 if ~isequal(SeqData.nb_frames,numel(timestamp)) 2046 disp_uvmat('ERRROR',['inconsistent number of images ' num2str(SeqData.nb_frames) ' with respect to the xml file: ' num2str(numel(timestamp))] ,checkrun); 2047 return 2048 end 2049 2050 disp ('max time difference xml and timestamps (IN SEC.)') 2051 max(abs(difftime)) 1985 2052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1986 2053 % MenuRun Callbacks … … 2177 2244 2178 2245 %% case of isolated input files without series 2179 switch FieldType 2180 case '' 2181 msgbox_uvmat('ERROR','invalid input file type') 2182 return 2183 case 'txt' 2184 edit(fileinput) 2185 return 2186 case 'figure' %display matlab figure 2187 hfig=open(fileinput); 2188 set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio 2189 set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function 2190 set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function 2191 return 2192 case 'xml' % edit xml files 2193 t=xmltree(fileinput); 2194 % the xml file marks a project or project link, open datatree_browser 2195 if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir') 2196 datatree_browser(fileinput) 2197 else % other xml file, open the xml editor 2246 if strcmp(FileInfo.FileIndexing,'off') 2247 switch FieldType 2248 case 'txt' 2249 edit(fileinput) 2250 case 'figure' %display matlab figure 2251 hfig=open(fileinput); 2252 set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio 2253 set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function 2254 set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function 2255 case 'xml' % edit xml files 2256 t=xmltree(fileinput); 2257 % the xml file marks a project or project link, open datatree_browser 2258 if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir') 2259 datatree_browser(fileinput) 2260 else % other xml file, open the xml editor 2261 editxml(fileinput); 2262 end 2263 case 'xls'% Excel file opended by editxml 2198 2264 editxml(fileinput); 2199 end2200 return2201 case 'xls'% Excel file opended by editxml 2202 editxml(fileinput);2203 2265 otherwise 2266 msgbox_uvmat('ERROR',['inputfile type ' FileInfo.FileType ' not implemented in uvmat']) 2267 2268 end 2269 return 2204 2270 end 2205 2271 … … 2264 2330 set(handles.j2,'String',num2stra(j2,NomType)); 2265 2331 if isfield(FileInfo,'MaskFile') 2266 if exist(FileInfo.MaskFile )2332 if exist(FileInfo.MaskFile,'file') 2267 2333 set(handles.CheckMask,'Value',1) 2268 2334 else … … 2337 2403 set(handles.MenuTools,'Enable','on') 2338 2404 2339 % initiate input file series and inputfilerefresh the current field view:2405 %% analyse the input file series, then refresh the current field view: 2340 2406 update_rootinfo(handles,RootPath,SubDir,[FileName FileExt],FileInfo, MovieObject,input_line); 2341 2407 … … 2360 2426 2361 2427 set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])% paint back button to red to indicate update is finished 2362 set(handles.uvmat,'Pointer','arrow')% set back the mouse pointer to arrow 2428 set(handles.uvmat,'Pointer','arrow')% set back the mouse pointer to arrowCheckIndexing 2363 2429 2364 2430 … … 2369 2435 function errormsg=update_rootinfo(handles,RootPath,SubDir,FileName,FileInfo,VideoObject,input_line) 2370 2436 %------------------------------------------------------------------------ 2371 errormsg=''; %default error msg 2372 2373 %% define the relevant handles depending on the input_line (1=first file series, 2= second file series) 2374 if ~exist('input_line','var') 2375 input_line=1; 2376 end 2377 if input_line==1 2378 handles_Fields=handles.FieldName; 2379 elseif input_line==2 2380 handles_Fields=handles.FieldName_1; 2381 end 2437 2382 2438 set(handles.FixVelType,'Value',0); %desactivate fixed veltype by default 2383 2439 … … 2385 2441 XmlFileName=find_imadoc(RootPath,SubDir);% search the appropriate ImaDoc xml file 2386 2442 [~,XmlName]=fileparts(XmlFileName); 2387 warntext='';%default warning message 2388 NbSlice=1;%default 2389 TimeUnit='';%default 2390 TimeName='';%default 2391 XmlData=[]; 2443 2444 CheckIndexing=false;% test for virtual indexing of frames different from the file name index, false by default 2392 2445 if isempty(XmlFileName) %no ImaDoc xml file detected 2393 2446 set(handles.view_xml,'Visible','off') … … 2402 2455 end 2403 2456 if ~isempty(XmlData) 2404 if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit) 2405 TimeUnit=XmlData.TimeUnit; 2406 end 2407 if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) 2408 TimeName='xml';%Time possibly documented by the xml file (but priority to the opened file if available) 2409 % if XmlData.Time(1,:)==XmlData.Time(2,:)% case starting with index 1 2410 % sizDti=size(XmlData.Time,1)-1;%size of the time vector explicitly defined in the xml file 2411 % ind_start=1; 2412 % else 2413 % sizDti=size(XmlData.Time,1);% case starting with index 0 2414 % ind_start=0; 2415 % end 2416 if isfield(XmlData,'FileSeries')&& ~strcmp(XmlName,SubDir) 2457 if isfield(XmlData,'FileSeries') 2458 if strcmp(XmlName,SubDir)% xml file directly at the level of the current data file (not up in the data tree) 2459 CheckIndexing=true;% virtual indexing of frames different from the file name index 2460 else % xml file not used to document index relabeling 2417 2461 XmlData=rmfield(XmlData,'FileSeries');%desactivate file indexing option for derived file series (e.g. images.png) 2418 end2462 end 2419 2463 end 2420 2464 end … … 2426 2470 end 2427 2471 end 2472 if CheckIndexing 2473 set(handles.MenuRelabelFrames,'checked','on')% activate the relabel tool by default 2474 else 2475 set(handles.MenuRelabelFrames,'checked','off') 2476 end 2428 2477 XmlData.FileInfo=FileInfo; 2478 errormsg=update_series(handles,RootPath,SubDir,FileName,XmlData,CheckIndexing,input_line); 2479 2480 %-------------------------------------------------------- 2481 function errormsg=update_series(handles,RootPath,SubDir,FileName,XmlData,CheckIndexing,input_line) 2482 errormsg=''; %default error msg 2483 warntext='';%default warning message 2484 NbSlice=1;%default 2485 TimeUnit='';%default 2486 TimeName='';%default 2429 2487 2430 2488 %% get the file series 2431 2489 MovieObject=[]; 2432 if strcmp(get(handles.MenuRelabelFrames,'checked'),'on') && isfield(XmlData,'FileSeries') && isfield(XmlData.FileSeries,'FileName') 2433 CheckIndexing=true; 2490 if CheckIndexing 2434 2491 NomType='*'; 2435 2492 i1_series=[]; … … 2439 2496 nbfield=[]; 2440 2497 nbfield_j=[]; 2441 2442 % if iscell(XmlData.FileSeries.FileName) 2443 % [RootPath,SubDir,RootFile,i1,i2,j1,j2,Ext,NomType]=fileparts_uvmat(XmlData.FileSeries.FileName{1}); 2444 % else 2445 % [RootPath,SubDir,RootFile,i1,i2,j1,j2,Ext,NomType]=fileparts_uvmat(XmlData.FileSeries.FileName); 2446 % end 2447 if strcmp(TimeName,'xml') %&& CheckIndexing% get the image series info from the xml file 2448 [nbfield,nbfield_j]=size(XmlData.Time); 2449 nbfield=nbfield-1; %remove the possible index 0 2450 nbfield_j=nbfield_j-1; %remove the possible index 0 2451 i1_series=zeros(nbfield,nbfield_j,1); 2452 i1_series(:,:,1)=(1:nbfield)'*ones(1,nbfield_j); 2453 i2_series=i1_series; 2454 if nbfield_j==1 2455 j1_series=[]; 2456 else 2457 j1_series(:,:,1)=ones(nbfield,1)*(1:nbfield_j); 2458 end 2459 j2_series=j1_series; 2460 end 2461 set(handles.i1,'String','1') 2498 FileInfo=XmlData.FileInfo; 2499 % if iscell(XmlData.FileSeries.FileName)(handles.i1,'String','1') 2500 set(handles.i1,'String','1')% the index does not correspond to file name index anymore 2462 2501 set(handles.j1,'String','1') 2463 2502 else % scan the input folder to get the list of existing files and NomType 2464 CheckIndexing=false;2465 2503 [~,~,~,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject]=... 2466 2504 find_file_series(fullfile(RootPath,SubDir),FileName); … … 2475 2513 if ~isempty(j1_series)&& ~strcmp(NomType,'*')% the j index is used to label the frame in multimage series 2476 2514 set(handles.j1,'String','1') 2515 elseif strcmp(FileInfo.FieldType,'image') && ~isequal(FileInfo.NumberOfFrames,1) 2516 set(handles.i1,'String','1') 2477 2517 end 2478 2518 end … … 2503 2543 UvData.NewSeries=1; %flag for REFRESH: begin a new series 2504 2544 UvData.FileName_1='';% name of the current second field (used to detect a constant field during file scanning) 2505 %UvData.FileType{input_line}=FileInfo.FileType;2506 2545 UvData.FileInfo{input_line}=FileInfo; 2507 2546 UvData.MovieObject{input_line}=MovieObject; … … 2514 2553 %% read timing and total frame number from the current file (e.g. movie files) 2515 2554 ColorType='falsecolor'; %default 2555 if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit) 2556 TimeUnit=XmlData.TimeUnit; 2557 end 2558 if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) 2559 TimeName='xml';%Time possibly documented by the xml file (but priority to the opened file if available) 2560 end 2561 2516 2562 if ~CheckIndexing && isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data) 2517 2563 TimeUnit='s'; … … 2519 2565 XmlData.Time=zeros(FileInfo.NumberOfFrames+1,2); 2520 2566 XmlData.Time(:,2)=(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate)'; 2567 set(handles.i1,'String','1')% set the frame index to 1 to start the movie 2521 2568 else 2522 2569 XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate); … … 2642 2689 if ~isequal(warntext,'') 2643 2690 msgbox_uvmat('WARNING',warntext); 2691 end 2692 2693 %% define the relevant handles depending on the input_line (1=first file series, 2= second file series) 2694 if ~exist('input_line','var') 2695 input_line=1; 2696 end 2697 if input_line==1 2698 handles_Fields=handles.FieldName; 2699 elseif input_line==2 2700 handles_Fields=handles.FieldName_1; 2644 2701 end 2645 2702 … … 3218 3275 i2=[];j2=[]; 3219 3276 else 3220 [ tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used3277 [~,~,~,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used 3221 3278 if isempty(i1)% no i index set by the input file name 3222 3279 i1=str2double(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) … … 3228 3285 if sub_value % a second input file has been entered 3229 3286 [InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileIndex_1,InputFile.FileExt_1,InputFile.NomType_1]=read_file_boxes_1(handles); 3230 [ tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1);% the indices for the second series taken from FileIndex_13287 [~,~,~,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1);% the indices for the second series taken from FileIndex_1 3231 3288 if isempty(i1_1) 3232 3289 i1_1=str2double(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) … … 4757 4814 YName=''; 4758 4815 ZName=''; 4816 if isfield(GetFieldData,'FieldOption') 4759 4817 switch GetFieldData.FieldOption 4760 4818 case 'vectors' … … 4810 4868 set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName]) 4811 4869 % set(handles.NomType,'String','*') 4812 set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) 4870 set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% put file index in the root name 4871 set(handles.NomType,'String','') 4813 4872 set(handles.i1,'String','1')% set counter to 1 (now the time index in the input matrix) 4814 4873 MaxIndex_i=get(handles.MaxIndex_i,'String'); … … 4843 4902 REFRESH_Callback(hObject, eventdata, handles) 4844 4903 end 4845 4904 end 4846 4905 case 'image' 4847 4906 %% look for image corresponding to civ data
Note: See TracChangeset
for help on using the changeset viewer.