Skip to content

Instantly share code, notes, and snippets.

@lacan
Last active July 27, 2018 16:48
Show Gist options
  • Save lacan/24cd5bb098faa30824a6 to your computer and use it in GitHub Desktop.
Save lacan/24cd5bb098faa30824a6 to your computer and use it in GitHub Desktop.
Imaris Batch Channel Math with EasyXT #Imaris #EasyXT #Matlab
% Example of looping through a folder to process a series of images.
% In this case, perform channel math.
% For convenience, this example uses EasyXT, but feel free to adapt it as needed.
% Get EasyXT Here: http://lacan.github.io/EasyXT/
% The ChannelMath method is borrowed from the XTension with the same name, made by Bitplane.
folder_name = uigetdir();
listing = dir(folder_name);
% Math expression you want to use
expression = {'sqrt(ch1 .* ch2)'};
% Extension of your image files
ext = '.lsm';
% Define save folder
savefolder_name = [folder_name '\save\'];
mkdir(savefolder_name);
%Start EasyXT(), Get it at: http://lacan.github.io/EasyXT/
X = EasyXT();
% Loop through the images
for i =1:size(listing,1)
file = listing(i);
if ~file.isdir && strcmp(file.name((end-3):end), ext)
% Clear the scene and make a new one, just in case
X.CreateNewScene();
X.imarisApp.FileOpen([folder_name '\' file.name],'');
% Call XTension or do some processing on the image
X.ChannelMath(expression);
app.FileSave([savefolder_name file.name(1:end-4) '.ims'], '');
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment