SlowMLEDeNoise--Estimateunderlyingstimulusresponseassumingaslowbackgrounddriftingain[RESPONSES,SIN_WEIGHTS]=SLOWMLEDENOISE(STIM_ONSETS,STIMOFFSETS,STIMVALUES,...SPIKE_TIMES,[PARAM1,VALUE1,...]);(seeadditionaloutputargumentsbelow)Thisfunctionassumesthattheresponsetoaneuralspiketraininresponsetostimulis_icanbewrittenasr(t)=g(t)*s_i(t)wherer(t)istheactualresponseobservedasafunctionoftime,g(t)isanunknownslowbackgroundgainmodulationofthecortex,ands_i(t)istheunknownmeanresponsetoeachstimulus.Theparametersg(t)ands_i(t)areestimatedusingamaximumlikelihoodapproach.First,initialestimatesofg(t)ands_i(t)aremade.Thefunctiong(t)isfitasthesumof4sinusoids.Thesesinwavesareconstrainedtohaveverylowtemporalfrequencies,andcannottakeatemporalfrequencyfasterthan1/10ofthetotaltrialdurationbydefault(see'maxFrequency'parameterbelow).Themeasuredmeanresponsetoeachstimulusistakentobetheinitialestimateofs_i(t).Wetheniterativelyre-estimates_i(t)andg(t)toincreasethelikelihoodofthedatar(t)thatweactuallyobserved.First,s_i(t)isfixedwhileg(t)isre-estimated,andtheng(t)isfixedwhiles_i(t)isre-estimated.Thisprocessisrepeated10timesbedefault(see'numIterations'parameterbelow).Note:ThisisageneralizationofcodethatDanRubinwroteaspartofhisPhDThesis:"A Novel Circuit Model of Contextual Modulation and Normalization in Primary Visual Cortex"ColumbiaUniversity2012RESPONSESaretheestimatedmeanresponsestoeachuniquestimulus.SIN_WEIGHTSarethebest-fitamplitudecoefficientstotheunderlying4termsinusoidalfit.PARAMETERSthatcanbemodified,withdefaultvalues:'mlesmoothness':Constraintofsmoothnessofsecondderivativeofstimulus:response.Default0.1responseunitssquared/stimvaluessquared.:The2ndderivativecalculationassumessthatSTIMVALUESare:equallyspaced.Anychangethatisfasterthanthisconstraint:isnotallowed.'tFilter':Timecourseofspikeratefilter,default100(seconds)'sin_dt':Stepsizeforsmoothedsinusoidfunction,default0.1(seconds)'dt':Stepsizeforsimulatedfiringrate,default1/1000(seconds)'model':Canbe'Poisson'or'Gaussian'(caseinsensitive):Use'Poisson'forspikeresponses,and'Gaussian'for:continuous-valuedmeasurements(spikerates/voltages/etc)'responses_s_i':Responsestoeachstimulus;ifthisis:empty,thenthespikeratesarecalculatedfromthe:stimulusonandofftimes(averagerate)(default[]):Ifyouwanttocalculatetheresponsetoacontinuous:processsuchastheF1componentoravoltage,then:youmustprovidethis.:Thisquantityservesasther(t)tobefit,andalso:servesastheinitialestimateofs(t).'prerecordtime':Numberofsecondsbeforethefirststimulusthatweassume:therecordingofspikesbegan(default5)'postrecordtime':Numberofsecondsafterthelaststimulusthatweassume:therecordingofspikescontinued(default5)'maxFrequency':Maximumtemporalfrequencyofthesmoothedsinewave,where:1cycleisthedurationofthewholeexperiment.Default10'numIterations':Numberofre-estimationstepstoperform.Default10.'verbose':0/1Printswhatisgoingonasfunctionruns(default0)Onecanalsoretrieveadditionaloutputs:[RESPONSES,SIN_WEIGHT,FIT_SIN4,MLE,RESPONSE_OBSERVED,...STIMLIST,RESPONSES_S_I,SMOOTH_TIME,SMOOTH_SPIKERATE,SINFIT_SMOOTH_SPIKERATE]...=SLOWMLEDENOISE(STIM_ONSETS,STIMOFFSETS,STIMVALUES,...SPIKE_TIMES,[PARAM1,VALUE1,...]);FIT_SIN4isasetof13coefficientstoa4thordersinusoidalfit(seeSIN4_FIT),MLEistheactualmaximumlikelihoodvalueRESPONSE_OBSERVEDistheactualresponsesthatwereobserved.InthecaseofthePoissonmodel,thisisthenumberofspikesperstimulus.InthecaseoftheGaussianmodel,thisistheresponserate.STIMLISTistheorderinwhichthestimuliwerepresented;stimuliarenumberedaccordingtothevalueofSTIMVALUES,fromleasttogreatest(seehelpUNIQUE)RESPONSES_S_Iaretheresponses(r(t)*g(t))foreachstimulusinSTIMLISTExamples:seeTESTSLOWMLEandTESTSLOWMLE_MODULATION('type testSlowMLE'and'type testSlowMLE_modulation')Seealso:FIT_SIN4