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

Last change on this file since 789 was 784, checked in by sommeria, 11 years ago

adpat uvmat to reading data from rdvision

File size: 19.4 KB
RevLine 
[616]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'
[619]80%     Par.Nblock=[];%size of image subblocks for background determination, =[]: no sublock
81%     Par.ThreshLum=-2000;% luminosity threshold for particle detection, < 0 for black particles, >0 for white particles
82%   ParamOut.ActionInput=Par;
[618]83    return
[616]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
94
95%% define the directory for result file
96OutputDir=[Param.OutputSubDir Param.OutputDirExt];
97
98%% root input file(s) name, type and index series
99RootPath=Param.InputTable{1,1};
100RootFile=Param.InputTable{1,3};
101SubDir=Param.InputTable{1,2};
102NomType=Param.InputTable{1,4};
103FileExt=Param.InputTable{1,5};
104[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
105%%%%%%%%%%%%
106% The cell array filecell is the list of input file names, while
107% filecell{iview,fileindex}:
108%        iview: line in the table corresponding to a given file series
109%        fileindex: file index within  the file series,
110% 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
111% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
112%%%%%%%%%%%%
113nbview=numel(i1_series);%number of input file series (lines in InputTable)
114nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
115nbfield_i=size(i1_series{1},2); %nb of fields for the i index
116nbfield=nbfield_j*nbfield_i; %total number of fields
117
[618]118%% frame index for movie or multimage file input 
119if ~isempty(j1_series{1})
120    frame_index=j1_series{1};
121else
122    frame_index=i1_series{1};
123end
124
[616]125%% check the input file type 
[784]126[FileInfo,VideoObject]=get_file_info(filecell{1,1});
[783]127FileType=FileInfo.FileType;
[616]128ImageTypeOptions={'image','multimage','mmreader','video'};
129if isempty(find(strcmp(FileType,ImageTypeOptions)))
130    disp('input file not images')
131    return
132end
133
134%% calibration data and timing: read the ImaDoc files
135[XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series);
136
137%%%%%%%%%%%%   SPECIFIC PART (to edit) %%%%%%%%%%%%
138%filter for particle center of mass(luminosity)
[619]139%Nblock=Param.ActionInput.Nblock;
140%ThreshLum=Param.ActionInput.ThreshLum;% luminosity threshold for particle detection, < 0 for black particles, >0 for white particles
141AbsThreshold=30; %threshold below which a pixel is considered belonging to a float
142%
[616]143hh=ones(5,5);
144hh(1,1)=0;
145hh(1,5)=0;% sum luminosity on the 5x5 domain without corners
146hh(5,1)=0;
147hh(5,5)=0;
148hdx=[-2:1:2];
149hdy=[-2:1:2];
150[hdX,hdY]=meshgrid(hdx,hdy);
151hdX(1,1)=0;
152hdX(1,5)=0;% sum luminosity on the 5x5 domain -corners
153hdX(5,1)=0;
154hdX(5,5)=0;
155hdY(1,1)=0;
156hdY(1,5)=0;% sum luminosity on the 5x5 domain -corners
157hdY(5,1)=0;
158hdY(5,5)=0;
159
160%%  mask to reduce the  working area (optional)
161CheckMask=0;
162if isfield(Param,'CheckMask') && isequal(Param.CheckMask,1)
163    [maskname,TestMask]=name_generator([filebase '_1mask'],1,1,'.png','_i');
164        MaskIma=imread(maskname);
165        Mask=MaskIma>=200;%=1 for good points, 0 for bad
166    CheckMask=1;
167end
168
[619]169%%%%%% MAIN LOOP ON FRAMES %%%%%%
[616]170for ifile=1:nbfield
171    if checkrun
172        if strcmp(get(Param.RUNHandle,'BusyAction'),'queue')
173            update_waitbar(Param.WaitbarHandle,ifile/nbfield)
174        else
175            break% leave the loop if the STOP button is activated on the GUI series
176        end
177    end
[618]178    if ~isempty(j1_series)&&~isequal(j1_series,{[]})
179        j1=j1_series{1}(ifile);
180    end
181    filename=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i1_series{1}(ifile),[],j1);
[619]182    A=read_image(filename,FileType,VideoObject,frame_index(ifile));% read the current frame
[616]183    if ndims(A)==3;%color images
[618]184        A=sum(double(A),3);% take the sum of color components
[616]185    end
186    if ThreshLum<0
187        A=max(max(A))-A;%take the negative
188    end
[618]189    if CheckMask
[616]190        A=A.*Mask;
191    end
192    if isempty(Nblock)
193        A=A-min(min(A));%substract absolute mean
194    else
195        Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima
196        Amin=A.*Aflagmin;%values of A at local minima
197        % local background: find all the local minima in image subblocks
198        sumblock= inline('sum(sum(x(:)))');
199        Backgi=blkproc(Amin,[Nblock Nblock],sumblock);% take the sum in  blocks
200        Bmin=blkproc(Aflagmin,[Nblock Nblock],sumblock);% find the number of minima in blocks
201        Backgi=Backgi./Bmin; % find the average of minima in blocks
202        % Backg=Backg+Backgi;
203        Backg=Backgi;
204        A=A-imresize(Backg/nburst(1),size(A),'bilinear');% interpolate to the initial size image and substract
205    end
[618]206    Aflagmax=sparse(imregionalmax(A));%find local maxima
207    Plum=imfilter(A,hh);% sum A on 5x% domains
[616]208    Plum=Aflagmax.*Plum;% Plum gives the particle luminosity at each particle location, 0 elsewhere
209    %make statistics on particles,restricted to a subdomain Sub
210    [Js,Is,lum]=find(Plum);%particle luminosity
211    Plum=(Plum>ThreshLum).*Plum;% introduce a threshold for particle luminosity
212    Aflagmax=Aflagmax.*(Plum>ThreshLum);
213    [Js,Is,lum]=find(Plum);%particle luminosity
214    nbtotal=size(Is)
215    nbtotal=nbtotal(1);
216    %particle size
[618]217    Parea=Aflagmax.*(Plum./A); %particle luminosity/max luminosity=area
[616]218    Pdiam=sqrt(Parea);
219    [Js,Is,diam]=find(Pdiam);%particle location
220   
221    %%%%%%%%%%%%%%%%%%%%%
222   
223    %nbre of particles per block
224%     nbpart=blkproc(Aflagmax,[Nblock Nblock],sumblock);%
225%     npb=size(nbpart);
226%     rangxb=[0.5 (npb(2)-0.5)]*Nblock; % pixel x coordinates for image display
227%     rangyb=[(npb(1)-0.5) 0.5]*Nblock; % pixel y coordinates for image display
228%     image(rangxb,rangyb,nbpart);
229   
230    % get the particle centre of mass
[618]231    dx=imfilter(A,hdX);
232    dy=imfilter(A,-hdY);
[616]233    dx=Aflagmax.*(dx./Plum);
234    dy=Aflagmax.*(dy./Plum);
235    dx=dx/pxcm;
236    dy=dy/pycm;
237    I=([1:npxy(2)]-0.5)/pxcm; %x pos
238    J=([npxy(1):-1:1]-0.5)/pycm; %y pos
239    [Ipos,Jpos]=meshgrid(I,J);
240    Ipos=reshape(Ipos,1,npxy(2)*npxy(1));
241    Jpos=reshape(Jpos,1,npxy(2)*npxy(1));
242    dx=reshape(dx,1,npxy(2)*npxy(1));
243    dy=reshape(dy,1,npxy(2)*npxy(1));
244    Aflag=reshape(Aflagmax,1,npxy(2)*npxy(1));
245    ind=find(Aflag);% select particle positions
246    XPart{ifile}=Ipos(ind)+dx(ind);
247    YPart{ifile}=Jpos(ind)+dy(ind);     
248end
249hold off
250
251size(XPart{1})
252
253%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254%Trajectoires
255%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256for ifile=1:nbfield
257   
258    [XPart{ifile},YPart{ifile}]=phys_XYZ(Calib,XPart{ifile},YPart{ifile});
259
260end
261
262if nbfield>2
263    figpart=figure
264    hold on
265    plot(XPart{1}(:),YPart{1}(:),'r+')
266    plot(XPart{2}(:),YPart{2}(:),'b+')
267    plot(XPart{3}(:),YPart{3}(:),'y+')
268    legend('particules image 1','particules image 2','particules image 3');
269    xlabel('x (cm)');
270    ylabel('y (cm)');
271    title('Position des particules')
272else
273   figpart=figure
274    hold on
275    plot(XPart{1}(:),YPart{1}(:),'r+')
276    plot(XPart{2}(:),YPart{2}(:),'b+')
277    legend('particules image 1','particules image 2');
278    xlabel('x (cm)');
279    ylabel('y (cm)');
280    title('Position des particules')
281end   
282
283%     prompt={'Ymin (cm)','Ymax( cm)','Xmin (cm)','Xmax (cm)'};
284%     Rep=inputdlg(prompt,'Experiment');
285%     Ymin=str2double(Rep(1));
286%     Ymax=str2double(Rep(2));
287%     Xmin=str2double(Rep(3));
288%     Xmax=str2double(Rep(4));
289   
290    Ymin=6;
291    Ymax=14;
292    Xmin=15;
293    Xmax=35;
294   
295    plot(Xmin,Ymin,'g+')
296    plot(Xmin,Ymax,'g+')
297    plot(Xmax,Ymin,'g+')
298    plot(Xmax,Ymax,'g+')
299
300   
301 for ima=2:nbfield   
302    t{1}=0*ones(size(XPart{1},2),1);
303    burst(1)=0;
304    burst(2)=0.018;
305    burst(3)=0.036;
306%     nburst=strcat('burst',num2str(ima-1),'-',num2str(ima),' (s)');
307%     prompt={'burst (s)'};
308%     Rep=inputdlg(prompt,nburst);
309%     burst(ima)=str2double(Rep(1));
310    t{ima}=(burst(ima)+burst(ima-1))*ones(size(XPart{ima},2),1);
311 end
312
313
314 
315 for ima=1:nbfield
316
317    IndY{ima}=find(YPart{ima}>Ymin & YPart{ima}<Ymax & XPart{ima}>Xmin & XPart{ima}<Xmax);
318    XPart{ima}=XPart{ima}(IndY{ima});
319    YPart{ima}=YPart{ima}(IndY{ima});
320   
321       
322end
323
324
325
326%%%%%%%%%%%%%%%%%%%%%%%
327% Calcul de v1
328%%%%%%%%%%%%%%%%%%%%%%%
329
330for i=1:size(XPart{1},2)
331    MatPos{1}(i,1)=XPart{1}(i);
332    MatPos{1}(i,2)=YPart{1}(i);
333    MatPos{1}(i,3)=t{1}(i);
334    %MatPos{1}(i,4)=i;
335end
336
337for j=1:size(XPart{2},2)-1
338    MatPos{1}(j+size(XPart{1},2),1)=XPart{2}(j);
339    MatPos{1}(j+size(XPart{1},2),2)=YPart{2}(j);
340    MatPos{1}(j+size(XPart{1},2),3)=t{2}(j);
341    %MatPos{1}(j,4)=j+size(XPart{1},2);
342end
343 
344% Dmax=inputdlg('Entrer la distance maximum (0.25 cm)','dmax (cm)',1)
345% dmax=str2num(Dmax{1});
346dmax=0.23;
347
348result{1}=track(MatPos{1},dmax);
349
350izero=1;
351for itest=1:1:size(result{1},1)-1
352    if  result{1}(itest+1,4)==result{1}(itest,4)
353        vitu{1}(izero,1)=(result{1}(itest+1,1)-result{1}(itest,1))/burst(2);
354        vitu{1}(izero,2)=result{1}(itest,4);
355        vitv{1}(izero,1)=(result{1}(itest+1,2)-result{1}(itest,2))/burst(2);
356        vitv{1}(izero,2)=result{1}(itest,4);
357        MatPos{2}(izero,1)=result{1}(itest,1);
358        MatPos{2}(izero,2)=result{1}(itest,2);
359        izero=izero+1;
360    end
361end
362
363
364vitfu{1}=vitu{1};
365vitfv{1}=vitv{1};
366
367
368%%%%%%%%%%%%%%%%%%%%%%%
369% Calcul de vi
370%%%%%%%%%%%%%%%%%%%%%%%
371
372
373if nbfield>2
374    for ima=2:nbfield-1
375       
376       for i=1:size(MatPos{ima},1)
377        MatPos{ima+1}(i,1)=MatPos{ima}(i,1)+(burst(ima+1)*vitfu{ima-1}(i));
378        MatPos{ima+1}(i,2)=MatPos{ima}(i,2)+(burst(ima+1)*vitfv{ima-1}(i));
379        MatPos{ima+1}(i,3)=t{ima}(i);
380      end
381
382      for j=1:size(XPart{ima+1},2)-1
383          MatPos{ima+1}(j+size(MatPos{ima},1),1)=XPart{ima+1}(j);
384          MatPos{ima+1}(j+size(MatPos{ima},1),2)=YPart{ima+1}(j);
385          MatPos{ima+1}(j+size(MatPos{ima},1),3)=t{ima+1}(j);
386      end
387       
388     
389    result{ima}=track(MatPos{ima+1},0.15);
390       
391        izero=1;
392        for itest=1:1:size(result{ima},1)-1
393            if  result{ima}(itest+1,4)==result{ima}(itest,4)
394                vitu{ima}(izero,1)=(result{ima}(itest+1,1)-result{ima}(itest,1))/burst(ima+1);
395                vitu{ima}(izero,2)=result{ima}(itest,4);
396                vitv{ima}(izero,1)=(result{ima}(itest+1,2)-result{ima}(itest,2))/burst(ima+1);
397                vitv{ima}(izero,2)=result{ima}(itest,4);
398                MatPos{ima+2}(izero,1)=result{ima}(itest,1);
399                MatPos{ima+2}(izero,2)=result{ima}(itest,2);
400                izero=izero+1;
401            end   
402        end
403
404            i=vitu{ima}(1,2):1:vitu{ima}(end,2)
405           
406              vitfu{ima}(:,1)=vitfu{ima-1}(i,1)+vitu{ima}(:,1);
407              vitfv{ima}(:,1)=vitfv{ima-1}(i,1)+vitv{ima}(:,1);
408              vitfu{ima}(:,2)=vitu{ima}(:,2);
409              vitfv{ima}(:,2)=vitv{ima}(:,2);
410
411            vitfu{ima-1}=vitfu{ima-1}(i,1);
412            vitfu{ima-1}(:,2)=i;
413            vitfv{ima-1}=vitfv{ima-1}(i,1);
414            vitfv{ima-1}(:,2)=i;
415            i=1:1:size(vitfu{ima-1},1)
416            xpos=MatPos{2}(i,1)
417            ypos=MatPos{2}(i,2)
418      end
419    end
420
421
422
423    figure
424    hold on
425    plot(MatPos{1}(:,1),MatPos{1}(:,2),'r+')
426    plot(MatPos{2}(:,1),MatPos{2}(:,2),'b+')
427    plot(MatPos{4}(:,1),MatPos{4}(:,2),'y+')
428    quiver(xpos(:),ypos(:),vitfu{1}(:,1),vitfv{1}(:,1),'g')
429    quiver(MatPos{4}(:,1),MatPos{4}(:,2),vitfu{2}(:,1),vitfv{2}(:,1),'k')
430    legend('particules image 1','particules image 2', 'particules image 3','vitesse 1-2 (cm/s)','vitesse 2-3 (cm/s)');
431    xlabel('x (cm)');
432    ylabel('y (cm)');
433    title('Position et vitesse (cm/s) des particules')
434   
435
436    for i=1:size(vitfu{end},1)
437     vitfuadd(i)=0;
438     vitfvadd(i)=0;
439    end
440
441   
442   
443         for i=1:1:size(vitfu{end}(:,1))
444           
445                for j=1:nbfield-1
446                    vitfuadd(i)= vitfuadd(i)+vitfu{j}(i,1);
447                    vitfvadd(i)= vitfvadd(i)+vitfv{j}(i,1);
448                    xpos1(i)=MatPos{1}(i,1);
449                    ypos1(i)=MatPos{1}(i,2);
450                    xpos2(i)=MatPos{2}(i,1);
451                    ypos2(i)=MatPos{2}(i,2);
452                   
453                end
454            end
455            sizexpos1=size(xpos1)
456
457    vitfumoy=vitfuadd./(nbfield-1)
458    vitfvmoy=vitfvadd./(nbfield-1)
459
460    testresult1=result{1}
461    testresult2=result{2}
462   
463if nbfield>2   
464    figure
465    hold on
466    plot(MatPos{1}(:,1),MatPos{1}(:,2),'r+')
467    plot(MatPos{2}(:,1),MatPos{2}(:,2),'b+')
468    quiver(xpos2(:),ypos2(:),vitfumoy(:),vitfvmoy(:),'g')
469    legend('particules image 1','particules image 2', 'vitesse moyenne (cm/s)');
470    xlabel('x (cm)');
471    ylabel('y (cm)');
472    title('Position et vitesse (cm/s) des particules')
473   
474else
475
476    figure
477    hold on
478    plot(MatPos{1}(:,1),MatPos{1}(:,2),'r+')
479    plot(MatPos{2}(:,1),MatPos{2}(:,2),'b+')
480    quiver(MatPos{2}(:,1),MatPos{2}(:,2),vitfu{1}(:),vitfv{1}(:),'g')
481    legend('particules image 1','particules image 2','vitesse 1-2 (cm/s)');
482    xlabel('x (cm)');
483    ylabel('y (cm)');
484    title('Position et vitesse (cm/s) des particules')
485   
486    vitfumoy=vitfu{1};
487    vitfvmoy=vitfv{1};
488
489end
490
491VitData.NbDim=2;
492VitData.NbCoord=2;
493VitData.CoordType='phys';
494VitData.dt=0.0185;
495VitData.CoordUnit='cm';
496VitData.Z=0;
497VitData.ListDimName={'nb_vectors'};
498VitData.DimValue=size(vitfumoy,2);
499VitData.ListVarName={'X'  'Y'  'U'  'V'  'F'};
500VitData.VarDimIndex={[1]  [1]  [1]  [1]  [1]};
501VitData.ListVarAttribute={'Role'};
502VitData.Role={'coord_x'  'coord_y'  'vector_x'  'vector_y'  'warnflag'};
503
504if nbfield>2
505    VitData.X=size(MatPos{4},1);
506    VitData.Y=size(MatPos{4},2);
507else
508    VitData.X=size(MatPos{2},1);
509    VitData.Y=size(MatPos{2},2);
510end
511
512VitData.U=size(vitfumoy,2);
513VitData.V=size(vitfvmoy,2);
514VitData.Style='plane';
515VitData.Time=[198.5203 198.5203];
516VitData.Action=Series.Action;
517
518if nbfield>2
519    VitData.X=MatPos{4}(:,1)';
520    VitData.Y=MatPos{4}(:,2)';
521else
522    VitData.X=MatPos{2}(:,1)';
523    VitData.Y=MatPos{2}(:,2)';
524end
525
526VitData.U=vitfumoy(:)';
527VitData.V=vitfvmoy(:)';
528
529if length(VitData.ListVarName) >= 4 & isequal(VitData.ListVarName(1:4), {'X'  'Y'  'U'  'V'})
530       VitData.ListAttribute={'nb_coord','nb_dim','dt','pixcmx','pixcmy','hart','civ','fix'};
531       VitData.nb_coord=2;
532       VitData.nb_dim=2;
533       VitData.dt=0.018;
534       VitData.absolut_time_T0=0;
535       VitData.pixcmx=1; %pix per cm (1 by default)
536       VitData.pixcmy=1; %pix per cm (1 by default)
537       VitData.hart=0;
538           if isequal(VitData.CoordType,'px')
539             VitData.civ=1;
540           else
541             VitData.civ=0;
542           end
543        VitData.fix=0;
544        VitData.ListVarName(1:4)={'vec_X'  'vec_Y'  'vec_U'  'vec_V'};
545        VitData.vec_X=VitData.X;
546        VitData.vec_Y=VitData.Y;
547        VitData.vec_U=VitData.U;
548        VitData.vec_V=VitData.V;
549end
550currentdir=pwd;%store the current working directory
551[Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ)
552cd(Path_ima);%move to the directory of the images: needed to create the result dir by 'mkdir'
553dircur=pwd; %current working directory
554[m1,m2,m3]=mkdir('TRACK_test')
555cd(currentdir)
556[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')
557error=struct2nc(filename_nc,VitData); %save result file
558if isequal(error,0)
559    [filename_nc ' written']
560else
561    warndlg_uvmat(error,'ERROR')
562end
563
Note: See TracBrowser for help on using the repository browser.