Skip to content

Instantly share code, notes, and snippets.

@divyanganar
Last active July 15, 2019 05:54
Show Gist options
  • Save divyanganar/4f09638ec01455c0d7d72efc3d1d90ff to your computer and use it in GitHub Desktop.
Save divyanganar/4f09638ec01455c0d7d72efc3d1d90ff to your computer and use it in GitHub Desktop.
Bandpass filter with FSL's fslmaths using Matlab
path = '/data/nimble/work/Divyangana_Rakesh/resting_state/t3/fmriprep';
subjectNames = dir(sprintf('%s',path));
subs = startsWith({subjectNames.name},'sub') & ~contains({subjectNames.name},'.html');
subject_names = {subjectNames.name};
subject_names = subject_names(subs);
TR = 1.4;
upper=((1/TR)/2)*100; upper=num2str(upper);
lower=((1/TR)/2)*10; lower=num2str(lower);
for i = 7:length(subject_names)
cd (sprintf('%s/%s/func',path,subject_names{i}))
zipped_file = sprintf('%s_task-rest_space-MNI152NLin2009cAsym_desc-smoothAROMAnonaggr_bold.nii.gz',subject_names{i});
system(['mv ' , zipped_file , ' ' , subject_names{i}, '_bold.nii.gz'])
fmrifile = sprintf('%s_task-rest_space-MNI152NLin2009cAsym_desc-smoothAROMAnonaggr_bold.nii',subject_names{i});
fprintf('calculating the mean image for %s, index: %d\n',subject_names{i},i);
system(['/usr/local/fsl/bin/fslmaths ' , fmrifile , ' -Tmean mean.nii.gz']);
fprintf('bandpass filtering for %s, index: %d\n',subject_names{i},i)
system(['fslmaths ' , fmrifile , ' -bptf ' upper ' ' lower ' -add mean.nii.gz ' , extractBefore(fmrifile,'_task') ,'_bptf_' extractAfter(fmrifile,'desc-')]);
delete('mean.nii.gz');
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment