Created
April 20, 2022 11:44
-
-
Save JohnAtl/5f4c3f4b5651d4163ae246d852034e7a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This is kind of a mashup with | |
# https://github.com/miykael/nipype-beginner-s-guide/blob/master/scripts/example_fMRI_1_first_level.py | |
# | |
def subjectinfo(subject_id): | |
import pandas as pd | |
from nipype.interfaces.base import Bunch | |
path = '/data/sub-%s/func' % subject_id | |
subject_info = [] | |
for run in run_list: | |
trialfile = 'sub-%s_task-%s_run-%s_events.tsv' % (subject_id, task_list[0], run) | |
trialinfo = pd.read_table(opj(path, trialfile)) | |
conditions = [] | |
onsets = [] | |
durations = [] | |
for trial_type in trialinfo.groupby('trial_type'): | |
conditions.append(trial_type[0]) | |
onsets.append(list(round(trial_type[1].onset,2))) | |
durations.append(round(trial_type[1].duration).tolist()) | |
subject_info.insert(int(run), | |
Bunch(conditions=conditions, | |
onsets=onsets, | |
durations=durations, | |
amplitudes=None, | |
tmod=None, | |
pmod=None, | |
regressor_names=None, | |
regressors=None)) | |
return subject_info # this output will later be returned to infosource | |
# Get Subject Info - get subject specific condition information | |
getsubjectinfo = Node(Function(input_names=['subject_id'], | |
output_names=['subject_info'], | |
function=subjectinfo), | |
name='getsubjectinfo') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment