Giter VIP home page Giter VIP logo

mocov's Introduction

MOcov Build Status

MOcov is a coverage report generator for Matlab and GNU Octave.

Features

  • Runs on both the Matlab and GNU Octave platforms.
  • Can be used directly with continuous integration services, such as coveralls.io and Shippable.
  • Integrates with MOxUnit, a unit test framework for Matlab and GNU Octave.
  • Supports the Matlab profiler.
  • Writes coverage reports in HTML, JSON and XML formats.
  • Distributed under the MIT license, a permissive free software license.

Installation

  • Using the shell (requires a Unix-like operating system such as GNU/Linux or Apple OSX):

    git clone https://github.com/MOcov/MOcov.git
    cd MOcov
    make install

    This will add the MOcov directory to the Matlab and/or GNU Octave search path. If both Matlab and GNU Octave are available on your machine, it will install MOcov for both.

  • Manual installation:

    • Download the zip archive from the MOcov website.

    • Start Matlab or GNU Octave.

    • On the Matlab or GNU Octave prompt, cd to the MOcov root directory, then run:

      cd MOcov            % cd to MOcov subdirectory
      addpath(pwd)        % add the current directory to the Matlab/GNU Octave path
      savepath            % save the path

Determining coverage

Coverage can be determined for evaluating a single expression or evaluation of a single function handle; for typical use cases this invokes running a test suite.

There are two methods to generate coverage while evaluating such an expression or function handle:

  1. the 'file' method (default)

    • Coverage information is stored internally by the function mocov_line_covered, which keeps this information through the use of persistent variables. Initially the coverage information is reset to being empty.
    • This method considers all files in a directory (and its subdirectories).
    • A temporary directory is created where modified versions of each file is stored.
    • Prior to evaluting the expression or function handle, for each file, MOcov determines which of its lines can be executed. Each line that can be executed is prefixed by a call to mocov_line_covered, which cause it to update internal state to record the filename and line number that was executed, and the result stored in the temporary directory.
    • The search path is updated to include the new temporary directory.

    After evaluating the expression or function handle, the temporary directory is deleted and the search path restored. Line coverage information is then extracted from the internal state of mocov_line_covered.

    This method runs on both GNU Octave and Matlab, but is typically slow.

  2. the 'profile' method

    • It uses the Matlab profiler.
    • This method runs on Matlab only (not on GNU Octave), but is generally faster.

Use cases

Typical use cases for MOcov are:

  • Locally run code with coverage for code in a unit test framework on GNU Octave or Matlab. Use

        mocov('-cover','path/with/code',...
                '-expression','run_test_command',...
                '-cover_json_file','coverage.json',...
                '-cover_xml_file','coverage.xml',...
                '-cover_html_dir','coverage_html',
                '-method','file');

    to generate coverage reports for all files in the 'path/with/code' directory when running eval('run_test_command'). Results are stored in JSON, XML and HTML formats.

  • As a specific example of the use case above, when using the MOxUnit unit test platform such tests can be run as

        success=moxunit_runtests('path/with/tests',...
                                    '-with_coverage',...
                                    '-cover','/path/with/code',...
                                    '-cover_xml_file','coverage.xml',...
                                    '-cover_html_dir','coverage_html');

    where 'path/with/tests' contains unit tests. In this case, moxunit_runtests will call the mocov function to generate coverage reports.

  • On the Matlab platform, results from profile('info') can be stored in JSON, XML or HTML formats directly. In the following:

        % enable profiler
        profile on;
    
        % run code for which coverage is to be determined
        <your code here>
    
        % write coverage based on profile('info')
        mocov('-cover','path/with/code',...
                '-profile_info',...
                '-cover_json_file','coverage.json',...
                '-cover_xml_file','coverage.xml',...
                '-cover_html_dir','coverage_html');

    coverage results are stored in JSON, XML and HTML formats.

  • Use with continuous integration service, such as Shippable or travis-ci combined with coveralls.io. See the travis.yml configuration file in the MOxUnit project for an example.

Use with travis-ci and Shippable

MOcov can be used with the Travis-ci and Shippable services for continuous integration testing. This is achieved by setting up a travis.yml file. Due to recursiveness issues, MOcov cannot use these services to generate coverage reports for itself; for an example in the related MOxUnit project, see the travis.yml configuration file file.

Compatibility notes

  • Because GNU Octave 3.8 and 4.0 do not support classdef syntax, 'old-style' object-oriented syntax is used for the class definitions.

Limitations

  • The 'file' method uses a very simple parser, which may not work as expected in all cases.
  • Currently there is only support to generate coverage reports for files in a single directory (and its subdirectory).

Contact

Nikolaas N. Oosterhof, nikolaas dot oosterhof at unitn dot it

Contributions

  • Thanks to Scott Lowe and Anderson Bravalheri for their contributions.

License

(The MIT License)

Copyright (c) 2015-2017 Nikolaas N. Oosterhof

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

mocov's People

Contributors

abravalheri avatar alexander-coleman-bose avatar jdbancal avatar jorgepz avatar jwleblan avatar mathieuboudreau avatar nno avatar schulzeas avatar scottclowe avatar thomasfeher avatar wahln avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mocov's Issues

MOcov gets confused with "comments"

I have been getting a "strange" error (most likely user induced) I suspect but I thought I would report it: for the record.

Similarly I have been getting this with travis CI and not locall which makes me think this is a MOcov issue and not a MOxUnit one.

I was getting this series of fail of the CI:
https://travis-ci.com/github/cpp-lln-lab/CPP_BIDS_SPM_pipeline/jobs/402478171

See for example line 1417:

failure: parse error near line 95 of file /tmp/oct-hyiVh2/utils/checkOptions.m

  syntax error

>>> mocov_line_covered(51,'utils/checkOptions.m',95,1);                                      'Contrasts', struct( ...

This was fixed by this commit: cpp-lln-lab/bidspm@4570441

That pretty much turns a "comment" like this:

Steps = struct( ...
    fieldsToSet.result.Steps = struct( ...
                                      'Level',  '', ... dataset, run, subject
                                      'Contrasts' , [ ] )

into a proper comment:

Steps = struct( ...
    fieldsToSet.result.Steps = struct( ...
                                      'Level',  '', ...  % dataset, run, subject
                                      'Contrasts' , [ ] )

Seems that this messes up with the parsing to measure code coverage (or at least this is my noob interpretation).

Note sure if this is a known "issue".

0% coverage reported

Raising an issue here after discussing it in the moxunit github action repo: joergbrech/moxunit-action#13

In brief:

I am running my test with moxunit and even when they pass I get 0% coverage (bids-standard/bids-matlab#124 (comment)).

The issue seems to be related to the fact that the code hose coverage is to be estimated in a "package" folder (folder starts with a "+").

@joergbrech checked an simply remove the + seemed to do the trick: joergbrech/moxunit-action#13 (comment)

Extra warning and errors when using on Windows

Currently implementing to use moxunit and mocov in CI on github and run my tests with matlab on ubuntu, macos and windows.

See this PR on a template repo: Remi-Gau/template_matlab_analysis#23

In CI on windows I am getting extra warnings and errors when asking for coverage that I do not get:

  • when not asking for coverage
  • on linux or macos

A typical warning would look something like this:

https://github.com/Remi-Gau/template_matlab_analysis/actions/runs/4860625025/jobs/8664661302?pr=23#step:5:19

   [�Warning: Escaped character '\g' is not valid. See 'doc sprintf' for supported special characters.]� 
  [�> In MOcovMFileCollection.rewrite_mfiles>@(line_number)sprintf(pat,line_number) (line 36)
  In MOcovMFile/write_lines_with_prefix (line 32)
  In MOcovMFileCollection/rewrite_mfiles (line 37)
  In MOcovMFileCollection/prepare (line 44)
  In mocov (line 92)
  In moxunit_runtests>run_all_tests (line 205)
  In moxunit_runtests (line 102)
  In run_tests (line 21)
  In run (line 91)
  In run_tests_ci (line 12)
  In run (line 91)
  In command_b91aebef_4fe2_4a34_b8f8_9545a323cf1a (line 1)
  In mdcsbatch (line 58)]� 

extra errors are usually of the type:

https://github.com/Remi-Gau/template_matlab_analysis/actions/runs/4860625025/jobs/8664661302?pr=23#step:5:142

  failure: Error: File: C:\Users\runneradmin\AppData\Local\Temp\tpaffcc5ec_1cd7_485e_86ca_7f00afc53b35\utils\is_octave.m Line: 12 Column: 22
  Character vector is not terminated properly.
    test_my_fibonacci_error:39 (D:\a\template_matlab_analysis\template_matlab_analysis\tests\test_my_fibonacci.m)

From a quick look it at least seems that the warning happen when the tested file is in a subfolder: windows path separator \ does not play well with sprintf.

Not yet sure what cause the errors though.

I will keep on investigating the possible causes and update this issue.

Support folders in file patterns

Currently it seems that the option -cover_exclude only supports file patterns. This means that it is not possible to exclude a single file in a subfolder, say a/function1.m. if a file with the same name is also present in another subfolder, say a/b/c/function1.m. Indeed, the pattern function1.m would match both.

Would it be possible to support exclude filters which match the full path, such as a/function1.m? Meaning that this would only match. Maybe, a simple way to do this could be to treat patterns slightly differently if they contain the / chararcter : currently a pattern like a/function1.m of ./function1.m will never match anything, right?

coverage in @dirs of classes is not shown

Hi,

I've tried to set up mocov and moxunit for a project using octave classic classes (not classdef).
I'm using Octave 5.2 on Ubuntu 20.04.

The functions belonging to the classes are stored in subdirectories named @classname.
Mocov is listing all the files correctly, but when executing the tests the coverage inside the class functions is not tracked.
Other subdirectories are tracked correctly.
If I set -cover to main_dir/@classname the code coverage is tracked correctly - but only for this one class, of course.

How can make mocov track all the coverage in the @ subdirectories?

Thanks, Ingo

Coverage fails with Octave classes

When I test Octave functions, the coverage report works well. but if I test classes (both with the old '@' syntax or the newer classdef) the tests run successfully but the report is empty:

<classes>
<class name="polynomial" filename="myClasses/polynomial.m" line-rate="1.000" branch-rate="0.0">
<methods></methods><lines>
</lines>
</class>
<class name="square" filename="myFunctions/square.m" line-rate="1.000" branch-rate="0.0">
<methods></methods><lines>
<line number="2" hits="1" branch="false"/>
</lines>
</class>

It is also a bit weird that myFunctions/square.m has method tags since it is not a class but OK.

Or am I doing something wrong? It would be nice to include a working example in the repo.

Add option to modify files for coverage tracking in-place

This option would be useful if the location of the files is intrinsically important.

With this option, files would be copied to a temporary directory, modified to include decorators on executable lines, the tests run and coverage data collected, then the original files copied back from their temporary locations.
This is instead of the standard method which (I believe) is to write copies of the files with the decorators in them, change the MATLAB/Octave path to use these instead of the originals, run the tests and collect the coverage data, then change the path back and delete the temporary files.

In my use-case, I have a file which is used to determine the path to the package for the purpose of loading resource files contained within the package. If this file is run from a temporary directory for coverage calculation purposes, the path will be incorrect and the resources will not be loaded.

Missing required data file in path while running test with MOcov

Hi,

New want-to-be user here.

First off - is this a stale project? I hope not, this would be a fantastic add-on to our project!

Trying to test this out on an existing (decently large) project that's trying to be both Matlab/Octave compatible and uses classes: qMRLab. Currently testing out MOcov in branch coverage.

My first attempt at using MOcov in it resulted in some infinite recursion errors, so I moved all the project files in a seperate folder than MOcov in my branch.

If I run one of our MOxUnit tests without the coverage flags:

res=moxunit_runtests('Test/MoxUnitCompatible/BatchExample_test.m')

The test runs successfully.


>> res=moxunit_runtests('Test/MoxUnitCompatible/BatchExample_test.m')
suite: 3 tests
.Warning: Directory already exists. 
> In BatchExample_test>test_batch (line 19)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: Directory already exists. 
> In BatchExample_test>test_batch (line 21)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
===============================================================
Testing: charmed BATCH...
===============================================================

Model = 

  charmed with properties:

                           MRIinputs: {'DiffusionData'  'SigmaNoise'  'Mask'}
                              xnames: {1×7 cell}
                           voxelwise: 1
                                  st: [0.5000 0.7000 6 0 0 3 1.4000]
                                  lb: [0 0.3000 3 0 0 1 0.3000]
                                  ub: [1 3 10 1 8 4 3]
                                  fx: [0 0 0 1 1 1 1]
                                Prot: [1×1 struct]
                             buttons: {1×13 cell}
                             options: [1×1 struct]
      Sim_Single_Voxel_Curve_buttons: {'SNR'  [50]}
    Sim_Sensitivity_Analysis_buttons: {'# of run'  [5]}
       Sim_Optimize_Protocol_buttons: {1×8 cell}
                             version: [2 0 10]
                           ModelName: 'charmed'

Please wait. Downloading data ...
Data has been downloaded ...
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'fr', 'Dh', 'diameter_mean', 'fcsf', 'lc', 'Dcsf', 'Dintra'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = charmed
         x = struct;
         x.fr = 0.5;
         x.Dh = 0.7;
         x.diameter_mean = 6;
         x.fcsf = 0;
         x.lc = 0;
         x.Dcsf = 3;
         x.Dintra = 1.4;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'fr', 'Dh', 'diameter_mean', 'fcsf', 'lc', 'Dcsf', 'Dintra'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = charmed
         x = struct;
         x.fr = 0.5;
         x.Dh = 0.7;
         x.diameter_mean = 6;
         x.fcsf = 0;
         x.lc = 0;
         x.Dcsf = 3;
         x.Dintra = 1.4;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Sensitivity_Analysis
   Simulates sensitivity to fitted parameters:
      (1) vary fitting parameters from lower (lb) to upper (ub) bound in 10 steps
      (2) run Sim_Single_Voxel_Curve Nofruns times
      (3) Compute mean and std across runs
   USAGE:
     SimVaryResults = Model.Sim_Sensitivity_Analysis(OptTable, Opt);
   INPUT:
     OptTable: [struct] nominal value and range for each parameter.
        st: [vector] nominal values for 'fr', 'Dh', 'diameter_mean', 'fcsf', 'lc', 'Dcsf', 'Dintra'
        fx: [binary vector] do not vary this parameter?
        lb: [vector] vary from lb...
        ub: [vector] up to ub
     Opt: [struct] Options of the simulation with fields:
  struct with fields:

       SNR: 50
    Nofrun: 5


   EXAMPLE:
         Model = charmed
         %              fr            Dh            diameter_mean fcsf          lc            Dcsf          Dintra        
         OptTable.st = [0.5           0.7           6             0             0             3             1.4]; % nominal values
         OptTable.fx = [0             1             1             1             1             1             1]; %vary fr...
         OptTable.lb = [0             0.3           3             0             0             1             0.3]; %...from 0
         OptTable.ub = [1             3             10            1             8             4             3]; %...to 1
         % Get all possible options
         Opt = button2opts([Model.Sim_Single_Voxel_Curve_buttons, Model.Sim_Sensitivity_Analysis_buttons],1);
         % run simulation using options `Opt(1)`
         SimResults = Model.Sim_Sensitivity_Analysis(OptTable,Opt(1));
         figure('Name','Sensitivity Analysis');
         SimVaryPlot(SimResults, 'fr' ,'fr' );
 
------------------------------
SAVED: charmed_batch.m
Demo is ready at: /private/tmp/qMRLab/charmed_demo
------------------------------
 charmed: Composite Hindered and Restricted Model for Diffusion
 Pulse Sequence Diagram
 
 
  Assumptions:
    Diffusion gradients are applied perpendicularly to the neuronal fibers.
    Neuronal fibers model:
      geometry                          cylinders
      Orientation dispersion            NO
      Permeability                      NO
    Diffusion properties:
      intra-axonal                      restricted in cylinder with Gaussian
                                         Phase approximation
       diffusion coefficient (Dr)       fixed by default. this assumption should have 
                                                           little impact if the average 
                                                           propagator is larger than
                                                           axonal diameter (sqrt(2*Dr*Delta)>8?m).
      extra-axonal                      Gaussian
       diffusion coefficient (Dh)       Constant by default. Time dependence (lc) 
                                                              can be added
 
  Inputs:
    DiffusionData       4D DWI
    (SigmaNoise)        map of the standard deviation of the noise per voxel
    (Mask)              Binary mask to accelerate the fitting
 
  Outputs:
    fr                  Fraction of water in the restricted compartment.
    Dh                  Apparent diffusion coefficient of the hindered compartment.
    diameter_mean       Mean axonal diameter weighted by the axonal area --> biased toward the larger axons
                          fixed to 0 --> stick model (recommended if Gmax < 300mT/m).
    fcsf                Fraction of water in the CSF compartment. (fixed to 0 by default)
    lc                  Length of coherence. If > 0, this parameter models the time dependence
                          of the hindered diffusion coefficient Dh.
                          Els Fieremans et al. Neuroimage 2016.
                          Interpretation is not perfectly known.
                          Use option "Time-Dependent Models" to get different interpretations.
    (fh)                Fraction of water in the hindered compartment, calculated as: 1 - fr - fcsf
    (residue)           Fitting residuals
 
  Protocol:
    Various bvalues
    diffusion gradient direction perpendicular to the fibers
 
    DiffusionData       Array [NbVol x 7]
      Gx                Diffusion Gradient x
      Gy                Diffusion Gradient y
      Gz                Diffusion Gradient z
      Gnorm (T/m)         Diffusion gradient magnitude
      Delta (s)         Diffusion separation
      delta (s)         Diffusion duration
      TE (s)            Echo time
 
  Options:
    Rician noise bias               Used if no SigmaNoise map is provided.
      'Compute Sigma per voxel'     Sigma is estimated by computing the STD across repeated scans.
      'fix sigma'                   Use scd_noise_std_estimation to measure noise level. Use 'value' to fix Sigma.
    Display Type
      'q-value'                     abscissa for plots: q = gamma.delta.G (?m-1)
      'b-value'                     abscissa for plots: b = (2.pi.q)^2.(Delta-delta/3) (s/mm2)
    S0 normalization
      'Use b=0'                     Use b=0 images. In case of variable TE, your dataset requires a b=0 for each TE.
      'Single T2 compartment'       In case of variable TE acquisition:
                                    fit single T2 using data acquired at b<1000s/mm2 (assuming Gaussian diffusion))
    Time-dependent models
      'Burcaw 2015'                 XXX
      'Ning MRM 2016'               XXX
 
  Example of command line usage (see showdemo charmed_batch):
    Model = charmed;  % Create class from model
    Model.Prot.DiffusionData.Mat = txt2mat('Protocol.txt');  % Load protocol
    data = struct;  % Create data structure
    data.DiffusionData = load_nii_data('DiffusionData.nii.gz');  % Load data
    data.Mask=load_nii_data('Mask.nii.gz');  % Load mask
    FitResults = FitData(data,Model,1);  % Fit each voxel within mask
    FitResultsSave_nii(FitResults,'DiffusionData.nii.gz');  % Save in local folder: FitResults/
           
    For more examples: qMRusage(charmed)
 
  Author: Tanguy Duval, 2016
 
  References:
    Please cite the following if you use this module:
      Assaf, Y., Basser, P.J., 2005. Composite hindered and restricted model of diffusion (charmed) MR imaging of the human brain. Neuroimage 27, 48?58.
    In addition to citing the package:
      Cabana J-F, Gu Y, Boudreau M, Levesque IR, Atchia Y, Sled JG, Narayanan S, Arnold DL, Pike GB, Cohen-Adad J, Duval T, Vuong M-T and Stikov N. (2016), Quantitative magnetization transfer imaging made easy with qMTLab: Software for data simulation, analysis, and visualization. Concepts Magn. Reson.. doi: 10.1002/cmr.a.21357

    Reference page for charmed

Warning: Environment Variable 'ISTRAVIS'=1: close window immediatly. run
>>setenv('ISTRAVIS','') to change this behavior. 
> In Custom_OptionsGUI>OptionsGUI_OutputFcn (line 162)
  In gui_mainfcn (line 262)
  In Custom_OptionsGUI (line 32)
  In charmed_batch (line 32)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Fitting voxel    3/962
...done   0%
Warning: Directory already exists. 
> In FitResultsSave_nii (line 9)
  In charmed_batch (line 103)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Elapsed time is 42.645827 seconds.
===============================================================
Testing: dti BATCH...
===============================================================

Model = 

  dti with properties:

    MRIinputs: {'DiffusionData'  'SigmaNoise'  'Mask'}
       xnames: {'L1'  'L2'  'L3'}
    voxelwise: 1
           st: [2 0.7000 0.7000]
           lb: [0 0 0]
           ub: [5 5 5]
           fx: [0 0 0]
         Prot: [1×1 struct]
      buttons: {1×9 cell}
      options: [1×1 struct]
      version: [2 0 10]
    ModelName: 'dti'

Please wait. Downloading data ...
Data has been downloaded ...
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'L1', 'L2', 'L3'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = dti
         x = struct;
         x.L1 = 2;
         x.L2 = 0.7;
         x.L3 = 0.7;
          Opt.SNR = 50;
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'L1', 'L2', 'L3'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = dti
         x = struct;
         x.L1 = 2;
         x.L2 = 0.7;
         x.L3 = 0.7;
          Opt.SNR = 50;
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Sensitivity_Analysis
   Simulates sensitivity to fitted parameters:
      (1) vary fitting parameters from lower (lb) to upper (ub) bound in 10 steps
      (2) run Sim_Single_Voxel_Curve Nofruns times
      (3) Compute mean and std across runs
   USAGE:
     SimVaryResults = Model.Sim_Sensitivity_Analysis(OptTable, Opt);
   INPUT:
     OptTable: [struct] nominal value and range for each parameter.
        st: [vector] nominal values for 'L1', 'L2', 'L3'
        fx: [binary vector] do not vary this parameter?
        lb: [vector] vary from lb...
        ub: [vector] up to ub
     Opt: [struct] Options of the simulation with fields:
  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = dti
         %              L1            L2            L3            
         OptTable.st = [2             0.7           0.7]; % nominal values
         OptTable.fx = [0             1             1]; %vary L1...
         OptTable.lb = [0             0             0]; %...from 0
         OptTable.ub = [5             5             5]; %...to 5
          Opt.SNR = 50;
          Opt.Nofrun = 5;
         % run simulation using options `Opt(1)`
         SimResults = Model.Sim_Sensitivity_Analysis(OptTable,Opt(1));
         figure('Name','Sensitivity Analysis');
         SimVaryPlot(SimResults, 'L1' ,'L1' );
 
------------------------------
SAVED: dti_batch.m
Demo is ready at: /private/tmp/qMRLab/dti_demo
------------------------------
 dti: Compute a tensor from diffusion data
 
  Assumptions:
    Anisotropic Gaussian diffusion tensor
    Valid at relatively low b-value (i.e. ~< 2000 s/mm2)
 
  Inputs:
    DiffusionData       4D DWI
    (SigmaNoise)        map of the standard deviation of the noise per voxel
    (Mask)              Binary mask to accelerate the fitting
 
  Outputs:
    D                   [Dxx Dxy Dxz Dxy Dyy Dyz Dxz Dyz Dzz] Difffusion Tensor
    L1                  1rst eigenvalue of D
    L2                  2nd eigenvalue of D
    L3                  3rd eigenvalue of D
    FA                  Fractional Anisotropy: FA = sqrt(3/2)*sqrt(sum((L-L_mean).^2))/sqrt(sum(L.^2));
    S0_TEXX             Signal at b=0 at TE=XX
    (residue)           Fitting residuals
 
  Protocol:
    At least 2 shells (e.g. b=1000 and b=0 s/mm2)
    diffusion gradient direction in 3D
 
    DiffusionData       Array [NbVol x 7]
      Gx                Diffusion Gradient x
      Gy                Diffusion Gradient y
      Gz                Diffusion Gradient z
      Gnorm (T/m)         Diffusion gradient magnitude
      Delta (s)         Diffusion separation
      delta (s)         Diffusion duration
      TE (s)            Echo time
 
  Options:
    fitting type                    
      'linear'                              Solves the linear problem (ln(S/S0) = -bD)
      'non-linear (Rician Likelihood)'      Add an additional fitting step,
                                             using the Rician Likelihood.
    Rician noise bias                       only for non-linear fitting
                                             SigmaNoise map is prioritary.
      'Compute Sigma per voxel'             Sigma is estimated by computing the STD across repeated scans.
      'fix sigma'                           Use scd_noise_std_estimation to measure noise level. Use 'value' to fix Sigma.
 
 
  Example of command line usage (see  dti_batch.html):
       Model = dti
       %% LOAD DATA
       data.DiffusionData = load_nii_data('DiffusionData.nii.gz');
       data.SigmaNoise = load_nii_data('SigmaNoise.nii.gz');
       data.Mask = load_nii_data('Mask.nii.gz');
       %% FIT A SINGLE VOXEL
       % Specific voxel:         datavox = extractvoxel(data,voxel);
       % Interactive selection:  datavox = extractvoxel(data);
       voxel       = round(size(data.DiffusionData(:,:,:,1))/2); % pick FOV center
       datavox     = extractvoxel(data,voxel);
       FitResults  = Model.fit(datavox);
       Model.plotModel(FitResults, datavox); % plot fit results
       %% FIT all voxels
       FitResults = FitData(data,Model);
       % SAVE results to NIFTI
       FitResultsSave_nii(FitResults,'DiffusionData.nii.gz'); % use header from 'DiffusionData.nii.gz'
           
    For more examples: qMRusage(dti)
 
  Author: Tanguy Duval, 2016
 
  References:
    Please cite the following if you use this module:
      Basser, P.J., Mattiello, J., LeBihan, D., 1994. MR diffusion tensor spectroscopy and imaging. Biophys. J. 66, 259?267.   
    In addition to citing the package:
      Cabana J-F, Gu Y, Boudreau M, Levesque IR, Atchia Y, Sled JG, Narayanan S, Arnold DL, Pike GB, Cohen-Adad J, Duval T, Vuong M-T and Stikov N. (2016), Quantitative magnetization transfer imaging made easy with qMTLab: Software for data simulation, analysis, and visualization. Concepts Magn. Reson.. doi: 10.1002/cmr.a.21357

    Reference page for dti

Warning: Environment Variable 'ISTRAVIS'=1: close window immediatly. run
>>setenv('ISTRAVIS','') to change this behavior. 
> In Custom_OptionsGUI>OptionsGUI_OutputFcn (line 162)
  In gui_mainfcn (line 262)
  In Custom_OptionsGUI (line 32)
  In dti_batch (line 32)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Fitting voxel       3/164005
...done   0%
Warning: Directory already exists. 
> In FitResultsSave_nii (line 9)
  In dti_batch (line 103)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Elapsed time is 44.601598 seconds.
===============================================================
Testing: noddi BATCH...
===============================================================

Model = 

  noddi with properties:

    MRIinputs: {'DiffusionData'  'Mask'}
       xnames: {'ficvf'  'di'  'kappa'  'fiso'  'diso'  'b0'  'theta'  'phi'}
    voxelwise: 1
           st: [0.5000 1.7000 0.0500 0 3 1 0.2000 0]
           lb: [0 1.3000 0.0500 0 1 0 0 0]
           ub: [1 2.1000 0.8000 1 5 1000 3.1416 3.1416]
           fx: [0 1 0 0 1 1 0 0]
         Prot: [1×1 struct]
      buttons: {'model name'  {1×2 cell}}
      options: [1×1 struct]
      version: [2 0 10]
    ModelName: 'noddi'

Please wait. Downloading data ...
Data has been downloaded ...
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'ficvf', 'di', 'kappa', 'fiso', 'diso', 'b0', 'theta', 'phi'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = noddi
         x = struct;
         x.ficvf = 0.5;
         x.di = 1.7;
         x.kappa = 0.05;
         x.fiso = 0;
         x.diso = 3;
         x.b0 = 1;
         x.theta = 0.2;
         x.phi = 0;
          Opt.SNR = 50;
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'ficvf', 'di', 'kappa', 'fiso', 'diso', 'b0', 'theta', 'phi'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = noddi
         x = struct;
         x.ficvf = 0.5;
         x.di = 1.7;
         x.kappa = 0.05;
         x.fiso = 0;
         x.diso = 3;
         x.b0 = 1;
         x.theta = 0.2;
         x.phi = 0;
          Opt.SNR = 50;
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Sensitivity_Analysis
   Simulates sensitivity to fitted parameters:
      (1) vary fitting parameters from lower (lb) to upper (ub) bound in 10 steps
      (2) run Sim_Single_Voxel_Curve Nofruns times
      (3) Compute mean and std across runs
   USAGE:
     SimVaryResults = Model.Sim_Sensitivity_Analysis(OptTable, Opt);
   INPUT:
     OptTable: [struct] nominal value and range for each parameter.
        st: [vector] nominal values for 'ficvf', 'di', 'kappa', 'fiso', 'diso', 'b0', 'theta', 'phi'
        fx: [binary vector] do not vary this parameter?
        lb: [vector] vary from lb...
        ub: [vector] up to ub
     Opt: [struct] Options of the simulation with fields:
  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = noddi
         %              ficvf         di            kappa         fiso          diso          b0            theta         phi           
         OptTable.st = [0.5           1.7           0.05          0             3             1             0.2           0]; % nominal values
         OptTable.fx = [0             1             1             1             1             1             1             1]; %vary ficvf...
         OptTable.lb = [0             1.3           0.05          0             1             0             0             0]; %...from 0
         OptTable.ub = [1             2.1           0.8           1             5             1e+03         3.1           3.1]; %...to 1
          Opt.SNR = 50;
          Opt.Nofrun = 5;
         % run simulation using options `Opt(1)`
         SimResults = Model.Sim_Sensitivity_Analysis(OptTable,Opt(1));
         figure('Name','Sensitivity Analysis');
         SimVaryPlot(SimResults, 'ficvf' ,'ficvf' );
 
------------------------------
SAVED: noddi_batch.m
Demo is ready at: /private/tmp/qMRLab/noddi_demo
------------------------------
  noddi:   Neurite Orientation Dispersion and Density Imaging
           Three-compartment model for fitting multi-shell DWI
 Pulse Sequence Diagram
            
  ASSUMPTIONS:
    Neuronal fibers model:
      geometry                          sticks (Dperp = 0)
      Orientation dispersion            YES (Watson distribution). Note that noddi is more robust to
                                                                    crossing fibers that DTI  (Campbell, NIMG 2017)
 
      Permeability                      NO
    Diffusion properties:
      intra-axonal                      totally restricted
        diffusion coefficient (Dr)      fixed by default.
      extra-axonal                      Tortuosity model. Parallel diffusivity is equal to
                                          intra-diffusivity.Perpendicular diffusivity is 
                                          proportional to fiber density
        diffusion coefficient (Dh)      Constant
 
  Inputs:
    DiffusionData       4D diffusion weighted dataset
    (Mask)               Binary mask to accelerate the fitting (OPTIONAL)
 
  Outputs:
    di                  Diffusion coefficient in the restricted compartment.
    ficvf               Fraction of water in the restricted compartment.
    fiso                Fraction of water in the isotropic compartment (e.g. CSF/Veins)
    fr                  Fraction of restricted water in the entire voxel (e.g. intra-cellular volume fraction)
                         fr = ficvf*(1-fiso)
    diso (fixed)        diffusion coefficient of the isotropic compartment (CSF)
    kappa               Orientation dispersion index                               
    b0                  Signal at b=0
    theta               angle of the fibers
    phi                 angle of the fibers
 
  Protocol:
    Multi-shell diffusion-weighted acquisition
     at least 2 non-zeros bvalues
     at least 5 b=0 (used to compute noise standard deviation
 
    DiffusionData       Array [NbVol x 7]
      Gx                Diffusion Gradient x
      Gy                Diffusion Gradient y
      Gz                Diffusion Gradient z
      Gnorm (T/m)         Diffusion gradient magnitude
      Delta (s)         Diffusion separation
      delta (s)         Diffusion duration
      TE (s)            Echo time
 
  Options:
    Model               Model part of noddi. 
                          Available models are:
                            -WatsonSHStickTortIsoVIsoDot_B0 is a four model compartment used for ex-vivo datasets
 
  Example of command line usage (see also showdemo noddi_batch):
    For more examples: qMRusage(noddi)
 
  Author: Tanguy Duval
 
  References:
    Please cite the following if you use this module:
      Zhang, H., Schneider, T., Wheeler-Kingshott, C.A., Alexander, D.C., 2012. noddi: practical in vivo neurite orientation dispersion and density imaging of the human brain. Neuroimage 61, 1000?1016.
    In addition to citing the package:
      Cabana J-F, Gu Y, Boudreau M, Levesque IR, Atchia Y, Sled JG, Narayanan S, Arnold DL, Pike GB, Cohen-Adad J, Duval T, Vuong M-T and Stikov N. (2016), Quantitative magnetization transfer imaging made easy with qMTLab: Software for data simulation, analysis, and visualization. Concepts Magn. Reson.. doi: 10.1002/cmr.a.21357

    Reference page for noddi

Warning: Environment Variable 'ISTRAVIS'=1: close window immediatly. run
>>setenv('ISTRAVIS','') to change this behavior. 
> In Custom_OptionsGUI>OptionsGUI_OutputFcn (line 162)
  In gui_mainfcn (line 262)
  In Custom_OptionsGUI (line 32)
  In noddi_batch (line 32)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Fitting voxel       3/164005
...done   0%
Warning: Directory already exists. 
> In FitResultsSave_nii (line 9)
  In noddi_batch (line 102)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Elapsed time is 67.513655 seconds.
===============================================================
Testing: b0_dem BATCH...
===============================================================

Model = 

  b0_dem with properties:

    MRIinputs: {'Phase'  'Magn'}
       xnames: {'B0 (Hz)'}
    voxelwise: 0
         Prot: [1×1 struct]
      buttons: {'Magn thresh'  [0.0500]}
      options: [1×1 struct]
      version: [2 0 10]
    ModelName: 'b0_dem'

Please wait. Downloading data ...
Data has been downloaded ...
------------------------------
SAVED: b0_dem_batch.m
Demo is ready at: /private/tmp/qMRLab/b0_dem_demo
------------------------------
  b0_dem map :  Dual Echo Method for B0 mapping
 
  Assumptions:
    Compute B0 map based on 2 phase images with different TEs
 
  Inputs:
    Phase       4D phase image, 2 different TEs in time dimension
    Magn        3D magnitude image
 
  Outputs:
 	B0map       B0 field map [Hz]
 
  Protocol:
    TimingTable
        deltaTE     Difference in TE between 2 images [ms]            
 
  Options:
    Magn thresh     relative threshold for the magnitude (phase is undefined in the background
 
  Example of command line usage (see also showdemo b0_dem_batch):
    Model = b0_dem;  % Create class from model 
    Model.Prot.TimingTable.Mat = 1.92e-3; % deltaTE [s]
    data.Phase = double(load_nii_data('Phase.nii.gz'));%Load 4D data, 2 frames with different TE
    data.Magn  = double(load_nii_data('Magn.nii.gz'));
    FitResults       = FitData(data,Model);
    FitResultsSave_nii(FitResults,'Phase.nii.gz'); %save nii file using Phase.nii.gz as template
     
    For more examples: qMRusage(b0_dem)
 
  Author: Ian Gagnon, 2017
 
  References:
    Please cite the following if you use this module:
      Maier, F., Fuentes, D., Weinberg, J.S., Hazle, J.D., Stafford, R.J.,
      2015. Robust phase unwrapping for MR temperature imaging using a
      magnitude-sorted list, multi-clustering algorithm. Magn. Reson. Med.
      73, 1662?1668. Schofield, M.A., Zhu, Y., 2003. Fast phase unwrapping
      algorithm for interferometric applications. Opt. Lett. 28, 1194?1196
    In addition to citing the package:
      Cabana J-F, Gu Y, Boudreau M, Levesque IR, Atchia Y, Sled JG,
      Narayanan S, Arnold DL, Pike GB, Cohen-Adad J, Duval T, Vuong M-T and
      Stikov N. (2016), Quantitative magnetization transfer imaging made
      easy with qMTLab: Software for data simulation, analysis, and
      visualization. Concepts Magn. Reson.. doi: 10.1002/cmr.a.21357

    Reference page for b0_dem

Warning: Environment Variable 'ISTRAVIS'=1: close window immediatly. run
>>setenv('ISTRAVIS','') to change this behavior. 
> In Custom_OptionsGUI>OptionsGUI_OutputFcn (line 162)
  In gui_mainfcn (line 262)
  In Custom_OptionsGUI (line 32)
  In b0_dem_batch (line 32)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
...done
Warning: Directory already exists. 
> In FitResultsSave_nii (line 9)
  In b0_dem_batch (line 90)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Elapsed time is 2.334252 seconds.
===============================================================
Testing: b1_dam BATCH...
===============================================================

Model = 

  b1_dam with properties:

     MRIinputs: {'SF60'  'SF120'}
        xnames: {}
     voxelwise: 0
    ProtFormat: {}
          Prot: []
       buttons: {}
       options: [1×1 struct]
       version: [2 0 10]
     ModelName: 'b1_dam'

Please wait. Downloading data ...
Data has been downloaded ...
------------------------------
SAVED: b1_dam_batch.m
Demo is ready at: /private/tmp/qMRLab/b1_dam_demo
------------------------------
  b1_dam map:  Double-Angle Method for B1+ mapping
 
  Assumptions:
    Compute a B1map using 2 SPGR images with 2 different flip angles (60, 120deg)
 
  Inputs:
    SF60            SPGR data at a flip angle of 60 degree
    SF120           SPGR data at a flip angle of 120 degree
 
  Outputs:
 	B1map           Excitation (B1+) field map
 
  Protocol:
 	NONE
 
  Options
    NONE
 
  Example of command line usage (see also showdemo b1_dam_batch):
    Model = b1_dam;% Create class from model 
    data.SF60 = double(load_nii_data('SF60.nii.gz')); %load data
    data.SF120  = double(load_nii_data('SF120.nii.gz'));
    FitResults       = FitData(data,Model); % fit data
    FitResultsSave_nii(FitResults,'SF60.nii.gz'); %save nii file using SF60.nii.gz as template
 
    For more examples: qMRusage(b1_dam)
 
  Author: Ian Gagnon, 2017
 
  References:
    Please cite the following if you use this module:
      Insko, E.K., Bolinger, L., 1993. Mapping of the Radiofrequency Field.
      J. Magn. Reson. A 103, 82?85.
    In addition to citing the package:
      Cabana J-F, Gu Y, Boudreau M, Levesque IR, Atchia Y, Sled JG,
      Narayanan S, Arnold DL, Pike GB, Cohen-Adad J, Duval T, Vuong M-T and
      Stikov N. (2016), Quantitative magnetization transfer imaging made
      easy with qMTLab: Software for data simulation, analysis, and
      visualization. Concepts Magn. Reson.. doi: 10.1002/cmr.a.21357

    Reference page for b1_dam

Warning: Environment Variable 'ISTRAVIS'=1: close window immediatly. run
>>setenv('ISTRAVIS','') to change this behavior. 
> In Custom_OptionsGUI>OptionsGUI_OutputFcn (line 162)
  In gui_mainfcn (line 262)
  In Custom_OptionsGUI (line 32)
  In b1_dam_batch (line 32)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
...done
Warning: Directory already exists. 
> In FitResultsSave_nii (line 9)
  In b1_dam_batch (line 83)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Elapsed time is 0.922826 seconds.
===============================================================
Testing: mt_sat BATCH...
===============================================================

Model = 

  mt_sat with properties:

    MRIinputs: {'MTw'  'T1w'  'PDw'  'B1map'  'Mask'}
       xnames: {}
    voxelwise: 0
         Prot: [1×1 struct]
      buttons: {'B1 correction factor'  [0.4000]}
      options: [1×1 struct]
      version: [2 0 10]
    ModelName: 'mt_sat'

Please wait. Downloading data ...
Data has been downloaded ...
------------------------------
SAVED: mt_sat_batch.m
Demo is ready at: /private/tmp/qMRLab/mt_sat_demo
------------------------------
  mt_sat :  Correction of Magnetization transfer for RF inhomogeneities and T1
 
  Assumptions:
    MTsat is a semi-quantitative method. MTsat values depend on protocol parameters.
 
  Inputs:
    MTw     3D MT-weighted data. Spoiled Gradient Echo (or FLASH) with MT
             pulse
    T1w     3D T1-weighted data. Spoiled Gradient Echo (or FLASH)
    PDw     3D PD-weighted data. Spoiled Gradient Echo (or FLASH)
   (B1map)  B1+ map. B1map = 1 : perfectly accurate flip angle. Optional.
   (Mask)   Binary mask. DOES NOT ACCELERATE FITTING. Just for visualisation
 
  Outputs:
 	  MTSAT         MT saturation map (%), T1-corrected
      T1            T1 map (s)    
 
  Options:
      B1 correction factor     Correction factor (empirical) for the transmit RF. Only
                                corrects MTSAT, not T1. 
                                Weiskopf, N., Suckling, J., Williams, G., CorreiaM.M., Inkster, B., Tait, R., Ooi, C., Bullmore, E.T., Lutti, A., 2013. Quantitative multi-parameter mapping of R1, PD(*), MT, and R2(*) at 3T: a multi-center validation. Front. Neurosci. 7, 95.
 
  Protocol:
      MTw    [FA  TR  Offset]  flip angle [deg], TR [s], Offset Frequency [Hz]
      T1w    [FA  TR]          flip angle [deg], TR [s]
      PDw    [FA  TR]          flip angle [deg], TR [s]
 
  Example of command line usage (see also showdemo mt_sat_batch):
    Model = mt_sat;  % Create class from model
    Model.Prot.MTw.Mat = txt2mat('MT.txt');  % Load protocol
    Model.Prot.T1w.Mat = txt2mat('T1.txt');
    Model.Prot.PDw.Mat = txt2mat('PD.txt');
    data = struct;  % Create data structure
    data.MTw = load_nii_data('MTw.nii.gz');
    data.T1w = load_nii_data('T1w.nii.gz');
    data.PDw = load_nii_data('PDw.nii.gz');  % Load data
    FitResults = FitData(data,Model); %fit data
    FitResultsSave_nii(FitResults,'MTw.nii.gz'); % Save in local folder: FitResults/
 
    For more examples: qMRusage(mt_sat)
 
  Author: Pascale Beliveau ([email protected])
 
  References:
    Please cite the following if you use this module:
      Helms, G., Dathe, H., Kallenberg, K., Dechent, P., 2008. High-resolution maps of magnetization transfer with inherent correction for RF inhomogeneity and T1 relaxation obtained from 3D FLASH MRI. Magn. Reson. Med. 60, 1396?1407.
    In addition to citing the package:
      Cabana J-F, Gu Y, Boudreau M, Levesque IR, Atchia Y, Sled JG, Narayanan S, Arnold DL, Pike GB, Cohen-Adad J, Duval T, Vuong M-T and Stikov N. (2016), Quantitative magnetization transfer imaging made easy with qMTLab: Software for data simulation, analysis, and visualization. Concepts Magn. Reson.. doi: 10.1002/cmr.a.21357

    Reference page for mt_sat

Warning: Environment Variable 'ISTRAVIS'=1: close window immediatly. run
>>setenv('ISTRAVIS','') to change this behavior. 
> In Custom_OptionsGUI>OptionsGUI_OutputFcn (line 162)
  In gui_mainfcn (line 262)
  In Custom_OptionsGUI (line 32)
  In mt_sat_batch (line 32)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
...done
Warning: Directory already exists. 
> In FitResultsSave_nii (line 9)
  In mt_sat_batch (line 105)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Elapsed time is 4.257172 seconds.
===============================================================
Testing: qmt_bssfp BATCH...
===============================================================

Model = 

  qmt_bssfp with properties:

                           MRIinputs: {'MTdata'  'R1map'  'Mask'}
                              xnames: {'F'  'kr'  'R1f'  'R1r'  'T2f'  'M0f'}
                           voxelwise: 1
                                  st: [0.1000 30 1 1 0.0400 1]
                                  lb: [1×6 double]
                                  ub: [0.3000 100 3 3 0.2000 2]
                                  fx: [0 0 1 1 0 0]
                                Prot: [1×1 struct]
                             buttons: {1×25 cell}
                             options: [1×1 struct]
      Sim_Single_Voxel_Curve_buttons: {1×6 cell}
    Sim_Sensitivity_Analysis_buttons: {'# of run'  [5]}
                             version: [2 0 10]
                           ModelName: 'qmt_bssfp'

Please wait. Downloading data ...
Data has been downloaded ...
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'F', 'kr', 'R1f', 'R1r', 'T2f', 'M0f'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

        SNR: 50
     Method: 'Analytical equation'
    ResetMz: 0


   EXAMPLE:
         Model = qmt_bssfp
         x = struct;
         x.F = 0.1;
         x.kr = 30;
         x.R1f = 1;
         x.R1r = 1;
         x.T2f = 0.04;
         x.M0f = 1;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'F', 'kr', 'R1f', 'R1r', 'T2f', 'M0f'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

        SNR: 50
     Method: 'Analytical equation'
    ResetMz: 0


   EXAMPLE:
         Model = qmt_bssfp
         x = struct;
         x.F = 0.1;
         x.kr = 30;
         x.R1f = 1;
         x.R1r = 1;
         x.T2f = 0.04;
         x.M0f = 1;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Sensitivity_Analysis
   Simulates sensitivity to fitted parameters:
      (1) vary fitting parameters from lower (lb) to upper (ub) bound in 10 steps
      (2) run Sim_Single_Voxel_Curve Nofruns times
      (3) Compute mean and std across runs
   USAGE:
     SimVaryResults = Model.Sim_Sensitivity_Analysis(OptTable, Opt);
   INPUT:
     OptTable: [struct] nominal value and range for each parameter.
        st: [vector] nominal values for 'F', 'kr', 'R1f', 'R1r', 'T2f', 'M0f'
        fx: [binary vector] do not vary this parameter?
        lb: [vector] vary from lb...
        ub: [vector] up to ub
     Opt: [struct] Options of the simulation with fields:
  struct with fields:

        SNR: 50
     Method: 'Analytical equation'
    ResetMz: 0
     Nofrun: 5


   EXAMPLE:
         Model = qmt_bssfp
         %              F             kr            R1f           R1r           T2f           M0f           
         OptTable.st = [0.1           30            1             1             0.04          1]; % nominal values
         OptTable.fx = [0             1             1             1             1             1]; %vary F...
         OptTable.lb = [0.0001        0.0001        0.2           0.2           0.01          0.0001]; %...from 0.0001
         OptTable.ub = [0.3           1e+02         3             3             0.2           2]; %...to 0.3
         % Get all possible options
         Opt = button2opts([Model.Sim_Single_Voxel_Curve_buttons, Model.Sim_Sensitivity_Analysis_buttons],1);
         % run simulation using options `Opt(1)`
         SimResults = Model.Sim_Sensitivity_Analysis(OptTable,Opt(1));
         figure('Name','Sensitivity Analysis');
         SimVaryPlot(SimResults, 'F' ,'F' );
 
------------------------------
SAVED: qmt_bssfp_batch.m
Demo is ready at: /private/tmp/qMRLab/qmt_bssfp_demo
------------------------------
  qmt_bssfp : qMT using Balanced Steady State Free Precession acquisition
 -----------------------------------------------------------------------------------------------------
  Assumptions:
  
  Inputs:
    MTdata        4D Magnetization Transfer data
    (R1map)       1/T1map (optional)
    (Mask)        Binary mask to accelerate the fitting (optional)
 
  Outputs:
      F         Ratio of number of restricted pool to free pool, defined 
                as F = M0r/M0f = kf/kr.
      kr        Exchange rate from the free to the restricted pool 
                (note that kf and kr are related to one another via the 
                definition of F. Changing the value of kf will change kr 
                accordingly, and vice versa).
      R1f       Longitudinal relaxation rate of the free pool 
                (R1f = 1/T1f).
      R1r       Longitudinal relaxation rate of the restricted pool 
                (R1r = 1/T1r).
      T2f       Tranverse relaxation time of the free pool (T2f = 1/R2f).
      M0f       Equilibrium value of the free pool longitudinal 
                magnetization.
 
    Additional Outputs
      M0r       Equilibrium value of the restricted pool longitudinal 
                   magnetization.
      kf        Exchange rate from the restricted to the free pool.
      resnorm   Fitting residual.
 
  Protocol:
    MTdata      Array [nbVols x 2]:
        Alpha   Flip angle of the RF pulses (degrees)
        Trf     Duration of the RF pulses (s)
 
  Options:
    RF Pulse
        Shape           Shape of the RF pulses.
                           Available shapes are:
                           - hard
                           - gaussian
                           - gausshann (gaussian pulse with Hanning window)
                           - sinc
                           - sinchann (sinc pulse with Hanning window)
                           - singauss (sinc pulse with gaussian window)
                           - fermi
        Nb of RF pulses Number of RF pulses applied before readout.
 
    Protocol Timing
        Fix TR          Select this option and enter a value in the text 
                          box below to set a fixed repetition time.
        Fix TR - Trf	Select this option and enter a value in the text 
                          box below to set a fixed free precession time
                          (TR - Trf).
        Prepulse      Perform an Alpha/2 - TR/2 prepulse before each 
                          series of RF pulses.
 
    R1
        Use R1map to      By checking this box, you tell the fitting 
          constrain R1f   algorithm to check for an observed R1map and use
                          its value to constrain R1f. Checking this box 
                          will automatically set the R1f fix box to true in            
                          the Fit parameters table.                
        Fix R1r = R1f     By checking this box, you tell the fitting
                          algorithm to fix R1r equal to R1f. Checking this 
                          box will automatically set the R1r fix box to 
                          true in the Fit parameters table.
 
    Global
        G(0)              The assumed value of the absorption lineshape of
                          the restricted pool.
 
  References:
    Please cite the following if you use this module:
    
    In addition to citing the package:
        Cabana J-F, Gu Y, Boudreau M, Levesque IR, Atchia Y, Sled JG, Narayanan S, Arnold DL, Pike GB, Cohen-Adad J, Duval T, Vuong M-T and Stikov N. (2016), Quantitative magnetization transfer imaging made easy with qMTLab: Software for data simulation, analysis, and visualization. Concepts Magn. Reson.. doi: 10.1002/cmr.a.21357
 

    Reference page for qmt_bssfp

Warning: Environment Variable 'ISTRAVIS'=1: close window immediatly. run
>>setenv('ISTRAVIS','') to change this behavior. 
> In Custom_OptionsGUI>OptionsGUI_OutputFcn (line 162)
  In gui_mainfcn (line 262)
  In Custom_OptionsGUI (line 32)
  In qmt_bssfp_batch (line 32)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Fitting voxel     3/4354
...done   0%
Warning: Directory already exists. 
> In FitResultsSave_nii (line 9)
  In qmt_bssfp_batch (line 95)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Elapsed time is 4.300731 seconds.
===============================================================
Testing: qmt_sirfse BATCH...
===============================================================

Model = 

  qmt_sirfse with properties:

                           MRIinputs: {'MTdata'  'R1map'  'Mask'}
                              xnames: {'F'  'kr'  'R1f'  'R1r'  'Sf'  'Sr'  'M0f'}
                           voxelwise: 1
                                  st: [0.1000 30 1 1 -0.9842 0.6564 1]
                                  lb: [1×7 double]
                                  ub: [1 100 10 10 0 1 2]
                                  fx: [0 0 0 1 0 1 0]
                                Prot: [1×1 struct]
                             buttons: {1×21 cell}
                             options: [1×1 struct]
      Sim_Single_Voxel_Curve_buttons: {1×6 cell}
    Sim_Sensitivity_Analysis_buttons: {'# of run'  [5]}
       Sim_Optimize_Protocol_buttons: {1×6 cell}
                             version: [2 0 10]
                           ModelName: 'qmt_sirfse'

Please wait. Downloading data ...
Data has been downloaded ...
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'F', 'kr', 'R1f', 'R1r', 'Sf', 'Sr', 'M0f'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

                       SNR: 50
                    Method: 'Analytical equation'
    T2fUsedinBlockequation: 0.0400


   EXAMPLE:
         Model = qmt_sirfse
         x = struct;
         x.F = 0.1;
         x.kr = 30;
         x.R1f = 1;
         x.R1r = 1;
         x.Sf = -0.98419;
         x.Sr = 0.65638;
         x.M0f = 1;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'F', 'kr', 'R1f', 'R1r', 'Sf', 'Sr', 'M0f'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

                       SNR: 50
                    Method: 'Analytical equation'
    T2fUsedinBlockequation: 0.0400


   EXAMPLE:
         Model = qmt_sirfse
         x = struct;
         x.F = 0.1;
         x.kr = 30;
         x.R1f = 1;
         x.R1r = 1;
         x.Sf = -0.98419;
         x.Sr = 0.65638;
         x.M0f = 1;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Sensitivity_Analysis
   Simulates sensitivity to fitted parameters:
      (1) vary fitting parameters from lower (lb) to upper (ub) bound in 10 steps
      (2) run Sim_Single_Voxel_Curve Nofruns times
      (3) Compute mean and std across runs
   USAGE:
     SimVaryResults = Model.Sim_Sensitivity_Analysis(OptTable, Opt);
   INPUT:
     OptTable: [struct] nominal value and range for each parameter.
        st: [vector] nominal values for 'F', 'kr', 'R1f', 'R1r', 'Sf', 'Sr', 'M0f'
        fx: [binary vector] do not vary this parameter?
        lb: [vector] vary from lb...
        ub: [vector] up to ub
     Opt: [struct] Options of the simulation with fields:
  struct with fields:

                       SNR: 50
                    Method: 'Analytical equation'
    T2fUsedinBlockequation: 0.0400
                    Nofrun: 5


   EXAMPLE:
         Model = qmt_sirfse
         %              F             kr            R1f           R1r           Sf            Sr            M0f           
         OptTable.st = [0.1           30            1             1             -0.98         0.66          1]; % nominal values
         OptTable.fx = [0             1             1             1             1             1             1]; %vary F...
         OptTable.lb = [0.0001        0.0001        0.05          0.05          -1            0.0001        0.0001]; %...from 0.0001
         OptTable.ub = [1             1e+02         10            10            0             1             2]; %...to 1
         % Get all possible options
         Opt = button2opts([Model.Sim_Single_Voxel_Curve_buttons, Model.Sim_Sensitivity_Analysis_buttons],1);
         % run simulation using options `Opt(1)`
         SimResults = Model.Sim_Sensitivity_Analysis(OptTable,Opt(1));
         figure('Name','Sensitivity Analysis');
         SimVaryPlot(SimResults, 'F' ,'F' );
 
------------------------------
SAVED: qmt_sirfse_batch.m
Demo is ready at: /private/tmp/qMRLab/qmt_sirfse_demo
------------------------------
  qmt_sirfse:  qMT using Inversion Recovery Fast Spin Echo acquisition
 Pulse Sequence Diagram
 
  ASSUMPTIONS: 
  (1) FILL
  (2) 
  (3) 
  (4) 
 
  Inputs:
    MTdata              Magnetization Transfert data
    (R1map)             1/T1map (OPTIONAL but recommended)
    (Mask)              Binary mask to accelerate the fitting (OPTIONAL)
 
  Outputs:
    F                   Ratio of number of restricted pool to free pool, defined 
                          as F = M0r/M0f = kf/kr.
    kr                  Exchange rate from the free to the restricted pool 
                          (note that kf and kr are related to one another via the 
                          definition of F. Changing the value of kf will change kr 
                          accordingly, and vice versa).
    R1f                 Longitudinal relaxation rate of the free pool 
                          (R1f = 1/T1f).
    R1r                 Longitudinal relaxation rate of the restricted pool 
                          (R1r = 1/T1r).
    Sf                  Instantaneous fraction of magnetization after vs. before 
                          the pulse in the free pool. Starting point is computed using Block
                          simulation.
    Sr                  Instantaneous fraction of magnetization after vs. before 
                          the pulse in the restricted pool. Starting point is computed using block
                          simulation.
    M0f                 Equilibrium value of the free pool longitudinal 
                          magnetization.
    (M0r)               Equilibrium value of the restricted pool longitudinal 
                          magnetization. Computed using M0f = M0r * F. 
    (kf)                Exchange rate from the restricted to the free pool. 
                          Computed using kf = kr * F.
    (resnorm)           Fitting residual.
 
  Protocol:
    MTdata
      Ti                Inversion times (s)
      Td                Delay times (s)   
 
    FSEsequence
      Trf               Duration of the pulses in the FSE sequence (s)
      Tr                Delay between the pulses in the FSE sequnece (s)
      Npulse            Number of refocusing pulses in the FSE sequence
 
  Options:
    Inversion Pulse
      Shape             Shape of the inversion pulse.
                           Available shapes are:
                           - hard
                           - gaussian
                           - gausshann (gaussian pulse with Hanning window)
                           - sinc
                           - sinchann (sinc pulse with Hanning window)
                           - singauss (sinc pulse with gaussian window)
                           - fermi
      Duration          Duration of the inversion pulse (s)
 
    Fitting
      Use R1map to      By checking this box, you tell the fitting 
      constrain R1f       algorithm to check for an observed R1map and use
                          its value to constrain R1f. Checking this box 
                          will automatically set the R1f fix box to true in            
                          the Fit parameters table.                
      Fix R1r = R1f     By checking this box, you tell the fitting
                          algorithm to fix R1r equal to R1f. Checking this 
                          box will automatically set the R1r fix box to 
                          true in the Fit parameters table.
 
    Sr Calculation
      Lineshape         The absorption lineshape of the restricted pool. Available lineshapes are: Gaussian, Lorentzian and SuperLorentzian.
      T2r               Transverse relaxation time of the restricted pool (T2r = 1/R2r)
 
  Example of command line usage (see also showdemo qmt_sirfse_batch):
    For more examples: qMRusage(qmt_sirfse)
 
  Author: Ian Gagnon, 2017

    Reference page for qmt_sirfse

Warning: Environment Variable 'ISTRAVIS'=1: close window immediatly. run
>>setenv('ISTRAVIS','') to change this behavior. 
> In Custom_OptionsGUI>OptionsGUI_OutputFcn (line 162)
  In gui_mainfcn (line 262)
  In Custom_OptionsGUI (line 32)
  In qmt_sirfse_batch (line 32)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Fitting voxel     3/4354
...done   0%
Warning: Directory already exists. 
> In FitResultsSave_nii (line 9)
  In qmt_sirfse_batch (line 99)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Elapsed time is 3.298491 seconds.
===============================================================
Testing: qmt_spgr BATCH...
===============================================================

Model = 

  qmt_spgr with properties:

                           MRIinputs: {'MTdata'  'R1map'  'B1map'  'B0map'  'Mask'}
                              xnames: {'F'  'kr'  'R1f'  'R1r'  'T2f'  'T2r'}
                           voxelwise: 1
                                  st: [0.1600 30 1 1 0.0300 1.3000e-05]
                                  lb: [1×6 double]
                                  ub: [0.5000 100 5 5 0.5000 5.0000e-05]
                                  fx: [0 0 1 1 0 0]
                                Prot: [1×1 struct]
                         ProtSfTable: [1×1 struct]
                             buttons: {1×32 cell}
                             options: [1×1 struct]
      Sim_Single_Voxel_Curve_buttons: {1×6 cell}
    Sim_Sensitivity_Analysis_buttons: {'# of run'  [5]}
       Sim_Optimize_Protocol_buttons: {1×6 cell}
                             version: [2 0 10]
                           ModelName: 'qmt_spgr'

Please wait. Downloading data ...
Data has been downloaded ...
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'F', 'kr', 'R1f', 'R1r', 'T2f', 'T2r'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

        SNR: 50
     Method: 'Analytical equation'
    ResetMz: 0


   EXAMPLE:
         Model = qmt_spgr
         x = struct;
         x.F = 0.16;
         x.kr = 30;
         x.R1f = 1;
         x.R1r = 1;
         x.T2f = 0.03;
         x.T2r = 1.3e-05;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'F', 'kr', 'R1f', 'R1r', 'T2f', 'T2r'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

        SNR: 50
     Method: 'Analytical equation'
    ResetMz: 0


   EXAMPLE:
         Model = qmt_spgr
         x = struct;
         x.F = 0.16;
         x.kr = 30;
         x.R1f = 1;
         x.R1r = 1;
         x.T2f = 0.03;
         x.T2r = 1.3e-05;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Sensitivity_Analysis
   Simulates sensitivity to fitted parameters:
      (1) vary fitting parameters from lower (lb) to upper (ub) bound in 10 steps
      (2) run Sim_Single_Voxel_Curve Nofruns times
      (3) Compute mean and std across runs
   USAGE:
     SimVaryResults = Model.Sim_Sensitivity_Analysis(OptTable, Opt);
   INPUT:
     OptTable: [struct] nominal value and range for each parameter.
        st: [vector] nominal values for 'F', 'kr', 'R1f', 'R1r', 'T2f', 'T2r'
        fx: [binary vector] do not vary this parameter?
        lb: [vector] vary from lb...
        ub: [vector] up to ub
     Opt: [struct] Options of the simulation with fields:
  struct with fields:

        SNR: 50
     Method: 'Analytical equation'
    ResetMz: 0
     Nofrun: 5


   EXAMPLE:
         Model = qmt_spgr
         %              F             kr            R1f           R1r           T2f           T2r           
         OptTable.st = [0.16          30            1             1             0.03          1.3e-05]; % nominal values
         OptTable.fx = [0             1             1             1             1             1]; %vary F...
         OptTable.lb = [0.0001        0.0001        0.05          0.05          0.003         3e-06]; %...from 0.0001
         OptTable.ub = [0.5           1e+02         5             5             0.5           5e-05]; %...to 0.5
         % Get all possible options
         Opt = button2opts([Model.Sim_Single_Voxel_Curve_buttons, Model.Sim_Sensitivity_Analysis_buttons],1);
         % run simulation using options `Opt(1)`
         SimResults = Model.Sim_Sensitivity_Analysis(OptTable,Opt(1));
         figure('Name','Sensitivity Analysis');
         SimVaryPlot(SimResults, 'F' ,'F' );
 
------------------------------
SAVED: qmt_spgr_batch.m
Demo is ready at: /private/tmp/qMRLab/qmt_spgr_demo
------------------------------
 qmt_spgr:  quantitative Magnetizatoion Transfer (qMT) using Spoiled Gradient Echo (or FLASH)
 Pulse Sequence Diagram
 
  Assumptions:
    FILL
 
  Inputs:
    MTdata              Magnetization Transfert data
    (R1map)             1/T1map (VFA RECOMMENDED Boudreau 2017 MRM)
    (B1map)             B1 field map, used for flip angle correction (=1 if not provided)
    (B0map)             B0 field map, used for offset correction (=0Hz if not provided)
    (Mask)              Binary mask to accelerate the fitting
 
  Outputs:
    F                   Ratio of number of restricted pool to free pool, defined
                          as F = M0r/M0f = kf/kr.
    kr                  Exchange rate from the free to the restricted pool
                          (note that kf and kr are related to one another via the
                          definition of F. Changing the value of kf will change kr
                          accordingly, and vice versa).
    R1f                 Longitudinal relaxation rate of the free pool
                          (R1f = 1/T1f).
 	R1r                 Longitudinal relaxation rate of the restricted pool
                          (R1r = 1/T1r).
 	T2f                 Tranverse relaxation time of the free pool (T2f = 1/R2f).
    T2r                 Tranverse relaxation time of the restricted pool (T2r = 1/R2r).
 	(kf)                Exchange rate from the restricted to the free pool.
    (resnorm)           Fitting residual.
 
  Protocol:
    MTdata              Array [Nb of volumes x 2]
      Angle             MT pulses angles (degree)
      Offset            Offset frequencies (Hz)
 
    TimingTable         Vector [5x1]
      Tmt               Duration of the MT pulses (s)
      Ts                Free precession delay between the MT and excitation pulses (s)
      Tp                Duration of the excitation pulse (s)
      Tr                Free precession delay after tje excitation pulse, before
                          the next MT pulse (s)
      TR                Repetition time of the whole sequence (TR = Tmt + Ts + Tp + Tr)
 
 
  Options:
    MT Pulse
      Shape                 Shape of the MT pulse.
                               Available shapes are:
                               - hard
                               - gaussian
                               - gausshann (gaussian pulse with Hanning window)
                               - sinc
                               - sinchann (sinc pulse with Hanning window)
                               - singauss (sinc pulse with gaussian window)
                               - fermi
      Sinc TBW              Time-bandwidth product for the sinc MT pulses
                               (applicable to sinc, sincgauss, sinchann MT
                               pulses).
      Bandwidth             Bandwidth of the gaussian MT pulse (applicable
                               to gaussian, gausshann and sincgauss MT pulses).
      Fermi transition (a)  slope 'a' (related to the transition width)
                               of the Fermi pulse (applicable to fermi MT
                               pulse).
                               Assuming pulse duration at 60 dB (from the Bernstein handbook)
                               and t0 = 10a,
                               slope = Tmt/33.81;
      # of MT pulses        Number of pulses used to achieve steady-state
                              before a readout is made.
    Fitting constraints
      Use R1map to         By checking this box, you tell the fitting
      constrain R1f          algorithm to check for an observed R1map and use
                             its value to constrain R1f. Checking this box
                             will automatically set the R1f fix box to true
                             in the Fit parameters table.
      Fix R1r = R1f        By checking this box, you tell the fitting
                             algorithm to fix R1r equal to R1f. Checking this
                             box will automatically set the R1r fix box to
                             true in the Fit parameters table.
      Fix R1f*T2f          By checking this box, you tell the fitting
                             algorithm to compute T2f from R1f value. R1f*T2f
                             value is set in the next box.
      R1f*T2f =            Value of R1f*T2f (no units)
 
    Model                  Model you want to use for fitting.
                              Available models are:
                              - SledPikeRP (Sled & Pike rectangular pulse),
                              - SledPikeCW (Sled & Pike continuous wave),
                              - Yarkykh (Yarnykh & Yuan)
                              - Ramani
                              Note: Sled & Pike models will show different
                                options than Yarnykh or Ramani.
 	Lineshape              The absorption lineshape of the restricted pool.
                              Available lineshapes are:
                              - Gaussian
                              - Lorentzian
                              - SuperLorentzian
    Read pulse alpha       Flip angle of the excitation pulse.
    Compute SfTable        By checking this box, you compute a new SfTable
 
  Command line usage:
    qMRusage(qmt_spgr
    showdemo qmt_spgr_batch
 
  Author: Ian Gagnon, 2017
 
  References:
    Please cite the following if you use this module:
      Sled, J.G., Pike, G.B., 2000. Quantitative interpretation of magnetization transfer in spoiled gradient echo MRI sequences. J. Magn. Reson. 145, 24?36.
    In addition to citing the package:
      Cabana J-F, Gu Y, Boudreau M, Levesque IR, Atchia Y, Sled JG, Narayanan S, Arnold DL, Pike GB, Cohen-Adad J, Duval T, Vuong M-T and Stikov N. (2016), Quantitative magnetization transfer imaging made easy with qMTLab: Software for data simulation, analysis, and visualization. Concepts Magn. Reson.. doi: 10.1002/cmr.a.21357

    Reference page for qmt_spgr

Warning: Environment Variable 'ISTRAVIS'=1: close window immediatly. run
>>setenv('ISTRAVIS','') to change this behavior. 
> In Custom_OptionsGUI>OptionsGUI_OutputFcn (line 162)
  In gui_mainfcn (line 262)
  In Custom_OptionsGUI (line 32)
  In qmt_spgr_batch (line 32)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Fitting voxel     1/4101
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In FitData (line 106)
  In qmt_spgr_batch (line 99)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (l   2/4101
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In FitData (line 106)
  In qmt_spgr_batch (line 99)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (l   3/4101
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In FitData (line 106)
  In qmt_spgr_batch (line 99)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
...done   0%
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/plotModel (line 295)
  In qMRshowOutput (line 45)
  In qmt_spgr_batch (line 109)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: Directory already exists. 
> In FitResultsSave_nii (line 9)
  In qmt_spgr_batch (line 114)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In qmt_spgr_batch (line 139)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/plotModel (line 295)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 318)
  In qmt_spgr_batch (line 139)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Warning: No MToff (i.e. no volumes acquired with Angles=0) --> Fitting assumes that
MTData are already normalized. 
> In qmt_spgr/fit (line 274)
  In qmt_spgr/Sim_Single_Voxel_Curve (line 315)
  In SimVary (line 48)
  In qmt_spgr/Sim_Sensitivity_Analysis (line 325)
  In qmt_spgr_batch (line 157)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Elapsed time is 18.544414 seconds.
===============================================================
Testing: noise_level BATCH...
===============================================================

Model = 

  noise_level with properties:

    MRIinputs: {'Data4D'  'NoiseMask'}
       xnames: {}
    voxelwise: 0
         Prot: [1×1 struct]
      buttons: {'figure'  [1]  'Noise Distribution'  {1×2 cell}}
      options: [1×1 struct]
      version: [2 0 10]
    ModelName: 'noise_level'

Please wait. Downloading data ...
Data has been downloaded ...
------------------------------
SAVED: noise_level_batch.m
Demo is ready at: /private/tmp/qMRLab/noise_level_demo
------------------------------
  noise_level :  Noise histogram fitting within a noise mask
  ASSUMPTIONS:
    (1)Uniform noise distribution. Outputs are scalar : all voxels have
        the same value
 
  Fitted Parameters:
    Non-central Chi Parameters
        Sigma
        eta
        N
 
  Options:
     figure             plot noise histogram fit
  Noise Distribution
     Rician             valid if using one coil OR adaptive combine
     Non-central Chi    valid for multi-coil and parallel imaging (parameter N reprensent the effective number of coils)
 
  Author: Ian Gagnon, 2017
 
  References:
    Please cite the following if you use this module:
      FILL
    In addition to citing the package:
      Cabana J-F, Gu Y, Boudreau M, Levesque IR, Atchia Y, Sled JG, Narayanan S, Arnold DL, Pike GB, Cohen-Adad J, Duval T, Vuong M-T and Stikov N. (2016), Quantitative magnetization transfer imaging made easy with qMTLab: Software for data simulation, analysis, and visualization. Concepts Magn. Reson.. doi: 10.1002/cmr.a.21357

    Reference page for noise_level

Warning: Environment Variable 'ISTRAVIS'=1: close window immediatly. run
>>setenv('ISTRAVIS','') to change this behavior. 
> In Custom_OptionsGUI>OptionsGUI_OutputFcn (line 162)
  In gui_mainfcn (line 262)
  In Custom_OptionsGUI (line 32)
  In noise_level_batch (line 32)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
     N        eta      sigma_g
    1.0000    0.0000    7.8462

...done
Warning: Directory already exists. 
> In FitResultsSave_nii (line 9)
  In noise_level_batch (line 85)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Elapsed time is 2.189288 seconds.
===============================================================
Testing: inversion_recovery BATCH...
===============================================================

Model = 

  inversion_recovery with properties:

                         MRIinputs: {'IRData'  'Mask'}
                            xnames: {'T1'  'rb'  'ra'}
                         voxelwise: 1
                                st: [600 -1000 500]
                                lb: [1.0000e-04 -10000 1.0000e-04]
                                ub: [5000 0 10000]
                                fx: [0 0 0]
                              Prot: [1×1 struct]
                           buttons: {'method'  {1×2 cell}}
                           options: [1×1 struct]
    Sim_Single_Voxel_Curve_buttons: {'SNR'  [50]}
     Sim_Optimize_Protocol_buttons: {1×6 cell}
                           version: [2 0 10]
                         ModelName: 'inversion_recovery'

Please wait. Downloading data ...
Data has been downloaded ...
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'T1', 'rb', 'ra'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = inversion_recovery
         x = struct;
         x.T1 = 600;
         x.rb = -1000;
         x.ra = 500;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'T1', 'rb', 'ra'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = inversion_recovery
         x = struct;
         x.T1 = 600;
         x.rb = -1000;
         x.ra = 500;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Sensitivity_Analysis
   Simulates sensitivity to fitted parameters:
      (1) vary fitting parameters from lower (lb) to upper (ub) bound in 10 steps
      (2) run Sim_Single_Voxel_Curve Nofruns times
      (3) Compute mean and std across runs
   USAGE:
     SimVaryResults = Model.Sim_Sensitivity_Analysis(OptTable, Opt);
   INPUT:
     OptTable: [struct] nominal value and range for each parameter.
        st: [vector] nominal values for 'T1', 'rb', 'ra'
        fx: [binary vector] do not vary this parameter?
        lb: [vector] vary from lb...
        ub: [vector] up to ub
     Opt: [struct] Options of the simulation with fields:
  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = inversion_recovery
         %              T1            rb            ra            
         OptTable.st = [6e+02         -1e+03        5e+02]; % nominal values
         OptTable.fx = [0             1             1]; %vary T1...
         OptTable.lb = [0.0001        -1e+04        0.0001]; %...from 0.0001
         OptTable.ub = [5e+03         0             1e+04]; %...to 5000
          Opt.SNR = 50;
          Opt.Nofrun = 5;
         % run simulation using options `Opt(1)`
         SimResults = Model.Sim_Sensitivity_Analysis(OptTable,Opt(1));
         figure('Name','Sensitivity Analysis');
         SimVaryPlot(SimResults, 'T1' ,'T1' );
 
------------------------------
SAVED: inversion_recovery_batch.m
Demo is ready at: /private/tmp/qMRLab/inversion_recovery_demo
------------------------------
 inversion_recovery: Compute a T1 map using Inversion Recovery data
 
  Assumptions:
  (1) Gold standard for T1 mapping
  (2) Infinite TR
 
  Inputs:
    IRData      Inversion Recovery data (4D)
    (Mask)      Binary mask to accelerate the fitting (OPTIONAL)
 
  Outputs:
    T1          transverse relaxation time [ms]
    b           arbitrary fit parameter (S=a + b*exp(-TI/T1))
    a           arbitrary fit parameter (S=a + b*exp(-TI/T1))
    idx         index of last polarity restored datapoint (only used for magnitude data)
    res         Fitting residual
 
 
  Protocol:
 	IRData  [TI1 TI2...TIn] inversion times [ms]
 
  Options:
    Method          Method to use in order to fit the data, based on whether complex or only magnitude data acquired.
      'complex'         RD-NLS (Reduced-Dimension Non-Linear Least Squares)
                          S=a + b*exp(-TI/T1)
       'magnitude'      RD-NLS-PR (Reduced-Dimension Non-Linear Least Squares with Polarity Restoration)
                          S=|a + b*exp(-TI/T1)|
 
  Example of command line usage (see also showdemo inversion_recovery_batch):
    Model = inversion_recovery;  % Create class from model
    Model.Prot.IRData.Mat=[350.0000; 500.0000; 650.0000; 800.0000; 950.0000; 1100.0000; 1250.0000; 1400.0000; 1700.0000];
    data = struct;  % Create data structure
    data.MET2data ='IRData.mat';  % Load data
    data.Mask = 'Mask.mat';
    FitResults = FitData(data,Model); %fit data
    FitResultsSave_mat(FitResults);
 
        For more examples: qMRusage(inversion_recovery)
 
  Author: Ilana Leppert, 2017
 
  References:
    Please cite the following if you use this module:
        A robust methodology for in vivo T1 mapping. Barral JK, Gudmundson E, Stikov N, Etezadi-Amoli M, Stoica P, Nishimura DG. Magn Reson Med. 2010 Oct;64(4):1057-67. doi: 10.1002/mrm.22497.
    In addition to citing the package:
        Cabana J-F, Gu Y, Boudreau M, Levesque IR, Atchia Y, Sled JG, Narayanan S, Arnold DL, Pike GB, Cohen-Adad J, Duval T, Vuong M-T and Stikov N. (2016), Quantitative magnetization transfer imaging made easy with qMTLab: Software for data simulation, analysis, and visualization. Concepts Magn. Reson.. doi: 10.1002/cmr.a.21357
 

    Reference page for inversion_recovery

Warning: Environment Variable 'ISTRAVIS'=1: close window immediatly. run
>>setenv('ISTRAVIS','') to change this behavior. 
> In Custom_OptionsGUI>OptionsGUI_OutputFcn (line 162)
  In gui_mainfcn (line 262)
  In Custom_OptionsGUI (line 32)
  In inversion_recovery_batch (line 32)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Fitting voxel     3/4532
...done   0%
Warning: Directory already exists. 
> In FitResultsSave_nii (line 9)
  In inversion_recovery_batch (line 92)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Elapsed time is 1.235961 seconds.
===============================================================
Testing: vfa_t1 BATCH...
===============================================================

Model = 

  vfa_t1 with properties:

                         MRIinputs: {'VFAData'  'B1map'  'Mask'}
                            xnames: {'M0'  'T1'}
                         voxelwise: 1
                              Prot: [1×1 struct]
                                st: [2000 0.7000]
                                lb: [0 1.0000e-05]
                                ub: [6000 5]
                                fx: [0 0]
                           buttons: {}
                           options: [1×1 struct]
    Sim_Single_Voxel_Curve_buttons: {'SNR'  [50]}
     Sim_Optimize_Protocol_buttons: {1×6 cell}
                           version: [2 0 10]
                         ModelName: 'vfa_t1'

Please wait. Downloading data ...
Data has been downloaded ...
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'M0', 'T1'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = vfa_t1
         x = struct;
         x.M0 = 2000;
         x.T1 = 0.7;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'M0', 'T1'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = vfa_t1
         x = struct;
         x.M0 = 2000;
         x.T1 = 0.7;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Sensitivity_Analysis
   Simulates sensitivity to fitted parameters:
      (1) vary fitting parameters from lower (lb) to upper (ub) bound in 10 steps
      (2) run Sim_Single_Voxel_Curve Nofruns times
      (3) Compute mean and std across runs
   USAGE:
     SimVaryResults = Model.Sim_Sensitivity_Analysis(OptTable, Opt);
   INPUT:
     OptTable: [struct] nominal value and range for each parameter.
        st: [vector] nominal values for 'M0', 'T1'
        fx: [binary vector] do not vary this parameter?
        lb: [vector] vary from lb...
        ub: [vector] up to ub
     Opt: [struct] Options of the simulation with fields:
  struct with fields:

    SNR: 50


   EXAMPLE:
         Model = vfa_t1
         %              M0            T1            
         OptTable.st = [2e+03         0.7]; % nominal values
         OptTable.fx = [0             1]; %vary M0...
         OptTable.lb = [0             1e-05]; %...from 0
         OptTable.ub = [6e+03         5]; %...to 6000
          Opt.SNR = 50;
          Opt.Nofrun = 5;
         % run simulation using options `Opt(1)`
         SimResults = Model.Sim_Sensitivity_Analysis(OptTable,Opt(1));
         figure('Name','Sensitivity Analysis');
         SimVaryPlot(SimResults, 'M0' ,'M0' );
 
------------------------------
SAVED: vfa_t1_batch.m
Demo is ready at: /private/tmp/qMRLab/vfa_t1_demo
------------------------------
  vfa_t1: Compute a T1 map using Variable Flip Angle
 
  Assumptions:
  
  Inputs:
    VFAData         spoiled Gradient echo data, 4D volume with different flip angles in time dimension
    (B1map)         excitation (B1+) fieldmap. Used to correct flip angles. (optional)
    (Mask)          Binary mask to accelerate the fitting (optional)
 
  Outputs:
    T1              Longitudinal relaxation time [s]
    M0              Equilibrium magnetization
 
  Protocol:
    VFAData Array [nbFA x 2]:
        [FA1 TR1; FA2 TR2;...]      flip angle [degrees] TR [s]
 
  Options:
    None
 
  Example of command line usage (see also showdemo vfa_t1_batch):
    Model = vfa_t1;  % Create class from model 
    Model.Prot.VFAData.Mat=[3 0.015; 20 0.015]; %Protocol: 2 different FAs
    data = struct;  % Create data structure 
    data.VFAData = load_nii_data('VFAData.nii.gz');
    data.B1map = load_nii_data('B1map.nii.gz');
    FitResults = FitData(data,Model); %fit data
    FitResultsSave_mat(FitResults);
 
    For more examples: qMRusage(vfa_t1)
 
  
  Author: Ian Gagnon, 2017
 
  References:
    Please cite the following if you use this module:
      Fram, E.K., Herfkens, R.J., Johnson, G.A., Glover, G.H., Karis, J.P.,
      Shimakawa, A., Perkins, T.G., Pelc, N.J., 1987. Rapid calculation of
      T1 using variable flip angle gradient refocused imaging. Magn. Reson.
      Imaging 5, 201?208
    In addition to citing the package:
      Cabana J-F, Gu Y, Boudreau M, Levesque IR, Atchia Y, Sled JG,
      Narayanan S, Arnold DL, Pike GB, Cohen-Adad J, Duval T, Vuong M-T and
      Stikov N. (2016), Quantitative magnetization transfer imaging made
      easy with qMTLab: Software for data simulation, analysis, and
      visualization. Concepts Magn. Reson.. doi: 10.1002/cmr.a.21357

    Reference page for vfa_t1

Warning: Environment Variable 'ISTRAVIS'=1: close window immediatly. run
>>setenv('ISTRAVIS','') to change this behavior. 
> In Custom_OptionsGUI>OptionsGUI_OutputFcn (line 162)
  In gui_mainfcn (line 262)
  In Custom_OptionsGUI (line 32)
  In vfa_t1_batch (line 32)
  In BatchExample_test>test_batch (line 55)
  In MOxUnitFunctionHandleTestCase/run (line 24)
  In MOxUnitTestSuite/run (line 53)
  In MOxUnitTestSuite/run (line 53)
  In moxunit_runtests>@()run(suite,test_report,params.partition_index,params.partition_count)
  In moxunit_runtests>run_all_tests (line 207)
  In moxunit_runtests (line 102) 
Fitting voxel     3/4668
...done   0%
          M0: 2.5567e+03
       Model: [1×1 vfa_t1]
    Protocol: [1×1 struct]
          T1: 1.3447
        Time: 0.1078
     Version: [2 0 10]
    computed: [128×128 double]
      fields: {'T1'  'M0'}

    T1: 0.7423
    M0: 2.0969e+03

Elapsed time is 1.584384 seconds.
===============================================================
Testing: mwf BATCH...
===============================================================

Model = 

  mwf with properties:

                           MRIinputs: {'MET2data'  'Mask'}
                              xnames: {'MWF'  'T2MW'  'T2IEW'}
                           voxelwise: 1
                                  lb: [1.0000e-04 1.0000e-04 40]
                                  ub: [100 40 200]
                                  fx: [0 0 0]
                                Prot: [1×1 struct]
                             buttons: {1×6 cell}
                             options: [1×1 struct]
      Sim_Single_Voxel_Curve_buttons: {1×9 cell}
    Sim_Sensitivity_Analysis_buttons: {'# of run'  [5]}
                             version: [2 0 10]
                           ModelName: 'mwf'

Please wait. Downloading data ...
Data has been downloaded ...
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'MWF', 'T2MW', 'T2IEW'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

                                             SNR: 200
                       T2Spectrumvariance_Myelin: 5
    T2Spectrumvariance_IEIntraExtracellularWater: 20


   EXAMPLE:
         Model = mwf
         x = struct;
         x.MWF = 50.0001;
         x.T2MW = 20.0001;
         x.T2IEW = 120;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Single_Voxel_Curve
   Simulates Single Voxel curves:
      (1) use equation to generate synthetic MRI data
      (2) add rician noise
      (3) fit and plot curve
   USAGE:
     FitResults = Model.Sim_Single_Voxel_Curve(x)
     FitResults = Model.Sim_Single_Voxel_Curve(x, Opt,display)
   INPUT:
     x: [struct] OR [vector] containing fit results: 'MWF', 'T2MW', 'T2IEW'
     display: [binary] 1=display, 0=nodisplay
     Opt:  struct with fields:

                                             SNR: 200
                       T2Spectrumvariance_Myelin: 5
    T2Spectrumvariance_IEIntraExtracellularWater: 20


   EXAMPLE:
         Model = mwf
         x = struct;
         x.MWF = 50.0001;
         x.T2MW = 20.0001;
         x.T2IEW = 120;
         % Get all possible options
         Opt = button2opts(Model.Sim_Single_Voxel_Curve_buttons,1);
         % run simulation using options `Opt(1)`
         figure('Name','Single Voxel Curve Simulation');
         FitResult = Model.Sim_Single_Voxel_Curve(x,Opt(1));
 
Sim_Sensitivity_Analysis
   Simulates sensitivity to fitted parameters:
      (1) vary fitting parameters from lower (lb) to upper (ub) bound in 10 steps
      (2) run Sim_Single_Voxel_Curve Nofruns times
      (3) Compute mean and std across runs
   USAGE:
     SimVaryResults = Model.Sim_Sensitivity_Analysis(OptTable, Opt);
   INPUT:
     OptTable: [struct] nominal value and range for each parameter.
        st: [vector] nominal values for 'MWF', 'T2MW', 'T2IEW'
        fx: [binary vector] do not vary this parameter?
        lb: [vector] vary from lb...
        ub: [vector] up to ub
     Opt: [struct] Options of the simulation with fields:
  struct with fields:

                                             SNR: 200
                       T2Spectrumvariance_Myelin: 5
    T2Spectrumvariance_IEIntraExtracellularWater: 20
                                          Nofrun: 5


   EXAMPLE:
         Model = mwf
         %              MWF           T2MW          T2IEW         
         OptTable.st = [50            20            1.2e+02]; % nominal values
         OptTable.fx = [0             1             1]; %vary MWF...
         OptTable.lb = [0.0001        0.0001        40]; %...from 0.0001
         OptTable.ub = [1e+02         40            2e+02]; %...to 100
         % Get all possible options
         Opt = button2opts([Model.Sim_Single_Voxel_Curve_buttons, Model.Sim_Sensitivity_Analysis_buttons],1);
         % run simulation using options `Opt(1)`
         SimResults = Model.Sim_Sensitivity_Analysis(OptTable,Opt(1));
         figure('Name','Sensitivity Analysis');
         SimVaryPlot(SimResults, 'MWF' ,'MWF' );
 
------------------------------
SAVED: mwf_batch.m
Demo is ready at: /private/tmp/qMRLab/mwf_demo
------------------------------
  mwf :  Myelin Water Fraction from Multi-Exponential T2w data
 
  Assumptions:
 
  Inputs:
    MET2data    Multi-Exponential T2 data
    (Mask)        Binary mask to accelerate the fitting (OPTIONAL)
 
  Outputs:
    mwf       Myelin Wanter Fraction
    T2MW      Spin relaxation time for Myelin Water (MW) [ms]
    T2IEW     Spin relaxation time for Intra/Extracellular Water (IEW) [ms]
 
  Options:
    Cutoff          Cutoff time [ms]
    Sigma           Noise standard deviation. Currently not corrected for rician bias
    Relaxation Type
         'T2'       For a SE sequence
        'T2*'      For a GRE sequence
 
  Protocol:
   MET2data   [TE1 TE2 ...] % list of echo times [ms]
 
  Example of command line usage (see also showdemo mwf_batch):
    Model = mwf;  % Create class from model
    Model.Prot.MET2data.Mat=[10:10:320];
    data = struct;  % Create data structure
    data.MET2data ='MET2data.mat';  % Load data
    data.Mask = 'Mask.mat';
    FitResults = FitData(data,Model); %fit data
    FitResultsSave_mat(FitResults);
 
        For more examples: qMRusage(mwf)
 
  Author: Ian Gagnon, 2017
 
  References:
    Please cite the following if you use this module:
      MacKay, A., Whittall, K., Adler, J., Li, D., Paty, D., Graeb, D.,
      1994. In vivo visualization of myelin water in brain by magnetic
      resonance. Magn. Reson. Med. 31, 673?677.
    In addition to citing the package:
      Cabana J-F, Gu Y, Boudreau M, Levesque IR, Atchia Y, Sled JG,
      Narayanan S, Arnold DL, Pike GB, Cohen-Adad J, Duval T, Vuong M-T and
      Stikov N. (2016), Quantitative magnetization transfer imaging made
      easy with qMTLab: Software for data simulation, analysis, and
      visualization. Concepts Magn. Reson.. doi: 10.1002/cmr.a.21357

    Reference page for mwf

Fitting voxel     3/2540
...done   0%
Elapsed time is 2.880604 seconds.
..
--------------------------------------------------

OK (passed=3)

res =

  logical

   1

However, with the MOcov flags:

res=moxunit_runtests('Test/MoxUnitCompatible/BatchExample_test.m','-with_coverage', '-cover','qMRLab/', '-cover_xml_file','coverage.xml', '-cover_html_dir','coverage_html')

The tests fails almost immediately:


>> res=moxunit_runtests('Test/MoxUnitCompatible/BatchExample_test.m','-with_coverage', '-cover','qMRLab/', '-cover_xml_file','coverage.xml', '-cover_html_dir','coverage_html')
suite: 3 tests
running coverage with parameters: -expression <function_handle> -cover qMRLab/ -cover_xml_file coverage.xml -cover_html_dir coverage_html 
.===============================================================
Testing: charmed BATCH...
===============================================================
31      eval(['Model = ' Modellist{iModel}]);
F.Error using MOcovMFileCollection/get_mfile>get_mfile_by_name (line 42)
Not found: Common/list_models.m

Error in MOcovMFileCollection/get_mfile (line 22)
    [mfile,idx]=lookup_func(obj,fn);

Error in MOcovMFileCollection/add_lines_executed_count (line 39)
        [mfile,idx]=get_mfile(obj, fn);

Error in mocov (line 107)
    mfile_collection=add_lines_executed_count(mfile_collection);

Error in moxunit_runtests>run_all_tests (line 205)
        test_report=mocov(all_params{:});

Error in moxunit_runtests (line 102)
    test_report=run_all_tests(suite, test_report, params);
 
>> 

Although the error message seems to suggest that the test fails on line 24 of the test file, by using breakpoints and stepping through this test file, it actually appears to fail on line 31, which is the first time it tries to create an object of the class charmed. If I try to run that line while debugging, the error I get is:

K>> eval(['Model = ' Modellist{iModel}]);
Error using txt2mat (line 734)
Invalid default value for property 'Prot' in class 'charmed':
no such file or directory

which suggests that there is an issue creating the property Prot for the class. The property Prot reads a file in location /"path where qMRLab.m is in"/Models_Functions/CHARMEDfun/Protocol.txt, however, the temp directory doesn't copy this file, which qMRLab expects to find in this location (e.g. /private/tmp/tpf0cdf7d3_15ab_4d09_bb25_fe430336fada/Models_Functions/CHARMEDfun/Protocol.txt is missing, but it is in ~/neuropoly/github/qMRLab/qMRLab/Models_Functions/CHARMEDfun/Protocol.txt).

Would there be a way to make sure all the files are copied in the temp directory, and not just the MOcov-read files?

Combining/merging multiple MOcov json reports?

I'm wondering if this is a feature/function that would be "easy" to implement. I'm not too familiar with what's under the hood of MOcov yet, so I'm not sure if it would be easy to reuse some of your functions to help with this.

The reason I need this is because TRAVIS tests are limited to 30 minutes per job, which means that our project needs to split our MOxUnit tests calls in TRAVIS into multiple jobs.

e.g.


jobs:
  include:
    - stage: Test 
      script: travis_wait 30 octave --no-gui --eval "bootstrapTest;cd('/home/travis/build/neuropoly/qMRLab/Test/MoxUnitCompatible/quickMoxTests');res=moxunit_runtests('-recursive');exit(~res);"
    - stage: Test
      script: travis_wait 30 octave --no-gui --eval "bootstrapTest;cd('/home/travis/build/neuropoly/qMRLab/Test/MoxUnitCompatible');res=moxunit_runtests('BatchExample_test.m');exit(~res);"
    # Paste Sim_test commands below 
    # Pay attention to the indentation! Make them look like -stage and script lines above.
    - stage: Test
      script: travis_wait 30 octave --no-gui --eval "bootstrapTest;cd('/home/travis/build/neuropoly/qMRLab/Test/MoxUnitCompatible');res=moxunit_runtests('SimTest_charmed.m');exit(~res);"
    - stage: Test
      script: travis_wait 30 octave --no-gui --eval "bootstrapTest;cd('/home/travis/build/neuropoly/qMRLab/Test/MoxUnitCompatible');res=moxunit_runtests('SimTest_dti.m');exit(~res);"
    - stage: Test
      script: travis_wait 30 octave --no-gui --eval "bootstrapTest;cd('/home/travis/build/neuropoly/qMRLab/Test/MoxUnitCompatible');res=moxunit_runtests('SimTest_noddi.m');exit(~res);"
    - stage: Test
      script: travis_wait 30 octave --no-gui --eval "bootstrapTest;cd('/home/travis/build/neuropoly/qMRLab/Test/MoxUnitCompatible');res=moxunit_runtests('SimTest_qmt_bssfp.m');exit(~res);"
    - stage: Test
      script: travis_wait 30 octave --no-gui --eval "bootstrapTest;cd('/home/travis/build/neuropoly/qMRLab/Test/MoxUnitCompatible');res=moxunit_runtests('SimTest_qmt_sirfse.m');exit(~res);"
    - stage: Test
      script: travis_wait 30 octave --no-gui --eval "bootstrapTest;cd('/home/travis/build/neuropoly/qMRLab/Test/MoxUnitCompatible');res=moxunit_runtests('SimTest_qmt_spgr.m');exit(~res);"
    - stage: Test
      script: travis_wait 30 octave --no-gui --eval "bootstrapTest;cd('/home/travis/build/neuropoly/qMRLab/Test/MoxUnitCompatible');res=moxunit_runtests('SimTest_inversion_recovery.m');exit(~res);"
    - stage: Test
      script: travis_wait 30 octave --no-gui --eval "bootstrapTest;cd('/home/travis/build/neuropoly/qMRLab/Test/MoxUnitCompatible');res=moxunit_runtests('SimTest_vfa_t1.m');exit(~res);"
    - stage: Test
      script: travis_wait 30 octave --no-gui --eval "bootstrapTest;cd('/home/travis/build/neuropoly/qMRLab/Test/MoxUnitCompatible');res=moxunit_runtests('SimTest_mwf.m');exit(~res);"

This means that we need to do multiple calls to MOcov, which will generate multiple coverage.json files.

This would be a really useful feature, which other coverage software have (e.g. Python's coverage package has a coverage combine option: http://coverage.readthedocs.io/en/latest/cmd.html#combining-data-files)

Add option to exclude individual files

I would like to test the coverage over a (recursive) folder, but exclude individual files within the folder(s).

This would be a useful feature generally if you have .m files which don't need to be in the coverage report but which should be in the folder with the rest of the package contents.

However, in my use-case I specifically want to exclude a file which is used to determine the path to the package (for the purpose of loading resource files within the package). This file needs to be excluded because the path will be incorrect if it is moved to a temporary directory for coverage calculation purposes.

Error when using MOcov with test subject coded as a class

On Ubuntu Trusty (32 bits - i686-pc-linux-gnu) with GNU Octave 4.0.2, running tests for subjects that use the "new" class definition syntax results in the following error:

failure: parse error near line 1 of file /tmp/oct-QJBT47/AClass.m

  syntax error

>>> mocov_line_covered(1,'AClass.m',1,1);classdef AClass < handle
                                                ^

  test_AClass>test_one:6 (/home/vagrant/drafts/dummy-mocov-example-for-issue/tests/test_AClass.m)

--------------------------------------------------

FAILED (failure=1)
ans = 0

Is there any place where the supported syntax is described?

The minimal code in the repository https://github.com/abravalheri/dummy-mocov-example-for-issue/ can be used to reproduce the error.

Note that when MOcov is disabled the test suite runs normally.

suite: 1 tests
hello world!.
--------------------------------------------------

OK
ans =  1

Thank you in advance! (Also thanks for working in a such unique and necessary project)

Multiline function declaration turns into Matlab warning

function [AlotOfParameters] = ...      
 function_name_thats_really_long(EvenMoreParameters)

is turned into:

mocov_line_covered(87,'function_name_thats_really_long.m',1,1);function [AlotOfParameters] = ...      
 function_name_thats_really_long(EvenMoreParameters)

this results in the following warning:

Local function name must be different from the script name.
The identifier was:
MATLAB:LocalFunctionNameSameAsFileName 

My best guess is that the ... causes some misbehaviour in the preparation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.