-
Notifications
You must be signed in to change notification settings - Fork 2
/
loadmc.m
47 lines (40 loc) · 1.38 KB
/
loadmc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function [T VOL H SIMname] = loadmc(SIMname,myfolder)
% loads mc.mci, mc_T.bin, mc_VOL.bin --> T,VOL,H
% presumes they exist.
% load mc.mci
PRINTON = 0;
[H SIMname] = reportHmci(SIMname,PRINTON,myfolder);
Nx = H(2);
Ny = H(3);
Nz = H(4);
% Load tissue structure in voxels, T(y,x,z)
% filename = sprintf('mcLibrary/%s_T.bin',SIMname);
% filename = fullfile(pwd,'mcLibrary',sprintf('%s_T.bin','mc')); % YL: tentatively only for mc_T.bin
filename = fullfile(myfolder,sprintf('%s_T.bin','mc')); % YL: tentatively only for mc_T.bin
disp(['loading ' filename])
tic
fid = fopen(filename, 'rb');
[Data count] = fread(fid, Ny*Nx*Nz, 'uint8');
fclose(fid);
toc
T = reshape(Data,Ny,Nx,Nz); % T(y,x,z)
clear Data
% flagV = (exist('mcLibrary/mc_VOL.bin')>0);
flagV = (exist('mc_VOL.bin')>0);
if flagV
% Load tissue structure in voxels, VOL(y,x,z)
% filename = sprintf('mcLibrary/%s_VOL.bin',SIMname);
% filename = fullfile(pwd,'mcLibrary',sprintf('%s_VOL.bin','mc'));% YL: tentatively only for mc_T.bin
filename = fullfile(myfolder, sprintf('%s_VOL.bin','mc'));% YL: tentatively only for mc_T.bin
disp(['loading ' filename])
tic
fid = fopen(filename, 'rb');
[Data count] = fread(fid, Ny*Nx*Nz, 'uint16');
fclose(fid);
toc
VOL = reshape(Data,Ny,Nx,Nz); % VOL(y,x,z)
clear Data
else
fprintf('No VOL. Let VOL = T.\n')
VOL = double(T);
end