Assistance with openPIV 3D

116 views
Skip to first unread message

Sid Dcosta

unread,
Aug 11, 2023, 1:25:03 PM8/11/23
to openpiv-users
Hi,

We are researchers wanting to apply the python OpenPIV library to our 3D gel bead dataset. We have 35 before and after slices at different Z depths, each of which is 1024x768 pixels in TIFF format. When we apply the "extended_search_area_piv3D" function on the array stacks, and visualize the output with the "quiver_3D" system, we get a messy result as shown below:

image.png

We are primarily following this 3D tutorial. We have also attempted using the OpenPIVGUI module, but it constantly states: "Failed to Process Image Pair(s)". Can you provide some guidance on how to create a navigable output?

Best regards,
Siddharth D'costa
Taaha Khan

Ivan Nepomnyashchikh

unread,
Aug 11, 2023, 1:56:14 PM8/11/23
to openpiv-users
Hello Siddharth and Taaha,
I can't see your image, I think you didn't attach it properly.
Also, I'm wondering if you converted your .tiff images with the function openpiv.tools.convert_16bits_tif. I used to have problems with .tiff format.
I'm also wondering about your research (if it is not a secret). My lab mates are playing with gel beads, that's is why I'm curious about your work.
Ivan

Sid Dcosta

unread,
Aug 11, 2023, 3:21:14 PM8/11/23
to openpiv-users
Hi Ivan,
Sorry about that, here is the updated image:

unnamed.png

We are interns at OHSU in Portland and the gist of the experiment was that we introduced a cell into a gel tray scattered with the beads and we intend to measure the displacement of each bead after introduction of the cell. Here is a before and after pair:

BEFORE
Screenshot 2023-08-11 121700.png

AFTER
Screenshot 2023-08-11 121833.png

One side questions we had was if you could provide some guidance if there is a specific function required to convert to grayscale within this package when we attach the data.

I'd be happy to link our paper once it is published if you are interested.

Thanks for your time,
Siddharth D'costa

Ivan Nepomnyashchikh

unread,
Aug 11, 2023, 4:35:59 PM8/11/23
to openpiv-users
So, we are neighbors!
I'm studying "down the road" from you, at OSU in Corvallis. Will be happy to help fellow oregonians!

First, I need to acknowledge that I'm doing classical fluid mechanics and I don't have experience with biological flows. I'm having hard time understanding how you conducted your experiment. In particular I don't understand what a "gel tray scattered with the beads" mean. I assume, though, that you are working with a living one-cell microorganism flowing in a viscous gel in some tray. I also assume that your "beads" mean very small particles - which we call PIV particles - which you put in your gel to visualize the flow around your cell.

Now we need to determine what kind of PIV you, actually, did.

If you did - what is called - microPIV, it is whole other story. Note that microPIV doesn't mean that you are working with micro objects, it means that you don't have a light sheet and you are illuminating your entire flow at once.

On the other hand, you wrote that you have 35 slices along z axis. That tells me you did regular PIV, not microPIV.

Now we need to figure out if you really did 3D PIV. Note that 3D PIV doesn't mean that you have many slices along some direction. It is whole other story. 3D PIV is an umbrella name for several special experimental techniques allowing you to obtain 3D velocity vectors at every point in your field. 3D PIV requires its own data-processing functions.

If you have several slices, it doesn't necessarily mean that you did 3D PIV. It means that you did regular 2D PIV at each slice. That being said, note, that there is a way to do 3D PIV using slices but there are several conditions there, one of which is to have a sufficiently small distance between the slices.

Let me assume that you didn't have a sufficiently small distance between your slices. That assumption leads to another assumption: you did regular 2D PIV at every slice.

In this case, you don't need to use OpenPIV 3D capabilities. You can simply use the most basic and easiest OpenPIV function to analyze each of your slices.

Having analyzed them, create a 3D matplotlib.pyplot figure and use python's for loop to quiver plot each of your slice on the same figure.

To do a regular most basic 2D PIV analysis of each of your slices, you can follow this tutorial, for instance: https://openpiv.readthedocs.io/en/latest/src/tutorial1.html . At the end of that tutorial don't do tools.display_vector_field. Instead combine your x, y, u3,v3 into a numpy array. Get such an array for each slice. Either stack those arrays into one big array or keep them in a python list. Use for loop to iterate through it to quiver plot your velocity fields.

With regards to gray-scaling your images, OpenPIV can handle that automatically. I, personally, always do that manually, just to make sure. For that, use opencv python library. Load your image using cv2.imread function like that :
cv2.imread(str(pair[0]), 0) # 0 flag reads in gray scale; str(pair[0]) is the path to your PIV pair of images;
# this function returns an image as a numpy array

Ivan Nepomnyashchikh

unread,
Aug 11, 2023, 4:49:36 PM8/11/23
to openpiv-users
Also, let me point out a couple of other things.

2D PIV gives us 2D velocity vectors: it can only measure components of velocity within the plane of the laser sheet. It cannot give us the out of plane component of velocity. So, if you do as I suggested, you will have your slices with velocities within the slices, you will not get the 3rd - out of plane - velocity component.

In order to get the out of plane velocity component, you have to set up your experiment in a special manner. And I don't know if your experimental setup is suitable to give you fully 3D velocity vectors.

Last thing I wanted to mention is that PIV is a very difficult skill to get. It took me more than a year before I started feeling somewhat comfortable with doing the most basic PIV experiments and analyses. Don't think that OpenPIV can magically give you results with one button push. You have to know all the theory and have experience to do a valid PIV experiment and analysis. The same is absolutely true for commercial PIV packages.

Ivan

Ivan Nepomnyashchikh

unread,
Aug 11, 2023, 4:55:32 PM8/11/23
to openpiv-users
Also, the tutorial you have cited is from 2020. Last autumn OpenPIV was updated to a new version which is not compatible with the older versions (i.e. it is not backward compatible). That is why the functions shown in your tutorial may not work. You need to check your OpenPIV version: if it is 0.25.0 or higher, it is not backward compatible and your tutorial should be corrected for your version of OpenPIV.
Probably the easiest way will be to create a new anaconda environment and install a 2020 OpenPIV version (actually, any version before 0.25.0 should work, I would suggest 0.24 version). In that new anaconda environment, try running your code and see if it works.

Alex Liberzon

unread,
Aug 11, 2023, 9:44:13 PM8/11/23
to openpiv-users
Could you please share a small sample of your data, so we could try to test the algorithm? 

Taaha Khan

unread,
Aug 15, 2023, 12:02:31 AM8/15/23
to openpiv-users
Hi there, I'm one of the other researchers on this project with Siddarth.

Thank you for the detailed notes! Our goal is to apply 3D PIV to the dataset, not 2D on each pair. We need that Z velocity component as well to analyze in the data. I think its also important to note that we ourselves did not do the actual experiment -- that was conducted by others in our team at the lab. Here, we are on the computational side of the project, so we just have to use the data that is provided to us. We have only very recently gotten into the field of PIV, so apologies if our questions might be trivial.

I agree with your concern that there might not be enough Z-slices to accurately apply 3D PIV in our data, considering that the slices were taken on 300-nanometer intervals, and the beads in the gel are around 200 nanometers in diameter. This means that the beads could potentially go out of frame on the Z level, right? I could ask the lab to reproduce the data on shorter Z intervals if that is possible with our setup.

What specifically could we change in the setup to make it easier to deal with? Is there an updated tutorial that applies the newer program for 3D applications? 

Here is a sample of the first 5 layers of the before and after image data: https://github.com/taaha-khan/Particle-Image-Velocimetry-3D/tree/main/data/data-PIV3D-sample
I've also linked some of the code for guidance (it won't work with the sample data though): https://github.com/taaha-khan/Particle-Image-Velocimetry-3D/blob/main/khan-PIV3D-V1.ipynb

The end goal is some displacement maps at high enough fidelity. Thank you for any help!

Ivan Nepomnyashchikh

unread,
Aug 15, 2023, 11:26:54 AM8/15/23
to openpiv-users
Hello Taaha,

I see. With regards to my comment about 3D PIV, let's say that you, really, have 3D PIV data (which means that you really have 3rd velocity component). That condition about sufficiently small distance between the slices I mentioned comes with other conditions (such as cameras arrangement). I think we don't need to dig that deep and we can rely on the expertise of the people who actually did the experiment and assume they did everything right.

Answering your question about the updated tutorial. Here's the full list of official OpenPIV tutorials: https://github.com/OpenPIV/openpiv-python-examples/tree/main/notebooks The entire list was updated to the latest OpenPIV version to the best of my knowledge.

I had a closer look at the tutorial you cited in your original question, it looks like it has been updated to the latest OpenPIV version according to the GitHub commit history.

You may want to go through the list and find other notebooks that deal with 3D PIV.

With regards to the small portion of the data set you gave, I think, you'll have to wait till Dr. Liberzon tests the algorithm on it. He is a savior in such cases.
I, personally, haven't played with the 3D algorithm and it will take me way longer to make it work than Dr. Liberzon.

Ivan

Alex Liberzon

unread,
Aug 17, 2023, 6:27:11 PM8/17/23
to Taaha Khan, openpiv-users
hi, 
I tried to run the code, but the 5 layers are not sufficient - it affects the size of the window. I understand that the problem now is mainly related to the size of the window which defines the size of the voxel and this eventually predicts the amount of tracers that can give a proper correlation peak. it's difficult to understand what do we see in 3D, and especially in these 5 layers. It can be an insufficient number of particles, or too large particles, or contrast, or other things. 
Could you visualize the 3D volume you're working with? 

Alex


--
You received this message because you are subscribed to the Google Groups "openpiv-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpiv-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/openpiv-users/f86736fd-90f6-45fd-b5f0-b3e8a70443d5n%40googlegroups.com.

Taaha Khan

unread,
Aug 23, 2023, 12:42:25 AM8/23/23
to openpiv-users
Hello Dr. Liberzon,

Thank you for looking into this, apologies for the delay. 

From what I understand, the issue is with the hyperparameters chosen with regard to du, dv, dw, win_um, fac_overlap, and signoise_filter. We are not familiar with the exact meanings of each of these parameters, so I would appreciate brief descriptions of the properties and how they are affecting the output. What would be the recommended ranges for those parameters for voxel size?

I understand that the small sample that I gave can't accurately gauge the issues, but I cannot share the entire dataset at the moment. How would you want the visualization of the 3D volume? Would you need an array of the stack with points at each of the particles?

Thank you,
Taaha

Alex Liberzon

unread,
Aug 23, 2023, 10:05:28 PM8/23/23
to Taaha Khan, openpiv-users
Hi, 

Beyond what’s written in the tutorial the only thing we could help is to somehow refer to a comparison with the 2D PIV, i.e. learning from our experience in that field. Let’s assume that 3D is just another dimension and everything else is identical in x,y and z directions (which I doubt, as you probably get more resolution in x,y in-plane and less in z- out of plane for confocal, depth direction). In such case, if we assume homogeneity, the important parameters are the window size, overlap and later, the signoise_filter. 
Window size (interrogation window size) is usually 64 x 64 pixels if resolution is reasonable, 32 x 32 if it’s good, and less if it’s excellent super-resolution. The rule of thumb is about 5-10 pairs of bright objects (tracer particle images) in the interrogation window. 
The overlap is more tricky, the typical value is 50% of the window size
The signoise_filter you better set to off first and see what are the values of sig2noise that are reported. Then decide how many percents are removed, it’s an unknown value for the most general case. 1 is probably setting it to off. 

Read the book of Raffel et al. PIV - practical guide, it’s the best source of knowledge. 

Now to the 3D case - it’s difficult to understand how the image is created and therefore how the “tracers” look like, so try some slices to get a better understanding of your images. Probably you could do uneven sizes in x,y,z directions. 


Best regards
Alex


From: openpi...@googlegroups.com <openpi...@googlegroups.com> on behalf of Taaha Khan <taaha...@gmail.com>
Sent: Wednesday, August 23, 2023 12:42:25 AM
To: openpiv-users <openpi...@googlegroups.com>
Subject: Re: [openpiv-users] Re: Assistance with openPIV 3D
 

Sid Dcosta

unread,
Aug 25, 2023, 4:52:17 PM8/25/23
to openpiv-users
Hi Dr. Liberzon

We are now able provide you with our entire dataset which you can access here: https://www.dropbox.com/scl/fi/kp2wiomhwjbuvyvpysidz/8-7For-Taaha-and-Sid.zip?dl=0&rlkey=o8fm26p9aclg9oi7kg1mwc33j. We would really appreciate it if you are able to run the code again this time with all the layers.

Taaha and I also attempted to create a rendering using a window size of 32x32x8 but the output was completely unusable:

image.png

Thanks for your time
Siddharth
Reply all
Reply to author
Forward
0 new messages