#pragma rtGlobals=1 // Use modern global access method. #pragma version=5.0 #pragma IgorVersion=6.1 //************************* // Vers. 1.2 092101 // // Procedures for the MRED panel to allow quick batch reduction of data files // -as of 8/01, use the new method of requiring only run numbers to select the datafiles // and these data failes need not be consecutively numbered // //****note that much of this file is becoming obsolete as improved methods for //reducing multiple files are introduced. Some of these procedures may not last long*** // //************************** //panel to allow reduction of a series of files using a selected protocol // //main entry procedure to open the panel, initializing if necessary Proc ReduceMultipleFiles() DoWindow/F Multiple_Reduce_Panel If(V_flag == 0) InitializeMultReducePanel() //draw panel Multiple_Reduce_Panel() //pop the protocol list MRProtoPopMenuProc("",1,"") Endif End //create the global variables needed to run the MReduce Panel //all are kept in root:myGlobals:MRED // Proc InitializeMultReducePanel() If(DataFolderExists("root:myGlobals:MRED")) //ok, do nothing else //no, create the folder and the globals NewDataFolder/O root:myGlobals:MRED // String/G root:myGlobals:MRED:gMRedMatchStr = "*" PathInfo catPathName If(V_flag==1) String dum = S_path String/G root:myGlobals:MRED:gCatPathStr = dum else String/G root:myGlobals:MRED:gCatPathStr = "no path selected" endif String/G root:myGlobals:MRED:gMRedList = "none" String/G root:myGlobals:MRED:gMRProtoList = "none" String/G root:myGlobals:MRED:gFileNumList="" // String/G root:myGlobals:MRED:gMRS1 = "no file selected" // String/G root:myGlobals:MRED:gMRS2 = "no file selected" // String/G root:myGlobals:MRED:gMRS3 = "no box selected" // Variable/G root:myGlobals:MRED:gMRV1 =0 // Variable/G root:myGlobals:MRED:gMRV2 = 999 Endif End //panel recreation macro for the MRED panel // Window Multiple_Reduce_Panel() PauseUpdate; Silent 1 // building window... NewPanel /W=(535,72,951,228) /K=1 as "Multiple File Reduction" ModifyPanel cbRGB=(65535,49151,29490) ModifyPanel fixedSize=1 SetDrawLayer UserBack DrawLine 7,30,422,30 SetVariable PathDisplay,pos={77,7},size={300,13},title="Path" SetVariable PathDisplay,help={"This is the path to the folder that will be used to find the SANS data while reducing. If no files appear in the popup, make sure that this folder is set correctly"} SetVariable PathDisplay,limits={-Inf,Inf,0},value= root:myGlobals:MRED:gCatPathStr Button PathButton,pos={3,3},size={70,20},proc=PickMRPathButton,title="Pick Path" Button PathButton,help={"Select the folder containing the raw SANS data files"} Button helpButton,pos={385,3},size={25,20},proc=ShowMRHelp,title="?" Button helpButton,help={"Show the help file for reducing multiple files using the same protocol"} PopupMenu MRFilesPopup,pos={3,72},size={167,19},proc=MRedPopMenuProc,title="File(s) to Reduce" PopupMenu MRFilesPopup,help={"The displayed file is the one that will be reduced. The entire list will be reduced if \"Reduce All..\" is selected. \r If no items, or the wrong items appear, click on the popup to refresh."} PopupMenu MRFilesPopup,mode=1,popvalue="none",value= #"root:myGlobals:MRED:gMRedList" SetVariable MRList,pos={3,48},size={350,13},proc=FileNumberListProc,title="File number list: " SetVariable MRList,help={"Enter a comma delimited list of file numbers to reduce. Ranges can be entered using a dash."} SetVariable MRList,limits={-Inf,Inf,1},value= root:myGlobals:MRED:gFileNumList Button ReduceAllButton,pos={3,128},size={180,20},proc=ReduceAllPopupFiles,title="Reduce All Files in Popup" Button ReduceAllButton,help={"This will reduce ALL of the files in the popup list, not just the top file."} Button DoneButton,pos={292,128},size={110,20},proc=MRDoneButtonProc,title="Done Reducing" Button DoneButton,help={"When done reducing files, this will close this control panel."} Button cat_short,pos={310,72},size={90,20},proc=DoCatShort,title="File Catalog" Button cat_short,help={"Use this button to generate a table with file header information. Very useful for identifying files."} Button show_cat_short,pos={280,98},size={120,20},proc=ShowCatShort_MRED,title="Show File Catalog" Button show_cat_short,help={"Use this button to bring the File Catalog window to the front."} PopupMenu MRProto_pop,pos={3,98},size={119,19},proc=MRProtoPopMenuProc,title="Protocol " PopupMenu MRProto_pop,help={"All of the data files in the popup will be reduced using this protocol"} PopupMenu MRProto_pop,mode=1,popvalue="none",value= #"root:myGlobals:MRED:gMRProtoList" EndMacro //simple procedure to bring the CAT TABLE to the front if it is present //alerts user, but does nothing else if CAT TABLE is not present //called by several panels // Proc ShowCATWindow() DoWindow/F CatVSTable if(V_flag==0) DoAlert 0,"There is no File Catalog table. Use the File Catalog button to create one." Endif End //function takes a list of filenames (just the name, no path , no extension) //that is COMMA delimited, and creates a new list that is also COMMA delimited //and contains the full path:file;vers for each file in the list //and ensures that files in returned list are RAW data , and can be found on disk // Function/S FullNameListFromFileList(list) String list String newList="",pathStr="",sepStr="," PathInfo catPathName if(V_flag==0) Abort "CatPath does not exist - use Pick Path to select the data folder" else pathStr = S_Path Endif Variable ii,num,ok String fullName="",partialName="",tempName="",str num = ItemsInList(list,",") ii=0 do //take each item, and try to find the file (extensions for raw data should be ;1) partialName = StringFromList(ii,list,",") //COMMA separated list if(strlen(partialName)!=0) //null string items will be skipped tempName = FindValidFilename(partialName) //will add the version # if needed fullName = pathStr + tempName //prepend the path (CAT) //discard strings that are not filenames (print the non-files) //make sure the file is really a RAW data file ok = CheckIfRawData(fullName) // 1 if RAW, 0 if unknown type if (!ok) //write to cmd window that file was not a RAW SANS file str = "This file is not recognized as a RAW SANS data file: "+tempName+"\r" Print str else //yes, a valid file:path;ext that is RAW SANS //add the full path:file;ext +"," to the newList newList += fullName + sepStr Endif endif //partialName from original list != "" ii+=1 while(ii= items) // no more items? break endif item= StringFromList(ii, list, separator) outputList += PossiblyQuoteName(item) + separator ii += 1 while(1) return outputList End