Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional outputs and order of the FitResults fields #272

Closed
agahkarakuzu opened this issue Sep 12, 2018 · 3 comments
Closed

Conditional outputs and order of the FitResults fields #272

agahkarakuzu opened this issue Sep 12, 2018 · 3 comments
Labels

Comments

@agahkarakuzu
Copy link
Member

In the new qsm_sb model, presence of the outputs depends on the selected options. For example:

%    Case - Split-Bregman:
%       i)  W/ magnitude weighting:  chiSBM, chiL2M, chiL2, unwrappedPhase, maskOut
%       ii) W/O magnitude weighting: chiSM, chiL2, unwrappedPhase, maskOut
%
%    Case - L2 Regularization:
%       i)  W/ magnitude weighting:  chiL2M, chiL2, unwrappedPhase, maskOut
%       ii) W/O magnitude weighting: chiL2, unwrappedPhase, maskOut
%
%    Case - No Regularization:
%       i) Magnitude weighting is not enabled: nfm, unwrappedPhase, maskOut

In this case, first problem is the correct ordering of FitResults fields, so that display units can pick up the correct output. I noticed that this totally depends on the order of field assignments. Given that there are different fit cases, a one-size-fits-all ordering is not possible. I worked this around by:

if exist('magnWeight') == 1
    FitResults.maskOut = double(magnWeight);
  else
    FitResults.maskOut = double(maskGlobal);
  end

  if isfield(FitResults, 'chiSBM')
    FitResults = orderfields(FitResults, {'chiSBM','chiL2M','chiL2','unwrappedPhase','maskOut'});
  end

  if isfield(FitResults, 'chiSB')
    FitResults = orderfields(FitResults, {'chiSB','chiL2','unwrappedPhase','maskOut'});
  end

Now the role of the xnames attribute has become ambiguous to me, at least for this model. Is this field primarily intended for simulations? Here for some reason I've forgotten, I noted that the main output should always be the first one. On the other hand, this is not the case, for example, vfa_t1 and nothing unusual happens. Any insights? How should xnames be assigned for this model?

@mathieuboudreau
Copy link
Member

I know that the very first xname parameter is what's plotted for in the batch examples (e.g. in sensitivity analysis and such).

Not sure what a good workaround for your issue might be, but I'd love one!

@tanguyduval
Copy link
Member

@agahkarakuzu xnames is mandatory for voxelwise models since it defines the fitting (input) parameters. The outputs (and their order) are defined by the fields of the Fitresults of the fit method.
Usually, the fitting parameters (inputs) are part of the outputs. But sometimes these parameters are not really meaningful and need to be recomputed... (for instance in NODDI; kappa is recomputed to obtain the orientation dispersion index).

If we want to obtain the outputs, we could whether:

  1. add a new property...
  2. Or (cleaner I think) Create a function that runs the fit method with null MRIinputs... Something like (not tested on all methods):
Model = qsm_sb;
Inputs = struct;
for fields = Model.MRIinputs
    Inputs.(fields{1}) = 1;
end
FitResults = Model.fit(Inputs);
Outputs = fieldnames(FitResults)

Using xnames in #294 to get the outputs for non-voxelwise Models was not clean and I will revert this

@agahkarakuzu
Copy link
Member Author

Resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants