MATLAB Answers

Error detected on worker 8.

2 views (last 30 days)
Knut Jørgen
Knut Jørgen on 15 Jun 2020
Caused by:
fl:filesystem:PathNotFound
nofit = '10';
depvarno = 10;
outdir = '~/T1/ANALYSIS/LMR3/outdir/test/';
tempsdir = '/extra_space/T1/ANALYSIS/LMR3/outdir/temps/';
infile1 = '~/T1/ANALYSIS/LMR3/Subjects/lh_LMR3_area.MASK.s30.MASK.mgh';
infile2 = '~/T1/ANALYSIS/LMR3/Subjects/rh_LMR3_area.MASK.s30.MASK.mgh';
[lh, M, mr_parms, volsz] = load_mgh(infile1);lh=squeeze(lh);
[rh, M, mr_parms, volsz] = load_mgh(infile2);rh=squeeze(rh);
if size(lh,1) ~= size(rh,1)
error('diffrent size')
end
n=size(lh,1)
matrise = zeros(n,6);
prs=20
myCluster = parcluster('local')
delete(myCluster.Jobs)
if license('test','distrib_computing_toolbox')
if verLessThan('matlab','8.2.0.29')
if (prs==1) || (matlabpool('size') ~= prs)
if (matlabpool('size') > 0)
matlabpool close;
end;
if (prs>1)
matlabpool(prs);
end;
end;
else
pc = gcp('nocreate'); % If no pool, do not create new one.
if isempty(gcp('nocreate'))
if (prs>1)
parpool(prs);
end;
elseif (pc.NumWorkers ~= prs) || (prs==1)
if ~isempty(gcp('nocreate'))
delete(gcp('nocreate'))
end
if (prs>1)
parpool(prs);
end;
end;
end;
else
display(' ');
display('Warning: Parallel Computing Toolbox missing, things will be real slow ...');
end;
for hemis = 1:2
if lt(hemis,2)
hemi = 'lh.area';
hemisphere = lh;
else
hemi = 'rh.area';
hemisphere = rh;
end
c = Composite(prs);
%parfor i = 1:n
spmd
for i=1:n
try
in = sprintf('%d',i);
vektor = hemisphere(i,:)';
%tempoutfile=fullfile(tempsdir, 'vektortemp.csv');
%csvwrite(tempoutfile,vektor);
%Les inn uavh.vars
indepvarmatrix = readtext('~/T1/ANALYSIS/LMR3/Subjects/maps_26y_indepvars.csv');
indepvar=indepvarmatrix(2:end,:);
allvars = [cell2mat(indepvar) vektor];
depvar = allvars(:,depvarno);
sprshoutfile=sprintf('%s%s%s%s',[tempsdir hemi '_' in '_sprsheettemp.csv']); csvwrite(sprshoutfile,allvars);
% Modifiser .inp med relevant datafilnavn
mscriptnavn = strcat(hemi, '_', in, '_mscript.inp');
%editcommand1 = sprintf('%s%s%s%s%s%s%s%s',['!(cp /home/lmr/T1/ANALYSIS/LMR3/Mplus/FINAL_inps/LMR3_26y_map.inp ' tempsdir mscriptnavn ')'])
copyfile('~/T1/ANALYSIS/LMR3/Mplus/Final_inps/LMR3_26y_map_kjb.inp',fullfile(tempsdir,mscriptnavn));
replacestring(fullfile(tempsdir,mscriptnavn),'{datafil}',sprshoutfile,17)
%editcommand2 = sprintf('%s%s%s%s%s%s%s%s',['!(sed -i ' '''17s+{datafil}+' sprshoutfile '+' '''' ' ' tempsdir mscriptnavn ')']);
replacestring(fullfile(tempsdir,mscriptnavn),'bootstrap=100000','bootstrap=10',26)
%editcommand3 = sprintf('%s%s%s%s%s%s%s%s',['!(sed -i ' '''26s+100000+' nofit '+' '''' ' ' tempsdir mscriptnavn ')']);
%eval(editcommand1)
%eval(editcommand2)
%eval(editcommand3)
% Mplus
% iterasjon
fprintf('%s%s\n',['Iterasjon nummer: ' in])
% test
tempmatrise=zeros(1,6);
fprintf('iteration %d \n',i)
if ~isequal(sum(depvar),0)
% Kjør Mpluskommando
%utfil = sprintf('%s',[substr(mscriptnavn,0,17) '.out']);
utfil = strcat(hemi,'_',in,'_','.out');
utpathfil = fullfile(tempsdir, utfil);
mpluscommand = sprintf('%s%s%s%s%s',['(mplus ' tempsdir mscriptnavn ' ' utpathfil ')']);
%eval(mpluscommand);
system(mpluscommand);
% Høst outputvar (statistic) fra outputfilen til Mplus
% greputfil = sprintf('%s%s%s%s',[outdir 'grepout_Pvals_' hemi '_' in '.out']);
% grepcommand0 = sprintf('%s%s%s%s%s%s%s%s',['!(grep -A 4 ' '''Specific indirect''' ' ' utpathfil ')' ])
% eval(grepcommand0)
% grepcommand = sprintf('%s%s%s%s%s%s%s%s',['!(grep -A 4 ' '''Specific indirect''' ' ' utpathfil ' > ' greputfil ')' ])
% eval(grepcommand);
% Les inn fra grepfil
%lesinncommand = sprintf('%s%s%s%s',[readtext
[grepstuff,P] = grep("Specific indirect",fullfile(utpathfil));
first=P.line(1);
second=P.line(2);
grepstuff=readtext(fullfile(utpathfil));
firstf=grepstuff(first:first+3,1);
secondf=grepstuff(second:second+3,1);
pval=split(firstf{4,1});
P = str2double(pval{5,1});
%pval = split(grepstuff{5});ci=split(grepstuff{11});
P = str2double(pval{5});
estimat = str2double(pval{2});
ci=split(secondf{4,1});
ciLOW=str2double(ci{2}); ciHIGH=str2double(ci{5}); % 2 og 5 eller 3 og 6
ciLOW3=str2double(ci{3}); ciHIGH6=str2double(ci{6});
%delgrepcommand = sprintf('%s%s%s',['!(rm ' greputfil ')']);eval
delete(utpathfil)
delete(fullfile(tempsdir,mscriptnavn));
delete(sprshoutfile)
tempmatrise(1,1) = P;
tempmatrise(1,2) = estimat;
tempmatrise(1,3) = ciLOW;
tempmatrise(1,4) = ciHIGH;
tempmatrise(1,5) = ciLOW3;
tempmatrise(1,6) = ciHIGH6;
% Lagre the statistic i en matrise
% matrise(i,1) = P;
% matrise(i,2) = estimat;
% matrise(i,3) = ciLOW;
% matrise(i,4) = ciHIGH;
% matrise(i,5) = ciLOW3;
% matrise(i,6) = ciHIGH6;
%elseif ~isequal(mean(depvar),0)
% matrise(i,1) = 0;
% matrise(i,2) = 0;
% matrise(i,3) = 0;
% matrise(i,4) = 0;
% matrise(i,5) = 0;
% matrise(i,6) = 0;
else
delete(fullfile(tempsdir,mscriptnavn));
delete(sprshoutfile)
end
catch
tempmatrise=NaN(1,6);
end
matrise(i,:) = tempmatrise;
end
c(labindex)
end
% Skriv ut matrisen
finaloutfilepathname = sprintf('%s%s%s',[outdir hemi '_final-matrise.csv']);
csvwrite(finaloutfilepathname,matrise);
poutfile = fullfile(outdir,strcat(hemi, '_outfile.P.mgh'));
estoutfile = fullfile(outdir, strcat(hemi,'_outfile.P.mgh'));
CIlowoutfile = fulfile(outdir,strcat(hemi, '_outfile.P.mgh'));
CIhighoutfile = fullfile(outdir,strcat(hemi, '_outfile.P.mgh'));
cilow3outfile = fullfile(outdir,strcat(hemi, '_outfile.P.mgh'));
cihigh3outfile = fulfile(outdir,strcat(hemi, '_outfile.P.mgh'));
save_mgh(matrise(:,1),poutfile,eye(4));
save_mgh(matrise(:,2),estoutfile,eye(4));
save_mgh(matrise(:,3),CIlowoutfile,eye(4));
save_mgh(matrise(:,4),CIhighoutfile,eye(4));
save_mgh(matrise(:,5),cilow3outfile,eye(4));
save_mgh(matrise(:,6),cihigh3outfile,eye(4));
end
if license('test','distrib_computing_toolbox')
if verLessThan('matlab','8.2.0.29')
if (matlabpool('size') > 0)
matlabpool close;
end;
else
if ~isempty(gcp('nocreate'))
delete(gcp('nocreate'))
end;
end;
end;
myCluster = parcluster('local');
delete(myCluster.Jobs);
end
function[]=replacestring(file,oldstring,newstring,linenumber)
f=readtext(file);
f(linenumber)=strrep(f(linenumber),oldstring,newstring);
fid=fopen(file,'w');
for i=1:length(f)
fprintf(fid,'%s\n',f{i});
end
fclose(fid);
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!