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

Reference to non-existent field 'dir_model'. #3

Closed petteriTeikari closed 4 years ago

petteriTeikari commented 4 years ago

You seem to be missing a field dir_model (Create directory that will store all that is model related) from your opt structure, when running with two input arguments spm_segment_ct(Image, DirOut):

Image = fullfile(path_base, file_to_analyze); DirOut = fullfile(path_base, 'output');

This come out as the error:

Reference to non-existent field 'dir_model'.

Error in init_uniform_template (line 15)
dir_model = opt.dir_model;

Error in load_model (line 34)
        model{s} = init_uniform_template(dat,opt);

Error in init_all (line 43)
    [dat,model,opt] = load_model(dat,opt); % Get model parameters (model)

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);

So the dir_model is not saved when calling init_uniform_template here: https://github.com/WCHN/CTseg/blob/c6cd2dab61d6c37b45adde90a7050d0a6da61c10/toolboxes/segmentation-model/code/load_model.m#L34

Which seemed to be due to this flag being false https://github.com/WCHN/CTseg/blob/c6cd2dab61d6c37b45adde90a7050d0a6da61c10/spm_segment_ct.m#L300

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