Skip to content
Commits on Source (7)
---
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 8
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
RawStringFormats:
- Delimiter: pb
Language: TextProto
BasedOnStyle: google
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Always
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 3
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: ForIndentation
#UseTab: Never
...
......@@ -85,12 +85,11 @@ autoEEG EEG_create (double tmin, double tmax) {
}
}
integer EEG_getChannelNumber (EEG me, const char32 *channelName) {
integer EEG_getChannelNumber (EEG me, conststring32 channelName) {
for (integer ichan = 1; ichan <= my numberOfChannels; ichan ++) {
if (Melder_equ (my channelNames [ichan], channelName)) {
if (Melder_equ (my channelNames [ichan].get(), channelName))
return ichan;
}
}
return 0;
}
......@@ -125,7 +124,7 @@ autoEEG EEG_readFromBdfFile (MelderFile file) {
if (numberOfBytesInHeaderRecord != (numberOfChannels + 1) * 256)
Melder_throw (U"Number of bytes in header record (", numberOfBytesInHeaderRecord,
U") doesn't match number of channels (", numberOfChannels, U").");
autostring32vector channelNames (1, numberOfChannels);
autostring32vector channelNames (numberOfChannels);
for (integer ichannel = 1; ichannel <= numberOfChannels; ichannel ++) {
fread (buffer, 1, 16, f); buffer [16] = '\0'; // labels of the channels
/*
......@@ -139,9 +138,9 @@ autoEEG EEG_readFromBdfFile (MelderFile file) {
}
}
channelNames [ichannel] = Melder_8to32 (buffer);
trace (U"Channel <<", channelNames [ichannel], U">>");
trace (U"Channel <<", channelNames [ichannel].get(), U">>");
}
bool hasLetters = str32equ (channelNames [numberOfChannels], U"EDF Annotations");
bool hasLetters = str32equ (channelNames [numberOfChannels].get(), U"EDF Annotations");
double samplingFrequency = undefined;
for (integer channel = 1; channel <= numberOfChannels; channel ++) {
fread (buffer, 1, 80, f); buffer [80] = '\0'; // transducer type
......@@ -149,22 +148,22 @@ autoEEG EEG_readFromBdfFile (MelderFile file) {
for (integer channel = 1; channel <= numberOfChannels; channel ++) {
fread (buffer, 1, 8, f); buffer [8] = '\0'; // physical dimension of channels
}
autonumvec physicalMinimum (numberOfChannels, kTensorInitializationType::RAW);
autoVEC physicalMinimum (numberOfChannels, kTensorInitializationType::RAW);
for (integer ichannel = 1; ichannel <= numberOfChannels; ichannel ++) {
fread (buffer, 1, 8, f); buffer [8] = '\0';
physicalMinimum [ichannel] = atof (buffer);
}
autonumvec physicalMaximum (numberOfChannels, kTensorInitializationType::RAW);
autoVEC physicalMaximum (numberOfChannels, kTensorInitializationType::RAW);
for (integer ichannel = 1; ichannel <= numberOfChannels; ichannel ++) {
fread (buffer, 1, 8, f); buffer [8] = '\0';
physicalMaximum [ichannel] = atof (buffer);
}
autonumvec digitalMinimum (numberOfChannels, kTensorInitializationType::RAW);
autoVEC digitalMinimum (numberOfChannels, kTensorInitializationType::RAW);
for (integer ichannel = 1; ichannel <= numberOfChannels; ichannel ++) {
fread (buffer, 1, 8, f); buffer [8] = '\0';
digitalMinimum [ichannel] = atof (buffer);
}
autonumvec digitalMaximum (numberOfChannels, kTensorInitializationType::RAW);
autoVEC digitalMaximum (numberOfChannels, kTensorInitializationType::RAW);
for (integer ichannel = 1; ichannel <= numberOfChannels; ichannel ++) {
fread (buffer, 1, 8, f); buffer [8] = '\0';
digitalMaximum [ichannel] = atof (buffer);
......@@ -193,26 +192,26 @@ autoEEG EEG_readFromBdfFile (MelderFile file) {
his numberOfChannels = numberOfChannels;
autoSound me = Sound_createSimple (numberOfChannels, duration, samplingFrequency);
Melder_assert (my nx == numberOfSamplesPerDataRecord * numberOfDataRecords);
autoNUMvector <unsigned char> dataBuffer ((integer) 0, 3 * numberOfSamplesPerDataRecord - 1);
autoNUMvector <uint8> dataBuffer ((integer) 0, 3 * numberOfSamplesPerDataRecord - 1);
for (integer record = 1; record <= numberOfDataRecords; record ++) {
for (integer channel = 1; channel <= numberOfChannels; channel ++) {
double factor = channel == numberOfChannels ? 1.0 : physicalMinimum [channel] / digitalMinimum [channel];
if (channel < numberOfChannels - EEG_getNumberOfExtraSensors (him.get())) factor /= 1000000.0;
if (is24bit) {
fread (& dataBuffer [0], 3, (size_t) numberOfSamplesPerDataRecord, f);
unsigned char *p = & dataBuffer [0];
uint8 *p = & dataBuffer [0];
for (integer i = 1; i <= numberOfSamplesPerDataRecord; i ++) {
integer sample = i + (record - 1) * numberOfSamplesPerDataRecord;
Melder_assert (sample <= my nx);
uint8_t lowByte = *p ++, midByte = *p ++, highByte = *p ++;
uint32_t externalValue = ((uint32_t) highByte << 16) | ((uint32_t) midByte << 8) | (uint32_t) lowByte;
uint8 lowByte = *p ++, midByte = *p ++, highByte = *p ++;
uint32 externalValue = ((uint32) highByte << 16) | ((uint32) midByte << 8) | (uint32) lowByte;
if ((highByte & 128) != 0) // is the 24-bit sign bit on?
externalValue |= 0xFF000000; // extend negative sign to 32 bits
my z [channel] [sample] = (int32_t) externalValue * factor;
externalValue |= 0xFF00'0000; // extend negative sign to 32 bits
my z [channel] [sample] = (int32) externalValue * factor;
}
} else {
fread (& dataBuffer [0], 2, (size_t) numberOfSamplesPerDataRecord, f);
unsigned char *p = & dataBuffer [0];
uint8 *p = & dataBuffer [0];
for (integer i = 1; i <= numberOfSamplesPerDataRecord; i ++) {
integer sample = i + (record - 1) * numberOfSamplesPerDataRecord;
Melder_assert (sample <= my nx);
......@@ -226,7 +225,7 @@ autoEEG EEG_readFromBdfFile (MelderFile file) {
int numberOfStatusBits = 8;
for (integer i = 1; i <= my nx; i ++) {
uint32 value = (uint32) (int32) my z [numberOfChannels] [i];
if (value & 0x0000FF00) {
if (value & 0x0000'FF00) {
numberOfStatusBits = 16;
}
}
......@@ -237,9 +236,9 @@ autoEEG EEG_readFromBdfFile (MelderFile file) {
double time = undefined;
for (integer i = 1; i <= my nx; i ++) {
uint32 value = (uint32) (int32) my z [numberOfChannels] [i];
for (int byte = 1; byte <= numberOfStatusBits / 8; byte ++) {
uint32 mask = byte == 1 ? 0x000000ff : 0x0000ff00;
char32 kar = byte == 1 ? (value & mask) : (value & mask) >> 8;
for (int ibyte = 1; ibyte <= numberOfStatusBits / 8; ibyte ++) {
uint32 mask = ( ibyte == 1 ? 0x0000'00ff : 0x0000'ff00 );
char32 kar = ( ibyte == 1 ? (value & mask) : (value & mask) >> 8 );
if (kar != U'\0' && kar != 20) {
MelderString_appendCharacter (& letters, kar);
} else if (letters. string [0] != U'\0') {
......@@ -302,7 +301,7 @@ autoEEG EEG_readFromBdfFile (MelderFile file) {
}
}
f.close (file);
his channelNames = channelNames.transfer();
his channelNames = std::move (channelNames);
his sound = me.move();
his textgrid = thee.move();
if (EEG_getNumberOfCapElectrodes (him.get()) == 32) {
......@@ -449,15 +448,13 @@ void EEG_filter (EEG me, double lowFrequency, double lowWidth, double highFreque
}
}
void EEG_setChannelName (EEG me, integer channelNumber, const char32 *a_name) {
autostring32 l_name = Melder_dup (a_name);
Melder_free (my channelNames [channelNumber]);
my channelNames [channelNumber] = l_name.transfer();
void EEG_setChannelName (EEG me, integer channelNumber, conststring32 newName) {
my channelNames [channelNumber] = Melder_dup (newName);
}
void EEG_setExternalElectrodeNames (EEG me,
const char32 *nameExg1, const char32 *nameExg2, const char32 *nameExg3, const char32 *nameExg4,
const char32 *nameExg5, const char32 *nameExg6, const char32 *nameExg7, const char32 *nameExg8)
conststring32 nameExg1, conststring32 nameExg2, conststring32 nameExg3, conststring32 nameExg4,
conststring32 nameExg5, conststring32 nameExg6, conststring32 nameExg7, conststring32 nameExg8)
{
if (EEG_getNumberOfExternalElectrodes (me) != 8)
Melder_throw (U"There aren't 8 external electrodes.");
......@@ -472,13 +469,13 @@ void EEG_setExternalElectrodeNames (EEG me,
EEG_setChannelName (me, firstExternalElectrode + 7, nameExg8);
}
void EEG_subtractReference (EEG me, const char32 *channelNumber1_text, const char32 *channelNumber2_text) {
integer channelNumber1 = EEG_getChannelNumber (me, channelNumber1_text);
void EEG_subtractReference (EEG me, conststring32 channelName1, conststring32 channelName2) {
integer channelNumber1 = EEG_getChannelNumber (me, channelName1);
if (channelNumber1 == 0)
Melder_throw (me, U": no channel named \"", channelNumber1_text, U"\".");
integer channelNumber2 = EEG_getChannelNumber (me, channelNumber2_text);
if (channelNumber2 == 0 && channelNumber2_text [0] != '\0')
Melder_throw (me, U": no channel named \"", channelNumber2_text, U"\".");
Melder_throw (me, U": no channel named \"", channelName1, U"\".");
integer channelNumber2 = EEG_getChannelNumber (me, channelName2);
if (channelNumber2 == 0 && channelName2 [0] != '\0')
Melder_throw (me, U": no channel named \"", channelName2, U"\".");
const integer numberOfElectrodeChannels = my numberOfChannels - EEG_getNumberOfExtraSensors (me);
for (integer isamp = 1; isamp <= my sound -> nx; isamp ++) {
double referenceValue = channelNumber2 == 0 ? my sound -> z [channelNumber1] [isamp] :
......@@ -523,7 +520,7 @@ void EEG_setChannelToZero (EEG me, integer channelNumber) {
}
}
void EEG_setChannelToZero (EEG me, const char32 *channelName) {
void EEG_setChannelToZero (EEG me, conststring32 channelName) {
try {
integer channelNumber = EEG_getChannelNumber (me, channelName);
if (channelNumber == 0)
......@@ -534,9 +531,9 @@ void EEG_setChannelToZero (EEG me, const char32 *channelName) {
}
}
void EEG_removeTriggers (EEG me, kMelder_string which, const char32 *criterion) {
void EEG_removeTriggers (EEG me, kMelder_string which, conststring32 criterion) {
try {
if (my textgrid -> tiers->size < 2 || ! Melder_equ (my textgrid -> tiers->at [2] -> name, U"Trigger"))
if (my textgrid -> tiers->size < 2 || ! Melder_equ (my textgrid -> tiers->at [2] -> name.get(), U"Trigger"))
Melder_throw (me, U" does not have a Trigger channel.");
TextGrid_removePoints (my textgrid.get(), 2, which, criterion);
} catch (MelderError) {
......@@ -550,8 +547,8 @@ autoEEG EEG_extractChannel (EEG me, integer channelNumber) {
Melder_throw (U"No channel ", channelNumber, U".");
autoEEG thee = EEG_create (my xmin, my xmax);
thy numberOfChannels = 1;
thy channelNames = NUMvector <char32 *> (1, 1);
thy channelNames [1] = Melder_dup (my channelNames [1]);
thy channelNames = autostring32vector (1);
thy channelNames [1] = Melder_dup (my channelNames [1].get());
thy sound = Sound_extractChannel (my sound.get(), channelNumber);
thy textgrid = Data_copy (my textgrid.get());
return thee;
......@@ -560,7 +557,7 @@ autoEEG EEG_extractChannel (EEG me, integer channelNumber) {
}
}
autoEEG EEG_extractChannel (EEG me, const char32 *channelName) {
autoEEG EEG_extractChannel (EEG me, conststring32 channelName) {
try {
integer channelNumber = EEG_getChannelNumber (me, channelName);
if (channelNumber == 0)
......@@ -571,7 +568,7 @@ autoEEG EEG_extractChannel (EEG me, const char32 *channelName) {
}
}
autoEEG EEG_extractChannels (EEG me, numvec channelNumbers) {
autoEEG EEG_extractChannels (EEG me, constVEC channelNumbers) {
try {
integer numberOfChannels = channelNumbers.size;
Melder_require (numberOfChannels > 0,
......@@ -579,10 +576,10 @@ autoEEG EEG_extractChannels (EEG me, numvec channelNumbers) {
autoEEG you = EEG_create (my xmin, my xmax);
your sound = Sound_extractChannels (my sound.get(), channelNumbers);
your numberOfChannels = numberOfChannels;
your channelNames = NUMvector <char32 *> (1, numberOfChannels);
your channelNames = autostring32vector (numberOfChannels);
for (integer ichan = 1; ichan <= numberOfChannels; ichan ++) {
integer originalChannelNumber = Melder_iround (channelNumbers [ichan]);
your channelNames [ichan] = Melder_dup (my channelNames [originalChannelNumber]);
your channelNames [ichan] = Melder_dup (my channelNames [originalChannelNumber].get());
}
your textgrid = Data_copy (my textgrid.get());
return you;
......@@ -611,10 +608,10 @@ void EEG_removeChannel (EEG me, integer channelNumber) {
try {
if (channelNumber < 1 || channelNumber > my numberOfChannels)
Melder_throw (U"No channel ", channelNumber, U".");
Melder_free (my channelNames [channelNumber]);
for (integer ichan = channelNumber; ichan < my numberOfChannels; ichan ++) {
my channelNames [ichan] = my channelNames [ichan + 1];
my channelNames [ichan] = my channelNames [ichan + 1].move();
}
my channelNames [my numberOfChannels]. reset();
my numberOfChannels -= 1;
Sound_removeChannel (my sound.get(), channelNumber);
} catch (MelderError) {
......@@ -622,7 +619,7 @@ void EEG_removeChannel (EEG me, integer channelNumber) {
}
}
void EEG_removeChannel (EEG me, const char32 *channelName) {
void EEG_removeChannel (EEG me, conststring32 channelName) {
try {
integer channelNumber = EEG_getChannelNumber (me, channelName);
if (channelNumber == 0)
......@@ -639,14 +636,16 @@ autoEEG EEGs_concatenate (OrderedOf<structEEG>* me) {
Melder_throw (U"Cannot concatenate zero EEG objects.");
EEG first = my at [1];
integer numberOfChannels = first -> numberOfChannels;
char32 **channelNames = first -> channelNames;
autostring32vector channelNames;
channelNames. copyFrom (first -> channelNames);
for (integer ieeg = 2; ieeg <= my size; ieeg ++) {
EEG other = my at [ieeg];
if (other -> numberOfChannels != numberOfChannels)
Melder_throw (U"The number of channels of ", other, U" does not match the number of channels of ", first, U".");
for (integer ichan = 1; ichan <= numberOfChannels; ichan ++) {
if (! Melder_equ (other -> channelNames [ichan], channelNames [ichan]))
Melder_throw (U"Channel ", ichan, U" has a different name in ", other, U" (", other -> channelNames [ichan], U") than in ", first, U" (", channelNames [ichan], U").");
if (! Melder_equ (other -> channelNames [ichan].get(), channelNames [ichan].get()))
Melder_throw (U"Channel ", ichan, U" has a different name in ", other,
U" (", other -> channelNames [ichan].get(), U") than in ", first, U" (", channelNames [ichan].get(), U").");
}
}
OrderedOf<structSound> soundList;
......@@ -658,10 +657,7 @@ autoEEG EEGs_concatenate (OrderedOf<structEEG>* me) {
}
autoEEG thee = Thing_new (EEG);
thy numberOfChannels = numberOfChannels;
thy channelNames = NUMvector <char32 *> (1, numberOfChannels);
for (integer ichan = 1; ichan <= numberOfChannels; ichan ++) {
thy channelNames [ichan] = Melder_dup (channelNames [ichan]);
}
thy channelNames = std::move (channelNames);
thy sound = Sounds_concatenate (soundList, 0.0);
thy textgrid = TextGrids_concatenate (& textgridList);
thy xmin = thy textgrid -> xmin;
......@@ -676,10 +672,7 @@ autoEEG EEG_extractPart (EEG me, double tmin, double tmax, bool preserveTimes) {
try {
autoEEG thee = Thing_new (EEG);
thy numberOfChannels = my numberOfChannels;
thy channelNames = NUMvector <char32 *> (1, my numberOfChannels);
for (integer ichan = 1; ichan <= my numberOfChannels; ichan ++) {
thy channelNames [ichan] = Melder_dup (my channelNames [ichan]);
}
thy channelNames. copyFrom (my channelNames);
thy sound = Sound_extractPart (my sound.get(), tmin, tmax, kSound_windowShape::RECTANGULAR, 1.0, preserveTimes);
thy textgrid = TextGrid_extractPart (my textgrid.get(), tmin, tmax, preserveTimes);
thy xmin = thy textgrid -> xmin;
......@@ -707,7 +700,7 @@ autoMixingMatrix EEG_to_MixingMatrix (EEG me,
autoMixingMatrix thee = MixingMatrix_create (my sound -> ny, my sound -> ny);
MixingMatrix_setRandomGauss (thee.get(), 0.0, 1.0);
for (integer ichan = 1; ichan <= my numberOfChannels; ichan ++) {
TableOfReal_setRowLabel (thee.get(), ichan, my channelNames [ichan]);
TableOfReal_setRowLabel (thee.get(), ichan, my channelNames [ichan].get());
TableOfReal_setColumnLabel (thee.get(), ichan, Melder_cat (U"ic", ichan));
}
MixingMatrix_CrossCorrelationTableList_improveUnmixing (thee.get(), tables.get(), maxNumberOfIterations, tol, method);
......@@ -722,20 +715,16 @@ autoEEG EEG_MixingMatrix_to_EEG_unmix (EEG me, MixingMatrix you) {
U"To be able to unmix, the number of channels in ", me, U" (", my numberOfChannels, U")",
U" should be equal to the number of rows in ", you, U" (", your numberOfRows, U").");
for (integer ichan = 1; ichan <= your numberOfRows; ichan ++) {
Melder_require (Melder_equ (my channelNames [ichan], your rowLabels [ichan]),
Melder_require (Melder_equ (my channelNames [ichan].get(), your rowLabels [ichan].get()),
U"To be able to unmix, the name of channel ", ichan,
U" should be the same in ", me, U" (where it is ", my channelNames [ichan], U")",
U" as in ", you, U" (where it is ", your rowLabels [ichan], U").");
U" should be the same in ", me, U" (where it is ", my channelNames [ichan].get(), U")",
U" as in ", you, U" (where it is ", your rowLabels [ichan].get(), U").");
}
autoEEG him = EEG_create (my xmin, my xmax);
his sound = Sound_MixingMatrix_unmix (my sound.get(), you);
his textgrid = Data_copy (my textgrid.get());
his numberOfChannels = your numberOfColumns;
his channelNames = NUMvector <char32 *> (1, his numberOfChannels);
//his channelNames = NUMstrings_copy (your columnLabels, 1, his numberOfChannels);
for (integer ichan = 1; ichan <= his numberOfChannels; ichan ++) {
his channelNames [ichan] = Melder_dup (your columnLabels [ichan]);
}
his channelNames. copyFrom (your columnLabels);
return him;
}
......@@ -744,20 +733,16 @@ autoEEG EEG_MixingMatrix_to_EEG_mix (EEG me, MixingMatrix you) {
U"To be able to mix, the number of channels in ", me, U" (", my numberOfChannels, U")",
U" should be equal to the number of columns in ", you, U" (", your numberOfColumns, U").");
for (integer ichan = 1; ichan <= your numberOfColumns; ichan ++) {
Melder_require (Melder_equ (my channelNames [ichan], your columnLabels [ichan]),
Melder_require (Melder_equ (my channelNames [ichan].get(), your columnLabels [ichan].get()),
U"To be able to mix, the name of channel ", ichan,
U" should be the same in ", me, U" (where it is ", my channelNames [ichan], U")",
U" as in ", you, U" (where it is ", your columnLabels [ichan], U").");
U" should be the same in ", me, U" (where it is ", my channelNames [ichan].get(), U")",
U" as in ", you, U" (where it is ", your columnLabels [ichan].get(), U").");
}
autoEEG him = EEG_create (my xmin, my xmax);
his sound = Sound_MixingMatrix_mix (my sound.get(), you);
his textgrid = Data_copy (my textgrid.get());
his numberOfChannels = your numberOfRows;
his channelNames = NUMvector <char32 *> (1, his numberOfChannels);
//his channelNames = NUMstrings_copy (your rowLabels, 1, his numberOfChannels);
for (integer ichan = 1; ichan <= his numberOfChannels; ichan ++) {
his channelNames [ichan] = Melder_dup (your rowLabels [ichan]);
}
his channelNames. copyFrom (your rowLabels);
return him;
}
......
......@@ -2,7 +2,7 @@
#define _EEG_h_
/* EEG.h
*
* Copyright (C) 2011-2012,2014,2015,2017,2018 Paul Boersma
* Copyright (C) 2011-2012,2014-2018 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -31,8 +31,8 @@ autoEEG EEG_readFromBdfFile (MelderFile file);
autoEEG EEGs_concatenate (OrderedOf<structEEG>* me);
void EEG_init (EEG me, double tmin, double tmax);
integer EEG_getChannelNumber (EEG me, const char32 *channelName);
void EEG_setChannelName (EEG me, integer channelNumber, const char32 *a_name);
integer EEG_getChannelNumber (EEG me, conststring32 channelName);
void EEG_setChannelName (EEG me, integer channelNumber, conststring32 newName);
static inline integer EEG_getNumberOfCapElectrodes (EEG me) {
return (my numberOfChannels - 1) & ~ 15L; // BUG
}
......@@ -42,20 +42,20 @@ static inline integer EEG_getNumberOfExtraSensors (EEG me) {
static inline integer EEG_getNumberOfExternalElectrodes (EEG me) {
return my numberOfChannels - EEG_getNumberOfCapElectrodes (me) - EEG_getNumberOfExtraSensors (me);
}
void EEG_setExternalElectrodeNames (EEG me, const char32 *nameExg1, const char32 *nameExg2, const char32 *nameExg3, const char32 *nameExg4,
const char32 *nameExg5, const char32 *nameExg6, const char32 *nameExg7, const char32 *nameExg8);
void EEG_setExternalElectrodeNames (EEG me, conststring32 nameExg1, conststring32 nameExg2, conststring32 nameExg3, conststring32 nameExg4,
conststring32 nameExg5, conststring32 nameExg6, conststring32 nameExg7, conststring32 nameExg8);
void EEG_detrend (EEG me);
void EEG_filter (EEG me, double lowFrequency, double lowWidth, double highFrequency, double highWidth, bool doNotch50Hz);
void EEG_subtractReference (EEG me, const char32 *channelNumber1, const char32 *channelNumber2);
void EEG_subtractReference (EEG me, conststring32 channelName1, conststring32 channelName2);
void EEG_subtractMeanChannel (EEG me, integer fromChannel, integer toChannel);
void EEG_setChannelToZero (EEG me, integer channelNumber);
void EEG_setChannelToZero (EEG me, const char32 *channelName);
void EEG_removeTriggers (EEG me, kMelder_string which, const char32 *criterion);
void EEG_setChannelToZero (EEG me, conststring32 channelName);
void EEG_removeTriggers (EEG me, kMelder_string which, conststring32 criterion);
autoEEG EEG_extractChannel (EEG me, integer channelNumber);
autoEEG EEG_extractChannel (EEG me, const char32 *channelName);
autoEEG EEG_extractChannels (EEG me, numvec channelNumbers);
autoEEG EEG_extractChannel (EEG me, conststring32 channelName);
autoEEG EEG_extractChannels (EEG me, constVEC channelNumbers);
void EEG_removeChannel (EEG me, integer channelNumber);
void EEG_removeChannel (EEG me, const char32 *channelName);
void EEG_removeChannel (EEG me, conststring32 channelName);
static inline autoSound EEG_extractSound (EEG me) { return Data_copy (my sound.get()); }
static inline autoTextGrid EEG_extractTextGrid (EEG me) { return Data_copy (my textgrid.get()); }
autoEEG EEG_extractPart (EEG me, double tmin, double tmax, bool preserveTimes);
......
......@@ -39,9 +39,9 @@ void structEEGWindow :: v_createHelpMenuItems (EditorMenu menu) {
EditorMenu_addCommand (menu, U"EEGWindow help", '?', menu_cb_EEGWindowHelp);
}
const char32 * structEEGWindow :: v_getChannelName (integer channelNumber) {
conststring32 structEEGWindow :: v_getChannelName (integer channelNumber) {
Melder_assert (our eeg != nullptr);
return our eeg -> channelNames [channelNumber];
return our eeg -> channelNames [channelNumber].get();
}
static void menu_cb_ExtractSelectedEEG_preserveTimes (EEGWindow me, EDITOR_ARGS_DIRECT) {
......@@ -70,12 +70,12 @@ void structEEGWindow :: v_updateMenuItems_file () {
GuiThing_setSensitive (our extractSelectedEEGTimeFromZeroButton, our endSelection > our startSelection);
}
void EEGWindow_init (EEGWindow me, const char32 *title, EEG eeg) {
void EEGWindow_init (EEGWindow me, conststring32 title, EEG eeg) {
my eeg = eeg; // before initing, because initing will already draw!
TextGridEditor_init (me, title, eeg -> textgrid.get(), eeg -> sound.get(), false, nullptr, nullptr);
}
autoEEGWindow EEGWindow_create (const char32 *title, EEG eeg) {
autoEEGWindow EEGWindow_create (conststring32 title, EEG eeg) {
try {
autoEEGWindow me = Thing_new (EEGWindow);
EEGWindow_init (me.get(), title, eeg);
......
......@@ -2,7 +2,7 @@
#define _EEGWindow_h_
/* EEGWindow.h
*
* Copyright (C) 2011-2012,2013,2014,2015,2017 Paul Boersma
* Copyright (C) 2011-2018 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -37,7 +37,7 @@ Thing_define (EEGWindow, TextGridEditor) {
override;
void v_createHelpMenuItems (EditorMenu menu)
override;
const char32 * v_getChannelName (integer channelNumber)
conststring32 v_getChannelName (integer channelNumber)
override;
void v_createMenuItems_file_extract (EditorMenu menu)
override;
......@@ -47,9 +47,9 @@ Thing_define (EEGWindow, TextGridEditor) {
#include "EEGWindow_prefs.h"
};
void EEGWindow_init (EEGWindow me, const char32 *title, EEG eeg);
void EEGWindow_init (EEGWindow me, conststring32 title, EEG eeg);
autoEEGWindow EEGWindow_create (const char32 *title, EEG eeg);
autoEEGWindow EEGWindow_create (conststring32 title, EEG eeg);
/* End of file EEGWindow.h */
#endif
......@@ -22,8 +22,8 @@ oo_DEFINE_CLASS (EEG, Function)
oo_INTEGER (numberOfChannels)
oo_STRING_VECTOR (channelNames, numberOfChannels)
oo_AUTO_OBJECT (Sound, 2, sound)
oo_AUTO_OBJECT (TextGrid, 0, textgrid)
oo_OBJECT (Sound, 2, sound)
oo_OBJECT (TextGrid, 0, textgrid)
#if oo_DECLARING
void v_info ()
......
......@@ -41,12 +41,11 @@
Thing_implement (ERP, Sound, 2);
integer ERP_getChannelNumber (ERP me, const char32 *channelName) {
integer ERP_getChannelNumber (ERP me, conststring32 channelName) {
for (integer ichan = 1; ichan <= my ny; ichan ++) {
if (Melder_equ (my channelNames [ichan], channelName)) {
if (Melder_equ (my channelNames [ichan].get(), channelName))
return ichan;
}
}
return 0;
}
......@@ -83,7 +82,7 @@ void ERP_drawChannel_number (ERP me, Graphics graphics, integer channelNumber, d
Graphics_unsetInner (graphics);
if (garnish) {
Graphics_drawInnerBox (graphics);
Graphics_textTop (graphics, true, Melder_cat (U"Channel ", my channelNames [channelNumber]));
Graphics_textTop (graphics, true, Melder_cat (U"Channel ", my channelNames [channelNumber].get()));
Graphics_textBottom (graphics, true, U"Time (s)");
Graphics_marksBottom (graphics, 2, true, true, false);
if (0.0 > tmin && 0.0 < tmax)
......@@ -98,13 +97,13 @@ void ERP_drawChannel_number (ERP me, Graphics graphics, integer channelNumber, d
}
void ERP_drawChannel_name (ERP me, Graphics graphics, const char32 *channelName, double tmin, double tmax, double vmin, double vmax, bool garnish) {
void ERP_drawChannel_name (ERP me, Graphics graphics, conststring32 channelName, double tmin, double tmax, double vmin, double vmax, bool garnish) {
ERP_drawChannel_number (me, graphics, ERP_getChannelNumber (me, channelName), tmin, tmax, vmin, vmax, garnish);
}
autoTable ERP_tabulate (ERP me, bool includeSampleNumbers, bool includeTime, int timeDecimals, int voltageDecimals, int units) {
double voltageScaling = 1.0;
const char32 *unitText = U"(V)";
conststring32 unitText = U"(V)";
if (units == 2) {
voltageDecimals -= 6;
voltageScaling = 1000000.0;
......@@ -116,7 +115,7 @@ autoTable ERP_tabulate (ERP me, bool includeSampleNumbers, bool includeTime, int
if (includeSampleNumbers) Table_setColumnLabel (thee.get(), ++ icol, U"sample");
if (includeTime) Table_setColumnLabel (thee.get(), ++ icol, U"time(s)");
for (integer ichan = 1; ichan <= my ny; ichan ++) {
Table_setColumnLabel (thee.get(), ++ icol, Melder_cat (my channelNames [ichan], unitText));
Table_setColumnLabel (thee.get(), ++ icol, Melder_cat (my channelNames [ichan].get(), unitText));
}
for (integer isamp = 1; isamp <= my nx; isamp ++) {
icol = 0;
......
......@@ -2,7 +2,7 @@
#define _ERP_h_
/* ERP.h
*
* Copyright (C) 2011,2014,2015,2017 Paul Boersma
* Copyright (C) 2011,2012,2014-2018 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -25,7 +25,7 @@
/**
Look up the channel number from its name.
*/
integer ERP_getChannelNumber (ERP me, const char32 *channelName);
integer ERP_getChannelNumber (ERP me, conststring32 channelName);
/**
* Draw the scalp distribution.
......@@ -38,7 +38,7 @@ void ERP_drawScalp (ERP me,
void ERP_drawScalp_garnish (Graphics graphics, double vmin, double vmax, enum kGraphics_colourScale colourScale);
void ERP_drawChannel_number (ERP me, Graphics graphics, integer channelNumber, double tmin, double tmax, double vmin, double vmax, bool garnish);
void ERP_drawChannel_name (ERP me, Graphics graphics, const char32 *channelName, double tmin, double tmax, double vmin, double vmax, bool garnish);
void ERP_drawChannel_name (ERP me, Graphics graphics, conststring32 channelName, double tmin, double tmax, double vmin, double vmax, bool garnish);
autoTable ERP_tabulate (ERP me, bool includeSampleNumbers, bool includeTime, int timeDecimals, int voltageDecimals, int units);
......
......@@ -45,9 +45,9 @@ Thing_implement (ERPPoint, AnyPoint, 0);
Thing_implement (ERPTier, AnyTier, 0);
integer ERPTier_getChannelNumber (ERPTier me, const char32 *channelName) {
integer ERPTier_getChannelNumber (ERPTier me, conststring32 channelName) {
for (integer ichan = 1; ichan <= my numberOfChannels; ichan ++) {
if (Melder_equ (my channelNames [ichan], channelName)) {
if (Melder_equ (my channelNames [ichan].get(), channelName)) {
return ichan;
}
}
......@@ -61,7 +61,7 @@ double ERPTier_getMean (ERPTier me, integer pointNumber, integer channelNumber,
return Vector_getMean (point -> erp.get(), tmin, tmax, channelNumber);
}
double ERPTier_getMean (ERPTier me, integer pointNumber, const char32 *channelName, double tmin, double tmax) {
double ERPTier_getMean (ERPTier me, integer pointNumber, conststring32 channelName, double tmin, double tmax) {
return ERPTier_getMean (me, pointNumber, ERPTier_getChannelNumber (me, channelName), tmin, tmax);
}
......@@ -71,10 +71,7 @@ static autoERPTier EEG_PointProcess_to_ERPTier (EEG me, PointProcess events, dou
Function_init (thee.get(), fromTime, toTime);
thy numberOfChannels = my numberOfChannels - EEG_getNumberOfExtraSensors (me);
Melder_assert (thy numberOfChannels > 0);
thy channelNames = NUMvector <char32 *> (1, thy numberOfChannels);
for (integer ichan = 1; ichan <= thy numberOfChannels; ichan ++) {
thy channelNames [ichan] = Melder_dup (my channelNames [ichan]);
}
thy channelNames. copyFrom (my channelNames);
integer numberOfEvents = events -> nt;
double soundDuration = toTime - fromTime;
double samplingPeriod = my sound -> dx;
......@@ -117,7 +114,7 @@ autoERPTier EEG_to_ERPTier_bit (EEG me, double fromTime, double toTime, int mark
}
}
static autoPointProcess TextGrid_getStartingPoints_multiNumeric (TextGrid me, uint16_t number) {
static autoPointProcess TextGrid_getStartingPoints_multiNumeric (TextGrid me, uint16 number) {
try {
autoPointProcess thee;
int numberOfBits = my tiers->size;
......@@ -148,7 +145,7 @@ static autoPointProcess TextGrid_getStartingPoints_multiNumeric (TextGrid me, ui
}
}
autoERPTier EEG_to_ERPTier_marker (EEG me, double fromTime, double toTime, uint16_t marker) {
autoERPTier EEG_to_ERPTier_marker (EEG me, double fromTime, double toTime, uint16 marker) {
try {
autoPointProcess events = TextGrid_getStartingPoints_multiNumeric (my textgrid.get(), marker);
autoERPTier thee = EEG_PointProcess_to_ERPTier (me, events.get(), fromTime, toTime);
......@@ -159,7 +156,7 @@ autoERPTier EEG_to_ERPTier_marker (EEG me, double fromTime, double toTime, uint1
}
autoERPTier EEG_to_ERPTier_triggers (EEG me, double fromTime, double toTime,
kMelder_string which, const char32 *criterion)
kMelder_string which, conststring32 criterion)
{
try {
autoPointProcess events = TextGrid_getPoints (my textgrid.get(), 2, which, criterion);
......@@ -171,8 +168,8 @@ autoERPTier EEG_to_ERPTier_triggers (EEG me, double fromTime, double toTime,
}
autoERPTier EEG_to_ERPTier_triggers_preceded (EEG me, double fromTime, double toTime,
kMelder_string which, const char32 *criterion,
kMelder_string precededBy, const char32 *criterion_precededBy)
kMelder_string which, conststring32 criterion,
kMelder_string precededBy, conststring32 criterion_precededBy)
{
try {
autoPointProcess events = TextGrid_getPoints_preceded (my textgrid.get(), 2,
......@@ -238,6 +235,7 @@ autoERP ERPTier_extractERP (ERPTier me, integer eventNumber) {
ERPTier_checkEventNumber (me, eventNumber);
ERPPoint event = my points.at [eventNumber];
integer numberOfChannels = event -> erp -> ny;
Melder_assert (numberOfChannels == my numberOfChannels);
integer numberOfSamples = event -> erp -> nx;
autoERP thee = Thing_new (ERP);
event -> erp -> structSound :: v_copy (thee.get());
......@@ -248,10 +246,7 @@ autoERP ERPTier_extractERP (ERPTier me, integer eventNumber) {
newChannel [isample] = oldChannel [isample];
}
}
thy channelNames = NUMvector <char32 *> (1, thy ny);
for (integer ichan = 1; ichan <= thy ny; ichan ++) {
thy channelNames [ichan] = Melder_dup (my channelNames [ichan]);
}
thy channelNames. copyFrom (my channelNames);
return thee;
} catch (MelderError) {
Melder_throw (me, U": ERP not extracted.");
......@@ -285,10 +280,8 @@ autoERP ERPTier_to_ERP_mean (ERPTier me) {
meanChannel [isample] *= factor;
}
}
mean -> channelNames = NUMvector <char32 *> (1, mean -> ny);
for (integer ichan = 1; ichan <= mean -> ny; ichan ++) {
mean -> channelNames [ichan] = Melder_dup (my channelNames [ichan]);
}
Melder_assert (mean -> ny == my numberOfChannels);
mean -> channelNames. copyFrom (my channelNames);
return mean;
} catch (MelderError) {
Melder_throw (me, U": mean not computed.");
......@@ -305,16 +298,13 @@ autoERPTier ERPTier_extractEventsWhereColumn_number (ERPTier me, Table table, in
autoERPTier thee = Thing_new (ERPTier);
Function_init (thee.get(), my xmin, my xmax);
thy numberOfChannels = my numberOfChannels;
thy channelNames = NUMvector <char32 *> (1, thy numberOfChannels);
for (integer ichan = 1; ichan <= thy numberOfChannels; ichan ++) {
thy channelNames [ichan] = Melder_dup (my channelNames [ichan]);
}
thy channelNames. copyFrom (my channelNames);
for (integer ievent = 1; ievent <= my points.size; ievent ++) {
ERPPoint oldEvent = my points.at [ievent];
TableRow row = table -> rows.at [ievent];
if (Melder_numberMatchesCriterion (row -> cells [columnNumber]. number, which, criterion)) {
autoERPPoint newEvent = Data_copy (oldEvent);
thy points. addItem_move (newEvent.move());
thy points. addItem_move (std::move (newEvent));
}
}
if (thy points.size == 0) {
......@@ -327,7 +317,7 @@ autoERPTier ERPTier_extractEventsWhereColumn_number (ERPTier me, Table table, in
}
autoERPTier ERPTier_extractEventsWhereColumn_string (ERPTier me, Table table,
integer columnNumber, kMelder_string which, const char32 *criterion)
integer columnNumber, kMelder_string which, conststring32 criterion)
{
try {
Table_checkSpecifiedColumnNumberWithinRange (table, columnNumber);
......@@ -337,16 +327,13 @@ autoERPTier ERPTier_extractEventsWhereColumn_string (ERPTier me, Table table,
autoERPTier thee = Thing_new (ERPTier);
Function_init (thee.get(), my xmin, my xmax);
thy numberOfChannels = my numberOfChannels;
thy channelNames = NUMvector <char32 *> (1, thy numberOfChannels);
for (integer ichan = 1; ichan <= thy numberOfChannels; ichan ++) {
thy channelNames [ichan] = Melder_dup (my channelNames [ichan]);
}
thy channelNames. copyFrom (my channelNames);
for (integer ievent = 1; ievent <= my points.size; ievent ++) {
ERPPoint oldEvent = my points.at [ievent];
TableRow row = table -> rows.at [ievent];
if (Melder_stringMatchesCriterion (row -> cells [columnNumber]. string, which, criterion, true)) {
if (Melder_stringMatchesCriterion (row -> cells [columnNumber]. string.get(), which, criterion, true)) {
autoERPPoint newEvent = Data_copy (oldEvent);
thy points. addItem_move (newEvent.move());
thy points. addItem_move (std::move (newEvent));
}
}
if (thy points.size == 0) {
......
......@@ -2,7 +2,7 @@
#define _ERPTier_h_
/* ERPTier.h
*
* Copyright (C) 2011,2014,2015,2017 Paul Boersma
* Copyright (C) 2011,2012,2014-2018 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -23,7 +23,7 @@
#include "ERPTier_def.h"
integer ERPTier_getChannelNumber (ERPTier me, const char32 *channelName);
integer ERPTier_getChannelNumber (ERPTier me, conststring32 channelName);
static inline void ERPTier_checkEventNumber (ERPTier me, integer eventNumber) {
if (eventNumber < 1)
Melder_throw (U"The specified event number is ", eventNumber, U" but should have been positive.");
......@@ -31,21 +31,21 @@ static inline void ERPTier_checkEventNumber (ERPTier me, integer eventNumber) {
Melder_throw (U"The specified event number (", eventNumber, U") exceeds the number of events (", my points.size, U").");
}
double ERPTier_getMean (ERPTier me, integer pointNumber, integer channelNumber, double tmin, double tmax);
double ERPTier_getMean (ERPTier me, integer pointNumber, const char32 *channelName, double tmin, double tmax);
double ERPTier_getMean (ERPTier me, integer pointNumber, conststring32 channelName, double tmin, double tmax);
void ERPTier_subtractBaseline (ERPTier me, double tmin, double tmax);
void ERPTier_rejectArtefacts (ERPTier me, double threshold);
autoERP ERPTier_extractERP (ERPTier me, integer pointNumber);
autoERP ERPTier_to_ERP_mean (ERPTier me);
autoERPTier ERPTier_extractEventsWhereColumn_number (ERPTier me, Table table, integer columnNumber, kMelder_number which, double criterion);
autoERPTier ERPTier_extractEventsWhereColumn_string (ERPTier me, Table table, integer columnNumber, kMelder_string which, const char32 *criterion);
autoERPTier ERPTier_extractEventsWhereColumn_string (ERPTier me, Table table, integer columnNumber, kMelder_string which, conststring32 criterion);
autoERPTier EEG_to_ERPTier_bit (EEG me, double fromTime, double toTime, int markerBit);
autoERPTier EEG_to_ERPTier_marker (EEG me, double fromTime, double toTime, uint16 marker);
autoERPTier EEG_to_ERPTier_triggers (EEG me, double fromTime, double toTime,
kMelder_string which, const char32 *criterion);
kMelder_string which, conststring32 criterion);
autoERPTier EEG_to_ERPTier_triggers_preceded (EEG me, double fromTime, double toTime,
kMelder_string which, const char32 *criterion,
kMelder_string precededBy, const char32 *criterion_precededBy);
kMelder_string which, conststring32 criterion,
kMelder_string precededBy, conststring32 criterion_precededBy);
/* End of file ERPTier.h */
#endif
......@@ -20,7 +20,7 @@
#define ooSTRUCT ERPPoint
oo_DEFINE_CLASS (ERPPoint, AnyPoint)
oo_AUTO_OBJECT (Sound, 2, erp)
oo_OBJECT (Sound, 2, erp)
oo_END_CLASS (ERPPoint)
#undef ooSTRUCT
......
/* ERPWindow.cpp
*
* Copyright (C) 2012,2013,2014,2015,2016,2017 Paul Boersma
* Copyright (C) 2012-2018 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -151,7 +151,7 @@ static BiosemiLocationData biosemiCapCoordinates32 [1+32] =
void ERP_drawScalp_garnish (Graphics graphics, double vmin, double vmax, enum kGraphics_colourScale colourScale) {
integer n = 201;
autonummat legend (n, 2, kTensorInitializationType::RAW);
autoMAT legend (n, 2, kTensorInitializationType::RAW);
for (integer irow = 1; irow <= n; irow ++) {
for (integer icol = 1; icol <= 2; icol ++) {
legend [irow] [icol] = (irow - 1) / (n - 1.0);
......@@ -174,8 +174,8 @@ void ERP_drawScalp (ERP me, Graphics graphics, double tmin, double tmax, double
//Graphics_fillRectangle (graphics, -1.1, 1.1, -1.01, 1.19);
//Graphics_setColour (graphics, Graphics_BLACK);
integer numberOfDrawableChannels =
my ny >= 64 && Melder_equ (my channelNames [64], U"O2") ? 64 :
my ny >= 32 && Melder_equ (my channelNames [32], U"Cz") ? 32 :
my ny >= 64 && Melder_equ (my channelNames [64].get(), U"O2") ? 64 :
my ny >= 32 && Melder_equ (my channelNames [32].get(), U"Cz") ? 32 :
0;
BiosemiLocationData *biosemiLocationData = numberOfDrawableChannels == 64 ? biosemiCapCoordinates64 : numberOfDrawableChannels == 32 ? biosemiCapCoordinates32 : 0;
for (integer ichan = 1; ichan <= numberOfDrawableChannels; ichan ++) {
......@@ -189,13 +189,13 @@ void ERP_drawScalp (ERP me, Graphics graphics, double tmin, double tmax, double
}
integer n = 201;
double d = 2.0 / (n - 1);
autonumvec mean (numberOfDrawableChannels, kTensorInitializationType::RAW);
autoVEC mean (numberOfDrawableChannels, kTensorInitializationType::RAW);
for (integer ichan = 1; ichan <= numberOfDrawableChannels; ichan ++) {
mean [ichan] = tmin == tmax ?
Sampled_getValueAtX (me, tmin, ichan, 0, true) :
Vector_getMean (me, tmin, tmax, ichan);
}
autonummat image (n, n, kTensorInitializationType::RAW);
autoMAT image (n, n, kTensorInitializationType::RAW);
for (integer irow = 1; irow <= n; irow ++) {
double y = -1.0 + (irow - 1) * d;
for (integer icol = 1; icol <= n; icol ++) {
......@@ -277,8 +277,8 @@ void structERPWindow :: v_drawSelectionViewer () {
Graphics_fillRectangle (our graphics.get(), -1.1, 1.1, -1.01, 1.19);
Graphics_setColour (our graphics.get(), Graphics_BLACK);
integer numberOfDrawableChannels =
erp -> ny >= 64 && Melder_equ (erp -> channelNames [64], U"O2") ? 64 :
erp -> ny >= 32 && Melder_equ (erp -> channelNames [32], U"Cz") ? 32 :
erp -> ny >= 64 && Melder_equ (erp -> channelNames [64].get(), U"O2") ? 64 :
erp -> ny >= 32 && Melder_equ (erp -> channelNames [32].get(), U"Cz") ? 32 :
0;
BiosemiLocationData *biosemiLocationData = numberOfDrawableChannels == 64 ? biosemiCapCoordinates64 : numberOfDrawableChannels == 32 ? biosemiCapCoordinates32 : 0;
for (integer ichan = 1; ichan <= numberOfDrawableChannels; ichan ++) {
......@@ -292,14 +292,14 @@ void structERPWindow :: v_drawSelectionViewer () {
}
integer n = 201;
double d = 2.0 / (n - 1);
autonumvec means (numberOfDrawableChannels, kTensorInitializationType::RAW);
autoVEC means (numberOfDrawableChannels, kTensorInitializationType::RAW);
for (integer ichan = 1; ichan <= numberOfDrawableChannels; ichan ++) {
means [ichan] =
our startSelection == our endSelection ?
Sampled_getValueAtX (erp, our startSelection, ichan, 0, true) :
Vector_getMean (erp, our startSelection, our endSelection, ichan);
}
autonummat image (n, n, kTensorInitializationType::RAW);
autoMAT image (n, n, kTensorInitializationType::RAW);
for (integer irow = 1; irow <= n; irow ++) {
double y = -1.0 + (irow - 1) * d;
for (integer icol = 1; icol <= n; icol ++) {
......@@ -403,7 +403,7 @@ void structERPWindow :: v_prefs_getValues (EditorCommand /* cmd */) {
FunctionEditor_redraw (this);
}
autoERPWindow ERPWindow_create (const char32 *title, ERP data) {
autoERPWindow ERPWindow_create (conststring32 title, ERP data) {
Melder_assert (data);
try {
autoERPWindow me = Thing_new (ERPWindow);
......
......@@ -2,7 +2,7 @@
#define _ERPWindow_h_
/* ERPWindow.h
*
* Copyright (C) 2012,2013,2014,2015,2017 Paul Boersma
* Copyright (C) 2012-2018 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -22,10 +22,10 @@
#include "ERP.h"
Thing_define (ERPWindow, SoundEditor) {
const char32 * v_getChannelName (integer channelNumber)
conststring32 v_getChannelName (integer channelNumber)
override {
ERP erp = (ERP) our data;
return erp -> channelNames [channelNumber];
return erp -> channelNames [channelNumber].get();
}
void v_drawSelectionViewer ()
override;
......@@ -50,7 +50,7 @@ Thing_define (ERPWindow, SoundEditor) {
/**
Create an ERPWindow.
*/
autoERPWindow ERPWindow_create (const char32 *title, ERP data);
autoERPWindow ERPWindow_create (conststring32 title, ERP data);
/* End of file ERPWindow.h */
#endif
# Makefile of the library "EEG"
# Paul Boersma, 8 August 2017
# Paul Boersma, 10 August 2018
include ../makefile.defs
CPPFLAGS = -I ../kar -I ../sys -I ../dwsys -I ../stat -I ../dwtools -I ../fon
CPPFLAGS = -I ../kar -I ../melder -I ../sys -I ../dwsys -I ../stat -I ../dwtools -I ../fon
OBJECTS = EEG.o EEGWindow.o ERPTier.o ERP.o ERPWindow.o \
praat_EEG.o manual_EEG.o
......@@ -22,4 +22,4 @@ libEEG.a: $(OBJECTS)
$(AR) cq libEEG.a $(OBJECTS)
$(RANLIB) libEEG.a
$(OBJECTS): *.h ../kar/*.h ../sys/*.h ../dwsys/*.h ../stat/*.h ../dwtools/*.h ../fon/*.h
$(OBJECTS): *.h ../kar/*.h ../melder/*.h ../sys/*.h ../dwsys/*.h ../stat/*.h ../dwtools/*.h ../fon/*.h
......@@ -71,7 +71,7 @@ DO
STRING_ONE (EEG)
if (channelNumber > my numberOfChannels)
Melder_throw (me, U": there are only ", my numberOfChannels, U" channels.");
const char32 *result = my channelNames [channelNumber];
conststring32 result = my channelNames [channelNumber].get();
STRING_ONE_END
}
......@@ -105,14 +105,14 @@ OK
FIND_ONE (EEG)
if (EEG_getNumberOfExternalElectrodes (me) == 8) {
const integer offsetExternalElectrode = EEG_getNumberOfCapElectrodes (me);
SET_STRING (externalElectrode1, my channelNames [offsetExternalElectrode + 1])
SET_STRING (externalElectrode2, my channelNames [offsetExternalElectrode + 2])
SET_STRING (externalElectrode3, my channelNames [offsetExternalElectrode + 3])
SET_STRING (externalElectrode4, my channelNames [offsetExternalElectrode + 4])
SET_STRING (externalElectrode5, my channelNames [offsetExternalElectrode + 5])
SET_STRING (externalElectrode6, my channelNames [offsetExternalElectrode + 6])
SET_STRING (externalElectrode7, my channelNames [offsetExternalElectrode + 7])
SET_STRING (externalElectrode8, my channelNames [offsetExternalElectrode + 8])
SET_STRING (externalElectrode1, my channelNames [offsetExternalElectrode + 1].get())
SET_STRING (externalElectrode2, my channelNames [offsetExternalElectrode + 2].get())
SET_STRING (externalElectrode3, my channelNames [offsetExternalElectrode + 3].get())
SET_STRING (externalElectrode4, my channelNames [offsetExternalElectrode + 4].get())
SET_STRING (externalElectrode5, my channelNames [offsetExternalElectrode + 5].get())
SET_STRING (externalElectrode6, my channelNames [offsetExternalElectrode + 6].get())
SET_STRING (externalElectrode7, my channelNames [offsetExternalElectrode + 7].get())
SET_STRING (externalElectrode8, my channelNames [offsetExternalElectrode + 8].get())
}
DO
MODIFY_EACH (EEG)
......@@ -204,7 +204,7 @@ FORM (NEW_EEG_extractChannel, U"EEG: Extract channel", nullptr) {
DO
CONVERT_EACH (EEG)
autoEEG result = EEG_extractChannel (me, channelName);
CONVERT_EACH_END (my name, U"_", channelName)
CONVERT_EACH_END (my name.get(), U"_", channelName)
}
FORM (NEW_EEG_extractChannels, U"EEG: Extract channels", nullptr) {
......@@ -213,7 +213,7 @@ FORM (NEW_EEG_extractChannels, U"EEG: Extract channels", nullptr) {
DO
CONVERT_EACH (EEG)
autoEEG result = EEG_extractChannels (me, channels);
CONVERT_EACH_END (my name, U"_ch")
CONVERT_EACH_END (my name.get(), U"_ch")
}
FORM (NEW_EEG_extractPart, U"EEG: Extract part", nullptr) {
......@@ -224,21 +224,21 @@ FORM (NEW_EEG_extractPart, U"EEG: Extract part", nullptr) {
DO
CONVERT_EACH (EEG)
autoEEG result = EEG_extractPart (me, fromTime, toTime, preserveTimes);
CONVERT_EACH_END (my name, U"_part")
CONVERT_EACH_END (my name.get(), 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)
CONVERT_EACH_END (my name.get())
}
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)
CONVERT_EACH_END (my name.get())
}
FORM (NEW_EEG_to_ERPTier_bit, U"To ERPTier (bit)", nullptr) {
......@@ -249,7 +249,7 @@ FORM (NEW_EEG_to_ERPTier_bit, U"To ERPTier (bit)", nullptr) {
DO
CONVERT_EACH (EEG)
autoERPTier result = EEG_to_ERPTier_bit (me, fromTime, toTime, markerBit);
CONVERT_EACH_END (my name, U"_bit", markerBit)
CONVERT_EACH_END (my name.get(), U"_bit", markerBit)
}
FORM (NEW_EEG_to_ERPTier_marker, U"To ERPTier (marker)", nullptr) {
......@@ -260,7 +260,7 @@ FORM (NEW_EEG_to_ERPTier_marker, U"To ERPTier (marker)", nullptr) {
DO
CONVERT_EACH (EEG)
autoERPTier result = EEG_to_ERPTier_marker (me, fromTime, toTime, (uint16) markerNumber);
CONVERT_EACH_END (my name, U"_", markerNumber)
CONVERT_EACH_END (my name.get(), U"_", markerNumber)
}
FORM (NEW_EEG_to_ERPTier_triggers, U"To ERPTier (triggers)", nullptr) {
......@@ -272,7 +272,7 @@ FORM (NEW_EEG_to_ERPTier_triggers, U"To ERPTier (triggers)", nullptr) {
DO
CONVERT_EACH (EEG)
autoERPTier result = EEG_to_ERPTier_triggers (me, fromTime, toTime, (kMelder_string) getEveryEventWithATriggerThat, theText);
CONVERT_EACH_END (my name, U"_trigger", theText)
CONVERT_EACH_END (my name.get(), U"_trigger", theText)
}
FORM (NEW_EEG_to_ERPTier_triggers_preceded, U"To ERPTier (triggers, preceded)", nullptr) {
......@@ -287,7 +287,7 @@ DO
CONVERT_EACH (EEG)
autoERPTier result = EEG_to_ERPTier_triggers_preceded (me, fromTime, toTime,
(kMelder_string) getEveryEventWithATriggerThat, text1, (kMelder_string) andIsPrecededByATriggerThat, text2);
CONVERT_EACH_END (my name, U"_trigger", text2)
CONVERT_EACH_END (my name.get(), U"_trigger", text2)
}
// MARK: Convert
......@@ -313,19 +313,19 @@ DO
autoMixingMatrix result = EEG_to_MixingMatrix (me,
startTime, endTime, numberOfCrossCorrelations, lagStep,
maximumNumberOfIterations, tolerance, diagonalizationMethod);
CONVERT_EACH_END (my name)
CONVERT_EACH_END (my name.get())
}
DIRECT (NEW_EEG_MixingMatrix_to_EEG_unmix) {
CONVERT_TWO (EEG, MixingMatrix)
autoEEG result = EEG_MixingMatrix_to_EEG_unmix (me, you);
CONVERT_TWO_END (my name, U"_", your name)
CONVERT_TWO_END (my name.get(), U"_", your name.get())
}
DIRECT (NEW_EEG_MixingMatrix_to_EEG_mix) {
CONVERT_TWO (EEG, MixingMatrix)
autoEEG result = EEG_MixingMatrix_to_EEG_mix (me, you);
CONVERT_TWO_END (my name, U"_", your name)
CONVERT_TWO_END (my name.get(), U"_", your name.get())
}
// MARK: - EEG & TextGrid
......@@ -384,7 +384,7 @@ DO
CONVERT_EACH (ERP)
autoTable result = ERP_tabulate (me, includeSampleNumber,
includeTime, timeDecimals, voltageDecimals, voltageUnits);
CONVERT_EACH_END (my name)
CONVERT_EACH_END (my name.get())
}
// MARK: Draw
......@@ -452,7 +452,7 @@ DO
STRING_ONE (ERP)
if (channelNumber > my ny)
Melder_throw (me, U": there are only ", my ny, U" channels.");
const char32 *result = my channelNames [channelNumber];
conststring32 result = my channelNames [channelNumber].get();
STRING_ONE_END
}
......@@ -599,7 +599,7 @@ DO
integer channelNumber = ERP_getChannelNumber (me, channelName);
if (channelNumber == 0) Melder_throw (me, U": no channel named \"", channelName, U"\".");
autoSound result = Sound_extractChannel (me, channelNumber);
CONVERT_EACH_END (my name, U"_", channelName)
CONVERT_EACH_END (my name.get(), U"_", channelName)
}
// MARK: Convert
......@@ -607,7 +607,7 @@ DO
DIRECT (NEW_ERP_downto_Sound) {
CONVERT_EACH (ERP)
autoSound result = ERP_downto_Sound (me);
CONVERT_EACH_END (my name)
CONVERT_EACH_END (my name.get())
}
// MARK: - ERPTIER
......@@ -627,7 +627,7 @@ DO
STRING_ONE (ERPTier)
if (channelNumber > my numberOfChannels)
Melder_throw (me, U": there are only ", my numberOfChannels, U" channels.");
const char32 *result = my channelNames [channelNumber];
conststring32 result = my channelNames [channelNumber].get();
STRING_ONE_END
}
......@@ -691,13 +691,13 @@ FORM (NEW_ERPTier_to_ERP, U"ERPTier: To ERP", nullptr) {
DO
CONVERT_EACH (ERPTier)
autoERP result = ERPTier_extractERP (me, eventNumber);
CONVERT_EACH_END (my name, U"_", eventNumber)
CONVERT_EACH_END (my name.get(), U"_", eventNumber)
}
DIRECT (NEW_ERPTier_to_ERP_mean) {
CONVERT_EACH (ERPTier)
autoERP result = ERPTier_to_ERP_mean (me);
CONVERT_EACH_END (my name, U"_mean")
CONVERT_EACH_END (my name.get(), U"_mean")
}
// MARK: - ERPTIER & TABLE
......@@ -711,7 +711,7 @@ DO
CONVERT_TWO (ERPTier, Table)
integer columnNumber = Table_getColumnIndexFromColumnLabel (you, extractAllEventsWhereColumn___);
autoERPTier result = ERPTier_extractEventsWhereColumn_number (me, you, columnNumber, (kMelder_number) ___is___, ___theNumber);
CONVERT_TWO_END (my name)
CONVERT_TWO_END (my name.get())
}
FORM (NEW1_ERPTier_Table_extractEventsWhereColumn_text, U"Extract events where column (text)", nullptr) {
......@@ -723,13 +723,13 @@ DO
CONVERT_TWO (ERPTier, Table)
integer columnNumber = Table_getColumnIndexFromColumnLabel (you, extractAllEventsWhereColumn___);
autoERPTier result = ERPTier_extractEventsWhereColumn_string (me, you, columnNumber, (kMelder_string) ___, ___theText);
CONVERT_TWO_END (my name)
CONVERT_TWO_END (my name.get())
}
// MARK: - file recognizers
static autoDaata bdfFileRecognizer (integer nread, const char * /* header */, MelderFile file) {
const char32 *fileName = MelderFile_name (file);
static autoDaata bdfFileRecognizer (integer nread, const char [] /* header */, MelderFile file) {
conststring32 fileName = MelderFile_name (file);
bool isBdfFile = Melder_stringMatchesCriterion (fileName, kMelder_string::ENDS_WITH, U".bdf", false);
bool isEdfFile = Melder_stringMatchesCriterion (fileName, kMelder_string::ENDS_WITH, U".edf", false);
if (nread < 512 || (! isBdfFile && ! isEdfFile)) return autoDaata ();
......
......@@ -62,15 +62,14 @@ static void bookkeeping (FFNet me);
Thing_implement (FFNet, Daata, 0);
char32 * FFNet_createNameFromTopology (FFNet me) {
autostring32 FFNet_createNameFromTopology (FFNet me) {
autoMelderString name;
MelderString_copy (& name, my nUnitsInLayer [0]);
for (integer i = 1; i <= my nLayers; i ++) {
MelderString_appendCharacter (& name, U'-');
MelderString_append (& name, my nUnitsInLayer [i]);
}
autostring32 naam = Melder_dup (name.string);
return naam.transfer();
return Melder_dup (name.string);
}
/****** non-linearities ****************************************************/
......@@ -302,11 +301,11 @@ void FFNet_reset (FFNet me, double weightRange) {
my minimizer.reset();
}
const char32* FFNet_getCategoryOfOutputUnit (FFNet me, integer outputUnit) {
const char32 *result = U"-- undefined --";
conststring32 FFNet_getCategoryOfOutputUnit (FFNet me, integer outputUnit) {
conststring32 result = U"-- undefined --";
if (my outputCategories && outputUnit <= my outputCategories -> size) {
SimpleString ss = my outputCategories->at [outputUnit];
result = ss -> string;
result = ss -> string.get();
}
return result;
}
......@@ -316,7 +315,7 @@ integer FFNet_getOutputUnitOfCategory (FFNet me, const char32* category) {
if (my outputCategories) {
for (integer i = 1; i <= my outputCategories -> size; i ++) {
SimpleString s = my outputCategories->at [i];
if (Melder_equ (s -> string, category)) {
if (Melder_equ (s -> string.get(), category)) {
result = i;
break;
}
......@@ -710,7 +709,7 @@ autoCollection FFNet_createIrisExample (integer numberOfHidden1, integer numberO
autoFFNet me = FFNet_create (4, numberOfHidden1, numberOfHidden2, 3, false);
FFNet_setOutputCategories (me.get(), uniq.get());
autostring32 name = FFNet_createNameFromTopology (me.get());
Thing_setName (me.get(), name.peek());
Thing_setName (me.get(), name.get());
collection -> addItem_move (me.move());
autoTableOfReal iris = TableOfReal_createIrisDataset ();
......@@ -781,7 +780,7 @@ autoFFNet PatternList_Categories_to_FFNet (PatternList me, Categories you, integ
autoFFNet result = FFNet_create (my nx, numberOfUnits1, numberOfUnits2, numberOfOutputs, false);
FFNet_setOutputCategories (result.get(), uniq.get());
autostring32 ffnetName = FFNet_createNameFromTopology (result.get());
Thing_setName (result.get(), ffnetName.peek());
Thing_setName (result.get(), ffnetName.get());
return result;
} catch (MelderError) {
Melder_throw (me, you, U": no FFNet created.");
......
......@@ -122,7 +122,7 @@ void FFNet_init (FFNet me, integer numberOfInputs, integer nodesInLayer1, intege
autoFFNet FFNet_create (integer numberOfInputs, integer numberInLayer1, integer numberInLayer2,
integer numberOfOutputs, bool outputsAreLinear);
char32 * FFNet_createNameFromTopology (FFNet me);
autostring32 FFNet_createNameFromTopology (FFNet me);
/* Create names as <inputs>-<outputs>, <inputs>-<hidden>-<outputs>,
<inputs>-<hidden1>-<hidden2>-<outputs> for 1, 2 or 3 layer networks.
*/
......
......@@ -82,9 +82,9 @@ autoActivationList FFNet_Categories_to_ActivationList (FFNet me, Categories thee
autoActivationList him = ActivationList_create (thy size, my nOutputs);
for (integer i = 1; i <= thy size; i ++) {
SimpleString category = thy at [i];
integer pos = OrderedOfString_indexOfItem_c (my outputCategories.get(), category -> string);
integer pos = OrderedOfString_indexOfItem_c (my outputCategories.get(), category -> string.get());
if (pos < 1) {
Melder_throw (U"The FFNet doesn't know the category ", category -> string, U".");
Melder_throw (U"The FFNet doesn't know the category ", category -> string.get(), U".");
}
his z [i] [pos] = 1.0;
}
......
......@@ -36,7 +36,7 @@ oo_DEFINE_CLASS (FFNet, Daata)
oo_INT (costFunctionType)
oo_AUTO_COLLECTION (Categories, outputCategories, SimpleString, 0)
oo_COLLECTION (Categories, outputCategories, SimpleString, 0)
oo_INTEGER (nWeights) /* number of weights */
......@@ -62,7 +62,7 @@ oo_DEFINE_CLASS (FFNet, Daata)
double **inputPattern, **targetActivation;
#endif
#if oo_DECLARING || oo_DESTROYING
oo_AUTO_OBJECT (Minimizer, 0, minimizer)
oo_OBJECT (Minimizer, 0, minimizer)
#endif
oo_DOUBLE_VECTOR (activity, nNodes)
......@@ -86,10 +86,10 @@ oo_DEFINE_CLASS (FFNet, Daata)
#endif
#if oo_COPYING
thy nonLinearity = nonLinearity;
thy nlClosure = nlClosure;
thy costFunction = costFunction;
thy cfClosure = cfClosure;
thy nonLinearity = our nonLinearity;
thy nlClosure = our nlClosure;
thy costFunction = our costFunction;
thy cfClosure = our cfClosure;
#endif
#if oo_DECLARING
......
# Makefile of the library "FFNet"
# David Weenink and Paul Boersma 2017-12-16
# David Weenink and Paul Boersma 2018-08-10
include ../makefile.defs
CPPFLAGS = -I ../kar -I ../sys -I ../dwtools -I ../fon -I ../dwsys -I ../stat -I ../gram
CPPFLAGS = -I ../kar -I ../melder -I ../sys -I ../dwtools -I ../fon -I ../dwsys -I ../stat -I ../gram
OBJECTS = FFNet.o \
FFNet_Eigen.o FFNet_Matrix.o FFNet_PatternList.o \
......@@ -25,4 +25,4 @@ libFFNet.a: $(OBJECTS)
$(AR) cq libFFNet.a $(OBJECTS)
$(RANLIB) libFFNet.a
$(OBJECTS): *.h ../kar/*.h ../sys/*.h ../dwtools/*.h ../fon/*.h ../dwsys/*.h ../stat/*.h ../gram/*.h
$(OBJECTS): *.h ../kar/*.h ../melder/*.h ../sys/*.h ../dwtools/*.h ../fon/*.h ../dwsys/*.h ../stat/*.h ../gram/*.h