|
29 | 29 | % :param dataLabel: strings to use to label the data rows or columns. |
30 | 30 | % :type dataLabel: cellstr |
31 | 31 | % |
| 32 | + % :param maxVox: max of scale for nb of voxels. Default to []. |
| 33 | + % :type maxVox: positive integer |
| 34 | + % |
| 35 | + % :param nbBins: use the same number of bins for all graphs. |
| 36 | + % By default based on the number of unique values across all |
| 37 | + % the datasets. |
| 38 | + % :type nbBins: positive integer |
| 39 | + % |
32 | 40 | % |
33 | 41 | % EXAMPLE:: |
34 | 42 | % |
|
58 | 66 | args.addParameter('scaleFactor', 1, @isnumeric); |
59 | 67 | args.addParameter('roiAs', 'rows', rowOrCol); |
60 | 68 | args.addParameter('dataLabel', {}, @iscellstr); |
| 69 | + args.addParameter('maxVox', [], @isnumeric); |
| 70 | + args.addParameter('nbBins', [], @isnumeric); |
61 | 71 |
|
62 | 72 | args.parse(varargin{:}); |
63 | 73 |
|
|
66 | 76 | scaleFactor = args.Results.scaleFactor; |
67 | 77 | roiAs = args.Results.roiAs; |
68 | 78 | dataLabel = args.Results.dataLabel; |
| 79 | + nbBins = args.Results.nbBins; |
69 | 80 |
|
70 | 81 | if ischar(dataImages) |
71 | 82 | dataImages = {dataImages}; |
|
95 | 106 |
|
96 | 107 | %% collect info to adapt the graphs later on |
97 | 108 |
|
98 | | - % max of scale for data values |
99 | | - maxVox = []; |
| 109 | + nbBinsList = []; |
100 | 110 |
|
101 | | - % limit axis of axis for ROI (as nb of voxels) |
| 111 | + % limit axis of axis for ROI (nb of voxels) |
102 | 112 | MIN = []; |
103 | 113 | MAX = []; |
104 | 114 |
|
105 | | - % use the same number of bins for all graphs |
106 | | - % based on the number of unique values across all the datasets |
107 | | - nbBins = []; |
108 | | - |
109 | 115 | % to plot all the modes |
110 | 116 | modes = []; |
111 | 117 |
|
|
133 | 139 |
|
134 | 140 | % modes and nbBins work better on rounded values |
135 | 141 | modes(end + 1) = mode(round(data{idxSubplot})); |
136 | | - nbBins(end + 1) = numel(unique(round(data{idxSubplot}))); |
| 142 | + nbBinsList(end + 1) = numel(unique(round(data{idxSubplot}))); |
137 | 143 |
|
138 | 144 | subplotList(iRow, iCol) = idxSubplot; |
139 | 145 |
|
|
143 | 149 |
|
144 | 150 | end |
145 | 151 |
|
146 | | - nbBins = max(nbBins); |
147 | | - |
148 | | - for i = 1:numel(data) |
149 | | - tmp = hist(data{i}, nbBins); |
150 | | - if isempty(tmp) |
151 | | - maxVox(end + 1) = nan; |
152 | | - else |
153 | | - maxVox(end + 1) = max(tmp); |
154 | | - end |
| 152 | + if isempty(nbBins) |
| 153 | + nbBins = max(nbBinsList); |
155 | 154 | end |
156 | 155 |
|
| 156 | + maxVox = getMaxVox(args, data); |
| 157 | + |
157 | 158 | %% plot histogram and mode |
158 | 159 |
|
159 | 160 | idxSubplot = 1; |
|
191 | 192 |
|
192 | 193 | end |
193 | 194 |
|
194 | | - %% label axis |
| 195 | + labelAxis(roiAs, rows, cols, subplotList, roiImages, dataLabel); |
| 196 | + |
| 197 | +end |
| 198 | + |
| 199 | +function labelAxis(roiAs, rows, cols, subplotList, roiImages, dataLabel) |
195 | 200 |
|
196 | 201 | if strcmp(roiAs, 'rows') |
197 | 202 |
|
|
241 | 246 | end |
242 | 247 |
|
243 | 248 | end |
| 249 | + |
| 250 | +function maxVox = getMaxVox(args, data) |
| 251 | + |
| 252 | + maxVox = args.Results.maxVox; |
| 253 | + |
| 254 | + if isempty(maxVox) |
| 255 | + |
| 256 | + for i = 1:numel(data) |
| 257 | + |
| 258 | + tmp = hist(data{i}, nbBins); |
| 259 | + |
| 260 | + if isempty(tmp) |
| 261 | + maxVox(end + 1) = nan; |
| 262 | + else |
| 263 | + maxVox(end + 1) = max(tmp); |
| 264 | + end |
| 265 | + |
| 266 | + end |
| 267 | + |
| 268 | + end |
| 269 | + |
| 270 | +end |
0 commit comments