Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example illustrating data preprocessing of fMRIprep outputs for use i… #64

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ramroomh
Copy link

Grabs data using pybids
Makes glmsingle compatible event files from .tsv event files in BIDS format
Resamples bold timeseries
Smooths bold timeseries
Batches runs by subject and executes

@kendrickkay kendrickkay requested a review from iancharest May 23, 2022 16:48
Copy link
Contributor

@Remi-Gau Remi-Gau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question:
is this supposed to be
A) an example on a specific frmriprep dataset and its raw counterpart?
B) something more generic that could apply to any BIDS derivatives?

If A then this will work better if the dataset is openly accessible (openneuro?).

If B then the code needs to be made more generic.

Option A sounds way easier unless you feel like embarking on a journey to create a BIDS app.

@@ -0,0 +1,187 @@
#!/group/tuominen/anaconda3/bin/python3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need to change this to make the code more portable

import numpy as np
import nibabel as nib
import pandas as pd
from bids import BIDSLayout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect you will need to add a requirements.txt to mention pybids need to be installed

Comment on lines +67 to +75
new_name['suffix'] = 'events_glmsingle'
pattern = 'sub-{}_ses-{}_task-{}_run-{}_{}.csv'
# Save the event file in derivatives, exclude TR column
new_design.to_csv(os.path.join(root, 'derivatives', 'iter4',
'sub-'+new_name['subject'], 'ses-'+new_name['session'], 'func',
pattern.format(new_name['subject'],
new_name['session'], new_name['task'], new_name['run'],
new_name['suffix'])), columns=['CSplusshock','CSplus','CSminus'],
index=False, header=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably :
A) want to use pybids build_path methods (https://bids-standard.github.io/pybids/generated/bids.layout.writing.html#module-bids.layout.writing) that should happily accept the dict of entities you have just created.
B) want to give a BIDS friendly name to your output file: keep events as suffix but add a desc-glmsingle entity

def smooth_bold(processed, smooth_num, subjects):
''' Smooth data prior to first-level analysis using FSL in nipype.
Output will have suffix _smooth appended.'''
from nipype.interfaces.fsl import Smooth
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe I missed it but you did not import nipype, right?
and I don't think it is a dependency of glmsingle so this should probably go into the requirements

also not a python expert, but do we have to go through nipype FSL interface to smooth the data? Doesn't that pre supposes that people have FSL installed on their system?

gs = GLM_single()
# Name output folders
metadata = processed.parse_file_entities(bold_runs[0])
outdir = os.path.join(os.path.dirname(bold_runs[0]), metadata['task'] + '_concat_glmsingle')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above to have BIDS friendly filenames

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants