#pragma TextEncoding = "Windows-1252" #pragma rtGlobals=3 // Use modern global access method and strict wave access. Function LoadPhotonCounting2() String Setname ="LL" Prompt SETNAME, "Name of set" DoPrompt "Input name for Set", setname if(V_flag) print "Cancelled by user" return -1 endif NewDataFolder/O/S root:$"PS_"+setname variable dpt=150000,numofFrames,refNum,pos,dptdif=0,ComLen,Nframes String pathName,str,fullPath,fileFilters = "Data Files (*.dpt,*.dpc):.dpt,.dpc;" String/G fileName,expdetails="" Variable/G photonN, timestamp Open/F=filefilters/R/Z=2 refNum //as fileName // Store results from Open in a safe place. fullPath = S_fileName filename=S_filename if (V_flag == -1) Print "DemoOpen cancelled by user." return -1 endif if (V_flag != 0) DoAlert 0, "Error in DemoOpen" return V_flag endif Make/O/N=2 IM //Store 2 first Characters Make/O/N=31 header=0 //Make Wave to store header values Fbinread/U/F=1 refnum, IM //First 2 characters should be IM (73 77) Fbinread/F=2 refnum, header //read the first 62 bytes of the header variable ii,jj,BytereadX,BytereadY,numofphotons,delimeter Make/O/T HContent Hcontent= {"comment length","width of image","height of image","x offset","y offset","file type 2=16bit","reserved"} // explanation of the header values read for future reference Fstatus refnum /// read the first 11 lines (the comment section) into a string FReadLine refNum, str // Read first line into string variable expdetails=str for(ii=0;ii<10;ii+=1) //read following 10 lines and append to expdetails FReadLine refNum, str expdetails+=str endfor //now get number of frames/exposures from the expdetails Nframes=str2num(expdetails[strsearch(expdetails,"NrExposure=",0,2)+11,strsearch(expdetails,",",strsearch(expdetails,"NrExposure=",0,2),2)-1]) variable/G threshold=str2num(expdetails[strsearch(expdetails,"threshold=",0,2)+10,strsearch(expdetails,"[",strsearch(expdetails,"threshold=",0,2),2)-1]) numofFrames=Nframes Variable/G frames=numofFrames Fsetpos refnum, 64+header[0] // go to the start of the data //read timestamp Fbinread/U/F=4 refnum, timestamp //read the timestamp //==============Make table to hold X0 and Y0 coordinates Fstatus refnum photonN=(V_logEOF-V_filepos-numofframes*5)/4 +1 ///// photons = (filebytes-headerbytes-bytes for end of frame X frames- file end bytes ) / (bytes per photon coord ) + 1 printf "I will read %g frames \r" frames// filename,V_logEOF,V_filepos Make/O/N=(photonN) X0=0,Y0=0 Make/O/N=(numofframes) Fpoint Fpoint=0 print Nframes X0=-5;Y0=-5;ii=0; jj=0 ////======read photons bytereadY=0;bytereadX=0 for(ii=0;jj1) print "DPT filetype detected, proceeding to bin data in single line" BinInSinglecolumn() //do binning debugging place0Framesatend() else Duplicate/O PhPFr PHline MakeYavg() place0Framesatend() endif // and place the null frames at the end (speeds up the G calculation algorithm by moving the null values at the end and breaking when the first zero is detected) End