Example #1
0
CrossCorrelationTable EEG_to_CrossCorrelationTable (EEG me, double startTime, double endTime, double lagStep, const char32 *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 = EEG_extractPart (me, startTime, endTime, true);
		long numberOfChannels;
		autoNUMvector <long> channels (NUMstring_getElementsOfRanges (channelRanges, thy numberOfChannels, & numberOfChannels, NULL, U"channel", true), 1);
		autoSound soundPart = Sound_copyChannelRanges (thy sound, channelRanges);
		autoCrossCorrelationTable him = Sound_to_CrossCorrelationTable (soundPart.peek(), startTime, endTime, lagStep);
		// assign channel names
		for (long i = 1; i <= numberOfChannels; i++) {
			long ichannel = channels[i];
			char32 *label = my channelNames[ichannel];
			TableOfReal_setRowLabel (him.peek(), i, label);
			TableOfReal_setColumnLabel (him.peek(), i, label);
		}
		return him.transfer();
	} catch (MelderError) {
		Melder_throw (me, U": no CrossCorrelationTable calculated.");
	}
}
Example #2
0
CrossCorrelationTables EEG_to_CrossCorrelationTables (EEG me, double startTime, double endTime, double lagStep, long ncovars, const char32 *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 = EEG_extractPart (me, startTime, endTime, true);
		long numberOfChannels;
		autoNUMvector <long> channels (NUMstring_getElementsOfRanges (channelRanges, thy numberOfChannels, & numberOfChannels, NULL, U"channel", true), 1);
		autoSound soundPart = Sound_copyChannelRanges (thy sound, channelRanges);
		autoCrossCorrelationTables him = Sound_to_CrossCorrelationTables (soundPart.peek(), startTime, endTime, lagStep, ncovars);
		return him.transfer();
	} catch (MelderError) {
		Melder_throw (me, U": no CrossCorrelationTables calculated.");
	}
}
Example #3
0
EEG EEG_to_EEG_bss (EEG me, double startTime, double endTime, long ncovars, double lagStep, const char32 *channelRanges, int whiteningMethod, int diagonalizerMethod, long maxNumberOfIterations, double tol) {
	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;
		}
		long numberOfChannels;
		autoNUMvector <long> channelNumbers (NUMstring_getElementsOfRanges (channelRanges, my numberOfChannels, & numberOfChannels, NULL, U"channel", true), 1);
		autoEEG thee = EEG_extractPart (me, startTime, endTime, true);
		if (whiteningMethod != 0) {
			bool fromCorrelation = whiteningMethod == 2;
			autoPCA pca = EEG_to_PCA (thee.peek(), thy xmin, thy xmax, channelRanges, fromCorrelation);
			autoEEG white = EEG_and_PCA_to_EEG_whiten (thee.peek(), pca.peek(), 0);
			thee.reset (white.transfer());
		}
		autoMixingMatrix mm = Sound_to_MixingMatrix (thy sound, startTime, endTime, ncovars, lagStep, maxNumberOfIterations, tol, diagonalizerMethod);

		autoEEG him = EEG_copyWithoutSound (me);
		his sound = Sound_and_MixingMatrix_unmix (my sound, mm.peek());
		EEG_setChannelNames_selected (him.peek(), U"ic", channelNumbers.peek(), numberOfChannels);

		// Calculate the cross-correlations between eye-channels and the ic's


		return him.transfer();

	} catch (MelderError) {
		Melder_throw (me, U": no independent components determined.");
	}
}
Example #4
0
    SENTENCEVAR (channelName, U"Channel name", U"Cz")
    OK
    DO
    CONVERT_EACH (EEG)
    autoEEG result = EEG_extractChannel (me, channelName);
    CONVERT_EACH_END (my name, U"_", channelName)
}

FORM (NEW_EEG_extractPart, U"EEG: Extract part", nullptr) {
    REALVAR (fromTime, U"left Time range (s)", U"0.0")
    REALVAR (toTime, U"right Time range (s)", U"1.0")
    BOOLEANVAR (preserveTimes, U"Preserve times", false)
    OK
    DO
    CONVERT_EACH (EEG)
    autoEEG result = EEG_extractPart (me, fromTime, toTime, preserveTimes);
    CONVERT_EACH_END (my name, U"_part")
}

DIRECT (NEW_EEG_extractSound) {
    CONVERT_EACH (EEG)
    if (! my sound) Melder_throw (me, U": I don't contain a waveform.");
    autoSound result = EEG_extractSound (me);
    CONVERT_EACH_END (my name)
}

DIRECT (NEW_EEG_extractTextGrid) {
    CONVERT_EACH (EEG)
    if (! my textgrid) Melder_throw (me, U": I don't contain marks.");
    autoTextGrid result = EEG_extractTextGrid (me);
    CONVERT_EACH_END (my name)