diff --git a/src/matlab/+D3d/+UI/Controls.m b/src/matlab/+D3d/+UI/Controls.m
index 3c4cc9606e40f81daa35ae7198d15134b2c7e39e..0135fa915d786dee735a53787e09a7b4d1e0012f 100644
--- a/src/matlab/+D3d/+UI/Controls.m
+++ b/src/matlab/+D3d/+UI/Controls.m
@@ -299,13 +299,7 @@ end
 
 % --- Executes on button press in cb_visible.
 function cb_visible_Callback(hObject, eventdata, handles)
-[imageData, colors, channelData] = D3d.UI.Ctrl.GetUserData();
-
-chan = get(handles.m_channelPicker,'Value');
-channelData(chan).visible = get(handles.cb_visible,'Value');
-
-D3d.UI.Ctrl.SetUserData(imageData,colors,channelData);
-D3d.UI.Ctrl.PlotTransferFunctions();
+    D3d.UI.ToggleChannel(get(handles.m_channelPicker,'Value'),get(handles.cb_visible,'Value'));
 end
 
 % --- Executes on button press in cb_textureLighting.
diff --git a/src/matlab/+D3d/+UI/ToggleChannel.m b/src/matlab/+D3d/+UI/ToggleChannel.m
new file mode 100644
index 0000000000000000000000000000000000000000..0404b5526f721c872cc83522f43d166bca46c845
--- /dev/null
+++ b/src/matlab/+D3d/+UI/ToggleChannel.m
@@ -0,0 +1,8 @@
+function ToggleChannel(chan,visible)
+    [imageData, colors, channelData] = D3d.UI.Ctrl.GetUserData();
+
+    channelData(chan).visible = visible;
+
+    D3d.UI.Ctrl.SetUserData(imageData,colors,channelData);
+    D3d.UI.Ctrl.PlotTransferFunctions();
+end