source: an2_cellwrite.m @ 37

Last change on this file since 37 was 37, checked in by tjniskan, 11 years ago
  • Renamed analyze2.m to aedes.m
  • Changed all references to "Analyze2" -> "Aedes" (hopefully I didn't

break anything...)

  • Added some nifti-tools to misclib
  • Fixed bug in an2_readfid.m that occurred when reading EPI-data

(thanks Teemu)

M an2_export_gui.m
D analyze2.m
M an2_getfilefilter.m
M an2_calc_wait.m
A misclib/nifti4dto3d.m
A misclib/nifti3dto4d.m
A misclib/filter_fmri_data.m
M misclib/dcm_info.m
M an2_cellwrite.m
M an2_revision.m
M startup.m
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
D about_analyze2.png
M an2_resviewer.m
M an2_maptool.m
A aedes.m
M an2_helpabout.m
M plugins/save_roi_as_mask.m
M plugins/calculate_t2_map.m
M an2_inputdlg.m
M an2_readctdata.m
M an2_readfid.m
M an2_readfidprefs.m
M an2_readtab.m
M an2_check_updates.m
A about_aedes.png
M an2_saveres.m
M an2_editstack.m
M an2_errordump.m
M an2_update.m
M an2_write_nifti.m

File size: 1.9 KB
Line 
1function [done,msg] = an2_cellwrite(incell,filename,varargin)
2% AN2_CELLWRITE - Write cell array to a text file
3%   
4%
5% Synopsis:
6%        [done,msg] = an2_cellwrite(incell,filename,varargin)
7%
8% Description:
9%
10% Examples:
11%
12% See also:
13%        AEDES
14
15% This function is a part of Analyze 2.0 - A graphical tool for analyzing
16% medical images
17%
18% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
19%
20% Department of Physics, (or Department of Neurobiology)
21% University of Kuopio,
22% P.O. Box 1627,
23% FIN-70211, Kuopio
24% FINLAND
25%
26% This program may be used under the terms of the GNU General Public
27% License version 2.0 as published by the Free Software Foundation
28% and appearing in the file LICENSE.TXT included in the packaging of
29% this program.
30%
31% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
32% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
33
34
35
36% Defaults
37done = false;
38delim = ';';
39
40% Check input arguments
41if nargin<2
42  error('Too few input arguments')
43elseif ~iscell(incell)
44  error('First input argument must be a cell array')
45elseif ~ischar(filename)
46  error('Filename must be of class char')
47end
48
49% Parse Input arguments
50for ii=1:2:length(varargin)
51  switch varargin{ii}
52   case 'delimitter'
53    if strcmpi(varargin{ii+1},'tab')
54      delim = '\t';
55    elseif strcmpi(varargin{ii+1},'space')
56      delim = ' ';
57    else
58      delim=varargin{ii+1};
59    end
60   otherwise
61    msg = sprintf('Unknown parameter "%s"!',varargin{ii});
62    return
63  end
64end
65
66% Open file for writing
67fid = fopen(filename,'w');
68if fid<0
69  msg = sprintf('Could not open file "%s" for writing',filename);
70  return
71end
72
73nRows = size(incell,1);
74nCols = size(incell,2);
75
76% Write cell to file
77for ii=1:nRows
78  for kk=1:nCols
79    fprintf(fid,['%s',delim],incell{ii,kk});
80  end
81  fprintf(fid,'\r\n');
82end
83
84% Close file
85fclose(fid);
86
87% All went well...
88done=true;
89msg='';
90
91% - EOF -
Note: See TracBrowser for help on using the repository browser.

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