Documentation/4.3/FAQ

From SlicerWiki

(Redirected from FAQ)
Jump to: navigation, search
Home < Documentation < 4.3 < FAQ


Contents



User FAQ: Installation & Generic

What is Slicer ?

3D Slicer is:

  • A software platform for the analysis (including registration and interactive segmentation) and visualization (including volume rendering) of medical images and for research in image guided therapy.
  • A free, open source software available on multiple operating systems: Linux, MacOSX and Windows
  • Extensible, with powerful plug-in capabilities for adding algorithms and applications.


Where can I download Slicer?

3DSlicer is available for download by visiting the following link: http://download.slicer.org

Where can I download older release of Slicer ?

Older releases of 3DSlicer are available here: http://slicer.kitware.com/midas3/folder/274

How to install Slicer ?

  1. Go to http://download.slicer.org
  2. Click on the link corresponding to your operating system
  3. Linux MacOSX Windows

    Start a terminal and type these commands:

    
    $ tar xzvf ~/Downloads/Slicer-4.3.0-linux-amd64.tar.gz -C ~/
    
    $ cd ~/Slicer-4.3.0-linux-amd64
    
    $ ./Slicer
    

     

    1. Double click on the downloaded Slicer-4.3.0-linux-amd64.exe package.
    2. Follow instructions displayed on the screen.

     

    1. Double click on the downloaded Slicer-4.3.0-linux-amd64.dmg package
    2. Drag & drop the Slicer.app onto your Desktop or in your Applications. Need help?

Is slicer really free?

Yes, really, truly, free. Not just a free trial. No pro version with all the good stuff. Slicer is free with no strings attached. You can even re-use the code in any way you want with no royalties and you don't even need to ask us for permission. (Of course we're always happy to hear from people who've found slicer interesting).

See the Slicer License page for the legal version of this.


Can I use slicer for patient care?

Slicer is intended for research work and has no FDA clearances or approvals of any kind. It is the responsibility of the user to comply with all laws and regulations (and moral/ethical guidelines) when using slicer.


How to cite Slicer?

Please cite the Slicer web site (http://www.slicer.org) and the following publications when publishing work that uses or incorporates Slicer.


How do I create an account for the Slicer wiki?

Please note: You only need an account if you want to edit or add pages.

Follow the Log in->Request Account link from the upper right corner of the slicer wiki page. Once the account request is approved, you will be e-mailed a notification message and the account will be usable at log in.


What if I have problems with Slicer installation?

You can read our guide explaining how to report a problem.


How to uninstall Slicer?

  • On Windows, choose "Uninstall" option from the Start menu.
  • On the Mac, remove the Slicer.app file. To clean up settings, remove "~/.config/www.na-mic.org/"
  • On Linux, remove the directory where the application is located. To clean up settings, remove "~/.config/NA-MIC/"


Where can I find Slicer tutorials?

Slicer tutorials associated with the latest 4.3 stable release are available by visiting the following link: Click Here.


I read errors in the logs complaining about memory

Errors such as “Description: Failed to allocate memory for image.” indicate that you don’t have enough memory space. This can be a common issue if you run a 32-bit version of Slicer. You cannot expect a 32-bit executable to deal with any moderately complex problem. The recommended solution is to download/build/use Slicer in 64-bit mode.

Possible workarounds:

  • Use a 64-bit version of Slicer
  • You have somewhat more memory if you run the module in a separate process. To do that open Edit / Application Settings / Modules and check the “Prefer Executable CLIs” option, then restart Slicer.
  • Decrease the size and/or resolution of the input and output images


Which Slicer version should I use: 3.X or 4.X ?

In general slicer3 and slicer4 have roughly similar functionality with respect to registration basics. Probably the most important thing to keep in mind is that slicer3 is no longer actively maintained.

Slicer4, on the other hand, has benefited from literally hundreds of bug fixes over the past several years, and typically has better features and much better performance. Also, the nightly builds of slicer4 are now using ITKv4, which has significantly improved registration code. I am told by active users/developers of ITK that ITKv4 should provide significantly better results in many cases. Also, several new registration techniques are being actively developed for slicer4.

Source: http://massmail.spl.harvard.edu/public-archives/slicer-users/2013/006190.html


What is my HOME folder ?

Linux or MacOSX Windows

Start a terminal.

$ echo ~
/home/jchris

Start Command Prompt (Start Menu -> All Programs -> Accessories -> Command Prompt)

> echo %userprofile%
C:\Users\jcfr

What to do if Slicer hang while loading data from an unresponsive network directory ?

On linux, the hotfix is to umount force the network directory. From a terminal, type the following:

sudo umount /mount/point -f

Make sure to NOT autocomplete the path with TAB.

This will "unfreeze" Slicer and allow you to save your work in a different directory.

The problem was originally reported as Slicer issue #2449 and the proposed solution was suggested by agarfors on sshfs-fuse/+bug/159031/comments/28


User FAQ: User Interface

How to overlay 2 volumes ?

  1. Load the two volumes
  2. Use the slice viewer controls to select one of the volumes as the foreground and one as the background.
  3. Change the opacity of the Foreground to your liking.
  4. If you click on the link symbol, this happens to all viewers

How to load data from a sequence of jpg files?

  1. Choose from the menu: File / Add Data
  2. Click Choose File(s) to Add button and select any of the files in the sequence in the displayed dialog
  3. Click on Show Options and uncheck the Single File option
  4. Click OK to load the volume
  5. Go to the Volumes module
  6. Choose the loaded image as Active Volume
  7. In the Volume Information section set the correct Image Spacing and Image Origin values


User FAQ: Extensions

What is an extension ?

Extensions in the Extension manager.

An extension could be seen as a delivery package bundling together one or more Slicer modules. After installing an extension, the associated modules will be presented to the user as built-in ones

The Slicer community maintains a website referred to as the Slicer Extensions Catalog to support finding, downloading and installing of extensions. Access to this website is integral to Slicer and facilitated by the Extensions Manager functionality built into the distributed program.

The Catalog classifies extensions into three levels of compliance:

  1. Category 1: Fully compliant Slicer Extensions: Slicer license, open source, maintained.
  2. Category 2: Open source, contact exists.
  3. Category 3: All other extensions (work in progress, beta, closed source etc).

To publish extensions, developers should consider reading the following pages:

What is the extensions catalog ?

The extensions catalog provides Slicer users with a convenient way to access the extensions previously uploaded on the extensions server:

Why there are no windows 32-bit extensions available ?

  • Win 32 has a very limited amount of memory available to an application.
  • Many registration and segmentation algorithms fail on that platform because they run out of memory, when used with state of large data.
  • Some of these failures are just that, some can crash slicer. Even though the "real" failure is caused by overextending the capabilities of the hardware (in a way the users fault), it appears to the user that Slicer does not work.
  • If you search the archives of slicer-users there are several such complaints until we started to discourage people to use 32 bit.

Discussion: http://massmail.spl.harvard.edu/public-archives/slicer-users/2013/006703.html

Should I install the nightly version to access to last extension updates ?

If the extension developers contributed updates for the current stable release, you don't have to install the nightly version of Slicer. You can simply update the extension. Consider reading How to update an already installed extension ?.

On the other hand, if the extension developers stopped to maintain the version of their extension built against the stable release (so that we can use the latest feature that will be in the next Slicer release), downloading the nightly is the only way to get the latest version of the extension.

How to update an already installed extension?

Assuming updates extensions are available for your version of Slicer, it is currently not possible without uninstalling the extension and re-installing it.

We are currently developing a mechanism allowing to either manually update or automatically suggest update. In the process of finalizing, reviewing and testing, the corresponding feature will be available in Slicer 4.4.

For more details, see [1][2] and [3]

[1] http://na-mic.org/Mantis/view.php?id=2089

[2] https://github.com/mwoehlke-kitware/Slicer/tree/REBASE-2089-update-extensions

[3] http://wiki.slicer.org/slicerWiki/index.php/Documentation/Labs/ExtensionsFrameworkRoadmap

How to manually install an extension ?

1) Get revision associated with your install or built Slicer. (Menu -> Help -> About)

2) Download extension matching your Slicer revision. Select operating system, bitness and enter revision on http://slicer.kitware.com/midas3/slicerappstore

3) Extract the archive (zip or tar.gz) in a folder. You should then have a folder like:

/path/to/<slicer_revision>-<os>-<bitness>-<extension_name>-<extension_scm><extension_revision>-YYYY-MM-DD

containing folder like:

lib/Slicer-X.Y/cli-modules
lib/Slicer-X.Y/qt-loadable-modules
lib/Slicer-X.Y/qt-scripted-modules

For more details: Documentation/4.3/Developers/DirectoryStructure

4) In the Module settings (Menu -> Edit -> Settings), add the path ending with lib/Slicer-X.Y/{cli|qt-scripted|qt-loadable}-modules


User FAQ: DICOM

When I click on "Load selection to slicer" I get an error message "Could not load ... as a scalar volume"

There's a chance you could be running out of memory when loading the data. Make sure you use a 64-bit version of Slicer. The 32-bit Windows version has constrained memory and often does not work with clinical CT studies.

Another potential cause of loading failure is corruption of the DICOM files by incorrect anonymization. Patient name, patient ID, and series instance UID fields should not be empty or missing (the anonymizer should replace them by other valid strings). Try to load the original, non-anonymized sequence and/or change your anonymization procedure.

If none of the above helps then check the Slicer error logs and report the error on the Slicer mailing list. If you share the data (e.g., upload it to Dropbox and add the link to the error report) then Slicer developers can reproduce and fix the problem faster.

I try to import a directory of DICOM files, but nothing shows up in the browser

DICOM is a complex way to represent data, and often scanners and other software will generate 'non-standard' files that claim to be DICOM but really aren't compliant with the specification. In addition, the specification itself has many variations and special formats that Slicer is not able to understand. Slicer is used most often with CT and MR DICOM objects, so these will typically work.

If you have trouble importing DICOM data here are some steps to try:

  • Make sure you are following the DICOM module documentation.
  • Review the Error Log for information.
  • Try loading the data by selecting one of the files in the Add Data Dialog. Note: be sure to turn on Show Options and then turn off the Single File option in order to load the selected series as a volume
  • If you are still unable to load the data, you may need to find a utility that converts the data into something Slicer can read. Sometimes tools like FreeSurfer, FSL or MRIcron can understand special formats that Slicer does not handle natively. These systems typically export NIfTI files that slicer can read.
  • If you are sure that the DICOM files do not contain patient confidential information, you may post a sample dataset on a web site and ask for help from Slicer's user mailing list. Please be careful not to accidentally reveal private health information. If you want to remove identifiers from the DICOM files you may want to look at the RSNA Clinical Trial Processor software.


User FAQ: Viewing and Resampling

What coordinate systems does Slicer use?

See this documentation of Slicer coordinate systems.

Is there a global coordinate system ?

There is no coordinate system in Slicer that is called Global. There is one called RAS. When you open Slicer, the middle of the pink wireframe box in the 3D view is at the origin of RAS. When a medical image is loaded in Slicer, it is oriented relative to the RAS coordinate system so the right hand of the patient is towards the R (first coordinate), the front of the patient is towards A (second coordinate). It's a right handed system.

To visualize "something", it is usually most convenient of to transform it to RAS, so it shows up relative to CT or MR images loaded in Slicer. When hovering the mouse over an image slice (2D), the RAS coordinates are displayed in the Data Probe located in lower left corner of the Slicer UI.

Source: http://slicer-devel.65872.n3.nabble.com/Reference-System-tp4031501p4031503.html

How can I use the reformat widget view to resample my images?

You can do something like this in the python console:

red = getNodes('vtkMRMLSliceNode*')['Red']
m = vtk.vtkMatrix4x4()
m.DeepCopy(red.GetSliceToRAS())
m.Invert()

t = slicer.vtkMRMLLinearTransformNode()
t.SetAndObserveMatrixTransformToParent(m)
 

Then put your volume under “t" or provide "t" as the transform to one of the Resample modules.


User FAQ: Registration

How do I fix incorrect axis directions? Can I flip an image (left/right, anterior/posterior etc) ?

Sometimes the header information that describes the orientation and size of the image in physical space is incorrect or missing. Slicer displays images in physical space, in a RAS orientation. If images appear flipped or upside down, the transform that describes how the image grid relates to the physical world is incorrect. In proper RAS orientation, a head should have anterior end at the top in the axial view, look to the left in a sagittal view, and have the superior end at the top in sagittal and coronal views.
Yes, you can flip images and change the axis orientation of images in slicer. But we urge to use great caution when doing so, since this can introduce subtantial problems if done wrong. Worse than no information is wrong information. Below the steps to flip the LR axis of an image:
You may skip steps 5-8 below and download predefined transforms here. To apply those unzip, drag & drop into Slicer and drag your volume inside the transform.

  1. Go to the Data module, right click on the node labeled "Scene" and select "Insert Transform" from the pulldown menu
  2. You should see a new transform node being added to the tree, named "LinearTransform_1" or similar.
  3. left click on the volume you wish to flip, and drag it onto the new transform node. You should see a "+" appear in front of the transform node, and clicking on it should reveal the volume now inside/under that transform.
  4. make sure you have the image you wish to flip selected and visible in the slice views, preferably all 3 views (sagittal, coronal, axial).
  5. Switch to the Transforms module and (if not selected already) select the newly created transform from the Active Transform menu.
  6. Under Transform Matrix you see a 4x4 array of ones and zeros. Each row represents an axis direction. We will switch the axis direction by changing the sign of one of the 1s.
  7. e.g. to flip left/right: double-click inside the top left field where you see a 1. The number should be high-lighted and change to 1.0
  8. replace the 1.0 with "-1.0", then hit the RETURN key. You should see a flip immediately, assuming you have the volume in the proper view. Depending on which of the axes you want flipped, select the 1 in one of the other rows.
  9. When you have the result you want, return to the Data module, there right click on your image and select Harden Transform from the pulldown menu.
  10. The image will move back outside the transform onto the main level, indicating that your change of axis orientation has now been applied. Note there is no Undo for this step. If you change your mind you have to apply the same flip again or reload your volume.
  11. Note that the flip will likely also cause a shift, depending on your image origin. You may choose to recenter your image. To do so go to the Volumes module, open the Volume Information tab and click on the Center Volume button
  12. Note that this change was applied to the header information that stores the physical orientation, not the image data itself. Hence you will only see this flip in software that reads and accounts this header orientation info.
  13. Save your image under a new name, do not use a format that doesn't store physical orientation info in the header (jpg, gif etc).; also consider saving the transform as documentation to what change you have applied. You can also use these saved transforms as templates to quickly flip an image.
  14. Again: the change is saved as part of the image orientation info and not as an actual resampling of the image, i.e. if you save your image and reload it in another software that does not read the image orientation info in the header (or displays in image space only), you will not see the change you just applied.

To flip the other axes do the same as above but edit the diagonal entries in the 2nd and 3rd row, for flipping anterior-posterior and inferior-superior directions, respectively.

How do I fix a wrong image orientation in the header? / My image appears upside down / facing the wrong way / I have incorrect/missing axis orientation

  • Problem: My image appears upside down / flipped / facing the wrong way / I have incorrect/missing axis orientation
  • Explanation: Slicer presents and interacts with images in physical space, which differs from the way the image is stored by a separate transform that defines how large the voxels are and how the image is oriented in space, e.g. which side is left or right. This information is stored in the image header, and different image file formats have different ways of storing this information. If Slicer supports the image format, it should read the information in the header and display the image correctly. If the image appears upside down or with distorted aspect ratio etc, then the image header information is either missing or incorrect.
  • Fix: See the FAQ above on how to flip an image axis within Slicer. You can also correct the voxel dimensions and the image origin in the Volume Information tab of the Volumes module, and you can reorient images via the Transforms module.
  • To fix an axis orientation directly in the header info of an image file:
1. load the image into slicer (File: Add Volume, Add Data, Load Scene..)
2. save the image back out as NRRD (.nhdr) format.
3. open the .nhdr with a text editor of your choice. You should see a line that looks like this:
 space: left-posterior-superior
 sizes: 448 448 128
 space directions: (0.5,0,0) (0,0.5,0) (0,0,0.8)
4. the three brackets ( ) represent the coordinate axes as defined in the space line above, i.e. the first one is left-right, the second anterior-posterior, and the last inferior-superior. To flip an axis place a minus sign in front of the respective number, which is the voxel dimension. E.g. to flip left-right, change the line to
 space directions: (-0.5,0,0) (0,0.5,0) (0,0,0.8)
5. alternatively if the entire orientation is wrong, i.e. coronal slices appear in the axial view etc., you may easier just change the space field to the proper orientation. Note that Slicer uses RAS space by default, i.e. first (x) axis = left-right, second (y) axis = posterior-anterior, third (z) axis = inferior-superior
6. save & close the edited .nhdr file and reload the image in slicer to see if the orientation is now correct.

How do I fix incorrect voxel size / aspect ratio of a loaded image volume?

  • Problem: My image appears distorted / stretched / with incorrect aspect ratio
  • Explanation: Slicer presents and interacts with images in physical space, which differs from the way the image is stored by a set of separate information that represents the physical "voxel size" and the direction/spatial orientation of the axes. If the voxel dimensions are incorrect or missing, the image will be displayed in a distorted fashion. This information is stored in the image header. If the information is missing, a default of isotropic 1 x 1 x 1 mm size is assumed for the voxel.
  • Fix: You can correct the voxel dimensions and the image origin in the Info tab of the Volumes module. If you know the correct voxel size, enter it in the fields provided (double click to edit). You should see the display update immediately. Ideally you should try to maintain the original image header information from the point of acquisition. Sometimes this information is lost in format conversion. Try an alternative converter or image format if you know that the voxel size is correctly stored in the original image. Alternatively you can try to edit the information in the image header, e.g. save the volume as (NRRD (.nhdr) format and open the ".nhdr" file with a text editor. See FAQ above.

I don't understand your coordinate system. What do the coordinate labels R,A,S and (negative numbers) mean?

  • It's very important to realize that Slicer displays all images in physical space, i.e. in mm. This requires orientation and size information that is stored in the image header. How that header info is set and read from the header will determine how the image appears in Slicer. RAS is the abbreviation for right, anterior, superior; indicating in order the relation of the physical axis directions to how the image data is stored.
  • For a detailed description on coordinate systems see here.

My image is very large, how do I downsample to a smaller size?

Several Resampling modules provide this functionality. If you also have a transform you wish to apply to the volume, we recommend the ResampleScalarVectorDWIVolume module, or the simpler ResampleScalarVolume module. See here for an explanation and overview of Resampling tools.

Resampling in place (changing voxel size):

1. Go to the Volumes module
2. from the Active Volume pulldown menu, select the image you wish to downsample
3. Open the Volume Information tab. Write down the voxel dimensions (Image Spacing) and overall image size (Image Dimensions), e.g. 1.2 x 1.2 x 3 mm voxel size, 512 x 512 x 86. You will need this information to determine the amount of down-/up-sampling you wish to apply
4. Go to the ResampleScalarVolume module (found under All modules)
5. In the Spacing field, enter the new desired voxel size. This is the above original voxel size multiplied with your downsampling factor. For example, if you wish to reduce the image to half (in plane), but leave the number of slices, you would enter a new voxel size of 2.4,2.4,3.
6. For Interpolation, check the box most appropriate for your input data: for labelmaps check nearest Neighbor, for 3D MRI or other bandlimited signals check hamming. For most others leave the linear default. The sinc interpolator (hamming, cosine, welch) and bspline (cubic) interpolators tend to produce less blurring than linear', but may cause overshoot near high contrast edges (e.g. negative intensity values for background pixels)
7.Input Volume: Select the image you wish to resample
8. Output Volume:Select Create New Volume for output volume, then rename to something meaningful, like your input + suffix "_resampled"
9. Click Apply

Resampling in place to match another image in size:

1. Go to the [[Documentation/4.3/Modules/ResampleScalarVectorDWIVolume

|ResampleScalarVectorDWIVolume module]]

2. Input Volume: Select the image you wish to resample
3. Output Volume: Select Create New Volume for output volume, and rename to something meaningful, like your input + suffix "_resampled"
4. Reference Volume: Select the reference image whose size/dimensions you want to match to.
5. Interpolation Type: check the box most appropriate for your input data: for labelmaps check nn=nearest Neighbor, for 3D MRI or other bandlimited signals check ws=windowed sinc. For most others leave the linear default. The ws and bspline (cubic) interpolators (hamming, cosine, welch) tend to produce less blurring than linear', but may cause overshoot near high contrast edges (e.g. negative intensity values for background pixels)
6. Click Apply. Note that if the input and reference volume do not overlap in physical space, i.e. are roughly co-registered, the resampled result may not contain any or all of the input image. This is because the program will resample in the space defined by the reference image and will fill in with zeros if there is nothing at that location. If you get an empty or clipped result, that is most likely the cause. In that case try to re-center the two volumes before resampling.

Resampling in place by specifying new dimensions:

1. Go to the ResampleScalarVectorDWIVolume module
2. Input Volume: Select the image you wish to resample
3. Output Volume: Select Create New Volume for output volume, and rename to something meaningful, like your input + suffix "_resampled"
4. Reference Volume: leave at "none"
5. Interpolation Type: check the box most appropriate for your input data: for labelmaps check nn=nearest Neighbor, for 3D MRI or other bandlimited signals check ws=windowed sinc. For most others leave the linear default. The ws and bspline (cubic) interpolators (hamming, cosine, welch) tend to produce less blurring than linear', but may cause overshoot near high contrast edges (e.g. negative intensity values for background pixels)
6. Click Apply. Note that if the input and reference volume do not overlap in physical space, i.e. are roughly co-registered, the resampled result may not contain any or all of the input image. This is
6. Manual Output Parameters: here you specify the new voxel size / spacing and dimensions. Note that you need to set both. If only the voxel size is specified, the image is resampled but retains its original dimensions (i.e. empty/zero space). If only the dimensions are specified the image will be resampled starting at the origin and cropped but not resized.
  • new voxel size: calculate the new voxel size and enter in the Spacing field, as described above in in 'Resampling in place above, see step #5
  • new image dimensions: enter new dimensions under Size. To prevent clipping, the output field of view FOV = voxel size * image dimensions, should match the input
7. leave rest at default and click Apply

How do I register images that are very far apart / do not overlap

  • Problem: when you place one image in the background and another in the foreground, the one in the foreground will not be visible (entirely) when switching bak & forth
  • Explanation:Slicer chooses the field of view (FOV) for the display based on the image selected for the background. The FOV will therefore be centered around what is defined in that image's origin. If two images have origins that differ significantly, they cannot be viewed well simultaneously.
  • Fix: recenter one or both images as follows:
1. Go to the Volumes module
2. Select the image to recenter from the Active Volume menu
3. Select/open the Volume Information tab.
4. Click the Center Volume button. You will notice how the Image Origin numbers displayed above the button change. If you have the image selected as foreground or background, you may see it move to a new location.
5. Repeat steps 2-4 for the other image volumes
6. In the slice view menu, click on the Fit to Window button (a small square next to the pin in the top left corner of each view)
7. Images should now be roughly in the same space. Note that this re-centering is considered a change to the image volume, and Slicer will mark the image for saving next time you select Save.

How do I register a DWI image dataset to a structural reference scan? (Cookbook)

  • Problem: The DWI/DTI image is not in the same orientation as the reference image that I would like to use to locate particular anatomy; the DWI image is distorted and does not line up well with the structural images
  • Explanation: DWI images are often acquired as EPI sequences that contain significant distortions, particularly in the frontal areas. Also because the image is acquired before or after the structural scans, the subject may have moved in between and the position is no longer the same.
  • Fix: obtain a baseline image from the DWI sequence, register that with the structural image and then apply the obtained transform to the DTI tensor. The two chief issues with this procedure deal with the difference in image contrast between the DWI and the structural scan, and with the common anisotropy of DWI data.
  • Overall Strategy and detailed instructions for registration & resampling can be found in our DWI registration cookbook
  • you can find example cases in the DWI chapter of the Slicer Registration Case Library, which includes example datasets and step-by-step instructions. Find an example closest to your scenario and Slicer version and perform the registration steps recommended there.

How do I initialize/align images with very different orientations and no overlap?

I would like to register two datasets, but the centers of the two images are so different that they don't overlap at all. Is there a way to pre-register them automatically or manually to create an initial starting transformation?

1. Go to the Volumes module
2. Select the image to recenter from the Active Volume menu
3. Select/open the Volume Information tab.
4. Click the Center Volume button. You will notice how the Image Origin numbers displayed above the button change. If you have the image selected as foreground or background, you may see it move to a new location.
5. Repeat steps 2-4 for the other image volumes
6. In the slice view menu, click on the Fit to Window button (a small square next to the pin in the top left corner of each view)
7. Images should now be roughly in the same space. Note that this re-centering is considered a change to the image volume, and Slicer will mark the image for saving next time you select Save.
  • Automatic Initialization: Most registration tools have initializers that should take care of the initial alignment in a scenario you described. However since they often are based on heuristics they may work well in some cases and not in others. The two modules that offer the most initializer options are General Registration (BRAINS) module (under Registration menu) and the Expert Automated Registration module.
  • General Registration (BRAINS) module initializers:
    • Initialization Transform: here you can specify a transform from which to start. You can perform a manual alignment (see here for tutorial) and then feed this as initializer here.
    • Initialization Transform Mode: these options generate automated initializations for you:
      • "Off assumes that the physical space of the images are close, and that centering in terms of the image Origins is a good starting point.
      • useCenterOfHeadAlign: recommended for registering brain MRI where all or most of the head is within the FOV
      • useMomentsAlign: recommended for image pairs with similar contrast, scale and content.
      • useGeometryAlign: recommended for image pairs with similar FOV for both objects. This aligns the image grid volumes disregarding of content.
      • useCenterOfROIAlign": recommended if you have a mask for each image that defines the regions you want registered. This will initialize based on those two masks.
      • Tip: yo can run the registration with just the initializer to see what kind of transformation it produces. In that case select a Slicer Linear Transform output but leave all boxes under Registration Phases unchecked.
  • ExpertAutomatedRegistration module initializers:
      • "None directly starts with optimization from the current position
      • CentersOfMass: recommended for image pairs with similar contrast, scale and content. Similar to useMomentsAlign above.
      • SecondMoments: same as above, but also calculating (principal) axis directions
      • Image Centers": similar to useGeometryAlign above: recommended for image pairs with similar FOV for both objects. This aligns the image grid volumes disregarding of content.

Can I manually adjust or correct a registration?

Yes for linear (rigid to affine) transforms; not without resampling for nonrigid transforms.
The automated registration algorithms (except for fiducial and surface registration) in Slicer operate on image intensity and try to move images so that similar image content is aligned. This is influenced by many factors such as image contrast, resolution, voxel anisotropy, artifacts such as motion or intensity inhomogeneity, pathology etc, the initial misalignment and the parameters selected for the registration. Before attempting manual correction, it is usually advisable to retry an automated run with modified parameters, additional initializers or masks. you can adjust/correct an obtained registration manually, within limits. There's a brief (no sound) video that demonstrates the procedure here: Manual Registration Movie (2 min) If the transform is linear, i.e. a rigid or affine transform, you can access the rigid components (translation and rotation) of that transform via the Transforms module. Or (maybe safer) you can create an additional new transform and nest the old one inside it. Then once you approve of the adjustment merge the two (via Harden Transform)

  1. Go to the Data module, right click on the node labeled "Scene" and select "Insert Transform" from the pulldown menu
  2. You should see a new transform node being added to the tree, named "LinearTransform_1" or similar.
  3. left click on the volume you wish to register, and drag it onto the new transform node. You should see a "+" appear in front of the transform node, and clicking on it should reveal the volume now inside/under that transform.
  4. make sure you have the image for which you wish to adjust the registration selected and visible in the slice views, preferably all 3 views (sagittal, coronal, axial).
  5. Switch to the Transforms module and (if not selected already) select the newly created transform from the Active Transform menu.
  6. adjust the translation and rotation sliders to adjust the current position. To get a finer degree of control, enter smaller numbers for the translation limits and enter rotation angles numerically in increments of a few degrees at a time

What's the difference between the various registration methods listed in Slicer?

Most of the registration modules use the same underlying ITK registration algorithm for cost function and optimization, but differ in implementation on parameter selection, initialization and the type of image toward which they have been tailored. To help choose the best one for you based on the method or available options, an.
To help choose based on a particular image type and content, you will find many example cases incl. step-by-step instructions and discussions on the particular registration challenges in the Slicer Registration Library. The library is organized in several different ways, e.g. consult this sortable table with all cases and the method used.
Note that registration methods are in continuous development, and not all cases in the Registration Library, may be updated for the latest version. To see which version they were verified on, check the icon in the title of the case page.

What's the purpose of masking / VOI in registration? / What does the masking option in registration accomplish ?

The masking option is a very effective tool to focus the registration onto the image content that is most important. It is often the case that the alignment of the two images is more important in some areas than others. Automated registration based on image intensity is easily dominated by the portions in the image that contain the most contrast/content. If you have much content that is present in only one image, masking that area out will prevent it from leading the registration astray. Masking provides the opportunity to specify the important regions and make the algorithm ignore the image content outside the mask. This does not mean that the rest is not registered, but rather that it moves along passively, i.e. areas outside the mask do not actively contribute to the cost function that determines the quality of the match. Note the mask defines the areas to include, i.e. to exclude a particular region, build a mask that contains the entire object/image except that region.

  • Note: masking within the registration is different from feeding a masked/stripped image as input, where areas of no interest have been erased. Such masking can still produce valuable results and is a viable option if the module in question does not provide a direct masking option. But direct masking by erasing portions of the image content can produce sharp edges that registration methods can lock onto. If the edge becomes dominant then the resulting registration will be only as good as the accuracy of the masking. That problem does not occur when using masking option within the module.
  • The following modules currently (v.3.6.1) provide masking:
    • General Registration (BRAINS) module : in the Mask Option tab, you can specify a mask for both fixed and moving image. Note that you need to specify both and that both need to be labelmaps with value 1 in areas you wish included and 0 elsewhere. Also both mask images must be the same size (image dimensions) as the image being registered; i.e. if you register two images of different size you cannot use the same mask for both, because the mask for the fixed image must match the fixed image size and the mask for the moving image must match the moving image size. But you can use the ResampleScalarVectorDWIVolume module to resample one mask to the resolution of the other (use the appropriate image as Reference) and then you can use it.
    • Expert Automated Registration module see in the Advanced Registration Parameters tab:you can specify 1 mask for the fixed image only. Mask should be a labelmap with value 1 in areas you wish included and 0 elsewhere.

Registration failed with an error. What should I try next?

  • Problem: automated registration fails, status message says "completed with error" or similar.
  • Explanation: Registration methods are mostly implemented as commandline modules, where the input to the algorithm is provided as temporary files and the algorithm then seeks a solution independently from the activity of the Slicer GUI. you will notice that you're free to continue using other Slicer functions while a registration is running. Several reasons can lead to failure, most commonly they are wrong or inconsistent input or lack of convergence if images are too far apart initially.
  1. check your input:
    1. did you provide both a fixed and a moving image?
    2. did you select an output (transform and/or new output volume)?
    3. do the two images have any overlap? Can you see them both in the slice views? If not try to recenter (see "Manual Recenter" in FAQ above). When rerunning the registration, try selecting an initializer
    4. are inputs consistent? E.g. General Registration (BRAINS) module will complain if you check a "BSpline" registration phase but do not select a BSpline output transform, or if you request masking and do not specify masking input or output.
  2. if above checks reveal nothing, open the Error Log window (Window Menu) and scroll to the bottom to see the most recent entries related to the registration. Usually you will see a commandline entry that shows which arguments were given to the algorithm, and a standard output or similar that lists what the algorithm returned. More detailed error info can be found in either this entry, or in the ERROR: ..." line at the top of the list. Click on the corresponding line and look for explanation in the provided text. If there was a problem with the input arguments or the that would be reported here.
  3. If the Error log does not provide useful clues, try varying some of the parameters. Note that if the algorithm aborts/fails right away and returns immediately with an error, most likely some input is wrong/inconsistent or missing.
  4. check the initial misalignment, if images are too far apart and there is no overlap, registration may fail. Consider initialization with a prior manual alignment, centering the images or using one of the initialization methods provided by the modules
  5. write to the Slicer user group (slicer-users@bwh.harvard.edu) and inform them of the error. We're keen on learning so we can improve the program. The fastest and best reply you will get if you copy and paste the error messages found in the Error Log into your mail.

Registration result is wrong or worse than before?

  • Problem: automated registration provides an alignment that is insufficient, possibly worse than the initial position
  • Explanation: The automated registration algorithms (except for fiducial and manual registration) in Slicer operate on image intensity and try to move images so that similar image content is aligned. This is influenced by many factors such as image contrast, resolution, voxel anisotropy, artifacts such as motion or intensity inhomogeneity, pathology etc, the initial misalignment and the parameters selected for the registration.
  1. re-run the registration with parameter modifications:
    1. if images have little initial overlap or are far apart in orientation, try a (different) initializer: e.g. General Registration (BRAINS) module has several initializers, details in their documentation and also in this FAQ above.
    2. do the two images have any overlap? Can you see them both in the slice views? If not try to recenter (see "Manual Recenter" in FAQ above). When
    3. try a lower DOF registration first to see if that fails. If the lower DOF fails, subsequent ones will also. For nonrigid registration, try adding intermediate steps, such as a similarity (7 DOF) or Affine (12 DOF) transform.
    4. if automated initializers do not help, try a manual initial alignment (see FAQ above). This need not be perfect, as long as it establishes good overlap and roughly same direction. Then try rerunning the registration using the manual transform as a starting point. (Initialization Transform) in the General Registration (BRAINS) module.
    5. if initial overlap is ok but registration "drifts away", there is either insufficient sample data or distracting image content. Try increasing the number of sample points. See FAQ below for estimates of sample points.
    6. insufficient contrast: consider adjusting the Histogram Bins (where avail.) to tune the algorithm to weigh small intensity variations more or less heavily
    7. strong anisotropy:' if one or both of the images have strong voxel anisotropy of ratios 5 or more, rotational alignment may become increasingly difficult for an automated method. Consider increasing the sample points and reducing the Histogram Bins.
    8. distracting image content: pathology, strong edges, clipped FOV with image content at the border of the image can easily dominate the cost function driving the registration algorithm. Masking is a powerful remedy for this problem: create a mask (binary labelmap/segmentation) that excludes the distracting parts and includes only those areas of the image where matching content exists. This requires one of the modules that supports masking input, such as General Registration (BRAINS) module or Expert Automated Registration module . Next best thing to use with modules that do not support masking is to mask the image manually and create a temporary masked image where the excluded content is set to 0 intensity; the MaskScalarVolume module performs this task.
    9. you can adjust/correct an obtained registration manually, within limits, as outlined manual initial alignment in this FAQ above.

How many sample points should I choose for my registration?

  • Problem: unsure what the Sample Points setting means or how I could use it to improve my registration.
  • Explanation:All registration modules contain a parameter field that controls how much of the image is sampled when performing an automated registration. The unit is often an absolute count, but in some cases also a percentage. Default settings also vary among modules. The number of samples is an important setting that determines both registration speed and quality. If the sample number is too small, registration may fail because it is driven by image content that insufficiently represents the image. If sample number is too large, registration can slow down significantly.
  • Fix: If registration speed is not a major issue, better to err on the side of larger samples. Most default settings are chosen to yield relatively fast registrations and for most of today's image represent only a small percentage. Below the defaults for the different registration modules, for version 3.6.1:
Defaults Used in Slicer Modules v.3.6.1

The table below relates total sample points and percentages to the most common image sizes. Also consider that sample points are chosen randomly so that some points may fall outside the actual object to be registered. That is not a bad thing per se, some background points are important, but not if they are too far from the edges of the object. So consider both total image size as well as the percentage of the image field of view that your object of interest obtains. E.g. if your object fills only half the image, double the sample points to get the desired amount of points within the object.

Image Size Total Points 10,000 50,000 100,000 200,000 1% 2% 5% 10% 20%
128 x 128 x 64 1048576 1.0% 4.8% 9.5% 19.1% ~10000 ~20000 ~52500 ~100000 ~200000
256 x 256 x 30 1966080 0.5% 2.5% 5.1% 10.2% ~20000 ~40000 ~97500 ~200000 ~400000
256 x 256 x 120 7864320 0.1% 0.6% 1.3% 2.5% ~77500 ~150000 ~400000 ~775000 ~1500000
192 x 192 x 192 7077888 0.1% 0.7% 1.4% 2.8% ~70000 ~150000 ~350000 ~700000 ~1500000
512 x 512 x 48 12582912 0.1% 0.4% 0.8% 1.6% ~125000 ~250000 ~625000 ~1250000 ~2500000
256 x 256 x 256 16777216 0.1% 0.3% 0.6% 1.2% ~175000 ~325000 ~850000 ~1750000 ~3250000
512 x 512 x 160 41943040 0.0% 0.1% 0.2% 0.5% ~425000 ~850000 ~2000000 ~4250000 ~8500000

The image below shows sample point densities on one slice of a brain MRI with 256x256x130 voxels. For robust registration, we recommend a useful coverage requires at least 1% coverage for affine, more (at least 5%) for nonrigid (BSpline) as DOF increase:
sample point densities on one slice of a brain MRI with 256x256x130 voxels; for robust registration, we recommend a useful coverage requires at least 1% coverage for affine, more (at least 5%)  for nonrigid (BSpline) as DOF increase

What's the BSpline Grid Size?

The BSpline grid is the basic structure of the deformation model applied when transforming one image to match the other. A uniform grid is placed over the entire image and the grid-points are allowed to move freely. These node displacements are then interpolated over the remainder of the grid. The image below shows an example of a 3x3x3 grid. An additional row of grid points is created at the boundary of the image (red). Those points are locked and do not move. They provide a boundary constraint to keep the grid from shifting. The interior points (green) are free to move in any direction (blue arrows), which gives 3 degrees of freedom (DOF) per grid-point. So a 3x3x3 grid translates into a transform with 27 DOF, a 5x5x5 grid will have 125 DOF. For comparison a rigid transform has 6 DOF, an affine transform has 12. When specifying a grid, be aware of your image resolution and anisotropy. For example if your image has substantially fewer voxels in one direction, it may be wise to also request fewer grid-points in that dimension, to avoid over fitting.
Example of a 3x3x3 BSpline grid placed over the entire image. Note that the 3x3x3 grid refers to the green center points, which are allowed to move freely. The additional (red) boundary points do not move.

I want to register two images with different intensity/contrast.

The two most critical image features that determine automated registration accuracy and robustness are image contrast and resolution. Differences in image contrast are best addressed with the appropriate cost function. The cost function that has proven most reliable for registering images with different contrast (e.g. a T1 MRI to a T2 or an MRI to CT or PET) is mutual information. All intensity-based registration modules use mutual information as the default cost function. Only the Expert Automated Registration module (under All Modules) lets you choose alternative cost function. No extra adjustment is therefore needed in terms of adjusting parameters to register images of different contrast. Depending on the amount of differences you may consider masking to exclude distracting image content or adjusting the Histogram Bins setting to increase/decrease the level of intensity detail the algorithm is aware of.

How important is bias field correction / intensity inhomogeneity correction?

While registration may still succeed with mild cases of inhomogeneity, moderate to severe inhomogeneity can negatively affect automated registration quality. It is recommended to run an automated bias-field correction on both images before registration.This becomes more relevant the more degrees of freedom you have in your registration, i.e. a BSpline registration is more likely to be affected by an intensity bias than an Affine. The image here (click to enlarge) BSpline deformation with/without bias-correction, click to enlarge shows an example of a low-level BSpline deformation applied once with and once without preceeding bias-correction. You can see how the lack of signal at the bottom of the uncorrected image causes the image to be "pulled downward:m which is incorrect. see here for documentation on the BiasCorrection module. Masking of non-essential peripheral structures can also help to reduce distracting image content. See the FAQ on masking for more details.

Have the Slicer registration methods been validated?

The Slicer3.6 registration modules share the same same underlying ITK registration engines. For validation of those basic algorithms refer to the ITK software guide or the Insight Journal. Slicer registration of images and surfaces has been applied successfully in many cases, some of which are documented here here. For ongoing efforts on improving/validating Slicer registration performance please contact the Slicer User Mailing List or the Slicer Developer Mailing List.

How can I save the parameter settings I have selected for later use or sharing?

The Parameter Set menu at the top tab of each module serves this purpose of saving and recalling instances of parameter settings. To save the current settings select Rename from the menu, give it a descriptive name and then select Create New Commandline Module from the menu. New settings are added to the menu as created. These settings are saved together with the Slicer Scene.mrml file. To save only the presets without any associate data, first save your entire scene, then delete all nodes in the MRML tree except the top Scene node, and then save this under a new name like "Slicer_Presets.mrml" etc. To load the presets in, use Import from the File menu, which will add the MRML entries to the existing scene. Do not load presets via "Load Scene", since that will replace the loaded data rather than add to it. A detailed user guide on loading presets can be found here. Note that the content and format of the Slicer Scene file tends to change and evolve with newer versions, and presets may not be compatible across very different versions.

Registration is too slow. How can I speed up my registration?

The key parameters that influence registration speed are the number of sample points, the degrees of freedom of the transform, the type of similarity metric and the initial misalignment and image contrast/content differences. If registration quality is ok, try reducing the sample points first. Guidelines on selecting sample points are given here. The degrees of freedom usually are given by the overall task and not subject to variation, but depending on initial misalignment, both speed and robustness can improve by an iterative approach that gradually increases DOF rather than starting with a high DOF setting. The General Registration (BRAINS) module and Expert Automated Registration module both allow prescriptions of iterative DOF.
If using a cost/criterion function other than mutual information, note that the corresponding ITK implementation may not have been parallelized and hence may not be taking advantage of multi-threading/multi-CPU cores on your computer. This can slow down performance significantly..
General tips:

Registration results are inconsistent and don't work on some image pairs. Are there ways to make registration more robust?

The key parameters that influence registration robustness are the number of sample points, the initial degrees of freedom of the transform, the type of similarity metric and the initial misalignment and image contrast/content differences. particularly initialization methods that seek a first alignment before beginning the optimization can make things worse. If initial position is already sufficiently close (i.e. more than 70% overlap and less than 20% rotational misalignment), consider turning off initialization if available (e.g. in General Registration (BRAINS) module (under Registration menu) and the Expert Automated Registration module ) Try increasing the sample points. Guidelines on selecting sample points are given here. The degrees of freedom usually are given by the overall task and not subject to variation, but depending on initial misalignment, robustness can greatly improve by an iterative approach that gradually increases DOF rather than starting with a high DOF setting. The General Registration (BRAINS) module and Expert Automated Registration module both allow prescriptions of iterative DOF.
If using a cost/criterion function other than mutual information (MI), note that MI tends to be the most forgiving/robust toward differences in image contrast.
Also see the.

One of my images has a clipped field of view. Can I still use automated registration?

Probably yes. Best remedy is to apply a mask that excludes the missing portion in the other image. Also initialization is critical, more so than with full FOV images. If images have large amount of initial misalignment, try to center both first (see here for details) or perform a cursory manual alignment (see here for details) and use that as initialization. An example of registrations with clipped FOV can be found in the Slicer Registration Library , e.g. case 4, case9; case 13; case 30 and others.

I ran a registration but cannot see the result. How do I visualize the result transform?

There are 2 ways to see the result of a registration: 1) by creating a new resampled volume that represents the moving image in the new orientation , 2) by direct (dynamic) rendering of the original image in a new space when placed inside a transform. The latter is not available for non-rigid transforms, hence a registration that includes nonlinear components (BSpline, Warp) must be visualized by first resampling the entire volume with the new transform. If you ran a registration yet see no effect, the reason could be one of the following:

  • you did not request an output. In the module parameters section, you must specify either an output transform or an output image/volume. Select one or both (for nonrigid registration).
  • you requested a result transform but the moving volume is not placed inside the transform in the MRML tree. Not all modules automatically place the moving image inside the result transform node. To see the effect do the following:
  1. Go to the Data module
  2. left click on the volume you wish to register, and drag & drop it onto the new transform node created by your registration. After dropping it once the transform, you should see a "+" appear in front of the transform node, and clicking on it should reveal the volume now inside/under that transform.
  3. make sure you have the image for which you wish to adjust the registration selected and visible in the slice views, preferably all 3 views (sagittal, coronal, axial). If the image is visible in the Slicer views, you should see a change immediately when the volume is placed inside the transform
  • registration completed with an error. Check for status messages at the top of the module and look at the Error Log in the window menu to see if there were any errors reported.
  • registration completed with a result that is too small to be noticeable: For linear transforms (rigid to affine) you can look at and edit the transform directly in Slicer: go to the Transforms module and select the transform. You should see the parameters in the 4x4 matrix displayed. If diagonal numbers are very close to 1 and all others very close to 0, you have a transform that barely moves the object at all. Nonrigid transforms you have to save to a file first; you can then view the .tfm file with any text editor.
  • you performed a non-rigid (BSpline) transform but did not yet request an output volume.

What's the difference between Rigid and Affine registration?

Rigid registration is a transform with 6 degrees of freedom (DOF): 3 translations (one along each axis) and 3 rotations (one around each axis). An affine registration includes 12 DOF, i.e. 3 additional DOF for scaling (along each axis) and shearing. So strictly speaking an affine transform is a non-rigid transform, even though linear, because the volume can distort. However in practice by non-rigid transform one usually refers to nonlinear transforms with more than 12 DOF, e.g. BSpline or polynomial models.

What's the difference between Affine and BSpline registration?

An affine registration includes 12 DOF, i.e. 3 for translations (one along each axis), 3 rotations (one around each axis), 3 for scaling (along each axis) and 3 for shearing. So strictly speaking an affine transform is a non-rigid transform, even though linear, because the volume can distort. However in practice by non-rigid transform one usually refers to nonlinear transforms with more than 12 DOF, e.g. BSpline or polynomial models. A BSpline registration employs a nonlinear nonrigid model that allows individual regions of the image to distort independently, but enforcing smooth transitions between them. A BSpline transform is not described by a 4x4 matrix like the affine model, but by a list of displacement vectors for each point along a prescribed grid. E.g. a 3x3x3 BSpline grid has 27 points that can move independently, yielding 27 DOF; a 5x5x5 grid analogously has 125 DOF etc.

The nonrigid (BSpline) registration transform does not seem to be nonrigid or does not show up correctly.

See FAQ on viewing registration results here. BSpline transforms are not available for immediate rendering by placing volumes or models inside the transforms. Only linear transforms can be viewed that way. A BSpline transform must be visualized by resampling the entire volume with the new transform. If you did not yet an output volume when running the registration, you can do so after the fact, use the ResampleScalarVectorDWIVolume module.

Can I combine multiple registrations?

Yes, you can nest multiple (affine) registrations inside eachother. You can generate combined ones via the right-click context menu in the Data module and selecting Harden Transform. Note that the original transform or volume is replaced when selecting Harden Transform, so it is recommended to rename the node afterwards to document the fact.
Currently (v.4.1) BSpline transforms cannot be combined with other transforms, so if you have combinations of Affine and BSpline or multiple BSpline transforms you need to resample multiple times to apply them all. We recommend to supersample the volume beforehand to counteract interpolation blurring.

Can I combine image and surface registration?

Not simultaneously. You can run surface and image registrations separately and then combine the transforms, but there is currently no support to combine both surface and intensity data into a single cost function.

What's the difference between BRAINSfit and BRAINSDemonWarp?

General Registration (BRAINS) module performs Rigid to Affine and BSpline registration that commonly will have at the most a few hundred degrees of freedom (DOF), whereas the Demon Registration (BRAINS) module performs a optic flow high-DOF warping scheme that has many thousands of DOF and is significantly less constrained.

Is the BRAINSfit registration for brain images only?

No, it is applicable and has been used successfully on non-brain image data. See the Registration Case Library for examples. The BRAINS name is derived from the ICTS at program at the University of Iowa, where it was developed, details of which you will find here.

Which registration methods offer masking?

By masking we mean to selectively include only parts of an image to
selectively participate (i.e contribute to the optimization) . Masking is supported directly by

Note that the use of masks differs among these: "Expert Auto" requires a binary mask for fixed image only, while "General BRAINS" requires masks for both fixed and moving image. Expected is a label map with values 0 and 1, 1 being the regions to include.

Is there a function to convert a box ROI into a volume labelmap?

Slicer version 3.6 supports conversion of a box ROI into a labelmap via the Crop Volume module. This function has not (yet) been ported to Slicer4. You can create a new ROI box or select an existing one. You must select an image volume to crop for the operation, even if you're only interested in the ROI labelmap. You need not select a dedicated output for the labelmap, it is generated automatically when the cropped volume is produced, and will be called Subvolume_ROI_Label in the MRML tree. After creating the box ROI labelmap, simply delete the cropped volume and other output like the "...resample-scale-1.0" volume.
Likely you will need the volume with the same dimension and pixel spacing as the reference image. The box volume produced above has the correct dimension, but is only 1 voxel in size. Hence there is a second step required, which is to resample the Subvolume_ROI_Label to the same resolution: use the ResampleScalarVectorDWIVolume module and select the appropriate reference and Nearest Neighbor as interpolation method. Finally go to the Volumes module and check the Labelmap box in the info tab to turn the volume into a labelmap.

Physical Space vs. Image Space: how do I align two registered images to the same image grid?

Slicer displays all data in a physical coordinate system. Hence an image can only be displayed correctly if it contains sufficient header information to relate the image voxel grid with physical space. This includes voxel size, axis orientation and scan order. It is therefore possible for two images to be aligned when viewed in Slicer, even though their underlying image grid is oriented very differently. To match the two images in image as well as physical space, the abovementioned axis direction, voxel size and image grid orientation must match. The procedure will depend on the image data, but the main tools at your disposal are the ResampleScalarVectorDWIVolume module and OrientImages module.

Is there a way to perform an Eddy current correction on DWI in Slicer

There is a way, you need to download the GTRACT extension (you can get it from the menu View->Extension Manager) Once you have it you will see a new module category under the diffusion one called "GTRACT". Within this category there is a module called "Coregister B-values". This module takes a DWI image and outputs a DWI image in which every DWI is co-registered to one of the B0 images (by default the first one), this can be regarded as motion correction. Within this module there is a checkbox in the "Registration Parameters" section: "Eddy Current Correction". This will tune some of the registration parameters such that some Eddy Current artifacts are corrected.

The registration transform file saved by Slicer does not seem to match what is shown

When executing the following procedure:

  1. Create a transform.
  2. Adjust it by adjusting the 6 slider bars in the Transforms module.
  3. Save the transform as a .tfm file.
  4. Inspect the contents of the .tfm file in a text editor, and compare them to what is shown in the 4x4 matrix in the Transforms module.
  5. re-load the .tfm back into slicer and confirm you have the same data as you saved from slicer.

you will notice that, even though the reloaded transform does match, the contents of the .tfm file and what is displayed in the Transforms module do not match. The explanation of this is kind of buried in the details of transforms. The issue relates to the difference between slicer which uses a "computer graphics" view of the world and itk which uses an "image processing" view of the world. By this we mean that in slicer you have a matrix hierarchy and you think in terms of moving an object from one spot to another - so a transform that has a positive "superior" value wrapped around a volume moves the volume up in patient space.
But ITK thinks of transformations in terms of mapping backwards from the display space back to the original image. Imagine if you are stepping sequentially through the output pixels then ITK wants to know the transform that takes you back to the input pixels that it needs to use to calculate the output. This modeling vs. resampling issue is in addition to the LPS/RAS issue, which is the 2nd (invisible) difference between the two transforms.
In Summarry:

  1. The transform represented in the widget is in RAS.
  2. The transform represented in the tfm file is in LPS.
  3. The transform represented in the file is the inverse of the transform in the widget (plus it has the LPS/RAS conversion applied).
  4. The order of the parameters in the tfm are the elements of the upper 3x3 of the transform displayed in the widget followed by the elements in the last column of the widget.

As an example:

  1. take the transform from the widget: --> c = [0.996918 -0.078459 -0.000000 6.899965; 0.068016 0.864225 -0.498488 -95.999726; 0.039111 0.496951 0.866896 266.299559; 0.0 0.000000 -0.000000 1.000000]
  2. Take the inverse --> inv(c) =
   0.9969    0.0680    0.0391  -10.7644
  -0.0785    0.8642    0.4970  -48.8313
  -0.0000   -0.4985    0.8669 -278.7091
        0         0         0    1.0000 
3. LPS to RAS conversion will take you all the way to what is the file, i.e. pre and post multiply inv(c) by the respective matrices.

How can I see the parameters of the function that describe a BSpline registration/deformation?

To see the parameters of the transform, you have to write it to file and investigate by other means. The BSpline transform is saved as a ITK .tfm which is a text file containing the displacement vectors of each grid-point, plus any initial affine transform (if present). One nice way to visualize is to create a grid image of the same dimensions as your target, and then apply the transform to this grid image, you can then see the deformations as deformations in the gridlines. Example Grid images can be downloaded here. Use the ResampleScalarVectorDWIVolume module for the resampling.

A quick way directly in slicer is to place the undeformed and deformed volumes into back- and foreground and fade back and forth with the fading slider. Another alternative is to convert the transform into a 4-D deformation field directly and visualize it in slicer using RGB color. See FAQ below on how to convert.

How can I convert a BSpline transform into a deformation field?

There is commandline functionality in Slicer to convert a BSpline ITK transform file (.tfm) into a deformation field volume. To execute, type (exchange /Applications/Slicer3.6.3 with the path of your Slicer installation):

 /Applications/Slicer3.6.3/Slicer3 --launch /Applications/Slicer3.6.3/lib/Slicer3/Plugins/BSplineToDeformationField --tfm InputBSpline.tfm 
  --refImage ReferenceImage.nrrd   --defImage Output_DeformationField.nrrd  

for more details try:

 /Applications/Slicer3.6.3/Slicer3 --launch /Applications/Slicer3.6.3/lib/Slicer3/Plugins/BSplineToDeformationField --help

My reoriented image returns to original position when saved; Problem with the Harden Transform function

right click on the image and select "Harden Transform" from the popup menu to reorient an image

You can apply an affine transform to an image by creating a transform, placing the volume inside that transform in the Data module, and then selecting Harden Transform via the context-menu (right click on the image volume). This will move the image back out to the main level and "apply" the transform. It will, however, not resample the image data, but rather place the information about the new orientation into the image header. When the image is saved, this information is saved also as part of the file header, as long as orientation data is supported by the file format. If the saved volume is now loaded by another software that does not consider this header orientation (e.g. ImageJ) or does not visualize the image in physical space, then the image will appear in its old position.
While resampling of data is best avoided if possible, a hard resampling is possible through the ResampleScalarVectorDWIVolume module: select your image and transform as input, create a new volume as output and click Apply. This new volume will now be in the new orientation that will be retained if saved and reloaded elsewhere.

What is the Meaning of 'Fixed Parameters' in the transform file (.tfm) of a BSpline registration ?

A typical BSpline transform file will contain 2 transforms, an affine portion (commonly saved as "Transform 1" at the end of the file), and a nonrigid BSpline portion (commonly saved as "Transform 0"). The bulk of the BSpline part are 3D displacement vectors for each of the BSpline grid-nodes in physical space, i.e. for each grid-node, there will be three blocks of displacements defining dx,dy,dz for all grid nodes. After this field is a "Fixed Parameters" section that may look like this:

 FixedParameters: 8 8 8 -54.1406 -54.1406 -35 54.1406 54.1406 35 1 0 0 0 1 0 0 0 1

The first 3 numbers are the actual grid size (number of knots in each dimension), which is always larger than your requested grid because the grid is extended beyond the image margin to prevent clipping. The next 3 numbers is the origin of the grid, spacing of the grid, and the direction cosines of the grid. More details on the format in the ITK documentation (ITKSoftwareGuide.pdf)

I have some DICOM images that I want to reslice at an arbitrary angle

There's several ways to go about this. If you wish to register your image to another reference/target image, run one of the automated registration methods. If you wish to realign manually, most efficient way is to use the Transforms module. Once you have the desired orientation, you need to apply the new orientation to the image. You can do this in 2 ways: 1) without or 2) with resampling the image data.

  1. Without resampling: In the Data module, select the image (inside the transforms node) and select "Harden Transforms" from the pulldown menu. This will write the new orientation in physical space into the image header. This will work only if other software you use and the image format you save it as support this form of orientation information in the image header.
  2. With resampling: Go to the ResampleScalarVectorDWIVolume module and create a new image by resampling the original with the new transform. This will incur interpolation blurring but is guaranteed to transfer for all image formats or software.

For more details on manual transform, see this FAQ and the here.

I have to manually segment a large number of slices. How can I make the process faster?

Contour every other slice, then run a Dilate and an Erode operation. For further speed increase (at the cost of losing more details), you may contour just every 3rd or 4th slice and then run Dilate multiple times (until all the holes are filled in) and then run Erode as many times as you ran Dilate. You can also subsample your image first, then edit, and finally upsample again and use the SmoothLabelmap module to reduce artifacts. See FAQ below for examples on quick segmentation methods.

How can I quickly generate a mask image ?

Several tools exist to interactively segment structures. A collection of short video examples demonstrating the methods can be found here : Video Tutorials on Mask generation

After registration the registered image appears cropped. How can I increase the field of view to see/include the entire image

Problem: The registration results seems to be correct but the output volume shows only the overlapping region. Is there a way that to show the whole registered volume including the parts which are not overlapping? There's two answers to this problem: one is a visualization issue related to how Slicer chooses the field of view (FOV), and one is how the FOV is chosen for resampling. Slice views: Slicer sets the overall field of view based on the image selected as "background". If the image in the foreground extends beyond that region it will be clipped. You can easily fix/test that by switching foreground and background volumes. If you already created a resampled version of the registered image, that may also have been cropped,because it sets the field of view based on the reference image (which is the fixed image usually). If you place your resampled image in the background and still see cropped edges, then that's what happened. In that case either use a different reference image for resampling or no reference at all and specify the result sizes manually, or use the crop tool to expand the FOV as described below:

  1. use the CropVolume module to over-crop the reference image (define ROI to cover the field of view you want to have in the resampled volume). You will need to use interpolated crop mode, so the resolution will not match the original reference volume.
  2. Use the result of the cropping operation as the reference for BRAINSResample module (you will need to specify the moving volume, output volume, and the transform produced by the BRAINS registration module).


User FAQ: Models

How can I transform a model for output?

Slicer performs all operations in millimeters, and all anatomy is referenced to the patient space. When the data from from DICOM or other formats with well-defined geometry mappings, all the dimensions are handled automatically.

However some output formats, such as .stl format, do not have defined physical units, and some software will insist that data be saved with respect to units other than millimeters. In this case, you can pre-transform the data before saving using the following steps:

  1. Create a linear transform using the Transforms module
  2. Enter the conversion factor along the main diagonal of the transform matrix (i.e. if the export should be in meters rather than millimeters, then enter 0.001 in place of 1.0 along the three locations in the main diagonal).
  3. Apply the new transform to the model (it will appear much smaller now in slicer)
  4. Go to the Data module
    1. Right-click on the model
    2. Pick the Harden Transform menu item.

The model will not change size, but it will move out of the transform, meaning that the internal data points have been changed and is ready for saving.


User FAQ: Scripting

Should I learn Python 2.X or 3.X ?

Since Slicer is currently built against python 2.7.3, we suggest you to learn python 2.X.

To learn more about the difference:

How to grab full slice image (+-volume, +-model) ?

A Few General Approaches

There are multiple ways to access image data from one or all of the slice views.

VTK Window to Image Function (vtk.vtkWindowToImageFilter()

# Example to grab image from red slice view and output as TIF
lm = slicer.app.layoutManager()
redWidget = lm.sliceWidget('Red')
redView = redWidget.sliceView()
wti = vtk.vtkWindowToImageFilter()
wti.SetInput(redView.renderWindow())
wti.Update()
w = vtk.vtkTIFFWriter()
w.SetInputConnection(wti.GetOutputPort())
w.SetFileName('tmp/test.tif')
w.Write()

Direct access to widget data using

# Example grabs image from red slice view and outputs as PNG
lm = slicer.app.layoutManager()
redWidget = lm.sliceWidget('Red')
im = redWidget.imageData()
w = vtk.vtkPNGWriter()
w.SetInput(im)
w.SetFileName('tmp/test.png')
w.Write()


QImages using the qt.QPixmap.grabWidget function

# example to grab all views and store in 'image'
         image = qt.QPixmap.grabWidget(slicer.util.mainWindow()).toImage()
# example to grab 3d view, store in tdv, then output as a png image file
         tdv = lm.threeDWidget(0).threeDView()
         qt.QPixmap().grabWidget(tdv).toImage().save('/tmp/test.png')

Notes

This is also useful for slicing up whatever is shown (eg. voxelizing model data) by iterating this over the dimensions of the volume/model

In order to view models in the slice view make sure to activate the "Slice Intersections Visible" property of the model


Specific Example

The following script iterates through the red slice view and outputs each slice as a .png image. It was originally designed to output volume+model data together slice-by-slice

https://gist.github.com/gortscizz/5060517
Personal tools