DeProj MATLAB error

Hii everyone! I am currently measuring some epithelial properties so I am highly interested in the new Dproj toolbox (Herbert et al. 2021)

The LocalZprojection works pretty well, but I am having trouble with the mathlab plug-in. I downloaded and install the src folder in the mathlab path. When I run “epicell” command I got the correct output but when I run the “RunExample” command I got an error: “Unrecognized function or variable”.

Do you have any idea of what can I be doing wrong?

Apart from that, I don’t know how to use the tool for my own images. Should I upload the images in Mathlab or should I move the images to the same folder as the scripts?



Hello @ClaraG Clara and thank you for letting us know.

I would suspect an issue with MATLAB path.
Could you copy paste the entire command window with the error message?
What folder do you run the example from?

This is the error:

‘bwconncomp’ requires Image Processing Toolbox.

Error in deproj/mask_to_objects (line 28)
CC = bwconncomp( ~M, 4 );

Error in deproj.from_heightmap (line 40)
[ objects, junction_graph ] = deproj.mask_to_objects( I, downsample );

Error in RunExample (line 61)
dpr = deproj.from_heightmap( …

I run it from the Dproj-master folder:
(I share the screenshot)

Hello and thank you it is super useful.
You need the image processing toolbox to run DeProj. It has the very nice function that the error message is missing.

1 Like

Thank youu Jean!!

I have just checked and in my academic version that package is missing … I will see how to get it.

1 Like

Hi Jean,

I already got the Toolbox and the examples Run perfectly, but now I have errors running my own images.

I created a new folder where I stock the images from which I want to get the morphometrics (the segmented and the heightmap images), the difference with the ones in the sample is that my segmented images are black with segmenting lines in white, so I don’t know if that makes a problem and I should try to invert the colors. Then I change the root_folder, mask_filename and heightmap_filename.

I got the following errors:

Error using bwboundaries
Expected input number 1, BW, to be two-dimensional.

Error in bwboundaries>parseInputs (line 195)
validateattributes(BW_in, {‘numeric’,‘logical’}, {‘real’,‘2d’,‘nonsparse’}, …

Error in bwboundaries (line 148)
[BW, conn, findHoles] = parseInputs(args{:});

Error in deproj/mask_to_objects (line 39)
bounds = bwboundaries( temp, 8, ‘noholes’ );

Error in deproj.from_heightmap (line 40)
[ objects, junction_graph ] = deproj.mask_to_objects( I, downsample );

Error in RunImage (line 42)
dpr = deproj.from_heightmap( …)

Do you know how to fix this? I add a screenshot.


Yes that is most likely due to the mask inverted color. The ridges should be black and the cells white.

Would you be ok to send me an excerpt of both files? I would test and report results here. I really wish to make sure it works everywhere.

This is the segmented image:
handCorrection4.tif (3.0 MB)

And this is the heightmap:
Referencesurface4.tif (2.0 MB)

For info: I am using Tissue Analyser or Episeg to segment the images. The default segmented image from both tools is the handCorrection I uploaded (black cells with white ridge).

It’s beautiful!

So yes, it was because the segmentation is black on white in RGB instead of white on black in 8-bit. If you use the following file it should work:
handCorrection4-inverted.tif (1.0 MB)

Thanks to your files I have found a bug in the import of segmentation. I just pushed a fix now, so you will have to git pull or redownload DeProj now.

1 Like

Cool! How do you invert the image color ? Is there a command in mathlab?

First convert it to 8-bit with Image > Type 8-bit.
Then invert it with Edit > Invert.

1 Like

Yes yes, it is super good.
Thanks a lot.

I uploaded deproj.
So just to clarify: the segmented image has to be always white with black ridges . Both images (the heightmap and the segmented image) have to be in.tif format, or can we upload .jpg /.png ?

Whatever MATLAB can read is going to be fine.
Probably not jpeg because of the lossy compression. PNG etc will be fine.


I have realised about a thing … The plots of the images are upside down, they are inversed from the input images (the heightmap and the segmentation), but I don’t know why. Is there a way to plot them with the same orientation?

Yes, check how we invert Z in the first example:

1 Like

If I change the value:
invert_z = true or false, the images doesn’t change, they are always face down.

Grmlml Is it possible you send me the script that generates the figures?

Sure, I am using the one you have in RunExample but uploading my images.
Here it is:

%% Clear all.

close all

%% Parameters, scripts and files location.

% Add DeProj functions to the path.

% Where are the images.
root_folder = ‘E9DPWgolgi’;
mask_filename = ‘handCorrection4-inverted.tif’;
heightmap_filename = ‘Referencesurface4.tif’;

pixel_size = 0.29; % µ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 ) );

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

%% Create deproj instance.

dpr = deproj.from_heightmap( …
I, …
H, …
pixel_size, …
voxel_depth, …
units, …
invert_z, …
inpaint_zeros, …
prune_zeros );

%% Plot morphological parameters.

close all

fprintf( ‘Plotting the cell sizes.\n’ )

fprintf( ‘Plotting the tissue orientation.\n’ )

fprintf( ‘Plotting the tissue local curvature.\n’ )

fprintf( ‘Plotting the cell elongation and direction.\n’ )

fprintf( ‘Plotting the impact of projection distorsion.\n’ )

fprintf( ‘Plotting the topology figure.\n’ )
dpr.plot_text( num2cell( vertcat( dpr.epicells.n_neighbors ) ), gca );

fprintf( ‘Finished.\n’ )