Skip to content

Commit 3a690e9

Browse files
committed
Add dynamic font size adjustment for R2025a+
Introduced logic to reduce font sizes in plot annotations and labels when running on MATLAB R2025a or newer with the append option enabled. This ensures better compatibility with updated rendering or display changes in future MATLAB releases.
1 parent 9845db2 commit 3a690e9

File tree

8 files changed

+328
-264
lines changed

8 files changed

+328
-264
lines changed

GannetCoRegister.m

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@
2323
end
2424

2525
MRS_struct.info.datetime.coreg = datetime('now');
26-
MRS_struct.info.version.coreg = '250912';
26+
MRS_struct.info.version.coreg = '250914';
27+
28+
if ~isMATLABReleaseOlderThan("R2025a") && MRS_struct.p.append
29+
font_size_adj = 2.75;
30+
else
31+
font_size_adj = 0;
32+
end
2733

2834
warning('off'); % temporarily suppress warning messages
2935

@@ -188,34 +194,34 @@
188194
if length(fname) > 30
189195
fname = [fname(1:12) '...' fname(end-11:end)];
190196
end
191-
text(0.5, 0.75, 'Mask output: ', 'Units', 'normalized', 'HorizontalAlignment' , 'right', 'FontName', 'Arial', 'FontSize', 13);
192-
text(0.5, 0.75, [' ' fname], 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13, 'Interpreter', 'none');
197+
text(0.5, 0.75, 'Mask output: ', 'Units', 'normalized', 'HorizontalAlignment' , 'right', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj);
198+
text(0.5, 0.75, [' ' fname], 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj, 'Interpreter', 'none');
193199

194-
text(0.5, 0.63, 'Spatial parameters: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
195-
text(0.5, 0.63, ' [LR, PA, SI]', 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13);
200+
text(0.5, 0.63, 'Spatial parameters: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj);
201+
text(0.5, 0.63, ' [LR, PA, SI]', 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj);
196202

197203
str = [' ' num2str(MRS_struct.p.voxdim(ii,1)) ' \times ' num2str(MRS_struct.p.voxdim(ii,2)) ' \times ' num2str(MRS_struct.p.voxdim(ii,3)) ' mm^{3}'];
198-
text(0.5, 0.51, 'Dimensions: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
199-
text(0.5, 0.51, str, 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13, 'Interpreter', 'tex');
204+
text(0.5, 0.51, 'Dimensions: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj);
205+
text(0.5, 0.51, str, 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj, 'Interpreter', 'tex');
200206

201207
str = [' ' num2str(prod(MRS_struct.p.voxdim(ii,:))/1e3) ' mL'];
202-
text(0.5, 0.39, 'Volume: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
203-
text(0.5, 0.39, str, 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13);
208+
text(0.5, 0.39, 'Volume: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj);
209+
text(0.5, 0.39, str, 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj);
204210

205211
str = [' [' num2str(MRS_struct.p.voxoff(ii,1), '%3.1f') ', ' num2str(MRS_struct.p.voxoff(ii,2), '%3.1f') ', ' num2str(MRS_struct.p.voxoff(ii,3), '%3.1f') '] mm'];
206-
text(0.5, 0.27, 'Position: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
207-
text(0.5, 0.27, str, 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13);
212+
text(0.5, 0.27, 'Position: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj);
213+
text(0.5, 0.27, str, 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj);
208214

209215
if any(strcmp(MRS_struct.p.vendor, {'Philips', 'Philips_data'}))
210216
str = [' [' num2str(MRS_struct.p.voxang(ii,2), '%3.1f') ', ' num2str(MRS_struct.p.voxang(ii,1), '%3.1f') ', ' num2str(MRS_struct.p.voxang(ii,3), '%3.1f') '] deg'];
211217
else
212218
str = [' [' num2str(MRS_struct.p.voxang(ii,1), '%3.1f') ', ' num2str(MRS_struct.p.voxang(ii,2), '%3.1f') ', ' num2str(MRS_struct.p.voxang(ii,3), '%3.1f') '] deg'];
213219
end
214-
text(0.5, 0.15, 'Angulation: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
215-
text(0.5, 0.15, str, 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13);
220+
text(0.5, 0.15, 'Angulation: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj);
221+
text(0.5, 0.15, str, 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj);
216222

217-
text(0.5, 0.03, 'CoRegVer: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13);
218-
text(0.5, 0.03, [' ' MRS_struct.info.version.coreg], 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13);
223+
text(0.5, 0.03, 'CoRegVer: ', 'Units', 'normalized', 'HorizontalAlignment', 'right', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj);
224+
text(0.5, 0.03, [' ' MRS_struct.info.version.coreg], 'Units', 'normalized', 'FontName', 'Arial', 'FontSize', 13 - font_size_adj);
219225

220226
hb = subplot(2,3,1:3);
221227

@@ -237,14 +243,14 @@
237243

238244
imagesc(MRS_struct.mask.(vox{kk}).img{ii});
239245
axis equal tight off;
240-
text(0.01, 0.5, 'L', 'Color', [1 1 1], 'FontSize', 20, 'Units', 'normalized');
241-
text(0.16, 0.95, 'A', 'Color', [1 1 1], 'FontSize', 20, 'Units', 'normalized');
242-
text(0.32, 0.5, 'A', 'Color', [1 1 1], 'FontSize', 20, 'Units', 'normalized');
243-
text(0.5, 0.95, 'S', 'Color', [1 1 1], 'FontSize', 20, 'Units', 'normalized');
244-
text(0.825, 0.95, 'S', 'Color', [1 1 1], 'FontSize', 20, 'Units', 'normalized');
245-
text(0.975, 0.5, 'R', 'Color', [1 1 1], 'FontSize', 20, 'Units', 'normalized');
246+
text(0.01, 0.5, 'L', 'Color', [1 1 1], 'FontSize', 20 - font_size_adj, 'Units', 'normalized');
247+
text(0.16, 0.95, 'A', 'Color', [1 1 1], 'FontSize', 20 - font_size_adj, 'Units', 'normalized');
248+
text(0.32, 0.5, 'A', 'Color', [1 1 1], 'FontSize', 20 - font_size_adj, 'Units', 'normalized');
249+
text(0.5, 0.95, 'S', 'Color', [1 1 1], 'FontSize', 20 - font_size_adj, 'Units', 'normalized');
250+
text(0.825, 0.95, 'S', 'Color', [1 1 1], 'FontSize', 20 - font_size_adj, 'Units', 'normalized');
251+
text(0.975, 0.5, 'R', 'Color', [1 1 1], 'FontSize', 20 - font_size_adj, 'Units', 'normalized');
246252
set(hb,'Position',[0 0.15 1 1]);
247-
title(t, 'FontName', 'Arial', 'FontSize', 15, 'Interpreter', 'none');
253+
title(t, 'FontName', 'Arial', 'FontSize', 15 - font_size_adj, 'Interpreter', 'none');
248254

249255
% Save output as PDF
250256
run_count = SavePDF(h, MRS_struct, ii, 1, kk, vox, mfilename, run_count);

0 commit comments

Comments
 (0)