Skip to content

Commit

Permalink
parse outputtype in json2mcx
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Jul 27, 2023
1 parent a4b3d51 commit 081c382
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions utils/json2mcx.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
cfg.prop=squeeze(cell2mat(struct2cell(json.Domain.Media)))';

if(isfield(json,'Shapes'))
cfg.shapes=savejson('',json.Shapes);
cfg.shapes=savejson('Shapes',json.Shapes);
end

if(isfield(json,'Domain') && isfield(json.Domain,'VolumeFile'))
Expand Down Expand Up @@ -109,7 +109,7 @@
case '.nii'
cfg.vol=mcxloadnii(json.Domain.VolumeFile);
end
else
elseif(~isfield(cfg,'shapes'))
cfg.vol=uint8(zeros(60,60,60));
end

Expand All @@ -124,6 +124,13 @@
cfg=copycfg(cfg,'isnormalize',json.Session,'DoNormalize');
cfg=copycfg(cfg,'outputformat',json.Session,'OutputFormat');
cfg=copycfg(cfg,'outputtype',json.Session,'OutputType');
if(length(cfg.outputtype)==1)
otypemap=struct('x', 'flux', 'f', 'fluence', 'e', 'energy', 'j', 'jacobian', 'p', 'nscat', 'm', 'wm', 'r', 'rf', 'l', 'length');
if(~isfield(otypemap, cfg.outputtype))
error('output type %s is not supported', cfg.outputtype);
end
cfg.outputtype=otypemap.(cfg.outputtype);
end
cfg=copycfg(cfg,'debuglevel',json.Session,'Debug');
cfg=copycfg(cfg,'autopilot',json.Session,'DoAutoThread');
cfg=copycfg(cfg,'autopilot',json.Session,'DoAutoThread');
Expand Down
4 changes: 4 additions & 0 deletions utils/mcxpreview.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
error('cfg must be a struct or struct array');
end

if(~exist('latticegrid','file'))
error('cfg must be a struct or struct array');
end

len=length(cfg);
if(nargout>0)
hs=cell(len,1);
Expand Down

0 comments on commit 081c382

Please sign in to comment.