source: trunk/src/series/particle_tracking.m @ 804

Last change on this file since 804 was 804, checked in by sommeria, 10 years ago

float tracking updated

File size: 19.6 KB
Line 
1% function ParamOut=particle_tracking(Param)
2%
3% Method:
4   
5% Organization of image indices:
6   
7%INPUT:
8% num_i1: matrix of image indices i
9% num_j1: matrix of image indices j, must be the same size as num_i1
10% num_i2 and num_j2: not used for a function acting on images
11% Series: matlab structure containing parameters, as defined by the interface UVMAT/series
12%       Series.RootPath{1}: path to the image series
13%       Series.RootFile{1}: root file name
14%       Series.FileExt{1}: image file extension
15%       Series.NomType{1}: nomenclature type for file in
16%
17% Method:
18%       Series.NbSlice: %number of slices defined on the interface
19% global A rangx0 rangy0 minA maxA; % make current image A accessible in workspace
20% global hfig1 hfig2 scalar
21% global Abackg nbpart lum diam
22%%%%%%%%%%%%%%ù
23%
24%%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
25%
26%OUTPUT
27% ParamOut: sets options in the GUI series.fig needed for the function
28%
29%INPUT:
30% In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series.
31% In batch mode, Param is the name of the corresponding xml file containing the same information
32% when Param.Action.RUN=0 (as activated when the current Action is selected
33% in series), the function ouput paramOut set the activation of the needed GUI elements
34%
35% Param contains the elements:(use the menu bar command 'export/GUI config' in series to
36% see the current structure Param)
37%    .InputTable: cell of input file names, (several lines for multiple input)
38%                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
39%    .OutputSubDir: name of the subdirectory for data outputs
40%    .OutputDirExt: directory extension for data outputs
41%    .Action: .ActionName: name of the current activated function
42%             .ActionPath:   path of the current activated function
43%             .ActionExt: fct extension ('.m', Matlab fct, '.sh', compiled   Matlab fct
44%             .RUN =0 for GUI input, =1 for function activation
45%             .RunMode='local','background', 'cluster': type of function  use
46%             
47%    .IndexRange: set the file or frame indices on which the action must be performed
48%    .FieldTransform: .TransformName: name of the selected transform function
49%                     .TransformPath:   path  of the selected transform function
50%    .InputFields: sub structure describing the input fields withfields
51%              .FieldName: name(s) of the field
52%              .VelType: velocity type
53%              .FieldName_1: name of the second field in case of two input series
54%              .VelType_1: velocity type of the second field in case of two input series
55%              .Coord_y: name of y coordinate variable
56%              .Coord_x: name of x coordinate variable
57%    .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object)
58%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59
60function ParamOut=particle_tracking(Param)
61
62%% set the input elements needed on the GUI series when the action is selected in the menu ActionName
63if isstruct(Param) && isequal(Param.Action.RUN,0)
64    % general settings of the GUI:
65    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
66    ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
67    ParamOut.NbSlice='off'; %nbre of slices ('off' by default)
68    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
69    ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
70    ParamOut.FieldTransform = 'off';%can use a transform function
71    ParamOut.ProjObject='off';%can use projection object(option 'off'/'on',
72    ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
73    ParamOut.OutputDirExt='.track';%set the output dir extension
74    ParamOut.OutputFileMode='NbSlice';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
75    filecell=get_file_series(Param);%check existence of the first input file
76    if ~exist(filecell{1,1},'file')
77        msgbox_uvmat('WARNING','the first input file does not exist')
78    end
79    % parameters specific to the function 'particle_tracking'
80    Par.Nblock=10;%size of image subblocks for background determination, =[]: no sublock
81    Par.ThreshLum=70;% luminosity threshold for particle detection, < 0 for black particles, >0 for white particles
82  ParamOut.ActionInput=Par;
83    return
84end
85
86%%%%%%%%%%%%  STANDARD RUN PART  %%%%%%%%%%%%
87ParamOut=[];
88%% read input parameters from an xml file if input is a file name (batch mode)
89checkrun=1;
90if ischar(Param)
91    Param=xml2struct(Param);% read Param as input file (batch case)
92    checkrun=0;
93end
94hseries=findobj(allchild(0),'Tag','series');
95RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series
96WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series
97
98%% define the directory for result file
99OutputDir=[Param.OutputSubDir Param.OutputDirExt];
100
101%% root input file(s) name, type and index series
102RootPath=Param.InputTable{1,1};
103RootFile=Param.InputTable{1,3};
104SubDir=Param.InputTable{1,2};
105NomType=Param.InputTable{1,4};
106FileExt=Param.InputTable{1,5};
107[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
108%%%%%%%%%%%%
109% The cell array filecell is the list of input file names, while
110% filecell{iview,fileindex}:
111%        iview: line in the table corresponding to a given file series
112%        fileindex: file index within  the file series,
113% i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j
114% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
115%%%%%%%%%%%%
116nbview=numel(i1_series);%number of input file series (lines in InputTable)
117nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
118nbfield_i=size(i1_series{1},2); %nb of fields for the i index
119nbfield=nbfield_j*nbfield_i; %total number of fields
120
121%% frame index for movie or multimage file input 
122if ~isempty(j1_series{1})
123    frame_index=j1_series{1};
124else
125    frame_index=i1_series{1};
126end
127
128%% check the input file type 
129[FileInfo,VideoObject]=get_file_info(filecell{1,1});
130FileType=FileInfo.FileType;
131ImageTypeOptions={'image','multimage','mmreader','video'};
132if isempty(find(strcmp(FileType,ImageTypeOptions)))
133    disp('input file not images')
134    return
135end
136
137%% calibration data and timing: read the ImaDoc files
138[XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series);
139
140%%%%%%%%%%%%   SPECIFIC PART (to edit) %%%%%%%%%%%%
141%filter for particle center of mass(luminosity)
142Nblock=Param.ActionInput.Nblock;
143ThreshLum=Param.ActionInput.ThreshLum;% luminosity threshold for particle detection, < 0 for black particles, >0 for white particles
144%AbsThreshold=30; %threshold below which a pixel is considered belonging to a float
145%
146hh=ones(5,5);
147hh(1,1)=0;
148hh(1,5)=0;% sum luminosity on the 5x5 domain without corners
149hh(5,1)=0;
150hh(5,5)=0;
151hdx=[-2:1:2];
152hdy=[-2:1:2];
153[hdX,hdY]=meshgrid(hdx,hdy);
154hdX(1,1)=0;
155hdX(1,5)=0;% sum luminosity on the 5x5 domain -corners
156hdX(5,1)=0;
157hdX(5,5)=0;
158hdY(1,1)=0;
159hdY(1,5)=0;% sum luminosity on the 5x5 domain -corners
160hdY(5,1)=0;
161hdY(5,5)=0;
162
163%%  mask to reduce the  working area (optional)
164CheckMask=0;
165if isfield(Param,'CheckMask') && isequal(Param.CheckMask,1)
166    [maskname,TestMask]=name_generator([filebase '_1mask'],1,1,'.png','_i');
167        MaskIma=imread(maskname);
168        Mask=MaskIma>=200;%=1 for good points, 0 for bad
169    CheckMask=1;
170end
171
172%%%%%% MAIN LOOP ON FRAMES %%%%%%
173for ifile=1:nbfield
174    if checkrun
175        update_waitbar(WaitbarHandle,ifile/nbfield)
176        if ~isempty(RUNHandle) &&ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
177            disp('program stopped by user')
178            return
179        end
180    end
181    j1=1;
182    if ~isempty(j1_series)&&~isequal(j1_series,{[]})
183        j1=j1_series{1}(ifile);
184    end
185    filename=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i1_series{1}(ifile),[],j1);
186    A=read_image(filename,FileType,VideoObject,frame_index(ifile));% read the current frame
187    if ndims(A)==3;%color images
188        A=sum(double(A),3);% take the sum of color components
189    end
190    if ThreshLum<0
191        A=max(max(A))-A;%take the negative
192    end
193    if CheckMask
194        A=A.*Mask;
195    end
196    if isempty(Nblock)
197        A=A-min(min(A));%substract absolute mean
198    else
199        Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima
200        Amin=A.*Aflagmin;%values of A at local minima
201        % local background: find all the local minima in image subblocks
202        sumblock= inline('sum(sum(x(:)))');
203        Backgi=blkproc(Amin,[Nblock Nblock],sumblock);% take the sum in  blocks
204        Bmin=blkproc(Aflagmin,[Nblock Nblock],sumblock);% find the number of minima in blocks
205        Backgi=Backgi./Bmin; % find the average of minima in blocks
206        % Backg=Backg+Backgi;
207        Backg=Backgi;
208        A=A-imresize(Backg/nburst(1),size(A),'bilinear');% interpolate to the initial size image and substract
209    end
210    Aflagmax=sparse(imregionalmax(A));%find local maxima
211    Plum=imfilter(A,hh);% sum A on 5x% domains
212    Plum=Aflagmax.*Plum;% Plum gives the particle luminosity at each particle location, 0 elsewhere
213    %make statistics on particles,restricted to a subdomain Sub
214    [Js,Is,lum]=find(Plum);%particle luminosity
215    Plum=(Plum>ThreshLum).*Plum;% introduce a threshold for particle luminosity
216    Aflagmax=Aflagmax.*(Plum>ThreshLum);
217    [Js,Is,lum]=find(Plum);%particle luminosity
218    nbtotal=size(Is)
219    nbtotal=nbtotal(1);
220    %particle size
221    Parea=Aflagmax.*(Plum./A); %particle luminosity/max luminosity=area
222    Pdiam=sqrt(Parea);
223    [Js,Is,diam]=find(Pdiam);%particle location
224   
225    %%%%%%%%%%%%%%%%%%%%%
226   
227    %nbre of particles per block
228%     nbpart=blkproc(Aflagmax,[Nblock Nblock],sumblock);%
229%     npb=size(nbpart);
230%     rangxb=[0.5 (npb(2)-0.5)]*Nblock; % pixel x coordinates for image display
231%     rangyb=[(npb(1)-0.5) 0.5]*Nblock; % pixel y coordinates for image display
232%     image(rangxb,rangyb,nbpart);
233   
234    % get the particle centre of mass
235    dx=imfilter(A,hdX);
236    dy=imfilter(A,-hdY);
237    dx=Aflagmax.*(dx./Plum);
238    dy=Aflagmax.*(dy./Plum);
239    dx=dx/pxcm;
240    dy=dy/pycm;
241    I=([1:npxy(2)]-0.5)/pxcm; %x pos
242    J=([npxy(1):-1:1]-0.5)/pycm; %y pos
243    [Ipos,Jpos]=meshgrid(I,J);
244    Ipos=reshape(Ipos,1,npxy(2)*npxy(1));
245    Jpos=reshape(Jpos,1,npxy(2)*npxy(1));
246    dx=reshape(dx,1,npxy(2)*npxy(1));
247    dy=reshape(dy,1,npxy(2)*npxy(1));
248    Aflag=reshape(Aflagmax,1,npxy(2)*npxy(1));
249    ind=find(Aflag);% select particle positions
250    XPart{ifile}=Ipos(ind)+dx(ind);
251    YPart{ifile}=Jpos(ind)+dy(ind);     
252end
253hold off
254
255size(XPart{1})
256
257%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258%Trajectoires
259%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260for ifile=1:nbfield
261   
262    [XPart{ifile},YPart{ifile}]=phys_XYZ(Calib,XPart{ifile},YPart{ifile});
263
264end
265
266if nbfield>2
267    figpart=figure
268    hold on
269    plot(XPart{1}(:),YPart{1}(:),'r+')
270    plot(XPart{2}(:),YPart{2}(:),'b+')
271    plot(XPart{3}(:),YPart{3}(:),'y+')
272    legend('particules image 1','particules image 2','particules image 3');
273    xlabel('x (cm)');
274    ylabel('y (cm)');
275    title('Position des particules')
276else
277   figpart=figure
278    hold on
279    plot(XPart{1}(:),YPart{1}(:),'r+')
280    plot(XPart{2}(:),YPart{2}(:),'b+')
281    legend('particules image 1','particules image 2');
282    xlabel('x (cm)');
283    ylabel('y (cm)');
284    title('Position des particules')
285end   
286
287%     prompt={'Ymin (cm)','Ymax( cm)','Xmin (cm)','Xmax (cm)'};
288%     Rep=inputdlg(prompt,'Experiment');
289%     Ymin=str2double(Rep(1));
290%     Ymax=str2double(Rep(2));
291%     Xmin=str2double(Rep(3));
292%     Xmax=str2double(Rep(4));
293   
294    Ymin=6;
295    Ymax=14;
296    Xmin=15;
297    Xmax=35;
298   
299    plot(Xmin,Ymin,'g+')
300    plot(Xmin,Ymax,'g+')
301    plot(Xmax,Ymin,'g+')
302    plot(Xmax,Ymax,'g+')
303
304   
305 for ima=2:nbfield   
306    t{1}=0*ones(size(XPart{1},2),1);
307    burst(1)=0;
308    burst(2)=0.018;
309    burst(3)=0.036;
310%     nburst=strcat('burst',num2str(ima-1),'-',num2str(ima),' (s)');
311%     prompt={'burst (s)'};
312%     Rep=inputdlg(prompt,nburst);
313%     burst(ima)=str2double(Rep(1));
314    t{ima}=(burst(ima)+burst(ima-1))*ones(size(XPart{ima},2),1);
315 end
316
317
318 
319 for ima=1:nbfield
320
321    IndY{ima}=find(YPart{ima}>Ymin & YPart{ima}<Ymax & XPart{ima}>Xmin & XPart{ima}<Xmax);
322    XPart{ima}=XPart{ima}(IndY{ima});
323    YPart{ima}=YPart{ima}(IndY{ima});
324   
325       
326end
327
328
329
330%%%%%%%%%%%%%%%%%%%%%%%
331% Calcul de v1
332%%%%%%%%%%%%%%%%%%%%%%%
333
334for i=1:size(XPart{1},2)
335    MatPos{1}(i,1)=XPart{1}(i);
336    MatPos{1}(i,2)=YPart{1}(i);
337    MatPos{1}(i,3)=t{1}(i);
338    %MatPos{1}(i,4)=i;
339end
340
341for j=1:size(XPart{2},2)-1
342    MatPos{1}(j+size(XPart{1},2),1)=XPart{2}(j);
343    MatPos{1}(j+size(XPart{1},2),2)=YPart{2}(j);
344    MatPos{1}(j+size(XPart{1},2),3)=t{2}(j);
345    %MatPos{1}(j,4)=j+size(XPart{1},2);
346end
347 
348% Dmax=inputdlg('Entrer la distance maximum (0.25 cm)','dmax (cm)',1)
349% dmax=str2num(Dmax{1});
350dmax=0.23;
351
352result{1}=track(MatPos{1},dmax);
353
354izero=1;
355for itest=1:1:size(result{1},1)-1
356    if  result{1}(itest+1,4)==result{1}(itest,4)
357        vitu{1}(izero,1)=(result{1}(itest+1,1)-result{1}(itest,1))/burst(2);
358        vitu{1}(izero,2)=result{1}(itest,4);
359        vitv{1}(izero,1)=(result{1}(itest+1,2)-result{1}(itest,2))/burst(2);
360        vitv{1}(izero,2)=result{1}(itest,4);
361        MatPos{2}(izero,1)=result{1}(itest,1);
362        MatPos{2}(izero,2)=result{1}(itest,2);
363        izero=izero+1;
364    end
365end
366
367
368vitfu{1}=vitu{1};
369vitfv{1}=vitv{1};
370
371
372%%%%%%%%%%%%%%%%%%%%%%%
373% Calcul de vi
374%%%%%%%%%%%%%%%%%%%%%%%
375
376
377if nbfield>2
378    for ima=2:nbfield-1
379       
380       for i=1:size(MatPos{ima},1)
381        MatPos{ima+1}(i,1)=MatPos{ima}(i,1)+(burst(ima+1)*vitfu{ima-1}(i));
382        MatPos{ima+1}(i,2)=MatPos{ima}(i,2)+(burst(ima+1)*vitfv{ima-1}(i));
383        MatPos{ima+1}(i,3)=t{ima}(i);
384      end
385
386      for j=1:size(XPart{ima+1},2)-1
387          MatPos{ima+1}(j+size(MatPos{ima},1),1)=XPart{ima+1}(j);
388          MatPos{ima+1}(j+size(MatPos{ima},1),2)=YPart{ima+1}(j);
389          MatPos{ima+1}(j+size(MatPos{ima},1),3)=t{ima+1}(j);
390      end
391       
392     
393    result{ima}=track(MatPos{ima+1},0.15);
394       
395        izero=1;
396        for itest=1:1:size(result{ima},1)-1
397            if  result{ima}(itest+1,4)==result{ima}(itest,4)
398                vitu{ima}(izero,1)=(result{ima}(itest+1,1)-result{ima}(itest,1))/burst(ima+1);
399                vitu{ima}(izero,2)=result{ima}(itest,4);
400                vitv{ima}(izero,1)=(result{ima}(itest+1,2)-result{ima}(itest,2))/burst(ima+1);
401                vitv{ima}(izero,2)=result{ima}(itest,4);
402                MatPos{ima+2}(izero,1)=result{ima}(itest,1);
403                MatPos{ima+2}(izero,2)=result{ima}(itest,2);
404                izero=izero+1;
405            end   
406        end
407
408            i=vitu{ima}(1,2):1:vitu{ima}(end,2)
409           
410              vitfu{ima}(:,1)=vitfu{ima-1}(i,1)+vitu{ima}(:,1);
411              vitfv{ima}(:,1)=vitfv{ima-1}(i,1)+vitv{ima}(:,1);
412              vitfu{ima}(:,2)=vitu{ima}(:,2);
413              vitfv{ima}(:,2)=vitv{ima}(:,2);
414
415            vitfu{ima-1}=vitfu{ima-1}(i,1);
416            vitfu{ima-1}(:,2)=i;
417            vitfv{ima-1}=vitfv{ima-1}(i,1);
418            vitfv{ima-1}(:,2)=i;
419            i=1:1:size(vitfu{ima-1},1)
420            xpos=MatPos{2}(i,1)
421            ypos=MatPos{2}(i,2)
422      end
423    end
424
425
426
427    figure
428    hold on
429    plot(MatPos{1}(:,1),MatPos{1}(:,2),'r+')
430    plot(MatPos{2}(:,1),MatPos{2}(:,2),'b+')
431    plot(MatPos{4}(:,1),MatPos{4}(:,2),'y+')
432    quiver(xpos(:),ypos(:),vitfu{1}(:,1),vitfv{1}(:,1),'g')
433    quiver(MatPos{4}(:,1),MatPos{4}(:,2),vitfu{2}(:,1),vitfv{2}(:,1),'k')
434    legend('particules image 1','particules image 2', 'particules image 3','vitesse 1-2 (cm/s)','vitesse 2-3 (cm/s)');
435    xlabel('x (cm)');
436    ylabel('y (cm)');
437    title('Position et vitesse (cm/s) des particules')
438   
439
440    for i=1:size(vitfu{end},1)
441     vitfuadd(i)=0;
442     vitfvadd(i)=0;
443    end
444
445   
446   
447         for i=1:1:size(vitfu{end}(:,1))
448           
449                for j=1:nbfield-1
450                    vitfuadd(i)= vitfuadd(i)+vitfu{j}(i,1);
451                    vitfvadd(i)= vitfvadd(i)+vitfv{j}(i,1);
452                    xpos1(i)=MatPos{1}(i,1);
453                    ypos1(i)=MatPos{1}(i,2);
454                    xpos2(i)=MatPos{2}(i,1);
455                    ypos2(i)=MatPos{2}(i,2);
456                   
457                end
458            end
459            sizexpos1=size(xpos1)
460
461    vitfumoy=vitfuadd./(nbfield-1)
462    vitfvmoy=vitfvadd./(nbfield-1)
463
464    testresult1=result{1}
465    testresult2=result{2}
466   
467if nbfield>2   
468    figure
469    hold on
470    plot(MatPos{1}(:,1),MatPos{1}(:,2),'r+')
471    plot(MatPos{2}(:,1),MatPos{2}(:,2),'b+')
472    quiver(xpos2(:),ypos2(:),vitfumoy(:),vitfvmoy(:),'g')
473    legend('particules image 1','particules image 2', 'vitesse moyenne (cm/s)');
474    xlabel('x (cm)');
475    ylabel('y (cm)');
476    title('Position et vitesse (cm/s) des particules')
477   
478else
479
480    figure
481    hold on
482    plot(MatPos{1}(:,1),MatPos{1}(:,2),'r+')
483    plot(MatPos{2}(:,1),MatPos{2}(:,2),'b+')
484    quiver(MatPos{2}(:,1),MatPos{2}(:,2),vitfu{1}(:),vitfv{1}(:),'g')
485    legend('particules image 1','particules image 2','vitesse 1-2 (cm/s)');
486    xlabel('x (cm)');
487    ylabel('y (cm)');
488    title('Position et vitesse (cm/s) des particules')
489   
490    vitfumoy=vitfu{1};
491    vitfvmoy=vitfv{1};
492
493end
494
495VitData.NbDim=2;
496VitData.NbCoord=2;
497VitData.CoordType='phys';
498VitData.dt=0.0185;
499VitData.CoordUnit='cm';
500VitData.Z=0;
501VitData.ListDimName={'nb_vectors'};
502VitData.DimValue=size(vitfumoy,2);
503VitData.ListVarName={'X'  'Y'  'U'  'V'  'F'};
504VitData.VarDimIndex={[1]  [1]  [1]  [1]  [1]};
505VitData.ListVarAttribute={'Role'};
506VitData.Role={'coord_x'  'coord_y'  'vector_x'  'vector_y'  'warnflag'};
507
508if nbfield>2
509    VitData.X=size(MatPos{4},1);
510    VitData.Y=size(MatPos{4},2);
511else
512    VitData.X=size(MatPos{2},1);
513    VitData.Y=size(MatPos{2},2);
514end
515
516VitData.U=size(vitfumoy,2);
517VitData.V=size(vitfvmoy,2);
518VitData.Style='plane';
519VitData.Time=[198.5203 198.5203];
520VitData.Action=Series.Action;
521
522if nbfield>2
523    VitData.X=MatPos{4}(:,1)';
524    VitData.Y=MatPos{4}(:,2)';
525else
526    VitData.X=MatPos{2}(:,1)';
527    VitData.Y=MatPos{2}(:,2)';
528end
529
530VitData.U=vitfumoy(:)';
531VitData.V=vitfvmoy(:)';
532
533if length(VitData.ListVarName) >= 4 & isequal(VitData.ListVarName(1:4), {'X'  'Y'  'U'  'V'})
534       VitData.ListAttribute={'nb_coord','nb_dim','dt','pixcmx','pixcmy','hart','civ','fix'};
535       VitData.nb_coord=2;
536       VitData.nb_dim=2;
537       VitData.dt=0.018;
538       VitData.absolut_time_T0=0;
539       VitData.pixcmx=1; %pix per cm (1 by default)
540       VitData.pixcmy=1; %pix per cm (1 by default)
541       VitData.hart=0;
542           if isequal(VitData.CoordType,'px')
543             VitData.civ=1;
544           else
545             VitData.civ=0;
546           end
547        VitData.fix=0;
548        VitData.ListVarName(1:4)={'vec_X'  'vec_Y'  'vec_U'  'vec_V'};
549        VitData.vec_X=VitData.X;
550        VitData.vec_Y=VitData.Y;
551        VitData.vec_U=VitData.U;
552        VitData.vec_V=VitData.V;
553end
554currentdir=pwd;%store the current working directory
555[Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ)
556cd(Path_ima);%move to the directory of the images: needed to create the result dir by 'mkdir'
557dircur=pwd; %current working directory
558[m1,m2,m3]=mkdir('TRACK_test')
559cd(currentdir)
560[filename_nc,idetect]=name_generator(filebase,num_i1(1),num_j1(1),'.nc','_i_j1-j2',1,num_i1(1),num_j1(2),'TRACK_test')
561error=struct2nc(filename_nc,VitData); %save result file
562if isequal(error,0)
563    [filename_nc ' written']
564else
565    warndlg_uvmat(error,'ERROR')
566end
567
Note: See TracBrowser for help on using the repository browser.