I'm currently trying to use the Python package trackpy and pims to track the position of certain particles in a fluid. I have .tiff files for each frame of the particle movement.
import numpy as np
%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy.ndimage.interpolation import zoom
import pandas as pd
import trackpy as tp
import pims
from scipy.optimize import curve_fit
v = pims.ImageSequence('Capture_*.tiff')
v = pims.as_grey(v)
f = tp.locate(v[0], 5, minmass=20, maxsize=3, invert=True)
f = tp.batch(v[:], 5, minmass=20, maxsize=3, invert=True)
I'm using the tp.batch function to locate the particles of each frame. However, when I do that I get the error below. I'm unsure how to fix this issue. I've noticed that if I rerun the function I get the error at a different frame each time.
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/var/folders/xj/cw6n24v100l7s1rkm85p4qym0000gn/T/ipykernel_3149/1176320070.py in
----> 1 f=tp.batch(v[:], 5, minmass=20, maxsize=3, invert=True)
~/opt/anaconda3/envs/APL_BM_env2/lib/python3.7/site-packages/trackpy/feature.py in batch(frames, diameter, output, meta, processes, after_locate, **kwargs)
555 try:
556 all_features = []
--> 557 for i, features in enumerate(map_func(curried_locate, frames)):
558 image = frames[i]
559 if hasattr(image, 'frame_no') and image.frame_no is not None:
~/opt/anaconda3/envs/APL_BM_env2/lib/python3.7/multiprocessing/pool.py in next(self, timeout)
746 if success:
747 return value
--> 748 raise value
749
750 __next__ = next # XXX
OSError: [Errno 9] Bad file descriptor