Table ERP_tabulate (ERP me, bool includeSampleNumbers, bool includeTime, int timeDecimals, int voltageDecimals, int units) { double voltageScaling = 1.0; const wchar_t *unitText = L"(V)"; if (units == 2) { voltageDecimals -= 6; voltageScaling = 1000000.0; unitText = L"(uV)"; } try { autoTable thee = Table_createWithoutColumnNames (my nx, includeSampleNumbers + includeTime + my ny); long icol = 0; if (includeSampleNumbers) Table_setColumnLabel (thee.peek(), ++ icol, L"sample"); if (includeTime) Table_setColumnLabel (thee.peek(), ++ icol, L"time(s)"); for (long ichan = 1; ichan <= my ny; ichan ++) { Table_setColumnLabel (thee.peek(), ++ icol, Melder_wcscat (my channelNames [ichan], unitText)); } for (long isamp = 1; isamp <= my nx; isamp ++) { icol = 0; if (includeSampleNumbers) Table_setNumericValue (thee.peek(), isamp, ++ icol, isamp); if (includeTime) Table_setStringValue (thee.peek(), isamp, ++ icol, Melder_fixed (my x1 + (isamp - 1) * my dx, timeDecimals)); for (long ichan = 1; ichan <= my ny; ichan ++) { Table_setStringValue (thee.peek(), isamp, ++ icol, Melder_fixed (voltageScaling * my z [ichan] [isamp], voltageDecimals)); } } return thee.transfer(); } catch (MelderError) { Melder_throw (me, ": not converted to Table."); } }
Table RealTier_downto_Table (I, const wchar_t *indexText, const wchar_t *timeText, const wchar_t *valueText) { iam (RealTier); Table thee = Table_createWithoutColumnNames (my points -> size, (indexText != NULL) + (timeText != NULL) + (valueText != NULL)); cherror { long icol = 0; if (indexText != NULL) { Table_setColumnLabel (thee, ++ icol, indexText); cherror } if (timeText != NULL) { Table_setColumnLabel (thee, ++ icol, timeText); cherror }
autoTable ResultsMFCs_to_Table (OrderedOf<structResultsMFC>* me) { try { long irow = 0; bool hasGoodnesses = false, hasReactionTimes = false; for (long iresults = 1; iresults <= my size; iresults ++) { ResultsMFC results = my at [iresults]; for (long itrial = 1; itrial <= results -> numberOfTrials; itrial ++) { irow ++; if (results -> result [itrial]. goodness != 0) hasGoodnesses = true; if (results -> result [itrial]. reactionTime != 0.0) hasReactionTimes = true; } } autoTable thee = Table_create (irow, 3 + hasGoodnesses + hasReactionTimes); Table_setColumnLabel (thee.get(), 1, U"subject"); Table_setColumnLabel (thee.get(), 2, U"stimulus"); Table_setColumnLabel (thee.get(), 3, U"response"); if (hasGoodnesses) Table_setColumnLabel (thee.get(), 4, U"goodness"); if (hasReactionTimes) Table_setColumnLabel (thee.get(), 4 + hasGoodnesses, U"reactionTime"); irow = 0; for (long iresults = 1; iresults <= my size; iresults ++) { ResultsMFC results = my at [iresults]; for (long itrial = 1; itrial <= results -> numberOfTrials; itrial ++) { irow ++; Table_setStringValue (thee.get(), irow, 1, results -> name); Table_setStringValue (thee.get(), irow, 2, results -> result [itrial]. stimulus); Table_setStringValue (thee.get(), irow, 3, results -> result [itrial]. response); if (hasGoodnesses) { Table_setNumericValue (thee.get(), irow, 4, results -> result [itrial]. goodness); } if (hasReactionTimes) { Table_setNumericValue (thee.get(), irow, 4 + hasGoodnesses, results -> result [itrial]. reactionTime); } } } return thee; } catch (MelderError) { Melder_throw (U"ResultsMFC objects not collected to Table."); } }
autoTable RealTier_downto_Table (RealTier me, const char32 *indexText, const char32 *timeText, const char32 *valueText) { try { autoTable thee = Table_createWithoutColumnNames (my points.size, (!! indexText) + (!! timeText) + (!! valueText)); long icol = 0; if (indexText) Table_setColumnLabel (thee.get(), ++ icol, indexText); if (timeText ) Table_setColumnLabel (thee.get(), ++ icol, timeText); if (valueText) Table_setColumnLabel (thee.get(), ++ icol, valueText); for (long ipoint = 1; ipoint <= my points.size; ipoint ++) { RealPoint point = my points.at [ipoint]; icol = 0; if (indexText) Table_setNumericValue (thee.get(), ipoint, ++ icol, ipoint); if (timeText) Table_setNumericValue (thee.get(), ipoint, ++ icol, point -> number); if (valueText) Table_setNumericValue (thee.get(), ipoint, ++ icol, point -> value); } return thee; } catch (MelderError) { Melder_throw (me, U": not converted to Table."); } }
Table RealTier_downto_Table (RealTier me, const char32 *indexText, const char32 *timeText, const char32 *valueText) { try { autoTable thee = Table_createWithoutColumnNames (my numberOfPoints (), (indexText != NULL) + (timeText != NULL) + (valueText != NULL)); long icol = 0; if (indexText != NULL) Table_setColumnLabel (thee.peek(), ++ icol, indexText); if (timeText != NULL) Table_setColumnLabel (thee.peek(), ++ icol, timeText); if (valueText != NULL) Table_setColumnLabel (thee.peek(), ++ icol, valueText); for (long ipoint = 1; ipoint <= my numberOfPoints (); ipoint ++) { RealPoint point = my point (ipoint); icol = 0; if (indexText != NULL) Table_setNumericValue (thee.peek(), ipoint, ++ icol, ipoint); if (timeText != NULL) Table_setNumericValue (thee.peek(), ipoint, ++ icol, point -> number); if (valueText != NULL) Table_setNumericValue (thee.peek(), ipoint, ++ icol, point -> value); } return thee.transfer(); } catch (MelderError) { Melder_throw (me, U": not converted to Table."); } }
Table Spectrum_downto_Table (Spectrum me, bool includeBinNumbers, bool includeFrequency, bool includeRealPart, bool includeImaginaryPart, bool includeEnergyDensity, bool includePowerDensity) { try { autoTable thee = Table_createWithoutColumnNames (my nx, includeBinNumbers + includeFrequency + includeRealPart + includeImaginaryPart + includeEnergyDensity + includePowerDensity); long icol = 0; if (includeBinNumbers) Table_setColumnLabel (thee.peek(), ++ icol, L"bin"); if (includeFrequency) Table_setColumnLabel (thee.peek(), ++ icol, L"freq(Hz)"); if (includeRealPart) Table_setColumnLabel (thee.peek(), ++ icol, L"re(Pa/Hz)"); if (includeImaginaryPart) Table_setColumnLabel (thee.peek(), ++ icol, L"im(Pa/Hz)"); if (includeEnergyDensity) Table_setColumnLabel (thee.peek(), ++ icol, L"energy(Pa^2/Hz^2)"); if (includePowerDensity) Table_setColumnLabel (thee.peek(), ++ icol, L"pow(dB/Hz)"); for (long ibin = 1; ibin <= my nx; ibin ++) { icol = 0; if (includeBinNumbers) Table_setNumericValue (thee.peek(), ibin, ++ icol, ibin); if (includeFrequency) Table_setNumericValue (thee.peek(), ibin, ++ icol, my x1 + (ibin - 1) * my dx); if (includeRealPart) Table_setNumericValue (thee.peek(), ibin, ++ icol, my z [1] [ibin]); if (includeImaginaryPart) Table_setNumericValue (thee.peek(), ibin, ++ icol, my z [2] [ibin]); if (includeEnergyDensity) Table_setNumericValue (thee.peek(), ibin, ++ icol, Sampled_getValueAtSample (me, ibin, 0, 1)); if (includePowerDensity) Table_setNumericValue (thee.peek(), ibin, ++ icol, Sampled_getValueAtSample (me, ibin, 0, 2)); } return thee.transfer(); } catch (MelderError) { Melder_throw (me, ": not converted to Table."); } }
Table TableOfReal_to_Table (TableOfReal me, const wchar_t *labelOfFirstColumn) { try { autoTable thee = Table_createWithoutColumnNames (my numberOfRows, my numberOfColumns + 1); Table_setColumnLabel (thee.peek(), 1, labelOfFirstColumn); for (long icol = 1; icol <= my numberOfColumns; icol ++) { wchar_t *columnLabel = my columnLabels [icol]; thy columnHeaders [icol + 1]. label = Melder_wcsdup (columnLabel && columnLabel [0] ? columnLabel : L"?"); } for (long irow = 1; irow <= thy rows -> size; irow ++) { wchar_t *stringValue = my rowLabels [irow]; TableRow row = static_cast <TableRow> (thy rows -> item [irow]); row -> cells [1]. string = Melder_wcsdup (stringValue && stringValue [0] ? stringValue : L"?"); for (long icol = 1; icol <= my numberOfColumns; icol ++) { double numericValue = my data [irow] [icol]; row -> cells [icol + 1]. string = Melder_wcsdup (Melder_double (numericValue)); } } return thee.transfer(); } catch (MelderError) { Melder_throw (me, ": not converted to Table."); } }
Table Formant_downto_Table (Formant me, bool includeFrameNumbers, bool includeTimes, int timeDecimals, bool includeIntensity, int intensityDecimals, bool includeNumberOfFormants, int frequencyDecimals, bool includeBandwidths) { try { autoTable thee = Table_createWithoutColumnNames (my nx, includeFrameNumbers + includeTimes + includeIntensity + includeNumberOfFormants + my maxnFormants * (1 + includeBandwidths)); long icol = 0; if (includeFrameNumbers) Table_setColumnLabel (thee.peek(), ++ icol, U"frame"); if (includeTimes) Table_setColumnLabel (thee.peek(), ++ icol, U"time(s)"); if (includeIntensity) Table_setColumnLabel (thee.peek(), ++ icol, U"intensity"); if (includeNumberOfFormants) Table_setColumnLabel (thee.peek(), ++ icol, U"nformants"); for (long iformant = 1; iformant <= my maxnFormants; iformant ++) { Table_setColumnLabel (thee.peek(), ++ icol, Melder_cat (U"F", iformant, U"(Hz)")); if (includeBandwidths) { Table_setColumnLabel (thee.peek(), ++ icol, Melder_cat (U"B", iformant, U"(Hz)")); } } for (long iframe = 1; iframe <= my nx; iframe ++) { icol = 0; if (includeFrameNumbers) Table_setNumericValue (thee.peek(), iframe, ++ icol, iframe); if (includeTimes) Table_setStringValue (thee.peek(), iframe, ++ icol, Melder_fixed (my x1 + (iframe - 1) * my dx, timeDecimals)); Formant_Frame frame = & my d_frames [iframe]; if (includeIntensity) Table_setStringValue (thee.peek(), iframe, ++ icol, Melder_fixed (frame -> intensity, intensityDecimals)); if (includeNumberOfFormants) Table_setNumericValue (thee.peek(), iframe, ++ icol, frame -> nFormants); for (long iformant = 1; iformant <= frame -> nFormants; iformant ++) { Formant_Formant formant = & frame -> formant [iformant]; Table_setStringValue (thee.peek(), iframe, ++ icol, Melder_fixed (formant -> frequency, frequencyDecimals)); if (includeBandwidths) Table_setStringValue (thee.peek(), iframe, ++ icol, Melder_fixed (formant -> bandwidth, frequencyDecimals)); } for (long iformant = frame -> nFormants + 1; iformant <= my maxnFormants; iformant ++) { Table_setNumericValue (thee.peek(), iframe, ++ icol, NUMundefined); if (includeBandwidths) Table_setNumericValue (thee.peek(), iframe, ++ icol, NUMundefined); } } return thee.transfer(); } catch (MelderError) { Melder_throw (me, U": not converted to Table."); } }