-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1aa6ad
commit f204b56
Showing
10 changed files
with
46 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
function AXstat =as_stats(bwseg,PixelSize,myelin,metric) | ||
% statis=as_stats(bwseg,pixelSize,myelin) | ||
function AXstat =as_stats(myelinseg,pixelSize,myelin) | ||
% AXstat=as_stats(myelinseg,pixelSize) | ||
if ~exist('myelin','var'), myelin=1; end | ||
|
||
|
||
bwseg=reshape2D(~~bwseg,1); | ||
Npix = length(bwseg(:)); | ||
cc = bwconncomp(bwseg, 8); | ||
if myelin | ||
myelinseg = bwseg; | ||
bwseg = logical(imfill(myelinseg,'holes') - myelinseg); | ||
end | ||
|
||
stats = regionprops(bwseg,{'Eccentricity', 'EquivDiameter','Area'}); | ||
myelinseg=reshape2D(myelinseg,1); | ||
cc = bwconncomp(myelinseg, 8); | ||
prop =regionprops(cc, {'Area', 'FilledArea'}); | ||
|
||
% convert units pixel to meters | ||
EquivDiameter = [stats.EquivDiameter]*PixelSize; | ||
% Creation of a struct var for the stats | ||
AXstat=struct('axonEquivDiameter',0,'gRatio',0,'myelinThickness',0); | ||
|
||
AXstat.EquivDiameter01 = sum(EquivDiameter>0 & EquivDiameter<1); | ||
AXstat.EquivDiameter14 = sum(EquivDiameter>1 & EquivDiameter<4); | ||
AXstat.EquivDiameter48 = sum(EquivDiameter>4 & EquivDiameter<8); | ||
AXstat.EquivDiameter812 = sum(EquivDiameter>8 & EquivDiameter<12); | ||
AXstat.EquivDiameter1217 = sum(EquivDiameter>12 & EquivDiameter<17); | ||
AXstat.EquivDiameter = mean(EquivDiameter); | ||
AXstat.EquivDiameter_W = sum(EquivDiameter.^3)/sum(EquivDiameter.^2); | ||
AXstat.EquivDiameter_std = std(EquivDiameter); | ||
AXstat.Eccentricity = max([stats.Eccentricity]); | ||
AXstat.AVF = sum([stats.Area])/Npix; | ||
AXstat.Naxons = length(stats); | ||
|
||
if myelin | ||
stats = regionprops(myelinseg,{'EquivDiameter'}); | ||
myelinEquivDiameter = [stats.EquivDiameter]*PixelSize; | ||
AXstat.MVF = sum(myelinseg)/Npix; | ||
AXstat.myelinEquivDiameter = median(myelinEquivDiameter); | ||
try | ||
AXstat.gRatio = single(EquivDiameter ./ myelinEquivDiameter); | ||
catch | ||
warning('Some myelin have no holes') | ||
if ~isempty(prop) | ||
% Area gives myelin area & FilledArea gives (myelin+axon) area | ||
area = [[prop.Area]' [prop.FilledArea]'-[prop.Area]']; | ||
% Calculate myelin area by using pixel size | ||
if myelin | ||
myelinArea = single(area(:, 1).*pixelSize^2); | ||
end | ||
% Calculate axon area by using pixel size | ||
if myelin | ||
axonArea = single(area(:, 2).*pixelSize^2); | ||
else | ||
axonArea = single(area(:, 1).*pixelSize^2); | ||
end | ||
% Myelin equiv. diameter = sqrt(4*TotalArea/pi) | ||
if myelin | ||
myelinEquivDiameter = single(sqrt(4*(myelinArea + axonArea)/pi)); | ||
end | ||
% Axon equiv. diameter = sqrt(4*AxonArea/pi) | ||
AXstat.axonEquivDiameter = single(sqrt(4*axonArea/pi)); | ||
% Calculate gRatio | ||
if myelin | ||
AXstat.gRatio = single(AXstat.axonEquivDiameter ./ myelinEquivDiameter); | ||
% Myelin thickness = (MyelinDiam - AxonDiam)/2 | ||
AXstat.myelinThickness = single((myelinEquivDiameter - AXstat.axonEquivDiameter) / 2); | ||
end | ||
|
||
% if nargout>0 | ||
% MorphoStat.circularity=; | ||
% end | ||
end | ||
|
||
if exist('metric','var') | ||
AXstat = AXstat.(metric); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
function fields=as_stats_fields | ||
function fieldsval=as_stats_fields | ||
|
||
fields={... | ||
'gRatio'... | ||
'axonEquivDiameter'... | ||
'myelinThickness'}; | ||
fieldsval=fields(as_stats([1 1; 1 1],1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters