#pragma rtGlobals=1 // Use modern global access method. //******************* K_FRAPcalcV8.ipf ******************************************** // Author: Kota Miura // How To Use: (rough) // 1. import data (becareful of the data format!!) // 2. set the bleaching point. // 3. do the calculation. // -- for previous history, see bottom //050714-16 added Leica data importing functions; Phair (2004) "Double Normalization", residual view in graph // Normalization process is different in these two cases. //050725 added leica data importing with 4th ROI (reference within cell) //050803 ver7b. modified leica data importing. Sharing data in two different types of normalization. Dynamic Menu //050804 added GapRatio calculation by AllCell intensity changes. original GapRatio calculatin by background estimation was modified. // when fitting background decay, y0 is now holded to 0. //050808 Option for adjusting background fitting range; fitting for the background in negative value. //050810 K_estGapRatioFromOrigin(flatback) //050811 Integrated Diffusion and Phair's Double Normalization into K_FrapCalcCore() // Integrated all types of Normalization to K_FrapCalcNormalizeCurves(FitPara_wave,normalized) // "Back Multiplly" method created // Phair's method is also possible with none-all cell data (only cell part reference) //050814 calculate gammaQ; use stdev during prebleach FRAP for measurement error. Limit fitting to certain time points //Procedure //1. get the invTau of the Background decay by fitting to a normal Exponential equation (see the equation in the help file). //2. get the initial guess for the FRAP curve by fitting it to a normal Exponential equation (same as 1) //3. Using the valuse derived from above, fit the curve to the FRAP equation. //FittingParameterWave // //0:fitmethod //1:normalized //2:width //3:background exists //4:flatback //5:BackGround_Timpoint0 //6:GapRatio // //7:I_prebleachBack //8:I_prebleachFrap //9:I_bleachfrap // //10:backamplitude //11:backtau //12:backy0 // //15:WholeCell_Exists //16:Ref_Exists //17:Base_Exists // fit method: // 0: Rainer - single exponential // 1: BackGroundMultiply-single exponential // 2: BackGroundMultiply-double exponential // 3: // 4: // 5: // 6: Double Normalization, single exponential // 7: Double Normalization, double exponential // 8: Double Normalization Ellenberg // 9:Double Normalization Soumpasis //data set types //+ 1111 () 0 FRAP + Whole Cell + Reference + Base //+ 1101 () 1 FRAP + Whole Cell + Base //- 1011 () 2 FRAP + Reference + Base //- 1100 () 3 FRAP + Whole Cell //+ 1010 () 4 FRAP + Reference //- 1001 () 5 FRAP + Base //+ 1000 () 6 FRAP Menu "Frap Calc", dynamic submenu "Import Zeiss data..." "Import Data 3: Time - Frap..", K_importFrapTxtData(2) "Import Data 3: Time - Frap - CellPart..", K_importFrapTxtData(0) "Import Data 3: Time - CellPart - Frap..", K_importFrapTxtData(1) "Import Data 8: Time - Frap - 6 CellPart..",K_importFrapTxtDataV2() "-" "Import Data 4: Time - Frap - All Cell - Base..", K_importFrapTxtData(3) //050802 "Import Data 4: Time - Frap - Base - All Cell..", K_importFrapTxtData(4) //050802 end submenu "Import Leica data..." "Import Data Ch1 Frap - AllCell - Base 12...",K_importFrapTxtData(20) "Import Data Ch2 Frap - AllCell - Base 15...",K_importFrapTxtData(21) "Import Data Ch1 Frap - AllCell - Base - Cell Part 16...",K_importFrapTxtData(22) //050725 "Import Data Ch2 Frap - AllCell - Base - Cell Part 20...",K_importFrapTxtData(23) //050725 end "-" "Fit Panel...",K_FrapFitPanel() // "weightening OFF", K_setWeightening(0) // "weightening ON", K_setWeightening(1) "-" "Set Bleach Point..",K_setBleachPoint() //"Calculate Tau Basic",K_FrapCalc() //"Calculate Tau",K_FrapCalc2() "-" "Prepare Layout",K_DOprepareLayout() "-" "Export Results as a Text File...",K_ExportResults() "Export Data as a Text File...",K_ExportData() "Export Both as Text files...",K_ExportData_Results() "-" submenu "Heiko Tools" //"Heiko Special 1",K_FrapAnalDoMultiAtOnceV2(0) //method=0: fit to "FRAP" changed to V2 040318 "Heiko Special",K_FrapAnalDoMultiAtOnceV2(1) //method=1: fit to "FRAP4" "-" "Draw Average Curve...",K_MultiAnalysisAveFit(0) "Append Average Curve...",K_MultiAnalysisAveFit(1) "-" "Heiko Special Multi Data and Results Saver",K_MultipleExportData_Results() "Heiko Special Export Reuslts Summary...",K_ExportSummaryData() end END //******************************************************************************************************************** Function K_CheckAllGV() K_checkG_BleachPoint() K_checkG_exp_Name() K_checkFit_method() K_checkWeight() checkG_CurrentExp() checkG_currentMethod() checkG_currentWidth() checkG_currentNormalized() checkG_dataForm() checkG_BackStartPnt() checkG_ExpoRainer() checkG_ExpoBackMult() checkG_ExpoPhair() K_checkG_currentMethodPopMenu() K_checkG_checkLimitRange() END Function K_setBleachPoint() //040304 for setting the bleach point. NVAR/z G_BleachPoint if( NVAR_Exists(G_BleachPoint)==0) print "G_BleachPoint created.." Variable/G G_BleachPoint=10 endif Variable BleachPoint=G_BleachPoint prompt BleachPoint, "Bleach Point? ('point' starts with 0)" Doprompt "Set Bleach Point:",BleachPoint G_BleachPoint=BleachPoint end Function K_checkG_BleachPoint()//K_checkGV() //040317 NVAR/z G_BleachPoint if( NVAR_Exists(G_BleachPoint)==0) Variable/G G_BleachPoint=10 printf "G_BleachPoint created: timepoint %f",G_BleachPoint endif end function K_checkG_exp_Name() SVAR/z G_exp_Name if( SVAR_Exists(G_exp_Name)==0) string/g G_exp_Name="tempname" endif end function K_checkFit_method() NVAR/z Fit_method if( NVAR_Exists(Fit_method)==0) Variable/G Fit_method=0 endif end function K_checkWeight() NVAR/z G_Weight if( NVAR_Exists(G_Weight)==0) Variable/G G_Weight=0 print "G_Weight created" Variable/G G_WeightLowPnt=0 Variable/G G_WeightHighPnt=10 endif end Function K_setWeightening(switching) variable switching NVAR/z G_Weight,G_WeightLowPnt,G_WeightHighPnt K_checkWeight() G_Weight=switching end function checkG_CurrentExp() SVAR/z G_CurrentExp if( SVAR_Exists(G_CurrentExp)==0) String/G G_CurrentExp=stringfromlist(0,K_FrapListExperiments()) endif end function checkG_currentMethod() NVAR/z G_currentMethod if( NVAR_Exists(G_currentMethod)==0) Variable/G G_currentMethod=0 endif end function checkG_currentWidth() NVAR/z G_currentWidth if( NVAR_Exists(G_currentWidth)==0) Variable/G G_currentWidth=0 endif end function checkG_currentNormalized() NVAR/z G_currentNormalized if( NVAR_Exists(G_currentNormalized)==0) Variable/G G_currentNormalized=0 endif end //old -050809 //2 FRAP + Whole Cell + Reference + Base //1 FRAP + Whole Cell + Base //3 FRAP + Reference + Base //4 FRAP + Whole Cell //0 FRAP + Reference //5 FRAP + Base //6 FRAP //new 050809- //1111 () 0 FRAP + Whole Cell + Reference + Base //1101 () 1 FRAP + Whole Cell + Base //1011 () 2 FRAP + Reference + Base //1100 () 3 FRAP + Whole Cell //1010 () 4 FRAP + Reference //1001 () 5 FRAP + Base //1000 () 6 FRAP //050802 function checkG_dataForm() NVAR/z G_dataForm if( NVAR_Exists(G_dataForm)==0) Variable/G G_dataForm=0 endif end //050802 // contains data form information for each and single experiment function checkG_dataFormSpecific(expname) string expname string expname_dataform=expname+"_dataform" NVAR/z G_dataFormSpec=$expname_dataform if( NVAR_Exists(G_dataFormSpec)==0) Variable/G $expname_dataform endif return G_dataFormSpec end //050808 function checkG_BackStartPnt() NVAR/z G_BackStartPnt if( NVAR_Exists(G_BackStartPnt)==0) K_checkG_BleachPoint() NVAR/z G_BleachPoint Variable/G G_BackStartPnt=G_BleachPoint endif end //050809 for panel function checkG_ExpoRainer() NVAR/z G_ExpoRainer if( NVAR_Exists(G_ExpoRainer)==0) Variable/G G_ExpoRainer=0 endif end //050809 for panel function checkG_ExpoBackMult() NVAR/z G_ExpoBackMult if( NVAR_Exists(G_ExpoBackMult)==0) Variable/G G_ExpoBackMult=0 endif end //050809 for panel function checkG_ExpoPhair() NVAR/z G_ExpoPhair if( NVAR_Exists(G_ExpoPhair)==0) Variable/G G_ExpoPhair=0 endif end //050809 for panel function K_expo_OneOutOfThree() checkG_ExpoRainer() NVAR/z G_ExpoRainer checkG_ExpoBackMult() NVAR/z G_ExpoBackMult checkG_ExpoPhair() NVAR/z G_ExpoPhair if (G_ExpoRainer) G_ExpoBackMult=0 G_ExpoPhair=0 endif if (G_ExpoBackMult) G_ExpoRainer=0 G_ExpoPhair=0 endif if (G_ExpoPhair) G_ExpoBackMult=0 G_ExpoRainer=0 endif end Function K_checkG_currentMethodPopMenu() NVAR/z G_currentMethodPopMenu if (NVAR_exists(G_currentMethodPopMenu)==0) variable/g G_currentMethodPopMenu=1 endif END Function K_checkG_checkLimitRange() NVAR/z G_checkLimitRange if (NVAR_exists(G_checkLimitRange)==0) variable/g G_checkLimitRange=0 endif END //*** WINNAMES Function/s K_GraphWinname(exp_name)//,method) string exp_name //variable method string window_name=exp_name+"_Frap_Fitting"//_mode"+num2str(method) return window_name END Function/s K_ResultsWinname(exp_name)//,method) string exp_name //variable method string window_name=exp_name+"_Frap_Fitting_results"//_mode"+num2str(method) return window_name END Function/s K_DataWinname(exp_name)//,method) string exp_name //variable method string window_name=exp_name+"_Frap_Data"//_mode"+num2str(method) return window_name END //****************** UTILITIES************************************************************************************** Function K_checkWindow(windowname) // returns 0 if the window is not existing 0403118 string windowname string ListGraph=WinList("*",";","WIN:3") variable NumberofGraphs=ItemsInList(ListGraph) variable i,j j=0 string current_string for (i=0;i5) && (Fit_method<10) && (normalized==0)) //Frapwave[]=(Frapwave[p]-I_Bleach_Frap)/fullscale if (WholeCell_Exists) Frapwave[]=Frapwave[p]*I_Prebleach_AllCell/AllCellwave[p]/I_Prebleach_Frap //Double (single) Normalization else if (Ref_Exists) Frapwave[]=Frapwave[p]*I_Prebleach_Ref/Refwave[p]/I_Prebleach_Frap //reference normalization else Frapwave[]=Frapwave[p]/I_Prebleach_Frap //single normalization endif endif if ((Fit_method==8) || (Fit_method==9)) //diffusion fitting I_Bleach_Frap=Frapwave[G_BleachPoint] wavestats/q/r=[0,G_BleachPoint-1] Frapwave fullscale=V_avg-I_Bleach_Frap Frapwave[]=(Frapwave[p]-I_Bleach_Frap)/fullscale endif endif wavestats/q/r=[0,G_BleachPoint-1] Frapwave I_Prebleach_Frap_norm=V_avg printf "Normalized: Prebleach Frap %g :: ",I_Prebleach_Frap_norm FitPara_wave[8]=I_Prebleach_Frap_norm if (WholeCell_Exists) wavestats/q/r=[0,G_BleachPoint-1] AllCellwave I_Prebleach_Allcell_norm=V_avg printf "Prebleach whole cell %g\r",I_Prebleach_Allcell_norm FitPara_wave[7]=I_Prebleach_Allcell_norm else if (Ref_Exists) wavestats/q/r=[0,G_BleachPoint-1] Refwave I_Prebleach_Ref_norm=V_avg printf "Prebleach reference %g\r",I_Prebleach_Ref_norm FitPara_wave[7]=I_Prebleach_Ref_norm else printf "No reference\r" FitPara_wave[7]=0 endif endif FitPara_wave[15]=WholeCell_Exists FitPara_wave[16]=Ref_Exists FitPara_wave[17]=Base_Exists //return I_Prebleach_Back_norm END // Used for Rainer's method and back Multiply method. Function K_FrapBackgroundGuess(decwave_y,decwave_x,FitPara_wave) wave decwave_y,decwave_x,FitPara_wave NVAR G_BleachPoint variable invTau2,decA,decY0 string decwave_ynm_norm=nameofwave(decwave_y) variable FlatBackground=FitPara_wave[4] SVAR/z G_CurrentExp string WinNameFit=K_GraphWinname(G_CurrentExp)//,fit_method) if (FlatBackground==1) // fit the background bleaching checkG_BackStartPnt() //050808 NVAR/z G_BackStartPnt //050808 //(1) hold y0 to 0 so that the real back ground is equal to the FRAP-bleached fluorescence level. //K0=0 //CurveFit/H="100"/W=0/Q exp decwave_y[G_BackStartPnt,] /X=decwave_x /D //(2) real backgroun dlevel (offset) is estimated by fitting also. CurveFit/H="000"/W=0/Q exp decwave_y[G_BackStartPnt,] /X=decwave_x /D wave/z W_coef //ModifyGraph mode($decwave_ynm_norm)=3,rgb($decwave_ynm_norm)=(0,15872,65280) //string decayFitnm //decayFitnm="fit_"+decwave_ynm_norm //ModifyGraph/w=$WinNameFit rgb($("fit_"+nameofwave(decwave_y)))=(0,15872,65280) invTau2=W_coef[2] decA=W_coef[1] decY0=W_coef[0] if ((numtype(invTau2)!=0)) //rescue for non-fitting and increaseing flourescence wavestats/q/R=[G_BackStartPnt,] decwave_y invTau2=0 decA=0 decY0=V_avg printf "--- Bad Fitting for the Back decay. background level set to %g (time point 0)----\r",decY0 FlatBackground=0 //flat endif if ((invTau2<=0) || (decA<=0)) //050808 then the background is increasing or badly shaped wavestats/q/R=[G_BackStartPnt,] decwave_y invTau2=0 decA=0 decY0=V_avg printf "--- Decay curve is flat or increasing . background level set to %g (Average of Post Bleach)----\r",decY0 FlatBackground=0 //FitPara_wave[4]=0 //flat endif else //flat background 050203 printf "Background is flat\r" //decayFitnm="fit_"+decwave_ynm_norm //duplicate/o decwave_y $decayFitnm wavestats/q/R=[G_BackStartPnt,] decwave_y invTau2=0 decA=0 decY0=V_avg endif printf "Fit Background (%s): invTau=%g A=%g ",nameofwave(decwave_y),invTau2,decA printf "y0=%g\r",decY0 FitPara_wave[10]=decA FitPara_wave[11]=invTau2 FitPara_wave[12] =decY0 //prepare Background curve normalized to 1 040324 //050804 if ((normalized==0) && (invtau2!=0)) //050804 decA=decA/BackGround_Timpoint0 //040324 //050804 endif //050804 decY0=decY0/BackGround_Timpoint0 //040324 //printf "Fit Background: invTau=%g A=%g ",invTau2,decA //printf "C=%g\r",BackGround_Timpoint0 END function K_FrapTimetoPnt(decwave_x,timepoint) wave decwave_x variable timepoint variable correspnt,i for (i=0;i1) print "---Gap Ratio > 1 (by Original Reference curve): Gap Ratio set to 1.---" GapRatio=1 endif Killwaves tempDecayOrig return GapRatio end // Renewed 050811 Function K_FrapCalcCore()//decwave_xnm,decwave_ynm,Frapwave_ynm,FitPara_wave) // Normalizing version.//040324 SVAR/z G_CurrentExp NVAR/z G_dataFormSpec=$(G_CurrentExp+"_dataform") string FitPara_wavename=G_CurrentExp+"_parameter" make/o/N=30 $FitPara_wavename wave FitPara_wave=$FitPara_wavename NVAR Fit_method //used for functions from menu :: to be replaced NVAR G_currentMethod Fit_method=G_currentMethod FitPara_wave[0]=Fit_method NVAR/z G_BleachPoint K_checkG_BleachPoint() variable normalized=FitPara_wave[1] printf "%s (",G_CurrentExp printf "%s)\r",K_ReturnMethods(Fit_method) String decwave_xnm,decwave_ynm,Frapwave_ynm String Original_t,Original_Back,Original_Frap,Original_base,Original_AllCell Original_base=G_CurrentExp+"_base" //050802 Original_AllCell=G_CurrentExp+"_AllCell" Original_Back=G_CurrentExp+"_bkgAv" Original_Frap=G_CurrentExp+"_FRAP" Original_t=G_CurrentExp+"_t" wave/z t_original=$Original_t wave/z Frap_original=$Original_Frap if ((G_dataFormSpec==1000) || (G_dataFormSpec==1001)) make/o/n=(numpnts(t_original)) $Original_Back wave/z Back_Original=$Original_Back Back_Original[]=1 FitPara_wave[3]=0 //reference is dummy else if ((G_dataFormSpec==1100) || (G_dataFormSpec==1101)) FitPara_wave[3]=0 else FitPara_wave[3]=1 endif endif variable FlatBackground //checks if the back ground curve is flat. wave/z AllCell_Original=$Original_AllCell wave/z Back_Original=$Original_Back if (waveexists(AllCell_Original)) FlatBackground=CheckFlatBackground(AllCell_Original) //0 if it is flat printf "Allcell: FlatBackground=%g\r",FlatBackground else if (waveexists(Back_Original)) FlatBackground=CheckFlatBackground(Back_Original) //0 if it is flat printf "Ref: FlatBackground=%g\r",FlatBackground else FlatBackground=-1 endif endif FitPara_wave[4]=FlatBackground //""""""""""""' Normalization ********************************* //variable I_Prebleach_Back_norm K_FrapCalcNormalizeCurves(FitPara_wave,normalized) //050306 //FitPara_wave[7]=I_Prebleach_Back_norm //I_Prebleach_FRAP_norm==always 1 050307 String Norm_t,Norm_Back,Norm_Frap,Norm_base,Norm_AllCell //Normalized Norm_t=(Original_t+"_c") Norm_base=Original_base+"_norm" Norm_AllCell=Original_AllCell+"_norm" Norm_Back=Original_Back+"_norm" Norm_Frap=Original_Frap+"_norm" wave Frapwave=$Norm_Frap wave timewave=$Norm_t variable WholeCell_Exists,Ref_Exists,Base_Exists WholeCell_Exists=FitPara_wave[15] Ref_Exists=FitPara_wave[16] Base_Exists=FitPara_wave[17] if (WholeCell_Exists) wave AllCellWave=$Norm_AllCell endif if (Ref_Exists) wave RefWave=$Norm_Back endif if (Base_Exists) wave BaseWave=$Norm_base endif //****************************** Graphing all possible background ********************************** //SVAR/z G_exp_name string WinNameFit=K_GraphWinname(G_CurrentExp)//,fit_method) if (Fit_method<3) //Rainer or Back Multiply DoWindow/f $WinNameFit if (V_flag==0) if (WholeCell_Exists) Display/L=frapaxis AllCellWave vs timewave ModifyGraph mode($Norm_AllCell)=3,marker($Norm_AllCell)=8,rgb($Norm_AllCell)=(16384,28160,65280) if (Ref_Exists) AppendToGraph/L=frapaxis RefWave vs timewave ModifyGraph mode($Norm_Back)=3,marker($Norm_Back)=8,rgb($Norm_Back)=(16384,28160,65280) endif else if (Ref_Exists) Display/L=frapaxis RefWave vs timewave ModifyGraph mode($Norm_Back)=3,marker($Norm_Back)=8,rgb($Norm_Back)=(16384,28160,65280) endif endif if ((WholeCell_Exists==1) || (Ref_Exists==1)) ModifyGraph lblPos(frapaxis)=40 Label frapaxis "Relative Fl. Intensity" Label bottom "Time [s]" SetAxis/A/E=0 frapaxis DoWindow/c $WinNameFit //give the windowname DoWindow/T $WinNameFit, WinNameFit endif else if ((K_checkTraceInGraph(WinNameFit,Norm_AllCell)==0) && (WholeCell_Exists==1)) appendtograph /L=frapaxis AllCellWave vs timewave ModifyGraph mode($Norm_AllCell)=3,marker($Norm_AllCell)=8,rgb($Norm_AllCell)=(16384,28160,65280) endif if ((K_checkTraceInGraph(WinNameFit,Norm_Back)==0) && (Ref_Exists==1)) appendtograph /L=frapaxis RefWave vs timewave ModifyGraph mode($Norm_Back)=3,marker($Norm_Back)=8,rgb($Norm_Back)=(16384,28160,65280) endif if (K_checkTraceInGraph(WinNameFit,("fit_"+Norm_AllCell))==1) Removefromgraph/z $("fit_"+Norm_AllCell) endif if (K_checkTraceInGraph(WinNameFit,("fit_"+Norm_Back))==0) Removefromgraph/z $("fit_"+Norm_Back) endif endif endif //""""""""""""' Decay study ********************************* variable GapRatio,invTau2,decA,decY0 if (Fit_method==0) if (WholeCell_Exists) K_FrapBackgroundGuess(AllCell_Original,timewave,FitPara_wave) else if (Ref_Exists) K_FrapBackgroundGuess(Back_Original,timewave,FitPara_wave) endif endif endif if ((Fit_method==1) || (Fit_method==2)) if (WholeCell_Exists) K_FrapBackgroundGuess(AllCellWave,timewave,FitPara_wave) else if (Ref_Exists) K_FrapBackgroundGuess(RefWave,timewave,FitPara_wave) endif endif endif if (FlatBackground==0) GapRatio=1 else GapRatio=K_retGapRatio(FitPara_wave) endif decA=FitPara_wave[10] invTau2= FitPara_wave[11] decY0= FitPara_wave[12] if (Fit_method>3) //double normalization don't have graph yet DoWindow/f $WinNameFit if (V_flag==0) Display/L=frapaxis Frapwave vs timewave ModifyGraph mode($Norm_Frap)=3,marker($Norm_Frap)=8 ModifyGraph lblPos(frapaxis)=40 Label frapaxis "Relative Fl. Intensity" Label bottom "Time [s]" SetAxis/A/E=0 frapaxis DoWindow/c $WinNameFit //give the windowname DoWindow/T $WinNameFit, WinNameFit else if (K_checkTraceInGraph(WinNameFit,Norm_AllCell)==1) RemoveFromGraph/z $Norm_AllCell RemoveFromGraph/z $("fit_"+Norm_AllCell) endif if (K_checkTraceInGraph(WinNameFit,Norm_Back)==1) RemoveFromGraph/z $Norm_Back RemoveFromGraph/z $("fit_"+Norm_Back) endif endif endif if (K_checkTraceInGraph(WinNameFit,nameofwave(Frapwave))==0) AppendToGraph/L=frapaxis Frapwave vs timewave ModifyGraph mode($Norm_Frap)=3,marker($Norm_Frap)=8 endif //**************************fitting of the frap curve to derive Guessing values variable y0_guess,amplitude_guess,invTau1_guess if ((Fit_method!=6) && (Fit_method!=7)) CurveFit/W=0/Q exp Frapwave[G_BleachPoint,] /X=timewave /D wave/z W_coef y0_guess=W_coef[0] amplitude_guess=W_coef[1] invTau1_guess=W_coef[2] printf "Frap Guess Values: A %g, invTau %g\r",amplitude_guess,invTau1_guess endif //------------------------------fitting of the frap curve to get the real answer variable HL,invTau,amplitude,backTau variable tauD_guess variable DifCoef,tauD variable amplitude_Ellenberg_guess,DifCoef_guess variable y0,amplitudeA,invTauA,amplitudeB,invTauB NVAR/z G_weight K_checkWeight() Duplicate/o Frapwave $(Norm_Frap+"w") //****** Weighting **************************************** wave/z frapweight=$(Norm_Frap+"w") wavestats/q/r=[0,G_BleachPoint-1] Frapwave //050814 for deriving measurement error variable sdev_measure=V_sdev variable avg_measure=V_avg //frapweight[]=Frapwave[p]*V_sdev/V_avg //050816 frapweight=sdev_measure NVAR/z G_WeightLowPnt,G_WeightHighPnt if (G_weight==1) frapweight[K_FrapTimetoPnt(timewave,G_WeightLowPnt),K_FrapTimetoPnt(timewave,G_WeightHighPnt)]=sdev_measure*0.2 //frapweight[]=frapweight[p]/2+0.1 endif //****** Weighting end**************************************** NVAR/z G_checkLimitRange variable fit_start,fit_end if (G_checkLimitRange==1) fit_start=K_FrapTimetoPnt(timewave,G_WeightLowPnt) fit_end=K_FrapTimetoPnt(timewave,G_WeightHighPnt) printf "fit limit from pnt %g to %g\r",fit_start,fit_end else fit_start=G_BleachPoint fit_end=numpnts(Frapwave)-1 endif //Prepare estimaiton curve string FrapFitnm="fit_"+Norm_Frap string FrapFit_estimationName="fit_"+Norm_Frap+"_est" Duplicate/O $Norm_Frap $FrapFit_estimationName wave FrapEst=$FrapFit_estimationName string residuewavename,residueTwavename residuewavename=K_CreateResidueWave(Frapwave,timewave) wave/z residuewave=$residuewavename wave/z residueTwave=$(residuewavename+"t") // Fitting and create estimation curve variable V_FitTol=0.0001 wave/z W_coef NVAR/z G_currentWidth switch (fit_method) case 0: //040330 Rainer's method //amplitude_guess*=-1 amplitude_guess=0.9 //050804 W_coef = {amplitude_guess,invTau1_guess,invTau2} FuncFit/W=0/H="001" FRAP W_coef Frapwave[fit_start,fit_end] /X=timewave/I=1/W=$(nameofwave(frapweight)) /D/R=$residuewavename/A=0 //040317 amplitude=W_coef[0] invTau=W_coef[1] backTau=W_coef[2] HL=(ln(0.5)/invTau*-1) //040303 FrapEst[]=amplitude/invTau*(invTau+BackTau)*(1-exp(-1*invTau*timewave[p])) break case 1: // background multiply single exponential amplitude_guess=0.9 //050804 //W_coef = {decA,amplitude_guess,invTau1_guess,invTau2,1} //050812 //W_coef = {decA,amplitude_guess,invTau1_guess,invTau2,(decY0/GapRatio)} //040324//050812 W_coef = {decA,amplitude_guess,invTau1_guess,invTau2,(decY0)} //040324 FuncFit/W=0/H="10011" FRAP4 W_coef Frapwave[fit_start,fit_end] /X=timewave/I=1/W=$(nameofwave(frapweight)) /D/R=$residuewavename/A=0 amplitude=W_coef[1] invTau=W_coef[2] backTau=W_coef[3] HL=(ln(0.5)/invTau*-1) //040303 //Duplicate/o Frapwave TempBack //TempBack[]=(decY0/GapRatio)+decA*exp(-1*invTau2*timewave[p]) FrapEst[]=amplitude*(1-exp(-1*invTau*timewave[p])) break case 2: // background multiply double exponential //this doesn't work currently 050808 amplitude_guess=0.9 //050804 W_coef = {decA,amplitude_guess,invTau1_guess,invTau2,decY0} //040324 FuncFit/W=0/H="10011" FRAP4 W_coef Frapwave[fit_start,fit_end] /X=timewave/I=1/W=$(nameofwave(frapweight)) /D/R=$residuewavename/A=0 amplitude=W_coef[1] invTau=W_coef[2] backTau=W_coef[3] HL=(ln(0.5)/invTau*-1) //040303 FrapEst[]=amplitude*(1-exp(-1*invTau*timewave[p])) break case 6: //fitting to the single exponetial //amplitude_guess=0.9 //W_coef = {y0_guess,amplitude_guess,invTau1_guess} //FuncFit/W=0/H="000" FRAP_exp2 W_coef Frapwave[G_BleachPoint,] /X=timewave/I=1/W=$(nameofwave(frapweight)) /D/R=$residuewavename/A=0 //040317 CurveFit/W=0/Q/H="000" exp Frapwave[fit_start,fit_end] /X=timewave/I=1/W=$(nameofwave(frapweight)) /D/R=$residuewavename/A=0 y0=W_coef[0] amplitudeA=W_coef[1] invTauA=W_coef[2] FrapEst[]=y0+amplitudeA*exp(-1*invTauA*timewave[p]) HL=(ln(0.5)/invTauA*-1) //040303 break case 7: //direct fitting of the double exponetial CurveFit/W=0/Q/H="00000" dblexp Frapwave[fit_start,fit_end] /X=timewave/I=1/W=$(nameofwave(frapweight)) /D/R=$residuewavename/A=0 //CurveFit/W=0/Q exp Frapwave_y[BleachPoint] /X=decwave_x /D wave/z W_coef y0=W_coef[0] amplitudeA=W_coef[1] invTauA=W_coef[2] amplitudeB=W_coef[3] invTauB=W_coef[4] printf "y0=%g, A1=%g, invTau1=%g A2=%g, invTau2=%g \r",y0,amplitudeA,invTauA,amplitudeB,invTauB FrapEst[]=y0+amplitudeA*(exp(-1*invTauA*timewave[p]))+amplitudeB*(exp(-1*invTauB*timewave[p])) HL=K_HalfLifeFromEst(FrapEst,timewave,y0,G_BleachPoint) break case 8://2: //double normalized diffusion - ellenberg if (G_currentWidth==0) abort "Set Frap Width" endif amplitude_Ellenberg_guess=y0_guess //040818 DifCoef_guess=K_DiffCoefestimateFromInvTau(invTau1_guess,y0_guess,amplitude_guess,G_currentWidth) //040818 W_coef = {amplitude_Ellenberg_guess,G_currentWidth,DifCoef_guess} //040429 FuncFit/W=0/H="010" FRAP_Ellenberg W_coef Frapwave[fit_start,fit_end] /X=timewave/I=1/W=$(nameofwave(frapweight)) /D/R=$residuewavename/A=0 //040429 amplitude=W_coef[0] DifCoef=W_coef[2] //HL=(3*width^2)/4/pi/DifCoef //040429 //HL=(width^2)/12/pi/DifCoef //040719 HL=0.75*(G_currentWidth^2)/pi/DifCoef //040719 // FrapEst[]=W_coef[0]*(1-(width^2*(width^2+4*pi*DifCoef*decwave_x[p])^-1 ))^0.5/(decY0+decA*exp(invTau2*decwave_x[p])) FrapEst[]=W_coef[0]*(1-((G_currentWidth^2*(G_currentWidth^2+4*pi*DifCoef*timewave[p])^-1 ))^0.5) //050307 break case 9://3: //double normalized diffusion soumpasis if (G_currentWidth==0) abort "Set Frap Width" endif amplitude_Ellenberg_guess=y0_guess //040818 DifCoef_guess=K_DiffCoefestimateFromInvTau(invTau1_guess,y0_guess,amplitude_guess,G_currentWidth) //040818 W_coef = {amplitude_Ellenberg_guess,G_currentWidth,DifCoef_guess} //040429 FuncFit/W=0/H="010" FRAP_Ellenberg W_coef Frapwave[fit_start,fit_end] /X=timewave/I=1/W=$(nameofwave(frapweight)) /D/R=$residuewavename/A=0 //040429 //V_FitTol=0.01 amplitude_guess=W_coef[0] tauD_guess=(G_currentWidth^2)/W_coef[2] W_coef = {amplitude_guess,tauD_guess} //if (G_weight==1) FuncFit/W=0/H="00" FRAP_soumpasis W_coef Frapwave[fit_start,fit_end] /X=timewave/I=1/W=$(nameofwave(frapweight)) /D/R=$residuewavename/A=0 //050305 //else //FuncFit/W=0/H="00" FRAP_soumpasis W_coef Frapwave_y[G_BleachPoint,] /X=decwave_x /D //050305 //endif amplitude=W_coef[0] tauD=W_coef[1] DifCoef=(G_currentWidth^2)/tauD // FrapEst[]=(W_coef[0]*(e^(-1*W_coef[1]/2/decwave_x[p]))*( bessI(0,(W_coef[1]/2/decwave_x[p]))+bessI(1,(W_coef[1]/2/decwave_x[p])) ))/(decY0+decA*exp(invTau2*decwave_x[p])) FrapEst[]=(W_coef[0]*(e^(-1*W_coef[1]/2/timewave[p]))*( bessI(0,(W_coef[1]/2/timewave[p]))+bessI(1,(W_coef[1]/2/timewave[p])) )) HL=K_SoumpasisHalfLife(FrapEst,timewave,amplitude,G_BleachPoint,Frapwave) break default: endswitch ModifyGraph/z lsize($("fit_"+nameofwave(Frapwave)))=2,rgb($("fit_"+nameofwave(Frapwave)))=(32768,40704,65280) NVAR/z G_chisq if (NVAR_exists(G_chisq)==0) variable/g G_chisq endif G_chisq=V_chisq NVAR/z G_gammaq if (NVAR_exists(G_gammaq)==0) variable/g G_gammaq endif G_gammaq=gammq((V_npnts-2)/2, G_chisq/2) FrapEst[0,(G_BleachPoint-1)]=NaN printf "Half Max: %g [s]\r",HL //040303 //Graphing if (K_checkTraceInGraph(WinNameFit,nameofwave(FrapEst))==0) AppendToGraph/L=frapaxis FrapEst vs timewave ModifyGraph rgb($FrapFit_estimationName)=(52224,52224,0) ModifyGraph lstyle($FrapFit_estimationName)=3 endif K_AppendResidueWave(residuewave, residueTwave) // residue plotting ////050714 // K_GraphResidue(Frapwave,FrapEst,timewave) //Calculate Mobile-Immobile fractions variable MobileFraction, ImmobileFraction //040303 switch (fit_method) case 0: MobileFraction=(amplitude/invTau*(invTau+BackTau))/GapRatio break case 1: //MobileFraction=amplitude/GapRatio MobileFraction=amplitude break case 2: //MobileFraction=amplitude/GapRatio MobileFraction=amplitude break case 6: //MobileFraction=(y0) MobileFraction=(y0-FrapEst[G_BleachPoint])/(1-FrapEst[G_BleachPoint]) break case 7: //MobileFraction=(y0) MobileFraction=(y0-FrapEst[G_BleachPoint])/(1-FrapEst[G_BleachPoint]) break case 8: //ellenberg MobileFraction=(amplitude) break case 9: //soumpasis MobileFraction=(amplitude) break endswitch if (MobileFraction>1) Printf "----The Mobile fraction was over 1 (%g)---\r",MobileFraction MobileFraction=1 endif ImmobileFraction=1-MobileFraction //040303 printf "Mobile Fraction: %g\r",MobileFraction //040303 printf "Immobile Fraction: %g\r",ImmobileFraction //040303 printf "Chi-Sq: %g GammaQ: %g\r",G_chisq,G_gammaq //040303 printf "%s %g %g %g %g %g\r",G_CurrentExp,HL,MobileFraction,ImmobileFraction,G_chisq,G_gammaq print "*******************************************************************" string BackName if (wholecell_exists) BackName=Norm_AllCell else BackName=Norm_Back endif string Txt1 switch (fit_method) case 0: Txt1="\\Z08\\s("+Norm_Frap+") FRAP Rainer A="+num2str(amplitude)+" iTau1="+num2str(invTau)+"\r\\s(" Txt1+=BackName+") Background iTau2="+num2str(backTau)+"\rHalf Max:"+num2str(HL) Txt1+="s Mobile: "+num2str(MobileFraction)+"\r\\s("+FrapFit_estimationName+") Estimation" Txt1+="\rChiSq="+num2str(G_chisq)+" GammaQ="+num2str(G_gammaq) break case 1: Txt1="\\Z08\\s("+Norm_Frap+") FRAP BackMulti A="+num2str(amplitude)+" iTau1="+num2str(invTau) Txt1+="\r\\s("+BackName+") Background iTau2="+num2str(backTau)+"\rHalf Max:"+num2str(HL) Txt1+="s Mobile: "+num2str(MobileFraction)+"\r\\s("+FrapFit_estimationName+") Estimation" Txt1+="\rChiSq="+num2str(G_chisq)+" GammaQ="+num2str(G_gammaq) break case 2: //back multiply norm double exp Txt1="\\Z08\\s("+Norm_Frap+") FRAP BackMulti A="+num2str(amplitude)+" iTau1="+num2str(invTau) Txt1+="\r\\s("+BackName+") Background iTau2="+num2str(backTau)+"\rHalf Max:"+num2str(HL) Txt1+="s Mobile: "+num2str(MobileFraction)+"\r\\s("+FrapFit_estimationName+") Estimation" Txt1+="\rChiSq="+num2str(G_chisq)+" GammaQ="+num2str(G_gammaq) break case 6: //double norm single exp Txt1="\\Z08\\s("+Norm_Frap+") Single exponential\ry0="+num2str(y0)+" A1="+num2str(amplitudeA) Txt1+="\riTau1="+num2str(invTauA)+"\rHalf Max:"+num2str(HL)+"s Mob. Frac: "+num2str(MobileFraction) Txt1+="\r\\s("+FrapFit_estimationName+") Estimation"+"\rChiSq="+num2str(G_chisq)+" GammaQ="+num2str(G_gammaq) break case 7: //double norm dpouble exp Txt1="\\Z08\\s("+Norm_Frap+") Double exponential\ry0="+num2str(y0)+"\rA1="+num2str(amplitudeA)+" iTau1="+num2str(invTauA) Txt1+="\rA2="+num2str(amplitudeB)+" iTau2="+num2str(invTauB)+"\rHalf Max:"+num2str(HL)+"s Mob. Frac: "+num2str(MobileFraction) Txt1+="\r\\s("+FrapFit_estimationName+") Estimation"+"\rChiSq="+num2str(G_chisq)+" GammaQ="+num2str(G_gammaq) break case 8://2: elllenberg Txt1="\\Z08\\s("+Norm_Frap+") FRAP Ellenberg\rA="+num2str(amplitude)+"\rDiffusion Coef="+num2str(DifCoef) Txt1+="\r\\s("+BackName+") Background\rHalf Max:"+num2str(HL)+"s\r\\s("+FrapFit_estimationName+") Estimation" Txt1+="\rChiSq="+num2str(G_chisq)+" GammaQ="+num2str(G_gammaq) break case 9://3: soumpasis Txt1="\\Z08\\s("+Norm_Frap+") FRAP Soumpasis\rA="+num2str(amplitude)+"\rDiffusion Coef="+num2str(DifCoef) Txt1+="\r\\s("+BackName+") Background\r\\s("+FrapFit_estimationName+") Estimation" Txt1+="\rChiSq="+num2str(G_chisq)+" GammaQ="+num2str(G_gammaq) break endswitch TextBox/W=$WinNameFit/C/N=text0/A=RB/F=0/B=1 Txt1 K_FrapResultTable(HL,MobileFraction,ImmobileFraction) return HL END Function K_FrapResultTable(HL,MobileFraction,ImmobileFraction) Variable HL,MobileFraction,ImmobileFraction NVAR/z fit_method NVAR/z G_chisq NVAR/z G_gammaq SVAR/z G_CurrentExp wave W_coef wave W_sigma string ResultsWaveName=K_nameFrapResultsWave(G_CurrentExp) switch(fit_method) case 0: Make/o/n=11 $ResultsWaveName wave FRAP_Results=$ResultsWaveName wave W_sigma FRAP_Results[0]=HL FRAP_Results[1]=abs(W_sigma[1]*ln(0.5)/W_coef[1]/W_coef[1]) //HL s.d. FRAP_Results[2]=MobileFraction FRAP_Results[3]=W_sigma[0] FRAP_Results[4]=ImmobileFraction FRAP_Results[5]=W_sigma[0] FRAP_Results[6]=W_coef[0] FRAP_Results[7]=W_coef[1] FRAP_Results[8]=W_coef[2] FRAP_Results[9]=G_chisq FRAP_Results[10]=G_gammaq Make/O/T/N=11 ResultParameterText ResultParameterText={"Half Life","Half Life s.d.","Moblie Fraction","Moblie Fraction s.d.","Immobile Fraction","Immobile Fraction s.d.","A","InvTau1","DecayInvTau2","ChiSq","gammaQ"} break case 1: Make/o/n=13 $ResultsWaveName wave FRAP_Results=$ResultsWaveName wave W_sigma FRAP_Results[0]=HL FRAP_Results[1]=abs(W_sigma[2]*ln(0.5)/W_coef[2]/W_coef[2]) //HL s.d. FRAP_Results[2]=MobileFraction FRAP_Results[3]=W_sigma[1] FRAP_Results[4]=ImmobileFraction FRAP_Results[5]=W_sigma[1] FRAP_Results[6]=W_coef[1] //A (Frap) FRAP_Results[7]=W_coef[2] //invtau1 FRAP_Results[8]=W_coef[3] //invtau2 FRAP_Results[9]=W_coef[4] //decay y0 FRAP_Results[10]=W_coef[0] //A (decay) FRAP_Results[11]=G_chisq FRAP_Results[12]=G_gammaq Make/O/T/N=13 ResultParameterText ResultParameterText={"Half Life","Half Life s.d.","Moblie Fraction","Moblie Fraction s.d.","Immobile Fraction","Immobile Fraction s.d.","A","InvTau1","DecayInvTau2","DecayY0","DecayA","ChiSq","gammaQ"} case 2: break case 6: //double norm single exp Make/o/n=14 $ResultsWaveName wave FRAP_Results=$ResultsWaveName wave W_sigma FRAP_Results[0]=HL FRAP_Results[1]=0//abs(W_sigma[1]*ln(0.5)/W_coef[1]/W_coef[1]) //HL s.d. FRAP_Results[2]=MobileFraction FRAP_Results[3]=W_sigma[0] FRAP_Results[4]=ImmobileFraction FRAP_Results[5]=W_sigma[0] FRAP_Results[6]=W_coef[1] // A1 (Frap) FRAP_Results[7]=W_sigma[1] FRAP_Results[8]=W_coef[2] //InvTau1 FRAP_Results[9]=W_sigma[2] //InvTau1 sd FRAP_Results[10]=W_coef[0] // y0 (Frap) FRAP_Results[11]=W_sigma[0] FRAP_Results[12]=G_chisq FRAP_Results[13]=G_gammaq Make/O/T/N=14 ResultParameterText ResultParameterText={"Half Life","Half Life s.d.","Moblie Fraction","Moblie Fraction s.d.","Immobile Fraction","Immobile Fraction s.d.","A1","A1sd","invTau1","invTau1sd","y0","y0sd","ChiSq","gammaQ"} //K_renameFrapResultsWave(G_exp_name) break case 7: //double norm double exp Make/o/n=18 $ResultsWaveName wave FRAP_Results=$ResultsWaveName wave W_sigma FRAP_Results[0]=HL FRAP_Results[1]=0//abs(W_sigma[1]*ln(0.5)/W_coef[1]/W_coef[1]) //HL s.d. FRAP_Results[2]=MobileFraction FRAP_Results[3]=W_sigma[0] FRAP_Results[4]=ImmobileFraction FRAP_Results[5]=W_sigma[0] FRAP_Results[6]=W_coef[1] // A1 (Frap) FRAP_Results[7]=W_sigma[1] FRAP_Results[8]=W_coef[2] //invTau1 FRAP_Results[9]=W_sigma[2] //InvTau1 sd FRAP_Results[10]=W_coef[3] // A2 (Frap) FRAP_Results[11]=W_sigma[3] FRAP_Results[12]=W_coef[4] //invTau2 FRAP_Results[13]=W_sigma[4] //InvTau2 sd FRAP_Results[14]=W_coef[0] // y0 (Frap) FRAP_Results[15]=W_sigma[0] FRAP_Results[16]=G_chisq FRAP_Results[17]=G_gammaq Make/O/T/N=18 ResultParameterText ResultParameterText={"Half Life","Half Life s.d.","Moblie Fraction","Moblie Fraction s.d.","Immobile Fraction","Immobile Fraction s.d.","A1","A1sd","invTau1","invTau1sd","A2","A2sd","invTau2","invTau2sd","y0","y0sd","ChiSq","gammaQ"} //K_renameFrapResultsWave(G_exp_name) break case 8: //ellenberg Make/o/n=11 $ResultsWaveName wave FRAP_Results=$ResultsWaveName wave W_sigma FRAP_Results[0]=HL FRAP_Results[1]=0//abs(W_sigma[1]*ln(0.5)/W_coef[1]/W_coef[1]) //HL s.d. FRAP_Results[2]=MobileFraction FRAP_Results[3]=W_sigma[0] FRAP_Results[4]=ImmobileFraction FRAP_Results[5]=W_sigma[0] FRAP_Results[6]=W_coef[0] //A (Frap) FRAP_Results[7]=W_coef[1] //width FRAP_Results[8]=W_coef[2] //Diffusion doefficient FRAP_Results[9]=G_chisq FRAP_Results[10]=G_gammaq Make/O/T/N=11 ResultParameterText ResultParameterText={"Half Life","Half Life s.d.","Moblie Fraction","Moblie Fraction s.d.","Immobile Fraction","Immobile Fraction s.d.","A","Width","Diffusion Coef","ChiSq","gammaQ"} //K_renameFrapResultsWave(G_exp_name) break case 9: //soumpasis Make/o/n=11 $ResultsWaveName wave FRAP_Results=$ResultsWaveName wave W_sigma FRAP_Results[0]=HL FRAP_Results[1]=0//abs(W_sigma[1]*ln(0.5)/W_coef[1]/W_coef[1]) //HL s.d. FRAP_Results[2]=MobileFraction FRAP_Results[3]=W_sigma[0] FRAP_Results[4]=ImmobileFraction FRAP_Results[5]=W_sigma[0] FRAP_Results[6]=W_coef[0] //A (Frap) FRAP_Results[7]=Nan FRAP_Results[8]=W_coef[1] //Diffusion doefficient FRAP_Results[9]=G_chisq FRAP_Results[10]=G_gammaq Make/O/T/N=11 ResultParameterText ResultParameterText={"Half Life","Half Life s.d.","Moblie Fraction","Moblie Fraction s.d.","Immobile Fraction","Immobile Fraction s.d.","A","Width","Diffusion Coef","ChiSq","gammaQ"} //K_renameFrapResultsWave(G_exp_name) break default: endswitch END //050811 Function/s K_CreateResidueWave(Frapwave,timewave) wave Frapwave,timewave NVAR/z G_BleachPoint string residuewavename=nameofwave(Frapwave)+"Res" string residuetimewavename=nameofwave(Frapwave)+"Rest" Make/o/n=(numpnts(Frapwave)) $residuewavename,$residuetimewavename wave/z residuewave=$residuewavename wave/z residuetimewave=$residuetimewavename //residuewave[]=Frapwave[p+G_BleachPoint]-EstimationWave[p+G_BleachPoint] residuetimewave[G_BleachPoint,]=timewave[p] residuetimewave[,G_BleachPoint-1]=Nan return residuewavename END //050811 Function K_AppendResidueWave(residuewave, residuetimewave) wave residuewave, residuetimewave SVAR/z G_exp_name string WinNameFit=K_GraphWinname(G_exp_name)//,fit_method) DoWindow/f $WinNameFit if (V_flag==1) if (K_checkTraceInGraph(WinNameFit,nameofwave(residuewave))==0) AppendtoGraph/L=residueaxis residuewave vs residuetimewave ModifyGraph axisEnab(frapaxis)={0,0.8},axisEnab(residueaxis)={0.83,1} ModifyGraph zero(residueaxis)=2 ModifyGraph mode($(nameofwave(residuewave)))=2 ModifyGraph margin(left)=50 ModifyGraph freePos(frapaxis)=0,freePos(residueaxis)=0 ModifyGraph lblPos(residueaxis)=40 ModifyGraph lsize($(nameofwave(residuewave)))=2 endif endif END Function K_FrapAnalDoMultiAtOnceV2(method) //040318 variable method // 0: normalize independent, 1:normalize coordinately String path_name prompt path_name, "Path name?" String exp_namep prompt exp_namep, "Prefix of the File?" Variable exp_num prompt exp_num, "How many experiments?" Doprompt "Path,Name and No.::",path_name,exp_namep,exp_num if (V_flag) Abort "Processing Canceled" endif variable j Make/o/N=(exp_num) $(exp_namep+"HL") wave HLwave=$(exp_namep+"HL") // variable BleachPoint=10 //040303 string exp_name Variable/g Fit_method=method for (j=1;j<(exp_num+1);j+=1) exp_name=exp_namep+num2str(j) //040303 K_importFrapTxtDataV2Multi(path_name,exp_name,exp_num) //040303 // if (method==0) // HLwave[j-1]= K_FrapCalc2_coreV2_norm(exp_name) //040318 // else // method=1 HLwave[j-1]= K_FrapCalc_main(exp_name)//,method) // endif endfor wavestats/q HLwave variable sem sem=V_sdev/V_npnts^0.5 execute "TileWindows/O=1/C" printf "\r\r\rExperiment %s ::\rHalf Life Ave=%g \rs.d.=%g\rs.e.m.=%g\rn=%g\r",exp_name,V_avg,V_sdev,sem,V_npnts END //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Function K_FrapCalc_main(exp_name)//,method) //040324 String exp_name variable HL HL=K_FrapCalcCore()//,method) return HL END //for calling from menu but unused from 050811 Function K_FrapCalc4(method) //040324 normalized version of calc2 Variable method String Frapwave_xnm Variable timepoint0 String exp_name prompt exp_name,"Name of Experiment?" Doprompt "Name",exp_name if (V_flag) Abort "Processing Canceled" endif K_CheckAllGV() NVAR/z G_BleachPoint SVAR/z G_exp_Name G_exp_Name=exp_name NVAR/z Fit_method Fit_method=method K_FrapCalc_main(exp_name)//,method) END //******************************** Diffusion ************************************************** Function K_FrapCalcDiffusion(method) //040324 normalized version of calc2 Variable method String Frapwave_xnm Variable timepoint0 String exp_name prompt exp_name,"Name of Experiment?" Variable normalized prompt Normalized,"Already Normalized?",popup "no;yes;" Variable width prompt width,"Bleach Width?" Doprompt "Name",exp_name,normalized,width if (V_flag) Abort "Processing Canceled" endif K_CheckAllGV() Normalized-=1 NVAR/z Fit_method Fit_method=method SVAR/z G_exp_Name G_exp_Name=exp_name K_FrapCalc_main(exp_name) END //************************************ PANEL components ***************************************// function/s K_FrapListExperiments() string timewavelist=wavelist("*_t",";","") string expnamelist="" string tempst variable i if (itemsinlist(timewavelist)==0) expnamelist+="none" else for (i=0;i1) // Printf "The Mobile fraction was over 1 (%g)\r",MobileFraction // MobileFraction=1 // endif // ImmobileFraction=1-MobileFraction //040303 // // printf "Mobile Fraction is %g\r",MobileFraction //040303 // printf "Immobile Fraction is %g\r",ImmobileFraction //040303 // // string Txt1 // switch (fit_method) // case 0: // Txt1="\\Z08\\s("+FrapFitnm+") FRAP Rainer A="+num2str(amplitude)+" iTau1="+num2str(invTau)+"\r\\s("+decwave_ynm_norm+") Background iTau2="+num2str(backTau)+"\rHalf Max:"+num2str(HL)+"s Mobile: "+num2str(MobileFraction)+"\r\\s("+FrapFit_estimationName+") Estimation" // break // // case 1: // Txt1="\\Z08\\s("+FrapFitnm+") FRAP BackMulti A="+num2str(amplitude)+" iTau1="+num2str(invTau)+"\r\\s("+decwave_ynm_norm+") Background iTau2="+num2str(backTau)+"\rHalf Max:"+num2str(HL)+"s Mobile: "+num2str(MobileFraction)+"\r\\s("+FrapFit_estimationName+") Estimation" // break // // case 4://2: // Txt1="\\Z08\\s("+FrapFitnm+") FRAP Ellenberg\rA="+num2str(amplitude)+"\rDiffusion Coef="+num2str(DifCoef)+"\r\\s("+decwave_ynm_norm+") Background\rHalf Max:"+num2str(HL)+"s\r\\s("+FrapFit_estimationName+") Estimation" // break // case 5://3: // Txt1="\\Z08\\s("+FrapFitnm+") FRAP Soumpasis\rA="+num2str(amplitude)+"\rDiffusion Coef="+num2str(DifCoef)+"\r\\s("+decwave_ynm_norm+") Background\r\\s("+FrapFit_estimationName+") Estimation" // break // // endswitch // TextBox/C/N=text0/A=RB Txt1 // // K_FrapResultTable(HL,MobileFraction,ImmobileFraction) // K_renameFrapResultsWave(G_exp_name) // // return HL //END ////returns estimation value of the background fl. (average of fl level before the bleaching ////from the fitted back curve. 050804 //function K_retAvgBackEstBack(decwave_x,decy0,decA,decTau,bleachpoint) // wave decwave_x // variable decy0,decA,decTau,bleachpoint // variable i,sigmaBackAvg // variable sigmaBack=0 // duplicate/O/R=[,bleachpoint] decwave_x tempbackest // tempbackest[]=decy0+decA*exp(-1*decTau*decwave_x[p]) // wavestats/q tempbackest // //for (i=0;i<(bleachpoint);i+=1) // // sigmaBack+=decy0+decA*(-1*decTau*decwave_x[i]) // //endfor // //sigmaBackAvg=sigmaBack/bleachpoint // //return sigmaBackAvg // killwaves tempbackest // return V_avg //end // 050809 //Function K_expnPopMenuProcOLD(ctrlName,popNum,popStr) : PopupMenuControl // String ctrlName // Variable popNum // String popStr // checkG_CurrentExp() // SVAR/z G_CurrentExp // G_CurrentExp=popStr // //// SVAR/z G_CurrentExp // variable Current_dataform=checkG_dataFormSpecific(G_CurrentExp) // SVAR/z G_MethodList // switch (Current_dataform) // case 0: // G_MethodList="exponential -Rainer;-;-;-;diffusion-Ellenberg;diffusion-Soumpasis;-;-" // break // case 1: // G_MethodList="exponential -Rainer;-;-;-;-;-;DoubleNorm-Single Exp;DoubleNorm-Double Exp" // break // case 2: //// G_MethodList="exponential -Rainer;exponential -BackMultiply;exponential -Back Correct1;exponential -Back Correct2;diffusion-Ellenberg;diffusion-Soumpasis;DoubleNorm-Single Exp;DoubleNorm-Double Exp" // G_MethodList="exponential -Rainer;-;-;-;diffusion-Ellenberg;diffusion-Soumpasis;DoubleNorm-Single Exp;DoubleNorm-Double Exp" // break // endswitch // PopupMenu popup1,value=# G_MethodList // ControlUpdate/W=$("FitPanel") popup1 //End //Function/S FrapMenuItem(itemNumber) // Variable itemNumber //// Variable turbo = NumVarOrDefault("root:gTurboMode", 0) // Variable dataform = NumVarOrDefault("root:G_dataForm", 0) // switch (itemNumber) // case 0: // if ((dataform==0) || (dataform==2)) // return "Rainer's method" // disabled state // else // return "(Rainer's method" // enabled state // endif // break // case 1: // if ((dataform==0) || (dataform==2)) // return "Back Decay multiply" // disabled state // else // return "(Back Decay multiply" // enabled state // endif // break // case 2: // if ((dataform==0) || (dataform==2)) // return "Ellenberg" // disabled state // else // return "(Ellenberg" // enabled state // endif // break // // case 3: // if ((dataform==0) || (dataform==2)) // return "Soumpasis" // disabled state // else // return "(Soumpasis" // enabled state // endif // break // // case 4: // break // // // case 5: // break // // case 6: // if ((dataform==1)|| (dataform==2)) // return"Double Normalize - Single Exp" // disabled state // else // return "(Double Normalize - Single Exp" // enabled state // endif // break // // case 7: // if ((dataform==1)|| (dataform==2)) // return"Double Normalize - Double Exp" // disabled state // else // return "(Double Normalize - Double Exp" // enabled state // endif // break // // endswitch // //End // 050713 // point No. - time - ch1 (Frap) - ch2 (order==0) // point No. - time - ch1 - ch2 (Frap) - ch3 (order==1) //050715 // ROI1 Frap // ROI2 All cell // ROI3 Background // 4 x 3 ROI = 12 waves loaded //Function K_importFrapTxtLeicaData(order) // Variable order // String exp_name // prompt exp_name, "Name of the Experiment?" // Doprompt "name::",exp_name // if (V_flag) // Abort "Processing Canceled" // endif // // String Original_t,Original_Back,Original_Frap,Original_AllCell // String Original_base //050725 //// Original_Back=exp_name+"_bkgOg" // Original_AllCell=exp_name+"_AllCell" // Original_Back=exp_name+"_bkgAv" //040429 to make single reference data calculatable. actually is not the average. // Original_Frap=exp_name+"_FRAP" // Original_t=exp_name+"_t" // Original_base=exp_name+"_base" //050725 // // checkG_dataFormSpecific(exp_name) //050802 // string dataformSpecName=exp_name+"_dataform" //050802 // Nvar/z GdataformSpec=$dataformSpecName //050802 // // LoadWave/N=original/D/G // switch (order) // case 0: // wave/z original0,original1,original2,original3 //ROI1 // wave/z original4,original5,original6,original7 //ROI2 // wave/z original8,original9,original10,original11 //ROI3 // // Rename original1,$Original_t // Rename original2,$Original_Frap // Rename original6,$Original_AllCell // Rename original10,$Original_Back // Killwaves original0,original3,original4,original5,original7,original8,original9,original11 // GdataformSpec=1 // break // case 1: // wave/z original0,original1,original2,original3,original4 //ROI1 // wave/z original5,original6,original7,original8,original9 //ROI2 // wave/z original10,original11,original12,original13,original4 //ROI3 // // Rename original1,$Original_t // Rename original3,$Original_Frap // Rename original8,$Original_AllCell // Rename original13,$Original_Back // Killwaves original0,original2,original4,original5,original6,original7,original9,original10,original11,original12,original14 // GdataformSpec=1 // break // case 2: //another ROI, double channel 050725 // wave/z original0,original1,original2,original3 //ROI1 // wave/z original4,original5,original6,original7 //ROI2 // wave/z original8,original9,original10,original11 //ROI3 // wave/z original12,original13,original14,original15 //ROI4 // // Rename original1,$Original_t // Rename original2,$Original_Frap // Rename original6,$Original_AllCell // Rename original10,$Original_base //050725 // Rename original14,$Original_back //050725 // // Killwaves original0,original3,original4,original5,original7,original8,original9,original11 // GdataformSpec=2 // break // // case 3: //another ROI, double channel 050725 // wave/z original0,original1,original2,original3,original4 //ROI1 // wave/z original5,original6,original7,original8,original9 //ROI2 // wave/z original10,original11,original12,original13,original4 //ROI3 // wave/z original15,original16,original17,original18,original9 //ROI4 // // Rename original1,$Original_t // Rename original3,$Original_Frap // Rename original8,$Original_AllCell // Rename original13,$Original_base //050725 // Rename original18,$Original_back //050725 // // Killwaves original0,original2,original4 // Killwaves original5,original6,original7,original9 // Killwaves original10,original11,original12,original14 // Killwaves original15,original16,original17,original19 // GdataformSpec=2 // break // endswitch // Edit $Original_t,$Original_Frap,$Original_AllCell,$Original_Back // Display $Original_AllCell,$Original_Back,$Original_Frap vs $Original_t // // //K_checkGV() //END //-------- HIstory //030916 : For Frap experiments -- calculate half life. // Coded for Heiko. //031221: file naming too tong - fixed. //040116: "k40" commented out //040303: modified for Zeta. // K_FrapCalc() modified: ranging the fitting t. // version2b // changed: K_FrapCalc2_core(exp_name,timepoint0,j) to K_FrapCalc2_core(exp_name,timepoint0) // changed: K_importFrapTxtDataV2Multi(path_name,exp_name,exp_num,currentNum) to K_importFrapTxtDataV2Multi(path_name,exp_name,exp_num) //040308: implemented mobile:immobile fraction calculaiton also for the K_FrapCalc2_core() //040311: f(t) = A*invtau1/(invtau1+invtau2)*(1-e^(-1*(invtau1+invtau2)*t)) // invtau1/(invtau1+invtau2) is the weighting of the contribtion of binding (invtau1) and bleaching (invtau2) to the dynamics of fluorescnence changes //040320: many changes. //040330: checking the normalization procedure of Rainer's method. //040429: diffusion fitting formula (Jan Ellenberg 1997) added. // In this experiment, photobleach was done to a 4um width strip. In this case, w=4. // save as K_FRAPcalcV4.ipf //040430: fixed problems with Layout // outsorced Result Recording. // FRAP_method became global value //040719 corrected the calculation of HalfLife for Diffusion model. //rename as V5 //040720 "DifCoef_guess" modified. direct use of exponential fitting -> invTau as the guess value. // formula for the diffusion corrected. (root to the outside) //040818 -importing of time & frap only data enabled // -Diffusion Coefficient calculaiton of time & frap only data enabled // -fale safe for the missing of bleach point information // -guessing of the diffusion coefficient from invTau (exponential fitting) is designed. Half Life is calculated, then // calculate the diffusion coefficient guessing value //050203 problem when importing dummy wave (such as all 1) fixed for the reaction models. // Importing of data without background bleaching is also possible. //050307 Changed many parts: integrated common parts, Soumpasis formula added. Updated to V6 // "Fitting Panel" created; Weighting function added. //050308 soumpasis HL calculaiton; panel info print // assignments: acquisition bleaching correction for the diffusion fitting. //050310 background subtraction by Phair et al. (2000) "Single Normalization".