Open wheelern opened 5 years ago
You are right it is probably that parameter. We normally used quite high frame rate and I have a hard threshold to reject large jumps between frames. It is probably easier if you can share the video.
I realize that with such a low frame rate and resolution many of the measured behavioral features will be unreliable, but I would still like to get tracks and midpoint velocity metrics. Video attached.
I was able to get it to recognize worms using the attached parameters, but when i go to get features all of the worms have frac_valid_skels == 0, so the features aren't calculated. It also errors out if I have "Use manually edited trajectories?" set to True (error is printed below). I'm not sure what the issue could be...
Extracting features summary. File 0 of 1 done. Total time: 0:00:00 Traceback (most recent call last): File "/Users/njwheeler/software/miniconda3/envs/tierpsy/lib/python3.6/site-packages/tierpsy/gui/AnalysisProgress.py", line 62, in run self.worker_fun(**self.worker_args) File "/Users/njwheeler/software/miniconda3/envs/tierpsy/lib/python3.6/site-packages/tierpsy/summary/collect.py", line 83, in calculate_summaries df = summary_func(fname) ValueError: No objects to concatenate
Hello,
The issue seems to be really that the worms move too much between frames traj_max_allowed_dist
to 500 and it seems to be working but i am not sure how reliable is the trajectory linkage at that low frame rate.
The real problem is that with that resolution the skeletonization algorithm will simply fail. We investigate that in the Fig S3 on the Nat Meth paper. Since must of the features rely on the presence of an skeleton, the only once that will be calculate are the blob features (blob_*). This include area, perimeter, length, width, solidity, compactness and the hu moments, and its derivatives. However, it does not include speed or orientation, neither information about the path.
It would not be too far fetch to modify the code (at least tierpsy features) to calculate more sophisticated features without the skeletonization (@aexbrown suggest it at some moment), however it is definitely not in the current pipeline. @luigiferiani do you know if somebody would be interested?
Cheers Avelino
We're having a Tierpsy hackathon in mid December and improving the support of low res videos is on the list of things to work on. So we might have a significant update in December or January that will help but no guarantees since the list of things for the hackathon is already pretty long.
I understand, thanks for looking into it.
In the end, for this assay I'm only interested in the paths, and I can probably get what I need from the HDF5 results now that the worms are correctly identified. I assume that the trajectory/coordinate data is there even if it doesn't pass tests for skeletonization.
In that case you can do something like this:
import pandas as pd
fname = 'PATH_TO_featuresN.hdf5'
fid = pd.HDFStore(fname, 'r')
trajectories_data = fid['trajectories_data']
delta_time = 1
velocities = []
for w_index, w_data in trajectories_data.groupby('worm_index_joined'):
x = w_data['coord_x']
y = w_data['coord_y']
worm_velocity = np.sqrt((x[:-delta_time] - x[delta_time:])**2 +
y[:-delta_time] - y[delta_time:])**2)
velocities.append(worm_velocity)
velocities_stats = np.percentiles(np.concatenate(velocities), [10, 50, 90])
I am trying to optimize parameters for recording a full 10 cm plate for 1 hr with images taken every 10 s. So the worms are quite small and the distance between a given worm in frame N and frame N + 1 is quite large. The parameters I have now work quite well for generating the mask, but after analysis the worms aren't recognized and identified as worms and thus no tracks are created. I am only analyzing 5-8 worms per plate, so I don't think crowding is an issue. I suspect I will have to edit some of the hidden parameters (perhaps traj_max_allowed_dist?). Do you have any suggestions for where to start?
I have a 76 frame (235 MB) AVI that I can send for testing, if you'd like.