CrossCorrelationTable EEG_to_CrossCorrelationTable (EEG me, double startTime, double endTime, double lagTime, const wchar_t *channelRanges) { try { // autowindow if (startTime == endTime) { startTime = my xmin; endTime = my xmax; } // don't allow times outside domain if (startTime < my xmin) { startTime = my xmin; } if (endTime > my xmax) { endTime = my xmax; } autoEEG thee = my f_extractPart (startTime, endTime, true); long numberOfChannels; autoNUMvector <long> channels (NUMstring_getElementsOfRanges (channelRanges, thy d_numberOfChannels, & numberOfChannels, NULL, L"channel", true), 1); autoSound soundPart = Sound_copyChannelRanges (thy d_sound, channelRanges); autoCrossCorrelationTable him = Sound_to_CrossCorrelationTable (soundPart.peek(), startTime, endTime, lagTime); // assign channel names for (long i = 1; i <= numberOfChannels; i++) { long ichannel = channels[i]; wchar_t *label = my d_channelNames[ichannel]; TableOfReal_setRowLabel (him.peek(), i, label); TableOfReal_setColumnLabel (him.peek(), i, label); } return him.transfer(); } catch (MelderError) { Melder_throw (me, ": no CrossCorrelationTable calculated."); } }
autoCovariance Sound_to_Covariance_channels (Sound me, double startTime, double endTime) { try { double lagStep = 0.0; autoCrossCorrelationTable thee = Sound_to_CrossCorrelationTable (me, startTime, endTime, lagStep); autoCovariance him = Thing_new (Covariance); thy structCrossCorrelationTable :: v_copy (him.peek()); return him; } catch (MelderError) { Melder_throw (me, U": no Covariance created."); } }
autoCrossCorrelationTables Sound_to_CrossCorrelationTables (Sound me, double startTime, double endTime, double lagStep, long ncovars) { try { if (lagStep < my dx) { lagStep = my dx; } if (endTime <= startTime) { startTime = my xmin; endTime = my xmax; } if (startTime + ncovars * lagStep >= endTime) { Melder_throw (U"Lag time too large."); } autoCrossCorrelationTables thee = CrossCorrelationTables_create (); for (long i = 1; i <= ncovars; i++) { double lag = (i - 1) * lagStep; autoCrossCorrelationTable ct = Sound_to_CrossCorrelationTable (me, startTime, endTime, lag); Collection_addItem_move (thee.peek(), ct.move()); } return thee; } catch (MelderError) { Melder_throw (me, U": no CrossCorrelationTables created."); } }