File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed
Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,54 @@ describe('broadenPeaks', () => {
200200 ] ) ;
201201 } ) ;
202202
203+ it ( 'factor=20 not same width' , ( ) => {
204+ let result = broadenPeaks (
205+ [
206+ {
207+ x : - 0.5 ,
208+ y : 1 ,
209+ ddY : 0 ,
210+ width : 0.1 ,
211+ index : 25 ,
212+ inflectionPoints : {
213+ from : { index : 23 , x : - 0.55 } ,
214+ to : { index : 27 , x : - 0.45 } ,
215+ } ,
216+ } ,
217+ {
218+ x : 0.5 ,
219+ y : 1 ,
220+ ddY : 0 ,
221+ width : 0.4 ,
222+ index : 75 ,
223+ inflectionPoints : {
224+ from : { index : 73 , x : 0.3 } ,
225+ to : { index : 77 , x : 0.7 } ,
226+ } ,
227+ } ,
228+ ] ,
229+ { factor : 20 } ,
230+ ) ;
231+ expect ( result ) . toBeDeepCloseTo ( [
232+ {
233+ x : - 0.5 ,
234+ y : 1 ,
235+ index : 25 ,
236+ width : 1.2 ,
237+ from : { x : - 1.5 } ,
238+ to : { x : - 0.3 } ,
239+ } ,
240+ {
241+ x : 0.5 ,
242+ y : 1 ,
243+ index : 75 ,
244+ width : 4.8 ,
245+ from : { x : - 0.3 } ,
246+ to : { x : 4.5 } ,
247+ } ,
248+ ] ) ;
249+ } ) ;
250+
203251 it ( 'factor=20 overlap=true' , ( ) => {
204252 let result = broadenPeaks (
205253 [
Original file line number Diff line number Diff line change @@ -43,7 +43,10 @@ export function broadenPeaks(
4343 let peak = peaks [ i ] ;
4444 let nextPeak = peaks [ i + 1 ] ;
4545 if ( peak . to . x > nextPeak . from . x ) {
46- peak . to . x = nextPeak . from . x = ( peak . to . x + nextPeak . from . x ) / 2 ;
46+ // we do it proportional to the width of the peaks
47+ peak . to . x = nextPeak . from . x =
48+ ( peak . width / ( nextPeak . width + peak . width ) ) * ( nextPeak . x - peak . x ) +
49+ peak . x ;
4750 }
4851 }
4952 }
You can’t perform that action at this time.
0 commit comments