cogrecon.core.data_flexing.time_travel_task package

Submodules

cogrecon.core.data_flexing.time_travel_task.time_travel_task_analytics module

cogrecon.core.data_flexing.time_travel_task.time_travel_task_analytics.calculate_fd_and_lacunarity(data, indicies=None)[source]
cogrecon.core.data_flexing.time_travel_task.time_travel_task_analytics.count_boundary_crossings(path_points, regions)[source]
cogrecon.core.data_flexing.time_travel_task.time_travel_task_analytics.count_boxes(data, scale)[source]
cogrecon.core.data_flexing.time_travel_task.time_travel_task_analytics.get_regions_of_points(point, regions)[source]
cogrecon.core.data_flexing.time_travel_task.time_travel_task_analytics.summarize_navigation_data(search_directory=None, file_regex='\\d\\d\\d_\\d_1_\\d_\\d\\d\\d\\d-\\d\\d-\\d\\d_\\d\\d-\\d\\d-\\d\\d.dat', output_path='time_travel_task_navigation_summary.csv', last_pilot_id=20, verbose=True, temporal_boundary_regions=None, fd_indicies_time=None, fd_indicies_space=None, fd_indicies_spacetime=None)[source]

This function will produce an output file which contains the navigation summary data for all data files in a directory, searching recursively based on a regular expression.

Parameters:fd_indicies_time (object) – If None, the FD scale window will be calculated for every path independently. Otherwise, a

list of indicies is expected which specify the scale indicies across the range [0.0009765625, 0.001953125, 0.00390625, 0.0078125, 0.015625, 0.03125, 0.0625, 0.125, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0]. Currently, this range is not able to be redefined via the top level interface. :param fd_indicies_space: If None, the FD scale window will be calculated for every path independently. Otherwise, a list of indicies is expected which specify the scale indicies across the range [0.0009765625, 0.001953125, 0.00390625, 0.0078125, 0.015625, 0.03125, 0.0625, 0.125, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0]. Currently, this range is not able to be redefined via the top level interface. :param fd_indicies_spacetime: If None, the FD scale window will be calculated for every path independently. Otherwise, a list of indicies is expected which specify the scale indicies across the range [0.0009765625, 0.001953125, 0.00390625, 0.0078125, 0.015625, 0.03125, 0.0625, 0.125, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0]. Currently, this range is not able to be redefined via the top level interface. :param search_directory: the directory to recursively search for files matching file_regex to process :param file_regex: the regular expression for files to search for in search_directory, recursively :param output_path: the output path to save the data (CSV format) :param last_pilot_id: for the ‘pilot?’ column, IDs less than or equal to last_pilot_id will be marked True :param verbose: If True, participant information will be logged to logging.info as parsing progresses. :param temporal_boundary_regions: the (Nr, Nd, 2) representation of the boundary regions in the environment where Nr is the number of regions (note that regions can intersect and do not have to cover the whole space - boundaries are defined as when the contained regions for a point change in any way), Nd is the number of dimensions, and 2 are the min and max of the box region in each dimension for each region. The default is [[[-100, 15]], [[15, 30]], [[30, 45]], [[45, 100]]].

Return type:bool
Returns:True if files were successfully processed, False otherwise.
cogrecon.core.data_flexing.time_travel_task.time_travel_task_analytics.summarize_test_data(search_directory=None, file_regex='\\d\\d\\d_\\d_2_\\d_\\d\\d\\d\\d-\\d\\d-\\d\\d_\\d\\d-\\d\\d-\\d\\d.dat', output_path='time_travel_task_test_summary.csv', last_pilot_id=20, verbose=True)[source]

This function will produce an output file which contains the test summary data for all data files in a directory, searching recursively based on a regular expression.

Parameters:
  • search_directory – the directory to recursively search for files matching file_regex to process
  • file_regex – the regular expression for files to search for in search_directory, recursively
  • output_path – the output path to save the data (CSV format)
  • last_pilot_id – for the ‘pilot?’ column, IDs less than or equal to last_pilot_id will be marked True
  • verbose – If True, participant information will be logged to logging.info as parsing progresses.
Return type:

bool

Returns:

True if files were successfully processed, False otherwise.

cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader module

cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.compute_accuracy(meta, items)[source]

Given some meta information from the file via get_filename_meta_data and the item information, compute the accuracy of the items within and across contexts.

Parameters:
  • meta – the meta information from get_filename_meta_data
  • items – the items from parse_test_items
Returns:

a tuple containing: space_misplacement - the amount of space-only misplacement time_misplacement - the amount of time-only misplacement space_time_misplacement - the total space and time misplacement (treating the values equally) direction_correct_count - the number of correct direction labels mean_context_crossing_excluding_wrong_context_pairs - the mean of the distance between context crossing pairs excluding those which are in the wrong context mean_context_noncrossing_excluding_wrong_context_pairs - the mean of the distance between non-context crossing pairs excluding those which are in the wrong context mean_context_crossing - the mean distance between context crossing pairs with no exclusions mean_noncontext_crossing - the mean distance between non-context-crossing pairs with no exclusions

cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.datetime_from_dot_net_binary(data)[source]

From http://stackoverflow.com/questions/15919598/serialize-datetime-as-binary

This function converts data from a .NET datetime binary representation to a python datetime object

Parameters:data – some binary data which is expected to convert to a datetime value
Returns:a datetime value corresponding to the binary .NET datetime representation from the input data
cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.decode_7bit_int_length(fp)[source]

From: http://stackoverflow.com/questions/1550560/encoding-an-integer-in-7-bit-format-of-c-sharp-binaryreader-readstring

This function takes a file pointer and extracts the appropriate next information which is expected to contain a .NET 7bit binary datetime encoded value and extracts the length of that datetime value.

Parameters:fp – a file pointer whose next expected element is a 7bit integer length of a binary datetime in .NET
Returns:a length value representing the string length of a binary datetime in .NET
cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.find_data_files_in_directory(directory, file_regex='')[source]

This function acts as a helper to search a directory for files that match a regular expression. The function will raise an IOError if the input path is not found.

Parameters:
  • directory – the directory to search
  • file_regex – the regular expression to match for files
Returns:

a list of files which match the regular expression

cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.find_last(lst, sought_elt)[source]

This function finds the last index that an element of a particular value appears in a list.

Parameters:
  • lst – the list to search
  • sought_elt – the element for which we search
Returns:

the index at which the last element matching sought_elt resides

cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.get_click_locations_and_indicies(iterations, items, meta)[source]

This function takes the iterations from read_binary_file, the items to be searched and the meta information from the file and returns the clicked positions, indices in the iterations, size and colors for visualization.

Parameters:
  • iterations – the iterations from read_binary_file
  • items – the items to be visualized
  • meta – the meta information from the filename
Returns:

a dictionary containing: click_pos - the x, z, time coordinates of the click position click_idx - the index in iterations at which time the click happened click_size - the size the click should be visualized as click_color - the color with which the click should be visualized

cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.get_exploration_metrics(iterations)[source]

This function gets the common exploration metrics from an iterations list returned by read_binary_file.

Parameters:iterations – the iterations from read_binary_file
Returns:a tuple containing total_time, space_travelled, time_travelled, and space_time_travelled
cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.get_filename_meta_data(fn)[source]

This function retrieves the meta information from a filename given the typical formatting in the Time Travel Task.

Parameters:fn – a filename to parse for meta-data
Returns:a dictionary containing keys ‘subID’, ‘trial’, ‘phase’, ‘inverse’ and ‘datetime’ of types string with the exception of datetime which is of type datetime
cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.get_item_details(pastel_factor=127)[source]

This function returns detailed information about the item solutions including strings representing the event state, strings with the item labels, and filename image strings (JPG), as well as RGB color tuples for each item.

Parameters:pastel_factor – a factor to render the RGB values via pastel shades (default 127)
Returns:a tuple containing: event_state_labels - a set of strings containing the labels for event states given an integer item_number_label - a set of strings containing the labels for items given an integer item_label_filenames - a set of strings containing the filename for JPGs containing the images of items given an integer cols - a set of RGB colors influenced by the input pastel_factor representing the item colors
cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.get_items_solutions(meta)[source]

This function returns the solution values given a particular meta-file information configuration.

Parameters:meta – the meta information from get_filename_meta_data
Returns:a tuple with items, times and directions where times contains numeric time constants, directions contains numeric labels such that 2 is Fall, 1 is Fly, and 0 is Stationary/Stay, and items containts a list of dictionaries containing values: “direction” - the 0, 1, or 2 direction value “pos” - the x, z, time coordinate of the item “color” - the RGB color tuple for the item
cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.is_correct_color(t, solution_t, bins=15.0)[source]

This function determines if a particular item time is correct given a time, solution time and bins in which a timeline is divided.

Parameters:
  • bins – the float representing the bins into which the timeline is divided
  • t – the time of the item
  • solution_t – the correct time of the time
Returns:

a boolean value, true if the item is in the correct time region, false otherwise

cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.parse_test_items(iterations, cols, item_number_label, event_state_labels)[source]

This function takes in a set of iterations parsed from read_binary_file, a set of color values, a set of item labels, and a set of event labels and produces the items, reconstruction items and the order description for each item in the reconstruction.

Parameters:
  • iterations – the iterations output from read_binary_file
  • cols – the colors of each item in canonical ordering
  • item_number_label – the labels for each item in canonical ordering
  • event_state_labels – the event labels for each item in canonical ordering
Returns:

a dictionary containing: “direction” - a numeric value representing the up, down or stationary state “pos” - the x, z, and t values representing the 2D position and time coordinates “color” - the color value representing the indexed color value from cols associated with the item

cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.phase_num_to_str(phase)[source]

This function converts a phase integer into a nameable phase string.

Parameters:phase – an integer which represents the phase type to be converted to a string
Returns:‘VR Practice’, ‘VR Study’, ‘VR Test’, ‘VE Practice’, ‘VE Study’, ‘VE Test’, ‘2D Practice’, ‘2D Study’, ‘2D Test’, in order, from 0 to 8.
cogrecon.core.data_flexing.time_travel_task.time_travel_task_binary_reader.read_binary_file(path)[source]

This function reads a Time Travel Task binary file in its entirety and converts it into a list of iterations which can be parsed independently.

Parameters:path – a string absolute path to a Time Travel Task binary file
Returns:a list of iterations (dictionaries containing values: ‘version’ - an integer version number

’datetime’ - a python datetime object for this iteration

’time_val’ - a time for this iteration

’timescale’ - a timescale which the current time is proceding through

’x’, ‘y’, ‘z’ - x, y, and z spatial coordinates in which the participant resides

’rx’, ‘ry’, ‘rz’, ‘rw’ - x, y, z, and w rotation quaternion coordinates in which the participant resides ‘keys’, ‘buttons’, ‘keylabels’, ‘buttonlabels’ 0 the key states, button states, key labels and button labels for every key and button which is registered to be logged

’itemsx’, ‘itemsy’, ‘itemsz’, ‘itemsactive’, ‘itemsclicked’, ‘itemsevent’, ‘itemstime’ - the item x, y, z spatial coordinates, the item active state (enabled or disabled in the environment), the item event, and time ‘boundarystate’, ‘br’, ‘bg’, ‘bb’ - the boundary state and Red, Green, and Blue color intensities of the boundary

’inventoryitemnumber’- the item numbers in the inventory this iteration

’activeinventoryitemnumber’,’activeinventoryeventinder’ - the active item number and event number this iteration)

cogrecon.core.data_flexing.time_travel_task.time_travel_task_to_iposition module

cogrecon.core.data_flexing.time_travel_task.time_travel_task_to_iposition.extract_basic_order(order_list, first=True)[source]

This function extracts simplified order information from an order list, assuming that we want to know the first item placed as 0 and last as ‘n’.

Parameters:
  • order_list – an order list of integers which contains gaps
  • first – a boolean determining if we want to order first to last or last to first
Returns:

an integer list 0 to ‘n’ ordered according to the input from smallest to largest integer

cogrecon.core.data_flexing.time_travel_task.time_travel_task_to_iposition.save_iposition_items_to_file(_filename, _items)[source]

This function saves a set of items in iposition (TSV) format given a filename and item dictionary list

Parameters:
  • _filename – a string filename in which to save the data
  • _items – a dictionary containing position information stored in a “pos” key to be saved
cogrecon.core.data_flexing.time_travel_task.time_travel_task_to_iposition.save_tsv(_filename, _list)[source]

This helper function saves simple TSV files via a _list (assumed to be 2D).

Parameters:
  • _filename – the string filename in which to save the TSV
  • _list – a 2D list to be saved where each row (first dimension) is saved per line and each element is separated by a tab
cogrecon.core.data_flexing.time_travel_task.time_travel_task_to_iposition.time_travel_task_to_iposition(input_dir, output_dir, file_regex='\\d\\d\\d_\\d_2_\\d_\\d\\d\\d\\d-\\d\\d-\\d\\d_\\d\\d-\\d\\d-\\d\\d.dat', order_first=True, exclude_incorrect_category=False, output_user_categories=True)[source]

This function is a global helper function meant to take a directory in which many Time Travel Task binary files exist and convert them all into iposition (TSV) compatible files to be saved in an output directory.

Parameters:
  • output_user_categories – a boolean which, if true, will cause the conversion to output categories.txt files populated with the user’s categorization of the items. If false, the correct categorization given the user’s meta information (i.e. inversion) will be used.
  • input_dir – the string directory to search for binary files via a regular expression stored in file_regex
  • output_dir – the string output directory in which to save files
  • file_regex – the string regular expression to use to determine if a file should be included as input
  • order_first – boolean value which, if true, order is used first-to-last - if false, order is used last-to-first
  • exclude_incorrect_category – a boolean value which, if true, removes items which are the wrong category from the output data

Module contents