cgdat package — CGDAT 2.0.3-3-g9aff488 documentation

# cgdat package

## Subpackages

- cgdat.qt_custom package
  - Submodules
  - cgdat.qt_custom.qt_dialogs module
  - cgdat.qt_custom.qt_extra module
  - cgdat.qt_custom.qt_thread module
  - Module contents
    - cgdat.qt_custom.qt_dialogs
    - cgdat.qt_custom.qt_extra
    - cgdat.qt_custom.qt_thread
- cgdat.qt_ui package
  - Submodules
  - cgdat.qt_ui.about_ui module
  - cgdat.qt_ui.cgdat_ui module
  - cgdat.qt_ui.import_dialog_ui module
  - cgdat.qt_ui.output_settings_ui module
  - cgdat.qt_ui.progress_dialog_ui module
  - Module contents

## Submodules

## cgdat.cgdat module

This file contains the main GUI class that is used in the Conditional game data analyse tool (CGDAT) was created for a friend of mine to help him with the data analysis he had to do for his graduation project. This tool is licensed under the GPL open source license. You are therefore free use the source code in any way provided that you the original copyright statements.

class `cgdat.cgdat.` `DataAnalyserGUI`

  Bases: `cgdat.qt_ui.cgdat_ui.Ui_MainWindow`

  This is the qt class used to create the general user interface for the CGDAT data analysis tool. It inherits from the Ui_MainWindow class that is automatically created by the PyQt5.uic.pyuic converter.

  Args:
    Ui_MainWindow (CGDAT_ui.Ui_MainWindow): Python GUI class created out of the CGDAT.ui file by the PyQt5.uic.pyuic converter.
  `action_about_slot`()

    Qt slot function created to display the about window. This slot is triggered when the about menu item is clicked or the user uses the F1 keyboard shortcut.

  `action_doc_slot`()

    Qt slot function displays the documentation. This slot is triggered when the docs menu item is clicked or the user uses the F2 keyboard shortcut.

  `add_conditions_row`()

    Qt slot function created to add an extra condition row to the condition grid. It is linked to the condition_add_row_btn and triggered when the button is clicked.

  `analyse_data`(*args, **kwargs)

    The function in which the data analysis is performed. The function uses the data present in the csv file which is specified in the input_file_path member variable. The data analysis is performed using the `pandas.read_csv()` function which returns a pandas dataframe. Following the data in this dataframe is checked against the conditional statements specified in the conditions grid of the main GUI window.

    Args:
      player_name (str, optional): The name of the player that needs to be analysed. Put “” if you don’t want to filter by player. If `player_name` = `None` the player is not used as a condition. progress_callback (str): The worker progress string which needs to be printed to the dialog console.
    Returns:
      Bool: Descriptor specifying whether the data analyse was successfully.
  `analyse_input_data_file`(*args, **kwargs)

    Qt slot function that is used to check if the data file is vallid and following add the available players to the player filter comboBox. This slot function is run in a worker thread so it does not freeze the GUI.

  `analyse_input_time_data_file`(*args, **kwargs)

    Qt slot function that is used to check if the time sections data file is vallid. This slot function is run in a worker thread so it does not freeze the GUI.

  `catch_thread_errors`(error_tuple)

    This function catches errors in worker threads and outputs them to the user.

    Args:
      error_tuple (tuple): The error tuple that was send by the worker tread.
  `check_condition`()

    Qt slot function created to check whether the conditions have the right format.

    Args:
      condition_text (str): The condition text.
    Returns:
      bool: Boolean specifying whether the condition format is correct.
  `createFolder`(directory)

    This function is used to create a folder when it does not exists

  `data_analyse_dialog_finished`(result)

    This function is used to check whether the data analysis was completed successfully or that the user cancelled the data analysis. When the data analysis was cancelled it terminates any running workers.

    Args:
      result (int): Bool specifying whether the QDialog was accepted (1) or rejected (0)
  `data_input_worker_finished`(result)

    QT slot function used to check whether the data file import was successful. If successful it updates the player filter choicer menu by adding the available players to the menu options.

    Args:
      bool: Boolean specifying whether the data file import was successfully.
  `get_input_file`()

    Qt slot function created to get a user specified input file. It is linked to the input_file_browser_btn and displays a file choicer dialog in which the user can specify the input data file.

  `get_output_dir`()

    Qt slot function created to get a user specified output folder. It is linked to the output_file_browser_btn_btn and displays a folder choicer dialog in which the user can specify the input data file. If no folder is specified the output files will be placed in a CGDAT/results folder which is placed in the windows documents folder.

  `get_time_sections_file`()

    Qt slot function created to get a user specified time sectsions input file. In this file the `begin times` and `End times` of the sections where the data analysis has to be performed are specified. It is linked to the time_file_browser_btn and displays a file choicer dialog in which the user can specify the input data file.

  `import_dialog_finished`(result)

    This function is used to check whether the data import was successful or whether the user cancelled the import using the cancel button present on the dialog window.

    Args:
      result (int): Bool specifying whether the QDialog was accepted (1) or rejected (0)
  `output_settings_dialog_finished`(result)

    Qt slot that is triggered when the output settings dialog is finished. This function updates the settings the user changed into the GUI member variables.

  `padBoolArray`(bool_array, n)
  `remove_conditions_row`()

    Qt slot function created to add an extra condition row to the condition grid. It is linked to the condition_remove_row_btn and triggered when the button is clicked.

  `reset_conditions`()

    Qt slot function created to reset the condition grid to its original state in which only condition row is present. It is linked to the reset_conditions_grid_btn.

  `set_output_settings`()

    Qt slot used to open the output_settings UI which can be used to set some additional settings for the output file. Currently the following additional settings are supported:

    > - Change the input file frequency: By default this will be around 600 hz.
    > - Set the columns to include in the output file: By default the CGDAT tool only keeps the variables (csv columns) that are specified in your conditions.

  `setupUi`(MainWindow)

    The function which is used to set up the parts of the GUI that were not already defined in the CGDAT.ui file. Further it is also used to add functionalities to the objects in the generated qt GUI python class.

    Args:
      MainWindow (PyQt5.QtWidgets.QMainWindow): Python Main window object created out of the CGDAT_ui.Ui_MainWindow class.
  `start_data_analysis`()

    Qt slot function that is used to start the data analysis in a number of worker threads so that the GUI does not freeze when the data analysis is performed. The actual data analysis is performed by the `analyse_data()` function.

  `timeDelta2DateTime`(time_delta_list)

    This method converts a list containing the time since measurement onset [seconds] into a list containing dateTime objects counting up from 00:00:00.

    Args:
      time_delta_list (list): List containing the times since the measurement has started.
    Returns:
      list: A list with the time in the DateTime format.
  `time_import_dialog_finished`(result)

    This function is used to check whether the file specifying the time sections was imported successfully or whether the user cancelled the import using the cancel button present on the dialog window.

    Args:
      result (int): Bool specifying whether the QDialog was accepted (1) or rejected (0)
  `time_input_worker_finished`(result)

    QT slot function used to check whether the time section file was successfully imported. If successful it updates the player filter choicer menu by adding the available players to the menu options.

    Args:
      bool: Boolean specifying whether the data file import was successfully.
  `worker_finished`(result)

    Qt slot function which is triggered when a thread is completed. It is connected to the threads finished signal. These signals are created using the pyqtSignal class.

## cgdat.create_shortcut_cl module

This function creates a shortcut which can be used to run the CGDAT tool

`cgdat.create_shortcut_cl.` `main`()

  Main function that is executed when we use the `cgdat-shortcut` command. This function creates a shortcut for the gui on the desktop.

## cgdat.start_cl module

This script is used to starts the cgdat gui out of the command line

`cgdat.start_cl.` `main`()

  Main function that is executed when we use the `cgdat-gui` command. This function starts the cgdat gui window.

## Module contents

This package contains a simple GUI for analysing csv game data. It contains the DataAnalyserGUI gui class and all the modules and functions that are used in creating this class.