expyriment.misc.data_preprocessing
Data Preprocessing Module.
This module contains several classes and functions that help to handle, preprocessing and aggregate Expyriment data files.
Classes
Functions
- expyriment.misc.data_preprocessing.get_experiment_duration(event_filename)
Extracts the experiment duration from event file and returns the time in minutes.
- Parameters:
- info_filenamestr
name (fullpath) of the Expyriment event file
- Returns:
- minutesfloat
experiment duration in minutes
- expyriment.misc.data_preprocessing.read_datafile(filename, only_header_and_variable_names=False, encoding=None, read_variables=None)
Read an Expyriment data file.
Returns the data, the variable names, the subject info & the comments:
- Parameters:
- filenamestr
name (fullpath) of the Expyriment data file
- only_header_and_variable_namesbool, optional
if True the function reads only the header and variable names (default=False)
- encodingstr, optional
the encoding with which the contents of the file will be read
- read_variablesarray of str, optional
array of variable names, read only the specified variables
- Returns:
- datalist of list
data array
- variableslist of str
variable names list
- subject_infodict
dictionary with subject information (incl. date and between subject factors)
- commentsstr
string with remaining comments
- expyriment.misc.data_preprocessing.write_concatenated_data(data_folder, file_name, output_file=None, delimiter=',', to_R_data_frame=False, names_comprise_glob_pattern=False)
Concatenate data and write it to a csv file.
All files that start with this name will be considered for the analysis (cf. aggregator.data_files)
- Parameters:
- data_folderstr
folder which contains of the data (str)
- file_namestr
name of the files; all files that start with this name will be considered
- output_filestr, optional
name of data output file; if no specified data will the save to {file_name}.csv
- delimiterstr, optional
delimiter character (default=”,”)
- to_R_data_frame: bool, optional
if True, data will be converted to a R data frame that is saved in a RDS file
- names_comprise_glob_patternboolean, optional
if True, data_folder and file_name are processed as glob pattern with wildcards such as “*” or “?”
Notes
The function is useful to combine the experimental data and prepare for further processing with other software. It basically wraps Aggregator.write_concatenated_data.
- expyriment.misc.data_preprocessing.write_csv_file(filename, data, varnames=None, delimiter=',')
Write 2D data array to csv file.
- Parameters:
- filenamestr
name (fullpath) of the data file
- datalist of list
2D array with data (list of list)
- varnameslist of str, optional
array of strings representing variable names
- delimiterstr, optional
delimiter character (default=”,”)