1+ function [I ,idx ] = bfGetPlaneAtZCT( r , z , c , t , varargin )
2+ % bfGetPlaneAtCZT Obtains an image plane for the Z, C, T
3+ %
4+ % I = bfGetPlaneAtZCT(r, z, c, t) returns a specified plane from the input
5+ % format reader. The indices specifying the plane to retrieve should be
6+ % contained between 1 and the number of planes for each dimesnion.
7+ %
8+ % I = bfGetPlaneAtZCT(r, z, c, t, ...) does as above but passes extra
9+ % arguments to bfGetPlane for tiling, etc.
10+ %
11+ % Examples
12+ %
13+ % r = bfGetReader('example.tif');
14+ % I = bfGetPlaneAtZCT(r, 1, 1, 1) % First plane of the series
15+ % I = bfGetPlaneAtZCT(r,r.getSizeZ(),r.getSizeC(),r.getSizeT()) % Last plane of the series
16+ % I = bfGetPlaneAtZCT(r, 1, 1, 1, 1, 1, 1, 20, 20) % 20x20 tile originated at (0, 0)
17+ %
18+ % See also: BFGETREADER, BFGETPLANE, loci.formats.IFormatReader.getIndex
19+
20+ % OME Bio-Formats package for reading and converting biological file formats.
21+ %
22+ % Copyright (C) 2012 - 2017 Open Microscopy Environment:
23+ % - Board of Regents of the University of Wisconsin-Madison
24+ % - Glencoe Software, Inc.
25+ % - University of Dundee
26+ %
27+ % This program is free software: you can redistribute it and/or modify
28+ % it under the terms of the GNU General Public License as
29+ % published by the Free Software Foundation, either version 2 of the
30+ % License, or (at your option) any later version.
31+ %
32+ % This program is distributed in the hope that it will be useful,
33+ % but WITHOUT ANY WARRANTY; without even the implied warranty of
34+ % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35+ % GNU General Public License for more details.
36+ %
37+ % You should have received a copy of the GNU General Public License along
38+ % with this program; if not, write to the Free Software Foundation, Inc.,
39+ % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
40+
41+ % Input check
42+ ip = inputParser ;
43+ isValidReader = @(x ) isa(x , ' loci.formats.IFormatReader' ) && ...
44+ ~isempty(x .getCurrentFile());
45+ ip .addRequired(' r' , isValidReader );
46+ ip .parse(r );
47+
48+ ip = inputParser ;
49+ % No validation because we already checked
50+ % Kept for positional errors
51+ ip .addRequired(' r' );
52+
53+ % Check ZCT coordinates are within range
54+ ip .addOptional(' z' ,1 ,@(x ) bfTestInRange(x ,' z' ,r .getSizeZ()));
55+ ip .addOptional(' c' ,1 ,@(x ) bfTestInRange(x ,' c' ,r .getSizeC()));
56+ ip .addOptional(' t' ,1 ,@(x ) bfTestInRange(x ,' t' ,r .getSizeT()));
57+
58+ ip .parse(r , z , c , t );
59+
60+ javaIndex = r .getIndex(z - 1 , c - 1 , t - 1 );
61+ I = bfGetPlane(r , javaIndex + 1 );
62+
63+ end
0 commit comments