-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_test.m
75 lines (52 loc) · 2.5 KB
/
run_test.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
clear all
close all
dicomDir = './testdata/brachyseeds/';
seriesDescription = 'mFFE';
echoNumber = 2;
% dicomDir = './testdata/goldfiducials/';
% seriesDescription = 't mFFE 3D Seeds';
% echoNumber = 2;
% dicomDir = '../testdata/cylinder/';
% seriesDescription = 'FFE 1mm 0 deg wfs1';
% echoNumber = 2;
% This test simulates an image with the letters AP/RL/FH on the
% corresponding axes in the image. This tests whether all coordinate
% conversions are working as intended.
%% Add necessary paths
addpath('./simulation')
addpath('./localization')
addpath('./redist/dicomseries-matlab/dicomseries')
addpath('./redist/forecast')
addpath('./redist/forecast/utils')
%% Set library creation parameters
modelParameters.objectFunction = @testObjectFunction;
modelParameters.objectOrientations = [1 0 0]; % TODO: Does not include roll
modelParameters.modelSize = []; % voxels, scanner AP RL FH, keep empty to use scan size times modelMultiplier
modelParameters.modelMultiplier = 1;
modelParameters.modelFOV = []; % mm, scanner AP RL FH, keep empty to use scan FOV
% Simulate only center of scan region
% Set to region size (in voxels) in MPS (Measurement, Phase, Slice),
% or set to a single scalar n if the region is cubic (equal to [n n n]).
% Set to false to disable.
modelParameters.smallFOVsize = []; % voxels, MPS
% Post processing functions after simulation
options.postProcessImage = @(x) conj(x); % Convert from left-handed to right-handed spin
%% Load complex image from dicoms
dicomdict('set', 'dicom-dict-philips.txt');
fprintf('Scanning dicom directory...\n');
partitions = readDicomSeries(dicomDir, struct('verbose', true, 'recursive', true));
fprintf('Reading images...\n');
[dicomImage, dicomInfo] = readDicomSeriesImage(dicomDir, partitions, struct('SeriesDescription', seriesDescription, 'ImageType', 'ORIGINAL\PRIMARY\M_FFE\M\FFE', 'EchoNumber', echoNumber));
dicomImage = rescaleDicomImage(dicomImage, dicomInfo);
%% Create "library"
imageParameters = getImageParametersFromDicomPhilips(dicomInfo);
library = createLibrary(modelParameters, imageParameters, options);
%% Show an overlay of the simulated image with AP/RL/FH to check if this is consistent with the acquired image.
tmp = zeroPad(library.templates(1).image, size(dicomImage));
tmp = abs(tmp) / max(abs(tmp(:)));
im = dicomImage;
im = abs(im) / max(abs(im(:)));
im = im + tmp;
figure, imshow(im(:,:,round(size(dicomImage,3)/2)), [])
figure, imshow(squeeze(im(:,round(size(dicomImage,2)/2),:)), [])
figure, imshow(squeeze(im(round(size(dicomImage,1)/2),:,:)), [])