From 587e451aacab3b21aef909fa90730ff27128ce89 Mon Sep 17 00:00:00 2001 From: Daniil Kazantsev Date: Fri, 27 Apr 2018 11:57:37 +0100 Subject: [PATCH] OS independent paths fixed --- matlab/Model2DGeneratorDemo.m | 7 +++++-- matlab/Model2D_tGeneratorDemo.m | 13 +++++++++---- matlab/Model3DGeneratorDemo.m | 7 +++++-- matlab/Model3D_tGeneratorDemo.m | 10 +++++++--- matlab/Object2DGeneratorDemo.m | 4 +++- matlab/Object3DGeneratorDemo.m | 5 ++++- matlab/SpectralPhantomDemo.m | 8 ++++++-- matlab/install/compile_mex.m | 31 +++++++++++++++++++------------ 8 files changed, 58 insertions(+), 27 deletions(-) diff --git a/matlab/Model2DGeneratorDemo.m b/matlab/Model2DGeneratorDemo.m index 50d0e48..818213b 100644 --- a/matlab/Model2DGeneratorDemo.m +++ b/matlab/Model2DGeneratorDemo.m @@ -9,7 +9,9 @@ close all;clc;clear; % adding paths -addpath('../functions/models/'); addpath('compiled/'); addpath('supplem/'); +pathtoModels = sprintf(['..' filesep 'functions' filesep 'models' filesep], 1i); +addpath(pathtoModels); +addpath('compiled'); addpath('supplem'); ModelNo = 4; % Select a model from Phantom2DLibrary.dat % Define phantom dimensions @@ -18,7 +20,8 @@ % Generate 2D phantom: curDir = pwd; mainDir = fileparts(curDir); -pathTP = strcat(mainDir,'/functions/models/Phantom2DLibrary.dat'); % path to TomoPhantom parameters file +pathtoLibrary = sprintf([filesep 'functions' filesep 'models' filesep 'Phantom2DLibrary.dat'], 1i); +pathTP = strcat(mainDir, pathtoLibrary); % path to TomoPhantom parameters file [G] = TomoP2DModel(ModelNo,N,pathTP); figure; imagesc(G, [0 1]); daspect([1 1 1]); colormap hot; %% diff --git a/matlab/Model2D_tGeneratorDemo.m b/matlab/Model2D_tGeneratorDemo.m index 1a0f6be..16062b5 100644 --- a/matlab/Model2D_tGeneratorDemo.m +++ b/matlab/Model2D_tGeneratorDemo.m @@ -9,7 +9,9 @@ close all;clc;clear; % adding paths -addpath('../functions/models/'); addpath('compiled/'); addpath('supplem/'); +pathtoModels = sprintf(['..' filesep 'functions' filesep 'models' filesep], 1i); +addpath(pathtoModels); +addpath('compiled'); addpath('supplem'); ModelNo = 100; % Select a model from Phantom2DLibrary.dat % Define phantom dimensions @@ -18,7 +20,8 @@ % Generate 2D+t phantom: curDir = pwd; mainDir = fileparts(curDir); -pathTP = strcat(mainDir,'/functions/models/Phantom2DLibrary.dat'); % path to TomoPhantom parameters file +pathtoLibrary = sprintf([filesep 'functions' filesep 'models' filesep 'Phantom2DLibrary.dat'], 1i); +pathTP = strcat(mainDir, pathtoLibrary); % path to TomoPhantom parameters file [G] = TomoP2DModel(ModelNo,N,pathTP); figure(1); imagesc(G, [0 1]); daspect([1 1 1]); title('2D+t model, t=3 here'); colormap hot; %% @@ -30,7 +33,8 @@ % Generate 2D phantom: curDir = pwd; mainDir = fileparts(curDir); -pathTP = strcat(mainDir,'/functions/models/Phantom2DLibrary.dat'); % path to TomoPhantom parameters file +pathtoLibrary = sprintf([filesep 'functions' filesep 'models' filesep 'Phantom2DLibrary.dat'], 1i); +pathTP = strcat(mainDir, pathtoLibrary); % path to TomoPhantom parameters file [G] = TomoP2DModel(ModelNo,N,pathTP); angles = linspace(0,180,N); % projection angles @@ -53,7 +57,8 @@ timeFrames = 25; %must be the same as in model curDir = pwd; mainDir = fileparts(curDir); -pathTP = strcat(mainDir,'/functions/models/Phantom2DLibrary.dat'); % path to TomoPhantom parameters file +pathtoLibrary = sprintf([filesep 'functions' filesep 'models' filesep 'Phantom2DLibrary.dat'], 1i); +pathTP = strcat(mainDir, pathtoLibrary); % path to TomoPhantom parameters file [G] = TomoP2DModel(ModelNo,N,pathTP); angles = linspace(0,180,N); % projection angles diff --git a/matlab/Model3DGeneratorDemo.m b/matlab/Model3DGeneratorDemo.m index 6597e08..1fb2288 100644 --- a/matlab/Model3DGeneratorDemo.m +++ b/matlab/Model3DGeneratorDemo.m @@ -7,7 +7,9 @@ close all;clc;clear; % adding paths -addpath('../functions/models/'); addpath('compiled/'); addpath('supplem/'); +pathtoModels = sprintf(['..' filesep 'functions' filesep 'models' filesep], 1i); +addpath(pathtoModels); +addpath('compiled'); addpath('supplem'); ModelNo = 10; % Select a model % Define phantom dimensions @@ -16,7 +18,8 @@ % generate 3D phantom (modify your PATH bellow): curDir = pwd; mainDir = fileparts(curDir); -pathTP = strcat(mainDir,'/functions/models/Phantom3DLibrary.dat'); % path to TomoPhantom parameters file +pathtoLibrary = sprintf([filesep 'functions' filesep 'models' filesep 'Phantom3DLibrary.dat'], 1i); +pathTP = strcat(mainDir, pathtoLibrary); % path to TomoPhantom parameters file [G] = TomoP3DModel(ModelNo,N,pathTP); % check 3 projections diff --git a/matlab/Model3D_tGeneratorDemo.m b/matlab/Model3D_tGeneratorDemo.m index ccf7379..f5666c5 100644 --- a/matlab/Model3D_tGeneratorDemo.m +++ b/matlab/Model3D_tGeneratorDemo.m @@ -7,7 +7,9 @@ close all;clc;clear; % adding paths -addpath('../functions/models/'); addpath('compiled/'); addpath('supplem/'); +pathtoModels = sprintf(['..' filesep 'functions' filesep 'models' filesep], 1i); +addpath(pathtoModels); +addpath('compiled'); addpath('supplem'); ModelNo = 100; % Select a model % Define phantom dimensions @@ -16,7 +18,8 @@ % generate 4D phantom (modify your PATH bellow): curDir = pwd; mainDir = fileparts(curDir); -pathTP = strcat(mainDir,'/functions/models/Phantom3DLibrary.dat'); % path to TomoPhantom parameters file +pathtoLibrary = sprintf([filesep 'functions' filesep 'models' filesep 'Phantom3DLibrary.dat'], 1i); +pathTP = strcat(mainDir, pathtoLibrary); % path to TomoPhantom parameters file [G] = TomoP3DModel(ModelNo,N,pathTP); sliceM = round(0.5*N); @@ -34,7 +37,8 @@ % generate 4D phantom (modify your PATH bellow): curDir = pwd; mainDir = fileparts(curDir); -pathTP = strcat(mainDir,'/functions/models/Phantom3DLibrary.dat'); % path to TomoPhantom parameters file +pathtoLibrary = sprintf([filesep 'functions' filesep 'models' filesep 'Phantom3DLibrary.dat'], 1i); +pathTP = strcat(mainDir, pathtoLibrary); % path to TomoPhantom parameters file [G] = TomoP3DModel(ModelNo,N,pathTP); %% diff --git a/matlab/Object2DGeneratorDemo.m b/matlab/Object2DGeneratorDemo.m index c2a3da6..093425f 100644 --- a/matlab/Object2DGeneratorDemo.m +++ b/matlab/Object2DGeneratorDemo.m @@ -6,7 +6,9 @@ close all;clc;clear; % adding paths -addpath('../functions/models/'); addpath('compiled/'); addpath('supplem/'); +pathtoModels = sprintf(['..' filesep 'functions' filesep 'models' filesep], 1i); +addpath(pathtoModels); +addpath('compiled'); addpath('supplem'); % Define object dimensions N = 256; % x-y-z size (cubic image) diff --git a/matlab/Object3DGeneratorDemo.m b/matlab/Object3DGeneratorDemo.m index 2951436..a85a3e6 100644 --- a/matlab/Object3DGeneratorDemo.m +++ b/matlab/Object3DGeneratorDemo.m @@ -6,7 +6,10 @@ close all;clc;clear; % adding paths -addpath('../functions/models/'); addpath('compiled/'); addpath('supplem/'); +pathtoModels = sprintf(['..' filesep 'functions' filesep 'models' filesep], 1i); +addpath(pathtoModels); +addpath('compiled'); addpath('supplem'); + % Define phantom dimensions N = 256; % x-y-z size (cubic image) diff --git a/matlab/SpectralPhantomDemo.m b/matlab/SpectralPhantomDemo.m index f27e0dc..2eaa0ff 100644 --- a/matlab/SpectralPhantomDemo.m +++ b/matlab/SpectralPhantomDemo.m @@ -9,7 +9,10 @@ close all;clc;clear; % adding paths -addpath('../functions/models/'); addpath('compiled/'); +pathtoModels = sprintf(['..' filesep 'functions' filesep 'models' filesep], 1i); +addpath(pathtoModels); +addpath('compiled'); addpath('supplem'); + ModelNo = 11; % Define phantom dimension @@ -18,7 +21,8 @@ % generate the 2D phantom: curDir = pwd; mainDir = fileparts(curDir); -pathTP = strcat(mainDir,'/functions/models/Phantom2DLibrary.dat'); % path to TomoPhantom parameters file +pathtoLibrary = sprintf([filesep 'functions' filesep 'models' filesep 'Phantom2DLibrary.dat'], 1i); +pathTP = strcat(mainDir, pathtoLibrary); % path to TomoPhantom parameters file [G] = TomoP2DModel(ModelNo,N,pathTP); % create 4 phantoms with dedicated materials diff --git a/matlab/install/compile_mex.m b/matlab/install/compile_mex.m index e8bfa06..0c1dbbc 100755 --- a/matlab/install/compile_mex.m +++ b/matlab/install/compile_mex.m @@ -1,25 +1,32 @@ % compile mex files once from Matlab running this script -cd ../ +fsep = filesep; +UpPath = sprintf(['..' fsep], 1i); +cd(UpPath); + mkdir compiled -cd ../functions/ + +PathFunc = sprintf(['..' fsep 'functions' fsep], 1i); +cd(PathFunc); + +Pathmove = sprintf(['..' fsep 'matlab' fsep 'compiled' fsep], 1i); fprintf('%s \n', 'Building functions...'); mex TomoP2DModel.c TomoP2DModel_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile TomoP2DModel.mex* ../matlab/compiled/ +movefile('TomoP2DModel.mex*',Pathmove); mex TomoP2DObject.c TomoP2DModel_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile TomoP2DObject.mex* ../matlab/compiled/ +movefile('TomoP2DObject.mex*',Pathmove); mex TomoP2DModelSino.c TomoP2DModelSino_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile TomoP2DModelSino.mex* ../matlab/compiled/ +movefile('TomoP2DModelSino.mex*',Pathmove); mex TomoP2DObjectSino.c TomoP2DModelSino_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile TomoP2DObjectSino.mex* ../matlab/compiled/ +movefile('TomoP2DObjectSino.mex*',Pathmove); mex TomoP3DModel.c TomoP3DModel_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile TomoP3DModel.mex* ../matlab/compiled/ +movefile('TomoP3DModel.mex*',Pathmove); mex TomoP3DObject.c TomoP3DModel_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile TomoP3DObject.mex* ../matlab/compiled/ -mex BackProjCPU.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile BackProjCPU.mex* ../matlab/compiled/ +movefile('TomoP3DObject.mex*',Pathmove); +% mex BackProjCPU.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" +% movefile BackProjCPU.mex* ../matlab/compiled/ fprintf('%s \n', 'All compiled!'); -cd ../ -cd matlab +cd(UpPath); +cd matlab \ No newline at end of file