A method is for controlling a system including an imaging modality. The method includes receiving an image and/or a series of images of a portion of a patient from the imaging modality, the field of view of the image and/or of the series of images covering at least a part of an instrument determining whether the part of the instrument is located within a defined portion of the field of view and/or in a given state selected from a plurality of first states and/or the part of the instrument executes a given movement selected from a plurality of movements and generating a control command for performing an action depending on whether the part of the instrument is located within the defined portion of the field of view and/or the part of the instrument is in the given state and/or the part of the instrument executes the given movement.