Ignore:
Timestamp:
Jan 12, 2022 8:10:01 PM (11 months ago)
Author:
ilavsky
Message:

12IDB improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/User Procedures/Nika/NI1_InstrumentSupport.ipf

    r1174 r1175  
    18261826        NewPath/Q/O Convert2Dto1DEmptyDarkPath, S_path 
    18271827        String DoingWhat= StringFromList(ItemsInList(DataFilePath,":")-1, DataFilePath,":")
     1828        //now we need to get idea, what the user wants to do.
     1829        //Options: tif/nexus
     1830        //SAXS/WAXS ?
     1831        //Mask - which from selection or none?
     1832        //Load parameters always or only first time.
     1833        //now get user input and load parameters and mask...
     1834        NI1_12IDBGetUserInput()
     1835        NVAR APS12IDBProcMethod                         //0 for beamline method (no background), 1 for Nika standard (with background).
     1836        NVAR APS12IDBReloadPars                         //Parameterrs - 0 for not reloading calibration parameters, 1 for reload with each data file.
     1837        SVAR APS12IDBDataType                           // = "12IDB_tif"                //default for tiff files. May change to Nexus later when that is standard.
     1838        //SVAR APS12IDBMask                     // = "---"                                      //default for none. User needs to create one in Nika
     1839        //SVAR APS12IDBGeometry                 //SAXS or WAXS?
    18281840       
    18291841        SVAR DataFileExtension=root:Packages:Convert2Dto1D:DataFileExtension
    18301842        SVAR BlankFileExtension=root:Packages:Convert2Dto1D:BlankFileExtension
    1831         BlankFileExtension = "12IDB_tif"
     1843        BlankFileExtension = APS12IDBDataType
    18321844        //select the right type of data
    1833         DataFileExtension = "12IDB_tif"
    1834         PopupMenu Select2DDataType win=NI1A_Convert2Dto1DPanel, popmatch= "12IDB_tif"
    1835         //now load mask...
    1836         variable ProcessingMethod       //0 for beamline method (no background), 1 for Nika standard (with background).
    1837         ProcessingMethod = NI1_12IDBLoadGoodPixMask()                     
     1845        DataFileExtension = APS12IDBDataType
     1846        PopupMenu Select2DDataType win=NI1A_Convert2Dto1DPanel, popmatch= APS12IDBDataType
    18381847
    18391848       
     
    18741883        ErrorCalculationsUseSEM = 1
    18751884       
    1876         if(ProcessingMethod)
     1885        if(APS12IDBProcMethod)
    18771886                UseSampleTransmission = 1
    18781887                UseSampleThickness = 0
     
    19101919
    19111920                UseCorrectionFactor = 1
    1912                 CorrectionFactor = 2.4e-06                      //this should be fudge factor 12IDB is using to crrect data to 0.1-100 intensity range...
     1921                CorrectionFactor = 2.4e-06                      //this should be fudge factor 12IDB is using to correct data to 0.1-100 intensity range...
    19131922                UseSolidAngle = 1                                               //thsi is needed for that fudge factor above.
    19141923               
     
    19361945        if(stringmatch(DoingWhat,"SAXS"))
    19371946                QbinningLogarithmic=1
    1938                 QvectorMaxNumPnts=0
    1939                 QvectorNumberPoints = 600
     1947                //QvectorMaxNumPnts=0
     1948                //QvectorNumberPoints = 600
     1949                //these are set by configuration file now.
    19401950        else
    19411951                //WAXS
     
    19431953                QvectorMaxNumPnts=1
    19441954        endif
    1945         if(ProcessingMethod)
     1955        if(APS12IDBProcMethod)
    19461956                //send user to Empty/Dark tab
    19471957                TabControl Convert2Dto1DTab win=NI1A_Convert2Dto1DPanel, value=3
     
    19591969//*******************************************************************************************************************************************
    19601970//*******************************************************************************************************************************************
     1971//*******************************************************************************************************************************************
     1972//*******************************************************************************************************************************************
     1973
     1974Function NI1_12IDBGetUserInput()                        //todo: some error handling...
     1975                //should be able to find mask in current working folder
     1976        string OldDFf=GetDataFolder(1)
     1977        setDataFolder root:Packages:Convert2Dto1D:
     1978        NVAR UseMask = root:Packages:Convert2Dto1D:UseMask
     1979        //Init needed APS12IDB... Parameters
     1980        variable/g APS12IDBProcMethod = 0                               //0 for beamline method (no background), 1 for Nika standard (with background).
     1981        variable/g APS12IDBReloadPars = 0                               //Parameterrs - 0 for not reloading calibration parameters, 1 for reload with each data file.
     1982        string/g APS12IDBDataType = "12IDB_tif"                 //default for tiff files. May change to Nexus later when that is standard.
     1983        //string/g APS12IDBMask = "---"                                 //default for none. User needs to create one in Nika
     1984        string/g APS12IDBGeometry = "SAXS"                              //SAXS or WAXS?
     1985        //Get what we are using here...
     1986        PathInfo Convert2Dto1DDataPath
     1987        string DataFilePath=S_path
     1988        //here we know what we are processing... Either the last folder is SAXS or WAXS
     1989        string UsingWhat=StringFromList(ItemsInList(DataFilePath,":")-1, DataFilePath,":")
     1990        if(StringMatch(UsingWhat, "SAXS"))
     1991                APS12IDBGeometry = "SAXS"
     1992        elseif(StringMatch(UsingWhat, "WAXS"))
     1993                APS12IDBGeometry = "WAXS"
     1994        else
     1995                abort "Wrong folder with data selected, this folder is not called SAXS or WAXS"
     1996        endif
     1997        //now what type of files are we using?
     1998        string ListOfTifFiles=IndexedFile(Convert2Dto1DDataPath, -1, ".tif")
     1999        string ListOfHDF5Files=IndexedFile(Convert2Dto1DDataPath, -1, ".hdf")
     2000        if(itemsInList(ListOfTifFiles)>0)
     2001                APS12IDBDataType = "12IDB_tif"
     2002        elseif(itemsInList(ListOfHDF5Files)>0)
     2003                APS12IDBDataType = "Nexus"
     2004        else
     2005                abort "Unknown image data file type. Can read .tif or .hdf (Nexus) only."
     2006        endif
     2007        //get calibration files.
     2008        //get the path to calibration and SAXS_mask2M.bmp or WAXS_mask2M.bpm, it is one level up...
     2009        string MaskPathStr= RemoveFromList(UsingWhat, DataFilePath,":")
     2010        NewPath/O/Q TempMaskUserPath, MaskPathStr
     2011        string ListOfCalibrations=GrepList(IndexedFile(TempMaskUserPath, -1, ".txt"), "(?i)calibration_parameters")
     2012        string SelectedCalibrationFile =RemoveEnding(GrepList(ListOfCalibrations,"(?i)"+UsingWhat), ";")                //this now should be saxs_calibration_parameters or waxs_calibration_parameters
     2013        print SelectedCalibrationFile
     2014        //get the mask files...
     2015        //mask may or may not exist, we need to get user to pick one or tell us it does not exist...
     2016        string ListOfBMPFiles=IndexedFile(TempMaskUserPath, -1, ".bmp")
     2017        string SelectedMaskFile = RemoveEnding(GrepList(ListOfBMPFiles,"(?i)"+UsingWhat),";")
     2018       
     2019        string LoadCalibration
     2020        string LoadMaskFile
     2021        string AlwaysReloadParameters
     2022        string ProcessingTypeStr
     2023        //dialog...
     2024       
     2025        Prompt LoadCalibration, "Load calibration from "+SelectedCalibrationFile+"?", popup, "Yes;No;"
     2026        if(strlen(SelectedMaskFile)>0)
     2027                Prompt LoadMaskFile, "Load BMP Mask file "+SelectedMaskFile+"?", popup, "Yes;No;"
     2028        else
     2029                Prompt LoadMaskFile, "No Mask file found", popup, "No;"
     2030        endif
     2031        Prompt ProcessingTypeStr, "Subtract Empty/background ?", popup, "No;Yes;"
     2032        Prompt AlwaysReloadParameters, "Reload geometry for each image ?", popup, "No;Yes;"
     2033        DoPrompt "Setup parameters", ProcessingTypeStr, LoadCalibration, AlwaysReloadParameters, LoadMaskFile
     2034        if(V_Flag)
     2035                abort
     2036        else
     2037                //setup processing method
     2038                if(stringMatch(ProcessingTypeStr,"Yes"))
     2039                        APS12IDBProcMethod = 1                  //subtract background (materials SAXS common).
     2040                else
     2041                        APS12IDBProcMethod = 0                  //do not subtract background (bioSAXS common)
     2042                endif
     2043                //Reload metadata always?
     2044                if(stringMatch(AlwaysReloadParameters,"Yes"))
     2045                        APS12IDBReloadPars = 1                  //reload metadata with each image?
     2046                else
     2047                        APS12IDBReloadPars = 0                  //do not reload metadata with each image
     2048                endif
     2049                //mask...
     2050                if(stringmatch(LoadMaskFile,"Yes"))
     2051                        ImageLoad/T=bmp/Q/N=TMPBMPMask/Z/P=TempMaskUserPath SelectedMaskFile
     2052                        if(V_Flag)
     2053                                print ":Loaded succesfully mask file from "+MaskPathStr+SelectedMaskFile
     2054                        else
     2055                                DoALert/T="Could not load Mask file" 0, "Could not load selected file with mask, you need to create mask manually"
     2056                                UseMask = 0
     2057                        endif
     2058                        Wave LoadedmaskImage = TMPBMPMask
     2059                        ImageTransform rgb2gray LoadedmaskImage
     2060                        Wave M_RGB2Gray
     2061                        ImageTransform flipCols M_RGB2Gray                      //this is correct flip needed...
     2062                        DoWIndow CCDImageToConvertFig
     2063                        if(V_Flag)
     2064                                RemoveImage/W=CCDImageToConvertFig/Z  M_ROIMask
     2065                        endif
     2066                        KillWaves/Z M_ROIMask, TMPBMPMask
     2067                        wavestats/Q M_RGB2Gray
     2068                        M_RGB2Gray/=V_max                               //normalize to be 1 or 0, seem to be 255
     2069                        Rename M_RGB2Gray, M_ROIMask
     2070                        UseMask = 1
     2071                else
     2072                        Wave M_ROIMask
     2073                        KillWaves/Z M_ROIMask
     2074                        UseMask = 0
     2075                        print "No Mask Loaded, user needs to setup their own "
     2076                endif
     2077                //parse the parameter file
     2078                if(stringmatch(LoadCalibration,"Yes"))
     2079                        NI1_12IDBLoadTXTMetadata(MaskPathStr, SelectedCalibrationFile) 
     2080                else
     2081                        print "No calibration file loaded. You are on your own!!!"
     2082                endif
     2083        endif
     2084
     2085
     2086        setDataFolder OldDFf   
     2087        return APS12IDBProcMethod
     2088end
     2089//*******************************************************************************************************************************************
     2090//*******************************************************************************************************************************************
     2091//*******************************************************************************************************************************************
     2092Function/S NI1_12IDBLoadTXTMetadata(PathStr, FileNameToLoad)           
     2093        string PathStr, FileNameToLoad
     2094       
     2095        NewPath/O/Q/Z LogFilesPath, PathStr
     2096        variable refNum, err
     2097        string OneLineStr, MetadataString="", newWaveNOte=""
     2098        open/R/T="????"/P=LogFilesPath/Z refNum as FileNameToLoad
     2099        if(V_flag!=0)
     2100                close refNum
     2101                Abort "Metadata import failed"
     2102        else            //open succesful
     2103                Do
     2104                        FreadLine refNum,OneLineStr
     2105                        if(strlen(OneLineStr)<=0)
     2106                                //break
     2107                                err=1
     2108                        endif
     2109                        MetadataString+=OneLineStr+";"
     2110                while(err==0)
     2111                Close refNum
     2112        endif
     2113        MetadataString = ReplaceString("%", MetadataString, "")
     2114        MetadataString = ReplaceString("\n", MetadataString, "")
     2115        MetadataString = ReplaceString("\r", MetadataString, "")
     2116        //MetadataString = ReplaceString(" ", MetadataString, "")
     2117        string currentItemString
     2118        variable i=0
     2119        do
     2120                currentItemString=StringFromList(i, MetadataString, ";")
     2121                i+=1
     2122                NI1_12IDBProcessTXTLine(currentItemString)
     2123        while(strlen(currentItemString)>0)
     2124end
     2125
     2126//*******************************************************************************************************************************************
     2127//*******************************************************************************************************************************************
     2128//*******************************************************************************************************************************************
     2129Function NI1_12IDBProcessTXTLine(LineToProcess)
     2130        string LineToProcess
     2131       
     2132        if(StringMatch(LineToProcess, "*[*]*" ))
     2133                LineToProcess[strsearch(LineToProcess, " ", strsearch(LineToProcess, "[", 0))]=";"
     2134                LineToProcess = ReplaceString("[", LineToProcess, "")
     2135                LineToProcess = ReplaceString("]", LineToProcess, "")
     2136        endif
     2137       
     2138        LineToProcess=ReplaceString(" ", LineToProcess, "")+";"
     2139        if(StringMatch(LineToProcess, "*row*" ))
     2140                variable/g APS12IDBtempRow = NumberByKey("row", LineToProcess, ":", ";")
     2141        endif
     2142        if(StringMatch(LineToProcess, "*col*" ))
     2143                variable/g APS12IDBtempCol = NumberByKey("col", LineToProcess, ":", ";")
     2144        endif
     2145        if(StringMatch(LineToProcess, "*pSize*" ))
     2146                NVAR PixelSizeX = root:Packages:Convert2Dto1D:PixelSizeX
     2147                NVAR PixelSizeY = root:Packages:Convert2Dto1D:PixelSizeY
     2148                PixelSizeX = NumberByKey("pSize", LineToProcess, ":", ";")
     2149                PixelSizeY = NumberByKey("pSize", LineToProcess, ":", ";")
     2150        endif
     2151        if(StringMatch(LineToProcess, "*SDD*" )&& !StringMatch(LineToProcess, "*SDDrel*" ))
     2152                NVAR SampleToCCDdistance = root:Packages:Convert2Dto1D:SampleToCCDdistance
     2153                SampleToCCDdistance = NumberByKey("SDD", LineToProcess, ":", ";")
     2154        endif
     2155        if(StringMatch(LineToProcess, "*BeamXY*" ))
     2156                NVAR BeamCenterX = root:Packages:Convert2Dto1D:BeamCenterX
     2157                NVAR BeamCenterY = root:Packages:Convert2Dto1D:BeamCenterY
     2158                NVAR APS12IDBtempRow
     2159                //Again, THIS IS INVERTED...
     2160                string TempStr=StringByKey("BeamXY", LineToProcess+"p", ":", "p")
     2161                variable BCX, BCY
     2162                BCX = str2num(StringFromList(0,TempStr,";"))
     2163                BCY = str2num(StringFromList(1,TempStr,";"))
     2164                BeamCenterY = APS12IDBtempRow - BCY             
     2165                BeamCenterX = BCX
     2166        endif
     2167        if(StringMatch(LineToProcess, "*eng*" )&&!StringMatch(LineToProcess, "*wavelength*" )&&!StringMatch(LineToProcess, "*xeng*" ))
     2168                NVAR XrayEnergy = root:Packages:Convert2Dto1D:XrayEnergy
     2169                NVAR Wavelength = root:Packages:Convert2Dto1D:Wavelength
     2170                XrayEnergy = NumberByKey("eng", LineToProcess, ":", ";")
     2171                Wavelength = 12.39842/XrayEnergy
     2172        endif
     2173        if(StringMatch(LineToProcess, "*wavelength*" ))
     2174                NVAR Wavelength = root:Packages:Convert2Dto1D:Wavelength
     2175                Wavelength = NumberByKey("wavelength", LineToProcess, ":", ";")
     2176        endif
     2177        if(StringMatch(LineToProcess, "*yaw*" ))
     2178                NVAR VerticalTilt = root:Packages:Convert2Dto1D:VerticalTilt
     2179                //Again, THIS IS INVERTED...
     2180                VerticalTilt = -1* NumberByKey("yaw", LineToProcess, ":", ";")         
     2181        endif
     2182        if(StringMatch(LineToProcess, "*absIntCoeff*" ))
     2183                NVAR CorrectionFactor = root:Packages:Convert2Dto1D:CorrectionFactor
     2184                //Again, THIS IS INVERTED...
     2185                CorrectionFactor = 1e-6 * NumberByKey("absIntCoeff", LineToProcess, ":", ";")           
     2186        endif
     2187        if(StringMatch(LineToProcess, "*qNum*" ))
     2188                NVAR QvectorNumberPoints = root:Packages:Convert2Dto1D:QvectorNumberPoints
     2189                QvectorNumberPoints = NumberByKey("qNum", LineToProcess, ":", ";")             
     2190        endif
     2191        if(StringMatch(LineToProcess, "*qMin*" ))
     2192                NVAR UserQMin = root:Packages:Convert2Dto1D:UserQMin
     2193                UserQMin = NumberByKey("qMin", LineToProcess, ":", ";")         
     2194        endif
     2195        if(StringMatch(LineToProcess, "*qMax*" ))
     2196                NVAR UserQMax = root:Packages:Convert2Dto1D:UserQMax
     2197                UserQMax = NumberByKey("qMax", LineToProcess, ":", ";")         
     2198        endif
     2199
     2200       
     2201       
     2202end
    19612203//*******************************************************************************************************************************************
    19622204//*******************************************************************************************************************************************
     
    21702412       
    21712413        LineToProcess=ReplaceString(" ", LineToProcess, "")+";"
    2172         if(StringMatch(LineToProcess, "*PixelSize(mm)*" ))
    2173                 NVAR PixelSizeX = root:Packages:Convert2Dto1D:PixelSizeX
    2174                 NVAR PixelSizeY = root:Packages:Convert2Dto1D:PixelSizeY
    2175                 PixelSizeX = NumberByKey("PixelSize(mm)", LineToProcess, ":", ";")
    2176                 PixelSizeY = NumberByKey("PixelSize(mm)", LineToProcess, ":", ";")
    2177         endif
    2178         if(StringMatch(LineToProcess, "*Sample-to-detectorDistance(mm)*" ))
    2179                 NVAR SampleToCCDdistance = root:Packages:Convert2Dto1D:SampleToCCDdistance
    2180                 SampleToCCDdistance = NumberByKey("Sample-to-detectorDistance(mm)", LineToProcess, ":", ";")
    2181         endif
    2182         if(StringMatch(LineToProcess, "*BeamCenterX*" ))
    2183                 NVAR BeamCenterX = root:Packages:Convert2Dto1D:BeamCenterX
    2184                 BeamCenterX = NumberByKey("BeamCenterX", LineToProcess, ":", ";")
    2185         endif
    2186         if(StringMatch(LineToProcess, "*BeamCenterY*" ))
    2187                 NVAR BeamCenterY = root:Packages:Convert2Dto1D:BeamCenterY
    2188                 //Again, THIS IS INVERTED...
    2189                 variable DimYSize=DimSize(LoadedWvHere, 1 )
    2190                 BeamCenterY = DimYSize - NumberByKey("BeamCenterY", LineToProcess, ":", ";")           
    2191         endif
    2192         if(StringMatch(LineToProcess, "*X-rayEnergy(keV)*" ))
    2193                 NVAR XrayEnergy = root:Packages:Convert2Dto1D:XrayEnergy
    2194                 NVAR Wavelength = root:Packages:Convert2Dto1D:Wavelength
    2195                 XrayEnergy = NumberByKey("X-rayEnergy(keV)", LineToProcess, ":", ";")
    2196                 Wavelength = 12.39842/XrayEnergy
    2197         endif
    2198         if(StringMatch(LineToProcess, "*TiltAnglePitch(degree)*" ))
    2199                 NVAR VerticalTilt = root:Packages:Convert2Dto1D:VerticalTilt
    2200                 //Again, THIS IS INVERTED...
    2201                 VerticalTilt = -1* NumberByKey("TiltAnglePitch(degree)", LineToProcess, ":", ";")               
    2202         endif
    2203 end
    2204 //*******************************************************************************************************************************************
    2205 //*******************************************************************************************************************************************
    2206 Function NI1_12IDBLoadGoodPixMask()                     //todo: some error handling...
    2207                 //should be able to find mask in current working folder
    2208         string OldDFf=GetDataFolder(1)
    2209         NVAR UseMask = root:Packages:Convert2Dto1D:UseMask
    2210         variable ProcessingTypeVal=0            //Processing type is : 0 use beamline processing (just reduction) or 1 subtract empty/background and reduce.
    2211         string ProcessingTypeStr="No"
    2212         setDataFOlder root:Packages:Convert2Dto1D:
    2213         //get the path to SAXS_mask2M.bmp or WAXS_mask2M.bpm, it is one level up...
    2214         PathInfo Convert2Dto1DDataPath
    2215         string DataFilePath=S_path
    2216         string UsingWhat=StringFromList(ItemsInList(DataFilePath,":")-1, DataFilePath,":")
    2217         string MaskPathStr= RemoveFromList(UsingWhat, DataFilePath,":")
    2218         //mask may or may not exist, we need to get user to pick one or tell us it does not exist...
    2219         NewPath/O/Q TempMaskUserPath, MaskPathStr
    2220         string ListOfBMPFiles=IndexedFile(TempMaskUserPath, -1, ".bmp")
    2221         string SelectedMaskFile
    2222         if(strlen(ListOfBMPFiles)>0)
    2223                 Prompt SelectedMaskFile, "Select BMP Mask file", popup, ListOfBMPFiles+"---;"
    2224                 Prompt ProcessingTypeStr, "Subtract Empty/background", popup, "No;Yes;"
    2225                 DoPrompt "Select Mask/Method", ProcessingTypeStr, SelectedMaskFile
    2226                 if(V_Flag || stringmatch(SelectedMaskFile,"---"))
    2227                         print "User canceled mask file selection, continue without it"
    2228                         UseMask = 0
    2229                         if(stringMatch(ProcessingTypeStr,"Yes"))
    2230                                 ProcessingTypeVal = 1
    2231                         endif
    2232                         return ProcessingTypeVal
     2414        NVAR APS12IDBReloadPars
     2415        if(APS12IDBReloadPars)
     2416                if(StringMatch(LineToProcess, "*PixelSize(mm)*" ))
     2417                        NVAR PixelSizeX = root:Packages:Convert2Dto1D:PixelSizeX
     2418                        NVAR PixelSizeY = root:Packages:Convert2Dto1D:PixelSizeY
     2419                        PixelSizeX = NumberByKey("PixelSize(mm)", LineToProcess, ":", ";")
     2420                        PixelSizeY = NumberByKey("PixelSize(mm)", LineToProcess, ":", ";")
    22332421                endif
    2234                 if(stringMatch(ProcessingTypeStr,"Yes"))
    2235                         ProcessingTypeVal = 1
     2422                if(StringMatch(LineToProcess, "*Sample-to-detectorDistance(mm)*" ))
     2423                        NVAR SampleToCCDdistance = root:Packages:Convert2Dto1D:SampleToCCDdistance
     2424                        SampleToCCDdistance = NumberByKey("Sample-to-detectorDistance(mm)", LineToProcess, ":", ";")
    22362425                endif
    2237                 ImageLoad/T=bmp/Q/N=TMPBMPMask/Z/P=TempMaskUserPath SelectedMaskFile
    2238                 if(V_Flag)
    2239                         print ":Loaded succesfully mask file from "+MaskPathStr+SelectedMaskFile
    2240                 else
    2241                         DoALert/T="Could not load Mask file" 0, "Could not load selected file with mask, you need to create mask manually"
    2242                         UseMask = 0
    2243                         return ProcessingTypeVal
     2426                if(StringMatch(LineToProcess, "*BeamCenterX*" ))
     2427                        NVAR BeamCenterX = root:Packages:Convert2Dto1D:BeamCenterX
     2428                        BeamCenterX = NumberByKey("BeamCenterX", LineToProcess, ":", ";")
    22442429                endif
    2245                 Wave LoadedmaskImage = TMPBMPMask
    2246                 ImageTransform rgb2gray LoadedmaskImage
    2247                 Wave M_RGB2Gray
    2248                 ImageTransform flipCols M_RGB2Gray                      //this is correct flip needed...
    2249                 DoWIndow CCDImageToConvertFig
    2250                 if(V_Flag)
    2251                         RemoveImage/W=CCDImageToConvertFig/Z  M_ROIMask
     2430                if(StringMatch(LineToProcess, "*BeamCenterY*" ))
     2431                        NVAR BeamCenterY = root:Packages:Convert2Dto1D:BeamCenterY
     2432                        //Again, THIS IS INVERTED...
     2433                        variable DimYSize=DimSize(LoadedWvHere, 1 )
     2434                        BeamCenterY = DimYSize - NumberByKey("BeamCenterY", LineToProcess, ":", ";")           
    22522435                endif
    2253                 KillWaves/Z M_ROIMask, TMPBMPMask
    2254                 wavestats/Q M_RGB2Gray
    2255                 M_RGB2Gray/=V_max                               //normalize to be 1 or 0, seem to be 255
    2256                 Rename M_RGB2Gray, M_ROIMask
    2257                 UseMask = 1
    2258         else            //no mask file found
    2259                 print "No BMP mask file found, continue without it"
    2260                 Prompt ProcessingTypeStr, "Subtract Empty/background", popup, "No;Yes;"
    2261                 DoPrompt "Select Method", SelectedMaskFile, ProcessingTypeStr
    2262                 if(stringMatch(ProcessingTypeStr,"Yes"))
    2263                         ProcessingTypeVal = 1
     2436                if(StringMatch(LineToProcess, "*X-rayEnergy(keV)*" ))
     2437                        NVAR XrayEnergy = root:Packages:Convert2Dto1D:XrayEnergy
     2438                        NVAR Wavelength = root:Packages:Convert2Dto1D:Wavelength
     2439                        XrayEnergy = NumberByKey("X-rayEnergy(keV)", LineToProcess, ":", ";")
     2440                        Wavelength = 12.39842/XrayEnergy
    22642441                endif
    2265                 UseMask = 0
    2266                 return ProcessingTypeVal
    2267         endif
    2268 
    2269 
    2270 
    2271 
    2272         setDataFolder OldDFf   
    2273         return ProcessingTypeVal
    2274 end
     2442                if(StringMatch(LineToProcess, "*TiltAnglePitch(degree)*" ))
     2443                        NVAR VerticalTilt = root:Packages:Convert2Dto1D:VerticalTilt
     2444                        //Again, THIS IS INVERTED...
     2445                        VerticalTilt = -1* NumberByKey("TiltAnglePitch(degree)", LineToProcess, ":", ";")               
     2446                endif
     2447        endif
     2448end
     2449//*******************************************************************************************************************************************
     2450//*******************************************************************************************************************************************
     2451//Function NI1_12IDBGetUserInput()                      //todo: some error handling...
     2452//              //should be able to find mask in current working folder
     2453//      string OldDFf=GetDataFolder(1)
     2454//      NVAR UseMask = root:Packages:Convert2Dto1D:UseMask
     2455//      variable ProcessingTypeVal=0            //Processing type is : 0 use beamline processing (just reduction) or 1 subtract empty/background and reduce.
     2456//      string ProcessingTypeStr="No"
     2457//      setDataFOlder root:Packages:Convert2Dto1D:
     2458//      //get the path to SAXS_mask2M.bmp or WAXS_mask2M.bpm, it is one level up...
     2459//      PathInfo Convert2Dto1DDataPath
     2460//      string DataFilePath=S_path
     2461//      string UsingWhat=StringFromList(ItemsInList(DataFilePath,":")-1, DataFilePath,":")
     2462//      string MaskPathStr= RemoveFromList(UsingWhat, DataFilePath,":")
     2463//      //mask may or may not exist, we need to get user to pick one or tell us it does not exist...
     2464//      NewPath/O/Q TempMaskUserPath, MaskPathStr
     2465//      string ListOfBMPFiles=IndexedFile(TempMaskUserPath, -1, ".bmp")
     2466//      string SelectedMaskFile
     2467//      if(strlen(ListOfBMPFiles)>0)
     2468//              Prompt SelectedMaskFile, "Select BMP Mask file", popup, ListOfBMPFiles+"---;"
     2469//              Prompt ProcessingTypeStr, "Subtract Empty/background", popup, "No;Yes;"
     2470//              DoPrompt "Select Mask/Method", ProcessingTypeStr, SelectedMaskFile
     2471//              if(V_Flag || stringmatch(SelectedMaskFile,"---"))
     2472//                      print "User canceled mask file selection, continue without it"
     2473//                      UseMask = 0
     2474//                      if(stringMatch(ProcessingTypeStr,"Yes"))
     2475//                              ProcessingTypeVal = 1
     2476//                      endif
     2477//                      return ProcessingTypeVal
     2478//              endif
     2479//              if(stringMatch(ProcessingTypeStr,"Yes"))
     2480//                      ProcessingTypeVal = 1
     2481//              endif
     2482//              ImageLoad/T=bmp/Q/N=TMPBMPMask/Z/P=TempMaskUserPath SelectedMaskFile
     2483//              if(V_Flag)
     2484//                      print ":Loaded succesfully mask file from "+MaskPathStr+SelectedMaskFile
     2485//              else
     2486//                      DoALert/T="Could not load Mask file" 0, "Could not load selected file with mask, you need to create mask manually"
     2487//                      UseMask = 0
     2488//                      return ProcessingTypeVal
     2489//              endif
     2490//              Wave LoadedmaskImage = TMPBMPMask
     2491//              ImageTransform rgb2gray LoadedmaskImage
     2492//              Wave M_RGB2Gray
     2493//              ImageTransform flipCols M_RGB2Gray                      //this is correct flip needed...
     2494//              DoWIndow CCDImageToConvertFig
     2495//              if(V_Flag)
     2496//                      RemoveImage/W=CCDImageToConvertFig/Z  M_ROIMask
     2497//              endif
     2498//              KillWaves/Z M_ROIMask, TMPBMPMask
     2499//              wavestats/Q M_RGB2Gray
     2500//              M_RGB2Gray/=V_max                               //normalize to be 1 or 0, seem to be 255
     2501//              Rename M_RGB2Gray, M_ROIMask
     2502//              UseMask = 1
     2503//      else            //no mask file found
     2504//              print "No BMP mask file found, continue without it"
     2505//              Prompt ProcessingTypeStr, "Subtract Empty/background", popup, "No;Yes;"
     2506//              DoPrompt "Select Method", SelectedMaskFile, ProcessingTypeStr
     2507//              if(stringMatch(ProcessingTypeStr,"Yes"))
     2508//                      ProcessingTypeVal = 1
     2509//              endif
     2510//              UseMask = 0
     2511//              return ProcessingTypeVal
     2512//      endif
     2513//
     2514//
     2515//
     2516//
     2517//      setDataFolder OldDFf   
     2518//      return ProcessingTypeVal
     2519//end
    22752520//*******************************************************************************************************************************************
    22762521//*******************************************************************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.