Load All TIFF Files
hrodstein
// LoadAllTIFFFilesFromFolder(pathName, nameWaveAfterFileName, displayImages)
// This function loads each TIFF file in a given file folder into Igor.
// The name of the TIFF file is assumed to end with ".tif".
// pathName is the name of an Igor symbolic path or "" to get a dialog.
// If nameWaveAfterFileName is true, the output wave name is the file name less the extension.
// Otherwise it is something like image0, image1 . . .
// If displayImages is true, a new image plot is created for each image.
Function LoadAllTIFFFilesFromFolder(pathName, nameWaveAfterFileName, displayImages)
String pathName // Name of an Igor symbolic path or "" to get a dialog
Variable nameWaveAfterFileName
Variable displayImages // 1 to display each image in a plot
if (strlen(pathName) == 0)
NewPath/O/M="Choose a folder containing TIFFs" LoadIndexedTIFFPath
if (V_flag != 0)
return -1 // User cancelled
endif
pathName = "LoadIndexedTIFFPath"
endif
String fileName
Variable index
index = 0
do
fileName = IndexedFile($pathName, index, ".tif")
if (strlen(fileName) == 0)
break // No more files.
endif
ImageLoad/P=$pathName/T=TIFF/N=image fileName
if (V_flag > 0)
String name = StringFromList(0, S_waveNames)
Wave w = $name
if (nameWaveAfterFileName)
String desiredName = S_fileName // S_fileName is set by ImageLoad
desiredName = ParseFilePath(3, S_fileName, ":", 0, 0) // Remove extension
if (Exists(desiredName) != 0)
desiredName = UniqueName(desiredName, 1, 0)
endif
Rename w, $desiredName
endif
if (displayImages)
NewImage w
endif
endif
index += 1
while (1)
End
// This function loads each TIFF file in a given file folder into Igor.
// The name of the TIFF file is assumed to end with ".tif".
// pathName is the name of an Igor symbolic path or "" to get a dialog.
// If nameWaveAfterFileName is true, the output wave name is the file name less the extension.
// Otherwise it is something like image0, image1 . . .
// If displayImages is true, a new image plot is created for each image.
Function LoadAllTIFFFilesFromFolder(pathName, nameWaveAfterFileName, displayImages)
String pathName // Name of an Igor symbolic path or "" to get a dialog
Variable nameWaveAfterFileName
Variable displayImages // 1 to display each image in a plot
if (strlen(pathName) == 0)
NewPath/O/M="Choose a folder containing TIFFs" LoadIndexedTIFFPath
if (V_flag != 0)
return -1 // User cancelled
endif
pathName = "LoadIndexedTIFFPath"
endif
String fileName
Variable index
index = 0
do
fileName = IndexedFile($pathName, index, ".tif")
if (strlen(fileName) == 0)
break // No more files.
endif
ImageLoad/P=$pathName/T=TIFF/N=image fileName
if (V_flag > 0)
String name = StringFromList(0, S_waveNames)
Wave w = $name
if (nameWaveAfterFileName)
String desiredName = S_fileName // S_fileName is set by ImageLoad
desiredName = ParseFilePath(3, S_fileName, ":", 0, 0) // Remove extension
if (Exists(desiredName) != 0)
desiredName = UniqueName(desiredName, 1, 0)
endif
Rename w, $desiredName
endif
if (displayImages)
NewImage w
endif
endif
index += 1
while (1)
End
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More