%path already set by loadData
headerInfoOut=headerInfo;

k1=squeeze(xa(:,:,:,1));
vbf=squeeze(xa(:,:,:,2));

if size(xa,4)>2
    k2=squeeze(xa(:,:,:,3));
end

headerInfoOut.data=single(k1);
headerInfoOut.content=[patientID '_k1'];
nhdr_nrrd_write(fullfile(path,[patientID '_k1.nrrd']),headerInfoOut,1)
    
if size(xa,4)>2
    headerInfoOut.data=single(k2);
    headerInfoOut.content=[patientID '_k2'];
    nhdr_nrrd_write(fullfile(path,[patientID '_k2.nrrd']),headerInfoOut,1)
end

headerInfoOut.data=single(vbf);
headerInfoOut.content=[patientID '_vbf'];
nhdr_nrrd_write(fullfile(path,[patientID '_vbf.nrrd']),headerInfoOut,1)

dt=size(data);
for i=1:nclass
    u=reshape(U(i,:),dt(1:3));
    headerInfoOut.data=single(u);
    headerInfoOut.content=sprintf('%s_center%i',patientID,i);
    nhdr_nrrd_write(fullfile(path,sprintf('%s_center%d.nrrd',patientID,i)),headerInfoOut,1);
    
end

%for i=1:c1
%    headerInfoOut.data=single(data1(:,:,:,i))*cm(i);
%    s=sprintf('%sVolume%d_model.nrrd',patientID,i-1);
%    nhdr_nrrd_write(fullfile(path,s),headerInfoOut,1);
%end
