1 | function histograms(DATA,ROI,AddInfo) |
---|
2 | % HISTAGRAMS - Calculate histograms for image and ROIs (Aedes plugin) |
---|
3 | % |
---|
4 | % |
---|
5 | % Synopsis: |
---|
6 | % |
---|
7 | % Description: |
---|
8 | % |
---|
9 | % Examples: |
---|
10 | % |
---|
11 | % See also: |
---|
12 | % |
---|
13 | |
---|
14 | % This function is a part of Aedes - A graphical tool for analyzing |
---|
15 | % medical images |
---|
16 | % |
---|
17 | % Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi> |
---|
18 | % |
---|
19 | % Department of Physics, Department of Neurobiology |
---|
20 | % University of Kuopio, 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 | %% Check if the data to be analyzed is valid |
---|
32 | if AddInfo.isDataMixed |
---|
33 | errordlg('Sorry. This plugin does not work with mixed data.','Error',... |
---|
34 | 'modal'); |
---|
35 | return |
---|
36 | end |
---|
37 | |
---|
38 | % Default number of bins |
---|
39 | nBins = 20; |
---|
40 | |
---|
41 | %% Prompt for number of bins |
---|
42 | resp = aedes_inputdlg('Please, input the number of bins',... |
---|
43 | 'Number of bins',num2str(nBins)); |
---|
44 | if isempty(resp) |
---|
45 | % Canceled |
---|
46 | return |
---|
47 | end |
---|
48 | nBins = str2num(resp{1}); |
---|
49 | |
---|
50 | % Scale data using CLim values |
---|
51 | data = double(DATA{1}.FTDATA); |
---|
52 | data(data<AddInfo.Clim(1))=AddInfo.Clim(1); |
---|
53 | data(data>AddInfo.Clim(2))=AddInfo.Clim(2); |
---|
54 | |
---|
55 | %% Plot histogram of the whole data |
---|
56 | [n_data,x_data]=hist(data(:),nBins); |
---|
57 | fh=figure; |
---|
58 | ax=axes('parent',fh); |
---|
59 | bar(ax,x_data,n_data); |
---|
60 | title(ax,'Whole data (scaled to CLim)'); |
---|
61 | |
---|
62 | |
---|
63 | %% Plot histograms of ROIs |
---|
64 | if ~isempty(ROI) |
---|
65 | fh=figure; |
---|
66 | if length(ROI)<=3 |
---|
67 | nCols = length(ROI); |
---|
68 | nRows = 1; |
---|
69 | elseif length(ROI)<=9 |
---|
70 | nCols = 3; |
---|
71 | nRows = ceil(length(ROI)/nCols); |
---|
72 | elseif length(ROI)>9 |
---|
73 | nCols = 4; |
---|
74 | nRows = ceil(length(ROI)/nCols); |
---|
75 | end |
---|
76 | |
---|
77 | for ii=1:length(ROI) |
---|
78 | data = DATA{1}.FTDATA(ROI(ii).voxels{1}); |
---|
79 | [n_data,x_data]=hist(data,nBins); |
---|
80 | ax=subplot(nRows,nCols,ii,'align','parent',fh); |
---|
81 | %ax=axes('parent',fh); |
---|
82 | bar(ax,x_data,n_data); |
---|
83 | title(ax,['ROI ',num2str(ii),' (',ROI(ii).label,')']); |
---|
84 | end |
---|
85 | end |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | |
---|
92 | |
---|