-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconcatDatasets.m
46 lines (41 loc) · 1.48 KB
/
concatDatasets.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
% Concatenates two datasets (appending in sample dimension).
%
% Author: Maurice Hollmann
% Date : 08/10
%
% Description:
% This method concats two datasets. It must be ensured that the data is in the same space!
% If one dataset has 10 samples and the second one has 15 samples the resulting dataset has
% 25 samples...
%
% If any dataset provides a mask, it will be used. If both do, the mask of the first one is used.
% The concatenation order will be like order of input.
%
% Parameters:
% dataset1 - the first datset
% dataset2 - the second datset
%
% Returns:
% dataset - the datset that is the concatenation of ds1 and ds2
%
% Comments:
%
function [dataset] = concatDatasets(dataset1, dataset2)
if(dataset1.is2D && dataset2.is2D)
dataset = dataset1;
if(isempty(dataset1.mask) && ~isempty(dataset2.mask))
dataset.mask = dataset2.mask;
end
dataset.data = cat(2, dataset.data, dataset2.data);
elseif(dataset1.is4D && dataset2.is4D)
dataset = dataset1;
if(isempty(dataset1.mask) && ~isempty(dataset2.mask))
dataset.mask = dataset2.mask;
end
dataset.data = cat(4, dataset.data, dataset2.data);
else
error('CONCAT DATASETS: Please check the dataset: dataset-type is not defined correctly OR input datasets are not of the same type!');
end
dataset.chunks = cat(2, dataset.chunks, dataset2.chunks);
dataset.classIDs = cat(2, dataset.classIDs, dataset2.classIDs);
end