Why the FigureLoop component in Report Generator changes the order of the figures generated by my code?

4 views (last 30 days)
Hi there! So here is what's happening. The order of my figures for a current run is (the list has the name of the plot): T2 fit 1, T2 Residuals, T1 fit 1, T1 Residuals, T2 fit 1, T2 Residuals, T1 fit 1, T1 Residuals, T2 fit 1, T2 Residuals, T1 fit 1, T1 Residuals
However, when I add the FigureLoop component and run the Report Generator this previous order is changed to: T1 fit 1, T2 fit 1, T2 fit 1, T1 fit 1, T1 Residuals, T2 Residuals, T1 Residuals, T1 Residuals, T2 Residuals, T1 fit 1, T2 fit 1, T2 Residuals This program can generate a large number of plots, thus this gets worse if I tried to generate a report for a case with as many plots as 196 or larger.
Here's the part of my code that generates the plots:
if any(M1T2(n) == 0), end; %continue, % no data so move onto the next column
%Curve fit for T2 (TE)
[xData, yData] = prepareCurveData( T2taus, M1T2 );
ffunT2 = fittype('M0*exp(-x/T2) + C', 'independent', 'x', 'dependent', 'y');
options = fitoptions(ffunT2);
options.Algorithm = 'Levenberg-Marquardt';
options.Display = 'Off';
options.Robust ='Bisquare';
options.StartPoint = [1000 1 1000];
%Fit model to data.
[cfun, gof] = fit(xData,yData,ffunT2,options);
%Create a figure for the plots for T2
figure('Name', 'T2 fit 1');
% Plot fit with data for T2.
h = plot(cfun, xData, yData, 'ob' );
legend( h, 'Mean Signal Intensity vs. TE', 'Custom fit 1', 'Location', 'NorthEast' );
% Label axes
xlabel 'Echo Time, TE (ms)'
ylabel 'Mean Signal Intensity, (ms)'
title ({(firstline);sprintf('T2 Curve Fit, Series %d - %d ', Series(1), Series(10))})
grid on
snapnow
% Plot residuals.
figure('Name', 'T2 Residuals')
h2 = plot( cfun, xData, yData, '*k','residuals');
legend( h2, 'Custom fit 1 - residuals', 'Zero Line', 'Location', 'NorthEast' );
% Label axes
xlabel 'Echo Time,TE (ms)'
ylabel 'Mean Signal Intensity (ms)'
title ({(firstline);sprintf('T2 Residuals, Series %d - %d ', Series(1), Series(10))})
grid on
snapnow
if any(M1T1(n) == 0), end; %continue, % no data so move onto the next column
%Curve fit for T1 (TR)
[xData2, yData2] = prepareCurveData( T1taus, M1T1 );
ffunT1 = fittype('M0T1*(1-SS*exp(-x/T1))', 'independent', 'x', 'dependent', 'y');
options = fitoptions(ffunT1);
options.Algorithm = 'Levenberg-Marquardt';
options.Display = 'Off';
options.Robust ='Bisquare';
options.StartPoint = [1000 1 1000];
%Fit model to data.
[cfun2, gof] = fit(xData2,yData2,ffunT1,options);
% Plot fit with data for T1.
figure('Name', 'T1 fit 1');
% subplot( 2, 1, 1 ); not needed because we want larger figures
h3 = plot(cfun2, xData2, yData2, 'sb' );
legend( h3, 'Mean Signal Intensity vs. TR', 'Custom fit 1', 'Location', 'SouthEast' );
% Label axes
xlabel 'Repetition Time, TR (ms)'
ylabel 'Mean Signal Intensity'
title ({(firstline);sprintf('T1 Curve Fit, Series %d - %d ', Series(1), Series(10))})
grid on
snapnow
% Plot residuals for T1.
figure('Name', 'T1 Residuals')
h4 = plot( cfun2, xData2, yData2, '*k','residuals');
legend( h4, 'Custom fit 1 - residuals', 'Zero Line', 'Location', 'NorthEast' );
% Label axes
xlabel ('Repetition Time, TR (ms)')
ylabel ('Mean Signal Intensity')
title ({(firstline);sprintf('T1 Residuals, Series %d - %d ', Series(1), Series(10))})
grid on
snapnow
Thank you very much for your time and attention.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!