Skip to content

Commit 9dc8598

Browse files
committed
refactor
1 parent 1f86774 commit 9dc8598

File tree

2 files changed

+46
-19
lines changed

2 files changed

+46
-19
lines changed

miss_hit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ tab_width: 2
1616
# metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html)
1717
metric "cnest": limit 4
1818
metric "file_length": limit 400
19-
metric "cyc": limit 23
19+
metric "cyc": limit 16
2020
metric "parameters": limit 7

src/roi/plotDataInRoi.m

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
% :param dataLabel: strings to use to label the data rows or columns.
3030
% :type dataLabel: cellstr
3131
%
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+
%
3240
%
3341
% EXAMPLE::
3442
%
@@ -58,6 +66,8 @@
5866
args.addParameter('scaleFactor', 1, @isnumeric);
5967
args.addParameter('roiAs', 'rows', rowOrCol);
6068
args.addParameter('dataLabel', {}, @iscellstr);
69+
args.addParameter('maxVox', [], @isnumeric);
70+
args.addParameter('nbBins', [], @isnumeric);
6171

6272
args.parse(varargin{:});
6373

@@ -66,6 +76,7 @@
6676
scaleFactor = args.Results.scaleFactor;
6777
roiAs = args.Results.roiAs;
6878
dataLabel = args.Results.dataLabel;
79+
nbBins = args.Results.nbBins;
6980

7081
if ischar(dataImages)
7182
dataImages = {dataImages};
@@ -95,17 +106,12 @@
95106

96107
%% collect info to adapt the graphs later on
97108

98-
% max of scale for data values
99-
maxVox = [];
109+
nbBinsList = [];
100110

101-
% limit axis of axis for ROI (as nb of voxels)
111+
% limit axis of axis for ROI (nb of voxels)
102112
MIN = [];
103113
MAX = [];
104114

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-
109115
% to plot all the modes
110116
modes = [];
111117

@@ -133,7 +139,7 @@
133139

134140
% modes and nbBins work better on rounded values
135141
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})));
137143

138144
subplotList(iRow, iCol) = idxSubplot;
139145

@@ -143,17 +149,12 @@
143149

144150
end
145151

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);
155154
end
156155

156+
maxVox = getMaxVox(args, data);
157+
157158
%% plot histogram and mode
158159

159160
idxSubplot = 1;
@@ -191,7 +192,11 @@
191192

192193
end
193194

194-
%% label axis
195+
labelAxis(roiAs, rows, cols, subplotList, roiImages, dataLabel);
196+
197+
end
198+
199+
function labelAxis(roiAs, rows, cols, subplotList, roiImages, dataLabel)
195200

196201
if strcmp(roiAs, 'rows')
197202

@@ -241,3 +246,25 @@
241246
end
242247

243248
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

Comments
 (0)