{"id":"max_normalized_cross_correlation","title":"Maximum normalized cross-correlation","family":"sliding","definition":"echotime","intro_en":"Maximum NCC finds the global integer shift with the largest normalized cross-correlation. EchoTime first z-normalizes each full series, then uses full-series norms at every lag. The animation shows overlap pairs and the complete lag profile, including the reduced overlap near the boundaries.","intro_zh":"最大 NCC 寻找归一化互相关最大的全局整数平移。EchoTime 先对完整序列分别进行 Z 标准化，再在每个滞后位置使用固定的完整序列范数。动画显示重叠配对与完整滞后曲线，包括边界附近的较短重叠。","steps_en":["Z-normalize both complete series once.","Slide through all integer lags and match only overlapping samples.","Divide each overlap dot product by the same full-series norm product.","Select the largest NCC and record its lag."],"steps_zh":["对两条完整序列分别进行 Z 标准化。","遍历整数滞后，仅匹配重叠样本。","以固定的完整序列范数乘积归一化各重叠点积。","选取最大 NCC 并记录滞后。"],"formula":"max_lag sum_overlap z(x)[i]*z(y)[i-lag] / (||z(x)||_2*||z(y)||_2)","caveats_en":["This is a global shift, not local time warping.","Full-norm zero-padding NCC differs from Pearson or cosine re-normalized on each overlap.","Constant series have undefined statistical correlation; EchoTime retains a zero-NCC convention for zero energy."],"caveats_zh":["这里估计全局平移，不进行局部时间规整。","固定全范数的补零 NCC 与在各重叠片段重新归一化的 Pearson 或余弦不同。","常量信号的统计相关未定义；EchoTime 对零能量保留零 NCC 的约定。"],"sources":[{"label":"EchoTime: ncc_sequence, max_ncc and sbd","url":"https://github.com/ZipengWu365/EchoTime/blob/main/src/echotime/similarity_methods.py"},{"label":"k-Shape original paper: shape-based cross-correlation","url":"https://www.paparrizos.org/papers/PaparrizosSIGMOD15.pdf"}],"x":[0.0,0.1,0.8,2.1,1.4,0.3,-0.2,-0.1,0.1,0.0],"y":[0.0,0.025244129544236896,0.02727892280477045,0.10423360024179602,0.7772959251407622,2.071232271760106,1.391617535054032,0.3197095979615637,-0.17031925260129854,-0.0876364454427473],"input_label":"Deterministic synthetic illustration; sample index is the time axis.","parameters":{"normalize":true,"padding":"zero outside overlap","normalization":"full-series norm product","lags":[-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9],"selected_lag":-2},"result":{"label":"similarity","value":0.9305963101139378,"detail":""},"frames":[{"phase":0,"caption":"Z-normalize each full series once before the lag scan","panel":{"kind":"lines","title":"Global z-normalization, fixed for every lag","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666],"a_label":"x","b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909],"b_label":"y"}},{"phase":0,"caption":"Z-normalize each full series once before the lag scan","panel":{"kind":"lines","title":"Global z-normalization, fixed for every lag","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295],"a_label":"x","b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513],"b_label":"y"}},{"phase":0,"caption":"Z-normalize each full series once before the lag scan","panel":{"kind":"lines","title":"Global z-normalization, fixed for every lag","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808],"a_label":"x","b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782],"b_label":"y"}},{"phase":0,"caption":"Z-normalize each full series once before the lag scan","panel":{"kind":"lines","title":"Global z-normalization, fixed for every lag","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"a_label":"x","b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"b_label":"y"}},{"phase":1,"caption":"Lag -9: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag -9; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[0,9]]},"value":0.0473622780963682,"value_label":"NCC at this lag"},{"phase":1,"caption":"Lag -8: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag -8; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[0,8],[1,9]]},"value":0.09153986957876563,"value_label":"NCC at this lag"},{"phase":1,"caption":"Lag -7: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag -7; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[0,7],[1,8],[2,9]]},"value":0.016908745212421583,"value_label":"NCC at this lag"},{"phase":1,"caption":"Lag -6: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag -6; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[0,6],[1,7],[2,8],[3,9]]},"value":-0.29145751338828363,"value_label":"NCC at this lag"},{"phase":1,"caption":"Lag -5: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag -5; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[0,5],[1,6],[2,7],[3,8],[4,9]]},"value":-0.5188701195040026,"value_label":"NCC at this lag"},{"phase":1,"caption":"Lag -4: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag -4; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[0,4],[1,5],[2,6],[3,7],[4,8],[5,9]]},"value":-0.21711035761622904,"value_label":"NCC at this lag"},{"phase":1,"caption":"Lag -3: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag -3; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[0,3],[1,4],[2,5],[3,6],[4,7],[5,8],[6,9]]},"value":0.49052957357582416,"value_label":"NCC at this lag"},{"phase":1,"caption":"Lag -2: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag -2; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[0,2],[1,3],[2,4],[3,5],[4,6],[5,7],[6,8],[7,9]]},"value":0.9305963101139378,"value_label":"NCC at this lag"},{"phase":1,"caption":"Lag -1: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag -1; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9]]},"value":0.5470463712762678,"value_label":"NCC at this lag"},{"phase":2,"caption":"Lag +0: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag +0; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[0,0],[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9]]},"value":-0.0751440347915077,"value_label":"NCC at this lag"},{"phase":2,"caption":"Lag +1: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag +1; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[1,0],[2,1],[3,2],[4,3],[5,4],[6,5],[7,6],[8,7],[9,8]]},"value":-0.45597650563563424,"value_label":"NCC at this lag"},{"phase":2,"caption":"Lag +2: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag +2; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[2,0],[3,1],[4,2],[5,3],[6,4],[7,5],[8,6],[9,7]]},"value":-0.5090062013168606,"value_label":"NCC at this lag"},{"phase":2,"caption":"Lag +3: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag +3; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[3,0],[4,1],[5,2],[6,3],[7,4],[8,5],[9,6]]},"value":-0.3999215627842331,"value_label":"NCC at this lag"},{"phase":2,"caption":"Lag +4: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag +4; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[4,0],[5,1],[6,2],[7,3],[8,4],[9,5]]},"value":-0.1475491227071923,"value_label":"NCC at this lag"},{"phase":2,"caption":"Lag +5: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag +5; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[5,0],[6,1],[7,2],[8,3],[9,4]]},"value":0.10671569667453622,"value_label":"NCC at this lag"},{"phase":2,"caption":"Lag +6: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag +6; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[6,0],[7,1],[8,2],[9,3]]},"value":0.16204499141535658,"value_label":"NCC at this lag"},{"phase":2,"caption":"Lag +7: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag +7; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[7,0],[8,1],[9,2]]},"value":0.11458196783648032,"value_label":"NCC at this lag"},{"phase":2,"caption":"Lag +8: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag +8; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[8,0],[9,1]]},"value":0.06812736504384748,"value_label":"NCC at this lag"},{"phase":2,"caption":"Lag +9: overlap product / fixed full-series norms","panel":{"kind":"alignment","title":"Lag +9; unmatched values contribute zero","a":[-0.6273643326097713,-0.4879500364742666,0.48795003647426666,2.3003358862358283,1.324435813287295,-0.20912144420325715,-0.9061929248807808,-0.7667786287452761,-0.4879500364742666,-0.6273643326097713],"b":[-0.6309292202742752,-0.5952071148826826,-0.5923277484471909,-0.4834318131381829,0.4689956913641513,2.3000008152663436,1.338301216642782,-0.17851908931398805,-0.8719421766124685,-0.7549405606044893],"pairs":[[9,0]]},"value":0.039582248920137404,"value_label":"NCC at this lag"},{"phase":3,"caption":"Keep the largest normalized cross-correlation","panel":{"kind":"lines","title":"Complete lag profile; marker is the selected shift","a":[0.0473622780963682,0.09153986957876563,0.016908745212421583,-0.29145751338828363,-0.5188701195040026,-0.21711035761622904,0.49052957357582416,0.9305963101139378,0.5470463712762678,-0.0751440347915077,-0.45597650563563424,-0.5090062013168606,-0.3999215627842331,-0.1475491227071923,0.10671569667453622,0.16204499141535658,0.11458196783648032,0.06812736504384748,0.039582248920137404],"a_label":"NCC","marker":7,"x":[-9.0,-8.0,-7.0,-6.0,-5.0,-4.0,-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0]},"value":0.9305963101139378,"value_label":"maximum NCC"},{"phase":3,"caption":"Keep the largest normalized cross-correlation","panel":{"kind":"lines","title":"Complete lag profile; marker is the selected shift","a":[0.0473622780963682,0.09153986957876563,0.016908745212421583,-0.29145751338828363,-0.5188701195040026,-0.21711035761622904,0.49052957357582416,0.9305963101139378,0.5470463712762678,-0.0751440347915077,-0.45597650563563424,-0.5090062013168606,-0.3999215627842331,-0.1475491227071923,0.10671569667453622,0.16204499141535658,0.11458196783648032,0.06812736504384748,0.039582248920137404],"a_label":"NCC","marker":7,"x":[-9.0,-8.0,-7.0,-6.0,-5.0,-4.0,-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0]},"value":0.9305963101139378,"value_label":"maximum NCC"},{"phase":3,"caption":"Keep the largest normalized cross-correlation","panel":{"kind":"lines","title":"Complete lag profile; marker is the selected shift","a":[0.0473622780963682,0.09153986957876563,0.016908745212421583,-0.29145751338828363,-0.5188701195040026,-0.21711035761622904,0.49052957357582416,0.9305963101139378,0.5470463712762678,-0.0751440347915077,-0.45597650563563424,-0.5090062013168606,-0.3999215627842331,-0.1475491227071923,0.10671569667453622,0.16204499141535658,0.11458196783648032,0.06812736504384748,0.039582248920137404],"a_label":"NCC","marker":7,"x":[-9.0,-8.0,-7.0,-6.0,-5.0,-4.0,-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0]},"value":0.9305963101139378,"value_label":"maximum NCC"},{"phase":3,"caption":"Keep the largest normalized cross-correlation","panel":{"kind":"lines","title":"Complete lag profile; marker is the selected shift","a":[0.0473622780963682,0.09153986957876563,0.016908745212421583,-0.29145751338828363,-0.5188701195040026,-0.21711035761622904,0.49052957357582416,0.9305963101139378,0.5470463712762678,-0.0751440347915077,-0.45597650563563424,-0.5090062013168606,-0.3999215627842331,-0.1475491227071923,0.10671569667453622,0.16204499141535658,0.11458196783648032,0.06812736504384748,0.039582248920137404],"a_label":"NCC","marker":7,"x":[-9.0,-8.0,-7.0,-6.0,-5.0,-4.0,-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0]},"value":0.9305963101139378,"value_label":"maximum NCC"}],"checks":{"api":"max_ncc","expected":0.9305963101139378,"observed":0.9305963101139378,"tolerance":1e-12},"animation_steps_en":["Z-normalize both complete series once.","Slide through all integer lags.","Use fixed full-series norms at every lag.","Keep the largest NCC and its lag."],"echotime_status":"Implemented in EchoTime","echotime_api":"max_ncc"}
