Using tools with animation

I have created a plot that uses a simple loop to animate a video using images of each frame. The updating happens in:

data = source.get(‘data’);

setInterval(function() {

data[‘image_data’] = [frames[i++ % num_frames]];

source.trigger(‘change’);

}, 100);

I would like to use the lasso selection tool to draw a region of interest, but the tools seem to be reset every time the image is re-rendered. Is there anyway to bypass this?