Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

tracks_neighbor_features.py 1.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  1. import numpy as np
  2. def find_clathrin_neighbors(tracks, tracks_by_frame, distance, norm_ord):
  3. """
  4. function that populates the "neighbors" attribute of all clathrin signals
  5. Input:
  6. tracks, tracks_by_frame: output of read_tracks
  7. distance: float
  8. norm_ord: np.inf or int
  9. this will be used for the ord argument of np.linalg.norm
  10. np.inf corresponds to square patches
  11. Output:
  12. list of tracks, for each clathrin signal in each track, this computes all neighbors of that signal within distance
  13. (in norm_ord norm) smaller than elements in the "distance" argument
  14. """
  15. distance = [dist for dist in distance if dist not in tracks[0].clathrin_signals[0].neighbors]
  16. for track in tracks:
  17. for signal in track.clathrin_signals:
  18. for dist in distance:
  19. signal.neighbors[dist] = []
  20. for ss in tracks_by_frame[signal.frame]:
  21. ds = np.linalg.norm(np.array((signal.x - ss['cla'].x, signal.y - ss['cla'].y)),
  22. ord=norm_ord)
  23. for dist in distance:
  24. if ds <= dist and ds > 0.01:
  25. signal.neighbors[dist].append(ss['cla'])
  26. return tracks
  27. #def num_of_neighbors(tracks, tracks_by_frame, distance, norm_ord):
  28. #to be finished...
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...