Issue calling sct_dmri_moco in version 5.3.0

Ok thank you. In the meantime, if I only use bvecs file as input for motion correction, would it be correct?
thanks ,

Rosella

Ok thank you. In the meantime, if I only use bvecs file as input for motion correction, would it be correct?

It depends on your data-- the purpose of using the bvals is to consider data as b=0 in case the bval is, let’s say 50 s/mm2-- so it’s your call

ok so I should wait for the bug to be fixed in order to use information from bvals, too
thank you

can you upload your bvals?

bvals (219 Bytes)
Here it is. I think withouth specifying bvals file sct_dmri_moco recognizes as b=0 just the first bval, since the others are close to 0 but not exactely.
thanks
Rosella

Indeed, these small values are really weird… I suggest you update the DWI sequence as this is highly unusual.

In the meantime you can simply replace these small values by 0.

ok, thank you. These bvalues have been set to 0.01 just because the scanner we use make complaints about b=0 exact values.

1 Like

Even setting bvalues to 0 , sct_dmri_moco does not recognise them:


I think this is because I can’t specify bvalues as an input to the function
Rosella

right-- what you need to put at 0 is the bvecs, not the bvals :point_right: wrong (see my post below)

I have not any bvectors at 0 actually.
Is bvalue = 0, isn’t it?

rosella

sorry-- i was a bit too fast-- so: i was wrong: you should not edit the bvecs.

however: it is not normal that by setting the bvals to 0, sct_dmri_moco does not recognize these scans as b=0.

pls upload data so we can try to reproduce the behaviour

Ok, thank you very much.
I have just given you access to the google drive folder with the data

I have not any bvectors at 0 actually.

you do:

0 0.990423282590532 -0.99866376659413 0.30997993846005 ...

the first one (for X) is “0”

So, if you change the X,Y,Z vectors to (0,0,0) for the indices where the bvals are 0, sct_dmri_moco captures the appropriate b=0 volumes:

...
  Number of b=0: 6 [0, 7, 12, 17, 22, 27]
  Number of DWI: 26 [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 13, 14, 15, 16, 18, 19, 20, 21, 23, 24, 25, 26, 28, 29, 30, 31]
...

Attached is the modified bvecs: bvecs_modif (1.4 KB)

Ok,
Thank you, This should not be necessary in case the bug on bvalues get fixed, shouldn’t be? I remember I did not have to modify my bvecs in previous SCT releases .
thanks,
Rosella

This should not be necessary in case the bug on bvalues get fixed, shouldn’t be?

indeed, once the bug is fixed, you will be able to input the bvals

Just one further question. Is it compulsory for bvalues =0 having corresponding bvecs equal to 0,0,0?

no

I met another issue when applying sct_dmri_moco, even after changing bvals file, however this happens only for one subject:
sct_dmri_moco -i kurtosis_crop.nii.gz -bvec bvecs_modif.txt -x spline

Input parameters:
  Input file ............ kurtosis_crop.nii.gz
  Group size ............ 3
Creating temporary folder (/tmp/sct-20210507103613.690089-moco-98nb2gyo)

Copying input data to tmp folder and convert to nii...

Get dimensions of data...
  42 x 42 x 21

Data orientation: RAI
  Treated as axial

Set suffix of transformation file name, which depends on the orientation:
Orientation is axial, suffix is 'Warp.nii.gz'. The estimated transformation is a 3D warping field, which is composed of a stack of 2D Tx-Ty transformations

Identify b=0 and DWI images...
  WARNING: bvecs file is 3xn instead of nx3. Consider using sct_dmri_transpose_bvecs.
  Transpose bvecs...
  Number of b=0: 6 [0, 7, 12, 17, 22, 27]
  Number of DWI: 26 [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 13, 14, 15, 16, 18, 19, 20, 21, 23, 24, 25, 26, 28, 29, 30, 31]

Split along T dimension...

Merge and average b=0 data...
Merge within groups: 100%|█████████████████████| 9/9 [00:00<00:00, 107.49iter/s]

Merge across groups...

-------------------------------------------------------------------------------
  Estimating motion on b=0 images...
-------------------------------------------------------------------------------

Input parameters:
  Input file ............ b0.nii
  Reference file ........ data_T0000.nii.gz
  Polynomial degree ..... 2
  Smoothing kernel ...... 1
  Gradient step ......... 1
  Metric ................ MI
  Sampling .............. None
  Todo .................. estimate_and_apply
  Mask  .................
  Output mat folder ..... mat_b0groups

Data dimensions:
  42 x 42 x 21 x 6

Copy file_target to a temporary file...

Register. Loop across Z (note: there is only one Z if orientation is axial)
Z=0/0:  67%|████████████████████████            | 4/6 [00:03<00:01,  1.08iter/s]
Traceback (most recent call last):
  File "/home/synapsi/sct_5.3.0/spinalcordtoolbox/scripts/sct_dmri_moco.py", line 225, in <module>
    main(sys.argv[1:])
  File "/home/synapsi/sct_5.3.0/spinalcordtoolbox/scripts/sct_dmri_moco.py", line 210, in main
    fname_output_image = moco_wrapper(param)
  File "/home/synapsi/sct_5.3.0/spinalcordtoolbox/moco.py", line 327, in moco_wrapper
    file_mat_b0, _ = moco(param_moco)
  File "/home/synapsi/sct_5.3.0/spinalcordtoolbox/moco.py", line 623, in moco
    file_data_splitZ_splitT_moco[it], im_mask=input_mask)
  File "/home/synapsi/sct_5.3.0/spinalcordtoolbox/moco.py", line 765, in register
    status, output = run_proc(cmd, verbose=1 if param.verbose == 2 else 0, env=env, **kw)
  File "/home/synapsi/sct_5.3.0/spinalcordtoolbox/utils/sys.py", line 320, in run_proc
    raise RuntimeError(output)
RuntimeError: Exception caught:
itk::ExceptionObject (0x294ac30)
Location: "unknown"
File: /__w/ANTs/ANTs/antsbin/staging/include/ITK-5.1/itkMattesMutualInformationImageToImageMetricv4.hxx
Line: 312
Description: itk::ERROR: MattesMutualInformationImageToImageMetricv4(0x293b370): Joint PDF summed to zero

thanks,
Rosella

Hi @Rosella_Tro,

This issue is caused by ANTs software failing to co-register two volumes because they are two far apart and/or too noisy. It has notably been raised here.

Possible workarounds include:

  • using another metric: -param MeanSquares or -param CC (slower, better results)
  • use more grouping: -g 5 (although I don’t recommend this one in your case, as you have low amount of volumes, and possibly high motion between adjacent volumes).

In the future, could you please open a new issue with a specific title corresponding to the error? Otherwise, if a single thread includes many different issues, it makes it difficult for other researchers to use the search module of this forum in case they encounter the same issue. For example, you could have opened an issue with the title: “ERROR: MattesMutualInformationImageToImageMetricv4 with sct_dmri_moco on SCT v5.3.0”

Thanks,
Julien

1 Like

Sure, sorry for that.
thank you,
Rosella