Skip to content

Commit

Permalink
Added SPM scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljwilson committed Jul 12, 2019
1 parent 434d608 commit 12754ad
Show file tree
Hide file tree
Showing 53 changed files with 7,352 additions and 208 deletions.
Binary file not shown.
104 changes: 104 additions & 0 deletions 3_experiment/3_3_data_analysis_fr/spm/UTSC_cluster_wrapper.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
function UTSC_cluster_wrapper(varargin)
% function UTSC_cluster_wrapper([modelID],[numworkers],[startSubj])
%
% Function for submitting a single-subject GLM analysis to be run
% on the computing cluster at UTSC.
%
% If submitted with no arguments, will prompt the user for the model ID,
% the number of nodes/workers to use, and the subject ID to start with
%
% Can also be run as a function, submitting the following optional
% arguments:
% modelID (e.g. '1_Preference'): a string identifying the name of the model
% - if calling as a function, modelID is a mandatory argument
% 'NumWorkers', followed by a number, indicating nodes to be used (default:
% 12)
% 'startSubj', followed by starting index of subject: a variable that
% allows you to skip some subjects and start later in the list

pathtofile = mfilename('fullpath');
homepath = pathtofile(1:(regexp(pathtofile,'derivatives')-1));

addpath(fullfile(homepath, 'derivatives','spm','code'))

% if called with arguments, use them, otherwise get them from user
if isempty(varargin)
model = input('Which model to run?: ', 's');
numWorkers = input('How many workers to request?: ');
startID = input('Which subject to start with?: ');
else
model = varargin{1};
if length(varargin) > 1
numWorkers = varargin{2};
else
numWorkers = 12;
end

if length(varargin) > 2
startID = varargin{3};
else
startID = 1;
end
end

if isempty(numWorkers)
numWorkers = 12;
end

if isempty(startID)
startId = 1;
end

%% get subject info and create submission info for each node
cd(homepath)

% load(fullfile('derivatives', 'spm','code','subject_list.mat')); % subject IDs for each study

subject_list; % creates subject list variables

numSubjects = length(good_subjects.subjects);

%% schedule tasks
clu=parcluster('default_jobmanager');

pjob=createJob(clu,'RestartWorker',logical(1),'NumWorkersRange', [1, numWorkers]);
set(pjob,'AdditionalPaths',{...
fullfile(homepath,'derivatives','spm','code'),...
'/psyhome/u7/hutchers/matlabextras/', ...
['/psyhome/u5/wilso603/Matlab/spm8']})

for s = startID:numSubjects
eval(['createTask(pjob, @' ...
['foodreg_m' model '_analyze2']...
', 0 ,{''' all_subjects.subjects{s} '''},''MaximumRetries'',50);'])
end
t = get(pjob,'Tasks');
submit(pjob)

%% start monitoring job progress
%
% results = fetchOutputs(pjob);
%
% %% check for errors
% nErrors = 0;
% idError = [];
% for i = 1:length(t)
% if ~isempty(t(i).ErrorMessage)
% nErrors = nErrors+1;
% idError = [idError i];
% end
% end
%
% %% housecleaning: delete job info if no errors
% if nErrors == 0
% dirname = pjob.Name;
% pause(2)
% unix(['rm -r ' homepath 'jobdata/' dirname '*']);
% fprintf('\nJob successfully completed.\n\n')
% else
% fprintf('Errors were detected! History of first error: \n\n')
% t(idError(1))
% end
%
% finished_jobs = findJob(clu,'State','finished','Username','hutchers');
% delete(finished_jobs);
61 changes: 61 additions & 0 deletions 3_experiment/3_3_data_analysis_fr/spm/batch_run.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

% ANALYZE
% foodreg_m1_Preference_analyze2(new_subjects.subjects, 'SubjectData_icaAroma_nonAggr_6mm')
% foodreg_m1_PostPre_analyze2(new_subjects.subjects, 'SubjectData_icaAroma_nonAggr_6mm')
% foodreg_m1_TasteHealth_analyze2(new_subjects.subjects, 'SubjectData_icaAroma_nonAggr_6mm')
%
% foodreg_m1_Preference_analyze2(new_subjects.subjects, 'SubjectData_MNI152_8mm')
% foodreg_m1_PostPre_analyze2(new_subjects.subjects, 'SubjectData_MNI152_8mm')
% foodreg_m1_TasteHealth_analyze2(new_subjects.subjects, 'SubjectData_MNI152_8mm')
% foodreg_m4_preference_a_pre_m_post_analyze2(good_subjects.subjects, 'SubjectData_MNI152_8mm')
% foodreg_m5_preference_a_reg_success_lasting_analyze2(good_subjects.subjects, 'SubjectData_MNI152_8mm')
% foodreg_m7_preference_a_reg_success_lasting_post_trial_analyze2(remaining_subjects.subjects, 'SubjectData_MNI152_8mm')
% foodreg_m8_pre_liking_analyze2(remaining_subjects.subjects, 'SubjectData_MNI152_8mm')

% CONTRASTS
preproc_version = 'SubjectData_MNI152_8mm';
%
% contrast2_par_m1_preference(good_subjects.subjects, preproc_version);
% contrast2_par_m2_taste_a_health(good_subjects.subjects, preproc_version);
% contrast2_par_m3_pre_m_post(good_subjects.subjects, preproc_version);
% contrast2_par_m4_preference_a_pre_m_post(good_subjects.subjects, preproc_version);
% contrast2_par_m5_preference_a_reg_success_lasting(good_subjects.subjects, preproc_version);
% contrast2_par_m7_preference_a_reg_success_lasting_post_trial(good_subjects.subjects, preproc_version);
% contrast2_par_m8_pre_liking(good_subjects.subjects, preproc_version);


% 2ND LEVEL
% cd /Volumes/DJW_Lacie_01/PROJECTS/2018_Food_Reg_fMRI/09_DATA/food_reg_fmri_01/analysis/SPM/
% f = fullfile('m1_Preference', preproc_version, 'm1_Preference_cons.mat');
% load(f);
% for con = 1:length(cname)
% rfx_par('m1_Preference',cname(con),good_subjects,preproc_version)
% end
%
% cd /Volumes/DJW_Lacie_01/PROJECTS/2018_Food_Reg_fMRI/09_DATA/food_reg_fmri_01/analysis/SPM/
% f = fullfile('m2_taste_a_health', preproc_version, 'm2_taste_a_health_cons.mat');
% load(f);
% for con = 1:length(cname)
% rfx_par('m2_taste_a_health',cname(con),good_subjects,preproc_version)
% end
%
% cd /Volumes/DJW_Lacie_01/PROJECTS/2018_Food_Reg_fMRI/09_DATA/food_reg_fmri_01/analysis/SPM/
% f = fullfile('m3_pre_m_post', preproc_version, 'm3_pre_m_post_cons.mat');
% load(f);
% for con = 1:length(cname)
% rfx_par('m3_pre_m_post',cname(con),good_subjects,preproc_version)
% end

% cd /Volumes/DJW_Lacie_01/PROJECTS/2018_Food_Reg_fMRI/09_DATA/food_reg_fmri_01/analysis/SPM/
% f = fullfile('7_preference_a_reg_success_lasting_post_trial', preproc_version, 'm7_preference_a_reg_success_lasting_post_trial_cons.mat');
% load(f);
% for con = 1:length(cname)
% rfx_par('7_preference_a_reg_success_lasting_post_trial',cname(con),good_subjects,preproc_version)
% end

cd /Volumes/DJW_Lacie_01/PROJECTS/2018_Food_Reg_fMRI/09_DATA/food_reg_fmri_01/analysis/SPM/
f = fullfile('8_pre_liking', preproc_version, 'm8_pre_liking_cons.mat');
load(f);
for con = 1:length(cname)
rfx_par('8_pre_liking',cname(con),good_subjects,preproc_version)
end

0 comments on commit 12754ad

Please sign in to comment.