-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparallelFun_SARA_Reaction.m
76 lines (61 loc) · 2.27 KB
/
parallelFun_SARA_Reaction.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
% function parallel_example_fun(job_nr)
%
% This function is an example to show how to use the parallelizing
% condor function CREATE_PARALLEL.m
%
% Kai Goergen, 27.3.2009
% Update: 25.6.2013 - Adapted to new infrastructure
function parallelFun_SARA_Reaction(job_nr1,job_nr2)
%% set path to your m-files
display(['Starting script for job nr ' num2str(job_nr1) '_' num2str(job_nr2)])
% example 1: add current path
curr_path = pwd;
addpath(curr_path) % adds path only for this session
% example 2: adding a folder with all it's subfolders, e.g. to add SPM
% spm_dir = '\analysis\share\spm8'
% addpath(genpath(spm_dir))
if ~exist('"$TMPDIR"/TMPResults')
mkdir('"$TMPDIR"/TMPResults')
end
addpath(genpath('"$TMPDIR"/TMPData')) % Set path
addpath(genpath('"$TMPDIR"/TMPResults')) % Set path
addpath(genpath('"$TMPDIR"/MVPA_Scripts')) %Set path
% cd('"$TMPDIR"/MVPA_Scripts')
% !!! check on Cartesius, that path is set correct
%% copy your data from the server to the local machine
%% run your script
% if you copy files, make sure to surround your script with a try/catch
% loop, so that you can still copy the resulting files back
try
% load('/home/enny/Documents/ADNI_NEW/TemporarySaveDir.mat');
% loadfile = [tempsave 'TemporarySave2']
% load(loadfile)
if ischar(job_nr2)
job_nr2 = str2num(job_nr2);
end
display(['Running script for job nr ' num2str(job_nr1) '_' num2str(job_nr2) ])
% call your script here, e.g.
% RunModel(job_nr, loadfile, X, T, nfolds)
SVMWideField_ReactionDecoder(job_nr1,job_nr2)
catch my_error
% display error and stack, and continue with the rest of the script
display_error_info(my_error)
display(['Script for job nr ' num2str(job_nr1) '_' num2str(job_nr2) ' aborted'])
end
%% copy you data back and clean up
% in case you are using a local directory, copy all data back to the net,
% and dont forget to delete the data on the remote machine afterwards
display(['Finished script for job nr ' num2str(job_nr1) '_' num2str(job_nr2)])
end
function display_error_info(ME)
ME
for curr_field = fieldnames(ME)'
display([curr_field{1} ':'])
display(ME.(curr_field{1}))
display(' ')
end
for stack_idx = 1:size(ME.stack, 1)
display(ME.stack(stack_idx))
display(' ')
end
end