def get_behav(r, s, txt=False): """Load behavioral data file for subject `s` on run `r` Remove bad activations based on `respcat` Parameters ---------- s : int Subject number r : int Run number Returns ------- behav : pd.DataFrame Examples -------- >>> get_behav(1, 1)[:5] onset duration gain loss PTval respnum respcat RT gain_ind 0 4 3 18 12 6.12 2 1 1.793 1 1 8 3 10 15 -4.85 3 0 1.637 0 2 18 3 34 16 18.16 1 1 1.316 1 3 24 3 18 5 13.05 1 1 1.670 1 4 28 3 26 13 13.13 2 1 1.232 1 """ s, r = n_convert(s, r) f_behav = '../data/ds005/sub'+s+\ '/behav/task001_run'+r+\ '/behavdata.txt' behav = pd.read_csv(f_behav, sep='\t') behav.insert(1, 'duration', 3) behav = behav[behav.respcat>=0] behav['gain_ind'] = (behav.gain >= behav.loss) * 1 behav.reset_index(drop=True, inplace=True) if txt == True: return f_behav else: return behav
def get_cond(r, s, c, txt=False): """Load condition data file `c` for subject `s` on run `r` Parameters ---------- r : int Run number s : int Subject number c : int Condition file Returns ------- cond : pd.DataFrame Examples -------- >>> get_cond(1, 1, 1)[:5] onset duration amplitude 0 0 3 1 1 4 3 1 2 8 3 1 3 18 3 1 4 24 3 1 """ s, r, c = n_convert(s, r, c) f_cond = '../data/ds005/sub'+s+\ '/model/model001/onsets/task001_run'+r+\ '/cond'+c+'.txt' cond = pd.DataFrame(np.loadtxt(f_cond), columns=['onset', 'duration', 'amplitude']) if txt == True: return f_cond else: return cond
def get_image(r, s): """Load .nii file for subject `s` on run `r` Parameters ---------- r : int Run number s : int Subject number Returns ------- Nifti1Image object Example ------- >>> get_image(1, 1).shape (64, 64, 34, 240) """ s, r = n_convert(s, r) f_img = '../data/ds005/sub'+s+\ '/BOLD/task001_run'+r+\ '/bold.nii.gz' return nib.load(f_img)