function tracks = trim(obj, tracks)
	% trim(obj, tracks)
	% trim track objects down to region where they are valid

	n_tracks = length(tracks);
	fields   = fieldnames(tracks);
	n_fields = length(fields);

	for n = 1 : n_tracks
		%% get range of valid data
		trk = tracks(n);
		i0  = find(~trk.ext, 1, 'first');
		i1  = find(~trk.ext, 1, 'last');

		rng = i0 : i1;
		%% trim flags
		trk.t	= trk.t(1, rng);
		trk.ext = trk.ext(1, rng);
		trk.oob = trk.oob(1, rng);

		%% trim additional fields
		for f = 1 : n_fields
			field = fields{f};
			if startsWith(field, 're_') || startsWith(field, 'im_')  || startsWith(field, 'fl_')
				trk.(field) = trk.(field)(:,:,rng);
			end
		end

		%% save
		tracks(n) = trk;
	end
end