slicer / slicerjupyter Goto Github PK
View Code? Open in Web Editor NEWExtension for 3D Slicer that allows the application to be used from Jupyter notebook
License: MIT License
Extension for 3D Slicer that allows the application to be used from Jupyter notebook
License: MIT License
Hi,
I was hoping to use Vscode as it had support for Jupyter notebooks. I have been unable to get it to place nicely however and the kernel is recognized but refuses to start.
attempt to switch to slicer kernel but fails silently
The kernel starts correctly when connecting to the browser based jupyter notebooks. Would you have any suggestions as to what i would need to modify to get Vscode to start the kernel?
Thanks for creating this wonderful extension!
I'm eager to try out new stuff in 4.13 - meanwhile SlicerJupyter has become indispensable. Hope you get a chance to look into the compilation issues on Linux I suspect are at fault because the extension doesn't show up in the extensions manager anymore.
thanks
Hi! I would like to use SlicerJupyter to display images from jupyter notebook, have them labeled in the editor in Slicer and save the mask as .tiff also using commands from python.
I cannot seem to find documentation on what functions I should use to have it work.
Thanks
Current version is from August 6 2018, see weidai11/cryptopp@2ec9c99 and
SlicerJupyter/SuperBuild/External_cryptopp.cmake
Lines 21 to 32 in 18f1346
Considering python-packages
project name is fairly generic and could conflict with other extension install python packages, we should rename it to python-slicerjupyter-requirements
. This will be done after the previous pull-request has been integrated. It is tracked by this issue:
Hello! I am trying to display slice views with a particular markup control point.
I am using this function:
slicer.modules.markups.logic().JumpSlicesToLocation(ras[0], ras[1], ras[2], True)
The function runs without any problems in the Jupiter notebook but when I am trying to display it (slicernb.ViewDisplay('FourUp')) there are no changes.
If I run the function in Slicer's python console, it jumps to the location right away.
How could I get this to display in the notebook?
Instead of asking the user to explicitly call jupyter-kernelspec install
, we should ask the user to select a python installation.
The Slicer module would then take care of:
venv
for regular python, and conda env
for anaconda ...)jupyter
Slicer kernel should be named using a convention like this one: Slicer X.Y.Z[-YYYY-MM-DD-rNNNN]
Build tree and install tree should be supported
It would be more convenient if we could run the jupyter notebook directly out of slicer. It would mean we could automate some of the installation steps to make it easier to use for training purposes (other modes could still be supported for developers)
I was able to do pip_install('jupyter')
inside slicer, but when I tried to run the notebook it fails with a missing python package, even though it should be a standard part of the Slicer python package (https://docs.python.org/3.6/library/wsgiref.html).
$ /Volumes/SSD2T/ssdtmp/Slicer.app/Contents/bin/PythonSlicer /Volumes/SSD2T/ssdtmp/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/jupyter.py notebook
Traceback (most recent call last):
File "/Volumes/SSD2T/ssdtmp/Slicer.app/Contents/lib/Python/bin/jupyter-notebook", line 5, in <module>
from notebook.notebookapp import main
File "/Volumes/SSD2T/ssdtmp/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/notebook/notebookapp.py", line 76, in <module>
from .base.handlers import Template404, RedirectWithParams
File "/Volumes/SSD2T/ssdtmp/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/notebook/base/handlers.py", line 24, in <module>
import prometheus_client
File "/Volumes/SSD2T/ssdtmp/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/prometheus_client/__init__.py", line 3, in <module>
from . import exposition
File "/Volumes/SSD2T/ssdtmp/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/prometheus_client/exposition.py", line 11, in <module>
from wsgiref.simple_server import make_server, WSGIRequestHandler
ModuleNotFoundError: No module named 'wsgiref'
Binder can run Jupyter notebooks interactively using docker containers. All we would need to do is to describe a docker container in the root of a repository that contains notebooks (see for example this)
When Jupyter kernel is connected, Slicer uses 100% CPU usage (at least on Windows). This does not impact performance (it only uses idle CPU cycles) but certainly not nice.
It is due to how QSocketNotifier is set up.
If we put a delay in the poll, as it was done earlier then CPU usage is low but GUI becomes much less responsive (slice browsing is slow, etc.).
It may be possible that the problem can be fixed by initializing the socket differently and making sure all available data is read as described here.
I make a new notebook, connect it to the 4.11 kernel that I installed earlier from within the SlicerJupyter module. Then I put in a few lines of code that makes a box.
If the last line of the cell happens to be of type <class 'MRMLCorePython.vtkMRMLModelNode'>
, then the output will be shown rendered in the notebook.
That's cool, but the managed Slicer instance runs into a major crisis. The problem is shown below, where I've defined a box. The box is shown alright in the notebook, but a black rectangle is scraped out of the window of the Slicer instance, which then generally refuse to work: nothing in that window is redrawn correctly afterwards. Example of kernel file is also enclosed. The Linux console output is:
Warning: In /work/Stable/Slicer-0/Libs/MRML/Core/vtkMRMLDisplayNode.cxx, line 831
vtkMRMLModelDisplayNode (0x43e88a0): SetSliceIntersectionVisibility method is deprecated, please use SetVisibility2D instead
Before that, I see after restarting:
[I 13:02:25.720 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
kernel a45bc8c0-9fa5-40fc-8c1b-37f4b20c1bb1 restarted
Switch to module: "Welcome"
Loading Slicer RC file [/home/fusentasticus/.slicerrc.py]
Jupyter connection file: [/home/fusentasticus/.local/share/jupyter/runtime/kernel-a45bc8c0-9fa5-40fc-8c1b-37f4b20c1bb1.json]
Starting Jupyter kernel server
Run with XEUS 0.24.1
The Slicer version is 4.11.20200930 (new release), running on Ubuntu 20.04.
{
"shell_port": 57603,
"iopub_port": 53115,
"stdin_port": 41961,
"control_port": 34089,
"hb_port": 60745,
"ip": "127.0.0.1",
"key": "703c2a32-e40336538922c79555486e35",
"transport": "tcp",
"signature_scheme": "hmac-sha256",
"kernel_name": "slicer-4.11"
}
slicer.util._executePythonModule('jupyter', ['notebook', 'list'])
Fatal Python error: initsite: Failed to import the site module
Traceback (most recent call last):
File "/Applications/Slicer.app/Contents/bin/../lib/Python/lib/python3.6/site.py", line 553, in <module>
main()
File "/Applications/Slicer.app/Contents/bin/../lib/Python/lib/python3.6/site.py", line 539, in main
known_paths = addusersitepackages(known_paths)
File "/Applications/Slicer.app/Contents/bin/../lib/Python/lib/python3.6/site.py", line 282, in addusersitepackages
user_site = getusersitepackages()
File "/Applications/Slicer.app/Contents/bin/../lib/Python/lib/python3.6/site.py", line 258, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/Applications/Slicer.app/Contents/bin/../lib/Python/lib/python3.6/site.py", line 248, in getuserbase
USER_BASE = get_config_var('userbase')
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/sysconfig.py", line 601, in get_config_var
return get_config_vars().get(name)
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/sysconfig.py", line 550, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/sysconfig.py", line 421, in _init_posix
_temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
ModuleNotFoundError: No module named '_sysconfigdata_m_darwin_darwin'
---------------------------------------------------------------------------
CalledProcessError Traceback (most recent call last)
In [10]:
Line 1:
File /Applications/Slicer.app/Contents/bin/Python/slicer/util.py, in _executePythonModule:
Line 2851: logProcessOutput(proc)
File /Applications/Slicer.app/Contents/bin/Python/slicer/util.py, in logProcessOutput:
Line 2820: raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
CalledProcessError: Command '['/Applications/Slicer.app/Contents/bin/../bin/PythonSlicer', '-m', 'jupyter', 'notebook', 'list']' returned non-zero exit status 1.
Auto-complete does not work in Slicer-4.11, because "jedi" Python package is not found.
Jedi is bundled in the extension package, but Slicer does not add the site-packages subfolder of the extension to PYTHONPATH - see result of this command on Slicer-4.10 and Slicer-4.11:
print('\n'.join(os.environ['PYTHONPATH'].split(os.pathsep)))
If I manually modify SlicerLauncherSettings.ini
by adding the site-packages folder then auto-completion works well.
[PYTHONPATH]
...
12\path=c:/Users/andra/appdata/Roaming/NA-MIC/Extensions-28482/SlicerJupyter/Lib/site-packages
...
Under Option 2, I don't understand the purpose of bullets 3, 4, and 5. Why tell the user to install python and jupyter when ultimately it will be the Slicer-provided python interpreter and Slicer-provided jupyter kernel that are used?
I am raising this issue because after following the instructions I thought SlicerJupyter was using the environment I installed and was frustrated when it couldn't access my packages. If I now understand correctly, then these instructions are just a way to give the user a GUI to manage their notebooks. If the user already has a Python env with jupyter installed -- which is probably true for everyone interested in SlicerJupyter -- then couldn't they simply use that?
The command to install the kernel copied to clipboard can be changed to {path_to_Slicer}/bin/PythonSlicer -m jupyter kernelspec install {...}
and the user can be told to run it from any console. This can appear earlier in the instructions.
Then the instructions to run the jupyter notebook server could be as simple as: "Run a jupyter notebook server from one of your other Python environments like Anaconda or Jupyter Lab. If you don't have another Python environment then use ./PythonSlicer -m jupyter notebook
" (except I couldn't get the latter to work! See below).
{And then continue with instructions on how to open a notebook with the correct kernel}
I admit my understanding of Python interpreters, jupyter kernels, jupyter notebook server and their interactions is rather basic. There's a good chance I'm misunderstanding how this is supposed to work.
I couldn't get ./PythonSlicer -m jupyter notebook
to work. It returned an esoteric error:
File "/media/chad/STORE/Tools/Neurophys/Slicer-4.11.0-2020-06-06-linux-amd64/lib/Python/lib/python3.6/site-packages/prometheus_client/exposition.py", line 9, in
from wsgiref.simple_server import make_server, WSGIServer, WSGIRequestHandler
ModuleNotFoundError: No module named 'wsgiref.simple_server'
This returned no relevant search results. 'wsgiref.simple_server' is a core Python module so I'm guessing that PythonSlicer doesn't ship with a full set of modules. Maybe it should include the modules necessary to run jupyter server?
Running under the slicer kernel getpass echos to the notebook and I think it is caused by this issue:
jupyter-xeus/xeus-python#325
That issue says that it is solved in the latest xeus-python.
Is it possible to upgrade the version of xeus?
After creating a notebook with Slicer 4.11, the kernel dies and keeps restarting without success. Below is the log i get. During this process a new instance of 3DSlicer is opened and then closed immediately.
I tried deleting my settings folder ( .config/NA-MIC ) and reinstalling the extension as well as re-downloading 3DSlicer but same thing happens. I'm not an expert at programming so comprehensive help would be much appreciated.
platform: Slicer-4.11.20200930-linux-amd64 r29402
[I 09:38:25.441 NotebookApp] Kernel started: 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee, name: slicer-4.11
Switch to module: "Welcome"
Jupyter connection file: [/home/raouf/.local/share/jupyter/runtime/kernel-3acaca7f-c1d7-4b80-9791-3e4224e1e9ee.json]
error: [/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[I 09:38:40.443 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
Switch to module: "Welcome"
Jupyter connection file: [/home/raouf/.local/share/jupyter/runtime/kernel-3acaca7f-c1d7-4b80-9791-3e4224e1e9ee.json]
error: [/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[I 09:38:55.472 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
Switch to module: "Welcome"
Jupyter connection file: [/home/raouf/.local/share/jupyter/runtime/kernel-3acaca7f-c1d7-4b80-9791-3e4224e1e9ee.json]
error: [/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[I 09:39:10.495 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
Switch to module: "Welcome"
Jupyter connection file: [/home/raouf/.local/share/jupyter/runtime/kernel-3acaca7f-c1d7-4b80-9791-3e4224e1e9ee.json]
error: [/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[I 09:39:25.520 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
[W 09:39:25.551 NotebookApp] Timeout waiting for kernel_info reply from 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
[W 09:39:30.091 NotebookApp] Nudge: attempt 10 on kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
[W 09:39:35.122 NotebookApp] Nudge: attempt 20 on kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
Switch to module: "Welcome"
Jupyter connection file: [/home/raouf/.local/share/jupyter/runtime/kernel-3acaca7f-c1d7-4b80-9791-3e4224e1e9ee.json]
error: [/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[W 09:39:40.147 NotebookApp] Nudge: attempt 30 on kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
[I 09:39:40.532 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
WARNING:root:kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee restarted
[W 09:39:45.174 NotebookApp] Nudge: attempt 40 on kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
[W 09:39:50.203 NotebookApp] Nudge: attempt 50 on kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
Switch to module: "Welcome"
[W 09:39:55.229 NotebookApp] Nudge: attempt 60 on kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
Jupyter connection file: [/home/raouf/.local/share/jupyter/runtime/kernel-3acaca7f-c1d7-4b80-9791-3e4224e1e9ee.json]
error: [/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[I 09:39:58.544 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
WARNING:root:kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee restarted
[W 09:40:00.255 NotebookApp] Nudge: attempt 70 on kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
[W 09:40:05.283 NotebookApp] Nudge: attempt 80 on kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
[W 09:40:10.314 NotebookApp] Nudge: attempt 90 on kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
Switch to module: "Welcome"
Jupyter connection file: [/home/raouf/.local/share/jupyter/runtime/kernel-3acaca7f-c1d7-4b80-9791-3e4224e1e9ee.json]
error: [/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[I 09:40:13.572 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
WARNING:root:kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee restarted
[W 09:40:15.351 NotebookApp] Nudge: attempt 100 on kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
[W 09:40:20.380 NotebookApp] Nudge: attempt 110 on kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
[I 09:40:25.326 NotebookApp] Saving file at /Untitled Folder/Untitled5.ipynb
[W 09:40:25.406 NotebookApp] Nudge: attempt 120 on kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee
[E 09:40:25.569 NotebookApp] Uncaught exception GET /api/kernels/3acaca7f-c1d7-4b80-9791-3e4224e1e9ee/channels?session_id=90c231b255574bad9283ee221e2b03d4 (127.0.0.1)
HTTPServerRequest(protocol='http', host='localhost:8891', method='GET', uri='/api/kernels/3acaca7f-c1d7-4b80-9791-3e4224e1e9ee/channels?session_id=90c231b255574bad9283ee221e2b03d4', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/tornado/websocket.py", line 956, in _accept_connection
await open_result
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/asyncio/futures.py", line 327, in __iter__
yield self # This tells Task to wait for completion.
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
future.result()
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/asyncio/futures.py", line 243, in result
raise self._exception
tornado.util.TimeoutError: Timeout
Switch to module: "Welcome"
[W 09:40:26.603 NotebookApp] Replacing stale connection: 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee:90c231b255574bad9283ee221e2b03d4
Jupyter connection file: [/home/raouf/.local/share/jupyter/runtime/kernel-3acaca7f-c1d7-4b80-9791-3e4224e1e9ee.json]
error: [/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[I 09:40:28.608 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
WARNING:root:kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee restarted
[E 09:40:28.609 NotebookApp] KernelRestarter: restart callback <bound method ZMQChannelsHandler.on_kernel_restarted of ZMQChannelsHandler(3acaca7f-c1d7-4b80-9791-3e4224e1e9ee)> failed
Traceback (most recent call last):
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/jupyter_client/restarter.py", line 86, in _fire_callbacks
callback()
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/notebook/services/kernels/handlers.py", line 601, in on_kernel_restarted
self._send_status_message('restarting')
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/notebook/services/kernels/handlers.py", line 597, in _send_status_message
self.write_message(json.dumps(msg, default=date_default))
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/tornado/websocket.py", line 337, in write_message
raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError
Switch to module: "Welcome"
Jupyter connection file: [/home/raouf/.local/share/jupyter/runtime/kernel-3acaca7f-c1d7-4b80-9791-3e4224e1e9ee.json]
error: [/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[I 09:40:46.636 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
WARNING:root:kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee restarted
[E 09:40:46.637 NotebookApp] KernelRestarter: restart callback <bound method ZMQChannelsHandler.on_kernel_restarted of ZMQChannelsHandler(3acaca7f-c1d7-4b80-9791-3e4224e1e9ee)> failed
Traceback (most recent call last):
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/jupyter_client/restarter.py", line 86, in _fire_callbacks
callback()
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/notebook/services/kernels/handlers.py", line 601, in on_kernel_restarted
self._send_status_message('restarting')
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/notebook/services/kernels/handlers.py", line 597, in _send_status_message
self.write_message(json.dumps(msg, default=date_default))
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/tornado/websocket.py", line 337, in write_message
raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError
Switch to module: "Welcome"
Jupyter connection file: [/home/raouf/.local/share/jupyter/runtime/kernel-3acaca7f-c1d7-4b80-9791-3e4224e1e9ee.json]
error: [/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[I 09:41:04.676 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
WARNING:root:kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee restarted
[E 09:41:04.677 NotebookApp] KernelRestarter: restart callback <bound method ZMQChannelsHandler.on_kernel_restarted of ZMQChannelsHandler(3acaca7f-c1d7-4b80-9791-3e4224e1e9ee)> failed
Traceback (most recent call last):
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/jupyter_client/restarter.py", line 86, in _fire_callbacks
callback()
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/notebook/services/kernels/handlers.py", line 601, in on_kernel_restarted
self._send_status_message('restarting')
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/notebook/services/kernels/handlers.py", line 597, in _send_status_message
self.write_message(json.dumps(msg, default=date_default))
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/tornado/websocket.py", line 337, in write_message
raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError
Switch to module: "Welcome"
Jupyter connection file: [/home/raouf/.local/share/jupyter/runtime/kernel-3acaca7f-c1d7-4b80-9791-3e4224e1e9ee.json]
error: [/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[I 09:41:19.715 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
WARNING:root:kernel 3acaca7f-c1d7-4b80-9791-3e4224e1e9ee restarted
[E 09:41:19.716 NotebookApp] KernelRestarter: restart callback <bound method ZMQChannelsHandler.on_kernel_restarted of ZMQChannelsHandler(3acaca7f-c1d7-4b80-9791-3e4224e1e9ee)> failed
Traceback (most recent call last):
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/jupyter_client/restarter.py", line 86, in _fire_callbacks
callback()
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/notebook/services/kernels/handlers.py", line 601, in on_kernel_restarted
self._send_status_message('restarting')
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/notebook/services/kernels/handlers.py", line 597, in _send_status_message
self.write_message(json.dumps(msg, default=date_default))
File "/home/raouf/Documents/Tools/Slicer-4.11.20200930-linux-amd64/lib/Python/lib/python3.6/site-packages/tornado/websocket.py", line 337, in write_message
raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError
Switch to module: "Welcome"
I can successfully install the kernel after running
jupyter-kernelspec install /home/username/.config/NA-MIC/Extensions-27968/SlicerJupyter/share/Slicer-4.11/qt-loadable-modules/JupyterKernel/Slicer-4.11/ --replace --user
and I get the [InstallKernelSpec] Installed kernelspec slicer-4.11 in /home/username/.local/share/jupyter/kernels/slicer-4.11
message indicating my kernel installation is sucessful.
However, when I run the jupyter notebook I don't see the kernel, and when I run jupyter kernelspec list
I don't see the kernel there neither.
I'm using Ubuntu 16.04 and Slicer 4.11.0-2019-02-19 r27968, and anaconda virtual environment
# Update plane from fiducial points
def UpdateSlicePlane(data):
a = data
points = np.array([list(zip(*a))])[0]
# b2 = np.array([list(zip(*a))])
sliceNode = slicer.app.layoutManager().sliceWidget("Red").mrmlSliceNode()
planePosition = points.mean(axis=1)
planeNormal = np.cross(points[:,1] - points[:,0], points[:,2] - points[:,0])
planeX = points[:,1] - points[:,0]
sliceNode.SetSliceToRASByNTP(planeNormal[0], planeNormal[1], planeNormal[2],
planeX[0], planeX[1], planeX[2],
planePosition[0], planePosition[1], planePosition[2], 0)
UpdateSlicePlane(data33)
slicernb.ViewDisplay('OneUpRedSlice', center=False)
我想将图片对齐,就像这样:
I want aligne the red plane with Coordinate axis?, like that:
On Linux platforms, xeus
also requires libuuid
, which is available in all linux distributions (uuid-dev
on Debian). This package should be installed on factory machines.
Issue to collect ideas/notes for SlicerJupyter+binder.
Easy:
display()
reflect the size of the running virtual display, which is about 1/4 of the 1280x1024 screen, so they are usually much smaller than the saved image when a notebook is re-run. The “awesome” window manager I'm using can be controlled with Lua, so if this can’t be done directly in Slicer/Qt, then it could be applied to the window in a launcher script.Maybe easy:
Hard:
Speculative:
Hello! I'm new to 3D Slicer and am looking to integrate it into my jupyter notebooks, I've installed 3D slicer but can't locate SlicerJupyter in the Extension Manager.
Noting here from quick test: the macOS packaging succeeded last night after the fixes. However, the kernel doesn't run in the packaged Slicer because there is no launcher. This line needs to be changed, because launcherExecutablePath
is empty string in a packaged build for macOS:
The kernel stops responding when lldb is attached to the Slicer process on macOS. Slicer prints the following in the notebook terminal, and in a popup window:
"Slicer has caught an internal error.\n\nYou may be able to continue from this point, but results are undefined.\n\nSuggested action is to save your work and restart.\n\nIf you have a repeatable sequence of steps that causes this message, please report the issue following instructions available at http://slicer.org\n\n\nThe message detail is:\n\nException thrown in event: Interrupted system call"
It may be interesting to update to the latest xeus and use xeus-python for the SlicerJupyter
kernel.
cryptopp
for signing messages as we now use OpenSSL
which is already a dependency of Slicer.Hello,
I would like to use SlicerJupyter for a project, but I can't install the latest version.
I am using Ubuntu 20.04 and Slicer-4.11.20210226. I have tried both ways for downloading the extension:
I am only able to install SlicerJupyter on Slicer revision = 27567, which is too old for me.
What am I doing wrong? Could you help me, please?
Do you have SliceJupyter for Linux Slicer-4.11.20210226?
Many thanks for considering my request.
Followed your video, copied command to clipboard and installed on a Terminal that I launched from Notebook:
Installation went fine.
Error snapshot:
It's dying every three seconds or so.
@pieper might be able to reproduce this error.
Since our data are on the ERIS cluster, we won't be able to use public binder to run SlicerJupyter on. On the other hand, we won't have docker. So, we are left with making use of Parters Jupyter server to run SlicerJupyter on.
Factory build fails on Mac with multiple errors, including
Error copying file "libxeus.1.dylib" to "/.../SlicerJupyter-build/inner-build/_CPack_Packages/Darwin/TGZ/27269-macosx-amd64-SlicerJupyter-git2734bf9-2018-07-07/Slicer.app/Contents/lib/Slicer-4.9/libxeus.1.dylib".
See full logs here: http://slicer.cdash.org/viewBuildError.php?buildid=1315187
I borrowed much of the awesome work here in the ViewInteractiveWidget
class to create ipyvtk_simple
as a more minimal, general, and extensible version of the widget for use with any vtkRenderWindow
backend (VTK or ParaView). It would be awesome refactor this project to utilize ipyvtk_simple
for the widget and maintain it there so that the broader Jupyter VTK ecosystem can leverage the excellent work done in this project!
I can handle a PR for this, but I won't have time likely until mid-August at the earliest. I figured I'd raise the issue just so everyone is aware and if there needs to be any discussion on this work, that can happen here. cc @jcfr
Some notable changes:
vtkRenderWindow
during initipyevents
and ipywdigets
(see Kitware/ipyvtklink#3 and linked PRs)After installing the 4.10 Slicer kernel successfully (as indicated by the text within the JupyterKernel extension), I tried to select the kernel in jupyter.
It begins to start, and then gives me this error message:
Jupyter connection file: [/home/emclab/.local/share/jupyter/runtime/kernel-5c44bbb4-9b6a-4bf7-9861-bcc42feaa7eb.json]
error: [/home/emclab/Downloads/InstalledSoftware/Slicer/bin/SlicerApp-real] exit abnormally - Report the problem.
Investigating a little bit, I was also unable to run SlicerApp-real directly when navigating to it from a terminal. It does not start and exits with the error message:
./SlicerApp-real: error while loading shared libraries: libqSlicerApp.so: cannot open shared object file: No such file or directory
I'm not sure that that test means anything because I suspect I'm not meant to run SlicerApp-real directly from a command line. I am using the stable binary release downloaded off of the Slicer website today
In any case there is an error with the kernel setup and I cannot run a jupyter notebook using the Slicer kernel.
Hi Guys, I've tried to figure this one out with no success.
I am building a custom app with SlicerCAT.
The path on lines 75 and similarly below are missing the last bit with the version, looks like ${Slicer_VERSION}
is evaluating to an empty string.
xeus-python kernel supports debugging, but it it currently not supported in the Slicer kernel.
The issue is that the application hangs when the debugger is attached, because a message that comes in the control channel would need to be processed in the main thread, but Slicer processes all messages (including the ones coming from the control channel) on the main thread.
See more information here: jupyter-xeus/xeus-python#275
Note: This issue is independent of #49.
@lassoan We set up the Deep Learning with RHEL, and I downloaded Slicer version 4.10.1
I noticed that there is no SlicerJupyter extension available from the Extension Manager.
Can you take a look at that, if you find the time?
cc: @mattjolley
Hi! We are trying to integrate slicer and pytorch and some other packages. There is no way we can get PyTorch or any other package to install through the interpreter. Interestingly, the interpreter tells me that slicer runs in my base environment where I do have the packages I need, but it fails to import them.
We have installed the nightly version because we need python 3, but when trying to do.
`import pip
pip.main(['install', 'scipy']) `
We get "AttributeError: module 'pip' has no attribute 'main'".
Could anyone help?
Hi there,
first of all thanks for the jupyter notebook extension for 3DSlicer.
It allows for streamlined data processing and reproducible workflows.
Slicer kernel seems to miss autoreload extension, which is a handy feature within jupyter notebooks.
%load_ext autoreload
causes AttributeError: 'kernel.XInteractiveShell' object has no attribute 'events'
Hi everyone,
I am facing the issue of "unable to start kernel for slicer" , giving logs as
Switch to module: "Welcome"
Loading Slicer RC file [/home/sliceruser/.slicerrc.py]
Jupyter connection file: [/home/sliceruser/.local/share/jupyter/runtime/kernel-2c7279ff-433a-43c2-88d2-f15696ba54fb.json]
error: [/home/sliceruser/Slicer/bin/SlicerApp-real] exit abnormally - Report the problem.
I am running docker image for 3D slicer
docker run -p 8888:8888 -p49053:49053 -v "$PWD":/home/sliceruser/work --rm -ti lassoan/slicer-notebook:2021-10-15-b3077c2
It works fine on my local machine (windows) and I am able to use 3D slicer via Jupiter notebook.
However, its not working on my remote VM (Ubuntu 18.04). Whenever, I try to open Slicer in notebook, it prompts message "kernel appear to die and restart automatically" but never succeed to start.
Any guidance would be great.
Here is image attached of logs
Thanks
Build fails on Windows (on the second run, it succeeds).
The error message refers to ipython requiring pygments and jedi, which is odd, because we don't need ipython and we install both pygments and jedi.
python-jedi.log
Creating directories for 'python-jedi'
Building Custom Rule C:/D/SlicerJupyter/CMakeLists.txt
No download step for 'python-jedi'
No update step for 'python-jedi'
No patch step for 'python-jedi'
Generate version-python-jedi.txt and license-python-jedi.txt
fatal: not a git repository (or any of the parent directories): .git
CMake Warning (dev) at C:/D/SlicerJupyter_R/CMakeFiles/python-jedi-generate-project-description.cmake:69 (message):
python-jedi: Could not find a license file
This warning is for project developers. Use -Wno-dev to suppress it.
No configure step for 'python-jedi'
No build step for 'python-jedi'
Performing install step for 'python-jedi'
Collecting jedi==0.17.0
Using cached jedi-0.17.0-py2.py3-none-any.whl (1.1 MB)
Collecting parso>=0.7.0
Using cached parso-0.7.0-py2.py3-none-any.whl (100 kB)
CUSTOMBUILD : error : ipython 7.14.0 requires pygments, which is not installed.
Installing collected packages: parso, jedi
Successfully installed jedi-0.17.0 parso-0.7.0
CUSTOMBUILD : warning : You are using pip version 20.0.2; however, version 20.1 is available.
You should consider upgrading via the 'C:\D\S4R\python-install\bin\python.exe -m pip install --upgrade pip' command.
Completed 'python-jedi'
python-pygments.log
Creating directories for 'python-pygments'
Building Custom Rule C:/D/SlicerJupyter/CMakeLists.txt
No download step for 'python-pygments'
No update step for 'python-pygments'
No patch step for 'python-pygments'
Generate version-python-pygments.txt and license-python-pygments.txt
fatal: not a git repository (or any of the parent directories): .git
CMake Warning (dev) at C:/D/SlicerJupyter_R/CMakeFiles/python-pygments-generate-project-description.cmake:69 (message):
python-pygments: Could not find a license file
This warning is for project developers. Use -Wno-dev to suppress it.
No configure step for 'python-pygments'
No build step for 'python-pygments'
Performing install step for 'python-pygments'
Collecting pygments==2.3.1
Using cached Pygments-2.3.1-py2.py3-none-any.whl (849 kB)
CUSTOMBUILD : error : ipython 7.14.0 requires jedi>=0.10, which is not installed.
Installing collected packages: pygments
CUSTOMBUILD : warning : The script pygmentize.exe is installed in 'C:\D\SlicerJupyter_R\python-packages-install\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pygments-2.3.1
CUSTOMBUILD : warning : You are using pip version 20.0.2; however, version 20.1 is available.
You should consider upgrading via the 'C:\D\S4R\python-install\bin\python.exe -m pip install --upgrade pip' command.
Completed 'python-pygments'
The goal is to remove code duplication from this project by generalizing changes implemented in xSlicer
classes and update xeus
project:
xserver_impl.hpp
publiclyxserver_impl::poll_impl
functionxkernel::start()
to keep track of object in ivar and support non-blocking caseI am getting the following error message when trying to install the Slicer kernel from SlicerJupyter extension in Slicer.
File kernel-template.json
doesn't exist in the extension directory.
[DEBUG][Qt] 05.11.2018 11:52:47 [] (unknown:0) - Switch to module: "JupyterKernel"
[WARNING][Qt] 05.11.2018 11:52:48 [] (unknown:0) - QIODevice::read (QFile, "/Applications/Slicer_4.11_nightly.app/Contents/Extensions-27534/SlicerJupyter/share/Slicer-4.11/qt-loadable-modules/JupyterKernel/Slicer-4.11/kernel-template.json"): device not open
[WARNING][Qt] 05.11.2018 11:52:48 [] (unknown:0) - virtual bool qSlicerJupyterKernelModule::installSlicerKernel(QString) failed: time out while launching process "/jupyter-kernelspec"
[CRITICAL][FD] 05.11.2018 12:01:46 [] (unknown:0) - objc[15905]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fffa0f27c90) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x1219c9cd8). One of the two will be used. Which one is undefined.
[WARNING][Qt] 05.11.2018 12:04:04 [] (unknown:0) - QIODevice::read (QFile, "/Applications/Slicer_4.11_nightly.app/Contents/Extensions-27534/SlicerJupyter/share/Slicer-4.11/qt-loadable-modules/JupyterKernel/Slicer-4.11/kernel-template.json"): device not open
[WARNING][Qt] 05.11.2018 12:04:04 [] (unknown:0) - virtual bool qSlicerJupyterKernelModule::installSlicerKernel(QString) failed: time out while launching process "/usr/local/bin/python/jupyter-kernelspec"
I installed SlicerJupyter from the extension manager.
Try how https://github.com/InsightSoftwareConsortium/itkwidgets can be used in Slicer's environment. They could be very useful for quick client-side visualization.
If user presses Tab key, auto-completion should be performed. Currently it just performs some hardcoded character replacement.
xSlicerInterpreter::complete_request_impl needs to be implemented properly. Probably the Python console needs to provide auto-complete feature, which this interpreter class can use.
Hi,
I added SlicerJupyter to SlicerCAT and I was able to build it but when I run CPack I get an error:
...
CPack: - Run preinstall target for: CTK
CPack: - Install project: CTK []
CPack: - Run preinstall target for: Slicer
CPack: - Install project: Slicer []
CMake Error at ~/Documents/Colada/d/Slicer-build/E/SlicerJupyter/cmake_install.cmake:50 (file):
file INSTALL cannot find "///proc/sys/fs/binfmt_misc/register": Permission
denied.
GIT Tag: b282a2c
Ubuntu 20.04
I am attempting to run slicer and Jupyter on my own machine. I installed SlicerJupyter as instructed
and installed the kernel per the instructions and by copying the command supplied by the SlicerJupyter module.
I am able to select the Slicer kernel as expected for a new notebook.
As the notebook loads, Slicer is started (as expected), however after about 10 seconds the notebook loses connection to the kernel, slicer shuts down and then Jupyter attempts to re-connect which re-launches slicer, and the process fails again.
The only output in the terminal that I get (where I am running jupyter notebook
from) is below:
Switch to module: "Welcome"
starting storescp process
(u'Starting /opt/Slicer/bin/../bin/storescp with ', ['11112', '--accept-all', '--output-directory', u'/home/matt/Documents/SlicerDICOMDatabase/incoming', '--exec-sync', '--exec-on-reception', u'/opt/Slicer/bin/../bin/dcmdump --load-short --print-short --print-filename --search PatientName "/home/matt/Documents/SlicerDICOMDatabase/incoming/#f"'])
process /opt/Slicer/bin/../bin/storescp now in state Starting
process /opt/Slicer/bin/../bin/storescp now in state Running
Jupyter connection file: [/home/matt/.local/share/jupyter/runtime/kernel-d8fe4d3d-7538-4a65-8d45-366fb853a0a4.json]
[W 15:47:56.001 NotebookApp] Replacing stale connection: d8fe4d3d-7538-4a65-8d45-366fb853a0a4:e02dc0d014cf4a278ff809dd32662747
Please let me know if I am missing something, or if I should install any software differently
Pressing Shift+Tab brings up the inspector window in the notebook, which shows documentation of the function where the cursor is at. Input code must be parsed to correctly identify the symbol that documentation should be displayed for.
Example:
Placing the cursor in getprofile shows its documentation (correctly ignores previous lines):
Placing the cursor after getrecursionlimit's opening bracket, it shows documentation of getrecusrionlimit(correctly ignores getprofile symbol):
This is the input that xeus receives:
code: a=5
b=10
sys.getprofile(sys.getrecursionlimit()
cursor_pos: 24
detail_level: 0```
From @jcfr: "At some point I got an already used connection message ... but I am not able to reproduce it yet."
When user requests a kernel restart or Jupyter determines that the kernel is dead then, Jupyter sends a server stop request to Slicer. If Slicer is busy (in the middle of a long computation) then Jupyter kills the process - which is actually just the launcher, so not SlicerApp-real keeps running, still using the server port.
Maybe the kernelspec could be changed so that SlicerApp-real is launched directly?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.