How to add functionality such that lines for the autodetected peaks can be overlaid on each spectra
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
In the below code it is currently displaying the 2nd FID and showing its peak with colors as shown in attached picture. this usually generates 2 to 6 FIDs.
I want to add functionality to "Show peaks" button as shown in the figure attached of the app. Hence, it shows peaks of all the FIDs with selected colours when flickering through button "previous FID" and "Next FID" mentioned on both side of "show peaks" button.
% create index for all FID files
str = 'fid';
index_fid = [];
for k = 1:numel(sTWIX)
if any(strfind(sTWIX(k).name,str))
index_fid = [index_fid k];
end
end
N.Fid = numel(index_fid);
% Assign indice variables to app
app.N = N;
app.index_me_bSSFP = index_me_bSSFP;
app.index_fid = index_fid;
% Process all FIDs and display 2nd FID in GUI
FIDs = struct;
for k = 1:numel(index_fid)
[FIDs(k).frequency, FIDs(k).spectrum] = FID_process_app(sTWIX(index_fid(k)), ...
sTWIX(index_fid(k)).files);
end
% Store FIDs in app
app.FIDs = FIDs;
% Auto detect peaks
for t = 1:length(FIDs)
FID_spec_max(t) = max(FIDs(t).spectrum); % See max signal from each spectra
end
[Pyr_sig spec_pos] = max(FID_spec_max); % Identify max signal from all spectra
temp_spec = FIDs(spec_pos).spectrum;
% Locate pyruvate position
[Pyr_sig Pyr_spec_pos] = max(temp_spec); % Locate pyruvate signal position
pyr_freq = FIDs(spec_pos).frequency(Pyr_spec_pos) % Identify pyruvate resonance frequency
% Locate urea position
Ure_sig = max(FIDs(spec_pos).spectrum(Pyr_spec_pos-150:Pyr_spec_pos-90));
Ure_spec_pos = find(abs(FIDs(spec_pos).spectrum) == abs(Ure_sig));
ure_freq = FIDs(spec_pos).frequency(Ure_spec_pos) % Identify urea resonance frequency
% Locate lactate position
Lac_sig = max(FIDs(spec_pos).spectrum(Pyr_spec_pos+175:Pyr_spec_pos+225));
Lac_spec_pos = find(abs(FIDs(spec_pos).spectrum) == abs(Lac_sig));
lac_freq = FIDs(spec_pos).frequency(Lac_spec_pos) % Identify lactate resonance frequency
% Locate hydrate position
Hyd_sig = max(FIDs(spec_pos).spectrum(Pyr_spec_pos+120:Pyr_spec_pos+150));
Hyd_spec_pos = find(abs(FIDs(spec_pos).spectrum) == abs(Hyd_sig));
hyd_freq = FIDs(spec_pos).frequency(Hyd_spec_pos) % Identify hydrate resonance frequency
% Locate alanine position
Ala_sig = max(FIDs(spec_pos).spectrum(Pyr_spec_pos+80:Pyr_spec_pos+110));
Ala_spec_pos = find(abs(FIDs(spec_pos).spectrum) == abs(Ala_sig));
ala_freq = FIDs(spec_pos).frequency(Ala_spec_pos) % Identify alanine resonance frequency
% Load auto detected values in
app.F1EditField.Value = lac_freq;
app.F2EditField.Value = hyd_freq;
app.F3EditField.Value = ala_freq;
app.F4EditField.Value = pyr_freq;
app.F5EditField.Value = ure_freq;
% Plot max signal FID in GUI Axes
plot(app.UIAxes,FIDs(spec_pos).frequency,FIDs(spec_pos).spectrum,...
'k',"LineWidth",3.0)
title(app.UIAxes,sprintf('Nonlocalised Spec - No. %01d',app.fid_int))
% plot prediected positions
xline(app.UIAxes,lac_freq,'r--',"LineWidth",3.0);
xline(app.UIAxes,hyd_freq,'b--',"LineWidth",3.0);
xline(app.UIAxes,ala_freq,'g--',"LineWidth",3.0);
xline(app.UIAxes,pyr_freq,'m--',"LineWidth",3.0);
xline(app.UIAxes,ure_freq,'c--',"LineWidth",3.0);
0 Kommentare
Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!