denisecailab / ezTrack

Free, platform independent, behavior tracking software.
GNU General Public License v3.0
118 stars 41 forks source link

ROI #41

Closed LeaRoyon closed 2 years ago

LeaRoyon commented 2 years ago

Hello,

I managed to used this code to track the animal in the whole box. However, when I draw ROIs, I have a KeyError. I named my ROIs: 'region_names' : ["start","middle","reward"], and I drew them. But compared to the video explaining ezsTrack, when I draw my region, the name is not written inside my square.

This is the error that I get when I run the cell:

 location = lt.TrackLocation(video_dict, tracking_params)
 location.to_csv(os.path.splitext(video_dict['fpath'])[0] + '_LocationOutput.csv', index=False)
 location.head()

KeyError Traceback (most recent call last)

in ----> 1 location = lt.TrackLocation(video_dict, tracking_params) 2 location.to_csv(os.path.splitext(video_dict['fpath'])[0] + '_LocationOutput.csv', index=False) 3 location.head() ~\ezTrack\LocationTracking_Functions.py in TrackLocation(video_dict, tracking_params) 784 785 #add region of interest info --> 786 df = ROI_Location(video_dict, df) 787 if video_dict['region_names'] is not None: 788 print('Defining transitions...') ~\ezTrack\LocationTracking_Functions.py in ROI_Location(video_dict, location) 1148 #Create ROI Masks 1149 ROI_masks = {} -> 1150 for poly in range(len(video_dict['roi_stream'].data['xs'])): 1151 x = np.array(video_dict['roi_stream'].data['xs'][poly]) #x coordinates 1152 y = np.array(video_dict['roi_stream'].data['ys'][poly]) #y coordinates KeyError: 'roi_stream'
ZachPenn commented 2 years ago

I am a bit confused by your situation. You say that that the names of the regions are not showing up when you draw them (Cell 6), but then report an error from Cell 8c. Are you drawing the regions on the output to Cell 6? The subsequent error in Cell 8c will occur if you have not drawn any of the regions in Cell 6.

LeaRoyon commented 2 years ago

Yes I was able to draw them but the code wouldn't recognize that it was there. I am not sure what happened but I upgraded my version of jupyter notebook and now it works! Thank you for the answer