GithubHelp home page GithubHelp logo

slicertorchio's Issues

Add missing transforms

๐Ÿš€ Feature
Add all the transforms of torchio to Slicer.

Motivation
Slicer is very useful for testing/visualization.

Can't find slicerrc.py

Thanks for sharing this work. After downloading 3D slicer on ubuntu 18, I could not find ~/.slicerrc.py to modify it. Can you please clarify how I can install this extension?

Thanks in advance.

Tooltips are truncated

Screen Shot 2020-06-21 at 13 20 49

Whereas the full docs say:

Tuple :math:(a, b) defining the scaling
magnitude. The scaling values along each dimension are
:math:(s_1, s_2, s_3), where :math:s_i \sim \mathcal{U}(a, b).
For example, using scales=(0.5, 0.5) will zoom out the image,
making the objects inside look twice as small while preserving
the physical size and position of the image.

Does not work with GPU-enabled PyTorch

๐Ÿ›Bug
I pip-installed torch within Slicer's Python interpreter with parameters torch==1.9.0+cu102 torchvision==0.10.0+cu102 torchaudio===0.9.0 -f https://download.pytorch.org/whl/torch_stable.html, the same way as I did in a regular install. Trying to switch to the TorchIOTransforms module results in a hang, followed by a crash.

To reproduce

Installed the extension, try to open it, click cancel on the "install Pytorch" prompt, install it manually as above, try to open the extension again, again click cancel and install torchio myself.

Expected behavior

When I try to switch to the module, the extension's GUI shows up.

Actual behavior

When I try to switch to the module, Slicer's GUI locks up, then after maybe 10-20 seconds exits without a message.

Slicer version

4.13.0-2021-06-28 r30015 / 1807944

Error loading torchio extension

๐Ÿ›Bug
Error loading torchio extension

To reproduce

I installed slicer and installed torchio extension from the extension manager

Expected behavior

Torchio extension loads on starting slicer

Actual behavior

Torchio extension does not load on starting slicer

  File "<string>", line 1, in <module>
  File "/home/reasat/Slicer-4.11.20210226-linux-amd64/lib/Python/lib/python3.6/imp.py", line 170, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 618, in _exec
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/reasat/Slicer-4.11.20210226-linux-amd64/NA-MIC/Extensions-29738/TorchIO/lib/Slicer-4.11/qt-scripted-modules/TorchIOModule.py", line 15, in <module>
    import PyTorchUtils
ModuleNotFoundError: No module named 'PyTorchUtils'
loadSourceAsModule - Failed to load file "/home/reasat/Slicer-4.11.20210226-linux-amd64/NA-MIC/Extensions-29738/TorchIO/lib/Slicer-4.11/qt-scripted-modules/TorchIOModule.py"  as module "TorchIOModule" !
Fail to instantiate module  "TorchIOModule"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/reasat/Slicer-4.11.20210226-linux-amd64/lib/Python/lib/python3.6/imp.py", line 170, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 618, in _exec
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/reasat/Slicer-4.11.20210226-linux-amd64/NA-MIC/Extensions-29738/TorchIO/lib/Slicer-4.11/qt-scripted-modules/TorchIOTransforms.py", line 19, in <module>
    from TorchIOModule import TorchIOModuleLogic
ImportError: cannot import name 'TorchIOModuleLogic'
loadSourceAsModule - Failed to load file "/home/reasat/Slicer-4.11.20210226-linux-amd64/NA-MIC/Extensions-29738/TorchIO/lib/Slicer-4.11/qt-scripted-modules/TorchIOTransforms.py"  as module "TorchIOTransforms" !
Fail to instantiate module  "TorchIOTransforms"
The following modules failed to be instantiated:
   TorchIOModule
   TorchIOTransforms
Switch to module:  "Welcome"

Slicer version
4.11.20210226 r29738 / 7a593c8

AttributeError: 'Tensor' object has no attribute 'astype'

log ๏ผš

TorchIO returned the error: Traceback (most recent call last):
File "/home/ubuntu/.config/NA-MIC/Extensions-29402/TorchIO/lib/Slicer-4.11/qt-scripted-modules/TorchIOTransforms.py", line 201, in onApplyButton
outputImage = self.currentTransform(inputVolumeNode, outputVolumeNode)
File "/home/ubuntu/.config/NA-MIC/Extensions-29402/TorchIO/lib/Slicer-4.11/qt-scripted-modules/TorchIOTransformsLib/Transform.py", line 119, in call
tensor = torch.from_numpy(data.astype(np.float32)) # why do I need this? Open a TorchIO issue?
AttributeError: 'Tensor' object has no attribute 'astype'

Transform kwargs:
{'scales': (1.79, 1.99), 'degrees': (-180.0, 180.0), 'translation': (14.5, 34.5), 'isotropic': True, 'image_interpolation': 'gaussian', 'default_pad_value': 'minimum'}

Can you help me๏ผŸ

Type error when converting to torch Tensor

Hi there, I'm running into an issue when applying any transform through your extension. I have posted version info and python console output below. Thanks

3DSlicer version: 4.11.20200930 r29402 / 002be18
Python version: 3.6.7

Slicer python output:

Transform kwargs:
{'num_control_points': (7, 7, 7), 'max_displacement': (7.5, 7.5, 7.5), 'locked_borders': 2, 'image_interpolation': 'linear'}
Transform args: {'scales': (0.8, 1.2000000000000002), 'degrees': (-10.0, 10.0), 'translation': (0.0, 0.0), 'isotropic': False, 'image_interpolation': 'linear', 'default_pad_value': 'minimum'}
TorchIO returned the error: Traceback (most recent call last):
File "C:/Users/BACLARK/AppData/Roaming/NA-MIC/Extensions-29402/TorchIO/lib/Slicer-4.11/qt-scripted-modules/TorchIOTransforms.py", line 201, in onApplyButton
outputImage = self.currentTransform(inputVolumeNode, outputVolumeNode)
File "C:\Users\BACLARK\AppData\Roaming\NA-MIC\Extensions-29402\TorchIO\lib\Slicer-4.11\qt-scripted-modules\TorchIOTransformsLib\Transform.py", line 118, in call
data, affine = torchio.io.sitk_to_nib(image)
File "C:\Users\BACLARK\AppData\Local\NA-MIC\Slicer 4.11.20200930\lib\Python\Lib\site-packages\torchio\data\io.py", line 285, in sitk_to_nib
data = ensure_4d(data, num_spatial_dims=input_spatial_dims)
File "C:\Users\BACLARK\AppData\Local\NA-MIC\Slicer 4.11.20200930\lib\Python\Lib\site-packages\torchio\data\io.py", line 313, in ensure_4d
tensor = torch.as_tensor(tensor)
TypeError: can't convert np.ndarray of type numpy.uint16. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.

Paths in README

I noticed the paths in the README are not up to date anymore

I had to change it to:

from pathlib import Path

modulePath = Path('~/git/SlicerTorchIO/TorchIOTransforms/TorchIOTransforms.py').expanduser()
moduleFactory = slicer.app.moduleManager().factoryManager()
moduleFactory.registerModule(qt.QFileInfo(str(modulePath)))
moduleFactory.loadModules([modulePath.stem])

Also I could not run this in using Slicer 4.10.2 because that version uses Python2. I downloaded Slicer 4.13.0, which uses Python3, but I get the following error:

Requirement already satisfied: six in ./lib/Python/lib/python3.6/site-packages (from packaging>=14.3->nibabel->torchio) (1.15.0)
TorchIO was installed successfully
Traceback (most recent call last):
  File "/home/derk/SlicerTorchIO/TorchIOTransforms/TorchIOTransforms.py", line 266, in checkTorchIO
    import torchio
  File "/home/derk/Downloads/Slicer-4.13.0-2020-11-25-linux-amd64/lib/Python/lib/python3.6/site-packages/torchio/__init__.py", line 11, in <module>
    from .transforms import *  # noqa: F401, F403
  File "/home/derk/Downloads/Slicer-4.13.0-2020-11-25-linux-amd64/lib/Python/lib/python3.6/site-packages/torchio/transforms/__init__.py", line 1, in <module>
    from .transform import Transform
  File "/home/derk/Downloads/Slicer-4.13.0-2020-11-25-linux-amd64/lib/Python/lib/python3.6/site-packages/torchio/transforms/transform.py", line 13, in <module>
    from ..data.subject import Subject
  File "/home/derk/Downloads/Slicer-4.13.0-2020-11-25-linux-amd64/lib/Python/lib/python3.6/site-packages/torchio/data/__init__.py", line 1, in <module>
    from .queue import Queue
  File "/home/derk/Downloads/Slicer-4.13.0-2020-11-25-linux-amd64/lib/Python/lib/python3.6/site-packages/torchio/data/queue.py", line 9, in <module>
    from .subject import Subject
  File "/home/derk/Downloads/Slicer-4.13.0-2020-11-25-linux-amd64/lib/Python/lib/python3.6/site-packages/torchio/data/subject.py", line 5, in <module>
    from .image import Image
  File "/home/derk/Downloads/Slicer-4.13.0-2020-11-25-linux-amd64/lib/Python/lib/python3.6/site-packages/torchio/data/image.py", line 8, in <module>
    from PIL import Image as ImagePIL
  File "/home/derk/Downloads/Slicer-4.13.0-2020-11-25-linux-amd64/lib/Python/lib/python3.6/site-packages/PIL/Image.py", line 94, in <module>
    from . import _imaging as core
ImportError: /home/derk/Downloads/Slicer-4.13.0-2020-11-25-linux-amd64/lib/Python/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-x86_64-linux-gnu.so: ELF load command address/offset not properly aligned

Any ideas? Or should I use a different Slicer version?

Traceback in TorchIOTransforms testing due to missing attribute

๐Ÿ›Bug
There doesn't appear to be a pipInstallTorch or pipInstallTorchIO in the TorchIOTransformsLogic class as discovered in factory build test https://slicer.cdash.org/test/19799012. @fepegar These were removed in ec1274a. There instead appears to be a installTorchIO available?

slicer.mrmlScene.Clear(0)
logic = TorchIOTransformsLogic()
logic.pipInstallTorch(showDialog=False)
logic.pipInstallTorchIO(showDialog=False)

======================================================================
ERROR: test_TorchIOTransforms (TorchIOTransforms.TorchIOTransformsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/work/Preview/S-0-E-b/TorchIO-build/lib/Slicer-4.13/qt-scripted-modules/TorchIOTransforms.py", line 244, in setUp
    logic.pipInstallTorch(showDialog=False)
AttributeError: 'TorchIOTransformsLogic' object has no attribute 'pipInstallTorch'

Slicer version

Slicer-4.13.0-2021-10-19

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.