Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DeProj
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IAH public
DeProj
Commits
15041917
Commit
15041917
authored
5 years ago
by
Sebastien Herbert
Browse files
Options
Downloads
Patches
Plain Diff
Dev version of main script
Currently only runs until the findContour line
parent
e9a20dea
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MainScripts/surface3D_combine.m
+33
-62
33 additions, 62 deletions
MainScripts/surface3D_combine.m
with
33 additions
and
62 deletions
MainScripts/surface3D_combine.m
+
33
−
62
View file @
15041917
...
...
@@ -26,8 +26,8 @@ projected seg (based on the polygon surface of the cell)
14
)
Display
final
maps
%}
function
surface3D_combine
(
doDispBell
,
doDispMesh
,
doDispOverlay
,
axPi
xSize
,
...
t
iffImSize
,
maxFaces
,
outputFolder
,
segLoc
,
curveLoc
)
function
surface3D_combine
(
doDispBell
,
doDispMesh
,
doDispOverlay
,
vo
xSize
,
...
maxT
iffImSize
,
maxFaces
,
outputFolder
,
segLoc
,
curveLoc
)
tic
close
all
...
...
@@ -35,19 +35,20 @@ PARAMS = {};
%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%
PARAMS
.
softVersion
=
'surface3D_combine_v0p1
3
.m'
;
PARAMS
.
softVersion
=
'surface3D_combine_v0p1
p0
.m'
;
if
nargin
==
0
fprintf
(
'Using default input parameters\n'
);
PARAMS
.
doDispBell
=
tru
e
;
% display the 2D segmentation
PARAMS
.
doDispMesh
=
tru
e
;
% display the 3D mesh
PARAMS
.
doDispOverlay
=
tru
e
;
% display the overlayed 2D seg and 3D mesh
PARAMS
.
doDispBell
=
fals
e
;
% display the 2D segmentation
PARAMS
.
doDispMesh
=
fals
e
;
% display the 3D mesh
PARAMS
.
doDispOverlay
=
fals
e
;
% display the overlayed 2D seg and 3D mesh
PARAMS
.
doDispErrorEllipse
=
true
;
% display the cells with an ellipse fit error
% Define axial step size (in um)
PARAMS
.
imSettings
.
axPixSize
=
0.5
;
% Axial pixel size (in um)
PARAMS
.
imSettings
.
axPixSize
=
0.5
;
% axial voxel size (in um)
PARAMS
.
imSettings
.
latPixSize
=
0.2
;
% lateral voxel size (in um)
PARAMS
.
t
iffImSize
=
40000
;
% Limit the input image size when using an elevation map (in pix)
PARAMS
.
maxT
iffImSize
=
40000
;
% Limit the input image size when using an elevation map (in pix)
PARAMS
.
maxFaces
=
300
;
% If need be, reduce the maximum number of faces for the mesh
% initialize input and output
...
...
@@ -55,6 +56,11 @@ if nargin == 0
segLoc
=
''
;
curveLoc
=
''
;
% DEV ONLY
outputFolder
=
'/media/sherbert/Data/Projects/Own_Project/Deproj/LValon/output/'
;
segLoc
=
'/media/sherbert/Data/Projects/Own_Project/Deproj/LValon/input/GT_SegmentationResults-labels-1.tif'
;
curveLoc
=
'/media/sherbert/Data/Projects/Own_Project/Deproj/LValon/input/LValonMultiC_elevMap_T1.tif'
;
elseif
nargin
==
9
fprintf
(
'Using GUI input parameters\n'
);
% Displays inputs
...
...
@@ -62,11 +68,12 @@ elseif nargin == 9
PARAMS
.
doDispMesh
=
doDispMesh
;
% display the 3D mesh
PARAMS
.
doDispOverlay
=
doDispOverlay
;
% display the overlayed 2D seg and 3D mesh
% Define axial step size (in um)
PARAMS
.
imSettings
.
axPixSize
=
axPixSize
;
% Define voxel size (in um)
PARAMS
.
imSettings
.
latPixSize
=
voxSize
(
1
);
% placeholders if ply object, will be overwritten
PARAMS
.
imSettings
.
axPixSize
=
voxSize
(
2
);
% placeholders if ply object, will be overwritten
% Curvature import
PARAMS
.
t
iffImSize
=
t
iffImSize
;
% Limit the input image size when using an elevation map (in pix)
PARAMS
.
maxT
iffImSize
=
maxT
iffImSize
;
% Limit the input image size when using an elevation map (in pix)
PARAMS
.
maxFaces
=
maxFaces
;
% If need be, reduce the maximum number of faces for the mesh
else
fprintf
(
'Number of input arguments is inadequate\n'
);
...
...
@@ -101,8 +108,9 @@ PARAMS.imSettings.z = 0; % image size in Z (in px) => Could be used to offset th
cd
(
PARAMS
.
outputFolder
)
%% Load 2D segmetation from Bellaiche soft and resize/flip
[
dataSeg
,
dataCells
,
PARAMS
]
=
loadSeg
(
PARAMS
);
[
dataSeg
,
PARAMS
]
=
loadSeg
(
PARAMS
);
%% Load sample curvature
dataCurv
=
loadCurve
(
PARAMS
);
...
...
@@ -143,7 +151,7 @@ end
%% Restructure projected cells to proper contours
% Find contiguous points of each cell/polygon countour
% Creates the edges for later use
dataCells
.
cellContour2D
=
findContour
(
data
Cells
.
contourPo2D
,
'bwboundary'
,
PARAMS
);
dataCells
.
cellContour2D
=
findContour
(
data
Seg
,
PARAMS
);
% % create triangulated areas Check with polygon intersection instead
% dataCells = polygon2surface(dataCells);
...
...
@@ -221,7 +229,7 @@ fprintf('Loading elevation map\n');
tiffImage
=
read
(
Tiff
(
PARAMS
.
curveLoc
));
% Calculate the scaling factor
scalingFactor
=
ceil
(
size
(
tiffImage
,
1
)
*
size
(
tiffImage
,
2
)
/
PARAMS
.
t
iffImSize
);
scalingFactor
=
ceil
(
size
(
tiffImage
,
1
)
*
size
(
tiffImage
,
2
)
/
PARAMS
.
maxT
iffImSize
);
% import and scale the image data
z
=
double
(
tiffImage
);
...
...
@@ -275,7 +283,7 @@ dataCurv.vertices = bsxfun( @plus,dataCurv.vertices,...
dataCurv
.
vertices
(:,
2
)
=
abs
(
bsxfun
(
@
minus
,
dataCurv
.
vertices
(:,
2
),
...
PARAMS
.
imSettings
.
y
*
PARAMS
.
imSettings
.
latPixSize
));
% If the number of faces is too high th
a
n reduce them
% If the number of faces is too high th
e
n reduce them
if
length
(
dataCurv
.
faces
)
>
PARAMS
.
maxFaces
fprintf
(
'Reducing the number of faces in the Mesh\n'
);
dataCurv
=
reducepatch
(
dataCurv
,
PARAMS
.
maxFaces
,
'verbose'
);
...
...
@@ -283,57 +291,20 @@ end
end
function
[
dataSeg
,
dataCells
,
PARAMS
]
=
loadSeg
(
PARAMS
)
% load
and parse data from the Bellaiche analysis
% returns the main structure + an additionnal
field
for the cells contour
function
[
dataSeg
,
PARAMS
]
=
loadSeg
(
PARAMS
)
% load
ridge image containing the segmentation.
% returns the main structure + an additionnal
structure
for the cells contour
% in pixels (0,0,0 = corners bottom left)
% Load data
% Add we GUI after original test phase
fprintf
(
'Loading segmentation file\n'
);
dataSeg
=
load
(
PARAMS
.
segLoc
);
% Set x y and frame parameters
PARAMS
.
imSettings
.
x
=
dataSeg
.
FRAME
.
imageSize
(
2
);
% image size in X (in px) % exists in dataSeg
PARAMS
.
imSettings
.
y
=
dataSeg
.
FRAME
.
imageSize
(
1
);
% image size in Y (in px) % exists in dataSeg
% PARAMS.imSettings.z and PARAMS.imSettings.axPixSize => are set by hand at
% the beginning
PARAMS
.
imSettings
.
latPixSize
=
dataSeg
.
FRAME
.
scale1D
;
% Lateral pixel size (in um) % exists in dataSeg
% % Check Parameter values => rendered useless by the GUI
% PARAMS = checkPARAMS(PARAMS);
% rescale and calculate the 2D position of each cell contour (and delete the whole sample fake cell)
dataCells
.
contourPo2D
=
{};
for
bioCell
=
1
:
length
(
dataSeg
.
CELLS
.
numbers
)
% for each cell
dataCells
.
contourPo2D
{
bioCell
}
=
zeros
(
length
(
dataSeg
.
CELLS
.
contour_indices
{
bioCell
}),
2
);
for
vertice
=
1
:
length
(
dataSeg
.
CELLS
.
contour_indices
{
bioCell
})
% dataCells.contourPo2D{bioCell}(vertice,1)=...
% idivide(dataSeg.CELLS.contour_indices{bioCell}(vertice),int32(2916))*PARAMS.imSettings.latPixSize;
% dataCells.contourPo2D{bioCell}(vertice,2)=...
% rem(dataSeg.CELLS.contour_indices{bioCell}(vertice),int32(2916))*PARAMS.imSettings.latPixSize;
% dataCells.contourPo2D{bioCell}(vertice,3)=0; % fake z position for plot 3D
dataCells
.
contourPo2D
{
bioCell
}(
vertice
,
1
)
=
...
double
(
idivide
(
dataSeg
.
CELLS
.
contour_indices
{
bioCell
}(
vertice
),
int32
(
2916
)))
*
PARAMS
.
imSettings
.
latPixSize
;
dataCells
.
contourPo2D
{
bioCell
}(
vertice
,
2
)
=
...
double
(
rem
(
dataSeg
.
CELLS
.
contour_indices
{
bioCell
}(
vertice
),
int32
(
2916
)))
*
PARAMS
.
imSettings
.
latPixSize
;
end
end
dataCells
.
contourPo2D
=
dataCells
.
contourPo2D
'
;
fprintf
(
'Loading segmentation image\n'
);
dataSeg
=
imread
(
PARAMS
.
segLoc
);
dataCells
.
types
=
dataSeg
.
CELLS
.
types
;
dataCells
.
numbers
=
dataSeg
.
CELLS
.
numbers
;
% Set x y size
[
PARAMS
.
imSettings
.
y
,
PARAMS
.
imSettings
.
x
]
=
size
(
dataSeg
)
;
% % delete largest cell => whole sample fake cell % to be used if too long
% % calculation or proves to be a problem
% [sorted_contour_length,I] = sort(dataSeg.CELLS.contour_chord_lengths,'descend');
% if sorted_contour_length(1)/sorted_contour_length(2) > 10
% % if not the largest cell may not be the sample contour
% dataCells.contourPo2D(I(1)) = [];
% else
% disp('Warning: check that the largest cell is the sample contour');
% end
% dataCells.types = dataSeg.CELLS.types;
% dataCells.numbers = 1:dataSeg.CELLS.numbers;
end
...
...
@@ -718,7 +689,7 @@ dataCells.area.areaProjPerFace(clippedCellList) = [];
dataCells
.
area
.
areaProjTot
(
clippedCellList
)
=
[];
dataCells
.
area
.
areaRealPerFace
(
clippedCellList
)
=
[];
dataCells
.
area
.
areaRealTot
(
clippedCellList
)
=
[];
dataCells
.
types
(
clippedCellList
)
=
[];
%
dataCells.types(clippedCellList) = [];
dataCells
.
numbers
(
clippedCellList
)
=
[];
% Create the last SIDES copy for the good cells
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment