54 lines
1.7 KiB
(Stored with Git Annex)
Python
54 lines
1.7 KiB
(Stored with Git Annex)
Python
'''
|
|
Purpose
|
|
How to Run
|
|
Marisa Lytle
|
|
Feb 2020
|
|
'''
|
|
|
|
from beh_process import calc_rt_acc
|
|
from dicom_proc import dicom_proc
|
|
import pandas as pd
|
|
import sys
|
|
import os
|
|
|
|
#asks for the rows of match that you would like to convert. Starting at zero with inclusive end point.
|
|
start = int(sys.argv[1])
|
|
end = int(sys.argv[1]) + 240
|
|
|
|
|
|
def main():
|
|
global start, end
|
|
eprime_merge = "./all_data_with_onsets.csv"
|
|
bidspath = "/dors1/gpc/JamesBooth/JBooth-Lab/BDL/ELP/bids/"
|
|
#read in data
|
|
print("reading in e-prime data from " + eprime_merge)
|
|
eprime_data = pd.read_csv(eprime_merge)
|
|
|
|
matches_csv = pd.read_csv('matched_dicoms.csv')
|
|
|
|
if end > len(matches_csv):
|
|
end = len(matches_csv)
|
|
|
|
matches_csv = matches_csv[start:end]
|
|
shifts = pd.read_csv('./Shift_amount.csv')
|
|
matches_csv = pd.merge(matches_csv, shifts, on='subject', how='left')
|
|
|
|
|
|
for x in range(len(matches_csv)):
|
|
info = matches_csv.iloc[x]
|
|
print("converting nii data for " + str(info.subject) + " " + str(info.task) + " " + str(info.eprime_unique))
|
|
run_data = eprime_data[(eprime_data['unique_time'] == info.eprime_unique)].reset_index(drop=True)
|
|
shifted_date = run_data['ShiftedSessionDate'][0]
|
|
|
|
run_data, events = calc_rt_acc(run_data)
|
|
nii_name, source_folder, out_folder = dicom_proc(bidspath,info,shifted_date)
|
|
|
|
eprime_name = nii_name + "_events.tsv"
|
|
|
|
|
|
run_data.to_csv(os.path.join(source_folder,eprime_name), sep='\t', index=False)
|
|
events.to_csv(os.path.join(out_folder,eprime_name), sep='\t', index=False)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|