load_tracks

lumicks.pylake.load_tracks

load_tracks(filename, kymo, channel, delimiter=';')

Loads a KymoTrackGroup from a csv file.

The file format contains a series of columns as follows: track index, time (pixels), coordinate (pixels), time (optional), coordinate (optional), sampled_counts (optional), minimum length

Note

If you processed (e.g. cropping, flipping, downsampling) the kymograph prior to tracking, you will have to make sure that you crop the kymograph you supply to this function in the same way.

Parameters:
  • filename (str | os.PathLike) – filename to import from.

  • kymo (Kymo) – Kymograph that the CSV data was tracked from. This kymograph has to be the one used to create the tracks (this includes any processing). See the note above for more information.

  • channel (str) – color channel that was used for tracking.

  • delimiter (str) – The string used to separate columns.

Returns:

kymotrack_group – Tracked kymograph lines that were stored in the file.

Return type:

KymoTrackGroup

Raises:

ValueError – If the file format is not as expected.

Examples

import lumicks.pylake as lk

file = lk.File("test_data/kymo.h5")
kymo = file.kymos["16"]  # Extract the kymo named 16

kymo_cropped = kymo.crop_by_distance(10, 25)
tracks = lk.track_greedy(kymo_cropped, channel="red", pixel_threshold=5)
tracks.save("tracks.csv")

loaded_tracks = lk.load_tracks("tracks.csv", kymo_cropped, "red")

# Plot the red channel of the kymograph and tracks together
kymo_cropped.plot("red", adjustment=lk.ColorAdjustment(5, 95, "percentile"))
loaded_tracks.plot()