Fitting Baselines to Spectra Claudia Beleites CENMAT a - PDF document

Fitting Baselines to Spectra Claudia Beleites CENMAT a
Fitting Baselines to Spectra Claudia Beleites CENMAT a

Fitting Baselines to Spectra Claudia Beleites CENMAT a - Description


V March 4 2015 Contents 1 Introduction 2 Polynomial Baselines 21 Syntax parameters 2 22 General Use 2 23 Fitting polynomial baselines using least squares ID: 60313 Download Pdf

Tags

March 2015 Contents

Download Section

Please download the presentation from below link :


Download Pdf - The PPT/PDF document "Fitting Baselines to Spectra Claudia Bel..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Embed / Share - Fitting Baselines to Spectra Claudia Beleites CENMAT a


Presentation on theme: "Fitting Baselines to Spectra Claudia Beleites CENMAT a"— Presentation transcript


FittingBaselinestoSpectraClaudiaBeleites Claudia.Beleites@chemometrix.gmbh&#x-34.;妉 DIARamanSpectroscopyGroup,UniversityofTrieste/Italy(2005{2008)SpectroscopyImaging,IPHT,Jena/Germany(2008{2017)OPV,JKI,Berlin/Germany(2017{2019)ArbeitskreisLebensmittelmikrobiologieundBiotechnologie,HamburgUniversity,Hamburg/GermanChemometricConsultingandChemometrixGmbH,Wolfersheim/Germany(since2016)May27,2020Contents 1Introduction 1 2PolynomialBaselines 1 2.1Syntax¶meters .......................................2 2.2GeneralUse .............................................2 2.3Fittingpolynomialbaselinesusingleastsquares .......................2 2.4Themechanismofautomatically ttingthebaselineinspc. t.poly.below ........3 2.5Specifyingthespectralrange ...................................4 2.6Fittingpolynomialsofdi erentorders .............................5 2.7Thenoiselevel ...........................................5 3RubberbandMethod 1IntroductionThisdocumentdiscussesbaselinecorrectionmethodsthatcanbeusedwithhyperSpec.hyperSpecprovidestwo ttingfunctionsforpolynomialbaselines,spc.fit.polyandspc.fit.poly.below.Anotherpossibilityisspc.rubberband,a\rubberband"methodthatdeterminessupportpointsby ndingtheconvexhullofeachspectrum.Thebaselinesarethenpiecewiselinearor(smoothing)splinesthroughthesupportpoints.Pleasenotethataspecializedpackageforbaseline tting,baseline[ 1 ],existsthatprovidesmanymoremethodsto tbaselinestospectroscopicdata.UsingbaselinewithhyperSpecobjectsisdemonstratedinvignette("hyperspec").2PolynomialBaselinesIncontrasttomanyotherprogramsthatprovidebaselinecorrectionmethods,hyperSpec'spolynomialbaselinefunctionsdoleastsquares ts.However,thebaselinescanbeforcedthroughparticular points,ifthisbehaviourisneeded.Themaindi erencebetweenthetwofunctionsisthatspc.fit.polyreturnsaleastsquares tthroughthecompletespectrumthatisgivenin t.towhereasspc.fit.poly.belowtriesto ndappropriatespectralregionsto tthebaselineto.2.1Syntax¶metersspc.fit.poly(fit.to,apply.to=fit.to,poly.order=1spc.fit.poly.below(fit.to,apply.to=fit.to,poly.order=1,npts.min=NULL,noise=0)fit.to:hyperSpecobjectwiththespectrawhosebaselinesaretobe tted.apply.to:hyperSpecobjectgivingthespectralrange,onwhichthebaselinesshouldbeeval-uated.IfapplyisNULL,ahyperSpecobjectwiththepolynomialcoecientsisreturnedinsteadofevaluatedbaselines.poly.order:polynomialorderofthebaselinesnpts.min:minimalnumberofdatapointsperspectrumtobeusedforthe t.npts.mindefaultstothelargerof3times(poly.order+1)or thofthenumberofdatapointsperspectrum.Ifnpts.minpoly.order,awarningisissuedandnpts.min-poly.order+1isused.noise:avectorgivingtheamountofnoise,seebelow.2.2GeneralUseBothfunctions tthepolynomialtothespectralrangegiveninhyperSpecobject t.to.Ifapply.toisnotNULL,thepolynomialsareevaluatedonthespectralrangeofapply.to.Otherwise,thepolynomialcoecientsarereturned.Subtractingthebaselineisuptotheuser,itiseasilydoneashyperSpecprovidesthe(minus)operator.2.3FittingpolynomialbaselinesusingleastsquaresCommonly,baselinesare tusing(single)supportpointsthatarespeci edbytheuser.Also,usuallysupportpointisusedforapolynomialoforder.Thisapproachisappropriateforspectrawithhighsignaltonoiseratio.Suchabaselinecanbeobtainedbyrestrictingthespectrain t.tototherespectivepoints(see gure 1 ):�bl-spc.fit.poly(chondro[c(1,101),,c(633,1788)],chondro[c(1,101)])�.99;冘plot(chondro[c(1,101)],plot.args=list(ylim=c(200,600)),col=1:2)�.99;冘plot(chondro[c(1,101),,c(633,1788)],add=TRUE,col=1:2,+lines.args=list(type="p",pch=20))�.99;冘plot(bl,add=TRUE,col=1:2) 600700800900100011001200130014001500160017001800 200300400500600Dn cm-1I / a.u. Figure1Fittingalinearbaselinethroughtwopoints.Ifthesignaltonoiseratioisnotideal,wavelengthsthatwork neforonespectrum(black)maynotbeappropriateforanother(red).However,ifthesignaltonoiseratioisnotideal,apolynomialwithsupportingpoints(i.e.withzerodegreesoffreedom)issubjecttoaconsiderableamountofnoise.Ifontheotherhand,moredatapointsconsistingofbaselineonlyareavailable,theuncertaintyonthepolynomialcanbereducedbyaleastsquares t.Bothspc.fit.polyandspc.fit.poly.belowthereforeprovideleastsquares ttingforthepoly-nomial.spc.fit.poly tstothewholespectralregionof t.to.Thus,forbaseline ttingthespectraneedtobecuttoappropriatewavelengthrangesthatdonotcontainanysignal.Inordertospeedupcalculations,theleastsquares tisdonebyusingtheVandermondematrixandsolvingtheequationsystembyqr.solve.This tisnotweighted.Aspectralregionwithmanydatapointsthereforehasgreaterin\ruenceontheresultingbaselinethanaregionwithjustafewdatapoints.Itisuptotheusertodecidewhetherthisshouldbecorrectedforbyselectingappropriatenumbersofdatapoints(e.g.byusingreplicatesoftheshorterspectralregion).2.4Themechanismofautomatically ttingthebaselineinspc.fit.poly.belowspc.fit.poly.belowtriestoautomatically ndappropriatespectralregionsforbaseline tting.Thisisdonebyexcludingspectralregionsthatcontainsignalsfromthebaseline tting.Theideaisthatalldatapointsthatlieabovea ttedpolynomial(initiallythroughthewholespectrum,thenthroughtheremainingpartsofthespectrum)willbetreatedassignalandthusbeexcludedfromthebaseline tting.Thesupportingpointsforthebaselinepolynomialsarecalculatediteratively:1.Apolynomialoftherequestedorderis ttotheconsideredspectralrange,initiallytothewholespectrumgivenin t.to 600700800900100011001200130014001500160017001800 50010001500Dn cm-1I / a.u.spectrum 1 Figure2Iterative ttingofthebaseline.Thedotsgivethesupportingpointsforthenextiteration'sbaseline,color:iterations. 17001705171017151720172517301735174017451750 200300400500Dn cm-1I / a.u. Figure3In\ruenceoffit.toonthebaselinepolynomial.Theblackbaselineis ttothespectralrange17001750cm,theblueto17201750cmonly.2.Onlythepartsofthespectrumthatliebelowthispolynomialplusthenoiseareretainedassupportingpointsforthenextiteration.Thesetwostepsarerepeateduntileithernofurtherpointsareexcluded,orthenextpolynomialwouldhavelessthannpts.minsupportingpoints.Thebaselinesandrespectivesupportingpointsforeachiterationofspc.fit.poly.below(chondro[1],poly.order=1)areshownin gure 2 .2.5SpecifyingthespectralrangeItispossibletoexcludespectralregionsthatdonotcontributetothebaselinefromthe tting,whilethebaselineisusedforthewholespectrum.Thisselectionofappropriatespectralregionsisessentialforspc.fit.poly.Butalsospc.fit.poly.belowcanbene tfromnarrowerspectralranges:the ttinggainsspeed.Thedefaultvaluefornpts.mindependsonthenumberofdatapointsperspectrum.Thusoneshouldalsoconsiderrequiringmoresupportpointsthanthedefaultvaluesuggests. 60080010001200140016001800 50010001500Dn cm-1I / a.u.spectrum 1 60080010001200140016001800 50010001500Dn cm-1I / a.u.spectrum 1 60080010001200140016001800 50010001500Dn cm-1I / a.u.spectrum 1 Figure4Baselinepolynomial ttothe rstspectrumofthechondrodatasetoforder0{2(lefttoright).Thedotsindicatethepointsusedforthe ttingofthepolynomial.�system.time(spc.fit.poly.below(chondro,NULL,npts.min=20))usersystemelapsed0.3550.0230.378�system.time(spc.fit.poly.below(chondro[,,c(min~700,1700~max)],NULL,npts.min=20))usersystemelapsed0.1910.0000.190Thechoiceofthespectralrangeinfit.toin\ruencestheresultingbaselinestoacertainextent,asbecomesclearfrom gure 3 .2.6Fittingpolynomialsofdi erentordersFigure 4 showstheresultingbaselinepolynomialofspc.fit.poly.below(chondro[1],poly.order=order)withorder0to3forthe rstspectrumofthechondrodataset.2.7ThenoiselevelBesidesde ningaminimalnumberofsupportingpoints,a\noiselevel"maybegiven.Consideraspectralrangeconsistingonlyofnoise.Theupperpartof gure 5 illustratestheproblem.Asthebaseline ttingalgorithmcannotdistinguishbetweennoiseandrealbandsappearingabovethe ttedpolynomial,theresultingbaseline(black)istoolowifthenoiseparameterisnotgiven.Settingthenoiselevelto4(2standarddeviations),the ttingconvergesimmediatelywithamuchbetterresult.Theresultingbaselinesforspc.fit.poly.below(chondro[1],poly.order=1,noise=12)ofthewholespectrumareshowninthemiddleandlowerpartof gure 5 noisemaybeasinglevalueforallspectra,oravectorwiththenoiselevelforeachofthespectraseparately.3RubberbandMethodParticularlyRamanspectraoftenshowincreasingbackgroundtowards.Inthiscase,polyno-mialbaselinesofteneitherneedhighorderorresidualbackgroundisleftinthespectra.Inthatcase,smoothingsplines ttedthroughthesupportingpointsareagoodalternative.Fortheparacetamolspectrum( g. 6 ),anoiselevelof300countsandtheequivalentof20degreesoffreedomworkwell. 0102030405060708090100 9698100102104 600700800900100011001200130014001500160017001800 50010001500Dn cm-1I / a.u.spectrum 1 Figure5Iterative ttingofthebaselinewithnoiselevel.Upperpart:e ectsofthenoiseparameteronthebaselineofaspectrumconsistingonlyofnoiseando set:withoutgivingnoisetheresultingbaseline(black)isclearlytoolow.Anoiselevelof4resultsinthebluebaseline.Thelowerpartshowthebaseline ttingwithnoiselevelonthecompletespectrum.Colour:iterations,dots:supportingpointsfortherespectivelynextbaseline.Dashed:baselineplusnoise.Allpointsabovethislineareexcludedfromthenextiteration.�bl-spc.rubberband(paracetamol[,,175~1800],noise=300,df=20)However,thereispossiblysomebackgroundleftbetween1200and1750cm-1wheretheoriginalspectrumisslightlyconcave.Thiscanbecorrectedbybendingthespectrumbeforeapplyingtherubberbandcorrection( g. 7 ):�bend-5e4*wl.eval(paracetamol[,,175~1800],function(x)x^2,normalize.wl=normalize01)�.99;冘bl-spc.rubberband(paracetamol[,,175~1800]+bend)-bendReferences[1]KristianHovdeLiland,TrygveAlmy,andBjrn-HelgeMevik.Optimalchoiceofbaselinecor-rectionformultivariatecalibrationofspectra.AppliedSpectroscopy,64:1007{1016,2010.SessionInfoRversion3.6.3(2020-02-29)Platform:x86_64-pc-linux-gnu(64-bit)Runningunder:Ubuntu18.04.4LTSMatrixproducts:defaultBLAS:/usr/lib/x86_64-linux-gnu/openblas/libblas.so.3LAPACK:/usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so 20040060080010001200140016001800 1000020000300004000050000Dn cm-1I / a.u. (a)paracetamolwiththerubberband ttedbaseline. 20040060080010001200140016001800 010000200003000040000Dn cm-1I / a.u. (b)Correctedspectrum.Figure6Rubberbandbaselinesfortheparacetamolspectrum. 20040060080010001200140016001800 10000300005000070000Dn cm-1I / a.u. (a)Bentparacetamolspectrumandrubberbandbaseline. 20040060080010001200140016001800 010000200003000040000Dn cm-1I / a.u. (b)Correctedspectrum.Figure7Rubberbandbaselinesfortheparacetamolspectrumafterbending.locale:[1]LC_CTYPE=de_DE.UTF-8LC_NUMERIC=CLC_TIME=de_DE.UTF-8[4]LC_COLLATE=CLC_MONETARY=de_DE.UTF-8LC_MESSAGES=de_DE.UTF-8[7]LC_PAPER=de_DE.UTF-8LC_NAME=CLC_ADDRESS=C[10]LC_TELEPHONE=CLC_MEASUREMENT=de_DE.UTF-8LC_IDENTIFICATION=Cattachedbasepackages:[1]gridstatsgraphicsgrDevicesutilsdatasetsmethodsbaseotherattachedpackages:[1]hyperSpec_0.99-20200527xml2_1.3.2ggplot2_3.3.0lattice_0.20-41loadedviaanamespace(andnotattached):[1]Rcpp_1.0.4.6magrittr_1.5tidyselect_1.0.0munsell_0.5.0[5]colorspace_1.4-1R.cache_0.14.0R6_2.4.1jpeg_0.1-8.1[9]rlang_0.4.6dplyr_0.8.5tools_3.6.3gtable_0.3.0[13]png_0.1-7R.oo_1.23.0latticeExtra_0.6-29withr_2.2.0[17]ellipsis_0.3.0lazyeval_0.2.2digest_0.6.25assertthat_0.2.1[21]tibble_3.0.1lifecycle_0.2.0crayon_1.3.4R.rsp_0.43.2[25]RColorBrewer_1.1-2purrr_0.3.4vctrs_0.2.4R.utils_2.9.2[29]testthat_2.3.2glue_1.4.0compiler_3.6.3pillar_1.4.4[33]scales_1.1.0R.methodsS3_1.8.0pkgconfig_2.0.3

Shom More....