-
Notifications
You must be signed in to change notification settings - Fork 1
/
DMFileGrouping.m
60 lines (51 loc) · 2.17 KB
/
DMFileGrouping.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
classdef DMFileGrouping < CoreBaseClass
% DMFileGrouping. Stores a set of Dicom metadata structures, corresponding
% to a coherent sequence of images
%
% DMFileGrouping objects are created by the DMFileGrouper class,
% which separates and groups images into coherent sequences according to
% their metadata.
%
%
% Licence
% -------
% Part of DicoMat. https://github.com/tomdoel/dicomat
% Author: Tom Doel, 2013. www.tomdoel.com
% Distributed under the BSD 3-Clause license. Please see the file LICENSE for details.
%
properties (SetAccess = private)
Metadata
end
methods
function obj = DMFileGrouping(metadata)
if ~isempty(metadata)
obj.Metadata{1} = metadata;
end
end
function AddFile(obj, metadata)
obj.Metadata{end + 1} = metadata;
end
% Determine if a file with specified metadata should be grouped with
% these files
function match = Matches(obj, other_metadata)
if numel(obj.Metadata) > 1
additional_image = obj.Metadata{2};
else
additional_image = [];
end
match = DMAreImagesInSameGroup(obj.Metadata{1}, other_metadata, additional_image);
end
% Sorts the images according to slice location, and computes values for
% slice thickness and global origin
function [slice_thickness, global_origin_mm, sorted_positions] = SortAndGetParameters(obj, reporting)
[sorted_indices, slice_thickness, global_origin_mm, sorted_positions] = DMSortImagesByLocation(obj, reporting);
if numel(obj.Metadata) > 1
if isempty(sorted_indices)
reporting.ShowWarning('DMFileGrouping:UnableToSortFiles', 'The images in this series may appear in the wrong order because I was unable to determine the correct ordering');
else
obj.Metadata = obj.Metadata(sorted_indices);
end
end
end
end
end