Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Train a Weka model on multiple images by stacking slices from them together as a single stack. The stack is the same size in XY as the largest image, and all smaller images are padded with 0's to the lower-right corner to keep their original scale.
// Requirements:
// Trainable Weka Segmentation
// The list of files to use for training must be described in a text file,
// with each line containing the full path to one image.
listOfImages = File.openDialog("Choose a file with a list of images:");
imagesString = File.openAsString(listOfImages);
images = split(imagesString, "\n");
for (i=0; i<images.length; i++) {
// To simulate training a Weka model on multiple datasets, this set of images
// is stacked in ImageJ/FIJI before being passed to Weka. Empty space with voxels
// equal to 0 are padded to the bottom-right of the image as needed.
run("Images to Stack", "method=[Copy (top-left)] name=Training Set title=[] use");
run("Trainable Weka Segmentation");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment