WCHN/CTseg

Reference to non-existent field 'pth_gr'.

Closed this issue · 1 comments

After getting the Start making initial estimates of GMM parameters... done! and Start making initial estimate of template...done!

image

This error comes

Error using segment_subject (line 449)
Reference to non-existent field 'pth_gr'.

Error in distribute_local (line 20)
    parfor (n=1:N, double(opt.client.workers))

Error in distribute (line 183)
        [varargout{2:numel(varargout)}] = distribute_local(opt, func, args, flags, access, N);

Error in SegModel>SegModel_segment (line 193)
[~,dat] = distribute(holly,'segment_subject','inplace',dat,'iter',model,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 I assume that somehow this check is skipped?

if ~isfield(dat{s}.template,'pth_gr') && ~isfield(dat{s}.template,'pth_H')

So maybe the pth_H ,but not pth_gr is set?

And when I added "double-checking" of the variables defined within the structure, it worked:

% Write derivatives to disk

% Double-checking that the paths actually are defined
    s = 1; % subscript used in "segmentation-model/code/init_load_a_der.m"
    if ~isfield(dat.template,'pth_gr')
        disp('... "pth_gr" was not defined, defining it again')
        dat.template.pth_gr = fullfile(opt.dir_a_der,['gr-' num2str(s) '.nii']);
    end    
        
    if ~isfield(dat.template,'pth_H')
        disp('... "pth_H" was not defined, defining it again')
        dat.template.pth_H  = fullfile(opt.dir_a_der,['H-' num2str(s) '.nii']);               
    end

and indeed only pth_gr was undefined and pth_H was defined for "initial estimate", and both were undefined for the "Analyzing and transferring files to the workers ...done." part

Start making initial estimate of template...done!
... "pth_gr" was not defined, defining it again
Analyzing and transferring files to the workers ...done.
... "pth_gr" was not defined, defining it again
... "pth_H" was not defined, defining it again

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