-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXTBatchProcess.m
More file actions
executable file
·95 lines (83 loc) · 2.55 KB
/
XTBatchProcess.m
File metadata and controls
executable file
·95 lines (83 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
%
%
% Batch Process Function for Imaris 7.3.0
%
% Copyright Bitplane AG 2011
%
%
% Installation:
%
% - Copy this file into the folder containing the XTensions you want to use
% - You will find this function in the Image Processing menu
%
% <CustomTools>
% <Menu>
% <Item name="Batch Process" icon="Matlab" tooltip="Automatically process images with a custom script">
% <Command>MatlabXT::XTBatchProcess(%i)</Command>
% </Item>
% </Menu>
% </CustomTools>
%
%
% Description:
%
% This XTension batch processes images.
%
%
function XTBatchProcess(aImarisApplicationID)
%Get script directory
scriptname = mfilename;
scriptfullname = mfilename('fullpath');
idx = strfind(scriptfullname, scriptname);
scriptpath = scriptfullname(1:idx(size(idx,2))-1);
%Get .m files (provided functions names equal filenames)
matlabfiles = what(scriptpath);
[junk,mfiles] = cellfun(@fileparts,matlabfiles.m,'UniformOutput',0); %#ok
clear junk;
%Get the current function name
[junk,curfun] = fileparts(scriptname); %#ok
clear junk;
%Remove it from the functions list
curfunidx = ismember(mfiles,curfun);
mfiles(curfunidx) = [];
%Get the images folder
folder = uigetdir;
files = [folder '\*.ims'];
listing = dir(files);
nfiles = size(listing,1);
%Choose the image processing
[selection,ok] = listdlg('PromptString','Select a function:',...
'SelectionMode','single',...
'ListString',mfiles);
if(ok == 1)
%Define function name
funcname = mfiles{selection};
funstr = funcname;
fun = str2func(funstr);
%Get the Imaris application
if isa(aImarisApplicationID, 'Imaris.IApplicationPrxHelper')
vImarisApplication = aImarisApplicationID;
else
% Connect to Imaris interface
javaaddpath ImarisLib.jar
vImarisLib = ImarisLib;
if ischar(aImarisApplicationID)
aImarisApplicationID = round(str2double(aImarisApplicationID));
end
vImarisApplication = vImarisLib.GetApplication(aImarisApplicationID);
end
%Process the files
for i=1:nfiles
filename = [folder '\' listing(i).name];
vImarisApplication.FileOpen(filename, '');
vImarisApplication.GetSurpassCamera().SetOrientationAxisAngle([0,0,1],0);
vImarisApplication.GetSurpassCamera().Fit();
%Process one image
try
fun(vImarisApplication);
catch err
disp(getReport(err,'extended'));
end
end
end
end