parfor EEG_temp=10:100;
EEG_temp_filter=filter(ones(1,EEG_temp),1,EEG_amp_vals(eeg_temp_subset,:),[],2);
EEG_vertices=eeg_temp_subset((max(EEG_temp_filter,[],2)==EEG_temp)>0);
connected_EEG_vertices=EEG_vertices((sum(surface.VertConn(EEG_vertices,EEG_vertices))>=2)>0);
if length(connected_EEG_vertices)<5000 && length(connected_EEG_vertices)>500
for fMRI_index=1:length(fMRI_thresholds);
signal_union=union(connected_EEG_vertices,unique(fMRI_Vertices(fMRI_index,:)));
signal_intersection=intersect(connected_EEG_vertices,unique(fMRI_Vertices(fMRI_index,:)));
Overlap=length(signal_intersection)/length(signal_union)*100;
highest_overlap=max(highest_overlap,Overlap)-Overlap;
if highest_overlap==0;
EEG_amp_value=[EEG_amp_value,EEG_amp];
EEG_temp_value=[EEG_temp_value,EEG_temp];
fMRI_amp_value=[fMRI_amp_value,fMRI_thresholds(fMRI_index)/100];
highest_overlap=max(highest_overlap,Overlap);
end
end
end % end of if
% eeg_temp_subset=EEG_vertices;
end %end of EEG_temp
This code is trying to maximize three variables, EEG_temp, EEG_amp, and fMRI_amp to determine which combination produces the highest overlap. Since there is 10s if not hundreds of thousands of combinations I thought parfor would help in speeding the analysis, since I have a cluster that can devote 16 cores to the task.
The problem I am having is with the highest_overlap variable. If I define it outside of the parfor loop, MATLAB won't even let me start running the analysis because it is defined outside the parfor loop, however, if I don't define it outside the parfor loop MATLAB crashes when it gets to the parfor loop because it isn't defined.
Can anyone offer a suggestion to fix the problem I have? I think the IF statement may have something to do with it, I had to define the highest_overlap the way it is where it is a differential because if I just did if highest_overlap==overlap, it told me I was misusing the highest_overlap variable. So I will take any solutions to get this code to work that you may have. Whether it is a change to the way highest overlap is used or to the entire code structure so long as it runs.
parfor) but an optimization function. Have a look atfminsearchand friends.highest_overlap. Where are you changingEEG_ampin your code, I don't really get how it works.