spinicist / QUIT

A set of tools for processing Quantitative MR Images
Mozilla Public License 2.0
59 stars 20 forks source link

despot1hifi: Error in evaluating the ResidualBlock #28

Closed andersonwinkler closed 3 years ago

andersonwinkler commented 3 years ago

Hi Tobias,

Thank you for this wonderful tool. We are running the newest version on a CentOS 7 machine but receiving the following error:

WARNING: Logging before InitGoogleLogging() is written to STDERR
W0418 22:33:10.659549  9963 residual_block.cc:129] 

Error in evaluating the ResidualBlock.

There are two possible reasons. Either the CostFunction did not evaluate and fill all    
residual and jacobians that were requested or there was a non-finite value (nan/infinite)
generated during the or jacobian computation. 

Residual Block size: 1 parameter blocks x 1 residuals

For each parameter block, the value of the parameters are printed in the first column   
and the value of the jacobian under the corresponding residual. If a ParameterBlock was 
held constant then the corresponding jacobian is printed as 'Not Computed'. If an entry 
of the Jacobian/residual array was requested but was not written to by user code, it is 
indicated by 'Uninitialized'. This is an error. Residuals or Jacobian values evaluating 
to Inf or NaN is also an error.  

Residuals:              nan 

Parameter Block 0, size: 3

     1.62731 |         -nan 
      0.0001 |         -nan 
     26.2386 |         -nan 

W0418 22:33:10.684064  9963 residual_block.cc:129] 

Error in evaluating the ResidualBlock.

There are two possible reasons. Either the CostFunction did not evaluate and fill all    
residual and jacobians that were requested or there was a non-finite value (nan/infinite)
generated during the or jacobian computation. 

Residual Block size: 1 parameter blocks x 1 residuals

For each parameter block, the value of the parameters are printed in the first column   
and the value of the jacobian under the corresponding residual. If a ParameterBlock was 
held constant then the corresponding jacobian is printed as 'Not Computed'. If an entry 
of the Jacobian/residual array was requested but was not written to by user code, it is 
indicated by 'Uninitialized'. This is an error. Residuals or Jacobian values evaluating 
to Inf or NaN is also an error.  

Residuals:              nan 

Parameter Block 0, size: 3

     3.52183 |         -nan 
      0.0001 |         -nan 
     29.3504 |         -nan 

W0418 22:33:10.726271 10005 residual_block.cc:129] 

Error in evaluating the ResidualBlock.

There are two possible reasons. Either the CostFunction did not evaluate and fill all    
residual and jacobians that were requested or there was a non-finite value (nan/infinite)
generated during the or jacobian computation. 

Residual Block size: 1 parameter blocks x 1 residuals

For each parameter block, the value of the parameters are printed in the first column   
and the value of the jacobian under the corresponding residual. If a ParameterBlock was 
held constant then the corresponding jacobian is printed as 'Not Computed'. If an entry 
of the Jacobian/residual array was requested but was not written to by user code, it is 
indicated by 'Uninitialized'. This is an error. Residuals or Jacobian values evaluating 
to Inf or NaN is also an error.  

Residuals:              nan 

Parameter Block 0, size: 3

      0.0001 |         -nan 
 0.000100003 |         -nan 
      19.234 |         -nan 

W0418 22:33:11.578938 10025 residual_block.cc:129] 

Error in evaluating the ResidualBlock.

There are two possible reasons. Either the CostFunction did not evaluate and fill all    
residual and jacobians that were requested or there was a non-finite value (nan/infinite)
generated during the or jacobian computation. 

Residual Block size: 1 parameter blocks x 1 residuals

For each parameter block, the value of the parameters are printed in the first column   
and the value of the jacobian under the corresponding residual. If a ParameterBlock was 
held constant then the corresponding jacobian is printed as 'Not Computed'. If an entry 
of the Jacobian/residual array was requested but was not written to by user code, it is 
indicated by 'Uninitialized'. This is an error. Residuals or Jacobian values evaluating 
to Inf or NaN is also an error.  

Residuals:              nan 

Parameter Block 0, size: 3

      0.0001 |         -nan 
 0.000100004 |         -nan 
     21.3006 |         -nan 

W0418 22:33:11.603441 10025 residual_block.cc:129] 

Error in evaluating the ResidualBlock.

There are two possible reasons. Either the CostFunction did not evaluate and fill all    
residual and jacobians that were requested or there was a non-finite value (nan/infinite)
generated during the or jacobian computation. 

Residual Block size: 1 parameter blocks x 1 residuals

For each parameter block, the value of the parameters are printed in the first column   
and the value of the jacobian under the corresponding residual. If a ParameterBlock was 
held constant then the corresponding jacobian is printed as 'Not Computed'. If an entry 
of the Jacobian/residual array was requested but was not written to by user code, it is 
indicated by 'Uninitialized'. This is an error. Residuals or Jacobian values evaluating 
to Inf or NaN is also an error.  

Residuals:              nan 

Parameter Block 0, size: 3

      0.0001 |         -nan 
 0.000100002 |         -nan 
     19.0134 |         -nan 

Environment variable QUIT_EXT is not valid, defaulting to NIFTI_GZ

The call is as follows:

qi despot1hifi SPGR.nii.gz IRSPGR.nii.gz --mask=mask.nii.gz --json=quit.json --threads=1 --clamp=5.0 --out=outputs/

where the json file contains:

{
    "MPRAGE": {
        "FA": 5,
        "TR": 0.005,
        "TI": 0.45,
        "TD": 0,
        "eta": 1,
        "ETL": 96,
        "k0": 0
    },
    "SPGR": {
        "TR": 0.005,
        "TE": 0.00184,
        "FA": [3, 4, 5, 6, 7, 9, 13, 18]
    },
    "SSFP": {
        "TR": 0.003256,
        "PhaseInc": [0, 0, 0, 0, 0, 0, 0, 0, 180, 180, 180, 180, 180, 180, 180, 180],
        "FA": [11.4705, 15.294, 20.0735, 25.808, 31.544, 38.235, 48.75, 65, 11.4705, 15.294, 20.0735, 25.808, 31.544, 38.235, 48.75, 65]
    }
}

What could be wrong?

Thanks!

All the best,

Anderson

PS: all images are in register to the same space as the SPGR.

spinicist commented 3 years ago

Hello,

If the number of voxels where this is reported is small, it is usually because the mask includes a few voxels at the edge of the brain with low or zero signal in one image. Do you get a reasonable looking map at the end of the processing?

The following should not matter, but note that the SSFP entry in the .json will be ignored (I never actually thought to use the same input file across programs but yes it should be fine) and that if this is data from a Siemens scanner, then "k0": 48 is probably correct because I think the default on Siemens is linear k-space ordering (whereas on GE centric is the default).

andersonwinkler commented 3 years ago

Thank you for the quick feedback. How to know the number of voxels affected? The whole output is above. Does this mean just 5 voxels? If there's a way to identify them (they aren't marked as NaN or Inf) we can exclude them from the mask.

The maps (HIFI_T1 and HIFI_B1) look good, and are very similar (but not identical) to an old run of the same subjects using an old QUIT version (from 3 years ago or so).

For the .json, yes, we put everything into a single one, assuming the unused elements would be ignored. The scanner is GE. Thanks!

spinicist commented 3 years ago

Yes - if that is your entire output it is just those five voxels.

Have you run the command with -v? It's supposed to report the voxel locations where the fit fails.

I smooth the B1 maps from HIFI with a polynomial (https://quit.readthedocs.io/en/latest/Docs/Utilities.html#qi-polyfit-qi-polyimg) and then re-run DESPOT1.

andersonwinkler commented 3 years ago

Many thanks. The -v ended up not showing the voxel coordinates for despot1hifi, but it does show voxels with issues in some of the other commands. Running again with a mask dilated by 1 voxel in all directions increased the number of errors, so it must indeed be issues with a few voxels around the edge of the brain and that we may be able to ignore.

Ultimately this goes into qi mcdespot, which before was showing some issues (not errors but a noisy MWF output, mostly in the GM, seeming some numerical issue). It's now running again with the polynomial smoothing of B1 and after a pass of despot1 and despot2. I'm optimistic, fingers crossed! It will take a few hours until it's done.

Thanks!

andersonwinkler commented 3 years ago

Ok, I think this error can be ignored for this data. I'll close the ticket.

However, hope it's ok if I open a new one about the outputs from mcdespot... it's producing weird results. Thanks!

spinicist commented 3 years ago

Okay - I possibly need to look into this a little bit more because, as you can see here: https://github.com/spinicist/QUIT/blob/master/Source/Core/ModelFitFilter.h#L566 it should report the exact voxel location for any failures. I may have misunderstood the return codes from Ceres.