Issue calling sct_dmri_moco in version 5.3.0

When trying to apply motion correction, the following error appears:
sct_dmri_moco -i denoised_patch2self.nii.gz -bvec bvecs -bval bvals -x spline

    --
    Spinal Cord Toolbox (5.3.0)

    sct_dmri_moco -i denoised_patch2self.nii.gz -bvec bvecs -bval bvals -x spline
    --


    Input parameters:
      Input file ............ denoised_patch2self.nii.gz
      Group size ............ 3
    Creating temporary folder (/tmp/sct-20210505170650.694281-moco-84mnd6p3)

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

    Get dimensions of data...
      42 x 42 x 13

    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...
    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 217, in moco_wrapper
        param.verbose)
      File "/home/synapsi/sct_5.3.0/spinalcordtoolbox/scripts/sct_dmri_separate_b0_and_dwi.py", line 289, in identify_b0
        bvals, bvecs = read_bvals_bvecs(fname_bvals, fname_bvecs)
      File "/home/synapsi/sct_5.3.0/python/envs/venv_sct/lib/python3.6/site-packages/dipy/io/gradients.py", line 46, in read_bvals_bvecs
        with open(this_fname, 'r') as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'bvals'

However, bvals file exists and is placed in the working directory.

thank you,
Rosella

My apologies: My previous reply was inaccurate, and I’ve deleted it. I’ll respond shortly with a new reply.

I tried to rename my ‘bvecs’ file as ‘bvecs.txt’ and not specifying bvals file as an input of sct_dmri_moco and the command worked. This because my bvals file is anyway a txt file with bvalues along each direction of bvecs file, it is not an image (.nii.gz) file.
best,
Rosella

My apologies for my first response. You’re absolutely right.

This is a bug in SCT. I’ve opened an issue here, and I will take a look at this right away. My apologies for any inconvenience.

Kind regards,
Joshua

1 Like

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?