ERPTier ERPTier_extractEventsWhereColumn_string (ERPTier me, Table table, long columnNumber, int which_Melder_STRING, const wchar_t *criterion) { try { Table_checkSpecifiedColumnNumberWithinRange (table, columnNumber); if (my events -> size != table -> rows -> size) Melder_throw (me, " & ", table, ": the number of rows in the table (", table -> rows -> size, ") doesn't match the number of events (", my events -> size, ")."); autoERPTier thee = Thing_new (ERPTier); Function_init (thee.peek(), my xmin, my xmax); thy numberOfChannels = my numberOfChannels; thy channelNames = NUMvector <wchar_t *> (1, thy numberOfChannels); for (long ichan = 1; ichan <= thy numberOfChannels; ichan ++) { thy channelNames [ichan] = Melder_wcsdup (my channelNames [ichan]); } thy events = SortedSetOfDouble_create (); for (long ievent = 1; ievent <= my events -> size; ievent ++) { ERPPoint oldEvent = my event (ievent); TableRow row = table -> row (ievent); if (Melder_stringMatchesCriterion (row -> cells [columnNumber]. string, which_Melder_STRING, criterion)) { autoERPPoint newEvent = Data_copy (oldEvent); Collection_addItem (thy events, newEvent.transfer()); } } if (thy events -> size == 0) { Melder_warning ("No event matches criterion."); } return thee.transfer(); } catch (MelderError) { Melder_throw (me, ": events not extracted."); } }
autoERPTier ERPTier_extractEventsWhereColumn_number (ERPTier me, Table table, long columnNumber, int which_Melder_NUMBER, double criterion) { try { Table_checkSpecifiedColumnNumberWithinRange (table, columnNumber); Table_numericize_Assert (table, columnNumber); // extraction should work even if cells are not defined if (my events -> size != table -> rows -> size) Melder_throw (me, U" & ", table, U": the number of rows in the table (", table -> rows -> size, U") doesn't match the number of events (", my events -> size, U")."); autoERPTier thee = Thing_new (ERPTier); Function_init (thee.peek(), my xmin, my xmax); thy numberOfChannels = my numberOfChannels; thy channelNames = NUMvector <char32 *> (1, thy numberOfChannels); for (long ichan = 1; ichan <= thy numberOfChannels; ichan ++) { thy channelNames [ichan] = Melder_dup (my channelNames [ichan]); } thy events = SortedSetOfDouble_create (); for (long ievent = 1; ievent <= my events -> size; ievent ++) { ERPPoint oldEvent = my event (ievent); TableRow row = table -> row (ievent); if (Melder_numberMatchesCriterion (row -> cells [columnNumber]. number, which_Melder_NUMBER, criterion)) { autoERPPoint newEvent = Data_copy (oldEvent); Collection_addItem_move (thy events.get(), newEvent.move()); } } if (thy events -> size == 0) { Melder_warning (U"No event matches criterion."); } return thee; } catch (MelderError) { Melder_throw (me, U": events not extracted."); } }
void RealTier_init_e (I, double tmin, double tmax) { iam (RealTier); my xmin = tmin; my xmax = tmax; my points = SortedSetOfDouble_create (); cherror end: return; }
FujisakiPitch FujisakiPitch_create (double tmin, double tmax, double baseFrequency, double alpha, double beta, double gamma) { try { autoFujisakiPitch me = Thing_new (FujisakiPitch); Function_init (me.peek(), tmin, tmax); my baseFrequency = baseFrequency; my alpha = alpha; my beta = beta; my gamma = gamma; my phraseCommands = SortedSetOfDouble_create (); my accentCommands = SortedSetOfDouble_create (); return me.transfer(); } catch (MelderError) { Melder_throw ("FujisakiPitch not created."); } }
autoVocalTractTier VocalTractTier_create (double fromTime, double toTime) { try { autoVocalTractTier me = Thing_new (VocalTractTier); Function_init (me.peek(), fromTime, toTime); my d_vocalTracts = SortedSetOfDouble_create (); return me; } catch (MelderError) { Melder_throw (U": VocalTractTier not created."); } }
autoFormantTier FormantTier_create (double tmin, double tmax) { try { autoFormantTier me = Thing_new (FormantTier); my points = SortedSetOfDouble_create (); my xmin = tmin; my xmax = tmax; return me; } catch (MelderError) { Melder_throw (U"FormantTier not created."); } }
static ERPTier EEG_PointProcess_to_ERPTier (EEG me, PointProcess events, double fromTime, double toTime) { try { autoERPTier thee = Thing_new (ERPTier); Function_init (thee.peek(), fromTime, toTime); thy numberOfChannels = my numberOfChannels - EEG_getNumberOfExtraSensors (me); Melder_assert (thy numberOfChannels > 0); thy channelNames = NUMvector <wchar_t *> (1, thy numberOfChannels); for (long ichan = 1; ichan <= thy numberOfChannels; ichan ++) { thy channelNames [ichan] = Melder_wcsdup (my channelNames [ichan]); } long numberOfEvents = events -> nt; thy events = SortedSetOfDouble_create (); double soundDuration = toTime - fromTime; double samplingPeriod = my sound -> dx; long numberOfSamples = floor (soundDuration / samplingPeriod) + 1; if (numberOfSamples < 1) Melder_throw (L"Time window too short."); double midTime = 0.5 * (fromTime + toTime); double soundPhysicalDuration = numberOfSamples * samplingPeriod; double firstTime = midTime - 0.5 * soundPhysicalDuration + 0.5 * samplingPeriod; // distribute the samples evenly over the time domain for (long ievent = 1; ievent <= numberOfEvents; ievent ++) { double eegEventTime = events -> t [ievent]; autoERPPoint event = Thing_new (ERPPoint); event -> number = eegEventTime; event -> erp = Sound_create (thy numberOfChannels, fromTime, toTime, numberOfSamples, samplingPeriod, firstTime); double erpEventTime = 0.0; double eegSample = 1 + (eegEventTime - my sound -> x1) / samplingPeriod; double erpSample = 1 + (erpEventTime - firstTime) / samplingPeriod; long sampleDifference = round (eegSample - erpSample); for (long ichannel = 1; ichannel <= thy numberOfChannels; ichannel ++) { for (long isample = 1; isample <= numberOfSamples; isample ++) { long jsample = isample + sampleDifference; event -> erp -> z [ichannel] [isample] = jsample < 1 || jsample > my sound -> nx ? 0.0 : my sound -> z [ichannel] [jsample]; } } Collection_addItem (thy events, event.transfer()); } return thee.transfer(); } catch (MelderError) { Melder_throw (me, ": ERP analysis not performed."); } }
void RealTier_init (RealTier me, double tmin, double tmax) { my xmin = tmin; my xmax = tmax; my points = SortedSetOfDouble_create (); }