Skip to content

Instantly share code, notes, and snippets.

Created December 11, 2014 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/53518056b5d667d0553e to your computer and use it in GitHub Desktop.
Save anonymous/53518056b5d667d0553e to your computer and use it in GitHub Desktop.
function sliceScrollFunction(handles, event_data)
% Try this for error avoidance
% pause(0.25)
% Get appdata
mainfig = getappdata(0, 'mainfig');
img_data = getappdata(mainfig, 'cq');
currentSlice = getappdata(mainfig, 'currentSlice');
current_gca = getappdata(mainfig, 'current_gca');
% Perform a switch on current_gca, and do the wheel scroll on the preferred
% choice and update that graph
switch current_gca
case 'axial'
% Case is axial, update gca with one slice in preferred direction,
% can possibly change later to modular amount.
if event_data == -1
if currentSlice(3) <= size(img_data,3)
currentSlice(3) = currentSlice(3) + 1;
else
return
end
elseif event_data == 1;
if currentSlice(3) > 1
currentSlice(3) = currentSlice(3) - 1;
else
return;
end
else
return;
end
% REMEMBER TO UPDATE APPDATA WITH NEW CURRENTSLICE
setappdata(mainfig, 'currentSlice', currentSlice);
% Clear and update relevant gca
displayAxial(handles);
case 'sagittal'
% Case is sagittal, update gca with one slice in preferred direction,
% can possibly change later to modular amount.
if event_data == -1
if currentSlice(1) <= size(img_data,1)
currentSlice(1) = currentSlice(1) + 1;
else
return;
end
elseif event_data == 1;
if currentSlice(1) > 1
currentSlice(1) = currentSlice(1) - 1;
else
return;
end
else
return;
end
% REMEMBER TO UPDATE GCF WITH NEW CURRENTSLICE
setappdata(mainfig, 'currentSlice', currentSlice);
% Clear and update relevant gca
displaySagittal(handles);
case 'coronal'
% Case is coronal, update gca with one slice in preferred direction,
% can possibly change later to modular amount.
if event_data == -1
if currentSlice(2) <= size(img_data,2)
currentSlice(2) = currentSlice(2) + 1;
else
return;
end
elseif event_data == 1;
if currentSlice(2) <= size(img_data,2)
currentSlice(2) = currentSlice(2) - 1;
else
return;
end
else
return;
end
% REMEMBER TO UPDATE GCF WITH NEW CURRENTSLICE
setappdata(mainfig, 'currentSlice', currentSlice);
% Clear and update relevant gca
displayCoronal(handles);
otherwise
return;
end
if get(handles.inclCrosshairsChxbox, 'Value') == 1;
drawCrosshairs(handles);
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment