#pragma rtGlobals=1 // Use modern global access method. #pragma version=5.0 #pragma IgorVersion=6.1 //********************* // Vers. 1.2 092101 // //entry procedure for reading a mask file //mask files are currently only acceptable in MCID format, as written out by NIH //Image, available on the Macs (haven't tested the output of the Java version //(Image/J) // // also contains new drawing routines for drawing a mask within IGOR // and saving it in the required format // - uses simpler drawing tools (fill objects, no lines) for speed // //************************* //reads the data (1=mask, 0 = no mask) //and plots a quickie image to make sure it's ok //data is always read into root:Packages:NIST:MSK folder // Proc ReadMASK() //SetDataFolder root:Packages:NIST:MSK String fname = PromptForPath("Select Mask file") if(strlen(fname)==0) return endif ReadMCID_MASK(fname) //SetDataFolder root:Packages:NIST:MSK //// SRK SEP06 disable plot of mask data, just show the overlay //// String waveStr = "root:Packages:NIST:MSK:data" //// NewImage/F/S=2/K=1 $waveStr //// ModifyImage '' ctab= {*,*,YellowHot,0} maskButtonProc("maskButton") // OverlayMask(1) //back to root folder (redundant) SetDataFolder root: End //reads the mask data into the root:Packages:NIST:MSK folder //setDataFolder is required here //y-values must be flipped to get proper array assignment of the mask // // SRK -SEP09 - removed hard-wired 16384 (128x128) from GBLoadWave cmd string // for general XY compatibility (192x192) = 36864 // Function ReadMCID_MASK(fname) String fname // Reads MCID-format mask files written out by SANS IMAGE // put data into MSK data folder // flip the y-values to correspond to the work file NVAR pixelsX = root:myGlobals:gNPixelsX NVAR pixelsY = root:myGlobals:gNPixelsY SetDataFolder root:Packages:NIST:MSK Killwaves/Z data,data0 //kill the old data, if it exists // String cmd = "GBLoadWave/N=data/T={72,72}/O/S=4/W=1/U=16384 /Q \"" + fname +"\"" String cmd = "GBLoadWave/N=data/T={72,72}/O/S=4/W=1/U=" cmd += num2istr(pixelsX*pixelsY) + " /Q \"" + fname +"\"" Execute cmd SetDataFolder root:Packages:NIST:MSK //make sure correct data folder is set WAVE data0 = $"root:Packages:NIST:MSK:data0" Redimension/N=(pixelsX,pixelsY) data0 Flip_Y(data0) SetDataFolder root:Packages:NIST:MSK Rename data0,data Variable/G root:Packages:NIST:MSK:gIsLogScale = 0 String/G root:Packages:NIST:MSK:fileList = GetFileNameFromPathNoSemi(fname) //back to root folder SetDataFolder root: return(0) End // //flips the y-data of the MCID format array that was read in //the input array (pixelsX x pixelsY) is overwritten as output // // AND MUST BE SQUARE! // Function Flip_Y(mat) Wave mat //reverses the order of y-indices in an MCID-style matrix output from SANS IMAGE, //so that a mask file will be displayed properly on screen - //"IMAGE" format is (0,0) in top left //the (WORK)_data matches the detector, with (0,0) in the bottom left corner NVAR pixelsX = root:myGlobals:gNPixelsX NVAR pixelsY = root:myGlobals:gNPixelsY Variable ii,jj,kk Make/O/N=(pixelsX) temp_y ii=0 do jj=0 do temp_y[jj]=mat[ii][jj] jj+=1 while(jj=0) //pad the rest of the file ii=0 jj=0 do FBinWrite /F=1 refnum,jj ii+=1 while(ii<508) //close the file Close refnum ReadMCID_MASK(fullpath) Killwaves/Z byteWave End