source: plugins/histograms.m @ 135

Last change on this file since 135 was 88, checked in by tjniskan, 10 years ago
  • Added a small plugin for displaying data and ROI histograms.

A plugins/histograms.m
M aedes_revision.m

File size: 2.0 KB
Line 
1function 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
32if AddInfo.isDataMixed
33  errordlg('Sorry. This plugin does not work with mixed data.','Error',...
34    'modal');
35  return
36end
37
38% Default number of bins
39nBins = 20;
40
41%% Prompt for number of bins
42resp = aedes_inputdlg('Please, input the number of bins',...
43  'Number of bins',num2str(nBins));
44if isempty(resp)
45  % Canceled
46  return
47end
48nBins = str2num(resp{1});
49
50% Scale data using CLim values
51data = DATA{1}.FTDATA;
52data(data<AddInfo.Clim(1))=AddInfo.Clim(1);
53data(data>AddInfo.Clim(2))=AddInfo.Clim(2);
54
55%% Plot histogram of the whole data
56[n_data,x_data]=hist(data(:),nBins);
57fh=figure;
58ax=axes('parent',fh);
59bar(ax,x_data,n_data);
60title(ax,'Whole data (scaled to CLim)');
61
62
63%% Plot histograms of ROIs
64if ~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
85end
86
87
88
89
90
91
92
Note: See TracBrowser for help on using the repository browser.

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