|
Doxygen Source Code Documentation
writeSPMmat.m File Reference
Go to the source code of this file.
|
Functions |
| if (exist(matin)~=2) |
| fprintf (2,'Error%s:\nFile%s not found.\n', FuncName, matin) |
end get its prefix | if (strmatch('tam.', fliplr(matin))==1) |
| if (~isfield(S,'M')) |
| fprintf (2,'Error%s:\nFailed to find M in%s\n', FuncName, matin) |
end | if (size(S.M, 2)~=4) |
end | fprintf (2,'Error%s:\nM does not have 4 columns!\nM''s size is%g x%g',...FuncName, size(S.M, 1), size(S.M, 2)) |
end | if (size(S.M, 1)~=3 &size(S.M, 1)~=4) |
end | fprintf (2,'Error%s:\nM does not have 3 or 4 rows!\nM''s size is%g x%g',...FuncName, size(S.M, 1), size(S.M, 2)) |
end | if (size(S.M, 1)==4) |
end | if (S.M(4, 1)~=0|S.M(4, 2)~=0|S.M(4, 3)~=0|S.M(4, 4)~=1) |
| fprintf (2,'Warning%s:\nAFNI expects the 4th row of M to be[0 0 0 1].\n', FuncName) |
| fprintf (2,'This row is currently[%g%g%g%g] and will be ignored by AFNI.\n',...S.M(4, 1), S.M(4, 2), S.M(4, 3), S.M(4, 4)) |
| fprintf (2,'Proceed with caution.\n') |
end end write output file | if (nargin==1) |
end | if (exist(matout)==2) |
end | fprintf (2,'Error%s:\nOutput file%s exists already.\nWill not overwrite.\n',...FuncName, matout) |
| if (fid< 0) |
| fprintf (2,'Error%s:\nFailed in opening%s for writing.\nCheck permissions and disk space.\n',...FuncName, matout) |
end | fprintf (fid,'#Conversion of SPM''s%s\n', matin) |
| fprintf (fid,'#transformation matrix file to ascii format.\n#\n') |
| fprintf (fid,'#To convert SPM datasets to AFNI''s format, use\n') |
| fprintf (fid,'#3dWarp including these options:\n') |
| fprintf (fid,'#-matvec_in2out%s-matvec_fsl\n', matout) |
| fprintf (fid,'#See 3dWarp-help for more info.\n#\n') |
| for (i=1:1:4) |
| fprintf (fid,'\t%f\t%f\t%f\t%f\n',...S.M(i, 1), S.M(i, 2), S.M(i, 3), S.M(i, 4)) |
end | fclose (fid) |
Variables |
| function [err] |
Purpose | __pad9__ |
Purpose the _ASCII extension
is added to matin Output | Parameters |
Purpose the _ASCII extension
is added to matin Output Bethesda
Maryland Define the function
name for easy referencing | FuncName = 'writeSPMmat' |
Debug Flag | DBG = 1 |
initailize return variables | err = 1 |
does the input file exist | matin = deblank(matin) |
| return |
end get its prefix | prefixin = matin(1:length(matin)-4) |
end load it | S = load (matin) |
end | beep |
end end write output file | matout = [prefixin, '_ASCII.mat'] |
end | fid = fopen(matout,'w') |
Function Documentation
fprintf |
( |
fid |
, |
|
|
'\t%f\t%f\t%f\t%f\n' |
, |
|
|
...S. |
M(i, 1), |
|
|
S. |
M(i, 2), |
|
|
S. |
M(i, 3), |
|
|
S. |
M(i, 4) |
|
) |
|
|
fprintf |
( |
fid |
, |
|
|
'#See 3dWarp-help for more info.\n#\n' |
|
|
) |
|
|
fprintf |
( |
fid |
, |
|
|
'#-matvec_in2out%s-matvec_fsl\n' |
, |
|
|
matout |
|
|
) |
|
|
fprintf |
( |
fid |
, |
|
|
'#3dWarp including these options:\n' |
|
|
) |
|
|
fprintf |
( |
fid |
, |
|
|
'#To convert SPM datasets to AFNI''s |
format, |
|
|
use\n' |
|
|
) |
|
|
fprintf |
( |
fid |
, |
|
|
'#transformation matrix file to ascii format.\n#\n' |
|
|
) |
|
|
fprintf |
( |
2 |
, |
|
|
'Error%s:\nFailed in opening%s for writing.\nCheck permissions and disk space.\n' |
, |
|
|
|
FuncName, |
|
|
matout |
|
|
) |
|
|
end fprintf |
( |
2 |
, |
|
|
'Error%s:\nOutput file%s exists already.\nWill not overwrite.\n' |
, |
|
|
|
FuncName, |
|
|
matout |
|
|
) |
|
|
fprintf |
( |
2 |
, |
|
|
'Proceed with caution.\n' |
|
|
) |
|
|
fprintf |
( |
2 |
, |
|
|
'This row is currently and will be ignored by AFNI.\n' |
[%g%g%g%g], |
|
|
...S. |
M(4, 1), |
|
|
S. |
M(4, 2), |
|
|
S. |
M(4, 3), |
|
|
S. |
M(4, 4) |
|
) |
|
|
end fprintf |
( |
2 |
, |
|
|
'Error%s:\nM does not have 3 or 4 rows!\nM''s size is%g x%g' |
, |
|
|
|
FuncName, |
|
|
size(S.M, 1) |
, |
|
|
size(S.M, 2) |
|
|
) |
|
|
end fprintf |
( |
2 |
, |
|
|
'Error%s:\nM does not have 4 columns!\nM''s size is%g x%g' |
, |
|
|
|
FuncName, |
|
|
size(S.M, 1) |
, |
|
|
size(S.M, 2) |
|
|
) |
|
|
end if |
( |
S.M(4, 1)~ |
= 0 | S.M(4,2) ~= 0 | S.M(4,3) ~= 0 | S.M(4,4) ~= 1 |
) |
|
|
end if |
( |
size(S.M, 1) |
= = 4 |
) |
|
|
end if |
( |
size(S.M, 1)~ |
= 3 & size(S.M,1) ~= 4 |
) |
|
|
end if |
( |
size(S.M, 2)~ |
= 4 |
) |
|
|
Variable Documentation
|
Initial value: writeSPMmat (matin, matout)
%
% [err] = writeSPMmat (matin, [matout])
Definition at line 1 of file writeSPMmat.m. |
|