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

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

float_tracking added in series

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