Skip to main content
. 2022 Jan 8;22(2):466. doi: 10.3390/s22020466
Algorithm 1 Meal Detection and Estimation Algorithm
Require:X={G,I,M}, ϵ
Ensure: Output meal size, mE
 Initialise model parameters θ from memory
N2
for t28,...,T do
     [yu,ym,yl] f(X|θ)
     Compare yu and yCGM
     Let k be number of samples where yu< yCGM
     if k > N AND ΔBG/Δt ≥ 1 then         ▹ Activate meal detection
          mE0
          errorAbs(ym(t)yCGM(t))
          while error >ϵ AND mE<mMAX do      ▹ Perform meal estimation
              if fine_search then
                  mEmE+1
              else
                  mEmE+10
              end if
              MmE
              [yu,ym,yl] f(X|θ)
              errorAbs(ym(t)yCGM(t))
              if error ϵ then
                  mEmE10
                  Activate fine_search
              end if
              if verify appropriate glucose dynamics then
                  mE0     ▹ Discard meal estimate
                  break
              end if
          end while
     else
           mE0
     end if
end for