📄 avw_write.m
字号:
function avw_write(avw, fileprefix, IMGorient, machine)
% avw_write - write Analyze files (*.img & *.hdr)
%
% This function is a wrapper for
% avw_hdr_write and avw_img_write.
%
% avw_write(avw, fileprefix, [IMGorient], [machine])
%
% where the input avw is a struct (see avw_read):
%
% avw.hdr - a struct with image data parameters.
% avw.img - a 3D matrix of image data (double precision).
%
% fileprefix - a string, the filename without the .img
% extension. If empty, may use avw.fileprefix
%
% IMGorient - optional int; force writing of specified
% orientation, as follows:
%
% [], if empty, will use avw.hdr.hist.orient field
% 0, transverse/axial unflipped (default, radiological)
% 1, coronal unflipped
% 2, sagittal unflipped
% 3, transverse/axial flipped
% 4, coronal flipped
% 5, sagittal flipped
%
% This function will set avw.hdr.hist.orient and write the
% image data in a corresponding order. This function is in
% alpha development, it has not been exhaustively tested
% (as of 07/2003).
%
% See the comments and notes throughout avw_hdr_read and
% avw_img_read for more information and documentation on
% the Analyze orientation options. Orientations 3-5 are
% NOT recommended! They are part of the Analyze format,
% but only used in Analyze for faster raster graphics
% during movies. (Also see the copy of the Analyze 7.5
% format pdf in the mri_toolbox doc folder; although
% the code is largely self sufficient, that pdf is the
% authoritative description).
%
% machine - optional string; see machineformat in fread
% for details. The default here is 'ieee-le'.
%
% Tip: to change the data type, set avw.hdr.dime.datatype to:
%
% 1 Binary ( 1 bit per voxel)
% 2 Unsigned character ( 8 bits per voxel)
% 4 Signed short ( 16 bits per voxel)
% 8 Signed integer ( 32 bits per voxel)
% 16 Floating point ( 32 bits per voxel)
% 32 Complex, 2 floats ( 64 bits per voxel), not supported
% 64 Double precision ( 64 bits per voxel)
% 128 Red-Green-Blue (128 bits per voxel), not supported
%
% See also: avw_read, avw_hdr_write, avw_img_write
% avw_hdr_read, avw_img_read
% avw_view
%
% $Revision: 1.2 $ $Date: 2004/02/07 01:41:51 $
% Licence: GNU GPL, no express or implied warranties
% History: 05/2002, Darren.Weber@flinders.edu.au
% The Analyze 7.5 format is copyright
% (c) Copyright, 1986-1995
% Biomedical Imaging Resource, Mayo Foundation
% This code attempts to respect the integrity of
% the format, although no guarantee is given that
% it has been exhaustively tested for compatibility
% with Analyze software (it should be though).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------------------------------------------------------------------------
% Check inputs
if ~exist('avw','var'),
doc avw_write;
msg = sprintf('\n...no input avw.\n');
error(msg);
elseif isempty(avw),
msg = sprintf('\n...empty input avw.\n');
error(msg);
elseif ~isfield(avw,'img'),
msg = sprintf('\n...empty input avw.img\n');
error(msg);
end
if ~exist('fileprefix','var'),
if isfield(avw,'fileprefix'),
if ~isempty(avw.fileprefix),
fileprefix = avw.fileprefix;
else
doc avw_write;
fprintf('\nAVW_WRITE: No input fileprefix - see help AVW_write\n');
return;
end
else
doc avw_write;
fprintf('\nAVW_WRITE: No input fileprefix - see help avw_write\n');
return;
end
end
if ~exist('IMGorient','var'), IMGorient = ''; end
if ~exist('machine','var'), machine = 'ieee-le'; end
if findstr('.hdr',fileprefix),
% fprintf('AVW_WRITE: Removing .hdr extension from ''%s''\n',fileprefix);
fileprefix = strrep(fileprefix,'.hdr','');
end
if findstr('.img',fileprefix),
% fprintf('AVW_WRITE: Removing .img extension from ''%s''\n',fileprefix);
fileprefix = strrep(fileprefix,'.img','');
end
%------------------------------------------------------------------------
% MAIN
version = '[$Revision: 1.2 $]';
avw_img_write(avw,fileprefix,IMGorient,machine);
% MUST write header after the image, to ensure any
% orientation changes during image write are saved
% in the header. The header is saved by avw_img_write, so it's
% not necessary to call it here. If it were called here, it
% would be called as such:
% avw_hdr_write(avw,fileprefix,machine);
return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -