12 #ifndef UTILITY_FUNCTIONS_H
13 #define UTILITY_FUNCTIONS_H
20 #define __FUNCTION_STR__ std::string(__PRETTY_FUNCTION__)
31 std::string
dirname(std::string path);
40 bool isTxt(std::string filename);
58 std::string
chomp(std::string str);
75 std::vector<std::string>
parseLine(std::string line, std::string delim);
94 std::vector<std::vector<std::string>>
readStrCSV(std::string filename,
95 char& delim,
char comment =
'#');
113 std::vector<std::vector<double>>
readNumericCSV(std::string filename,
125 double gammaPDF(
double x,
double k,
double theta);
149 double cannonHrf(
double t,
double rdelay,
double udelay,
double rdisp,
150 double udisp,
double puRatio,
double onset,
double total);
181 std::vector<double>
getRegressor(std::vector<std::vector<double>>& spec,
182 double tr,
size_t ntimes,
double t0);
204 std::vector<double>
getRegressor(std::vector<std::vector<double>>& spec,
205 double tr,
size_t ntimes,
double t0);
222 void boldsim(
size_t len,
double* iobuff,
double dt,
double learn);
238 void convolve(std::vector<double>& signal,
double(*foo)(
double),
239 double tr,
double length);
253 return fwhm/(2*sqrt(2*log(2)));
267 return sd*(2*sqrt(2*log(2)));
287 MemMap(std::string fn,
size_t bsize);
297 MemMap(std::string fn,
bool writeable=
false);
303 MemMap() : m_size(0), m_fd(0), m_data(NULL) {};
315 int64_t
openNew(std::string fn,
size_t bsize);
328 int64_t
openExisting(std::string fn,
bool writeable,
bool quiet =
true);
351 void*
data() {
return m_data; };
358 const void*
data()
const {
return m_data; };
369 int64_t
size() {
return m_size; };
378 #endif // UTILITY_FUNCTIONS_H
MemMap()
Just create the object. Until open() is called the size() will be 0 and returned data() will be NULL;...
double cannonHrf(double t, double rdelay, double udelay, double rdisp, double udisp, double puRatio, double onset, double total)
Cannonical hemodynamic response funciton from SPM. delay of response (relative to onset) = 6 delay of...
double fwhm_to_sd(double fwhm)
Computes the standard deviation from FWHM (because I can never remember the ratio) ...
std::string dirname(std::string path)
Returns the directory name for the given file.
std::vector< std::vector< std::string > > readStrCSV(std::string filename, char &delim, char comment= '#')
This function parses an input and returns a list of rows.
int64_t openExisting(std::string fn, bool writeable, bool quiet=true)
Open the specified file with the specified size. If createNew is set then a new file will be created ...
std::string chomp(std::string str)
Removes whitespace at the beginning and end of a string.
int64_t openNew(std::string fn, size_t bsize)
Open the specified file with the specified size. If createNew is set then a new file will be created ...
bool fileExists(std::string filename)
Returns true if a file exists and is possible to open.
std::vector< std::vector< double > > readNumericCSV(std::string filename, char comment= '#')
This function parses an input and returns a list of rows.
bool isopen()
Return true if a file is currently open.
void boldsim(size_t len, double *iobuff, double dt, double learn)
In place simulation of BOL timeseries using the balloon model. Habituation is accomplished by subtrac...
void * data()
Get pointer to data.
void close()
Close the current file (if one is open). data() will return NULL and size() will return 0 after this ...
std::vector< std::string > parseLine(std::string line, std::string delim)
Given a delimiter splits the line based on the delmiter and removes extra white space as necessary...
Memory map class. The basic gyst is that this works like a malloc except that data may be initialized...
double gammaPDF(double x, double k, double theta)
Gamma distribution, used by Cannonical HRF from SPM.
void convolve(std::vector< double > &signal, double(*foo)(double), double tr, double length)
Convolves a signal and a function using loops (not fast) No wrapping is done.
bool isTxt(std::string filename)
Reads a file and returns true if its entirely made up of printable ascii.
std::vector< double > getRegressor(std::vector< std::vector< double >> &spec, double tr, size_t ntimes, double t0)
Takes a 1 or 3 column format of regressor and produces a timeseries sampeled every tr...
const void * data() const
Get constant pointer to current data.
double sd_to_fwhm(double sd)
Computes the FWHM from from standard deviation (because I can never remember the ratio) ...
int64_t size()
Length (in bytes) of memory map.
~MemMap()
Destructor, close file.