/usr/share/octave/packages/image-2.4.1/analyze75read.m is in octave-image 2.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | ## Copyright (C) 2012-2013 Adam H Aitkenhead <adamhaitkenhead@gmail.com>
## Copyright (C) 2012 Carnë Draug <carandraug+dev@gmail.com>
##
## 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/>.
## -*- texinfo -*-
## @deftypefn {Function File} {@var{image} =} analyze75read (@var{filename})
## @deftypefnx {Function File} {@var{image} =} analyze75read (@var{header})
## Read image data of an Analyze 7.5 file.
##
## @var{filename} must be the path for an Analyze 7.5 file or the path for a
## directory with a single .hdr file can be specified. Alternatively, the file
## @var{header} can be specified as returned by @code{analyze75info}.
##
## @seealso{analyze75info, analyze75write}
## @end deftypefn
function data = analyze75read (filename)
if (nargin != 1)
print_usage;
elseif (isstruct (filename))
if (!isfield (filename, "Filename"))
error ("analyze75read: structure given does not have a `Filename' field.");
else
header = filename;
filename = filename.Filename;
endif
elseif (!ischar (filename))
error ("analyze75read: `filename' must be either a string or a structure.");
endif
fileprefix = analyze75filename (filename);
if (!exist ("header", "var"))
header = analyze75info ([fileprefix, ".hdr"]);
endif
## Finally start reading the actual file
[fidI, err] = fopen ([fileprefix, ".img"]);
if (fidI < 0)
error ("analyze75read: unable to fopen `%s': %s", [fileprefix, ".img"], err);
endif
if (strcmp (header.ImgDataType, "DT_SIGNED_SHORT"));
datatype = "int16";
elseif (strcmp (header.ImgDataType, "DT_SIGNED_INT"));
datatype = "int32";
elseif (strcmp (header.ImgDataType, "DT_FLOAT"));
datatype = "single";
elseif (strcmp (header.ImgDataType, "DT_DOUBLE"));
datatype = "double";
endif
data = zeros (header.Dimensions, datatype);
data(:) = fread (fidI, datatype, header.ByteOrder);
fclose (fidI);
## Rearrange the data
data = permute (data, [2,1,3]);
endfunction
|