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

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