/ concept-collection / seqlab
Sign in
concept-collection / seqlab
seqlab / src / engine / pulseq / +mr / compile_mex.m
56 lines · 2.0 KBCodeBlameHistory
78d04f1seqlab: write and view pulseq MRI sequences in the browserJeremy Magland 1%% Compile mex files from MATLAB source
2% This script is designed to compile frequently used Pulseq functions into
3% mex files for faster execution.
4%
5% The Pulseq toolbox has been designed such that these files are *not*
6% necessary to use the toolbox, but if they are present a substantial
7% performance improvement can be acheived.
8%
9% The script relies on the MATLAB Coder package, available in later
10% versions of MATLAB.
13if isempty(which('codegen'))
14 error('codegen not found for this version of MATLAB. Try 2014b or higher');
15end
16currDir=pwd;
17if ~strcmp(currDir(end-2:end),'+mr')
18 error('Please run from directory: pulseq/matlab/+mr')
19end
21%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22% Create configuration object of class 'coder.MexCodeConfig'.
23%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25cfg = coder.config('mex');
26cfg.GenerateReport = true;
27cfg.SaturateOnIntegerOverflow = false;
28cfg.IntegrityChecks = false;
29cfg.ResponsivenessChecks = false;
30cfg.ExtrinsicCalls = false;
32%%
33%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34% Define argument types for entry-point 'compressShape_mat'.
35%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36ARGS = cell(1,1);
37ARGS{1} = cell(1,1);
38ARGS{1}{1} = coder.typeof(0,[Inf 1],[1 0]);
40codegen -config cfg -o compressShape_mex ./compressShape_mat.m -args ARGS{1}
42%%
43%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44% Define argument types for entry-point 'find_mat'.
45%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46ARGS = cell(1,1);
47ARGS{1} = cell(4,1);
48ARGS{1}{1} = coder.typeof(0,[1 Inf],[0 1]);
49ARGS{1}{2} = struct;
50ARGS{1}{2}.array = coder.typeof(0,[1 Inf],[0 1]);
51ARGS{1}{2} = coder.typeof(ARGS{1}{2},[1 Inf],[0 1]);
52ARGS{1}{3} = coder.typeof(0,[1 Inf],[0 1]);
53ARGS{1}{4} = coder.typeof(0,[1 Inf],[0 1]);
55codegen -config cfg -o ./@EventLibrary/find_mex ./@EventLibrary/find_mat.m -args ARGS{1}
moveopenescclose