source: misclib/dcm_info.m @ 94

Last change on this file since 94 was 45, checked in by tjniskan, 11 years ago
  • Changed a small thing in license notices

M an2_export_gui.m
M an2_cellsprintf.m
M an2_getfilefilter.m
M an2_calc_wait.m
M an2_smiswrite.m
M misclib/spectrsum.m
M misclib/shiftind.m
M misclib/nifti4dto3d.m
M misclib/nifti3dto4d.m
M misclib/dcm_info.m
M 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
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
M an2_smisread.m
M an2_resviewer.m
M an2_maptool.m
M aedes.m
M an2_helpabout.m
M an2_res2table.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
M an2_readfid.m
M an2_readfidprefs.m
M an2_readtab.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: 3.3 KB
Line 
1function dcm_info(pathname,add_params)
2% Print some information from DICOM files...
3
4% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
5%
6% Department of Physics, Department of Neurobiology
7% University of Kuopio, FINLAND
8%
9% This program may be used under the terms of the GNU General Public
10% License version 2.0 as published by the Free Software Foundation
11% and appearing in the file LICENSE.TXT included in the packaging of
12% this program.
13%
14% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
15% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16
17% Default parameters
18Param = {'SeriesDescription',...
19  'AcqTime'};
20Param_length = [25 8];
21
22if nargin==0 || isempty(pathname)
23  try
24        tmp_dir=getpref('Analyze2','GetDcmDir');
25  catch
26        tmp_dir = '';
27  end
28  pathname=uigetdir(tmp_dir);
29  if isequal(pathname,0)
30        % Canceled
31        return
32  end
33  setpref('Analyze2','GetDcmDir',pathname)
34elseif nargin>2
35  error('Too many input argumetns')
36end
37
38% Make sure that pathname is a cell array
39if ischar(pathname)
40  pathname = {pathname};
41end
42
43if nargin==2
44  Param = {Param{:} add_params{:}};
45  Param_length = [Param_length ones(1,length(add_params))*15];
46end
47total_width = 7+sum(Param_length)+2*length(Param_length)+6;
48
49% DCM file to read (the first one)
50fname = 'i0000_0000b.dcm';
51
52for ii=1:length(pathname)
53  % Get the im_(number) folders
54  s=dir(pathname{ii});
55  fpath = {s([s(:).isdir]).name};
56 
57  % Find the im_(number folders)
58  tmp=regexp(fpath,'^im_\d{1,2}$');
59  ind=~cellfun(@isempty,tmp);
60  if any(ind)
61        fp={fpath{find(ind)}};
62       
63        %fprintf(1,'***************************************************\n')
64        fprintf(1,'%s\n',repmat('*',1,total_width))
65        fprintf(1,'%s\n\n',pathname{ii})
66        fprintf(1,'%7s',' ')
67        fprintf(1,'%s  ',l_trunkStr(Param{1},Param_length(1)))
68        fprintf(1,'%s  ',l_trunkStr(Param{2},Param_length(2)))
69       
70       
71        for tt=3:length(Param)
72          fprintf(1,'%s  ',l_trunkStr(Param{tt},Param_length(tt)));
73        end
74        fprintf(1,'%s\n',l_trunkStr('nFiles',6))
75        fprintf(1,'%s\n',repmat('-',1,total_width))
76       
77        for kk=1:length(fp)
78          % Get the number of files in the current folder
79          s=dir(fullfile(pathname{ii},fp{kk}));
80          fn={s(~[s(:).isdir]).name};
81          nFiles = length(find(~cellfun(@isempty,regexp(fn,'^i\d{4}_\d{4}b.dcm$'))));
82         
83          % Read the dicom headers
84          try
85                hdr=dicominfo(fullfile(pathname{ii},fp{kk},fname));
86          catch
87                fprintf(1,'Could not read: %s\n',fullfile(pathname{ii},fp{kk},fname))
88                continue
89          end
90          fprintf(1,'%5s: ',fp{kk});
91          fprintf(1,'%s  ',l_trunkStr(hdr.SeriesDescription,25));
92          fprintf(1,'%s:%s:%s  ',hdr.AcquisitionTime(1:2),...
93                hdr.AcquisitionTime(3:4),...
94                hdr.AcquisitionTime(5:6));
95         
96          for tt=3:length(Param)
97                if not(isfield(hdr,Param{tt}))
98                  str = 'N/A';
99                else
100                  if isnumeric(hdr.(Param{tt}))
101                        str = num2str(hdr.(Param{tt})(:).');
102                  else
103                        str = num2str(hdr.(Param{tt}));
104                  end
105                end
106                fprintf('%s  ',l_trunkStr(str,Param_length(tt)))
107          end
108          fprintf('(%d)\n',nFiles)
109        end
110        fprintf(1,'%s\n\n\n',repmat('*',1,total_width))
111  else
112        % Print warning and continue to next iteration
113        fprintf(1,'\nWarning: Cannot find im_# folders from\n');
114        fprintf(1,'%s\n',pathname{ii});
115        fprintf(1,'Skipping folder...\n\n\n')
116        continue
117  end
118 
119end
120
121function str_out=l_trunkStr(str,len)
122
123str_out = fliplr(sprintf(['%',num2str(len),'s'],fliplr(str(1:min(end,len)))));
124
Note: See TracBrowser for help on using the repository browser.

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