Unify scope preprocessing and simulation DSP handoff
This commit is contained in:
86
Functions/Job_Processing/findSignalPulseformer.m
Normal file
86
Functions/Job_Processing/findSignalPulseformer.m
Normal file
@@ -0,0 +1,86 @@
|
||||
function pulseformer = findSignalPulseformer(signalLike)
|
||||
%FINDSIGNALPULSEFORMER Try to recover TX pulseformer metadata from a signal logbook.
|
||||
|
||||
pulseformer = [];
|
||||
|
||||
if isempty(signalLike) || ~isprop(signalLike, 'logbook') || isempty(signalLike.logbook)
|
||||
return
|
||||
end
|
||||
|
||||
if ~ismember('ModifierCopy', signalLike.logbook.Properties.VariableNames)
|
||||
return
|
||||
end
|
||||
|
||||
modifierCopies = signalLike.logbook.ModifierCopy;
|
||||
for idx = numel(modifierCopies):-1:1
|
||||
pulseformer = extractPulseformerCandidate(modifierCopies{idx});
|
||||
if ~isempty(pulseformer)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function pulseformer = extractPulseformerCandidate(candidate)
|
||||
pulseformer = [];
|
||||
|
||||
if isempty(candidate)
|
||||
return
|
||||
end
|
||||
|
||||
if isa(candidate, 'Pulseformer')
|
||||
pulseformer = candidate;
|
||||
return
|
||||
end
|
||||
|
||||
if iscell(candidate)
|
||||
for cellIdx = 1:numel(candidate)
|
||||
pulseformer = extractPulseformerCandidate(candidate{cellIdx});
|
||||
if ~isempty(pulseformer)
|
||||
return
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if isstruct(candidate)
|
||||
if isfield(candidate, 'pulseformer')
|
||||
pulseformer = extractPulseformerCandidate(candidate.pulseformer);
|
||||
if ~isempty(pulseformer)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if hasPulseformerFields(candidate)
|
||||
pulseformer = candidate;
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
try
|
||||
if isprop(candidate, 'pulseformer')
|
||||
pulseformer = extractPulseformerCandidate(candidate.pulseformer);
|
||||
if ~isempty(pulseformer)
|
||||
return
|
||||
end
|
||||
end
|
||||
catch
|
||||
end
|
||||
|
||||
try
|
||||
if hasPulseformerFields(candidate)
|
||||
pulseformer = candidate;
|
||||
end
|
||||
catch
|
||||
end
|
||||
end
|
||||
|
||||
function tf = hasPulseformerFields(candidate)
|
||||
tf = false;
|
||||
|
||||
if isstruct(candidate)
|
||||
tf = isfield(candidate, 'pulse') && isfield(candidate, 'pulselength');
|
||||
return
|
||||
end
|
||||
|
||||
tf = isobject(candidate) && isprop(candidate, 'pulse') && isprop(candidate, 'pulselength');
|
||||
end
|
||||
Reference in New Issue
Block a user