The invention relates to a method of detecting incipient blood vessel collapse in a circuit comprising means for drainage, preferably a cannula, positioned in said vessel and connected to a pump, characterized in that the incipient vessel collapse is detected by detecting a pre-collapse oscillation state characterized by oscillations of blood pressure of substantially constant frequency and limited amplitude.The invention relates also to a method of optimizing the blood flow of a pump comprising the step of detecting incipient blood vessel collapse, a device, preferably a medical apparatus, configured to carry out the method of the present invention, and to a computer readable storage medium storing a computer program configured to carry out said method.