In your current code you are iterating the frames and use only the last one.
To select each frame you could load the data in the __init__ method (move the data_matrix = ... code there) and select the frame in __getitem__ by using the passed idx:
img = data_matrix[:, :, idx]

(same for the target).