<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Use-case
Step1:  Storing of video data
Step2:  Tracking data
Step3:  Addtional Information
<ASSISTANT_TASK:>
Python Code:
import nixio as nix
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
from utils.notebook import print_stats
from utils.video_player import Playback
nix_file = nix.File.open('data/tracking_data.h5', nix.FileMode.ReadOnly)
print_stats(nix_file.blocks)
b = nix_file.blocks[0]
print_stats(b.data_arrays)
print_stats(b.multi_tags)
Explanation: Use-case: Fish tracking
Classical conditioning experiments of weakly electric fish Apteronotus albifrons
-- Benda Lab, University of Tübingen, Germany --
Context:
Fish are trained to choose one electical stimulus.
Trials are videotaped @25Hz using an IR camera.
Fish are tracked, position and orientation extracted.
End of explanation
video = [a for a in b.data_arrays if a.name == "video"][0]
fig = plt.figure(facecolor='white', figsize=(1024 / 90, 768 / 90), dpi=90)
pb = Playback(fig,video)
pb.start()
Explanation: Storing of video data:
Movies are, depending on the number of color channels, stored as 3D, respectively 4D DataArrays.
End of explanation
# get the tag linking tracking and video data
tag = [t for t in b.multi_tags if t.name == "tracking"][0]
fig = plt.figure(facecolor='white', figsize=(1024 / 90, 768 / 90), dpi=90)
pb = Playback(fig, video, tracking_tag=tag)
pb.start()
Explanation: Tracking data:
Tracking data is stored as positions in the 4D Matrix, the fourth dimension specifies the time (frame) at which an objkect was tracked. Link between video data and position data is established using a MultiTag entity.
End of explanation
fig = plt.figure(facecolor='white', figsize=(1024 / 90, 768 / 90), dpi=90)
pb = Playback(fig, video, tracking_tag=tag, show_orientation=True)
pb.start()
nix_file.close()
Explanation: Addtional Information:
During tracking additional information, i.e. the fish's orientation, is gathered. For each position there is also an orientation. This information is stored as a Feature of the tracking.
End of explanation
<END_TASK>