| T O P I C R E V I E W |
| mbudde |
Posted - Apr 14 2003 : 2:44:41 PM Please excuse my ignorance here, but are there any tools or packages that can be used to read the Biac XML headers? Or is this something that's being developed. The other topics seem to address this, but it's not quite clear to me.
It would be especially helpful if there was something that would read the Biac header and produce SPM header files automatically.
best, matt
|
| 2 L A T E S T R E P L I E S (Newest First) |
| josh.bizzell |
Posted - Apr 16 2003 : 3:17:32 PM Matt, I've written a matlab function, biac_hread, which mimics spm_hread that you could use temporarily for this purpose. This function uses writemrtest that Syam mentioned above, so you'll have to set up your environment variable as he described. Once you have this function, you could then use spm_hwrite to (hopefully) get an SPM header. NOTE: This code was written very quickly and hasn't been tested thoroughly, so beware. Example (in Matlab): >> [dim,vox,scale,type,offset,origin,descrip] = biac_hread('E:\study\series002\series002_00.bxh'); >> s = spm_hwrite('E:\study\series002\series002.hdr',dim,vox,scale,type,offset,origin,descrip);
Here's the code for biac_hread (you'll have to copy and paste it to an m-file):
function [DIM,VOX,SCALE,TYPE,OFFSET,ORIGIN,DESCRIP] = biac_hread(P)
% reads a header
% FORMAT [DIM VOX SCALE TYPE OFFSET ORIGIN DESCRIP] = biac_hread(P);
%
% P - filename (e.g spm or spm.img)
% DIM - image size [i j k [l]] (voxels)
% VOX - voxel size [x y z [t]] (mm [secs])
% SCALE - scale factor
% TYPE - datatype (integer - see spm_type)
% OFFSET - offset (bytes)
% ORIGIN - origin [i j k]
% DESCRIP - description string
%___________________________________________________________________________
%
% spm_hread reads variables into working memory from a SPM/ANALYZE
% compatible header file. If the header does not exist global defaults
% are used. The 'originator' field of the ANALYZE format has been
% changed to ORIGIN in the SPM version of the header. funused1 of the
% ANALYZE format is used for SCALE
%
% see also dbh.h (ANALYZE) spm_hwrite.m and spm_type.m
%
%__________________________________________________________________________
% Edited by Josh Bizzell, 2003-April-04, for the BIAC
% @(#)spm_hread.m 2.7 99/10/29
P = deblank(P);
P2 = [P(1:end-3),'hdr'];
if (strncmp(P(end-2:end),'img',3) & exist(P2,'file')) | ...
strncmp(P(end-2:end),'hdr',3)
[DIM,VOX,SCALE,TYPE,OFFSET,ORIGIN,DESCRIP] = spm_hread(P);
else
V = readmrtest(P,'=>INFOONLY');
readmrtest(V,'=>CLEANUP');
if ~isempty(V)
DIM = [getfield(V.info.dimensions,{1},'size'),...
getfield(V.info.dimensions,{2},'size'),...
getfield(V.info.dimensions,{3},'size')];
VOX = [getfield(V.info.dimensions,{1},'spacing'),...
getfield(V.info.dimensions,{2},'spacing'),...
getfield(V.info.dimensions,{3},'spacing')];
SCALE = 1;
TYPE = spm_type(getfield(V.info,'elemtype'));
OFFSET = 0;
% Maybe set to actual origin
ORIGIN = [0 0 0];
DESCRIP = ['BIAC - ',P];
else
error(sprintf('Error reading %s.',P));
global DIM VOX SCALE TYPE OFFSET ORIGIN
DESCRIP = ['defaults'];
end
end
|
| syam.gadde |
Posted - Apr 14 2003 : 3:19:33 PM New versions of readmr and writemr that are capable of reading and writing the BXH header are currently in a testing phase and exist as "readmrtest" and "writemrtest" in \\gall\programs\User_Scripts\alpha They support the same readmr and writemr command-line calling conventions, but allow for additional functionality if you use the new-style parameters. The test routines only have a limited GUI and lack the spiffy GUI that readmr sports.
Using the XML routines will require that you add the following path \\gall\programs\matlab\biac\lib to your personal "path" environment variable to bring in the extra XML libraries you need. To do this go to Control Panel -> System -> Advanced and that will give you the Environment Variables button.
Producing SPM headers would be a goal of the image conversion program mentioned in an earlier topic, but another, more ideal approach that we are pursuing is to add support for the XML header into programs (perhaps SPM) for which we have source code access. Tasks on our plate include prioritizing this wish-list and moving forward with it.
[Edited to replace broca=>gall] |
|
|