Skip to content
Snippets Groups Projects
Commit cc5c78c6 authored by Yoann Guilhem's avatar Yoann Guilhem Committed by Nicola Vigano
Browse files

Update help headers in EDF IO tools

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@830 4c865b51-4357-4376-afb4-474e03ccb993
parent 41123393
No related branches found
No related tags found
No related merge requests found
function edf=edf_is(filename)
function edf = edf_is(filename)
% EDF_IS Check if a file contains a EDF header.
% -------------------------------------------------------------------------
% edf = edf_is(filename)
%
% INPUTS:
% filename = <string> Name of the file to check%
%
% OUTPUT:
% edf = <bool> Result of the check
fid=fopen(filename,'rt');
fgetl(fid); % first line
header=strfind(fgetl(fid),'HeaderID');
fclose(fid);
if header
edf=true;
edf=true;
else
edf=false;
edf=false;
end
end % end of function
function [img, varargout] = edf_read(filename, GT_bb, dispmes, info)
% EDF_READ.M Reads images and 3D volumes from .edf files
% Usage:
% data = edf_read(filename[, GT_bb]);
% [data, info] = edf_read(filename[, GT_bb]);
%
% if GT_bb is supplied (optional) - only reads the region from [originx
% originy width height] inclusive (only works for 2D EDF files)
%
% if a second output variable is given, returns the edf header info
%
% Greg Johnson
% June 2006
%
% Modified by Nicola Vigano, 2011-2012, nicola.vigano@esrf.fr
% EDF_READ Reads images and 3D volumes from .edf files.
% --------------------------------------------------------------------------
% [img[, info]] = edf_read(filename[, GT_bb, dispmes, info]);
%
% INPUT:
% filename = <string> Input edf filename
%
% OPTIONAL INPUT:
% GT_bb = <int> Region of interest [originx originy width height]
% (works only with 2D files)
% dispmes = <string> Verbose mode {'disp', 'nodisp'}
% info = <struct> EDF header info (as input)
%
% OUTPUT:
% img = <double> Output image (2D or 3D)
%
% OPTIONAL OUTPUT:
% info = <struct> EDF header info (as output)
%
% Version 002 XX-06-2006 by NVigano, nicola.vigano@esrf.fr
% Many changes, many versions
% Modified by Nicola Vigano, 2011-2012, nicola.vigano@esrf.fr
%
% Version 001 XX-06-2006 by GJohnson
if (~exist('dispmes', 'var'))
dispmes = true;
......@@ -176,4 +186,4 @@ function [img, varargout] = edf_read(filename, GT_bb, dispmes, info)
headerLength = ftell(fidFind);
fclose(fidFind);
end
end %end of function
end % end of function
function edf_write(data, filename, info, minimal)
% EDF_WRITE.M An EDF writer than handles images and 3D volumes
% Usage:
% edf_write(im, filename)
% the datatype of the EDF file will be the same as the Matlab variable
% (usually double - 64 bits)
% edf_write(vol, filename, header)
% possible to pass any information in the header of the file, and force any data type.
% i.e. header.datatype = 'uint16' will write data in 16bit integers
% header structure format is the one retrieved by edf_info.m
% EDF_WRITE An EDF writer than handles images and 3D volumes
% --------------------------------------------------------------------------
% edf_write(data, filename, info, minimal)
%
% WARNING! THESE IMAGES DO NOT NEED TRANSPOSING BEFORE WRITING!
% Greg Johnson
% June 2006
% WARNING! THESE IMAGES DO NOT NEED TRANSPOSING BEFORE WRITING!
%
% note - if using edf header fields to store information - be aware that
% capital letters get converted to lowercase. Safer to use
% non-capitialised field names
% andy - 9/12/2008
% INPUT:
% data = <anytype> Image data to write in the EDF file. The datatype
% of the EDF file will be the same as the Matlab
% variable (usually double - 64 bits).
% filename = <string> Output EDF filename
%
% OPTIONAL INPUT:
% info = <struct> Any information to put in the file header and
% force any data type. See edf_info.m
% e.g header.datatype = 'uint16' for 16bit integers
% minimal = <any> To speedup the writing process
%
% Modified by Nicola Vigano, 2011-2012, nicola.vigano@esrf.fr
% Imported and modified. Added 'minimal' parameter to speedup the write.
% NOTE:
% If using edf header fields to store information, be aware that
% capital letters get converted to lowercase. Safer to use
% non-capitialised field names
% Andy King - 9/12/2008
%
% Version 002 2011-2012 by NVigano, nicola.vigano@esrf.fr
% Added 'minimal' parameter to speedup the write.
% Imported and modified.
%
% Version 001 XX-06-2012 by GJohnson
if (exist('info', 'var'))
if isstruct(info)
......@@ -74,7 +82,7 @@ function edf_write(data, filename, info, minimal)
fwrite(fid, permute(data, [2 1 3]), edfinfo.datatype);
fclose(fid);
end
end % end of function
function header = sfGenerateHeader(edfinfo, minimal)
info = edfinfo;
......@@ -158,8 +166,7 @@ end
function str_header = edf_headerstring(what, value)
% function str=headerstring(what,value,kind)
% used by writeheader
% function str_header = edf_headerstring(what, value)
% returns a string for incorporation in an edf-header
% what is the information item (e.g. 'Dim_1')
% value of the item
......@@ -181,8 +188,7 @@ function str_header = edf_headerstring(what, value)
end
function str_header = edf_headerstring_cell(data)
% function str=headerstring(what,value,kind)
% used by writeheader
% function str_header = edf_headerstring_cell(data)
% returns a string for incorporation in an edf-header
% what is the information item (e.g. 'Dim_1')
% value of the item
......
function correct = gtVerifyEDFHeader(directory, verbose)
if (~exist('verbose', 'var'))
% GTVERIFYEDFHEADER Checks the validiy of the header of multiple EDF files.
% -------------------------------------------------------------------------
% correct = gtVerifyEDFHeader(directory, verbose)
%
% INPUT:
% directory = <string> Directory where the EDF files are located
% verbose = <bool> Verbose mode
%
% OUTPUT:
% correct = <bool> True if all headers are correct
if (~exist('verbose', 'var'))
verbose = true;
end
out = GtConditionalOutput(verbose);
......@@ -18,3 +29,5 @@ function correct = gtVerifyEDFHeader(directory, verbose)
out.fprintf('(%04d) Done.\n', length(files))
end
end % end of function
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment