Giter Site home page Giter Site logo

lassoan / slicerelastix Goto Github PK

View Code? Open in Web Editor NEW
46.0 7.0 28.0 2.77 MB

This extension makes available Elastix medical image registration toolkit (http://elastix.isi.uu.nl/) available in Slicer.

License: MIT License

CMake 20.82% Python 79.18%
3d-slicer-extension

slicerelastix's Introduction

SlicerElastix

This extension makes available Elastix medical image registration toolkit (https://elastix.lumc.nl) available in Slicer.

Installation

  • Download and install latest stable release or a recent nightly release of 3D Slicer (https://download.slicer.org).
  • Start 3D Slicer application, open the Extension Manager (menu: View / Extension manager)
  • Install SlicerElastix extension (in Registration category)

Register two volumes

  • Start 3D Slicer
  • Load your volumes (for example: switch to SampleData module and load MRBrainTumor1 and MRBrainTumor2 images)
  • Switch to General registration (Elastix) module (in Registration category)
  • Select Fixed volume (for example: MRBrainTumor1)
  • Select Moving volume (this volume will be resampled to match voxels of the Fixed volume; for example: MRBrainTumor2)
  • Select Preset: generic (all) performs deformable registration; generic rigid (all) performs rigid registration
  • Select "Create new Volume" for Output volume (this will be the resampled moving volume)
  • Select "Create new Transform" if later you want to visualize the displacement field or apply the transform to other nodes (points, surfaces, other volumes)
  • Click Apply button and wait a couple of minutes

Visualize and save results

  • To compare Fixed volume with Output volume (registered moving volume): set Fixed volume as Foreground volume in slice viewers and fade between the Output volume and Foreground volume to see how well they are aligned.
  • To display displacement field: in Transforms module, select the Output transform and in Display section enable visualization in slice and/or 3D views.
  • To apply transforms to other nodes: use Transforms module (or in Data module / Transform hierarchy tab: drag-and-drop nodes under the Output transform).
  • To save Output volume or transform, select menu: File / Save.

Customize registration parameters

  • Click Show database folder in Advanced section, which will open the tolder that contains all registration preset parameter files
  • Edit the parameter set database file (ElastixParameterSetDatabase.xml) to edit or add a new preset (each ParameterSet element defines one preset)
  • To modify parameters of a registration step, edit the corresponding .txt parameter file

slicerelastix's People

Contributors

bishopwolf avatar che85 avatar cpinter avatar jcfr avatar koegl avatar lassoan avatar pcarnah avatar pieper avatar simonoxen avatar sunderlandkyl avatar surgicaltechlab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

slicerelastix's Issues

Is generic rigid preset actually rigid?

Hello Andras!
First of all, thanks for the great work!
I have a question regarding the elastix generic rigid preset - it looks to me that both in slicer3d and in python when I use this preset the output volume has 1x1x1mm spacing. Does that mean that this registration is not rigid then?

Thanks!

Registration does not complete if volume is not selected

If only a transform is selected as output, the registration fails.

image

Traceback (most recent call last):
  File "C:/Users/pinter/AppData/Roaming/NA-MIC/Extensions-27501/SlicerElastix/lib/Slicer-4.10/qt-scripted-modules/Elastix.py", line 327, in onApplyButton
    movingVolumeMaskNode = self.movingVolumeMaskSelector.currentNode())
  File "C:/Users/pinter/AppData/Roaming/NA-MIC/Extensions-27501/SlicerElastix/lib/Slicer-4.10/qt-scripted-modules/Elastix.py", line 591, in registerVolumes
    self.logProcessOutput(tp)
  File "C:/Users/pinter/AppData/Roaming/NA-MIC/Extensions-27501/SlicerElastix/lib/Slicer-4.10/qt-scripted-modules/Elastix.py", line 519, in logProcessOutput
    raise subprocess.CalledProcessError(return_code, "elastix")
CalledProcessError: Command 'elastix' returned non-zero exit status -1

elxInvertTransform

Hi Andras,

Could you please add elxInvertTransform to the binaries?

my extension uses elastix (I am preparing to upload it next week) and I a planning to add your extension as a dependency instead of adding elastix binaries to my extension.

Failed to compute results. Command 'elastix' died with <Signals.SIGABRT: 6>.

Have this issue on macbook air 15inch M2 (Macos 14.0). Please Help!

Details:
`Traceback (most recent call last):
File “/Applications/Slicer.app/Contents/bin/Python/slicer/util.py”, line 3146, in tryWithErrorDisplay
yield
File “/Applications/Slicer.app/Contents/Extensions-32158/SlicerElastix/lib/Slicer-5.5/qt-scripted-modules/Elastix.py”, line 241, in onApplyButton
self.logic.registerVolumesUsingParameterNode(self._parameterNode)
File “/Applications/Slicer.app/Contents/Extensions-32158/SlicerElastix/lib/Slicer-5.5/qt-scripted-modules/Elastix.py”, line 518, in registerVolumesUsingParameterNode
self.registerVolumes(
File “/Applications/Slicer.app/Contents/Extensions-32158/SlicerElastix/lib/Slicer-5.5/qt-scripted-modules/Elastix.py”, line 564, in registerVolumes
self.logProcessOutput(elastixProcess)
File “/Applications/Slicer.app/Contents/Extensions-32158/SlicerElastix/lib/Slicer-5.5/qt-scripted-modules/Elastix.py”, line 499, in logProcessOutput
raise subprocess.CalledProcessError(return_code, “elastix”)
subprocess.CalledProcessError: Command ‘elastix’ died with <Signals.SIGABRT: 6>.

Elastix not found on Mac

Installed SlicerElastix extension but it failed to find elastix.

Setting the path manually to this works:

/Applications/Slicer-4.8.0.app/Contents/Extensions-26489/SlicerElastix/lib/Slicer-4.8

looks like a simple script change fixes this - I'll make a PR

error when run make package

System: Ubuntu 16

CPack Error: Not enough items on list: CPACK_INSTALL_CMAKE_PROJECTS. CPACK_INSTALL_CMAKE_PROJECTS should hold quadruplet of install directory, install project name, install component, and install subdirectory.
CPack Error: Error when generating package: SlicerElastix
Makefile:83: recipe for target 'package' failed

Elastix is not found on MacOSX

Currently Elastix is not bundled correctly in the extension.

Workaround that users can apply until the issue is fixed:

Build failure with ITK v5.1rc03

SlicerElastix build fails due to new Elastix build failures with ITK v5.1rc03.

d:\d\p\s-0-e-b\slicerelastix-build\elastix\components\resamplers\mystandardresampler\elxMyStandardResampler.h(76): error C2039: 'PointType': is not a member of 'itk::ResampleImageFilter<itk::Image<float,2>,itk::Image<float,2>,double,TInterpolatorPrecisionType>' [D:\D\P\S-0-E-b\SlicerElastix-build\elastix-build\Components\Resamplers\MyStandardResampler\MyStandardResampler.vcxproj] [D:\D\P\S-0-E-b\SlicerElastix-build\elastix.vcxproj]

See details here:
http://slicer.cdash.org/viewBuildError.php?buildid=1881538

Preset "3D MRI, monomodal (brain)" does not work

Issue migrated from https://issues.slicer.org/view.php?id=4562.

Using sample data MRBrainTumor1 and MRBrainTumor2, I try to register them using SlicerElastix extension using "3D MRI, monomodal (brain)" presets. After registration is finished, nothing looks changed. If I try to save the scene, the transform and resampled volume are not selected by default, meaning they are empty nodes. If I go to the temp folder and load the intermediate images (e.g. result.hdr), they look correctly resampled. The extension works with other presets (e.g. "generic (all)", "generic (rigid)", "3D MR T1, monomodal (brain)").

Modifying elastix parameters

This is not an issue, rather a suggestion.

Currently, the only way to modify a parameter is to edit the text file. Here is a draft of my idea:

  • All the parameters and their options are saved in a text file.
  • Users can modify the current parameters file by using two QComboBoxes, a QComboBox for the parameter and another for its values (QLineEdit in case of numbers).

This makes it easier and faster to experiment on different parameters.

Elastix won't run on unsaved scene

I had the following error when trying to run SlicerElastix revision ba52785, Slicer version 4.10.0, Windows 10:

ERROR: could not read fixed image.

itk::ImageFileReaderException (0000006C06FDEBE8)
Location: "unknown"
File: d:\d\s\slicer-4100-build\itk\modules\io\imagebase\include\itkImageFileReader.hxx
Line: 143
Description: Could not create IO object for reading file C:/Users/hbraun/AppData/Local/Temp/Slicer/Elastix/20190913_155457_404\input\fixed.mha
The file doesn't exist.
Filename = C:/Users/hbraun/AppData/Local/Temp/Slicer/Elastix/20190913_155457_404\input\fixed.mha

I had just added the images to the scene and had not saved yet. Saving the scene as MRB did not fix the problem, but restarting Slicer and reloading the MRB did. At first glance it looks like this is probably an issue with POSIX vs Windows file separators ('\' vs '/') since I see both mixed together in the error text.

Slicer extension macOS packaging is failing

Before the fixup process is initiated, we can observe that the following executable already reference library using @rpath.

To allow the extension process to successfully complete, absolute path are expected:

elastix

otool -L elastix 
elastix:
	@rpath/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
	/path/to/ITK-build/lib/libITKConvolution-5.3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/path/to/ITK-build/lib/libITKLabelMap-5.3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	[...]
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.0.0)
	/path/to/ITK-build/lib/libitkdouble-conversion-5.3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	@rpath/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	@rpath/libunwind.1.dylib (compatibility version 1.0.0, current version 1.0.0)

transformix

otool -L transformix
transformix:
	@rpath/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
	/path/to/ITK-build/lib/libITKConvolution-5.3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/path/to/ITK-build/lib/libITKLabelMap-5.3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	[...]
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.0.0)
	/path/to/ITK-build/lib/libitkdouble-conversion-5.3.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	@rpath/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	@rpath/libunwind.1.dylib (compatibility version 1.0.0, current version 1.0.0)

To disable the fixup, the following patch was locally applied to the associated Slice source tree:

git diff 
diff --git a/CMake/SlicerExtensionCPack.cmake b/CMake/SlicerExtensionCPack.cmake
index 6adec7bcac..b81e02f701 100644
--- a/CMake/SlicerExtensionCPack.cmake
+++ b/CMake/SlicerExtensionCPack.cmake
@@ -275,7 +275,7 @@ install(SCRIPT \"${slicer_extension_cpack_bundle_fixup_directory}/SlicerExtensio
     if(NOT result EQUAL 0)
       message(FATAL_ERROR "${EXTENSION_NAME}-Fixup: Failed to configure project [source_dir:${source_dir}, build_dir:${build_dir}")
     endif()
-    set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${build_dir};${EXTENSION_NAME}-Fixup;ALL;/")
+    #set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${build_dir};${EXTENSION_NAME}-Fixup;ALL;/")
   endif()
 endif()

Once the packaging has been generated with the fixup disabled using make package, the fixup can then explicitly be initiated using:

cd /path/to/S-0-E-b/SlicerElastix-build/inner-build

cp -r _CPack_Packages _CPack_Packages.orig

cmake \
  -DCMAKE_INSTALL_PREFIX:PATH=/path/to/S-0-E-b/SlicerElastix-build/inner-build/_CPack_Packages/Darwin/TGZ/32195-macosx-amd64-SlicerElastix-gitd98ebde-2023-08-03/ \
  -P ./SlicerExtensionBundle/SlicerExtensionCPackBundleFixup.cmake

Doing so allow to more easily debug and identify issues.

Copying _CPack_Packages to _CPack_Packages.orig may allow to restore the "packaged" tree before attempting to re-run the script. Helpful if it was updated and to avoid re-running make package

Strange output when registering brain MRI to CT scan

Hi I'm trying to register an MRI brain image to a CT scan but the result of elastix is the following nonsensical image:

brain_registration

Any idea what might be causing this? I start by linearly transforming one of the images onto the other which I use as the "Initial Transform", then run elastix with the default settings to produce this volume.

Thanks.

vtkMatrixFromArray not found

I'm working with the Elastix toolbox for Slicer and I was trying to get the transforms that you receive from the toolbox. Anyways, I found that the above mentioned function is not supported anymore by slicer.util. I found a work around by using DeepCopy. Was vtkMatrixFromArray removed in a newer version?

linearTransform.SetMatrix(vtkMatrixFromArray(fixedToMoving))

AdvancedKappaStatistic metric not installed

I want to perform multi-metric registration, which register two CT data sets with MI and simultaneously register the corresponding segments (binary images) with the kappa statistic. Although I did not pass the segmentation node to Elastix, there seemed some problems with the configuration. The error log is shown below.
`Error:
AdvancedKappaStatistic(index 3) - This component is not installed!
ERROR: error occurred while creating Metric 1.

itk::ExceptionObject (00000000001BF480)
Location: "unknown"
File: D:\D\P\S-0-E-b\SlicerElastix-build\elastix\Core\Kernel\elxElastixMain.cxx
Line: 822
Description: itk::ERROR: ElastixMain(000000000377DF10): The following component could not be created: AdvancedKappaStatistic

ERROR:
One or more components could not be created.
Errors occurred!`
Hope for some ideas. Thanks a lot.

Running Elastix registration changes save location of "fixed" and "moving" volumes

After running Elastix the volumes I selected for the “fixed” and “moving” volumes are by default saved as metaImage (*.mha) files in the [home]/AppData/Local/Temp/Slicer/Elastix/[datetime]/input/ directory. This behavior is unexpected and annoying: The original volumes are unchanged and they should remain unaltered in their original location.

Output Transform

I was trying to get output transform in generic rigid registration, but it doesn't record any output transform. Although I get the output volume, I don't know what is the output transform :(

BSpline output transform is not always correct

SlicerElastix can import linear and bspline transform from Elastix internal format, but sometimes the resulting transform is not accurate (gives different result than when a grid transform is generated).

How to reproduce: register MRHead volume to MRBrainTumor1 sample data set using default registration preset. Create output volume and output transform. The output volume matches the fixed volume very well, but applying the output transform to the moving volume results in much less accurate alignment.

Workaround: enable "Force grid output transform" in advanced section.

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.