{"id":"shift_cosine_similarity","title":"Shifted cosine similarity","family":"sliding","definition":"reference","intro_en":"Shifted cosine similarity evaluates cosine on the current overlap after each permitted integer shift, using only samples that overlap. This example admits lags from minus three to plus three samples, leaving at least seven paired observations. The animation shows the actual overlap pairs and candidate scores before selecting their maximum.","intro_zh":"Shifted cosine similarity 在每个允许的整数平移后，仅对重叠样本计算对应分数。本例滞后范围为 −3 至 +3 个采样点，始终保留至少七对观测。动图展示实际配对和候选分数，再选择最大值。","steps_en":["Fix the permitted lags and minimum acceptable overlap before scoring.","At each lag, compute cosine on the current overlap on the actual paired samples.","Record every candidate score together with its lag.","Choose the maximum overlap score."],"steps_zh":["先固定允许滞后与最小可接受重叠长度。","对每个滞后的实际配对样本计算对应分数。","记录所有候选分数及其滞后。","选取最大重叠分数。"],"formula":"max_{lag=-3,...,3} cosine(x_overlap,y_overlap)","caveats_en":["Every overlap has its own norm; this is different from full-norm NCC.","The bounded window is an explicit demonstration choice; allowing every possible lag changes the problem.","Overlap cropping removes unmatched endpoints from this score."],"caveats_zh":["每个重叠片段使用自己的范数，与全范数 NCC 不同。","有界窗口是明确的演示选择；允许所有滞后会改变问题。","重叠裁剪会从分数中排除未匹配的两端。"],"sources":[{"label":"Imported registry: overlap-based shift definitions","url":"https://github.com/ZipengWu365/EchoTime/blob/main/src/echotime/data/ts_similarity_package_v2_registry.csv"},{"label":"SciPy: cosine","url":"https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.cosine.html"}],"x":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"y":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"input_label":"Deterministic synthetic illustration; sample index is the time axis.","parameters":{"lags":[-3,-2,-1,0,1,2,3],"minimum_overlap":7,"normalization":"per overlap","selected_lag":-2},"result":{"label":"similarity","value":0.9999274856496999,"detail":""},"frames":[{"phase":0,"caption":"Use the declared bounded lag window: -3 to +3 samples","panel":{"kind":"lines","title":"Original input; no hidden standardization","a":[1.0,1.1,1.8],"a_label":"x","b":[1.0,1.025244129544237,1.0272789228047705],"b_label":"y"}},{"phase":0,"caption":"Use the declared bounded lag window: -3 to +3 samples","panel":{"kind":"lines","title":"Original input; no hidden standardization","a":[1.0,1.1,1.8,3.1,2.4],"a_label":"x","b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623],"b_label":"y"}},{"phase":0,"caption":"Use the declared bounded lag window: -3 to +3 samples","panel":{"kind":"lines","title":"Original input; no hidden standardization","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8],"a_label":"x","b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323],"b_label":"y"}},{"phase":0,"caption":"Use the declared bounded lag window: -3 to +3 samples","panel":{"kind":"lines","title":"Original input; no hidden standardization","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"a_label":"x","b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"b_label":"y"}},{"phase":1,"caption":"Lag -3: cosine on the current overlap","panel":{"kind":"alignment","title":"Overlap correspondence at lag -3","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[0,3],[1,4],[2,5],[3,6],[4,7],[5,8],[6,9]]},"value":0.9132178579851044,"value_label":"current overlap score"},{"phase":1,"caption":"Lag -2: cosine on the current overlap","panel":{"kind":"alignment","title":"Overlap correspondence at lag -2","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[0,2],[1,3],[2,4],[3,5],[4,6],[5,7],[6,8],[7,9]]},"value":0.9999274856496999,"value_label":"current overlap score"},{"phase":1,"caption":"Lag -1: cosine on the current overlap","panel":{"kind":"alignment","title":"Overlap correspondence at lag -1","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9]]},"value":0.9162894697098246,"value_label":"current overlap score"},{"phase":1,"caption":"Lag +0: cosine on the current overlap","panel":{"kind":"alignment","title":"Overlap correspondence at lag +0","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[0,0],[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9]]},"value":0.7906558684296512,"value_label":"current overlap score"},{"phase":1,"caption":"Lag +1: cosine on the current overlap","panel":{"kind":"alignment","title":"Overlap correspondence at lag +1","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[1,0],[2,1],[3,2],[4,3],[5,4],[6,5],[7,6],[8,7],[9,8]]},"value":0.7158686001448061,"value_label":"current overlap score"},{"phase":1,"caption":"Lag +2: cosine on the current overlap","panel":{"kind":"alignment","title":"Overlap correspondence at lag +2","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[2,0],[3,1],[4,2],[5,3],[6,4],[7,5],[8,6],[9,7]]},"value":0.7040479452405561,"value_label":"current overlap score"},{"phase":1,"caption":"Lag +3: cosine on the current overlap","panel":{"kind":"alignment","title":"Overlap correspondence at lag +3","a":[1.0,1.1,1.8,3.1,2.4,1.3,0.8,0.9,1.1,1.0],"b":[1.0,1.025244129544237,1.0272789228047705,1.104233600241796,1.7772959251407623,3.071232271760106,2.3916175350540323,1.3197095979615636,0.8296807473987015,0.9123635545572527],"pairs":[[3,0],[4,1],[5,2],[6,3],[7,4],[8,5],[9,6]]},"value":0.6994882829944036,"value_label":"current overlap score"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[0.9132178579851044],"a_label":"overlap score","marker":0,"x":[-3.0]},"value":0.9132178579851044,"value_label":"best candidate so far"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[0.9132178579851044,0.9999274856496999],"a_label":"overlap score","marker":1,"x":[-3.0,-2.0]},"value":0.9999274856496999,"value_label":"best candidate so far"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[0.9132178579851044,0.9999274856496999,0.9162894697098246],"a_label":"overlap score","marker":2,"x":[-3.0,-2.0,-1.0]},"value":0.9999274856496999,"value_label":"best candidate so far"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[0.9132178579851044,0.9999274856496999,0.9162894697098246,0.7906558684296512],"a_label":"overlap score","marker":3,"x":[-3.0,-2.0,-1.0,0.0]},"value":0.9999274856496999,"value_label":"best candidate so far"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[0.9132178579851044,0.9999274856496999,0.9162894697098246,0.7906558684296512,0.7158686001448061],"a_label":"overlap score","marker":4,"x":[-3.0,-2.0,-1.0,0.0,1.0]},"value":0.9999274856496999,"value_label":"best candidate so far"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[0.9132178579851044,0.9999274856496999,0.9162894697098246,0.7906558684296512,0.7158686001448061,0.7040479452405561],"a_label":"overlap score","marker":5,"x":[-3.0,-2.0,-1.0,0.0,1.0,2.0]},"value":0.9999274856496999,"value_label":"best candidate so far"},{"phase":2,"caption":"Compare scores only over the admitted lag window","panel":{"kind":"lines","title":"Candidate score versus lag","a":[0.9132178579851044,0.9999274856496999,0.9162894697098246,0.7906558684296512,0.7158686001448061,0.7040479452405561,0.6994882829944036],"a_label":"overlap score","marker":6,"x":[-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0]},"value":0.9999274856496999,"value_label":"best candidate so far"},{"phase":3,"caption":"Select the largest overlap similarity","panel":{"kind":"lines","title":"Complete bounded lag scan","a":[0.9132178579851044,0.9999274856496999,0.9162894697098246,0.7906558684296512,0.7158686001448061,0.7040479452405561,0.6994882829944036],"a_label":"candidate score","marker":1,"x":[-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0]},"value":0.9999274856496999,"value_label":"final result"},{"phase":3,"caption":"Select the largest overlap similarity","panel":{"kind":"lines","title":"Complete bounded lag scan","a":[0.9132178579851044,0.9999274856496999,0.9162894697098246,0.7906558684296512,0.7158686001448061,0.7040479452405561,0.6994882829944036],"a_label":"candidate score","marker":1,"x":[-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0]},"value":0.9999274856496999,"value_label":"final result"},{"phase":3,"caption":"Select the largest overlap similarity","panel":{"kind":"lines","title":"Complete bounded lag scan","a":[0.9132178579851044,0.9999274856496999,0.9162894697098246,0.7906558684296512,0.7158686001448061,0.7040479452405561,0.6994882829944036],"a_label":"candidate score","marker":1,"x":[-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0]},"value":0.9999274856496999,"value_label":"final result"},{"phase":3,"caption":"Select the largest overlap similarity","panel":{"kind":"lines","title":"Complete bounded lag scan","a":[0.9132178579851044,0.9999274856496999,0.9162894697098246,0.7906558684296512,0.7158686001448061,0.7040479452405561,0.6994882829944036],"a_label":"candidate score","marker":1,"x":[-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0]},"value":0.9999274856496999,"value_label":"final result"}],"animation_steps_en":["Fix lags from -3 to +3 and retain adequate overlap.","Compute cosine on each actual overlap.","Record every candidate score with its lag.","Choose the maximum overlap score."],"echotime_status":"Possible addition","echotime_api":""}
