-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAFNI_3dTproject_faces.py
executable file
·63 lines (54 loc) · 2.89 KB
/
AFNI_3dTproject_faces.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
import glob
from shutil import copyfile
import pandas as pd
import json
import numpy as np
from subprocess import call
import sys
## Frame wise displacement isn't here
fmriprep_out="/data/jux/cnds/amennen/rtAttenPenn/fmridata/Nifti/derivatives/fmriprep"
task_path = '/data/jux/cnds/amennen/rtAttenPenn/fmridata/behavdata/faces'
run_path = '/data/jux/cnds/amennen/rtAttenPenn/fmridata/Nifti/derivatives/afni/first_level/normalized_runs_baseline'
cf_dir = '/data/jux/cnds/amennen/rtAttenPenn/fmridata/Nifti/derivatives/fsl/first_level/confound_EVs'
timing_path = '/data/jux/cnds/amennen/rtAttenPenn/fmridata/Nifti/derivatives/afni/first_level/timing_files'
analyses_out = '/data/jux/cnds/amennen/rtAttenPenn/fmridata/Nifti/derivatives/afni/first_level/stats'
whole_brain_mask = '/data/jux/cnds/amennen/rtAttenPenn/MNI_things/mni_icbm152_t1_tal_nlin_asym_09c_BOLD_mask_Penn.nii'
subjectNum = np.int(sys.argv[1])
bids_id = 'sub-{0:03d}'.format(subjectNum)
# concatenate confound EVS
print(bids_id)
sessions = [1,3]
nRuns = 2
for s in sessions:
subjectDay = s
ses_id = 'ses-{0:02d}'.format(subjectDay)
print(ses_id)
confounds_dir = cf_dir + '/' + bids_id + '/' + ses_id
run1_cf = confounds_dir + '/' + bids_id + '_' + ses_id + '_' + 'task-faces_rec-uncorrected_run-01_bold_confounds.tsv'
run2_cf = confounds_dir + '/' + bids_id + '_' + ses_id + '_' + 'task-faces_rec-uncorrected_run-02_bold_confounds.tsv'
r1_tsv = pd.read_csv(run1_cf, sep='\t')
r2_tsv = pd.read_csv(run2_cf, sep='\t')
frames = [r1_tsv,r2_tsv]
newdf = pd.concat(frames)
full_save_path = confounds_dir + '/' + bids_id + '_' + ses_id + '_' + 'task-faces_rec-uncorrected_COMBINED_bold_confounds.1D'
newdf.to_csv(full_save_path, sep='\t',index=False,header=False)
if not os.path.exists(full_save_path):
newdf.to_csv(full_save_path, sep='\t',index=False,header=False)
output_path = "{0}/{1}/{2}".format(analyses_out,bids_id,ses_id)
if not os.path.exists(output_path):
cmd = 'mkdir -pv {0}'.format(output_path)
call(cmd,shell=True)
# look at how many jobs it's using bc it might be trying to use all CPUs/jobs that are available
# put a mask *****-- some brain mask for the template space to be used for every subject
# automask will only run for each person with what it sense is the brain
# removing polort A
cmd = ("3dTproject -stopband 0 0.01 "
"-input "
"{0}/{1}/{2}/{1}_{2}_task-faces_rec-uncorrected_run-01_bold_space-MNI152NLin2009cAsym_preproc.nii.gz "
"{0}/{1}/{2}/{1}_{2}_task-faces_rec-uncorrected_run-02_bold_space-MNI152NLin2009cAsym_preproc.nii.gz "
"-mask {4} "
"-ort {3} "
"-prefix {5}/{1}/{2}/{1}_{2}_task-faces_glm_3dtproject.nii.gz ".format(run_path,
bids_id, ses_id,full_save_path,whole_brain_mask,analyses_out))
call(cmd,shell=True)