{"id":"spectral_similarity","title":"EchoTime spectral similarity","family":"native","definition":"echotime","intro_en":"EchoTime's spectral component works on standardized first differences. It linearly detrends the periodogram input, drops the zero-frequency bin, and normalizes the remaining power. One term measures one minus base-two JS divergence; another measures positive correlation of spectral structure. Their geometric mean produces the actual score shown by the animation.","intro_zh":"EchoTime 的频谱分项作用于标准化一阶差分。周期图计算使用线性去趋势，去除零频箱并归一化其余功率。一个分项取 1 减二进制 JS 散度，另一个衡量频谱结构的正相关，动图展示两者几何平均得到的实际分数。","steps_en":["Use standardized first differences as spectral input.","Compute linearly detrended periodograms, remove DC and normalize power.","Calculate 1-JS divergence in bits and positive spectral correlation.","Take the geometric mean of overlap and structure scores."],"steps_zh":["以标准化一阶差分作为频谱输入。","计算线性去趋势周期图，去除零频并归一化功率。","计算二进制 1−JS 散度与频谱正相关。","对重叠和结构分数取几何平均。"],"formula":"sqrt(clip(1-JS_base2(Px,Py),0,1)*max(corr(Px-U,Py-U),0)); spectra of z(diff(x))","caveats_en":["Power spectra discard phase; similar spectra do not ensure aligned waveforms.","The JS term here is a divergence in bits, not the square-root JS distance in another atlas card.","Resampling, differentiation and detrending all change the spectral object being compared."],"caveats_zh":["功率谱舍弃相位，频谱相似不保证波形对齐。","这里的 JS 项是以比特为单位的散度，与另一条目的平方根 JS 距离不同。","重采样、差分和去趋势都会改变所比较的频谱对象。"],"sources":[{"label":"EchoTime comparison implementation","url":"https://github.com/ZipengWu365/EchoTime/blob/main/src/echotime/similarity.py"},{"label":"EchoTime spectral preprocessing and JS definition","url":"https://github.com/ZipengWu365/EchoTime/blob/main/src/echotime/metrics.py"}],"x":[0.0,0.3,0.9,1.8,2.7,2.1,1.5,1.1,1.3,2.0,2.8,3.4,3.0,2.4,2.1,2.5,3.4,4.2,4.4,4.0,3.7,3.9,4.8,5.2],"y":[1.5,2.0519225760215023,2.5029737413368567,2.8847890070498634,3.3269392741386694,2.933060886050363,2.8090394772296827,2.72585888185695,2.7447210175121164,2.9398624371786375,3.3900034277072537,4.0626233874128905,4.107225730147529,3.7653701874961145,3.286091424860995,3.2508751301708068,3.8879044257286575,4.807850340965032,5.3047858081274875,5.010505135042322,4.45690204174836,4.306684421263111,5.058860495657116,5.718268001238006],"input_label":"Deterministic synthetic illustration; sample index is the time axis.","parameters":{"n_points":24,"default_n_points":256,"channels":1,"preprocessing":"compare_series linear resampling followed by per-channel population z-score","demonstration_note":"24 points expose the computation; production default is 256","periodogram_detrend":"linear","drop_DC":true,"JS_log_base":2,"frequency_grid":[0.043478260869565216,0.08695652173913043,0.13043478260869565,0.17391304347826086,0.21739130434782608,0.2608695652173913,0.30434782608695654,0.34782608695652173,0.3913043478260869,0.43478260869565216,0.4782608695652174]},"result":{"label":"similarity","value":0.9942354071620247,"detail":""},"frames":[{"phase":0,"caption":"The native spectrum is computed from standardized first differences","panel":{"kind":"lines","title":"Differenced signals entering the spectrum","a":[0.13569205707299586,0.6864421710751585,1.2371922850773207],"a_label":"x","b":[0.8611829040219345,0.6254594043197607,0.4636640210189587],"b_label":"y"}},{"phase":0,"caption":"The native spectrum is computed from standardized first differences","panel":{"kind":"lines","title":"Differenced signals entering the spectrum","a":[0.13569205707299586,0.6864421710751585,1.2371922850773207,1.2371922850773205,-1.5165582849334895,-1.5165582849334895,-1.1493915422653818,-0.047891314261057395,0.8700255424092123],"a_label":"x","b":[0.8611829040219345,0.6254594043197607,0.4636640210189587,0.6046591511482543,-1.3490321779414889,-0.7184111612757136,-0.6229714384718065,-0.38451071398430725,0.02743127692528874],"b_label":"y"}},{"phase":0,"caption":"The native spectrum is computed from standardized first differences","panel":{"kind":"lines","title":"Differenced signals entering the spectrum","a":[0.13569205707299586,0.6864421710751585,1.2371922850773207,1.2371922850773205,-1.5165582849334895,-1.5165582849334895,-1.1493915422653818,-0.047891314261057395,0.8700255424092123,1.053608913743266,0.6864421710751587,-1.1493915422653815,-1.5165582849334895,-0.9658081709313272,0.31927542840705014,1.2371922850773203],"a_label":"x","b":[0.8611829040219345,0.6254594043197607,0.4636640210189587,0.6046591511482543,-1.3490321779414889,-0.7184111612757136,-0.6229714384718065,-0.38451071398430725,0.02743127692528874,0.6233324430274709,1.1432371499945881,-0.3243591640718407,-1.227461486057608,-1.5486018580235412,-0.5108850431442582,1.060066350152393],"b_label":"y"}},{"phase":0,"caption":"The native spectrum is computed from standardized first differences","panel":{"kind":"lines","title":"Differenced signals entering the spectrum","a":[0.13569205707299586,0.6864421710751585,1.2371922850773207,1.2371922850773205,-1.5165582849334895,-1.5165582849334895,-1.1493915422653818,-0.047891314261057395,0.8700255424092123,1.053608913743266,0.6864421710751587,-1.1493915422653815,-1.5165582849334895,-0.9658081709313272,0.31927542840705014,1.2371922850773203,1.0536089137432667,-0.047891314261057395,-1.149391542265382,-0.9658081709313273,-0.04789131426105795,1.2371922850773203,0.3192754284070508],"a_label":"x","b":[0.8611829040219345,0.6254594043197607,0.4636640210189587,0.6046591511482543,-1.3490321779414889,-0.7184111612757136,-0.6229714384718065,-0.38451071398430725,0.02743127692528874,0.6233324430274709,1.1432371499945881,-0.3243591640718407,-1.227461486057608,-1.5486018580235412,-0.5108850431442582,1.060066350152393,1.7212060650395784,0.7326851101671589,-1.1162851411098784,-1.7222882495717105,-0.7796283351933038,1.3291495472315065,1.1123613457985642],"b_label":"y"}},{"phase":1,"caption":"Linearly detrend, discard DC, normalize remaining spectral power","panel":{"kind":"bars","title":"Normalized non-DC power","a":[0.0330917804999614,0.03700226908656857],"a_label":"spectrum x","b":[0.036756306623512085,0.043023540868000594],"b_label":"spectrum y"}},{"phase":1,"caption":"Linearly detrend, discard DC, normalize remaining spectral power","panel":{"kind":"bars","title":"Normalized non-DC power","a":[0.0330917804999614,0.03700226908656857,0.44923429460094044],"a_label":"spectrum x","b":[0.036756306623512085,0.043023540868000594,0.4830886234813127],"b_label":"spectrum y"}},{"phase":1,"caption":"Linearly detrend, discard DC, normalize remaining spectral power","panel":{"kind":"bars","title":"Normalized non-DC power","a":[0.0330917804999614,0.03700226908656857,0.44923429460094044,0.34490753383238365,0.06403498348415791],"a_label":"spectrum x","b":[0.036756306623512085,0.043023540868000594,0.4830886234813127,0.2902565712538243,0.07185412347876845],"b_label":"spectrum y"}},{"phase":1,"caption":"Linearly detrend, discard DC, normalize remaining spectral power","panel":{"kind":"bars","title":"Normalized non-DC power","a":[0.0330917804999614,0.03700226908656857,0.44923429460094044,0.34490753383238365,0.06403498348415791,0.030502813776625518,0.0029085593441418077],"a_label":"spectrum x","b":[0.036756306623512085,0.043023540868000594,0.4830886234813127,0.2902565712538243,0.07185412347876845,0.03179405376220255,0.002633630792704574],"b_label":"spectrum y"}},{"phase":1,"caption":"Linearly detrend, discard DC, normalize remaining spectral power","panel":{"kind":"bars","title":"Normalized non-DC power","a":[0.0330917804999614,0.03700226908656857,0.44923429460094044,0.34490753383238365,0.06403498348415791,0.030502813776625518,0.0029085593441418077,0.0014148218628631814,0.011708591243633193],"a_label":"spectrum x","b":[0.036756306623512085,0.043023540868000594,0.4830886234813127,0.2902565712538243,0.07185412347876845,0.03179405376220255,0.002633630792704574,0.0016516019393784378,0.012563309808645907],"b_label":"spectrum y"}},{"phase":1,"caption":"Linearly detrend, discard DC, normalize remaining spectral power","panel":{"kind":"bars","title":"Normalized non-DC power","a":[0.0330917804999614,0.03700226908656857,0.44923429460094044,0.34490753383238365,0.06403498348415791,0.030502813776625518,0.0029085593441418077,0.0014148218628631814,0.011708591243633193,0.024256963210410584,0.0009373890583137272],"a_label":"spectrum x","b":[0.036756306623512085,0.043023540868000594,0.4830886234813127,0.2902565712538243,0.07185412347876845,0.03179405376220255,0.002633630792704574,0.0016516019393784378,0.012563309808645907,0.02546917441175963,0.0009090635798906395],"b_label":"spectrum y"}},{"phase":2,"caption":"Compute JS overlap; separately compare centered spectral structure","panel":{"kind":"bars","title":"Per-frequency JS divergence contributions","a":[6.937373561996486e-05,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":0},"value":6.937373561996486e-05,"value_label":"partial JS divergence (bits)"},{"phase":2,"caption":"Compute JS overlap; separately compare centered spectral structure","panel":{"kind":"bars","title":"Per-frequency JS divergence contributions","a":[6.937373561996486e-05,0.0001635578696836731,0.0004434780046563957,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":2},"value":0.0006764096099600336,"value_label":"partial JS divergence (bits)"},{"phase":2,"caption":"Compute JS overlap; separately compare centered spectral structure","panel":{"kind":"bars","title":"Per-frequency JS divergence contributions","a":[6.937373561996486e-05,0.0001635578696836731,0.0004434780046563957,0.0016980925620412972,0.00016236326827980332,0.0,0.0,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":4},"value":0.002536865440281134,"value_label":"partial JS divergence (bits)"},{"phase":2,"caption":"Compute JS overlap; separately compare centered spectral structure","panel":{"kind":"bars","title":"Per-frequency JS divergence contributions","a":[6.937373561996486e-05,0.0001635578696836731,0.0004434780046563957,0.0016980925620412972,0.00016236326827980332,9.653690509057468e-06,4.920974017811014e-06,0.0,0.0,0.0,0.0],"a_label":"contribution","marker":6},"value":0.002551440104808003,"value_label":"partial JS divergence (bits)"},{"phase":2,"caption":"Compute JS overlap; separately compare centered spectral structure","panel":{"kind":"bars","title":"Per-frequency JS divergence contributions","a":[6.937373561996486e-05,0.0001635578696836731,0.0004434780046563957,0.0016980925620412972,0.00016236326827980332,9.653690509057468e-06,4.920974017811014e-06,6.600929257498083e-06,1.0857924613485407e-05,0.0,0.0],"a_label":"contribution","marker":8},"value":0.0025688989586789865,"value_label":"partial JS divergence (bits)"},{"phase":2,"caption":"Compute JS overlap; separately compare centered spectral structure","panel":{"kind":"bars","title":"Per-frequency JS divergence contributions","a":[6.937373561996486e-05,0.0001635578696836731,0.0004434780046563957,0.0016980925620412972,0.00016236326827980332,9.653690509057468e-06,4.920974017811014e-06,6.600929257498083e-06,1.0857924613485407e-05,1.0659318244082556e-05,1.5672847870750533e-07],"a_label":"contribution","marker":10},"value":0.0025797150054017765,"value_label":"partial JS divergence (bits)"},{"phase":3,"caption":"Combine 1-JS divergence and positive spectral correlation geometrically","panel":{"kind":"bars","title":"Overlap, spectral structure and combined score","a":[0.9974202849945982,0.99106069901114,0.9942354071620247],"a_label":"contribution","marker":0,"labels":["1-JS","corr","GM"]},"value":0.9942354071620247,"value_label":"spectral similarity"},{"phase":3,"caption":"Combine 1-JS divergence and positive spectral correlation geometrically","panel":{"kind":"bars","title":"Overlap, spectral structure and combined score","a":[0.9974202849945982,0.99106069901114,0.9942354071620247],"a_label":"contribution","marker":1,"labels":["1-JS","corr","GM"]},"value":0.9942354071620247,"value_label":"spectral similarity"},{"phase":3,"caption":"Combine 1-JS divergence and positive spectral correlation geometrically","panel":{"kind":"bars","title":"Overlap, spectral structure and combined score","a":[0.9974202849945982,0.99106069901114,0.9942354071620247],"a_label":"contribution","marker":2,"labels":["1-JS","corr","GM"]},"value":0.9942354071620247,"value_label":"spectral similarity"},{"phase":3,"caption":"Combine 1-JS divergence and positive spectral correlation geometrically","panel":{"kind":"bars","title":"Overlap, spectral structure and combined score","a":[0.9974202849945982,0.99106069901114,0.9942354071620247],"a_label":"contribution","marker":0,"labels":["1-JS","corr","GM"]},"value":0.9942354071620247,"value_label":"spectral similarity"}],"checks":{"api":"compare_series(..., n_points=24): spectral_similarity","expected":0.9942354071620247,"observed":0.9942354071620247,"tolerance":1e-11},"animation_steps_en":["Start from standardized first differences.","Detrend, compute spectra, discard DC and normalize power.","Measure JS overlap and positive spectral correlation.","Combine the two scores with a geometric mean."],"echotime_status":"EchoTime report component / reference metric","echotime_api":"spectral_similarity"}
