<jupyter_start><jupyter_text>RTTHere, we load the risk taking task data into a dataframe for further processing.<jupyter_code>%load_ext autoreload
%autoreload 2
#export
from fastcore.foundation import patch
from trr265.gbe.data_provider import GBEProvider
from trr265.data_provider import get_efficiently
import numpy as np<jupyter_output><empty_output><jupyter_text>Getting the data<jupyter_code>#export
class RTTDataProvider(GBEProvider):
    '''This class builds upon GBEProvider to get the working memory task data.'''
    def __init__(self, data_folder_path):
        GBEProvider.__init__(self, data_folder_path)
dp = RTTDataProvider('/Users/hilmarzech/Projects/trr265/trr265/data/')<jupyter_output><empty_output><jupyter_text>Parsing output strings<jupyter_code>#export
@patch
def decode_rtt_strings(self:RTTDataProvider, gbe_data):
    df = self.decode_gbe_strings(gbe_data, "RewardAndHappinessGame")
    # Calculating outcome variables
    df['trial_type'] = np.nan
    df.loc[(df.choiceamount.astype(float) < 0),'trial_type'] = 'loss'
    df.loc[(df.choiceamount.astype(float) > 0),'trial_type'] = 'win'
    df.loc[(df.choiceamount.astype(float) == 0),'trial_type'] = 'mixed'
    df['result'] = df.trialresult.replace({'1':'gain', '2': 'loss', '3':'certain'})
    df['gambled'] = df.result!='certain'
    # Filtering variables of interest
    df = df[["gbe_index","trial_number","timestarted", "timesubmitted", "choiceamount", "decisiontime", "happiness", "happinessstart", "happinesstime" ,"spinnerangle", "spinnerloseamount", "spinnerwinamount", "spintime", "trial_type","trialresult","gambled"]]
    return df<jupyter_output><empty_output><jupyter_text>Getting the data<jupyter_code>#export
@patch
@get_efficiently
def get_rtt_data(self:RTTDataProvider):
    gbe_data = self.get_gbe_data()
    df = self.decode_rtt_strings(gbe_data)
    return df
df = dp.get_rtt_data(update = True)
df<jupyter_output>Preparing rtt_data
{'fraction_non_alphanumeric': 0.13102019678922838, 'fraction_numerical': 0.00983946141895391, 'mean_word_length': 6.918032786885246, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '618716', 'license': 'Apache-2.0', 'n_tokens_mistral': 714, 'n_tokens_neox': 677, 'n_words': 123, 'path': 'notebooks/08_gbe.rtt.data_provider.ipynb', 'repo_name': 'hgzech/trr265', 'size': '1931'}