-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathopenslide_open.m
56 lines (49 loc) · 1.87 KB
/
openslide_open.m
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
function openslidePointer = openslide_open(slideName)
% OPENSLIDE_OPEN Opens a whole-slide image for interaction
%
% openslidePointer = openslide_open(slideName)
%
% INPUT ARGUMENTS
% slideName - Full file name of whole-slide image to interact with, i.e.
% including path and file extension
%
% OPTIONAL INPUT ARGUMENTS
% N/A
%
% OUTPUT
% openslidePointer - Pointer to whole-slide image to interact with, to be used
% as input argument in other openslide funcions
% Copyright (c) 2016 Daniel Forsberg
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%%
% Check if library for openslide is already loaded
if ~libisloaded('openslidelib')
warning('OpenSlide library has not been loaded, attempting to load')
openslide_load_library();
end
% Get pointer to whole-slide image
openslidePointer = calllib('openslidelib','openslide_open',slideName);
% Check validity of returned pointer
if isempty(openslidePointer)
errorMessage = ['Unable to open the specified slide: ',slideName,'\n'];
error('openslide:openslide_open',errorMessage)
end
% Check for errors
[errorMessage] = openslide_get_error(openslidePointer);
% Terminate if an error was returned
if ~isempty(errorMessage)
error('openslide:openslide_open',errorMessage)
end