DeProj MATLAB error


Actually it works.
Changing the value of invert_z on line 24 to false changes the Z orientation.

On a side note and unrelated , do you make sure that the pixel size and voxel depth (lines 17 and 20) are the right ones for your movie?

I get this image:

But I need this:

I change the pixel size according to mines but I don’t know where to get the info from the voxel depth, so I just leave 1 as value.

Ahhhhhhh but this is the Y axis, not the Z axis.
The Z axis is orthogonal to this plan. You have to rotate the image to see it. The images generated by DeProj are 3D, but shown by default parallel to the XY plane.
If you want to invert the axis you can use pain MATLAB command

set(gca, 'YDir','reverse')

A word of caution about the voxel depth: we use it to compute the real area, perimeter and curvature. All 3D morphological parameters actually. If you don’t set it right, the values reported by DeProj will be incorrect.
To know the value for the voxel depth check the metadata of the source 3D image or ask the person that did the imaging.

1 Like

Sorry, maybe I should have say Y axis, but I wasn’t sure if the axis were annotated the same way as I take the photos with the microscope …
I checked my images and they are: 0.297x0.297x1 .
So I am setting properly the pixel size and the voxel depth in the code.

Where should I write that command and how: set(gca, ‘YDir’,‘reverse’)? I reversed the images manually and now it works for the antero-posterior axis (Y axis) but I also have to flip the image because the left-right axis (X axis) is inversed … I rather not doing it manually … if I use imrotate() and flip() would it work too?

(PS. I am sorry for my basic questions … I am biologist and I am still getting used to the code :sweat_smile:)

%% Example de-projection script.

%% Clear all.

close all

%% Parameters, scripts and files location.

% Add DeProj functions to the path.

root_folder = ‘E9DPWgolgi’;

mask_filename = ‘handCorrection4.tif’;
heightmap_filename = ‘Referencesurface4.tif’;

pixel_size = 0.297; % µm
units = ‘µm’;
voxel_depth = 1.; % µm

prune_zeros = true;
inpaint_zeros = true;

invert_z = true;

%% Read files.

% ImageJ mask.
fprintf(‘Opening mask image: %s\n’, mask_filename )
I = imread( fullfile( root_folder, mask_filename ) );
I = imrotate(I,180)
I = flip (I, 2)

fprintf(‘Opening height-map image: %s\n’, heightmap_filename )
H = imread( fullfile( root_folder, heightmap_filename ) );
H = imrotate(H,180)
H = flip (H,2)

It seems to work with this too ?