<jupyter_start><jupyter_text>**Code for preprocessing the WCST task (jsPsych)**1. Click the FOLDER ikon in the left column (last icon)2. In the opening window, click the UPLOAD icon (first icon) (if another window opens before this step, click OK)3. In the opening window, choose the WCST outputs for the upload (e.g., "_Subject_01_Session_1_output.csv")4. Run the coe with the Runtime --> Run all option5. If the code runs correctly, it will download a .csv file to your local machine------<jupyter_code>import glob
import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
import pandas as pd
import os
import numpy as np
from google.colab import files
# get data file names
filenames = glob.glob("*.csv")
dfs = []
for filename in filenames:
    dfs.append(pd.read_csv(filename, encoding='ISO-8859-1'))

# Concatenate all data into one DataFrame
big_frame = pd.concat(dfs, ignore_index=True)
big_frame
#leave only the important columns
df = big_frame.loc[:, ['Participant Public ID', 'STAT_nr_of_trials','STAT_p_of_correct_trials','STAT_nr_of_perseverative_responses','STAT_nr_of_perseverative_errors','STAT_nr_of_non_perseverative_errors','STAT_p_perseverative_errors','STAT_nr_of_total_errors','STAT_p_of_errors','STAT_category_achieved','STAT_p_of_conceptual_level_responses','STAT_failure_to_maintain_set','STAT_trials_to_complete_first_category']]
df.head()
#drop instruction, feedback trials
df = df.dropna(subset=['STAT_nr_of_trials'])
df.head()
#save data
df.to_csv("wcst.csv",index=False)
files.download("wcst.csv")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10620601407549585, 'fraction_numerical': 0.008317338451695458, 'mean_word_length': 7.145833333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '663839', 'license': 'MIT', 'n_tokens_mistral': 534, 'n_tokens_neox': 522, 'n_words': 143, 'path': 'WCST_jsPsych_analysis.ipynb', 'repo_name': 'laschmid/WCST_jsPsych', 'size': '1563'}