%% Create and Connect 3-D Crop Layer
% Create a 3-D crop layer and connect both of its inputs using a layerGraph object.

layers = [
    image3dInputLayer([32 32 32 3],'Name','image')
    convolution3dLayer(3,16,'Padding','same','Name','conv')
    crop3dLayer('Name','crop')
    concatenationLayer(4,2,'Name','concat')
    ]

% Create a layer graph. The first input of the 3-D crop layer is automatically connected to the output of the 3-D convolutional layer.

lgraph = layerGraph(layers);

%  Add a max pooling layer to the layer graph.

maxPool = maxPooling3dLayer(2,'stride',2,'Name','pool');
lgraph = addLayers(lgraph,maxPool);
lgraph = connectLayers(lgraph,'image','pool');

% Connect the second input of the crop layer to the output of the max pooling layer.

lgraph = connectLayers(lgraph,'pool','crop/ref');

% Concatenate the crop layer output and the max pooling layer output.

lgraph = connectLayers(lgraph,'pool','concat/in2');

% Display the layer graph.

plot(lgraph)

% Copyright 2019 The MathWorks, Inc.