deid.utils package¶
Submodules¶
deid.utils.actions module¶
-
deid.utils.actions.
get_func
(function_name)[source]¶ Get_func will return a function that is defined from a string.
the function is assumed to be in this file
Parameters: a function from globals based on a name string (return) –
-
deid.utils.actions.
get_timestamp
(item_date, item_time=None, jitter_days=None, format=None)[source]¶ Get_timestamp will return (default) a UTC timestamp.
This will have some date and (optional) time. A different format can be provided to change default behavior. eg: “%Y%m%d”
deid.utils.fileio module¶
-
deid.utils.fileio.
get_temporary_name
(prefix=None, ext=None)[source]¶ Get a temporary name.
Get a temporary name, can be used for a directory or file. This does so without creating the file, and adds an optional prefix
Parameters: - prefix (if defined, add the prefix after deid) –
- ext (if defined, return the file extension appended. Do not specify ".") –
-
deid.utils.fileio.
read_file
(filename, mode='r')[source]¶ Read a file.
Parameters: - filename (the name of the file to write to) –
- mode (the mode to open the file, defaults to read (r)) –
-
deid.utils.fileio.
read_json
(filename, mode='r', ordered_dict=False)[source]¶ Open a file, “filename” and read the string as json
Parameters: - filename (the name of the file to write to) –
- mode (the mode to open the file, defaults to read (r)) –
- ordered_dict (If true, return an OrderedDict (default is False)) –
-
deid.utils.fileio.
recursive_find
(base, pattern=None)[source]¶ Recursively find files that match a pattern.
recursive find will yield dicom files in all directory levels below a base path. It uses get_dcm_files to find the files in the bases.
Parameters: - base (the base directory to search) –
- pattern (a pattern to match. If None, defaults to "*") –
-
deid.utils.fileio.
write_file
(filename, content, mode='w')[source]¶ Write to file.
write_file will open a file, “filename” and write content, “content” and properly close the file
Parameters: - filename (the name of the file to write to) –
- content (the content to write to file) –
- mode (the mode to open the file, defaults to write (w)) –