source: misclib/makelcmraw.m @ 36

Last change on this file since 36 was 36, checked in by tjniskan, 11 years ago
  • Added option to an2_readfid, an2_data_read and an2_readfidprefs

which allows controlling the output precision. Default is 'double'
(which is more precise), but if you have a very long data changing
this to 'single' will half the memory requirements.

  • Rewrote an2_inputdlg so that it does not depend on Matlab license.
  • Deleted many depricated files.
  • Moved addicon.m under misclib.
  • Added Analyze2 under GNU General Public License (version 2).
  • Added GPL license in license.txt file and added license

notifications in m-files.

M an2_export_gui.m
M analyze2.m
M an2_cellsprintf.m
M an2_getfilefilter.m
M an2_calc_wait.m
D an2_getnicedialoglocation.m
D misclib/uiclear.m
M misclib/spectrsum.m
M misclib/shiftind.m
M misclib/dcm_info.m
D misclib/b1_map.m
A misclib/addicon.m
M misclib/makelcmraw.m
M an2_check_file_exist.m
M an2_iseven.m
M an2_cellwrite.m
M an2_wbar.m
M an2_rot3d.m
M an2_readfdf.m
M an2_revision.m
M an2_viewprocpar.m
M an2_checkcthdr.m
D an2_questerrordlg.m
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
A license.txt
M an2_resviewer.m
M an2_maptool.m
M an2_res2table.m
M an2_helpabout.m
M an2_copy_roi.m
M plugins/save_roi_as_mask.m
M plugins/write_difference_images.m
M plugins/plot_profile.m
M plugins/calculate_t2_map.m
M plugins/calculate_t1r_map.m
M plugins/view_kspace.m
M plugins/copy_data_to_workspace.m
M plugins/take_snapshot.m
M an2_inputdlg.m
M an2_roi_copy_gui.m
M an2_readctdata.m
D an2_setdefaultbutton.m
M an2_readfid.m
M an2_readfidprefs.m
D addicon.m
M an2_readtab.m
D an2_imaread.m
M an2_check_updates.m
M an2_killfigs.m
M an2_roi_stats.m
M an2_saveres.m
M an2_rotateflip.m
M an2_juigetfiles.m
M an2_gui_defaults.m
M an2_editstack.m
M an2_errordump.m
M an2_update.m
M an2_write_nifti.m

File size: 2.6 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% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
15%
16% Department of Physics, (or Department of Neurobiology)
17% University of Kuopio,
18% P.O. Box 1627,
19% FIN-70211, Kuopio
20% FINLAND
21%
22% This program may be used under the terms of the GNU General Public
23% License version 2.0 as published by the Free Software Foundation
24% and appearing in the file LICENSE.TXT included in the packaging of
25% this program.
26%
27% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
30
31%% Default RAW file name and path
32FilePath = [pwd,filesep];
33FileName = 'out.RAW';
34
35%% Parse input arguments
36if nargin==0
37  %% Ask for a file
38  [DATA,msg] = an2_readfid('','return',3);
39  if isempty(DATA)
40    error(msg)
41    return
42  end
43elseif nargin==2
44  FilePath = outdir;
45  if ~(FilePath(end)==filesep)
46    FilePath = [FilePath,filesep];
47  end
48elseif nargin==3
49  FilePath = outdir;
50  if ~(FilePath(end)==filesep)
51    FilePath = [FilePath,filesep];
52  end
53  FileName = outname;
54  [fp,fn,fe]=fileparts(FileName);
55  FileName = [fn,'.RAW'];
56end
57
58%% Get default RAW file name
59if any(nargin==[0 1 2])
60  try
61    fpath=DATA.HDR.fpath;
62    ind = find(fpath==filesep);
63    if ind(end)==length(fpath)
64      tmp=fpath(ind(end-1)+1:end-1);
65    else
66      tmp=fpath(ind(end)+1:end);
67    end
68    FileName = [tmp(1:end-4),'.RAW'];
69  catch
70    % Failed, issue a warning and use out.RAW instead
71    warning('Could not determine filename. Using "out.RAW"')
72    FilePath = [pwd,filesep];
73    FileName = 'out.RAW';
74  end
75end
76
77
78%% Open file for writing
79fid = fopen([FilePath,FileName],'w');
80if fid<0
81  error('Could not open file "%s" for writing',FileName)
82end
83
84%% Write SEQPAR
85fprintf(fid,' $SEQPAR\n');
86fprintf(fid,' hzpppm=%3.3f\n',DATA.PROCPAR.sfrq);
87fprintf(fid,' echot=%4.1f\n',DATA.PROCPAR.te*1000);
88fprintf(fid,' seq=''%s''\n','STEAM');
89fprintf(fid,' $END\n');
90
91%% Write NMID
92fprintf(fid,' $NMID\n');
93fprintf(fid,' id=''%s''\n',FileName(1:min(length(FileName),20)));
94fprintf(fid,' fmtdat=''(2e14.5)''\n');
95fprintf(fid,' tramp=1.\n');
96fprintf(fid,' volume=1.\n');
97fprintf(fid,' $END\n');
98
99%% Write data
100real_data = real(DATA.KSPACE);
101real_data = real_data(:);
102imag_data = imag(DATA.KSPACE);
103imag_data = imag_data(:);
104tmp=strrep(strrep(strrep(sprintf('   %1.5e   %1.5e\n',[real_data ...
105                    imag_data]'),'e+0','e+'),'e-0','e-'),' -','-');
106%fprintf(fid,'  %1.5e  %1.5e\n',[real_data imag_data]');
107fprintf(fid,'%s',tmp);
108
109
110%% Close file
111fclose(fid);
Note: See TracBrowser for help on using the repository browser.

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