https://github.com/samsydco/HBN
Tip revision: 278127d07b721c73679c11d0d1836631df778323 authored by samsydco on 16 May 2022, 17:49:03 UTC
Update README
Update README
Tip revision: 278127d
3_fmriprep.py
#!/usr/bin/env python3
# Documentation for fmriprep version 1.1.4:
# https://fmriprep.org/en/1.1.4/usage.html
import subprocess as sp
import glob
import pandas as pd
import numpy as np
import os
from tqdm import tqdm
import datetime
from settings import *
site = 'Site-CBIC'
#site = 'Site-RU'
compcsv = TRratingdr+'compT1_'+site+'.csv'
compdf = pd.read_csv(compcsv)
plist = []
for index, row in compdf.iterrows():
if ((str(row['final']) != "n" and str(row['final'])!='nan') and
not os.path.exists(fmripreppath+row['sub']+'.html')):
#len(glob.glob(fmripreppath+row['sub']+'/figures/*sdc*'))!=2):
plist.append(row['sub'])
plist = plist[:75]
nchunk = 4 # number of items per chunk (maybe use 10?)
pchunk = [plist[x:x+nchunk] for x in range(0,len(plist),nchunk)]
if __name__ == "__main__":
# stuff only to run when not called via 'import' here
password = input('Type the password for scohen@sophon.columbia.edu:')
# Run participants in batches of nchunk - check what is max?:
# Delete extra BOLD stuff
for chunk in tqdm(pchunk):
pstr = ' '.join(chunk)
for task in ['DM']:
date = str(datetime.datetime.now())[0:19].replace(' ','_')
f = open("%sfmriprep_cmdoutput/%s_%s_%s.txt"%(path,task,date,pstr.replace(" ","_")), "w")
# "-t" in docker instead of "-it" :)
command = ('docker run --rm -t -u 14128:13110 -v /usr/local/freesurfer/license.txt:/opt/freesurfer/license.txt:ro -v '+path+site+':/data:ro -v '+outputdr+':/out -v '+tmpdr+':/scratch poldracklab/fmriprep:1.1.4 /data /out participant --ignore slicetiming fieldmaps --use-syn-sdc --output-space template fsaverage6 --participant_label '+pstr+' -t movie'+task+' -w /scratch').split()
p = sp.Popen(['sudo', '-S'] + command, stdin=sp.PIPE, stderr=sp.PIPE,
universal_newlines=True,stdout=f)
p.communicate(password + '\n')[1]