<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Mixed Data DDM
DDM using both patient and matched control data
Step1:  Start by parsing the .mat files from the matched controls
Step2:  Clean up - remove nan entries as these cause hddm to fail
Step3:  Merge patient and matched control data to single .csv file
First, create tagged versions of the csv files - include "tag" column to differentiate between patient and control
Step4:  Build HDDM model
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%cd ..
import warnings; warnings.filterwarnings('ignore')
Explanation: Mixed Data DDM
DDM using both patient and matched control data
End of explanation
from utils import matparser, data_compiler
import glob
data_dir = 'data/controls/'
matparser.parse_dir(data_dir)
out_dir = "data/controls.csv"
data_compiler.compile_dir(data_dir, out_dir)
Explanation: Start by parsing the .mat files from the matched controls
End of explanation
!cat data/controls.csv | grep -v nan > data/controls_clean.csv 
Explanation: Clean up - remove nan entries as these cause hddm to fail
End of explanation
!cat data/patients_clean.csv | sed 1d | awk -v d="patient" -F"," 'BEGIN { OFS = "," } {$5=d; print}' | tr -d $'\r' > data/patients_tagged.csv
!cat data/controls_clean.csv | sed 1d | awk -v d="control" -F"," 'BEGIN { OFS = "," } {$5=d; print}' | tr -d $'\r' > data/controls_tagged.csv
!echo "response,rt,subj_idx,stim,subj_type" > data/combined_clean.csv
!cat data/patients_tagged.csv >> data/combined_clean.csv; sed 1d data/controls_tagged.csv >> data/combined_clean.csv
Explanation: Merge patient and matched control data to single .csv file
First, create tagged versions of the csv files - include "tag" column to differentiate between patient and control
End of explanation
import hddm
data = hddm.load_csv('data/combined_clean.csv')
model = hddm.HDDM(data, depends_on={'v': ['stim', 'subj_type'], 'a': 'subj_type'})
model.find_starting_values()
model.sample(6000, burn=20)
Explanation: Build HDDM model
End of explanation
<END_TASK>