Changeset 919


Ignore:
Timestamp:
Apr 13, 2020 4:32:11 PM (2 years ago)
Author:
ilavsky
Message:

WIP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/User Procedures/Irena/IRB1_bioSAXS.ipf

    r918 r919  
    14891489
    14901490//************************************************************************************************************
    1491 //                                                      ATSAS support in Irena Tool
     1491//                                                      ATSAS PDDF and MW weight calculation support in Irena Tool
    14921492//************************************************************************************************************
    14931493//************************************************************************************************************
     
    15261526        //Dist Tabs definition
    15271527        TabControl PDDFTabs,pos={260,130},size={330,330}, proc=IRB1_PDDFTabProc
    1528         TabControl PDDFTabs,tabLabel(0)="PDDF",tabLabel(1)="MolWeight", value=0
    1529 
    1530         //MW controls
    1531         TitleBox PDDFInstructions1 title="\Zr120SAXSMoW2 MW Calc : ",size={230,15},pos={270,156},frame=0,fColor=(0,0,65535),labelBack=0
    1532         checkbox PDDFUseProtein, pos={300,180}, title="\Zr120Protein", size={120,14},proc=IRB1_PDDFCheckProc, variable=root:Packages:Irena:PDDFInterface:PDDFUseProtein, fColor=(65535,0,0), mode=1, help={"Run PDDF with setting for Proteins. Changes density and SLD"}
    1533         checkbox PDDFUseNucleicAcid, pos={450,180}, title="\Zr120Nucleic Acid", size={120,14},proc=IRB1_PDDFCheckProc, variable=root:Packages:Irena:PDDFInterface:PDDFUseNucleicAcid, fColor=(65535,0,0), mode=1, help={"Run PDDF with settings from Nucleai acid. Changes density and SLD"}
    1534         Button CalculateMolecularWieght,pos={290,220},size={170,20}, proc=IRB1_PDDFButtonProc,title="Fit Rg and calculate MW", help={"Calculate Dmax on these data"}
    1535         //checkbox CalculateDmaxEstOnImport, pos={480,185}, title="Calc. on add data?", size={76,14},proc=IRB1_PDDFCheckProc, variable=root:Packages:Irena:PDDFInterface:CalculateDmaxEstOnImport, help={"Calculate Dmax when new data are added (useful when multiprocessing)"}
    1536         //Unified fit/Porod analysis results
    1537         //SetVariable SAXSMoW2I0,pos={270,185},size={210,15}, noproc,title="Fitted I0                   =  ", variable=root:Packages:Irena:PDDFInterface:SAXSMoW2I0, noedit=1,limits={0,inf,0},frame=0, help={"Porod Invariant calcualtion result"}
    1538         //SetVariable SAXSMoW2Rg,pos={270,207},size={250,15}, noproc,title="Fitted Rg [A]            =  ", variable=root:Packages:Irena:PDDFInterface:SAXSMoW2Rg, noedit=1,limits={0,inf,0},frame=0, help={"Density of protein, user changeable, in g/cm3"}
    1539         SetVariable MWTrueVolumeA3,pos={270,250},size={250,15}, noproc,title="Porod Volume [A^3] =  ", variable=root:Packages:Irena:PDDFInterface:MWTrueVolumeA3, noedit=1,limits={0,inf,0},frame=0, help={"True Volume of protein in [cm3] "}
    1540         //SetVariable MWMolecularWeightkDa,pos={270,251},size={250,15}, noproc,title="MW [kDa]              =  ", variable=root:Packages:Irena:PDDFInterface:MWMolecularWeightkDa, noedit=1,fstyle=1, fsize=13, limits={0,inf,0},frame=0, help={"Molecula weight in kDa"}
    1541 
     1528        TabControl PDDFTabs,tabLabel(0)="PDDF",tabLabel(1)="Mol. Weight", value=0
     1529
     1530        //TAB 0
    15421531        //PDDF Gnom specifics
    15431532        TitleBox PDDFInstructions5 title="\Zr120PDDF controls - method & parameters : ",size={430,15},pos={270,156},frame=0,fColor=(0,0,65535),labelBack=0
     
    15671556        TitleBox PDDFInstructions2 title="\Zr120MW estimate requires Absolute Intensity!",size={330,15},pos={270,420},frame=0,fColor=(0,0,65535),labelBack=0
    15681557        SetVariable ConcentrationForCals,pos={270,440},size={220,15}, proc=IRB1_PDDFSetVarProc,title="c [mg/ml] =              ",variable=root:Packages:Irena:PDDFInterface:ConcentrationForCals,limits={0,inf,0.1}, help={"Concentration for MW calculations"}
    1569         //will fit another 3 numbers here...
    1570         //ConcentrationForCals;ScattLengthDensDifference;PDDFCalculatedMW
    1571 
    1572 
    1573         //GNOM calculated results
     1558
     1559        //TAB 1
     1560        //MW controls
     1561        TitleBox PDDFInstructions1 title="\Zr120SAXSMoW2 MW Calc : ",size={230,15},pos={270,156},frame=0,fColor=(0,0,65535),labelBack=0
     1562        checkbox PDDFUseProtein, pos={300,180}, title="\Zr120Protein", size={120,14},proc=IRB1_PDDFCheckProc, variable=root:Packages:Irena:PDDFInterface:PDDFUseProtein, fColor=(65535,0,0), mode=1, help={"Run PDDF with setting for Proteins. Changes density and SLD"}
     1563        checkbox PDDFUseNucleicAcid, pos={450,180}, title="\Zr120Nucleic Acid", size={120,14},proc=IRB1_PDDFCheckProc, variable=root:Packages:Irena:PDDFInterface:PDDFUseNucleicAcid, fColor=(65535,0,0), mode=1, help={"Run PDDF with settings from Nucleai acid. Changes density and SLD"}
     1564        Button CalcRgAndMolecularWeight,pos={310,210},size={170,20}, proc=IRB1_PDDFButtonProc,title="Fit Rg and calculate MW", help={"Calculate Dmax on these data"}
     1565        checkbox RamboTainerQmax8overRg, pos={270,250}, title="Qmax 8/Rg?", size={76,14},proc=IRB1_PDDFCheckProc, variable=root:Packages:Irena:PDDFInterface:RamboTainerQmax8overRg, mode=0, help={"Set Qmax to 8/Rg automatically"}
     1566        checkbox RamboTainerQmaxLog225, pos={400,250}, title="Qmax I(0)/200?", size={76,14},proc=IRB1_PDDFCheckProc, variable=root:Packages:Irena:PDDFInterface:RamboTainerQmaxLog225, mode=0, help={"Set Qmax to Q when I(0)/200"}
     1567        SetVariable RamboTainerQmax,pos={260,275},size={250,15}, proc=IRB1_PDDFSetVarProc,title="Qmax = ", variable=root:Packages:Irena:PDDFInterface:RamboTainerQmax, limits={0.01,1,0.1},frame=1,bodyWidth=90, help={"Qmax to use"}, format="%4.2f"
     1568
     1569
     1570        checkbox RamboTainerAutoSetBckg, pos={270,300}, title="Auto Find Background?", size={76,14},proc=IRB1_PDDFCheckProc, variable=root:Packages:Irena:PDDFInterface:RamboTainerAutoSetBckg, mode=0, help={"Find Background AUtomatically background from I(Q)"}
     1571        checkbox RamboTainerSubtractFlatBackground, pos={270,325}, title="Subtract Background?", size={76,14},proc=IRB1_PDDFCheckProc, variable=root:Packages:Irena:PDDFInterface:RamboTainerSubtractFlatBackground, mode=0, help={"Subtract background from I(Q)"}
     1572        SetVariable RamboTainerFlatBackground,pos={260,350},size={250,17}, bodyWidth=90, proc=IRB1_PDDFSetVarProc,title="Flat Background = ", variable=root:Packages:Irena:PDDFInterface:RamboTainerFlatBackground, limits={0.01,1,0.02},frame=1, help={"Flat Background"}, format="%4.2f"
     1573
     1574        SetVariable MWTrueVolumeA3,pos={270,420},size={250,15}, noproc,title="Porod Volume [A^3] =  ", variable=root:Packages:Irena:PDDFInterface:MWTrueVolumeA3, noedit=1,limits={0,inf,0},frame=0, help={"True Volume of protein in [cm3] "}
     1575
     1576
     1577
     1578        //Below, at the end...
     1579
     1580        //GNOM calculated results
    15741581        TitleBox PDDFInstructions21 title="\Zr120Results :",size={330,15},pos={270,475},frame=0,fColor=(0,0,65535),labelBack=0
    15751582        SetVariable SAXSMoW2I0,pos={260,500},size={200,15}, noproc,title="SAXSMoW2 I0 =   ", variable=root:Packages:Irena:PDDFInterface:SAXSMoW2I0, noedit=1,limits={0,inf,0},frame=0,size={180,17}, bodyWidth=70, help={"Porod Invariant calcualtion result"}, format="%4.2f"
     
    15841591
    15851592        //Controls for results 
    1586         TitleBox PDDFInstructions3 title="\Zr110Save results controls : ",size={200,15},pos={270,655},frame=0,fColor=(0,0,65535),labelBack=0
     1593        TitleBox PDDFInstructions3 title="\Zr110Save results controls : ",size={200,15},pos={300,655},frame=0,fColor=(0,0,65535),labelBack=0
    15871594        TitleBox PDDFInstructions4 title="\Zr100Where? : ",size={120,15},pos={465,655},frame=0,fColor=(0,0,65535),labelBack=0
    1588         checkbox SaveToFolderAutomatically, pos={495,679}, title="Folder", size={76,14},noproc, variable=root:Packages:Irena:PDDFInterface:SaveToFolderAutomatically, mode=0, help={"Save to folder when running sequence"}
    1589         checkbox SaveToNotebookAutomatically, pos={495,697}, title="Notebook", size={76,14},noproc, variable=root:Packages:Irena:PDDFInterface:SaveToNotebookAutomatically, mode=0, help={"Save to notebook when running sequence"}
    1590         checkbox SaveToWavesAutomatically, pos={495,715}, title="Waves", size={76,14},noproc, variable=root:Packages:Irena:PDDFInterface:SaveToWavesAutomatically, mode=0, help={"Save to notebook when running sequence"}
    1591 
    1592 //results presentation for all methods...
    1593 
    1594 
    1595 
    1596 
     1595        checkbox SaveToFolder, pos={495,679}, title="Folder", size={76,14},noproc, variable=root:Packages:Irena:PDDFInterface:SaveToFolder, mode=0, help={"Save to folder"}
     1596        checkbox SaveToNotebook, pos={495,697}, title="Notebook", size={76,14},noproc, variable=root:Packages:Irena:PDDFInterface:SaveToNotebook, mode=0, help={"Save to notebook"}
     1597        checkbox SaveToWaves, pos={495,715}, title="Waves", size={76,14},noproc, variable=root:Packages:Irena:PDDFInterface:SaveToWaves, mode=0, help={"Save to notebook"}
     1598        checkbox SaveToGNOMOut, pos={495,733}, title="Gnom out", size={76,14},noproc, variable=root:Packages:Irena:PDDFInterface:SaveToGNOMOut, mode=0, help={"Export GNOM Out file outside"}
     1599
     1600        //results presentation for all methods...
    15971601        Button SavePDDFresults,pos={300,680},size={180,20}, proc=IRB1_PDDFButtonProc,title="Save PDDF results", help={"Save PDDF results to folder"}
    15981602        Button OpenResultsAndTable,pos={300,710},size={180,15}, proc=IRB1_PDDFButtonProc,title="Open Table and Notebook", help={"Open Table and Notebook with results"}
    1599         Button DeleteResultsAndTable,pos={270,735},size={170,15}, proc=IRB1_PDDFButtonProc,title="Delete results waves", help={"Delete waves wirth results, this will clean the records!"}
    1600         Checkbox OverwriteExistingData, pos={465,735},size={76,14},title="Overwrite Ouput?", noproc, variable=root:Packages:Irena:PDDFInterface:OverwriteExistingData
     1603        Button DeleteResultsAndTable,pos={230,735},size={130,15}, proc=IRB1_PDDFButtonProc,title="Delete results waves", help={"Delete waves with results, this will clean the records!"}
     1604        Checkbox OverwriteExistingData, pos={370,735},size={76,14},title="Overwrite Ouput?", noproc, variable=root:Packages:Irena:PDDFInterface:OverwriteExistingData
    16011605
    16021606        //create graphs for Data and PDDF
     
    16071611        SetActiveSubwindow ##
    16081612
    1609         Button SelectAllData,pos={200,680},size={80,20}, proc=IRB1_PDDFButtonProc,title="Select All", help={"Select all data in the Listbox"}
     1613        Button SelectAllData,pos={190,680},size={80,20}, proc=IRB1_PDDFButtonProc,title="Select All", help={"Select all data in the Listbox"}
    16101614
    16111615        SetVariable SleepBetweenDataProcesses,pos={600,735},size={220,15}, noproc,variable=root:Packages:Irena:PDDFInterface:SleepBetweenDataProcesses
     
    16281632//**********************************************************************************************************
    16291633//**********************************************************************************************************
     1634
     1635static Function IRB1_PDDFRecalculareQmax()
     1636
     1637                        NVAR RamboTainerQmax8overRg = root:Packages:Irena:PDDFInterface:RamboTainerQmax8overRg
     1638                        NVAR RamboTainerQmaxLog225 = root:Packages:Irena:PDDFInterface:RamboTainerQmaxLog225
     1639                       
     1640                        NVAR RamboTainerQmax = root:Packages:Irena:PDDFInterface:RamboTainerQmax
     1641                        NVAR SAXSMoW2Rg = root:Packages:Irena:PDDFInterface:SAXSMoW2Rg
     1642                        NVAR SAXSMoW2I0=root:Packages:Irena:PDDFInterface:SAXSMoW2I0
     1643                        Wave Intensity=root:Packages:Irena:PDDFInterface:Intensity
     1644                        Wave Qvector=root:Packages:Irena:PDDFInterface:Q_vec
     1645                       
     1646                        if(RamboTainerQmax8overRg && SAXSMoW2Rg>0)     
     1647                                RamboTainerQmax = 8/SAXSMoW2Rg
     1648                        elseif(RamboTainerQmaxLog225 && SAXSMoW2I0>0)
     1649                                variable IntToFind = SAXSMoW2I0/200
     1650                                FindLevel/P/Q Intensity, IntToFind
     1651                                if(V_Flag==0)   //level found...
     1652                                        RamboTainerQmax = Qvector[V_LevelX]
     1653                                else    //now found...
     1654                                        RamboTainerQmax = Qvector[numpnts(Qvector)-2]
     1655                                endif
     1656                        else
     1657                                if(RamboTainerQmax<0.05)
     1658                                        RamboTainerQmax = 0.3
     1659                                endif
     1660                        endif                   
     1661end
     1662
    16301663//**********************************************************************************************************
    16311664//**********************************************************************************************************
     
    16641697                                DataQstartPoint=tempP
    16651698                        endif
     1699                       
     1700                        if(stringmatch(sva.ctrlName,"RamboTainerQmax"))
     1701                                NVAR RamboTainerQmax8overRg = root:Packages:Irena:PDDFInterface:RamboTainerQmax8overRg
     1702                                NVAR RamboTainerQmaxLog225 = root:Packages:Irena:PDDFInterface:RamboTainerQmaxLog225
     1703                                RamboTainerQmax8overRg = 0
     1704                                RamboTainerQmaxLog225 = 0
     1705                        endif
     1706                        if(stringmatch(sva.ctrlName,"RamboTainerFlatBackground"))
     1707                                NVAR RamboTainerAutoSetBckg = root:Packages:Irena:PDDFInterface:RamboTainerAutoSetBckg
     1708                                RamboTainerAutoSetBckg = 0
     1709                                IRB1_PDDFFitAndCalculateMW()
     1710                        endif
     1711                        if(stringmatch(sva.ctrlName,"RamboTainerQmax"))
     1712                                IRB1_PDDFFitAndCalculateMW()
     1713                        endif
     1714
     1715
    16661716                        break
    16671717                case 3: // Live update
     
    16891739                        //do something here
    16901740                        IRB1_PDDFFixTabControls(tab)
     1741                        IN2G_RemoveDataFromGraph(topGraphStr = "IRB1_PDDFInterfacePanel#PDFDisplay")
     1742                        RemoveFromGraph/W=IRB1_PDDFInterfacePanel#DataDisplay /Z FitScatteringProfileBckg
     1743                        RemoveFromGraph/W=IRB1_PDDFInterfacePanel#DataDisplay /Z FitScatteringProfile
     1744                        RemoveFromGraph/W=IRB1_PDDFInterfacePanel#DataDisplay /Z PDDFModelIntensity
     1745
    16911746                        break
    16921747                case -1: // control being killed
     
    17141769        checkbox PDDFUseNucleicAcid, win=IRB1_PDDFInterfacePanel,  disable = (whichTab!=1)
    17151770        TitleBox PDDFInstructions1, win=IRB1_PDDFInterfacePanel,  disable = (whichTab!=1)
    1716         Button CalculateMolecularWieght, win=IRB1_PDDFInterfacePanel,  disable = (whichTab!=1)
     1771        Button CalcRgAndMolecularWeight, win=IRB1_PDDFInterfacePanel,  disable = (whichTab!=1)
    17171772        SetVariable MWTrueVolumeA3, win=IRB1_PDDFInterfacePanel,  disable = (whichTab!=1)
     1773        checkbox RamboTainerAutoSetBckg,  disable = (whichTab!=1)
     1774        checkbox RamboTainerQmax8overRg,  disable = (whichTab!=1)
     1775        checkbox RamboTainerQmaxLog225,  disable = (whichTab!=1)
     1776        SetVariable RamboTainerQmax,  disable = (whichTab!=1)
     1777        checkbox RamboTainerSubtractFlatBackground,  disable = (whichTab!=1)
     1778        SetVariable RamboTainerFlatBackground,  disable = (whichTab!=1)
    17181779        //PDDF Gnom specifics
    17191780        TitleBox PDDFInstructions5, win=IRB1_PDDFInterfacePanel,   disable = (whichTab!=0)
     
    17611822                        NVAR PDDFUseProtein = root:Packages:Irena:PDDFInterface:PDDFUseProtein
    17621823                        NVAR PDDFUseNucleicAcid = root:Packages:Irena:PDDFInterface:PDDFUseNucleicAcid
     1824                        NVAR RamboTainerQmax8overRg = root:Packages:Irena:PDDFInterface:RamboTainerQmax8overRg
     1825                        NVAR RamboTainerQmaxLog225 = root:Packages:Irena:PDDFInterface:RamboTainerQmaxLog225
     1826
     1827                        if(stringmatch(cba.ctrlname,"RamboTainerAutoSetBckg"))
     1828                                IRB1_PDDFFitAndCalculateMW()
     1829                        endif
     1830                        if(stringmatch(cba.ctrlname,"RamboTainerSubtractFlatBackground"))
     1831                                IRB1_PDDFFitAndCalculateMW()
     1832                        endif
     1833                        if(stringmatch(cba.ctrlname,"RamboTainerQmax8overRg"))
     1834                                if(checked)
     1835                                        //RamboTainerQmax8overRg = 0
     1836                                        RamboTainerQmaxLog225 = 0
     1837                                endif
     1838                                IRB1_PDDFRecalculareQmax()
     1839                                IRB1_PDDFFitAndCalculateMW()
     1840                        endif
     1841                        if(stringmatch(cba.ctrlname,"RamboTainerQmaxLog225"))
     1842                                if(checked)
     1843                                        RamboTainerQmax8overRg = 0
     1844                                        //RamboTainerQmaxLog225 = 0
     1845                                endif
     1846                                IRB1_PDDFRecalculareQmax()
     1847                                IRB1_PDDFFitAndCalculateMW()
     1848                        endif
     1849
     1850
    17631851                        if(stringmatch(cba.ctrlname,"PDDFUseGNOM"))
    17641852                                if(checked)
     
    18481936                                IRB1_PDDFSaveResultsToFldr()
    18491937                                IRB1_PDDFSaveToWaves()
     1938                                IRB1_SaveToGnomOutFile()
    18501939                        endif
    18511940                        if(stringMatch(ba.ctrlName,"RunSequenceofPDDF"))
     
    18651954                                IN2G_OpenWebManual("Irena/ImportData.html")                             //fix me!!                     
    18661955                        endif
    1867                         if(stringMatch(ba.ctrlName,"CalculateMolecularWieght"))
     1956                        if(stringMatch(ba.ctrlName,"CalcRgAndMolecularWeight"))
    18681957                                IRB1_PDDFFitAndCalculateMW()
    18691958                        endif
     
    19262015                                IRB1_PDDFSaveResultsToFldr()
    19272016                                IRB1_PDDFSaveToWaves()
     2017                                IRB1_SaveToGnomOutFile()
    19282018                                DoUpdate
    19292019                                if(SleepBetweenDataProcesses>0.5)
     
    19762066        endif
    19772067
     2068        variable TempNumPoints=2000
    19782069        variable Rg
    19792070        Variable G
     
    20002091        if (V_FitError!=0)      //there was error in fitting
    20012092                beep
    2002                 Abort "Fitting error, Cannot fit Rg"
     2093                Abort "Fitting error, Cannot fit Rg or otehr parameters"
    20032094        endif
    20042095        //Store Unified fit results.
     
    20142105        SAXSMoW2Rg = Rg
    20152106        //calculate Intensity to display
    2016         Duplicate/O OriginalIntensity, QstarVector, FitScattareingProfile
     2107        Duplicate/O OriginalIntensity, QstarVector, FitScatteringProfile
    20172108        QstarVector = OriginalQvector / (erf(OriginalQvector*w_coef[1]/sqrt(6)))^3
    2018         FitScattareingProfile =  w_coef[0]*exp(-OriginalQvector^2*w_coef[1]^2/3)+(w_coef[2]/QstarVector^w_coef[3])// + w_coef[4]
    2019         CheckDisplayed /W=IRB1_PDDFInterfacePanel#DataDisplay  FitScattareingProfile 
     2109        FitScatteringProfile =  w_coef[0]*exp(-OriginalQvector^2*w_coef[1]^2/3)+(w_coef[2]/QstarVector^w_coef[3])// + w_coef[4]
     2110        CheckDisplayed /W=IRB1_PDDFInterfacePanel#DataDisplay  FitScatteringProfile 
    20202111        if(!V_flag)
    20212112                GetAxis /W=IRB1_PDDFInterfacePanel#DataDisplay /Q left
    2022                 AppendToGraph  /W=IRB1_PDDFInterfacePanel#DataDisplay  FitScattareingProfile  vs OriginalQvector
    2023                 ModifyGraph /W=IRB1_PDDFInterfacePanel#DataDisplay lstyle(FitScattareingProfile)=2,lsize(FitScattareingProfile)=1
    2024                 ModifyGraph /W=IRB1_PDDFInterfacePanel#DataDisplay rgb(FitScattareingProfile)=(1,3,39321)
     2113                AppendToGraph  /W=IRB1_PDDFInterfacePanel#DataDisplay  FitScatteringProfile  vs OriginalQvector
     2114                ModifyGraph /W=IRB1_PDDFInterfacePanel#DataDisplay lstyle(FitScatteringProfile)=2,lsize(FitScatteringProfile)=1
     2115                ModifyGraph /W=IRB1_PDDFInterfacePanel#DataDisplay rgb(FitScatteringProfile)=(1,3,39321)
    20252116        endif
    20262117        SetAxis/W=IRB1_PDDFInterfacePanel#DataDisplay/A left
     
    20412132        variable changeOverQmax = 8/Rg                                                                                                                                                  //formula 7
    20422133        //alternative is to pick changeOverQmax based on Formula 8, so log(I(o)/I(gmax) ~ 2.25, formula 7 is easier, keep for now...
    2043         Make/Free/N=10000 InvariantIntWv, InvariantQWv, InvarQstar, InvarIntQ2
     2134        Make/Free/N=(TempNumPoints) InvariantIntWv, InvariantQWv, InvarQstar, InvarIntQ2
    20442135        InvariantQWv            =       p*(changeOverQmax/(numpnts(InvariantQWv)-1))+0.00002                                    //this creates Q wave between 0.00002 and qmax
    20452136        InvarQstar                      =       InvariantQWv / (erf(InvariantQWv*Rg/sqrt(6)))^3                                                 //Q* for Unified level
     
    20722163        //Nucelic acid MW= (Qr/0.00934)^0.808
    20732164        //but first , we need to fit data with background also:
     2165        NVAR RamboTainerQmax8overRg = root:Packages:Irena:PDDFInterface:RamboTainerQmax8overRg
     2166        NVAR RamboTainerQmaxLog225 = root:Packages:Irena:PDDFInterface:RamboTainerQmaxLog225   
     2167        NVAR RamboTainerQmax = root:Packages:Irena:PDDFInterface:RamboTainerQmax
     2168        NVAR RamboTainerSubtractFlatBackground = root:Packages:Irena:PDDFInterface:RamboTainerSubtractFlatBackground
     2169        NVAR RamboTainerFlatBackground = root:Packages:Irena:PDDFInterface:RamboTainerFlatBackground
     2170        NVAR RamboTainerAutoSetBckg = root:Packages:Irena:PDDFInterface:RamboTainerAutoSetBckg
     2171        IRB1_PDDFRecalculareQmax()                              //this will set Qmax as needed...
    20742172        Make /N=5/O W_coef, LocalEwave
    20752173        Make/N=5/T/O T_Constraints
     
    20882186        if (V_FitError!=0)      //there was error in fitting
    20892187                beep
    2090                 Abort "Fitting error, Cannot fit Rg"
     2188                Abort "Fitting error in Rambo-Tainer method, Cannot fit Rg or other parameters"
    20912189        endif
    20922190        //Store Unified fit results.
     
    20972195        RTP =   w_coef[3]
    20982196        RTBackground =  w_coef[4]
     2197        //calculate Intensity to display
     2198        Duplicate/O OriginalIntensity, QstarVector, FitScatteringProfileBckg
     2199        QstarVector = OriginalQvector / (erf(OriginalQvector*w_coef[1]/sqrt(6)))^3
     2200        FitScatteringProfileBckg =  w_coef[0]*exp(-OriginalQvector^2*w_coef[1]^2/3)+(w_coef[2]/QstarVector^w_coef[3]) + w_coef[4]
     2201        CheckDisplayed /W=IRB1_PDDFInterfacePanel#DataDisplay  FitScatteringProfileBckg 
     2202        if(!V_flag)
     2203                GetAxis /W=IRB1_PDDFInterfacePanel#DataDisplay /Q left
     2204                AppendToGraph  /W=IRB1_PDDFInterfacePanel#DataDisplay  FitScatteringProfileBckg  vs OriginalQvector
     2205                ModifyGraph /W=IRB1_PDDFInterfacePanel#DataDisplay lstyle(FitScatteringProfileBckg)=9,lsize(FitScatteringProfileBckg)=1
     2206                ModifyGraph /W=IRB1_PDDFInterfacePanel#DataDisplay rgb(FitScatteringProfileBckg)=(3,52428,1)
     2207        endif
     2208        if(RamboTainerAutoSetBckg)
     2209                RamboTainerFlatBackground = RTBackground
     2210        endif
    20992211        //QstarVector = OriginalQvector / (erf(OriginalQvector*w_coef[1]/sqrt(6)))^3
    2100         //FitScattareingProfile =  w_coef[0]*exp(-OriginalQvector^2*w_coef[1]^2/3)+(w_coef[2]/QstarVector^w_coef[3]) + w_coef[4]
     2212        //FitScatteringProfile =  w_coef[0]*exp(-OriginalQvector^2*w_coef[1]^2/3)+(w_coef[2]/QstarVector^w_coef[3]) + w_coef[4]
    21012213
    21022214        //now, fron this excersize we really need only the background...
     
    21042216        NVAR PDDFUseNucleicAcid=root:Packages:Irena:PDDFInterface:PDDFUseNucleicAcid
    21052217        NVAR PDDFUseProtein=root:Packages:Irena:PDDFInterface:PDDFUseProtein
    2106         Make/Free/N=10000 RamboTainerIntQ, RamboTainerQ, RamboTainerInt, RamboTainerQstar
     2218        Make/Free/N=(TempNumPoints) RamboTainerIntQ, RamboTainerQ, RamboTainerInt, RamboTainerQstar
    21072219        variable Qmaxmeasured=OriginalQvector[numpnts(OriginalQvector)-3]
    21082220        RamboTainerQ = p*(Qmaxmeasured/(numpnts(InvariantQWv)-1))+0.00002                               //this creates Q wave between 0.00002 and qmax measured
     
    21112223        ChangeToRealIntP=BinarySearch(RamboTainerQ,QValueToChange )
    21122224        RamboTainerInt[ChangeToRealIntP, ] = OriginalIntensity[BinarySearchInterp(OriginalQvector, RamboTainerQ[p])]
    2113         RamboTainerInt -= RTBackground                                          //this subtract approximate background from the data.
     2225        if(RamboTainerSubtractFlatBackground)
     2226                RamboTainerInt -= RamboTainerFlatBackground                                             //this subtract approximate background from the data.
     2227        endif
    21142228        RamboTainerIntQ = RamboTainerInt*RamboTainerQ
    21152229        //***                   Qmax for integration of Q*I(Q) is challenge...
    2116         //Qmax of 0.3 seems to work for BSA test data, but is likely sampel independent, which seems wrong...
    2117         //FindLevel/P  RamboTainerInt, RTG/1000
    2118         //print RamboTainerQ[V_LevelX]                          this is similar to SAXSMoW2 paper, where they set log(I(0)/I(Qmax)) ~ 2 ... 2.5 in our case that is 3.
    2119         //print 8/RTRg                                                                  this is SAXSMoW2 paper standard qmax. They do have corrections to fix infinite integral, we do not...
    2120         //for now use 8/Rg
    2121         variable maxQforRamboTainer = 8/RTRg                                           
    2122         variable IntgQIQ=areaXY(RamboTainerQ, RamboTainerIntQ, 0, maxQforRamboTainer )
     2230        variable IntgQIQ=areaXY(RamboTainerQ, RamboTainerIntQ, 0, RamboTainerQmax )
    21232231        //variable i
    21242232        //for(i=0.1;i<1;i+=0.1)
    21252233        //      print " Qmax = "+num2str(i)+" Intg(QI(Q) = "+num2str(areaXY(RamboTainerQ, RamboTainerIntQ, 0, i ))
    21262234        //endfor
     2235        //    now calculate I*Q vs Q to display in DataDisplay plot...
     2236        Duplicate/O RamboTainerInt, TotalScatteredInt, IntgQIntensity
     2237        Duplicate/O RamboTainerQ, TotalScatteredQ
     2238        TotalScatteredInt = RamboTainerInt*RamboTainerQ
     2239        multithread IntgQIntensity = areaXY(TotalScatteredQ, TotalScatteredInt, 0, TotalScatteredQ[p] )
     2240        IN2G_RemoveDataFromGraph(topGraphStr = "IRB1_PDDFInterfacePanel#PDFDisplay")
     2241        AppendToGraph /W=IRB1_PDDFInterfacePanel#PDFDisplay  TotalScatteredInt  vs TotalScatteredQ
     2242        AppendToGraph /W=IRB1_PDDFInterfacePanel#PDFDisplay/R  IntgQIntensity  vs TotalScatteredQ
     2243        ModifyGraph/W=IRB1_PDDFInterfacePanel#PDFDisplay  mirror(bottom)=1
     2244        ModifyGraph/W=IRB1_PDDFInterfacePanel#PDFDisplay lstyle(IntgQIntensity)=3,rgb(IntgQIntensity)=(0,0,65535)
     2245        //              SetAxis/W=IRB1_PDDFInterfacePanel#PDFDisplay/A/E=1 left
     2246
     2247        Label/W=IRB1_PDDFInterfacePanel#PDFDisplay left "Q * I(Q)"
     2248        Label/W=IRB1_PDDFInterfacePanel#PDFDisplay right "sum(Q * I(Q)) to Qmax"
     2249        Label/W=IRB1_PDDFInterfacePanel#PDFDisplay bottom "Q [1/A]"
     2250
     2251       
     2252       
    21272253        variable RTVc           =       SAXSMoW2I0/IntgQIQ
    21282254        variable RTQr           =       (RTVc)^2 / SAXSMoW2Rg
     
    21392265        //Tagtext+="\\F"+IN2G_LkUpDfltStr("FontType")+"\\Z"+IN2G_LkUpDfltVar("TagSize")+"Protein Vol [cm3] = "+num2str(MWTrueVolumeA3)+"\r"
    21402266        Tagtext+="\\F"+IN2G_LkUpDfltStr("FontType")+"\\Z"+IN2G_LkUpDfltVar("TagSize")+"     MW [kDa] = "+num2str(MWMolecularWeightkDa)
    2141         Tag/C/N=GuessRg/A=LT/L=0/TL=0/W=IRB1_PDDFInterfacePanel#DataDisplay FitScattareingProfile, numpnts(FitScattareingProfile)/10,Tagtext
     2267        Tag/C/N=GuessRg/A=LT/L=0/TL=0/W=IRB1_PDDFInterfacePanel#DataDisplay FitScatteringProfile, numpnts(FitScatteringProfile)/10,Tagtext
    21422268       
    21432269        KillWaves/Z LocalEwave, W_coef, T_constraints, QstarVector
     
    25042630//**************************************************************************************
    25052631//**************************************************************************************
     2632Static Function IRB1_SaveToGnomOutFile()
     2633
     2634        NVAR SaveToGNOMOut = root:Packages:Irena:PDDFInterface:SaveToGNOMOut
     2635        Wave/Z/T GNOMOutFileTextWave = root:Packages:Irena:PDDFInterface:GNOMOutFileTextWave
     2636        SVAR DataFolderName = root:Packages:Irena:PDDFInterface:DataFolderName
     2637        if(SaveToGNOMOut && WaveExists(GNOMOutFileTextWave))
     2638                //now we want to save this to where user Igor experiment is...
     2639                PathInfo  home
     2640                string PathToStore=S_path
     2641                if(strlen(PathToStore)<1)       //Igor experiment not saved, no home path exists...
     2642                        DoAlert 0, "You need to save this Igor experiment first, so we know where to put those GNOM out files"
     2643                        SaveExperiment
     2644                endif
     2645                //OK, now Igor experiment is saved.
     2646                //create a new path, which will be next to the Igor experiment and have GNOM out files.
     2647                string ExpName=IgorInfo(1)
     2648                string FldrName=ExpName+"_GNOM_Out"
     2649                PathInfo home
     2650                NewPath /C/O/Q GNOMOutFiles , S_Path+FldrName
     2651                string FileNameOut=StringFromList(ItemsInList(DataFolderName, ":")-1, DataFolderName, ":")
     2652                Duplicate/Free/T GNOMOutFileTextWave, TempStrWave
     2653                TempStrWave = ReplaceString("\n", TempStrWave[p], "")
     2654                TempStrWave = ReplaceString("\r", TempStrWave[p], "")
     2655                GetFileFolderInfo /P=GNOMOutFiles /Q /Z (FileNameOut+".out")
     2656                if(V_Flag==0)
     2657                        DoAlert 1, "The file : "+ FileNameOut+".out" +" already exists, do you want to overwrite it?"
     2658                        if(V_Flag!=1)
     2659                                abort
     2660                        endif
     2661                endif
     2662                Save/G/M="\n"/O/P=GNOMOutFiles TempStrWave as (FileNameOut+".out")
     2663               
     2664               
     2665        endif
     2666
     2667end
     2668
     2669//**************************************************************************************
     2670//**************************************************************************************
    25062671
    25072672static Function IRB1_PDDFRunIrenaPDDF()
     
    26232788                ModifyGraph/W=IRB1_PDDFInterfacePanel#DataDisplay mode(PDDFModelIntensity)=3,marker(PDDFModelIntensity)=8,msize(PDDFModelIntensity)=4,rgb(PDDFModelIntensity)=(0,0,65535)
    26242789               
     2790                IN2G_RemoveDataFromGraph(topGraphStr = "IRB1_PDDFInterfacePanel#PDFDisplay")
    26252791                CheckDisplayed /W=IRB1_PDDFInterfacePanel#PDFDisplay pddfPr
    26262792                if(!V_flag)
     
    26862852        UseUserDefinedData = 0
    26872853        UseModelData = 0
     2854        //delete GNOM out file, if exists...
     2855        Wave/Z GNOMOutFileTextWave = root:Packages:Irena:PDDFInterface:GNOMOutFileTextWave
     2856        KillWaves /Z GNOMOutFileTextWave
    26882857        //get the names of waves, assume this tool actually works. May not under some conditions. In that case this tool will not work.
    26892858        IR3C_SelectWaveNamesData("Irena:PDDFInterface", FolderNameStr)                  //this routine will preset names in strings as needed,  DataFolderName = DataStartFolder+FolderNameStr
     
    28383007        ListOfVariables += "MooreNumFunctions;MooreDetNumFunctions;MooreFitMaxSize;"   
    28393008        ListOfVariables += "PDDFCalculatedRg;PDDFCalculatedI0;ConcentrationForCals;ScattLengthDensDifference;PDDFCalculatedMW;"
    2840         ListOfVariables += "RamboTainerMW;"
    2841         ListOfVariables += "SaveToFolderAutomatically;SaveToNotebookAutomatically;SaveToWavesAutomatically;"   
     3009        ListOfVariables += "RamboTainerMW;RamboTainerQmax8overRg;RamboTainerQmax;RamboTainerQmaxLog225;"
     3010        ListOfVariables += "RamboTainerSubtractFlatBackground;RamboTainerFlatBackground;RamboTainerAutoSetBckg;"
     3011        ListOfVariables += "SaveToFolder;SaveToNotebook;SaveToWaves;SaveToGNOMOut;"     
    28423012        ListOfVariables += "MWPorodInvariant;MWTrueVolumeA3;MWMassDensityProtein;MWMolecularWeightkDa;"
    28433013        ListOfVariables += "GNOMAlfaResult;SAXSMoW2I0;SAXSMoW2Rg;PDDFUseProtein;PDDFUseNucleicAcid;"
     
    29053075        IRB1_ResetValuesToPreventStale()
    29063076       
    2907         NVAR SaveToFolderAutomatically
    2908         NVAR SaveToNotebookAutomatically
    2909         NVAR SaveToWavesAutomatically
    2910         if(SaveToFolderAutomatically+SaveToNotebookAutomatically+SaveToWavesAutomatically<1)
    2911                 SaveToFolderAutomatically=1
    2912                 SaveToNotebookAutomatically=1
    2913                 SaveToWavesAutomatically=1
     3077        NVAR SaveToFolder
     3078        NVAR SaveToNotebook
     3079        NVAR SaveToWaves
     3080        if(SaveToFolder+SaveToNotebook+SaveToWaves<1)
     3081                SaveToFolder=1
     3082                SaveToNotebook=1
     3083                SaveToWaves=1
    29143084        endif
    29153085        NVAR CalculateDmaxEstOnImport
     
    29733143        DFref oldDf= GetDataFolderDFR()
    29743144        setDataFolder root:Packages:Irena:PDDFInterface
    2975         NVAR SaveToFolderAutomatically=root:Packages:Irena:PDDFInterface:SaveToFolderAutomatically
    2976         NVAR SaveToNotebookAutomatically=root:Packages:Irena:PDDFInterface:SaveToNotebookAutomatically
    2977         NVAR SaveToWavesAutomatically=root:Packages:Irena:PDDFInterface:SaveToWavesAutomatically
    2978         if(SaveToNotebookAutomatically!=1)
     3145        NVAR SaveToFolder=root:Packages:Irena:PDDFInterface:SaveToFolder
     3146        NVAR SaveToNotebook=root:Packages:Irena:PDDFInterface:SaveToNotebook
     3147        NVAR SaveToWaves=root:Packages:Irena:PDDFInterface:SaveToWaves
     3148        if(SaveToNotebook!=1)
    29793149                setDataFolder OldDf
    29803150                return 0
     
    30633233        IN2G_PrintDebugStatement(IrenaDebugLevel, 5,"")
    30643234        DFref oldDf= GetDataFolderDFR()
    3065         NVAR SaveToFolderAutomatically=root:Packages:Irena:PDDFInterface:SaveToFolderAutomatically
    3066         NVAR SaveToNotebookAutomatically=root:Packages:Irena:PDDFInterface:SaveToNotebookAutomatically
    3067         NVAR SaveToWavesAutomatically=root:Packages:Irena:PDDFInterface:SaveToWavesAutomatically
    3068         if(SaveToWavesAutomatically!=1)
     3235        NVAR SaveToFolder=root:Packages:Irena:PDDFInterface:SaveToFolder
     3236        NVAR SaveToNotebook=root:Packages:Irena:PDDFInterface:SaveToNotebook
     3237        NVAR SaveToWaves=root:Packages:Irena:PDDFInterface:SaveToWaves
     3238        if(SaveToWaves!=1)
    30693239                setDataFolder OldDf
    30703240                return 0
     
    31863356        setDataFolder root:Packages:Irena:PDDFInterface
    31873357
    3188         NVAR SaveToFolderAutomatically=root:Packages:Irena:PDDFInterface:SaveToFolderAutomatically
    3189         NVAR SaveToNotebookAutomatically=root:Packages:Irena:PDDFInterface:SaveToNotebookAutomatically
    3190         NVAR SaveToWavesAutomatically=root:Packages:Irena:PDDFInterface:SaveToWavesAutomatically
    3191         if(SaveToFolderAutomatically!=1)
     3358        NVAR SaveToFolder=root:Packages:Irena:PDDFInterface:SaveToFolder
     3359        NVAR SaveToNotebook=root:Packages:Irena:PDDFInterface:SaveToNotebook
     3360        NVAR SaveToWaves=root:Packages:Irena:PDDFInterface:SaveToWaves
     3361        if(SaveToFolder!=1)
    31923362                return 0
    31933363        endif
     
    32583428        Wave/Z ChisquaredWave                   =root:Packages:Irena:PDDFInterface:ChisquaredWave
    32593429        Wave/Z CurrentResultsGamma      =root:Packages:Irena:PDDFInterface:CurrentResultsGamma
     3430        Wave/Z GNOMOutFileTextWave = root:Packages:Irena:PDDFInterface:GNOMOutFileTextWave
    32603431
    32613432        Duplicate/O pddfRadius, tempR_distribution
     
    32933464        tempname="PDDFGammaFunction_"+num2str(ii)
    32943465        Duplicate /O tempCurrentResultsGamma, $tempname
     3466        if(WaveExists(GNOMOutFileTextWave))
     3467                tempname="GnomOutFile"+num2str(ii)
     3468                Duplicate/O GNOMOutFileTextWave, $(tempname)
     3469        endif
    32953470       
    32963471        print "Saved data to folder "+getDataFolder(1)+" , data generation is "+num2str(ii)
Note: See TracChangeset for help on using the changeset viewer.