Surgical phase recognition by learning phase transitions