Downloaded PIV .zip, but soem functions seem to be missing

classic Classic list List threaded Threaded
2 messages Options
Joana Leite Joana Leite
Reply | Threaded
Open this post in threaded view
|

Downloaded PIV .zip, but soem functions seem to be missing

Hi everyone!

I'm quite new at PIV analysis, so I would appreciate some help here.
Well, I've downloaded the PIV zip folder from here and extracted all files to the MATLAB folder.

I'm using a main script to apply PIV to all images, but it's not working, giving meerrors such as: Undefined function or variable 'matpiv'.

Error in main_PIV (line 63)
        [x,y,u1,v1]= matpiv(f1,f2,win_piv,tm_int,0.5,'single'); % matpiv(image1,image2,size of
        window,time_interval, overlap, looping for window)
Also, there's a warning message at the beginning: Warning: Name is nonexistent or not a directory: C:\Program Files\MATLAB\R2017a\bin\piv & other
functions
> In path (line 109)
  In addpath (line 88)
  In main_PIV (line 8)
Warning: Directory already exists.
> In main_PIV (line 51)
Warning: Directory already exists.
> In main_PIV (line 52)
Warning: Directory already exists.
> In main_PIV (line 53)
Warning: Directory already exists.
> In main_PIV (line 54)
Warning: Directory already exists.
> In main_PIV (line 55)

I do not understand why it's not working, since I've already set the path and all the functions should be on the package I've downloaded, right?

I don't know really, can someone give me a guess for this to happen?

This is the main script I'm using:
close all;clear all;clc;

addpath(fullfile(cd,'piv & other functions'));

global max_sp_dsply

%%  USER INPUT pixel size in Microns, Time in sec

win_piv=64;
pxl_sz=.178; %% pixel size of the movie; also variable
tm_int=5; %%time-lapse; it's variable, need to be changed depending on the one you've defined when acquiring the movie
max_sp_dsply=.5;


% ROI 1 Input the corordinates to define rectangle      
r1_xmin = 176;
r1_xmax = 280;

r1_ymin = 30;
r1_ymax = 185;
   

% ROI 2
r2_xmin = 78;
r2_xmax = 133;

r2_ymin = 30;
r2_ymax = 181;



   

%%


[filename, pathname] = uigetfile({'*.*'}, 'Input your stack (.tif)');

avi_filename2=filename;

img_info=imfinfo(fullfile(pathname,filename));
Num_file=length(img_info);

res_folder=fullfile(pathname,[filename '_Results']);

mkdir(res_folder);
mkdir(res_folder,'PIV velocity text');
mkdir(res_folder,'PIV r1 velocity text');
mkdir(res_folder,'PIV r2 velocity text');
mkdir(res_folder,'PIV quiver image');


for ifile=1:Num_file-1

        f1=imread(fullfile(pathname,filename),ifile);
        f2=imread(fullfile(pathname,filename),ifile+1);
                       
        [x,y,u1,v1]= matpiv(f1,f2,win_piv,tm_int,0.5,'single'); % matpiv(image1,image2,size of window,time_interval, overlap, looping for window)
       
        u=pxl_sz*u1;   % x, y, u1, v1 => matrix
        v=pxl_sz*v1;  
       
       
  % ~~~~~~~~~~~~~~~~~~~~~~       Filter and interpolate      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
        v(isnan(v))=0;  u(isnan(u))=0;      % Make NaN values = 0        
       
        [lu,lv]=localfilt(x,y,u,v,2,'median');
        [fu,fv]=naninterp(lu,lv,'weighted');
        u=fu;  
        v=fv;   % fu, fv => matrix            
   
       
  % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~     Get x,y,u,v vector    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 
        xx=x(:);  yy=y(:);  % xx, yy, uu, vv => vector
        uu=u(:);  vv=v(:);
               
        zz=sqrt((uu.^2)+(vv.^2));
                       
        temp_mat=[xx,yy,uu,vv];
               
        csvwrite(fullfile(res_folder,'PIV velocity text',[avi_filename2 '_' num2str(ifile),'.txt']), temp_mat);    
       
   
       
   % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~     Get x,y,u,v of roi  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
        % ROI 1
       
        idx_r1 = find(xx<=r1_xmax & xx>=r1_xmin & yy<=r1_ymax & yy>=r1_ymin);
       
        xx_r1 = xx(idx_r1);
        yy_r1 = yy(idx_r1);
        uu_r1 = uu(idx_r1);
        vv_r1 = vv(idx_r1);
       
        csvwrite(fullfile(res_folder,'PIV r1 velocity text',[avi_filename2 '_' num2str(ifile),'.txt']), [xx_r1,yy_r1,uu_r1,vv_r1]);
       
        abs_avg_uu_r1(ifile) = abs(mean(uu_r1));
        abs_avg_vv_r1(ifile) = abs(mean(vv_r1));
       
       
        % ROI 2
       
        idx_r2 = find(xx<=r2_xmax & xx>=r2_xmin & yy<=r2_ymax & yy>=r2_ymin);
     
        xx_r2 = xx(idx_r2);
        yy_r2 = yy(idx_r2);
        uu_r2 = uu(idx_r2);
        vv_r2 = vv(idx_r2);
       
        csvwrite(fullfile(res_folder,'PIV r2 velocity text',[avi_filename2 '_' num2str(ifile),'.txt']), [xx_r2,yy_r2,uu_r2,vv_r2]);
         
        abs_avg_uu_r2(ifile) = abs(mean(uu_r2));
        abs_avg_vv_r2(ifile) = abs(mean(vv_r2));
   
               
   % ~~~~~~~~~~~~~~~~~~~~~~~~~~~        Quiver plot        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
        xx(~vv)=0;  yy(~uu)=0;    % Removing null zeros during ploting  
        scaled_quiver2(xx,yy,uu,vv,f1);
        set(gcf, 'Position', get(0,'Screensize'));
        print('-dtiffnocompression','-r300',fullfile(res_folder,'PIV quiver image',[num2str(ifile),'.tif']));
        close all;
     
           
end


% ~~~~~~~~~~~~~~~~~~~~~~~~~~~        Scale bar        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cmap = jet(36); % 1:35 level , define a color map with 35 levels
rgb_cmap = reshape(flipud(cmap),[length(cmap) 1 3]);

figure;
imagesc(rgb_cmap);
x_y_w_h1=get(gcf,'Position');
x_y_w_h2=get(gca,'Position');
x_y_w_h1(3)=150;
x_y_w_h2(3)=0.2;
x_y_w_h2(1)=x_y_w_h2(1)+0.25;
set(gcf,'Position',x_y_w_h1);
set(gca,'Position',x_y_w_h2);
set(gca,'XTickLabel','');
set(gca,'TickLength', [0 0]);
set(gca,'YTick',1:36);
set(gca,'YTickLabel',{num2str(max_sp_dsply),'','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','0'});

clrbar=getframe(gcf);
imwrite(clrbar.cdata,fullfile(res_folder,'PIV quiver image','scale bar.tif'));
 
xlswrite(fullfile(res_folder,'PIV quiver image','Absolute average u & v for r1 & r2.xlsx'),{'Frame','abs_avg_uu_r1','abs_avg_vv_r1','abs_avg_uu_r2','abs_avg_vv_r2'},1,'A1');
xlswrite(fullfile(res_folder,'PIV quiver image','Absolute average u & v for r1 & r2.xlsx'),[[1:Num_file-1]' abs_avg_uu_r1' abs_avg_vv_r1' abs_avg_uu_r2' abs_avg_vv_r2'],1,'A2');

close all;

William William
Reply | Threaded
Open this post in threaded view
|

Re: Downloaded PIV .zip, but soem functions seem to be missing

This is the PIVlab forum, it looks like you are looking for a tool called 'matpiv'.
I suggest that you download PIVlab instead, because it is easier to use as matpiv.

Please consider donating for the PIVlab project:
http://paypal.me/pools/c/81Y8wBVi4y

The developer needs to update to a recent Matlab release in order to keep the project running.