source: misclib/makelcmraw.m @ 17

Last change on this file since 17 was 17, checked in by tjniskan, 12 years ago
  • Rewrote the handling of plugins. The plugins now work without the

an2_plugins.m. Simply copy a plugin M-file into the plugins-directory
of analyze2 and they should work.

  • Rewrote the handling of 4D-arrays.
  • Restructured the analyze2 directory. Some misc functions that are

not used by analyze2 were moved into "misclib" directory.

D uiclear.m
D spectrsum.m
M analyze2.m
A misclib
A misclib/uiclear.m
A misclib/spectrsum.m
A misclib/shiftind.m
A misclib/linebroad.m
A misclib/b1_map.m
A misclib/makelcmraw.m
D b1_map.m
M an2_helpabout.m
A plugins
A plugins/calc_t1r_map.m
A plugins/show_kspace.m
A plugins/diffimage.m
A plugins/copydataroi_plugin.m
A plugins/mean_std_between_thold.m
A plugins/snapshot_plugin.m
A plugins/profile_plugin.m
A plugins/voxels_between_thold.m
D linebroad.m
D shiftind.m
D private
D an2_plugins.m
D makelcmraw.m

File size: 2.2 KB
Line 
1function ok = makelcmraw(DATA,outdir,outname)
2% MAKELCMRAW - Write data in LCModel RAW file format
3%   
4%
5% Synopsis:
6%
7% Description:
8%
9% Examples:
10%
11% See also:
12%
13
14% Juha-Pekka Niskanen - <Juha-Pekka.Niskanen@uku.fi>  -  10.04.2006
15% Department of Biomedical NMR, University of Kuopio
16%
17% Last modified - 27.06.2007 - (J-P N)
18
19%% Default RAW file name and path
20FilePath = [pwd,filesep];
21FileName = 'out.RAW';
22
23%% Parse input arguments
24if nargin==0
25  %% Ask for a file
26  [DATA,msg] = an2_readfid('','return',3);
27  if isempty(DATA)
28    error(msg)
29    return
30  end
31elseif nargin==2
32  FilePath = outdir;
33  if ~(FilePath(end)==filesep)
34    FilePath = [FilePath,filesep];
35  end
36elseif nargin==3
37  FilePath = outdir;
38  if ~(FilePath(end)==filesep)
39    FilePath = [FilePath,filesep];
40  end
41  FileName = outname;
42  [fp,fn,fe]=fileparts(FileName);
43  FileName = [fn,'.RAW'];
44end
45
46%% Get default RAW file name
47if any(nargin==[0 1 2])
48  try
49    fpath=DATA.HDR.fpath;
50    ind = find(fpath==filesep);
51    if ind(end)==length(fpath)
52      tmp=fpath(ind(end-1)+1:end-1);
53    else
54      tmp=fpath(ind(end)+1:end);
55    end
56    FileName = [tmp(1:end-4),'.RAW'];
57  catch
58    % Failed, issue a warning and use out.RAW instead
59    warning('Could not determine filename. Using "out.RAW"')
60    FilePath = [pwd,filesep];
61    FileName = 'out.RAW';
62  end
63end
64
65
66%% Open file for writing
67fid = fopen([FilePath,FileName],'w');
68if fid<0
69  error('Could not open file "%s" for writing',FileName)
70end
71
72%% Write SEQPAR
73fprintf(fid,' $SEQPAR\n');
74fprintf(fid,' hzpppm=%3.3f\n',DATA.PROCPAR.sfrq);
75fprintf(fid,' echot=%4.1f\n',DATA.PROCPAR.te*1000);
76fprintf(fid,' seq=''%s''\n','STEAM');
77fprintf(fid,' $END\n');
78
79%% Write NMID
80fprintf(fid,' $NMID\n');
81fprintf(fid,' id=''%s''\n',FileName(1:min(length(FileName),20)));
82fprintf(fid,' fmtdat=''(2e14.5)''\n');
83fprintf(fid,' tramp=1.\n');
84fprintf(fid,' volume=1.\n');
85fprintf(fid,' $END\n');
86
87%% Write data
88real_data = real(DATA.KSPACE);
89real_data = real_data(:);
90imag_data = imag(DATA.KSPACE);
91imag_data = imag_data(:);
92tmp=strrep(strrep(strrep(sprintf('   %1.5e   %1.5e\n',[real_data ...
93                    imag_data]'),'e+0','e+'),'e-0','e-'),' -','-');
94%fprintf(fid,'  %1.5e  %1.5e\n',[real_data imag_data]');
95fprintf(fid,'%s',tmp);
96
97
98%% Close file
99fclose(fid);
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008