Initialize Environment


In [3]:
try:
    %load_ext autoreload
    %autoreload 2
    
except:
    print 'NOT IPYTHON'

from __future__ import division
from IPython.display import display

import os
import sys
import glob
import json
import subprocess

import numpy as np
import pandas as pd
import seaborn as sns
import scipy.io as io
import h5py
import matplotlib.pyplot as plt
from matplotlib import rcParams

import fig_plotting
rcParams = fig_plotting.update_rcparams(rcParams)

import scipy.stats as stats

os.chdir('../')
import Codebase
conv_adj_matr_to_cfg_matr = Codebase.Networks.configuration.convert_adj_matr_to_cfg_matr
conv_cfg_vec_to_adj_matr = Codebase.Networks.configuration.convert_conn_vec_to_adj_matr
os.chdir('./Analysis_Notebooks/')

path_Remotes = '/Users/akhambhati/Remotes'
path_CoreData = path_Remotes + '/CORE.fMRI_cogcontrol.medaglia'
path_RsrchData = path_Remotes + '/RSRCH.NMF_CogControl'
path_ExpData = path_RsrchData + '/e05-BehStat'

for path in [path_CoreData, path_RsrchData, path_ExpData]:
    if not os.path.exists(path):
        print('Path: {}, does not exist'.format(path))
        os.makedirs(path)


The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

Load Behavioral Data


In [4]:
df_beh = io.loadmat('{}/BehavioralData_CogControlCorrect.mat'.format(path_CoreData))

stroop_lbl = [lbl[0] for lbl in df_beh['StroopLabels'][0]]
navon_lbl = [lbl[0] for lbl in df_beh['NavonLabels'][0]]
stroop_beh = df_beh['StroopCorrectOnly']
navon_beh = df_beh['NavonCorrectOnly']

bad_subj_ix = [1, 6]
good_subj_ix = np.setdiff1d(np.arange(stroop_beh.shape[0]), bad_subj_ix)

print('Stroop Labels: {}'.format(stroop_lbl))
print('Navon Labels: {}'.format(navon_lbl))

stroop_move = io.loadmat('{}/StroopMove.mat'.format(path_CoreData))['move'][:, 0]
navon_move = io.loadmat('{}/NavonMove.mat'.format(path_CoreData))['move'][:, 0]


Stroop Labels: [u'Total Accuracy', u'Interference Accuracy', u'NoInterference Accuracy', u'MeanRT', u'MedianRT', u'InterferenceMeanRT', u'InterferenceMedianRT', u'NoInterferenceMeanRT', u'NoInterferenceMedianRT', u'InterferenceMedianRTMinusMeanRT']
Navon Labels: [u'Total Accuracy', u'ShiftingAccuracy', u'NoShiftingAccuracy', u'MeanRT', u'MedianRT', u'ShiftingMeanRT', u'ShiftingMedianRT', u'NoShiftingMeanRT', u'NoShiftingMedianRT', u'ProportionTotalNonResponses']

Compare Task Performance


In [8]:
%matplotlib inline

stroop_interf_acc = stroop_beh[:, 1]
navon_interf_acc = navon_beh[:, 1]

stroop_noninterf_acc = stroop_beh[:, 2]
navon_noninterf_acc = navon_beh[:, 2]

stroop_cost_acc = stroop_noninterf_acc - stroop_interf_acc
navon_cost_acc = navon_noninterf_acc - navon_interf_acc

plt.figure()
ax = plt.subplot(111)
print(stats.wilcoxon(stroop_interf_acc, navon_interf_acc))
ax.boxplot([stroop_interf_acc, navon_interf_acc])
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.set_xlabel('')
ax.set_xticklabels(['Stroop', 'Navon'])
ax.set_ylabel('Interference Accuracy')
plt.show()

plt.figure()
ax = plt.subplot(111)
print(stats.wilcoxon(stroop_cost_acc, navon_cost_acc))
ax.boxplot([stroop_cost_acc, navon_cost_acc])
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.set_xlabel('')
ax.set_xticklabels(['Stroop', 'Navon'])
ax.set_ylabel('Cost (Accuracy)')
plt.show()


stroop_interf_rt = stroop_beh[:, 5]
navon_interf_rt = navon_beh[:, 5]

stroop_noninterf_rt = stroop_beh[:, 7]
navon_noninterf_rt = navon_beh[:, 7]

stroop_cost_rt = stroop_interf_rt - stroop_noninterf_rt
navon_cost_rt = navon_interf_rt - navon_noninterf_rt


plt.figure()
ax = plt.subplot(111)
print(stats.wilcoxon(stroop_interf_rt, navon_interf_rt))
ax.boxplot([stroop_interf_rt, navon_interf_rt])
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.set_xlabel('')
ax.set_xticklabels(['Stroop', 'Navon'])
ax.set_ylabel('Mean Interference RT')
plt.show()

plt.figure()
ax = plt.subplot(111)
print(stats.wilcoxon(stroop_cost_rt, navon_cost_rt))
ax.boxplot([stroop_cost_rt, navon_cost_rt])
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.set_xlabel('')
ax.set_xticklabels(['Stroop', 'Navon'])
ax.set_ylabel('Mean Cost RT')
plt.show()


WilcoxonResult(statistic=14.0, pvalue=1.6789398011889547e-05)
WilcoxonResult(statistic=42.0, pvalue=8.9187274244596825e-05)
WilcoxonResult(statistic=0.0, pvalue=1.7343976283205784e-06)
WilcoxonResult(statistic=0.0, pvalue=1.7343976283205784e-06)

In [ ]: