A device (20) for treating a medical condition is provided, and a surgical
procedure for implanting the device is disclosed. The device (20)
includes a sensor (44), which is adapted to generate a signal responsive
to a state of a patient, and at least one electrode (27), which is
adapted to be coupled to a pelvic site of the patient. A control unit
(22) is adapted to receive the signal, to analyze the signal so as to
distinguish between an imminent stress incontinence event and an imminent
urge event, and, responsive to analyzing the signal, to apply an
electrical waveform to the at least one electrode (27). In various
configurations, the device (20) may be used alternatively or additionally
to treat fecal incontinence, interstitial cystitis, chronic pelvic pain,
or urine retention.