WCHN / CTseg

Brain CT image segmentation, normalisation, skull-stripping and total brain/intracranial volume computation.
GNU General Public License v3.0
55 stars 17 forks source link

Error using get_par>get_lkp (line 59) max(lkp) ~= K #4

Closed petteriTeikari closed 4 years ago

petteriTeikari commented 4 years ago

This error occurred when getting to the GMM estimation part

------------------------------------------------------------------------
08-Oct-2019 16:23:00 - Running job #1
------------------------------------------------------------------------
08-Oct-2019 16:23:00 - Running '3D to 4D File Conversion'
08-Oct-2019 16:23:02 - Done    '3D to 4D File Conversion'
08-Oct-2019 16:23:02 - Done

Start making initial estimates of GMM parameters...

Error in get_par (line 24)
        [varargout{1:nargout}] = get_lkp(varargin{:});

Error in get_gmms (line 9)
parfor s=1:S0

Error in init_gmm (line 24)
[dat,model] = get_gmms(obs,model,dat,opt);

Error in init_all (line 32)
    [dat,model] = init_gmm(dat,model,opt);

Error in SegModel>SegModel_segment (line 187)
[dat,model,opt] = init_all(dat,opt);

Error in SegModel (line 40)
        [varargout{1:nargout}] = SegModel_segment(varargin{:});

Error in spm_segment_ct>segment_ct (line 366)
opt = SegModel('segment',dat,opt);

Error in spm_segment_ct (line 103)
opt = segment_ct(Nii,DirOut,PthToolboxes,VerboseSeg,CleanBrain,Write,Samp,MRF);

Error in batch_segment_CTs>predict_mask_CTseg (line 38)
    spm_segment_ct(Image, DirOut)

Error in batch_segment_CTs (line 21)
        pred_masks{i} = predict_mask_CTseg(test_CTs, test_CT_files(i).name);

With default values, the K = 6, and lkp has 14 elements, and the max (8) is not equal to 8:

lkp =

  Columns 1 through 13

     1     1     1     2     2     2     3     4     5     6     7     8     8

  Column 14

     8

This seems to correspond to this setting: https://github.com/WCHN/CTseg/blob/c6cd2dab61d6c37b45adde90a7050d0a6da61c10/spm_segment_ct.m#L354

But then the default K is 6, which of them should be changed? I changed this to 8 and made it work: https://github.com/WCHN/CTseg/blob/c6cd2dab61d6c37b45adde90a7050d0a6da61c10/toolboxes/segmentation-model/code/default_opt.m#L343

brudfors commented 4 years ago

Hello @petteriTeikari ,

The recent major update+refactoring of the code should have solved this issue.

I am sorry that resolving it took so long. The code was in a very experimental phase when I first uploaded it to GitHub (as you know) and has required significant modifications to work in a general way (improvements to the underlying mathematical models, re-training of the atlas, etc.). However, now it should work well as I have tested it on a large cohort of routine clinical CT images.

Best wishes,

Mikael