cmind.utils.utils¶
Miscellaneous Utilities A group of small functions commonly used within the CMIND pipelines
str2list dprint input2bool sphere str2none is_string_like parser_to_bash fsl_highpass_temporal_filter1D calc_tSNR_regress
Functions
calc_tSNR_regress (image[, DesMat, mask, ...]) |
regresses out Design Matrix components before calculating the standard deviation so that task related signal changes don’t penalize the tSNR value |
confirm ([prompt, resp]) |
prompts for yes or no response from the user. Returns True for yes and |
dprint (input_dict[, HTML_markup, silent]) |
print dictionary key,value pairs |
fsl_highpass_temporal_filter1D (volume1D, sigma) |
perform highpass temporal filtering the way it is done in FSL |
get_unicode_type () |
determine if the Python installation was compiled with –enable-unicode=ucs4 or ucs2 |
input2bool (input_val) |
convert various input types to boolean |
input2list (input_val[, seperator, convert_to]) |
convert various input types to lists |
is_string_like (obj) |
Check whether obj behaves like a string. |
lprint (input_list[, HTML_markup, silent]) |
print list items, one per line |
parser_to_bash (parser, script_name[, ...]) |
|
reindent (s[, numSpaces]) |
add indentation to a multiline string |
sphere ([r, N]) |
create an ndarray (x,y,z) coordinates over a sphere of radius r |
str2list (csvstring[, str_strip, str_split]) |
separates a comma seperated string such as “a, b, c, d” |
str2none (s[, none_strings]) |
convert strings such as “none” to the Python None object, otherwise |
-
cmind.utils.utils.
calc_tSNR_regress
(image, DesMat=None, mask=None, doResidual=False)[source]¶ regresses out Design Matrix components before calculating the standard deviation so that task related signal changes don’t penalize the tSNR value
Parameters: image : ndarray
input image to calculate tSNR on
DesMat : ndarray
design matrix [Time x Regressors]
mask : ndarray
boolean image of pixel locations over which to calculate tSNR
doResidual : bool
compute residuals?
Returns: tSNR : ndarray
map of the computed tSNR values
mask : ndarray
the mask that was used in computing tSNR
mean_tSNR : float
mean values of tSNR over the mask
res : ndarray
residuals
-
cmind.utils.utils.
confirm
(prompt=None, resp=False)[source]¶ prompts for yes or no response from the user. Returns True for yes and False for no.
‘resp’ should be set to the default value assumed by the caller when user simply types ENTER.
>>> confirm(prompt='Create Directory?', resp=True) Create Directory? [y]|n: True >>> confirm(prompt='Create Directory?', resp=False) Create Directory? [n]|y: False >>> confirm(prompt='Create Directory?', resp=False) Create Directory? [n]|y: y True
-
cmind.utils.utils.
dprint
(input_dict, HTML_markup=False, silent=False)[source]¶ print dictionary key,value pairs
Parameters: input_dict : dict
dictionary to print
-
cmind.utils.utils.
fsl_highpass_temporal_filter1D
(volume1D, sigma, demean_result=True)[source]¶ perform highpass temporal filtering the way it is done in FSL (based on the FSL C function: bandpass_temporal_filter)
Parameters: volume1D : array or list
1D timeseries to filter
sigma : float
sigma is in timepoints
Returns: volume1D_filt : array
filtered timeseries
-
cmind.utils.utils.
get_unicode_type
()[source]¶ determine if the Python installation was compiled with –enable-unicode=ucs4 or ucs2
-
cmind.utils.utils.
input2bool
(input_val)[source]¶ convert various input types to boolean
Parameters: input_val : str or bool or int or float
input to convert
Returns: boolval : bool
boolean output
Notes
If input_val is a bool, boolval = input_val.
- If input_val is a str, the following case-insensitive conversions are made:
- [true, t, 1] evaluate to True (case insensitive)
- [false, f, 0, none] evaluate to False (case insensitive)
- any other string raises an error
If input_val is numeric and equals 0, boolval is False.
-
cmind.utils.utils.
input2list
(input_val, seperator=', ', convert_to=None)[source]¶ convert various input types to lists
Parameters: input_val : str or bool or int or float or numpy.ndarray or list or tuple
input to convert to list
Returns: output_list : list
Notes
If input_val is a string, any brackets will be stripped and then the string will be split via the seperator argument. e.g. ‘x,y,z’ would become the list: [‘x’, ‘y’, ‘z’]
-
cmind.utils.utils.
lprint
(input_list, HTML_markup=False, silent=False)[source]¶ print list items, one per line
Parameters: input_list : dict
list to print
-
cmind.utils.utils.
sphere
(r=1, N=100)[source]¶ create an ndarray (x,y,z) coordinates over a sphere of radius r
Parameters: r : float, optional
radius of sphere
N : int, optional
number of equal angular divisions to use along theta and phi
Returns: x : ndarray
x coordinates
y : ndarray
y coordinates
z : ndarray
z coordinates
-
cmind.utils.utils.
str2list
(csvstring, str_strip='"', str_split=', ')[source]¶ - separates a comma seperated string such as “a, b, c, d”
- into a list [‘a’,’b’,’c’,’d’]
Parameters: csvstring : str
string to be split into a list
str_strip : str, optional
strip instances of str_strip from csvstring before splitting. default = ‘”’
str_split : str, optional
string argument to be used by split() when processing csvstring default = ‘,’
Returns: str_list : list
list of strings