A surgical instrument, in particular a surgical cutting or drilling instrument, the surgical instrument comprising: - a drive unit; - a cutting tool or drill bit engageable with the drive unit; - a measuring device attached to or integral with the surgical instrument, wherein the measuring device is configured to measure the distance [x(t)] covered by the cutting tool or drill bit along a cutting or drilling path with respect to time and relative to a reference position; said surgical instrument being characterized in that it further comprises - a processing unit electronically directly or wirelessly connected to the measuring device and suitably programmed to record a graph G of the distance [x(t)] covered by the cutting tool or drill bit relative to the reference position and with respect to time during a cutting or drilling process; and - a digital data storage, in the digital data storage reference data are stored which include at least one data set specifying a reference graph G Ref of the distance [x(t)] covered by a cutting tool or drill bit with respect to time and within a time window in the range of a transition of the cutting tool or drill bit from a first medium having a first density to a second medium having a different second density during a cutting or drilling process, wherein the at least one reference graph G Ref defines a reference point of a transition of the cutting tool or drill bit from a first medium to a second medium; and wherein the time window includes a first time period before the reference point of a transition and a second time period after the reference point of a transition; and the processing unit is suitably programmed to compare the recorded graph G with the at least one reference graph G Ref by means of a similarity measure to quantify the agreement between the recorded graph G or at least one portion of the recorded graph G and the at least one reference graph G Ref to find the position of a transition in the recorded graph G. - a drive unit; - a cutting tool or drill bit engageable with the drive unit; - a measuring device attached to or integral with the surgical instrument, wherein the measuring device is configured to measure the distance [x(t)] covered by the cutting tool or drill bit along a cutting or drilling path with respect to time and relative to a reference position; said surgical instrument being characterized in that it further comprises - a processing unit electronically directly or wirelessly connected to the measuring device and suitably programmed to record a graph G of the distance [x(t)] covered by the cutting tool or drill bit relative to the reference position and with respect to time during a cutting or drilling process; and - a digital data storage, in the digital data storage reference data are stored which include at least one data set specifying a reference graph G Ref of the distance [x(t)] covered by a cutting tool or drill bit with respect to time and within a time window in the range of a transition of the cutting tool or drill bit from a first medium having a first density to a second medium having a different second density during a cutting or drilling process, wherein the at least one reference graph G Ref defines a reference point of a transition of the cutting tool or drill bit from a first medium to a second medium; and wherein the time window includes a first time period before the reference point of a transition and a second time period after the reference point of a transition; and the processing unit is suitably programmed to compare the recorded graph G with the at least one reference graph G Ref by means of a similarity measure to quantify the agreement between the recorded graph G or at least one portion of the recorded graph G and the at least one reference graph G Ref to find the position of a transition in the recorded graph G. the at least one reference graph G Ref defines a reference point of a transition of the cutting tool or drill bit from a first medium to a second medium; and wherein the time window includes a first time period before the reference point of a transition and a second time period after the reference point of a transition; and the processing unit is suitably programmed to compare the recorded graph G with the at least one reference graph G Ref by means of a similarity measure to quantify the agreement between the recorded graph G or at least one portion of the recorded graph G and the at least one reference graph G Ref to find the position of a transition in the recorded graph G.