-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
126 changed files
with
4,284 additions
and
875 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
AuditoryMachineLearningTrainingTestingPipeline/src/+BlockCreators/FullFileBlockCreator.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
classdef FullFileBlockCreator < BlockCreators.Base | ||
% | ||
%% ----------------------------------------------------------------------------------- | ||
properties (SetAccess = private) | ||
end | ||
|
||
%% ----------------------------------------------------------------------------------- | ||
methods | ||
|
||
function obj = FullFileBlockCreator() | ||
obj = [email protected]( inf, 0 ); | ||
end | ||
%% ------------------------------------------------------------------------------- | ||
|
||
end | ||
|
||
%% ----------------------------------------------------------------------------------- | ||
methods (Access = protected) | ||
|
||
function outputDeps = getBlockCreatorInternOutputDependencies( obj ) | ||
outputDeps.v = 1; | ||
end | ||
%% ------------------------------------------------------------------------------- | ||
|
||
function [blockAnnots,afeBlocks] = blockify( obj, afeData, annotations ) | ||
currentDependencies = obj.getOutputDependencies(); | ||
sceneConfig = currentDependencies.preceding.preceding.sceneCfg; | ||
annotations = BlockCreators.StandardBlockCreator.extendAnnotations( ... | ||
sceneConfig, annotations ); | ||
anyAFEsignal = afeData(1); | ||
if isa( anyAFEsignal, 'cell' ), anyAFEsignal = anyAFEsignal{1}; end; | ||
streamLen_s = double( size( anyAFEsignal.Data, 1 ) ) / anyAFEsignal.FsHz; | ||
if nargout > 1 | ||
afeBlocks = {afeData}; | ||
end | ||
blockAnnots = annotations; | ||
blockAnnots.blockOnset = 0; | ||
blockAnnots.blockOffset = streamLen_s; | ||
end | ||
%% ------------------------------------------------------------------------------- | ||
|
||
end | ||
%% ----------------------------------------------------------------------------------- | ||
|
||
methods (Static) | ||
|
||
%% ------------------------------------------------------------------------------- | ||
%% ------------------------------------------------------------------------------- | ||
|
||
end | ||
|
||
end | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
function outputDeps = getBlockCreatorInternOutputDependencies( obj ) | ||
outputDeps.sbc = getBlockCreatorInternOutputDependencies@... | ||
BlockCreators.StandardBlockCreator( obj ); | ||
outputDeps.v = 1; | ||
outputDeps.v = 3; | ||
end | ||
%% ------------------------------------------------------------------------------- | ||
|
||
|
@@ -32,6 +32,10 @@ | |
blockAnnots = [email protected]( ... | ||
obj, afeData, annotations ); | ||
end | ||
[blockAnnots(:).nrj] = deal(struct('t',[],'nrj',[])); | ||
[blockAnnots(:).nrjOthers] = deal(struct('t',[],'nrjOthers',[])); | ||
[blockAnnots(:).srcSNRactive] = deal(struct('t',[],'srcSNRactive',[])); | ||
[blockAnnots(:).srcSNR2] = deal(struct('t',[],'srcSNR2',[])); | ||
aFields = fieldnames( blockAnnots ); | ||
isSequenceAnnotation = cellfun( @(af)(... | ||
isstruct( blockAnnots(1).(af) ) && ... | ||
|
@@ -40,30 +44,74 @@ | |
), aFields ); | ||
sequenceAfields = aFields(isSequenceAnnotation); | ||
for ii = 1 : numel( blockAnnots ) | ||
blockAnnots(ii) = ... | ||
BlockCreators.MeanStandardBlockCreator.adjustPreMeanAnnotations( ... | ||
blockAnnots(ii) ); | ||
for jj = 1 : numel( sequenceAfields ) | ||
seqAname = sequenceAfields{jj}; | ||
annot = blockAnnots(ii).(seqAname); | ||
if length( annot.t ) == size( annot.(seqAname), 1 ) | ||
if iscell( annot.(seqAname) ) | ||
annotSeq = annot.(seqAname); | ||
if length( annot.t ) == size( annotSeq, 1 ) | ||
if iscell( annotSeq ) | ||
as_szs = cellfun( @(c)( size( c, 2 ) ), annotSeq(1,:) ); | ||
blockAnnots(ii).(seqAname) = ... | ||
cellSqueezeFun( @mean, annot.(seqAname), 1, true ); | ||
mat2cell( nanmean( cell2mat( annotSeq ), 1 ), 1, as_szs ); | ||
else | ||
blockAnnots(ii).(seqAname) = mean( annot.(seqAname), 1 ); | ||
blockAnnots(ii).(seqAname) = nanmean( annotSeq, 1 ); | ||
end | ||
else | ||
error( 'unexpected annotations sequence structure' ); | ||
end | ||
end | ||
blockAnnots(ii) = ... | ||
BlockCreators.MeanStandardBlockCreator.extendMeanAnnotations( ... | ||
blockAnnots(ii) ); | ||
end | ||
end | ||
%% ------------------------------------------------------------------------------- | ||
%% ------------------------------------------------------------------------------- | ||
|
||
end | ||
%% ----------------------------------------------------------------------------------- | ||
|
||
methods (Static) | ||
|
||
%% ------------------------------------------------------------------------------- | ||
|
||
% TODO: this is the wrong place for the annotation computation; it | ||
% should be done in SceneEarSignalProc -- and is now here, for the | ||
% moment, to avoid recomputation with SceneEarSignalProc. | ||
|
||
function avgdBlockAnnots = extendMeanAnnotations( avgdBlockAnnots ) | ||
srcsGlobalRefEnergyMeanChannel = cellfun( ... | ||
@(c)(sum(c) ./ 2 ), avgdBlockAnnots.globalSrcEnergy ); | ||
srcsGlobalRefEnergyMeanChannel_db = 10 * log10( srcsGlobalRefEnergyMeanChannel ); | ||
haveSrcsEnergy = srcsGlobalRefEnergyMeanChannel_db > -40; | ||
isAmbientSource = isnan( avgdBlockAnnots.srcAzms ); | ||
haveSrcsEnergy(isAmbientSource) = []; | ||
avgdBlockAnnots.nActivePointSrcs = single( sum( haveSrcsEnergy ) ); | ||
avgdBlockAnnots.srcSNR2 = 10 * log10( avgdBlockAnnots.nrj ./ avgdBlockAnnots.nrjOthers ); | ||
avgdBlockAnnots.nrj = 10 * log10( avgdBlockAnnots.nrj ); | ||
avgdBlockAnnots.nrjOthers = 10 * log10( avgdBlockAnnots.nrjOthers ); | ||
avgdBlockAnnots.globalSrcEnergy = cellfun( @(c)(10 * log10( c )), ... | ||
avgdBlockAnnots.globalSrcEnergy, 'UniformOutput', false ); | ||
end | ||
%% ------------------------------------------------------------------------------- | ||
|
||
% TODO: this is the wrong place for the annotation computation; it | ||
% should be done in SceneEarSignalProc -- and is now here, for the | ||
% moment, to avoid recomputation with SceneEarSignalProc. | ||
|
||
function annotations = adjustPreMeanAnnotations( annotations ) | ||
annotations.srcSNRactive.t = annotations.globalSrcEnergy.t; | ||
annotations.srcSNRactive.srcSNRactive = annotations.srcSNR_db.srcSNR_db; | ||
allSrcsInactive = annotations.nActivePointSrcs.nActivePointSrcs == 0; | ||
annotations.srcSNRactive.srcSNRactive(allSrcsInactive,:) = nan; | ||
annotations.srcSNRactive.srcSNRactive = annotations.srcSNRactive.srcSNRactive; | ||
annotations.nrj.t = annotations.globalSrcEnergy.t; | ||
annotations.nrj.nrj = 10.^(annotations.nrj_db.nrj_db./10); | ||
annotations.nrjOthers.t = annotations.globalSrcEnergy.t; | ||
annotations.nrjOthers.nrjOthers = 10.^(annotations.nrjOthers_db.nrjOthers_db./10); | ||
end | ||
%% ------------------------------------------------------------------------------- | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.