Skip to content

Commit

Permalink
Merge pull request #698 from HJZollner/develop
Browse files Browse the repository at this point in the history
Add flag to preserve polarity
  • Loading branch information
HJZollner authored Mar 7, 2024
2 parents fa85d37 + 31ede82 commit d52f75a
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions process/OspreyProcess.m
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,19 @@
% actually have negative polarity, but end up positive in the data, so
% that the spectrum needs to be flipped.
if ~isfield(MRSCont.opts.SubSpecAlignment, 'polResidCr')
raw_Cr = op_freqrange(raw,2.8,3.2);
% Determine the polarity of the respective peak: if the absolute of the
% maximum minus the absolute of the minimum is positive, the polarity
% of the respective peak is positive; if the absolute of the maximum
% minus the absolute of the minimum is negative, the polarity is negative.
polResidCr = abs(max(real(raw_Cr.specs))) - abs(min(real(raw_Cr.specs)));
polResidCr = squeeze(polResidCr);
polResidCr(polResidCr<0) = -1;
polResidCr(polResidCr>0) = 1;
if isfield(MRSCont.opts.SubSpecAlignment, 'PreservePolarity') && ~MRSCont.opts.SubSpecAlignment.PreservePolarity
raw_Cr = op_freqrange(raw,2.8,3.2);
% Determine the polarity of the respective peak: if the absolute of the
% maximum minus the absolute of the minimum is positive, the polarity
% of the respective peak is positive; if the absolute of the maximum
% minus the absolute of the minimum is negative, the polarity is negative.
polResidCr = abs(max(real(raw_Cr.specs))) - abs(min(real(raw_Cr.specs)));
polResidCr = squeeze(polResidCr);
polResidCr(polResidCr<0) = -1;
polResidCr(polResidCr>0) = 1;
else
polResidCr = 1;
end
else
polResidCr = MRSCont.opts.SubSpecAlignment.polResidCr;
end
Expand Down Expand Up @@ -602,9 +606,9 @@
raw_no_subspec_aling = raw;

% Correct the frequency axis so that Cr appears at 3.027 ppm
[refShift_SubSpecAlign, ~] = osp_XReferencing(raw,[3.03 3.22],[1 1],[1.85 4.2]);% determine frequency shift
[refShift_SubSpecAlign, ~] = osp_XReferencing(raw,[3.03 3.22],[1 1],[1.85 3.9]);% determine frequency shift
if abs(refShift_SubSpecAlign) > 10 % This a huge shift. Most likley wrong and we will try it again with tNAA only
[refShift_SubSpecAlign, ~] = osp_XReferencing(raw,2.01,1,[1.85 4.2]);% determine frequency shift
[refShift_SubSpecAlign, ~] = osp_XReferencing(raw,2.01,1,[1.85 3.9]);% determine frequency shift
end

% Apply initial referencing shift
Expand Down

0 comments on commit d52f75a

Please sign in to comment.