Skip to content

Commit

Permalink
workflow correction to BG image
Browse files Browse the repository at this point in the history
  • Loading branch information
ronshnapp committed Oct 23, 2024
1 parent f3d8e8c commit 86ebe30
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
12 changes: 11 additions & 1 deletion example/workflow.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,22 @@ def calculate_BG_image(dirname, extension):

# segmenting the image if there are more than 1 frames
if N_img is None or N_img>1:

if type(remove_BG)==str:
print('\n','using given background image')
BG = imread(remove_BG)*1.0
elif remove_BG==True:
print('\n','calculating background image')
BG = calculate_BG_image(dirname, ext)
else:
BG=False

loopSegment = loop_segmentation(dirname,
particle_size=p_size,
extension=ext,
image_start=image_start,
N_img=N_img,
remove_ststic_BG=remove_BG,
remove_ststic_BG=BG,
sigma=sigma,
median=median,
threshold=threshold,
Expand Down
33 changes: 22 additions & 11 deletions myptv/tracking_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,16 +983,24 @@ def build_trajectories_from_frame(self, frame_num, backwards=False,
If backwards=True then the tracking is backwards in time.
'''

# ensure there are particles to track in this frame number
if frame_num not in list(self.particles.keys()):
return None

# a list to hold trajectories and trajectory particle identifiers
trajs = []

# a list to hold the trajectory noise levels
NSRs = []

# 0) if above 20% of particles in the frame were used, clear them
uf = len(self.used_particles[frame_num])/len(self.particles[frame_num])
if uf > 0.2:
self.clear_used_particles()
if frame_num in list(self.used_particles.keys()):
Nused = len(self.used_particles[frame_num])
Nf = len(self.particles[frame_num])
uf = Nused / Nf
if uf > 0.2:
self.clear_used_particles()

# 1) building trajectories from particles in the given frame number
if backwards==False:
Expand Down Expand Up @@ -1380,14 +1388,17 @@ def smooth_trajectory(traj, Ns):


# Tests:

fname = '/home/ron/Desktop/Research/jetArrayTank/20240821/Rec2/particles'
max_dt = 3
Ns = 11
NSR_th = 0.25
tmf = tracker_multiframe(fname, max_dt, Ns, d_max=0.5, dv_max=0.5, NSR_th=NSR_th)

tmf.track_frames(f0=None, fe=None, frame_skips=5)
if __name__ == "__main__":
fname = '/home/ron/Desktop/Research/jetArrayTank/20241020_puffs/Rec18/particles'
max_dt = 3
Ns = 11
NSR_th = 0.25
tmf = tracker_multiframe(fname, max_dt, Ns, d_max=0.5, dv_max=0.5, NSR_th=NSR_th)

f0 = 134
fe = None
frame_skips = 5
tmf.track_frames(f0=f0, fe=fe, frame_skips=frame_skips)



Expand Down

0 comments on commit 86ebe30

Please sign in to comment.