8
Latest revision: 11/30/2011 1 Illumination Correction tutorial I. Introduction The Correct Illumination Calculate and Correct Illumination Apply modules are intended to compensate for the non‐uniformities in illumination often present in microscopy images. It is not uncommon for the intensity within a fluorescence image to vary by more than two‐fold across the field of view due to the optics of the microscope, imperfection in the slide or sensor bias. Correcting the illumination variation can be important both for accurate segmentation and for intensity measurements. II. Creating an illumination function The Correct Illumination ‐ Calculate module is used to create the illumination function, an image that is representative of the overall pattern of illumination in the image or image set. Generally, it is necessary to create a different function for each set of imaging or sample preparation conditions because either can yield changes in the pattern of illumination. For example, the illumination pattern will change if you use a different staining reagent for a batch of images or change any components or settings in the optical path of the microscope. In fact, sometimes the illumination pattern can change throughout the course of the day as the microscope lamp changes temperature, or between different batches of what should be identical staining reagents. In our experience, a separate illumination function should be calculated for each separate plate in a multi‐well plate experiment. Additionally, while the pattern of illumination may look very similar for each imaged wavelength, the absolute intensities will most likely vary between wavelengths (channels). Therefore, a separate illumination function should be prepared for each channel. Deciding on a workflow: There are two workflow options available in CellProfiler to create and apply illumination functions for a project: (1) create and save illumination functions using one CellProfiler pipeline, then later retrieve and apply the illumination functions using a separate CellProfiler analysis pipeline; or (2) create and apply illumination functions within a single CellProfiler analysis pipeline. For experiments where a different illumination function will be calculated for each individual image, (2) is the better choice. For typical high‐throughput experiments involving more than 100 images that will share an illumination function, (1) is more convenient because it allows you to readily inspect the illumination functions that are produced for quality control purposes, prior to applying them to analyze images. It offers the opportunity to tweak the pipeline that creates the illumination functions prior to analyzing images. As well, if creating the illumination function is time‐consuming (i.e., many images are being processed), it is worthwhile to create the function in a pipeline separate from the one used for analysis, to make the analysis pipeline more efficient. Example pipelines following both workflows are available at www.cellprofiler.org/examples.shtml in the IlluminationCorrection example pipeline.

Illumination Correction tutorial · 2016. 2. 4. · Latest revision: 11/30/2011 1 Illumination Correction tutorial I. Introduction The Correct Illumination ‐ Calculate and Correct

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

  • Latestrevision:11/30/2011

    1

    Illumination Correction tutorial

    I. Introduction TheCorrectIllumination‐CalculateandCorrectIllumination‐Applymodulesareintendedtocompensateforthenon‐uniformitiesinilluminationoftenpresentinmicroscopyimages.Itisnotuncommonfortheintensitywithinafluorescenceimagetovarybymorethantwo‐foldacrossthefieldofviewduetotheopticsofthemicroscope,imperfectionintheslideorsensorbias.Correctingtheilluminationvariationcanbeimportantbothforaccuratesegmentationandforintensitymeasurements.II. Creating an illumination function TheCorrectIllumination‐Calculatemoduleisusedtocreatetheilluminationfunction,animagethatisrepresentativeoftheoverallpatternofilluminationintheimageorimageset.Generally,itisnecessarytocreateadifferentfunctionforeachsetofimagingorsamplepreparationconditionsbecauseeithercanyieldchangesinthepatternofillumination.Forexample,theilluminationpatternwillchangeifyouuseadifferentstainingreagentforabatchofimagesorchangeanycomponentsorsettingsintheopticalpathofthemicroscope.Infact,sometimestheilluminationpatterncanchangethroughoutthecourseofthedayasthemicroscopelampchangestemperature,orbetweendifferentbatchesofwhatshouldbeidenticalstainingreagents.Inourexperience,aseparateilluminationfunctionshouldbecalculatedforeachseparateplateinamulti‐wellplateexperiment.Additionally,whilethepatternofilluminationmaylookverysimilarforeachimagedwavelength,theabsoluteintensitieswillmostlikelyvarybetweenwavelengths(channels).Therefore,aseparateilluminationfunctionshouldbepreparedforeachchannel.Decidingonaworkflow:TherearetwoworkflowoptionsavailableinCellProfilertocreateandapplyilluminationfunctionsforaproject:(1)createandsaveilluminationfunctionsusingoneCellProfilerpipeline,thenlaterretrieveandapplytheilluminationfunctionsusingaseparateCellProfileranalysispipeline;or(2)createandapplyilluminationfunctionswithinasingleCellProfileranalysispipeline.Forexperimentswhereadifferentilluminationfunctionwillbecalculatedforeachindividualimage,(2)isthebetterchoice.Fortypicalhigh‐throughputexperimentsinvolvingmorethan100imagesthatwillshareanilluminationfunction,(1)ismoreconvenientbecauseitallowsyoutoreadilyinspecttheilluminationfunctionsthatareproducedforqualitycontrolpurposes,priortoapplyingthemtoanalyzeimages.Itofferstheopportunitytotweakthepipelinethatcreatestheilluminationfunctionspriortoanalyzingimages.Aswell,ifcreatingtheilluminationfunctionistime‐consuming(i.e.,manyimagesarebeingprocessed),itisworthwhiletocreatethefunctioninapipelineseparatefromtheoneusedforanalysis,tomaketheanalysispipelinemoreefficient.Examplepipelinesfollowingbothworkflowsareavailableatwww.cellprofiler.org/examples.shtmlintheIlluminationCorrectionexamplepipeline.

  • Latestrevision:11/30/2011

    2

    Figure1:ScreenshotoftheCellProfilerinterfacefortheCorrectIllumination‐Calculatemodule.

    ConfiguringtheCorrectIllumination–Calculatemoduletocreateilluminationfunctions:AnexampleoftheCorrectIllumination‐CalculatemoduleisshowninFig.1.Somemodulesettingsonlybecomevisiblebasedonyourresponsetoothersettings,soonlysomeoftheavailablesettingsareshownhere.Foroverallguidanceonusingthemodule,seethefullhelpforthemodulebyselectingitinthemodulepanelatthetopleftoftheCellProfilerwindow,thenclicktheClicktheHelpbutton underthemodulepanelontheleft.ClicktheHelpbuttonstotherightofeachmodulesettingforadetaileddescriptionofthatsetting.Ifsavinganilluminationfunctionforlaterretrieval,besuretoselect'.mat'asthefileformatforsavingsincethisformatusesfloatingpointpixelvalues,whichisnecessaryforthemathematicaloperationsinvolvedinilluminationcorrection.III. Applying the illumination function IntheCorrectIllumination‐Applymodule(somesettingsofwhichareshowninFig.2),youhavetheoptiontoeitherdivideorsubtracttheilluminationfunctionfromtheinputimage(theimagetobecorrected).Iftheilluminationfunctionwasrescaledtobe1orgreaterinCorrectIllumination‐Calculate,selectDivide.Otherwise,ifthefunctionwasnotrescaled,selectSubtract.SeethehelpfortheBackgroundvs.RegularsettingintheCorrectIllumination‐Calculatemoduleformoreguidance.Inbothcases,thisshouldleavetheimageintherangeof0to1.

  • Latestrevision:11/30/2011

    3

    Ifthegradientacrossthefinalcorrectedimageremainslarge,youmaywanttorescaletheintensitiesaftertheApplystepbyusingtheRescaleIntensitymoduleonthefinalimage.Sincedoingsowillstretchtheintensitiesinthefinalimage,thisfunctionshouldbeusedcarefully.Rescalingisnotrecommendedwhenyouintendtomeasureandcompareintensitiesamongrescaledimagesintheimageset.Itisalsonotrecommendediftheimagesetmaycontainimagesthathavenoobjects;insuchcasestherescaledimagewillsetthebrightestpartoftheblankbackgroundoftheimagetobeverybright,thusconfusinglatermodulessuchasIdentifyPrimaryObjects.SeethehelpfortheRescaleIntensitymoduleformoreinformationontherescalingoptionsavailable.

    Figure2:ScreenshotoftheCellProfilerinterfacefortheCorrectIllumination‐Applymodule.

    IV. Inspecting the illumination function and its results ThequalityoftheIlluminationcorrectiondependsentirelyonthesettingschosenforCorrectIllumination‐Calculate.Yourchoiceastowhatcombinationsofsettingsareappropriatewilldependonthespatialarrangementofthefeaturesofinterestinyourcellularimagesandwhethereachimageislikelytohaveadifferentilluminationpatternorwhethermultipleimagesarelikelytosharethesamepattern.Inthissection,wewillinspectexampleilluminationfunctionsandassesswhethertheyareappropriate.

  • Latestrevision:11/30/2011

    4

    Example1:InthisexamplefromacollectionofimagesofU2OScells(Fig.3):

    1. Thecellsareuniformlydistributedacrosstheimage(thatis,theyarenotpreferentiallylocatedincertainpartsoftheimage).

    2. Theyoccupymostoftheforeground.3. Thereseemstobeacomplexilluminationpatternwheretheilluminationseems

    dimmerinthetopleftandpossiblythebottomleftandtoprightcorners.4. Theimageispartofabatchofimagespreparedunderthesamesamplepreparation

    andimagingconditions,allofwhichshowasimilarilluminationpattern.

    Figure3:RawgrayscaleimageofU2OScells.

    ThisimagesetshouldbecorrectedusingtheRegularmethod,whichtendstoproducemoreaccuratecorrectionwhentherebrightobjectsacrossmuchoftheimage.Becauseof(2),thereisinsufficientbackgroundintheimageforthealternativeBackgroundmethod.Althoughotheroptionsmightwork,wewillchooseMedianasthesmoothingmethodbecauseof(3)–thepatternappearstoberathercomplexasisoftenthecaseforfluorescenceimages.Becauseof(4),weshouldchooseAll(tocalculateafunctionbasedonmanyimagestogether)ratherthanEach(whichcalculatesadifferentfunctionforeachimage).IfweweretoincorrectlychoosetheRegularmethoduponEachimageindividually,wewouldobtainapoorilluminationfunctionthatresemblestheoriginaldistributionofthecells,showingdarkregionspreciselywherecellsareabsentandbrightregionswheremanycellsarepresent(Fig.3A).Sincethisfunctionismorereflectiveoftheextrinsicfeaturesofinterest(thecellsthemselves),andnottheintrinsicqualitiesoftheacquisitionsystem,thisisnotadesirableilluminationfunction.However,becausethisimageispartofasetproducedbyanautomatedmicroscope,itwouldbebettertotakeadvantageofthewholeimagesettoproduceamorerobustilluminationfunctionthatislesssensitivetovariationsineachparticularimage.ItisthuspreferabletouseAllinsteadofEach,averagingtogethermanyimagespriortosmoothing.Theresultisanensembleilluminationfunctionthatismorerepresentativeofthefluorescencevariationintrinsictoallimagescapturedduringtheexperiment(Fig.4B).Evenso,theilluminationpatternstillhassomeforeground

    Before proceeding: Please gain a basic understanding of the options within Correct Illumination – Calculate and Correct Illumination – Apply by reading the help for the module: select it in the module panel at the top left of the CellProfiler window, then click the Click the Help button under the module panel on the left.

  • Latestrevision:11/30/2011

    5

    variationsoriginatingfromthecelldistributioninsteadoftheimagingsystem.Increasingthesmoothingfiltersizeyieldsanilluminationfunctionthat(Fig.4C).

    Figure4:IlluminationfunctionsproducedfromtheimagesetcontainingFig.3(A)UsingRegular+Each+MedianfilteringontherawimageinFig.3.(B)UsingRegular+All+Medianfilteringonthefullimageset.(C)

    UsingRegular+All+Medianfilteringonthefullimagesetwithalargersmoothingfiltersize.Figure5showstheresultsoftheilluminationcorrectiontothisexample.AfterapplyingtheilluminationfunctioninFig.4CtotheoriginalimageusingDivisioninCorrectIllumination‐Apply,wegetthefollowingresultinFig.5B.Thecellsaremuchmoreeveninintensity,withlessvariationbetweentheouteredgesandthecenteroftheimage.Cautionshouldbeusedtomakesuretheimagesarenotover‐corrected–thatis,tomakesurethatrealvariationinthebrightnessofcellsisnotremovedusingilluminationcorrectiontechniques,disturbingthemeasurementsmadefromthecells.

    Figure5:Theoriginalimageofcells(A)correctedforilluminationvariation(B).

    Example2:Inthisexampleofanimageofnucleistainedwithhistone‐2Bcherryandcontainingalargeimageartifact(Fig.6A):

    1. Theorganismsaresparselydistributed.2. Thebackgroundoftheimageseemstoshowthepatternofillumination.3. Theilluminationpatternvariessubstantiallybetweendifferentimagesintheset

    (notshown).Anattempttoidentifythenucleiintheoriginalimagewillresultindetectionoftheartifactinadditiontothenucleipresent(Fig.6B).Becauseof(1)and(2),theBackgroundmethodisthemoreappropriateoptionforcorrectingtheimageasopposedtoRegular.Becauseof

    A B C

    A B

  • Latestrevision:11/30/2011

    6

    (3),weshouldselectEachratherthanAll,sinceeachimagewillneeditsownilluminationcorrectionfunction.

    Figure6:(A)Originalimageofnucleicorruptedwithanintensityartifact.(B).Downstreameffectonnuclei

    identification.UsingBackground+Each+MedianasinExample1yieldstheilluminationfunctionsshowninFig.7AandB.TheilluminationfunctioninFig.7A,however,usedablocksizethatwastoosmallinCorrectIllumination‐Calculate,sowhilethebackgroundintensitydistributionisvisible,someforegroundpixelswereincludedinthefunction.Uponinspection,itiseasytoseethenucleiintheilluminationfunction,whichisundesirable–portionsofthenucleiwillbeimproperlyremovedfromtheimageifthisilluminationfunctionisapplied.UsingBackground+Each+Medianwithalargerblocksizeyieldsanilluminationfunctionwhichbetterreflectstheactualbackgroundintensitydistribution(Fig.7B).

    Figure7:Azoomed‐inviewofIlluminationfunctionsproducedfromtheimageinFigure6.(A)UsingRegular

    +Each+Medianfiltering.(B)Sameas(A)withalargerblocksize.Figure8AandBdepictthecorrectedimagewiththeresultsofnucleiidentification.Withtheartifactremoved,thenucleiarenowsegmentedmuchmoreaccurately.

    B

    B

    A

    A

  • Latestrevision:11/30/2011

    7

    Figure8:(A)Correctedimageofnuclei.(B).Downstreameffectonnucleiidentification.

    Example3:InthisexampleofC.elegansnematodescontainedinawell(Fig.9):

    1. Theorganismsaresparselydistributed.2. Thebackgroundoftheimage(whiteportioninFig.9A)seemstoshowthepatternof

    illumination.3. Theilluminationpatternvariesbetweendifferentimagesintheset(notshown).4. Thepatterntendstobeaverysimpleonethatisbrighttowardsthemiddleanddim

    towardstheedgesofthewell.Thispatternistypicalforbrightfieldimages.Becauseof(1)and(2),theBackgroundmethodisthemoreappropriateoptionratherthanRegular.Becauseof(3),weshouldselectEachratherthanAll,sinceeachimagewillneeditsownilluminationcorrectionfunction.Inthisinstance,twopre‐processingstepsareperformedpriortoilluminationcorrection.First,theimageisinvertedinintensityusingtheImageMathmodule(Fig.9B),sincetheBackgroundmethodassumesthatthebackgroundiscomprisedoflowintensitypixels.Second,theregionoutsidethewellismaskedoutusingtheMaskImagemoduleinordertorestricttheareaofinteresttothewellinterior.Withoutthismethod,CorrectIllumination–Calculatewillassumethattheilluminationwasextremelydimattheedgesoftheimageandattempttocorrectthedarkregions,resultinginaveryskewedilluminationpatternneartheedgesofthewell.WechooseBackground+Each+FitPolynomialdueto(4)fromthelistabove–thepatternappearstobesimpleasisoftenthecaseforbrightfieldimages.ThisyieldstheilluminationfunctionshowninFig.9C.

    Figure9:(A)Rawimageofnematodesinawellingrayscale.(B)Theimagein(A)invertedinintensity.(C)

    Illuminationfunctionsproducedfrom(B)usingBackground+Each+FitPolynomial.

    B

    A B C

    A

  • Latestrevision:11/30/2011

    8

    However,anothercorrectionmethodisavailablewhichyieldssimilarresultsaswellasbeingeasiertouse.TheRegular+Each+ConvexHullmethodisoptimizedfortransmittedlightimageswithilluminationpatternssimilartotheoneillustratedinthisimage.Inbrief,themethodeffectively“erases”darkobjectsfromthelightbackground,whichhasthefollowingadvantagesovertheBackgroundmethodabove:

    1. Therearenorequirementsregardingthedistributionoforganismsintheimage.2. Noinversionofpixelintensities(asinFig.9B)isneededsincethemethodassumes

    theimageconsistsofadarkforegroundonalightbackground.Theimagecorrectionisappliedbydividingtheoriginalimagebytheresultantilluminationfunctioni.e.,usingDivideinCorrectIllumination–Apply.ThismethodproducestheilluminationcorrectionfunctionshowninFig.10B.Applyingthisilluminationfunctiontotheoriginalimageyieldsacorrectedimageinwhichthebackgroundilluminationwithinthewellisabsent(Fig.10C).

    Figure10:Imagesoftherawimage(A),theilluminationcorrectionfunction(B)andthecorrectedimage(C).

    A B C