expyriment.misc.data_preprocessing

Data Preprocessing Module.

This module contains several classes and functions that help to handle, preprocessing and aggregate Expyriment data files.

Attributes

Modules

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_filename : str

name (fullpath) of the Expyriment event file

Returns:

minutes : float

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:

filename : str

name (fullpath) of the Expyriment data file

only_header_and_variable_names : bool, optional

if True the function reads only the header and variable names (default=False)

encoding : str, optional

the encoding with which the contents of the file will be read

read_variables : array of str, optional

array of variable names, read only the specified variables

Returns:

data : list of list

data array

variables : list of str

variable names list

subject_info : dict

dictionary with subject information (incl. date and between subject factors)

comments : str

string with remaining comments

expyriment.misc.data_preprocessing.write_concatenated_data(data_folder, file_name, output_file=None, delimiter=', ', to_R_data_frame=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_folder : str

folder which contains of data of the subjects (str)

file_name : str

name of the files

output_file : str, optional

name of data output file. If no specified data will the save to {file_name}.csv

delimiter : str, 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

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:

filename : str

name (fullpath) of the data file

data : list of list

2D array with data (list of list)

varnames : list of str, optional

array of strings representing variable names

delimiter : str, optional

delimiter character (default=”,”)