*This directory contains Python scripts and intermediate data files used for analysis and to produce figures for the manuscript.*

*Please check the GitHub repo for the most up to date version of this code/instruction*: https://github.com/JJ473/BOE\_multiview\_SPIM\_PIV

##### **Standard analysis procedure using the Multiview SPIM PIV Python directory**

1. Modify config.py to include the correct file paths to the dataset, and relevant image acquisition parameters (e.g. z-stack height, separation between z-planes etc.)
2. Use remove dark frames.py to remove blank images from the dataset (caused by rare occasions where the camera could not trigger successfully). Note this does not modify image data, it only flags blank images in their metadata so they are ignored in the analysis.
3. Use ssim registration.py to measure the phase and spatial shift between the two z-stacks from two sample orientations, and record the interim stack registration parameters to be used as initial values for the chi2 registration. (Optionally, use the interactive widget in spatial registration.py to see how stacks are spatially registered)
4. Use chi2registration.py to perform stack registration by comparing the vertical velocities from two stacks. Optimise registration parameters using initial values measured from ssim registration.
5. Update relevant parameters in config.py to the optimised parameters. Then use 3D field generate.py to produce a snapshot of 3C-3D blood flow vector field at a certain phase of the heartbeat (by default, this is controlled by stack\_phase, which represents the heart phase of the first z-stack). The complete vector field (and two snapshots used for visualisation) are already computed and stored in field\_map\_complete and field\_map\_snapshot.
6. Each snapshot of vector field is stored in a single file, containing 3 arrays of vector positions, 3 arrays of velocity and 3 arrays of velocity uncertainty. They can be visualised using 3D field render.py and 3D field visualisation.py. They produce the 3D Mayavi render of the vector field and the orthogonal cross sectional views of the vector field superimposed on the heart wall images.



\*\*note that mostly standard Python packages are required for this directory, only the calculation of absolute differences is performed using a custom package by J. M. Taylor, available at https://github.com/jmtayloruk/py\_sad\_correlation. This was used to speed up the computation time, but the equivalent result can also be calculated using just NumPy.









**In addition to the analysis procedure, the specific scripts used to produce figures are:**

Fig.4 left - intersection visualisation.py

Fig.4 right - 3D stack intersection visualisation.py



Fig.5 - bootstrap demonstration.py



Fig.7 left - 2D visualisation of MVF.py



Fig.7 right, 8 - chi2registration.py



Fig.9 - 3D field render.py



Fig.10,11 - 3D field visualisation.py



\*\*note Fig. 9, 10, 11 requires gfp zstacks produced from generate gfp zstack.py. It produces a single zstack with each plane containing one image, at one phase of heartbeat. This makes visualisation much quicker without having to construct stack every time. Examples of constructed stack visualised in figures are stored with the dataset.

