General registration (BRAINS) returns "Joint PDF summed to zero" error

Operating system: Mac OSX 10.9.5
Slicer version: 4.7

I am trying to run a registration in the BRAINS module, that is somewhat unique and different from the sample cases given online. I have a grayscale FA scalar volume image file (obtained from a DTI volume file), and I have generated an FEM mask of the actual brain section used, by means of a Matlab code. The FEM mask consists of 80-odd slices, and the file format is NifTI. I followed the protocol for BRAINS general reg. per the tutorial for DTI registration on the Slicer forum. The steps I followed and the parameters I used are as follows:

  1. Load the FAV1 file.

  2. Load the FEM masks. I loaded this as a directory, since I have 80 individual slices which I can load in 3D slicer in a way that I can scroll through them as a volume file. They start with slice # slice001, and go upwards in number. [Note: in the option bar where the foreground and background can be selected, only slice001 shows up, but I can still scroll through all 80 slices]

  3. I then chose to keep the FAV1 file as my foreground at 0.5 opacity, and the FEM mask directory, slice001, as my background. [Note: Changing the visibility of the files does not help at all. I am able to only see the file I load last, whichever it may be].

  4. I opened the Gen. reg. BRAINS module, and set the parameters like this. Basically, I did not alter anything except the fixed and moving image inputs. All other default numerical parameters were the same. I used the B-spline method.

  5. The registration completes with errors (and barely takes a second or 2 to complete). The error is as follows:

General Registration (BRAINS) standard error:

WARNING: In /Users/kitware/Dashboards/Nightly/Slicer-0-build/ITKv4/Modules/Numerics/Optimizersv4/src/itkLBFGSBOptimizerv4.cxx, line 116
LBFGSBOptimizerv4 (0x104b0e210): LBFGSB optimizer does not support scaling. All scales are set to one.

libc++abi.dylib: terminating with uncaught exception of type itk::ExceptionObject: /Users/kitware/Dashboards/Nightly/Slicer-0-build/BRAINSTools/BRAINSCommonLib/BRAINSFitHelperTemplate.hxx:1552:
_itk::ERROR: Exception caught: _
itk::ExceptionObject (0x107a00c08)
_Location: “unknown” _
File: /Users/kitware/Dashboards/Nightly/Slicer-0-build/ITKv4/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx
Line: 205
Description: itk::ERROR: MattesMutualInformationImageToImageMetricv4(0x104b02930): Joint PDF summed to zero

General Registration (BRAINS) standard output:

Original Fixed image origin[0, 0, 0, 0]
TranformTypes: BSpline(1 of 1).

=============================== ITKv4 Registration: Starting Transform Estimations for BSpline(1 of 1).===============================

Initialized BSpline transform is set to be an identity transform.
_ - Number of parameters = 9945_
– WARNING: Only one in every 663 parameters is printed on screen.

_ - Cost Function Convergence Factor : 2e+13_
_ - Projected Gradient Tolerance : 1e-05_
_ - Maximum Number of Corrections : 25_
_ - Maximum Number of Evaluations : 900_
_ - Maximum Number of Iterations : 1500_

*** Running bspline registration (meshSizeAtBaseLevel = [14, 10, 12]) ***

After this point, I really don’t know what else I can do. I have tried different combinations of file loading, but nothing seems to work. I even centered the 2 files to the same origin, but I was still unable to view them together. I would be happy to provide the files if need be.

Sorry for the long post, but I would really like some insight into fixing this issue! Thank you in advance!

This error typically occurs when the fixed and moving images do not overlap. Either translate them manually to be approximately in the same position and harden the transform; or try one of the automatic initial alignment options.

This is because the two volumes don’t overlap at all (this confirms that the “Joint PDF summed to zero” error is due to non-overlapping contours). Until you align the volumes, you will only see one of them at a time. After you switch volume, click the small rectangle icon at the top of slice view controller to reset the field of view.

You can align the volumes by using Transforms or Landmark Registration module. You may skip manual alignment and try to get General registration (BRAINS) compute initial alignment by using useMomentsAlign or useGeometryAlign option in Transform initialization settings.

1 Like

Is that why I’m unable to view both images when I load them? because they
do not overlap?
However, as mentioned in my post, I ensured that both their centers were
situated at 0,0,0. Shouldn’t this be solving the problem?

Rewati Kulkarni

Research Assistant, Injury Biomechanics Lab.

University of Pennsylvania,
Department of Bioengineering
+1 267-648-7960 | rewati.p.k01@gmail.com rewati.p.k01@gmail.com

Choose one image in the red slice viewer, the other in the green slice viewer, and on both of them reset the field of view and show it in 3D (click the small rectangle and the eye icon in the slice view controller, complete the basic 3D Slicer tutorials if you are not sure how to do these). Then you’ll see the 3D position of these volumes and check if they overlap or not.

1 Like

You mentioned that some of your data is generated some Matlab code.

It is quite possible that the results you saved from that code lose the direction/spacing information about the image. I am not sure what you mean by the above, but no, it is not sufficient that origins of the images are identical. You must consider directions and spacing, and confirm the datasets make sense when visualized as suggested by @lassoan.

1 Like

I would recommend to use nrrdread.m and nrrdwrite.m functions (available in the MatlabBridge extension or can be downloaded from here). These are well tested and set preserve origin, spacing, and directions information properly.

By the way, why don’t you use the MatlabBridge extension for running your Matlab code? It takes care of passing images and other parameters between Slicer and your Matlab functions.

Thank you for all your responses! I was able to fix the issue and get the registration working.

1 Like

2 posts were merged into an existing topic: Gen Registration (Brains) fails despite overlap of series