Skip to content

Commit

Permalink
BUG: Adapt new atlas roi structures.
Browse files Browse the repository at this point in the history
  • Loading branch information
ningfei committed Dec 4, 2020
1 parent d121038 commit a572858
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions ea_checkstructures.m
Original file line number Diff line number Diff line change
Expand Up @@ -240,29 +240,29 @@ function ea_setnewatlas(h,gf,options,handles,dontupdate)
options.atlasset=h.Parent.Label;
load([ea_space(options,'atlases'),options.atlasset,filesep,'atlas_index.mat']);
if strcmp(h.Label,'ALL')
fv=atlases.fv;
roi=atlases.roi;
pixdim=atlases.pixdim;
xyz=[];
for i=1:numel(fv)
for i=1:numel(roi)
try % some are empty in case of midline/mixed structures
xyz=[xyz;fv{i}.vertices];
xyz=[xyz;roi{i}.fv.vertices];
end
end
pixdim=pixdim{1};
else
[~,six]=ismember(h.Label,ea_rmext(atlases.names));
fv=atlases.fv(six,:);
roi=atlases.roi(six,:);
pixdim=atlases.pixdim(six,:);
if length(fv)>1
if length(roi)>1
xyz=[];
for i=1:numel(fv)
for i=1:numel(roi)
try % some are empty in case of midline/mixed structures
xyz=[xyz;fv{i}.vertices];
xyz=[xyz;roi{i}.fv.vertices];
end
end
pixdim=mean([pixdim{1};pixdim{2}]);
else
xyz=fv{1}.vertices;
xyz=roi{1}.fv.vertices;
pixdim=pixdim{1};
end
end
Expand Down
6 changes: 3 additions & 3 deletions ea_genvat_horn.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@
if ~isfield(atlases,'tissuetypes')
atlases.tissuetypes=ones(length(atlases.names),1);
end
for atlas=1:numel(atlases.fv)
if isempty(atlases.fv{atlas}) || (atlases.tissuetypes~=1)
for atlas=1:numel(atlases.roi)
if isempty(atlases.roi{atlas}.fv) || (atlases.tissuetypes~=1)
continue
end
fv(cnt)=atlases.fv{atlas};
fv(cnt)=atlases.roi{atlas}.fv;

ins=surfinterior(fv(cnt).vertices,fv(cnt).faces);
%tissuetype(cnt)=1;
Expand Down
16 changes: 8 additions & 8 deletions helpers/ea_atlasmajorcomponent.m
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
function atlases=ea_atlasmajorcomponent(atlases,toclean)
% from specified component, only preserve largest component

for c=toclean
for c=toclean
for side=1:2
% figure, patch(atlases.fv{c,side},'FaceColor','none')
fvsplit=splitFV(atlases.fv{c,side}.faces,atlases.fv{c,side}.vertices);
% figure, patch(atlases.roi{c,side}.fv,'FaceColor','none')

fvsplit=splitFV(atlases.roi{c,side}.fv.faces,atlases.roi{c,side}.fv.vertices);
for comp=1:length(fvsplit)
lengths(comp)=length(fvsplit(comp).faces);
end
[~,ix]=max(lengths);
atlases.fv{c,side}.faces=fvsplit(ix).faces;
atlases.fv{c,side}.vertices=fvsplit(ix).vertices;
atlases.roi{c,side}.fv.faces=fvsplit(ix).faces;
atlases.roi{c,side}.fv.vertices=fvsplit(ix).vertices;
end
end

Expand Down Expand Up @@ -69,7 +69,7 @@
openVertices = f(nextAvailFace,:);
while ~isempty(openVertices)
availFaceInds = find(fSets==0);
[availFaceSub, ~] = find(ismember(f(availFaceInds,:), openVertices));
[availFaceSub, ~] = find(ismember(f(availFaceInds,:), openVertices));
fSets(availFaceInds(availFaceSub)) = currentSet;
openVertices = f(availFaceInds(availFaceSub),:);
end
Expand All @@ -85,4 +85,4 @@
[unqVertIds, ~, newVertIndices] = unique(setF);
fvOut(currentSet).faces = reshape(newVertIndices,size(setF));
fvOut(currentSet).vertices = v(unqVertIds,:);
end
end
4 changes: 2 additions & 2 deletions helpers/ea_atlasreducepatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

for atl=1:length(atlases.names)
for side=1:2
atlases.fv{atl,side}=reducepatch(atlases.fv{atl,side},red);
atlases.roi{atl,side}.fv=reducepatch(atlases.roi{atl,side}.fv,red);

end
end

0 comments on commit a572858

Please sign in to comment.