Using oblique slice on a binary volume - resulting in empty oblique slice

6 Ansichten (letzte 30 Tage)
I am trying to follow the example for obtaining an oblique slice. https://uk.mathworks.com/help/images/ref/obliqueslice.html
How do I obtain an oblique slice through a binary volume?
A sample of my code is below.
The problem very much appears to be with the obliqueslice function because the volume D is behaving as expected 512 x 512 x 152 int16 comprising 0s (background) and 1s volume.
The slice B is a 533 x 522 int16 comprising only 0s
I've tried changing the interpolation method for oblique slice (linear/nearest) and I've tried converting D to categorical or logical.
Any tips?
V = dicomreadVolume('dicomFolder'); % my dicom folder
V = squeeze(V); % 512 x 512 x 152 int16
labels = load('labels.mat'); % saved labels from volume segmenter app
labels = labels.labels; % 512 x 512 x 152 categorical
fpm = (labels == 'Label1'); % 512 x 512 x 152 logical
fpm = int16(fpm); % converted from logical to integer so that surf work. Still only consists of 1s and 0s
point1 = [180, 270, 78]; % This lies within the labeled volume so by definition the slice should cut through the volume
point2 = [166, 271, 13];
vector = point1 - point2
[y,x,z,D] = reducevolume(fpm,[1,1,1]); % I found that I needed to reverse x and y to get the axes the same between points and volumes
[B,x,y,z] = obliqueslice(D,point2,normal, 'Method','nearest');
figure
% First plot volume to visualise and make sure that it is bisected by the
% slice plane.
p1 = patch(isosurface(x,y,z, D),...
'FaceColor','red','EdgeColor','none');
hold on
view(3)
axis equal
daspect([1,1,1])
colormap(gray(2))
camlight
lighting gouraud
% Now plot slice plane
surf(x,y,z,B);
grid off
view([-38 12])
colormap(gray(2))
hold on
xlabel('x-axis')
ylabel('y-axis');
zlabel('z-axis');
title('Slice in 3-D Coordinate Space')
% plot points
plot3(point1(1),point1(2),point1(3),'or','MarkerFaceColor','r');
plot3(point2(1),point2(2),point2(3),'or','MarkerFaceColor','r');
hold off
figure
imshow(B,[])
title('Slice in Image Plane')

Antworten (1)

T.Nikhil kumar
T.Nikhil kumar am 27 Okt. 2023
Hello Christopher,
I understand that you are trying to obtain an oblique slice through a binary volume from a DICOM image and are facing some issues with it.
I would suggest you try resolving these issues and it could result in the correct slice matrix.
  • I cannot find the definition of the normal vector in this code snippet. You could create a suitable normal vector to the plane defined by ‘point1’ and ‘point2’ points. Refer to the following code for a possible normal vector:
% Calculate the normal vector to the plane defined by point1 and point2
vector = point1 - point2;
normal = vector / norm(vector);
  • Check if any other transformations like image orientation are needed to align the coordinate systems of your points and the DICOM volume. DICOM images can have different orientations.
Another suggestion is that you can directly save the ‘labels’ from ‘Volume Segmenter App’ as ‘logical’ type object instead of programmatically converting the ‘categorical’ type object.
You can learn more about the ‘norm’ function through the following documentation:
You can learn about the different coordinate systems in DICOM images and chose appropriate values for points through this documentation:
Hope this helps you make progress!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by