I have written a procedure, which I will be implementing in a GUI, where n image files are loaded. The number of images (n) is already determined by the length of a pre-existing wave. The user selects the first file in the list from a dialogue, the script then loads all the waves. My approach was to select the first file, then generate a list of all the files in the folder using IndexedFile(myPath, -1, "TIFF"), get the index of the first file selected using WhichListItem then loop to generate a list of all the required files. I wanted to this so that I could call the ImageLoad operation just once operating on the list of selected files. The problem however, is that with the path name and a list of up to, or even greater than 20 images with 20 characters per name the strings quickly become too long. I know that this can be solved by just putting the image load in the loop selecting the files but is there any way to initiate the ImageLoad once (Would it even be quicker or worthwhile!?) or should I just stick it in the loop and call for each file? See the code below:
IndexedFile(myPath, -1, "TIFF")
String pathName = ""
String fileName = ""
Open/D/R/T="TIFF" /P=$pathName /M="Select first image in scan" refNum as fileName
If ( strlen(S_fileName) == 0 )
pathName = ParseFilePath(1, S_fileName, ":", 1, 0)
NewPath/O myPath pathName
fileName = ParseFilePath(0, S_fileName, ":", 1, 0)
String FilesInFolder = IndexedFile(myPath, -1, "TIFF")
Variable firstFileIndex = WhichListItem(fileName, FilesInFolder)
Wave wAlphaI = $(StringFromList(0,WaveList("*","","DIMS:1"))) // there is only one wave in this folder with Dim = 1
String filesToLoad = ""
Variable fileIndex = firstFileIndex
filesToLoad += IndexedFile(myPath, fileIndex, "TIFF")+";"
if( strlen(fileName) == 0 )
fileIndex += 1
While( fileIndex < firstFileIndex+(NumPnts(wAlphaI) )
sprintf ImageLoadCMD, "ImageLoad/P=%s/T=TIFF %s" , pathName, filesToLoad
ImageLoad is designed to handle one image file per call. Here is an example of loading all images in a folder specified by the user (Newpath) and where the file names have the suffix ".tif":
String name,list=IndexedFile(myPath, -1, ".tif")
I hope this helps,
Back to top