Debian Codegraph @

dwtools/EEG_extensions.cpp

raw symbols SCIP
1 /* EEG_extensions.cpp
2 *
3 * Copyright (C) 2012-2019 David Weenink, 2015,2017,2018 Paul Boersma
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "Correlation.h"cxx . . $ `<file>/dwtools/Correlation.h`/
20 #include "EEG_extensions.h"cxx . . $ `<file>/dwtools/EEG_extensions.h`/
21 #include "NUM2.h"cxx . . $ `<file>/dwsys/NUM2.h`/
22 #include "Sound_and_PCA.h"cxx . . $ `<file>/dwtools/Sound_and_PCA.h`/
23 #include "Sound_extensions.h"cxx . . $ `<file>/dwtools/Sound_extensions.h`/
24 #include "Spectrum_extensions.h"cxx . . $ `<file>/dwtools/Spectrum_extensions.h`/
25 #include "Sound_and_MixingMatrix.h"cxx . . $ `<file>/dwtools/Sound_and_MixingMatrix.h`/
26 #include "Sound_and_Spectrum.h"cxx . . $ `<file>/fon/Sound_and_Spectrum.h`/
27
28 static autoEEGcxx . . $ autoEEG# EEG_copyWithoutSoundcxx . . $ EEG_copyWithoutSound(fd6e5a87ed96171c). (EEGcxx . . $ EEG# me) {
29 try {
30 autoEEGcxx . . $ autoEEG# thee = EEG_createcxx . . $ EEG_create(52dd326870d969b2). (mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.);
31 thycxx . . $ `melder/melder.h:45:9`! numberOfChannelscxx . . $ structEEG#numberOfChannels. = mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structEEG#numberOfChannels.;
32 thycxx . . $ `melder/melder.h:45:9`! textgridcxx . . $ structEEG#textgrid. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Data_copycxx . . $ Data_copy(97a542a26794c80e). (mycxx . . $ `melder/melder.h:44:9`! textgridcxx . . $ structEEG#textgrid..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
33 thycxx . . $ `melder/melder.h:45:9`! channelNamescxx . . $ structEEG#channelNames. =cxx . . $ _autostringautovector#`operator=`(150f7ba7aac25b7e). copy_STRVECcxx . . $ copy_STRVEC(cfa8029879abedac). (mycxx . . $ `melder/melder.h:44:9`! channelNamescxx . . $ structEEG#channelNames..getcxx . . $ _autostringautovector#get(9d56076a9ef7dd02).());
34 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
35 } catch (MelderErrorcxx . . $ MelderError#) {
36 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not copied.");
37 }
38 }
39
40 static autoINTVECcxx . . $ autoINTVEC# EEG_channelNames_to_channelNumberscxx . . $ EEG_channelNames_to_channelNumbers(1b53e06397203e8c). (EEGcxx . . $ EEG# me, constSTRVECcxx . . $ constSTRVEC# const& channelNames) {
41 try {
42 autoINTVECcxx . . $ autoINTVEC# channelNumbers = zero_INTVECcxx . . $ zero_INTVEC(dab5d3ef28d6a25). (channelNames.sizecxx . . $ _conststringvector#size.);
43 for (integercxx . . $ integer# i = 1; i <= channelNames.sizecxx . . $ _conststringvector#size.; i ++) {
44 for (integercxx . . $ integer# j = 1; j <= mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structEEG#numberOfChannels.; j ++)
45 if (Melder_equcxx . . $ `melder/melder_str32.h:124:9`! (channelNames [cxx . . $ _conststringvector#`operator[]`(2065423e0524e64a).i], mycxx . . $ `melder/melder.h:44:9`! channelNamescxx . . $ structEEG#channelNames. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).j].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()))
46 channelNumbers [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = j;
47 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (channelNumbers [i] != 0,
48 U"Channel name \"", channelNames [i], U"\" not found.");
49 }
50 return channelNumberscxx . . $ autovector#autovector(d33c649a3aceae2f).;
51 } catch (MelderErrorcxx . . $ MelderError#) {
52 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": channelNames not found.");
53 }
54 }
55
56 static void EEG_setChannelNames_selectedcxx . . $ EEG_setChannelNames_selected(f4807041967404ec). (EEGcxx . . $ EEG# me, conststring32cxx . . $ conststring32# precursor, constINTVECVUcxx . . $ constINTVECVU# const& channelNumbers) {
57 autoMelderStringcxx . . $ autoMelderString# namecxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).;
58 const conststring32cxx . . $ conststring32# zero = U"0";
59 for (integercxx . . $ integer# i = 1; i <= channelNumbers.sizecxx . . $ constvectorview#size.; i ++) {
60 MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& name, precursor);
61 if (mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structEEG#numberOfChannels. > 100) {
62 if (i < 10)
63 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& name, zero);
64 if (i < 100)
65 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& name, zero);
66 } else if (i < 10) {
67 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& name, zero);
68 }
69 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& name, i);
70 EEG_setChannelNamecxx . . $ EEG_setChannelName(4799c046184655e2). (me, channelNumbers [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).i], name.stringcxx . . $ MelderString#string.);
71 }
72 }
73
74 autoCrossCorrelationTablecxx . . $ autoCrossCorrelationTable# EEG_to_CrossCorrelationTablecxx . . $ EEG_to_CrossCorrelationTable(82f8988c1f3d3c7d). (EEGcxx . . $ EEG# me, double startTime, double endTime, double lagStep, constINTVECVUcxx . . $ constINTVECVU# const& channels) {
75 try {
76 // autowindow
77 if (startTime == endTime) {
78 startTime = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.;
79 endTime = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.;
80 }
81 // don't allow times outside domain
82 if (startTime < mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.) {
83 startTime = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.;
84 }
85 if (endTime > mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.) {
86 endTime = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.;
87 }
88 autoEEGcxx . . $ autoEEG# thee = EEG_extractPartcxx . . $ EEG_extractPart(4b0b976428c6cf0). (me, startTime, endTime, true);
89 autoSoundcxx . . $ autoSound# soundPart = Sound_extractChannelscxx . . $ Sound_extractChannels(854b47aef71dd5a5). (thycxx . . $ `melder/melder.h:45:9`! soundcxx . . $ structEEG#sound..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), channels);
90 autoCrossCorrelationTablecxx . . $ autoCrossCorrelationTable# him = Sound_to_CrossCorrelationTablecxx . . $ Sound_to_CrossCorrelationTable(365ea64c78210068). (soundPart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), startTime, endTime, lagStep);
91 // assign channel names
92 for (integercxx . . $ integer# i = 1; i <= channels.sizecxx . . $ constvectorview#size.; i ++) {
93 const integercxx . . $ integer# ichannel = channels [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).i];
94 const conststring32cxx . . $ conststring32# label = mycxx . . $ `melder/melder.h:44:9`! channelNamescxx . . $ structEEG#channelNames. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).ichannel].getcxx . . $ _autostring#get(5a2a78a048fb49a8).();
95 TableOfReal_setRowLabelcxx . . $ TableOfReal_setRowLabel(7bba53c4f5b398fa). (him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), i, label);
96 TableOfReal_setColumnLabelcxx . . $ TableOfReal_setColumnLabel(7bba53c4f5b398fa). (him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), i, label);
97 }
98 return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
99 } catch (MelderErrorcxx . . $ MelderError#) {
100 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no CrossCorrelationTable calculated.");
101 }
102 }
103
104 autoCovariancecxx . . $ autoCovariance# EEG_to_Covariancecxx . . $ EEG_to_Covariance(ae851c3d40c70ebd). (EEGcxx . . $ EEG# me, double startTime, double endTime, constINTVECVUcxx . . $ constINTVECVU# const& channels) {
105 try {
106 const double lagStep = 0.0;
107 autoCrossCorrelationTablecxx . . $ autoCrossCorrelationTable# thee = EEG_to_CrossCorrelationTablecxx . . $ EEG_to_CrossCorrelationTable(82f8988c1f3d3c7d). (me, startTime, endTime, lagStep, channels);
108 autoCovariancecxx . . $ autoCovariance# him = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Covariance);
109 thycxx . . $ `melder/melder.h:45:9`! structCrossCorrelationTablecxx . . $ structCrossCorrelationTable# :: v1_copycxx . . $ structSSCP#v1_copy(42659c2335f2eda7). (him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
110 return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
111 } catch (MelderErrorcxx . . $ MelderError#) {
112 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Covariance calculated.");
113 }
114 }
115
116 autoCrossCorrelationTableListcxx . . $ autoCrossCorrelationTableList# EEG_to_CrossCorrelationTableListcxx . . $ EEG_to_CrossCorrelationTableList(35472d7ac1e44b81). (EEGcxx . . $ EEG# me,
117 double startTime, double endTime, integercxx . . $ integer# numberOfCrossCorrelations, double lagStep, constINTVECVUcxx . . $ constINTVECVU# const& channels)
118 {
119 try {
120 // autowindow
121 if (startTime == endTime) {
122 startTime = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.;
123 endTime = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.;
124 }
125 // don't allow times outside domain
126 if (startTime < mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.) {
127 startTime = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.;
128 }
129 if (endTime > mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.) {
130 endTime = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.;
131 }
132 autoEEGcxx . . $ autoEEG# thee = EEG_extractPartcxx . . $ EEG_extractPart(4b0b976428c6cf0). (me, startTime, endTime, true);
133 autoSoundcxx . . $ autoSound# soundPart = Sound_extractChannelscxx . . $ Sound_extractChannels(854b47aef71dd5a5). (thycxx . . $ `melder/melder.h:45:9`! soundcxx . . $ structEEG#sound..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), channels);
134 autoCrossCorrelationTableListcxx . . $ autoCrossCorrelationTableList# him = Sound_to_CrossCorrelationTableListcxx . . $ Sound_to_CrossCorrelationTableList(17b583310ad9ab5e). (soundPart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(),
135 startTime, endTime, numberOfCrossCorrelations, lagStep);
136 return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
137 } catch (MelderErrorcxx . . $ MelderError#) {
138 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no CrossCorrelationTables calculated.");
139 }
140 }
141
142 autoPCAcxx . . $ autoPCA# EEG_to_PCAcxx . . $ EEG_to_PCA(b2b5e876497623cd). (EEGcxx . . $ EEG# me, double startTime, double endTime, constINTVECVUcxx . . $ constINTVECVU# const& channels, int fromCorrelation) {
143 try {
144 autoCovariancecxx . . $ autoCovariance# cov = EEG_to_Covariancecxx . . $ EEG_to_Covariance(ae851c3d40c70ebd). (me, startTime, endTime, channels);
145 autoPCAcxx . . $ autoPCA# himcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).;
146 if (fromCorrelation) {
147 autoCorrelationcxx . . $ autoCorrelation# cor = SSCP_to_Correlationcxx . . $ SSCP_to_Correlation(8f3ffd89372af6fe). (cov.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
148 him =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). SSCP_to_PCAcxx . . $ SSCP_to_PCA(67c2aab67f958214). (cor.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
149 } else {
150 him =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). SSCP_to_PCAcxx . . $ SSCP_to_PCA(67c2aab67f958214). (cov.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
151 }
152 return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
153 } catch (MelderErrorcxx . . $ MelderError#) {
154 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no PCA calculated.");
155 }
156 }
157
158 autoEEGcxx . . $ autoEEG# EEG_PCA_to_EEG_whitencxx . . $ EEG_PCA_to_EEG_whiten(b375a45417e455e1). (EEGcxx . . $ EEG# me, PCAcxx . . $ PCA# thee, integercxx . . $ integer# numberOfComponents) {
159 try {
160 if (numberOfComponents <= 0 || numberOfComponents > thycxx . . $ `melder/melder.h:45:9`! numberOfEigenvaluescxx . . $ structEigen#numberOfEigenvalues.)
161 numberOfComponents = thycxx . . $ `melder/melder.h:45:9`! numberOfEigenvaluescxx . . $ structEigen#numberOfEigenvalues.;
162 numberOfComponents = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (numberOfComponents, mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structEEG#numberOfChannels.);
163
164 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thycxx . . $ `melder/melder.h:45:9`! labels.size == thycxx . . $ `melder/melder.h:45:9`! dimension);
165 autoINTVECcxx . . $ autoINTVEC# channelNumbers = EEG_channelNames_to_channelNumberscxx . . $ EEG_channelNames_to_channelNumbers(1b53e06397203e8c). (me, thycxx . . $ `melder/melder.h:45:9`! labelscxx . . $ structPCA#labels..getcxx . . $ _autostringautovector#get(9d56076a9ef7dd02).());
166
167 autoEEGcxx . . $ autoEEG# him = Data_copycxx . . $ Data_copy(97a542a26794c80e). (me);
168 autoSoundcxx . . $ autoSound# white = Sound_PCA_whitenSelectedChannelscxx . . $ Sound_PCA_whitenSelectedChannels(2ecd99f663df0ea7). (mycxx . . $ `melder/melder.h:44:9`! soundcxx . . $ structEEG#sound..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), thee, numberOfComponents, channelNumberscxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).());
169 for (integercxx . . $ integer# i = 1; i <= channelNumbers.sizecxx . . $ autovector#size.; i ++)
170 hiscxx . . $ `melder/melder.h:47:9`! soundcxx . . $ structEEG#sound. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (channelNumbers [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]) <<=cxx . . $ `operator<<=`(adea042513329390). whitecxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (i);
171
172 EEG_setChannelNames_selectedcxx . . $ EEG_setChannelNames_selected(f4807041967404ec). (him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"wh", channelNumberscxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).());
173 return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
174 } catch(MelderErrorcxx . . $ MelderError#) {
175 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not whitened with ", thee);
176 }
177 }
178
179 autoEEGcxx . . $ autoEEG# EEG_PCA_to_EEG_principalComponentscxx . . $ EEG_PCA_to_EEG_principalComponents(b375a45417e455e1). (EEGcxx . . $ EEG# me, PCAcxx . . $ PCA# thee, integercxx . . $ integer# numberOfComponents) {
180 try {
181 if (numberOfComponents <= 0 || numberOfComponents > thycxx . . $ `melder/melder.h:45:9`! numberOfEigenvaluescxx . . $ structEigen#numberOfEigenvalues.)
182 numberOfComponents = thycxx . . $ `melder/melder.h:45:9`! numberOfEigenvaluescxx . . $ structEigen#numberOfEigenvalues.;
183 numberOfComponents = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (numberOfComponents, mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structEEG#numberOfChannels.);
184
185 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (thycxx . . $ `melder/melder.h:45:9`! labels.size == thycxx . . $ `melder/melder.h:45:9`! dimension);
186 autoINTVECcxx . . $ autoINTVEC# channelNumbers = EEG_channelNames_to_channelNumberscxx . . $ EEG_channelNames_to_channelNumbers(1b53e06397203e8c). (me, thycxx . . $ `melder/melder.h:45:9`! labelscxx . . $ structPCA#labels..getcxx . . $ _autostringautovector#get(9d56076a9ef7dd02).());
187 autoEEGcxx . . $ autoEEG# him = Data_copycxx . . $ Data_copy(97a542a26794c80e). (me);
188 autoSoundcxx . . $ autoSound# pc = Sound_PCA_to_Sound_pc_selectedChannelscxx . . $ Sound_PCA_to_Sound_pc_selectedChannels(2ecd99f663df0ea7). (mycxx . . $ `melder/melder.h:44:9`! soundcxx . . $ structEEG#sound..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), thee, numberOfComponents, channelNumberscxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).());
189 for (integercxx . . $ integer# i = 1; i <= channelNumbers.sizecxx . . $ autovector#size.; i ++)
190 hiscxx . . $ `melder/melder.h:47:9`! soundcxx . . $ structEEG#sound. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (channelNumbers [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]) <<=cxx . . $ `operator<<=`(adea042513329390). pccxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (i);
191
192 EEG_setChannelNames_selectedcxx . . $ EEG_setChannelNames_selected(f4807041967404ec). (him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"pc", channelNumberscxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).());
193 return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
194 } catch (MelderErrorcxx . . $ MelderError#) {
195 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not projected.");
196 }
197 }
198
199 autoEEGcxx . . $ autoEEG# EEG_to_EEG_bsscxx . . $ EEG_to_EEG_bss(a1e31e4b8a18ccd2). (EEGcxx . . $ EEG# me, double startTime, double endTime, integercxx . . $ integer# numberOfCrossCorrelations, double lagStep,
200 constINTVECVUcxx . . $ constINTVECVU# const& channels, int whiteningMethod, int diagonalizerMethod, integercxx . . $ integer# maxNumberOfIterations, double tol,
201 autoMixingMatrixcxx . . $ autoMixingMatrix# *p_resultingMixingMatrix)
202 {
203 try {
204 // autowindow
205 if (startTime == endTime) {
206 startTime = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.;
207 endTime = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.;
208 }
209 // don't allow times outside domain
210 if (startTime < mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.)
211 startTime = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.;
212
213 if (endTime > mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.)
214 endTime = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.;
215
216 autoEEGcxx . . $ autoEEG# thee = EEG_extractPartcxx . . $ EEG_extractPart(4b0b976428c6cf0). (me, startTime, endTime, true);
217 if (whiteningMethod != 0) {
218 const bool fromCorrelation = ( whiteningMethod == 2 );
219 autoPCAcxx . . $ autoPCA# pca = EEG_to_PCAcxx . . $ EEG_to_PCA(b2b5e876497623cd). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), thycxx . . $ `melder/melder.h:45:9`! xmincxx . . $ structFunction#xmin., thycxx . . $ `melder/melder.h:45:9`! xmaxcxx . . $ structFunction#xmax., channels, fromCorrelation);
220 autoEEGcxx . . $ autoEEG# white = EEG_PCA_to_EEG_whitencxx . . $ EEG_PCA_to_EEG_whiten(b375a45417e455e1). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), pca.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0);
221 thee =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). white.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
222 }
223 autoMixingMatrixcxx . . $ autoMixingMatrix# mm = Sound_to_MixingMatrixcxx . . $ Sound_to_MixingMatrix(d82867c4462d41ff). (thycxx . . $ `melder/melder.h:45:9`! soundcxx . . $ structEEG#sound..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(),
224 startTime, endTime, numberOfCrossCorrelations, lagStep,
225 maxNumberOfIterations, tol, diagonalizerMethod);
226
227 autoEEGcxx . . $ autoEEG# him = EEG_copyWithoutSoundcxx . . $ EEG_copyWithoutSound(fd6e5a87ed96171c). (me);
228 hiscxx . . $ `melder/melder.h:47:9`! soundcxx . . $ structEEG#sound. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Sound_MixingMatrix_unmixcxx . . $ Sound_MixingMatrix_unmix(e0882d588ff3191a). (mycxx . . $ `melder/melder.h:44:9`! soundcxx . . $ structEEG#sound..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mm.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
229 EEG_setChannelNames_selectedcxx . . $ EEG_setChannelNames_selected(f4807041967404ec). (him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"ic", channels);
230
231 // Calculate the cross-correlations between eye-channels and the ic's
232
233 if (p_resultingMixingMatrix)
234 *p_resultingMixingMatrix =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). mm.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
235 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
236 } catch (MelderErrorcxx . . $ MelderError#) {
237 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no independent components determined.");
238 }
239 }
240
241 autoSoundcxx . . $ autoSound# EEG_to_Sound_modulatedcxx . . $ EEG_to_Sound_modulated(420533120239e700). (EEGcxx . . $ EEG# me, double baseFrequency, double channelBandwidth, constINTVECcxx . . $ constINTVEC# const& channelNumbers) {
242 try {
243 const double maxFreq = baseFrequency + mycxx . . $ `melder/melder.h:44:9`! numberOfChannelscxx . . $ structEEG#numberOfChannels. * channelBandwidth;
244 const double samplingFrequency = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (2.0 * maxFreq, 44100.0);
245 autoSoundcxx . . $ autoSound# thee = Sound_createSimplecxx . . $ Sound_createSimple(fcb03a673f737ce). (1, mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax. - mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., samplingFrequency);
246 for (integercxx . . $ integer# i = 1; i <= channelNumbers.sizecxx . . $ constvector#size.; i ++) {
247 const integercxx . . $ integer# ichannel = channelNumbers [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).i];
248 const double fbase = baseFrequency;// + (ichannel - 1) * channelBandwidth;
249 autoSoundcxx . . $ autoSound# si = Sound_extractChannelcxx . . $ Sound_extractChannel(fdb1ba3dfee1bd33). (mycxx . . $ `melder/melder.h:44:9`! soundcxx . . $ structEEG#sound..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ichannel);
250 autoSpectrumcxx . . $ autoSpectrum# spi = Sound_to_Spectrumcxx . . $ Sound_to_Spectrum(e96f4d575d8eeb8c). (si.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), true);
251 Spectrum_passHannBandcxx . . $ Spectrum_passHannBand(4e1fbc861a283982). (spi.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.5, channelBandwidth - 0.5, 0.5);
252 autoSpectrumcxx . . $ autoSpectrum# spi_shifted = Spectrum_shiftFrequenciescxx . . $ Spectrum_shiftFrequencies(71e5228f2f84cdd2). (spi.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), fbase, samplingFrequency / 2.0, 30);
253 autoSoundcxx . . $ autoSound# resampled = Spectrum_to_Soundcxx . . $ Spectrum_to_Sound(b9577246d0f6b8d7). (spi_shifted.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
254 const integercxx . . $ integer# nx = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (resampled ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). nxcxx . . $ structSampled#nx., thycxx . . $ `melder/melder.h:45:9`! nxcxx . . $ structSampled#nx.);
255 for (integercxx . . $ integer# j = 1; j <= nx; j ++) {
256 thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] += resampled ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j];
257 }
258 }
259 Vector_scalecxx . . $ Vector_scale(54f31cdb89d1acde). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.99);
260 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
261 } catch (MelderErrorcxx . . $ MelderError#) {
262 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no playable sound created.");
263 }
264 }
265
266 autoSoundcxx . . $ autoSound# EEG_to_Sound_frequencyShiftedcxx . . $ EEG_to_Sound_frequencyShifted(ef06ba7f16cc0732). (EEGcxx . . $ EEG# me, integercxx . . $ integer# channel, double frequencyShift, double samplingFrequency, double maxAmp) {
267 try {
268 autoSoundcxx . . $ autoSound# si = Sound_extractChannelcxx . . $ Sound_extractChannel(fdb1ba3dfee1bd33). (mycxx . . $ `melder/melder.h:44:9`! soundcxx . . $ structEEG#sound..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), channel);
269 autoSpectrumcxx . . $ autoSpectrum# spi = Sound_to_Spectrumcxx . . $ Sound_to_Spectrum(e96f4d575d8eeb8c). (si.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), true);
270 autoSpectrumcxx . . $ autoSpectrum# spi_shifted = Spectrum_shiftFrequenciescxx . . $ Spectrum_shiftFrequencies(71e5228f2f84cdd2). (spi.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), frequencyShift, samplingFrequency / 2.0, 30);
271 autoSoundcxx . . $ autoSound# thee = Spectrum_to_Soundcxx . . $ Spectrum_to_Sound(b9577246d0f6b8d7). (spi_shifted.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
272 if (maxAmp > 0)
273 Vector_scalecxx . . $ Vector_scale(54f31cdb89d1acde). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), maxAmp);
274 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
275 } catch (MelderErrorcxx . . $ MelderError#) {
276 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": channel not converted to sound.");
277 }
278 }
279
280 /* End of file EEG_extensions.cpp */