Selecting subsets of Images

macro
Tags: #<Tag:0x00007fd5400c62b0>

#1

Hi guys,

is there a way to select an open window using ‘selectWindow()’ by only using a part of the image title?
For example I have 3 images open

1213_volume.tiff
1213_surface.tiff
1213_xxx.tiff

and want to select only the image containing ‘volume’ in it’s name.
Is that possible?

Thanks in advance


#2

Not directly, but you can add this small function that adds the functionality you need

function selectImageByPart(title_part) {
	//Get imageList
	images = getList("image.titles");
	// find first image that contains the title_part
	for(i=0; i< images.length;i++) {
		if(matches(images[i], ".*"+title_part+".*")) {
			selectImage(images[i]);
			return;
		}
	}
}

Then you can use it in your script by calling selectImageByPart(“volume”);

There are other solutions, but this is the most quick I could write up.


#3

Thanks oburri,

that was exactly what I was looking for!

Greeting from Basel
Niklas