Skip to content

Commit 5ce2913

Browse files
committed
[format] reformat demo scripts
1 parent af30773 commit 5ce2913

2 files changed

Lines changed: 102 additions & 102 deletions

File tree

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
1-
clear cfg
1+
clear cfg;
22

3-
disp('== mesh generation (iso2mesh) ...')
4-
%# Create a box-like homogeneous domain
5-
boxsize = [60, 50, 40]; %# domain size
6-
trisize = 4; %# max triangule size on the surface
7-
maxvol = 4; %# max tet element volume
3+
disp('== mesh generation (iso2mesh) ...');
4+
%#Create a box-like homogeneous domain
5+
boxsize = [60, 50, 40]; %#domain size
6+
trisize = 4; %#max triangule size on the surface
7+
maxvol = 4; %#max tet element volume
88

9-
tic
10-
[nbox1, fbox1] = meshabox([0,0,0], boxsize, trisize); %# create a big box
11-
[nbox2, fbox2] = meshabox([10,10,10], [30,30,30], trisize); %# create a box inclusion
12-
[nbox1, fbox1] = removeisolatednode(nbox1, fbox1(:,1:3)); %# clean the surface
13-
[nbox2, fbox2] = removeisolatednode(nbox2, fbox2(:,1:3));
9+
tic;
10+
[nbox1, fbox1] = meshabox([0, 0, 0], boxsize, trisize); %#create a big box
11+
[nbox2, fbox2] = meshabox([10, 10, 10], [30, 30, 30], trisize); %#create a box inclusion
12+
[nbox1, fbox1] = removeisolatednode(nbox1, fbox1(:, 1:3)); %#clean the surface
13+
[nbox2, fbox2] = removeisolatednode(nbox2, fbox2(:, 1:3));
1414

15-
[no1, fc1] = mergemesh(nbox1, fbox1, nbox2, fbox2); %# combine the two non-intersecting surfaces
16-
regionseed = [1, 1, 1 %# a seed point inside region 1 (large box)
17-
11,11,11]; %# a seed point inside region 2 (small box)
18-
[cfg.node, cfg.elem] = s2m(no1,fc1,1,maxvol, 'tetgen', regionseed); %# generate tetrahedral mesh - outer box: label 1, inner box: label 2
15+
[no1, fc1] = mergemesh(nbox1, fbox1, nbox2, fbox2); %#combine the two non-intersecting surfaces
16+
regionseed = [1, 1, 1 %#a seed point inside region 1 (large box)
17+
11, 11, 11]; %#a seed point inside region 2 (small box)
18+
[cfg.node, cfg.elem] = s2m(no1, fc1, 1, maxvol, 'tetgen', regionseed); %#generate tetrahedral mesh - outer box: label 1, inner box: label 2
1919

20-
cfg.seg = cfg.elem(:,5); %# cfg.seg is similar to cfg.elemprop in mmclab, but also supports node-based labels
21-
cfg.elem(:,5)=[];
22-
toc
20+
cfg.seg = cfg.elem(:, 5); %#cfg.seg is similar to cfg.elemprop in mmclab, but also supports node-based labels
21+
cfg.elem(:, 5) = [];
22+
toc;
2323

24-
plotmesh(cfg.node, [cfg.elem, cfg.seg], 'y>20')
24+
plotmesh(cfg.node, [cfg.elem, cfg.seg], 'y>20');
2525

26-
disp('== define settings in cfg ...')
26+
disp('== define settings in cfg ...');
2727

28-
%# Creating forward simulation data structure cfg
29-
%# properties:[mua(1/mm),mus(1/mm),g, n] % if both mus/g are given, mus'=mus/(1-g) will be used for diffusion, usually set g to 0
30-
cfg.prop = [0, 0, 1, 1 %# cfg.prop is the same as mcx/mmc, row-1 is for label 0, row-2 for label 1 etc
31-
0.006, 0.8, 0, 1.37 %# label 1 (background domain)
32-
0.02, 1, 0, 1.37]; %# label 2 (inclusion)
28+
%#Creating forward simulation data structure cfg
29+
%#properties:[mua(1/mm),mus(1/mm),g, n] % if both mus/g are given, mus'=mus/(1-g) will be used for diffusion, usually set g to 0
30+
cfg.prop = [0, 0, 1, 1 %#cfg.prop is the same as mcx/mmc, row-1 is for label 0, row-2 for label 1 etc
31+
0.006, 0.8, 0, 1.37 %#label 1 (background domain)
32+
0.02, 1, 0, 1.37]; %#label 2 (inclusion)
3333

34-
%# Default redbird source is a pencil beam, same as mcx/mmc
35-
cfg.srcpos = [25, 25, 0]; %# redbird srcpos can have multiple rows
36-
cfg.srcdir = [0, 0, 1]; %# srcdir determines how sources are sunken into the mesh
34+
%#Default redbird source is a pencil beam, same as mcx/mmc
35+
cfg.srcpos = [25, 25, 0]; %#redbird srcpos can have multiple rows
36+
cfg.srcdir = [0, 0, 1]; %#srcdir determines how sources are sunken into the mesh
3737

38-
%# Redbird detector positions are point-like, directly sampling the output fluence; it is different from the disk-like shape in mcx/mmc
39-
cfg.detpos = [35, 25, max(cfg.node(:,3))]; %# redbird detpos can have multiple rows
40-
cfg.detdir = [0, 0, -1]; %# redbird automatically computes the adjoint solutions, treating detectors as sources
38+
%#Redbird detector positions are point-like, directly sampling the output fluence; it is different from the disk-like shape in mcx/mmc
39+
cfg.detpos = [35, 25, max(cfg.node(:, 3))]; %#redbird detpos can have multiple rows
40+
cfg.detdir = [0, 0, -1]; %#redbird automatically computes the adjoint solutions, treating detectors as sources
4141

42-
%# redbird cfg does not need cfg.{nphoton,tstart,tend,tstep,elemprop}, which are required in mmclab
42+
%#redbird cfg does not need cfg.{nphoton,tstart,tend,tstep,elemprop}, which are required in mmclab
4343

44-
disp('== preprocessing domain ...')
45-
%# calling rbmeshprep() populates other needed mesh data, such as cfg.{evol,nvol,face,area,reff,deldotdel,cols,idxsum}
46-
%# this is similar to `cfg = mmclab(cfg, 'prep')`
44+
disp('== preprocessing domain ...');
45+
%#calling rbmeshprep() populates other needed mesh data, such as cfg.{evol,nvol,face,area,reff,deldotdel,cols,idxsum}
46+
%#this is similar to `cfg = mmclab(cfg, 'prep')`
4747

48-
tic
48+
tic;
4949
cfg = rbmeshprep(cfg);
50-
toc
50+
toc;
5151

52-
disp('== run simulation ...')
53-
%# Run forward simulation (you can also call rbrun())
54-
tic
52+
disp('== run simulation ...');
53+
%#Run forward simulation (you can also call rbrun())
54+
tic;
5555
[detphi, phi] = rbrunforward(cfg);
56-
toc
56+
toc;
5757

58-
%# rbrunforward returned two outputs:
59-
%# detphi - the sampled measurements (fluence, not diffuse reflectance!) at all src/det pairs
60-
%# phi - the fluence at all nodes for all sources and detectors (column-dimension)
58+
%#rbrunforward returned two outputs:
59+
%#detphi - the sampled measurements (fluence, not diffuse reflectance!) at all src/det pairs
60+
%#phi - the fluence at all nodes for all sources and detectors (column-dimension)
6161

62-
disp('== plot results ...')
62+
disp('== plot results ...');
6363
figure;
64-
colormap('jet')
65-
plotmesh([cfg.node log10(phi(:,1))], cfg.elem, 'y > 25') %# first column is from the src
66-
%shading interp
67-
title('forward solution from source')
68-
69-
figure
70-
colormap('jet')
71-
plotmesh([cfg.node log10(phi(:,2))], cfg.elem, 'y > 25') %# 2nd column is from the detector
72-
%shading interp
73-
title('forward solution from detector')
64+
colormap('jet');
65+
plotmesh([cfg.node log10(phi(:, 1))], cfg.elem, 'y > 25'); %#first column is from the src
66+
% shading interp
67+
title('forward solution from source');
68+
69+
figure;
70+
colormap('jet');
71+
plotmesh([cfg.node log10(phi(:, 2))], cfg.elem, 'y > 25'); % # 2nd column is from the detector
72+
% shading interp
73+
title('forward solution from detector');
Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
1-
clear cfg
1+
clear cfg;
22

3-
disp('== mesh generation (iso2mesh) ...')
4-
%# Create a 3 layer domain
5-
maxvol = 4; %# max tet element volume
3+
disp('== mesh generation (iso2mesh) ...');
4+
%#Create a 3 layer domain
5+
maxvol = 4; %#max tet element volume
66

7-
tic
8-
[no1, fc1, regionseeds] = latticegrid([0,60], [0, 50], [0, 5, 10, 30]);%# create a 3-layer z-lattice
9-
[cfg.node, cfg.elem] = s2m(no1,fc1,1,maxvol, 'tetgen', regionseeds); %# generate tetrahedral mesh, label increases in z-axis
7+
tic;
8+
[no1, fc1, regionseeds] = latticegrid([0, 60], [0, 50], [0, 5, 10, 30]); %#create a 3-layer z-lattice
9+
[cfg.node, cfg.elem] = s2m(no1, fc1, 1, maxvol, 'tetgen', regionseeds); %#generate tetrahedral mesh, label increases in z-axis
1010

11-
cfg.seg = cfg.elem(:,5); %# cfg.seg is similar to cfg.elemprop in mmclab, but also supports node-based labels
12-
cfg.elem(:,5)=[];
13-
toc
11+
cfg.seg = cfg.elem(:, 5); %#cfg.seg is similar to cfg.elemprop in mmclab, but also supports node-based labels
12+
cfg.elem(:, 5) = [];
13+
toc;
1414

15-
plotmesh(cfg.node, [cfg.elem, cfg.seg], 'y>20')
15+
plotmesh(cfg.node, [cfg.elem, cfg.seg], 'y>20');
1616

17-
disp('== define settings in cfg ...')
17+
disp('== define settings in cfg ...');
1818

19-
%# Creating forward simulation data structure cfg
20-
%# properties:[mua(1/mm),mus(1/mm),g, n] % if both mus/g are given, mus'=mus/(1-g) will be used for diffusion, usually set g to 0
21-
cfg.prop = [0, 0, 1, 1 %# cfg.prop is the same as mcx/mmc, row-1 is for label 0, row-2 for label 1 etc
22-
0.006, 0.8, 0, 1.37 %# label 1 (0 < z < 5)
23-
0.02, 0.4, 0, 1.37 %# label 2 (5 < z < 10)
24-
0.002, 1, 0, 1.37]; %# label 2 (10 < z < 30)
19+
%#Creating forward simulation data structure cfg
20+
%#properties:[mua(1/mm),mus(1/mm),g, n] % if both mus/g are given, mus'=mus/(1-g) will be used for diffusion, usually set g to 0
21+
cfg.prop = [0, 0, 1, 1 %#cfg.prop is the same as mcx/mmc, row-1 is for label 0, row-2 for label 1 etc
22+
0.006, 0.8, 0, 1.37 %#label 1 (0 < z < 5)
23+
0.02, 0.4, 0, 1.37 %#label 2 (5 < z < 10)
24+
0.002, 1, 0, 1.37]; %#label 2 (10 < z < 30)
2525

26-
%# Default redbird source is a pencil beam, same as mcx/mmc
26+
%#Default redbird source is a pencil beam, same as mcx/mmc
2727
[xi, yi] = meshgrid(5:5:50, 5:5:40);
28-
cfg.srcpos = [xi(:), yi(:), ones(length(xi(:)), 1)]; %# redbird srcpos can have multiple rows
29-
cfg.srcdir = [0, 0, 1]; %# srcdir determines how sources are sunken into the mesh
28+
cfg.srcpos = [xi(:), yi(:), ones(length(xi(:)), 1)]; %#redbird srcpos can have multiple rows
29+
cfg.srcdir = [0, 0, 1]; %#srcdir determines how sources are sunken into the mesh
3030

31-
%# Redbird detector positions are point-like, directly sampling the output fluence; it is different from the disk-like shape in mcx/mmc
31+
%#Redbird detector positions are point-like, directly sampling the output fluence; it is different from the disk-like shape in mcx/mmc
3232
[xi, yi] = meshgrid(7.5:5:50, 7.5:5:40);
33-
cfg.detpos = [xi(:), yi(:), ones(length(xi(:)), 1)]; %# redbird detpos can have multiple rows
34-
cfg.detdir = [0, 0, 1]; %# redbird automatically computes the adjoint solutions, treating detectors as sources
33+
cfg.detpos = [xi(:), yi(:), ones(length(xi(:)), 1)]; %#redbird detpos can have multiple rows
34+
cfg.detdir = [0, 0, 1]; %#redbird automatically computes the adjoint solutions, treating detectors as sources
3535

36-
%# redbird cfg does not need cfg.{nphoton,tstart,tend,tstep,elemprop}, which are required in mmclab
36+
%#redbird cfg does not need cfg.{nphoton,tstart,tend,tstep,elemprop}, which are required in mmclab
3737

38-
disp('== preprocessing domain ...')
39-
%# calling rbmeshprep() populates other needed mesh data, such as cfg.{evol,nvol,face,area,reff,deldotdel,cols,idxsum}
40-
%# this is similar to `cfg = mmclab(cfg, 'prep')`
38+
disp('== preprocessing domain ...');
39+
%#calling rbmeshprep() populates other needed mesh data, such as cfg.{evol,nvol,face,area,reff,deldotdel,cols,idxsum}
40+
%#this is similar to `cfg = mmclab(cfg, 'prep')`
4141

42-
tic
42+
tic;
4343
cfg = rbmeshprep(cfg);
44-
toc
44+
toc;
4545

46-
disp('== run simulation ...')
47-
%# Run forward simulation (you can also call rbrun())
48-
tic
46+
disp('== run simulation ...');
47+
%#Run forward simulation (you can also call rbrun())
48+
tic;
4949
[detphi, phi] = rbrunforward(cfg);
50-
toc
50+
toc;
5151

52-
%# rbrunforward returned two outputs:
53-
%# detphi - the sampled measurements (fluence, not diffuse reflectance!) at all src/det pairs
54-
%# phi - the fluence at all nodes for all sources and detectors (column-dimension)
52+
%#rbrunforward returned two outputs:
53+
%#detphi - the sampled measurements (fluence, not diffuse reflectance!) at all src/det pairs
54+
%#phi - the fluence at all nodes for all sources and detectors (column-dimension)
5555

56-
disp('== plot results ...')
56+
disp('== plot results ...');
5757
figure;
58-
colormap('jet')
59-
plotmesh([cfg.node log10(abs(phi(:,1)))], cfg.elem, 'y > 25') %# first column is from the src
60-
%shading interp
61-
title('forward solution from source')
58+
colormap('jet');
59+
plotmesh([cfg.node log10(abs(phi(:, 1)))], cfg.elem, 'y > 25'); %#first column is from the src
60+
% shading interp
61+
title('forward solution from source');
6262

63-
figure
64-
colormap('jet')
65-
plotmesh([cfg.node log10(abs(phi(:,2)))], cfg.elem, 'y > 25') %# 2nd column is from the detector
66-
%shading interp
67-
title('forward solution from detector')
63+
figure;
64+
colormap('jet');
65+
plotmesh([cfg.node log10(abs(phi(:, 2)))], cfg.elem, 'y > 25'); % # 2nd column is from the detector
66+
% shading interp
67+
title('forward solution from detector');

0 commit comments

Comments
 (0)