Utility functions

List of functions in the utils folder.


src.utils.checkInput(data)

Check the data to write and convert to the proper format if needed.

Default will be ‘n/a’ for chars and NaN for numeric data.

USAGE:

data = checkInput(data)
src.utils.getFullFilename(fileName, cfg)

Returns the full path of a file (fo a given subject and modality in a run).

USAGE:

fullFilename = getFullFilename(fileName, cfg)
Parameters
  • fileName (string) –

  • cfg (structure) – Configuration. See checkCFG().

src.utils.initializeExtraColumns(logFile)

Initialize the fields for the extra columns

USAGE:

logFile = initializeExtraColumns(logFile)
Parameters

logFile (structure) – It contains what to save in the experiment outputs.

Returns

logFile

(structure) logfile updated with extra columns.

Example:

logfile.extraColumns{'Speed', 'Response key'}
logFile = initializeExtraColumns(logFile)
src.utils.isPositiveInteger(input2check)

It checks whether the input is a positive integer and report it as true or false

USAGE:

trueOrFalse = isPositiveInteger(input2check)
Parameters

input2check (vector) – (1xn) The input to check (either a number or NaN)

Returns

trueOrFalse

(boolean)

src.utils.nanPadding(cfg, data, expectedLength)

For numeric data that don’t have the expected length, it will be padded with NaNs. If the vector is too long it will be truncated

USAGE:

data = nanPadding(cfg, data, expectedLength)
src.utils.printCreditsCppBids(cfg)

It will print the credits of this repo. Depending on the level of verbosity set in cfg.verbose (default is 2 if not set), it will print the graphic and general information.

USAGE:

printCreditsCppBids(cfg)
Parameters

cfg (structure) – Configuration. See checkCFG().

src.utils.returnHeaderName(columnName, nbCol, iCol)

It returns one by one the column name to be used as a header in a recently opened event file

USAGE:

headerName = returnHeaderName(columnName, nbCol, iCol)
Parameters
  • columnName (string) – The column name to print

  • nbCol (integer) – It is the number of columns associated to one entry of the extra column list

  • iCol (integer) – Index of the columns associated to one entry of the extra column list

Returns

  • headerName

    (string) return the extra column name to be used as header

src.utils.returnNamesExtraColumns(logFile)

It returns the extra columns name(s), in cfg.extraColumns, as header to add to the event file

USAGE:

[namesExtraColumns] = returnNamesExtraColumns(logFile)
Parameters

logFile (structure) – It contains all the information to be saved in the event/stim file

Returns

  • namesExtraColumns

    (cell) (nx1)

src.utils.returnNbColumns(logFile, nameExtraColumn)

It returns the number of columns associated to one entry of the extra column list.

USAGE:

[nbCol] = returnNbColumns(logFile, nameExtraColumn)
Parameters
  • logFile (structure) – It contains every information related to the experiment output(s)

  • nameExtraColumn (string) – An entry of logFile.extraColumns

Returns

  • nbCol

    (integer) The number of columns associated to one entry of the extra column list.

src.utils.setDefaultFields(structure, fieldsToSet)

Recursively loop through the fields of a structure and sets a value if they don’t exist.

USAGE:

structure = setDefaults(structure, fieldsToSet)
Parameters
  • structure (structure) –

  • fieldsToSet (structure) –

Returns

  • structure

    (structure)