Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Eamon Doyle
roiTool
Commits
abb2d4cf
Commit
abb2d4cf
authored
Jun 19, 2024
by
Eamon Doyle
Browse files
updates for massively increased speed
parent
ee1c78a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
mergeRoiTool.m
View file @
abb2d4cf
...
@@ -432,45 +432,101 @@ if ~isempty(text)
...
@@ -432,45 +432,101 @@ if ~isempty(text)
set
(
handles
.
progressText
,
'String'
,
text
);
set
(
handles
.
progressText
,
'String'
,
text
);
end
end
function
[]
=
currentLine
s
=
dbstack
;
line
=
s
(
2
)
.
line
;
display
([
'At '
s
.
name
'line '
line
]);
function
redrawImage
(
hObject
,
eventdata
,
handles
)
function
redrawImage
(
hObject
,
eventdata
,
handles
)
axes
(
handles
.
axes1
);
%st = dbstack;
%display(['Start ' st.name]);
%currentLine
%tic;
%axes(handles.axes1);
%currentLine;toc;
images
=
handles
.
imageMat
;
images
=
handles
.
imageMat
;
%h = imagesc(images(:,:,1,1),'HitTest','off');
%h = imagesc(images(:,:,1,1),'HitTest','off');
cs
=
handles
.
currentSlice
;
cs
=
handles
.
currentSlice
;
%currentLine;toc;
gridsize
=
handles
.
lungGridSize
;
gridsize
=
handles
.
lungGridSize
;
newim
=
repmat
(
images
(:,:,
1
,
cs
),
1
,
1
,
3
);
newim
=
repmat
(
images
(:,:,
1
,
cs
),
1
,
1
,
3
);
newim
=
double
(
newim
);
newim
=
double
(
newim
);
newim
=
newim
.
/
max
(
newim
(:));
newim
=
newim
.
/
max
(
newim
(:));
lms
=
handles
.
lungGridSize
;
lms
=
handles
.
lungGridSize
;
imsize
=
size
(
images
);
imsize
=
size
(
images
);
overlay
=
zeros
(
size
(
newim
));
overlay
=
zeros
(
size
(
newim
));
if
lms
>
-
1
if
lms
>
-
1
for
n
=
1
:
size
(
handles
.
lungMatrix
,
1
)
-
1
% for n=1:size(handles.lungMatrix,1)-1
for
m
=
1
:
size
(
handles
.
lungMatrix
,
2
)
-
1
% for m=1:size(handles.lungMatrix,2)-1
xx
=
n
*
lms
;
% xx = n*lms;
yy
=
m
*
lms
;
% yy = m*lms;
switch
handles
.
lungMatrix
(
m
,
n
,
1
,
handles
.
currentSlice
)
% switch handles.lungMatrix(m,n,1,handles.currentSlice)
case
1
% case 1
cd
=
[
0.2
,
0.2
,
0.0
];
% cd = [0.2, 0.2, 0.0];
case
2
% case 2
cd
=
[
0.4
,
0
,
0
];
% cd = [0.4,0,0];
case
3
% case 3
cd
=
[
0
,
0.4
,
0
];
% cd = [0,0.4,0];
case
4
% case 4
cd
=
[
0.1
,
0.1
,
0.5
];
% cd = [0.1,0.1,0.5];
otherwise
% otherwise
cd
=
[
0
0
0
];
% cd = [0 0 0];
end
% end
%
%
% overlay(yy:yy+lms, xx:xx+lms,1)=cd(1);
% overlay(yy:yy+lms, xx:xx+lms,2)=cd(2);
% overlay(yy:yy+lms, xx:xx+lms,3)=cd(3);
% end
% end
lungmat2
=
repmat
(
imresize
(
handles
.
lungMatrix
(:,:,
1
,
handles
.
currentSlice
),
lms
,
'nearest'
),[
1
,
1
,
3
]);
overlay
(
yy
:
yy
+
lms
,
xx
:
xx
+
lms
,
1
)
=
cd
(
1
);
for
mcolor
=
1
:
4
overlay
(
yy
:
yy
+
lms
,
xx
:
xx
+
lms
,
2
)
=
cd
(
2
);
switch
mcolor
overlay
(
yy
:
yy
+
lms
,
xx
:
xx
+
lms
,
3
)
=
cd
(
3
);
case
1
cmat
=
[
0.5
0.5
0
];
case
2
cmat
=
[
0
0
1
];
case
3
cmat
=
[
0
1
0
];
case
4
cmat
=
[
0.75
0
0
];
end
end
%[x,y,i] = find(lungmat2==mcolor)
%color2 = [0 0 1];
%color2 = reshape(color2,[1,1,3]);
for
itr
=
1
:
3
lungmathold
=
lungmat2
(:,:,
itr
);
lungmathold
(
find
(
lungmathold
==
mcolor
))
=
cmat
(
itr
);
lungmat2
(:,:,
itr
)
=
lungmathold
;
end
%overlay(x,y,1) = cmat(1);
%overlay(x,y,2) = cmat(2);
%overlay(x,y,3) = cmat(3);
end
end
a
=
size
(
lungmat2
);
b
=
size
(
overlay
);
c
=
b
-
a
;
%currentLine
%toc;
overlay
=
padarray
(
lungmat2
,
c
(
1
:
2
),
0
,
'post'
);
end
end
%size(newim)
%size(newim)
%size(overlay)
%size(overlay)
newim
=
newim
+
overlay
;
newim
=
newim
+
overlay
;
...
@@ -481,20 +537,26 @@ set(h,'PickableParts','none')
...
@@ -481,20 +537,26 @@ set(h,'PickableParts','none')
set
(
handles
.
sliceNum
,
'String'
,
num2str
(
handles
.
currentSlice
));
set
(
handles
.
sliceNum
,
'String'
,
num2str
(
handles
.
currentSlice
));
set
(
handles
.
sliceCount
,
'String'
,
sprintf
(
'/ %i'
,
size
(
images
,
4
)));
set
(
handles
.
sliceCount
,
'String'
,
sprintf
(
'/ %i'
,
size
(
images
,
4
)));
if
lms
>
-
1
if
lms
>
-
1
gridColor
=
[
0.2
,
0.4
,
0.2
];
hold
on
;
for
n
=
0
:
gridsize
:
imsize
(
1
);
hold
on
;
for
n
=
0
:
gridsize
:
imsize
(
1
);
h
=
plot
([
n
,
n
],[
0
,
imsize
(
2
)],
'g'
);
h
=
plot
([
n
,
n
],[
0
,
imsize
(
2
)],
'Color'
,
gridColor
);
set
(
h
,
'HitTest'
,
'off'
)
set
(
h
,
'HitTest'
,
'off'
)
set
(
h
,
'PickableParts'
,
'none'
)
set
(
h
,
'PickableParts'
,
'none'
)
%set(h,'ButtonDownFcn',@axes1_ButtonDownFcn)
%set(h,'ButtonDownFcn',@axes1_ButtonDownFcn)
end
end
for
n
=
0
:
gridsize
:
imsize
(
2
);
for
n
=
0
:
gridsize
:
imsize
(
2
);
h
=
plot
([
0
,
imsize
(
1
)],[
n
,
n
],
'
g'
);
h
=
plot
([
0
,
imsize
(
1
)],[
n
,
n
],
'
Color'
,
gridColor
);
set
(
h
,
'HitTest'
,
'off'
)
set
(
h
,
'HitTest'
,
'off'
)
set
(
h
,
'PickableParts'
,
'none'
)
set
(
h
,
'PickableParts'
,
'none'
)
%set(h,'ButtonDownFcn',@axes1_ButtonDownFcn)
%set(h,'ButtonDownFcn',@axes1_ButtonDownFcn)
end
end
%handles
%handles
end
end
%currentLine
%toc;
...
@@ -591,7 +653,7 @@ lungMatrix = zeros(floor(imsize(1)./gridsize),floor(imsize(2)./gridsize),imsize(
...
@@ -591,7 +653,7 @@ lungMatrix = zeros(floor(imsize(1)./gridsize),floor(imsize(2)./gridsize),imsize(
handles
.
lungMatrix
=
lungMatrix
;
handles
.
lungMatrix
=
lungMatrix
;
handles
.
lungGridSize
=
gridsize
;
handles
.
lungGridSize
=
gridsize
;
hold
on
;
for
n
=
0
:
gridsize
:
imsize
(
1
);
hold
on
;
for
n
=
0
:
gridsize
:
imsize
(
1
);
h
=
plot
([
n
,
n
],[
0
,
imsize
(
2
)],
'
g'
);
h
=
plot
([
n
,
n
],[
0
,
imsize
(
2
)],
'
Color'
,[
0.2
,
0.4
,
0.2
]
);
%set(h,'HitTest','off')
%set(h,'HitTest','off')
set
(
h
,
'ButtonDownFcn'
,
@
axes1_ButtonDownFcn
)
set
(
h
,
'ButtonDownFcn'
,
@
axes1_ButtonDownFcn
)
end
end
...
@@ -616,6 +678,10 @@ function axes1_ButtonDownFcn(hObject, eventdata, handles)
...
@@ -616,6 +678,10 @@ function axes1_ButtonDownFcn(hObject, eventdata, handles)
% handles structure with handles and user data (see GUIDATA)
% handles structure with handles and user data (see GUIDATA)
%gca;
%gca;
%st = dbstack;
%display(['Start ' st.name]);
%tic;
drawnow
drawnow
handles
=
guidata
(
hObject
);
handles
=
guidata
(
hObject
);
%colormap('gray');
%colormap('gray');
...
@@ -636,8 +702,8 @@ end
...
@@ -636,8 +702,8 @@ end
lungGridSize
=
handles
.
lungGridSize
;
lungGridSize
=
handles
.
lungGridSize
;
lungGridMatSize
=
size
(
handles
.
lungMatrix
);
lungGridMatSize
=
size
(
handles
.
lungMatrix
);
lungMatLoc
=
floor
(
currentBox
);
lungMatLoc
=
floor
(
currentBox
);
lmy
=
floor
(
lungMatLoc
(
1
)
.
/
size
(
handles
.
imageMat
,
2
)
*
lungGridMatSize
(
2
));
lmy
=
floor
(
lungMatLoc
(
1
)
.
/
size
(
handles
.
imageMat
,
2
)
*
lungGridMatSize
(
2
))
+
1
;
lmx
=
floor
(
lungMatLoc
(
2
)
.
/
size
(
handles
.
imageMat
,
1
)
*
lungGridMatSize
(
1
));
lmx
=
floor
(
lungMatLoc
(
2
)
.
/
size
(
handles
.
imageMat
,
1
)
*
lungGridMatSize
(
1
))
+
1
;
currentSlice
=
get
(
handles
.
slider2
,
'Value'
);
currentSlice
=
get
(
handles
.
slider2
,
'Value'
);
if
handles
.
debug
>
3
if
handles
.
debug
>
3
lungGridMatSize
lungGridMatSize
...
@@ -661,6 +727,9 @@ redrawImage(hObject, eventdata, handles);
...
@@ -661,6 +727,9 @@ redrawImage(hObject, eventdata, handles);
% Update handles structure
% Update handles structure
guidata
(
hObject
,
handles
);
guidata
(
hObject
,
handles
);
%toc;
%display(['Stop ' st.name]);
function
mouseClick
(
~
,
~
)
function
mouseClick
(
~
,
~
)
disp
(
'yep'
)
disp
(
'yep'
)
get
(
gca
,
'CurrentPoint'
)
get
(
gca
,
'CurrentPoint'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment