Skip to content

Commit

Permalink
added fiber tracking and tested using Shooka Karimour's data
Browse files Browse the repository at this point in the history
  • Loading branch information
ronshnapp committed Oct 20, 2023
1 parent ac7d3a4 commit 422a9ce
Show file tree
Hide file tree
Showing 13 changed files with 569 additions and 345 deletions.
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
December 25, 2022
Version: 0.6.5
Version: 0.7.0

<img src="./user_manual/figs/logo.png" style="zoom:20%;" />

Expand Down Expand Up @@ -29,6 +29,7 @@ MyPTV is designed to be used by scientists and engineers who need to track the t
6) Tracking particles in 2D
7) Smoothing particle trajectories while calculating their velocities and accelerations
8) Re-connecting broken trajectories
9) Measuring the orientations of anisotropic particles in 3D (new from version 7.0.0 and on)

## How to install?

Expand Down
12 changes: 4 additions & 8 deletions example/params_file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
images_folder: Images_cam1
single_image_name: cal2.tif
image_extension: '.tif'
shape: particles
mask: 1.0
ROI: 227, 1050, 120, 920
plot_result: True
Expand All @@ -24,7 +25,7 @@
max_ysize: 15.0
max_mass: None
method: labeling
particle_size: 8
particle_size: 8
save_name: test

- matching:
Expand Down Expand Up @@ -73,7 +74,6 @@
max_distance: 0.4
save_name: trajecotries_stitched


- 2D_tracking:
blob_file: blobs_cam1
frame_start: 0
Expand All @@ -85,24 +85,20 @@
dv_max: 1.0
save_name: trajectories_2D


- manual_matching_GUI:
cameras: [cam1, cam2, cam3]
images: [./Images_cam1/01.tif, ./Images_cam2/01.tif, ./Images_cam3/01.tif]


# This is for fiber orientations, developed by Eric Aschari
- orientations:
- fiber_orientations:
camera_names: cam1, cam2
cam_resolution: 1248, 1248
blob_files: blobs_cam1_direction, blobs_cam2_direction
fibers_file: particles
trajectory_file: trajectories
save_name: fiber_orientations


# Future preparation for adding external functionalities
- run_extension:
path_to_extention: the_absolute_path_to_the_script_containing_the_code
action_name: the_name_of_the_class_that_needs_to_run
extention_params_file: the_path_to_the_extentions_params_file

329 changes: 225 additions & 104 deletions example/workflow.py

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions myptv/fibers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
"""
Created on Sun March 20 2020
@author: ron
MyPTV init file
"""




File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def get_blobs(self):

stamp_y, stamp_x = meshgrid(range(self.im.shape[1]),
range(self.im.shape[0]))

for blob in range(len(blob_pixels)):

index = np.argwhere(self.labeled == blob+1)/1.0
Expand Down Expand Up @@ -410,10 +410,11 @@ def apply_blobs_size_filter(self):

if self.mass_limits[0] is not None:
fltr = lambda b: b[2] > self.mass_limits[0]
self.blobs = list(filter(fltr, self.blobs))

if self.mass_limits[1] is not None:
fltr = lambda b: b[2] < self.mass_limits[1]

self.blobs = list(filter(fltr, self.blobs))


def plot_blobs(self, vmin=None, vmax=None):
Expand Down
24 changes: 23 additions & 1 deletion myptv/imaging_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

import os
from math import sin, cos
from numpy import zeros, array, dot
from numpy import zeros, array, dot, transpose
from numpy.linalg import inv
from myptv.utils import line_dist, point_line_dist

Expand Down Expand Up @@ -229,6 +229,28 @@ def get_r(self, eta, zeta):
return r


def get_r_ori(self, u): # from Eric
'''
A function used for the orientation of fibers, written
by Eric Aschari.
input - pixel coordinates (eta, zeta) seen by the camera
output - direction vector in real space
'''

eta = u[0,0]
zeta = u[1,0]

Z3 = [eta, zeta, eta**2, zeta**2, eta * zeta]

e = dot(self.E, Z3)

r = dot(array([-eta, -zeta, -self.f]) - e, self.R) # previously with - before eta_ and zeta_
r = r / (r[0]**2 + r[1]**2 + r[2]**2)**0.5

return transpose(array([self.O + r]))


def projection(self, x, correction=True):
'''
will return the image coordinate (eta, zeta) of a real point x.
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

setup(
name='myptv',
packages=find_packages(include=['myptv']),
version='0.6.5',
packages=find_packages(include=['myptv', 'myptv.fibers']),
version='0.7.0',
description='A 3D Particle Tracking Velocimetry library',
install_requires=['numpy', 'scipy', 'scikit-image','pandas','matplotlib','pyyaml', 'tk', 'Pillow'],
author='Ron Shnapp',
Expand Down
152 changes: 78 additions & 74 deletions user_manual/user_manual.aux

Large diffs are not rendered by default.

Loading

0 comments on commit 422a9ce

Please sign in to comment.