Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracking (Feature) #86

Open
pr4deepr opened this issue Oct 4, 2024 · 0 comments
Open

tracking (Feature) #86

pr4deepr opened this issue Oct 4, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@pr4deepr
Copy link
Collaborator

pr4deepr commented Oct 4, 2024

Ability to read tracking data so moving cells can be processed..

https://napari.org/stable/howtos/layers/tracks.html

Example code for reading into napari:

Get xml file into a format: track_id,t,z,y,x (if not, z, then just id,t,y,x)
example (can optimize this)
Use pandas for saving table as csv

import pandas as pd
#read xml into variable tracks

df = pd.DataFrame.from_dict(tracks).T

#explode trackdata and create a column so each row is the original index value
df = df.explode('trackData').reset_index()

#convert trackData to columns
df[['t', 'x', 'y', 'z']] = pd.DataFrame(df['trackData'].tolist(), index=df.index)
df = df[['index', 't', 'z', 'y', 'x']]
#save as csv without index
df.to_csv('./tracking.csv', index=False)

Read tracking layer into napari (can only be done programmatically)

a = pd.read_csv('tracking.csv',index_col=None)
b = a[['index','t','y','x']]
tracks = np.array(b)
#remember to use scaling when adding tracks so it matches the image scale
viewer.add_tracks(tr, name='tracks',scale=[1,, 0.14499219, 0.14499219])  #(dz,dy,dx)
@pr4deepr pr4deepr added the enhancement New feature or request label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant