rtCommon.utils
Utils - various utilites for rtfMRI
Module Contents
Classes
Functions
|
Load matlab data file and convert it to a MatlabStructDict object for |
|
|
|
Find nonzero elements of A in flat "C" row-major indexing order |
|
|
|
|
|
|
|
|
|
Find newest file matching pattern according to filesystem creation time. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Provides a delay of demoStep seconds from the previous event time (i.e. sleeps) |
|
|
|
|
|
|
|
Returns seconds to next TR start time |
|
Given a datetime.time return seconds.fraction since day beginning |
|
Returns average round trip time in seconds |
Attributes
- 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