rtCommon.utils

Utils - various utilites for rtfMRI

Module Contents

Classes

DebugLevels

Functions

parseMatlabStruct(→ rtCommon.structDict.MatlabStructDict)

Load matlab data file and convert it to a MatlabStructDict object for

loadMatFile(→ rtCommon.structDict.MatlabStructDict)

loadMatFileFromBuffer(...)

find(→ numpy.ndarray)

Find nonzero elements of A in flat "C" row-major indexing order

loadConfigFile(filename)

flatten_1Ds(M)

dateStr30(timeval)

md5SumFile(filePath)

findNewestFile(filepath, filepattern)

Find newest file matching pattern according to filesystem creation time.

copyFileWildcard(src, dst)

fileCount(dir, pattern)

writeFile(filename, data[, binary])

readFile(filename[, binary])

deleteFilesFromList(fileList)

deleteFolder(dir)

deleteFolderFiles(dir[, recursive])

runCmdCheckOutput(cmd, outputRegex)

demoDelay(demoStep[, prevEventTime])

Provides a delay of demoStep seconds from the previous event time (i.e. sleeps)

installLoggers(consoleLevel, fileLevel[, filename])

getGitCodeId()

stringPartialFormat(→ str)

trimDictBytes(msg[, trimSize])

getTimeToNextTR(→ float)

Returns seconds to next TR start time

dtimeToSeconds(→ float)

Given a datetime.time return seconds.fraction since day beginning

calcAvgRoundTripTime(pingFunc)

Returns average round trip time in seconds

Attributes

gitCodeId

rtCommon.utils.parseMatlabStruct(top_struct) rtCommon.structDict.MatlabStructDict

Load matlab data file and convert it to a MatlabStructDict object for easier python access. Expect only one substructure array, and use that one as the name variable in MatlabStructDict. Return the MatlabStructDict object

rtCommon.utils.loadMatFile(filename: str) rtCommon.structDict.MatlabStructDict
rtCommon.utils.loadMatFileFromBuffer(data) rtCommon.structDict.MatlabStructDict
rtCommon.utils.find(A: numpy.ndarray) numpy.ndarray

Find nonzero elements of A in flat “C” row-major indexing order but sorted as in “F” column indexing order

rtCommon.utils.loadConfigFile(filename)
rtCommon.utils.flatten_1Ds(M)
rtCommon.utils.dateStr30(timeval)
rtCommon.utils.md5SumFile(filePath)
rtCommon.utils.findNewestFile(filepath, filepattern)

Find newest file matching pattern according to filesystem creation time. Return the filename

rtCommon.utils.copyFileWildcard(src, dst)
rtCommon.utils.fileCount(dir, pattern)
rtCommon.utils.writeFile(filename, data, binary=True)
rtCommon.utils.readFile(filename, binary=True)
rtCommon.utils.deleteFilesFromList(fileList)
rtCommon.utils.deleteFolder(dir)
rtCommon.utils.deleteFolderFiles(dir, recursive=True)
rtCommon.utils.runCmdCheckOutput(cmd, outputRegex)
rtCommon.utils.demoDelay(demoStep, prevEventTime=None)

Provides a delay of demoStep seconds from the previous event time (i.e. sleeps) Given demoStep in seconds, calculate how long to sleep until the next clock cycle will be reached that is an even value of demoStep. Then sleep that amount of time. If prevEventTime is specified and we are more than 1 demo step since the prevEvent then don’t sleep.

class rtCommon.utils.DebugLevels
L1 = 19
L2 = 18
L3 = 17
L4 = 16
L5 = 15
L6 = 14
L7 = 13
L8 = 12
L9 = 11
L10 = 10
rtCommon.utils.installLoggers(consoleLevel, fileLevel, filename=None)
rtCommon.utils.gitCodeId
rtCommon.utils.getGitCodeId()
rtCommon.utils.stringPartialFormat(text, tag, val) str
rtCommon.utils.trimDictBytes(msg, trimSize=64)
rtCommon.utils.getTimeToNextTR(lastTrTime, trRepSec, nowTime, clockSkew) float

Returns seconds to next TR start time :param lastTrTime - datetime.time of the start of last TR: :param trRepSec - repetition time in seconds between TRs: :param nowTime - current time as datetime.time struct: :param clockSkew - seconds that scanner clock is ahead of caller clock:

Returns

seconds to next TR start (as float)

rtCommon.utils.dtimeToSeconds(valTime) float

Given a datetime.time return seconds.fraction since day beginning

rtCommon.utils.calcAvgRoundTripTime(pingFunc)

Returns average round trip time in seconds