%reset random generator
rng shuffle

%add nrrd processing capability
addpath('nrrd_read_write_rensonnet')

[cax,cm]=loadTime(path,patientID);

segmFile=fullfile(path,patientID,sprintf('%s_Segmentation.txt',patientID));
%v0=loadPixels(segm,patientID);
v0=dlmread(segmFile);

data=loadSPECTdata(path,patientID,cm);

sigma2=str2num(sigma2);
na=7;
fcenters=extractCenters(data,v0,sigma2,na);

%this will write out fitPar
[globalPar, cPars] = fitCentersPixel(path, patientID, cax, cm, fcenters,sigma2);

%[globalPar, cPars, xa, U]=fitFromClusters(path,cax, cm, data, nclass,realizationId);

disp('DynamicPixelAnalysis done');
quit;
%writeData
