FOV error with dwi

Summary of what happened:

I have a double-shell dwi dataset and each shell acquired in 2 opposite phase-encoding directions. The preprocessing for some of my subjects did not execute cleanly and I got an error message (please see below).

Command used (and if a helper script was used, a link to the helper script or the command generated):

docker run --rm -it -v /home/moye/software/licenses/license.txt:/opt/freesurfer/license.txt:ro -v /media/moye/Data/test/data_bids:/data:ro -v /media/moye/Data/test/eddy_params.json:/sngl/eddy/eddy_config.json:ro -v /media/moye/Data/test/data_output/output1:/out pennbbl/qsiprep:0.16.1 /data /out participant --eddy-config /sngl/eddy/eddy_config.json --output_space T1w --output_resolution 3 --nthreads 4 --omp_nthreads 2 --distortion-group-merge average --dwi_only

Version:

0.16.1

Environment (Docker, Singularity, custom installation):

Docker

Data formatted according to a validatable standard? Please provide the output of the validator:

Relevant log outputs (up to 20 lines):

Traceback:
	Traceback (most recent call last):
	  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 398, in run
	    runtime = self._run_interface(runtime)
	  File "/usr/local/miniconda/lib/python3.8/site-packages/qsiprep/interfaces/nilearn.py", line 134, in _run_interface
	    new_nii = concat_imgs(self.inputs.in_files, dtype=self.inputs.dtype)
	  File "/usr/local/miniconda/lib/python3.8/site-packages/nilearn/_utils/niimg_conversions.py", line 487, in concat_niimgs
	    for index, (size, niimg) in enumerate(zip(lengths, _iter_check_niimg(
	  File "/usr/local/miniconda/lib/python3.8/site-packages/nilearn/_utils/niimg_conversions.py", line 160, in _iter_check_niimg
	    raise ValueError(
	ValueError: Field of view of image #1 is different from reference FOV.
	Reference affine:
	array([[-1.49574971e+00, -1.03281870e-01,  4.54510152e-02,
	         1.11821228e+02],
	       [-1.12779170e-01,  1.38819790e+00, -5.56944251e-01,
	        -5.48834076e+01],
	       [ 3.71517451e-03,  5.58783770e-01,  1.39202881e+00,
	        -8.33356552e+01],
	       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
	         1.00000000e+00]])
	Image affine:
	array([[-1.49574971e+00, -1.03281826e-01,  4.54506166e-02,
	         1.11821251e+02],
	       [-1.12778962e-01,  1.38819790e+00, -5.56944311e-01,
	        -5.48833923e+01],
	       [ 3.71482549e-03,  5.58783770e-01,  1.39202881e+00,
	        -8.33356323e+01],
	       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
	         1.00000000e+00]])
	Reference shape:
	(140, 140, 92)
	Image shape:
	(140, 140, 92, 208)

Screenshots / relevant information:

I also found similar problems on githubhttps://github.com/PennLINC/qsiprep/issues/225, but there is no clear solution。
My file structure is as follows:

├── sub-1009_acq-dir107AP_dwi.bval
├── sub-1009_acq-dir107AP_dwi.bvec
├── sub-1009_acq-dir107AP_dwi.json
├── sub-1009_acq-dir107AP_dwi.nii.gz
├── sub-1009_acq-dir107AP_sbref.json
├── sub-1009_acq-dir107AP_sbref.nii.gz
├── sub-1009_acq-dir107PA_dwi.bval
├── sub-1009_acq-dir107PA_dwi.bvec
├── sub-1009_acq-dir107PA_dwi.json
├── sub-1009_acq-dir107PA_dwi.nii.gz
├── sub-1009_acq-dir107PA_sbref.json
├── sub-1009_acq-dir107PA_sbref.nii.gz
├── sub-1009_acq-dir99AP_dwi.bval
├── sub-1009_acq-dir99AP_dwi.bvec
├── sub-1009_acq-dir99AP_dwi.json
├── sub-1009_acq-dir99AP_dwi.nii.gz
├── sub-1009_acq-dir99AP_sbref.json
├── sub-1009_acq-dir99AP_sbref.nii.gz
├── sub-1009_acq-dir99PA_dwi.bval
├── sub-1009_acq-dir99PA_dwi.bvec
├── sub-1009_acq-dir99PA_dwi.json
├── sub-1009_acq-dir99PA_dwi.nii.gz
├── sub-1009_acq-dir99PA_sbref.json
└── sub-1009_acq-dir99PA_sbref.nii.gz

I want to end up with just one dwi file with a size of dir-208。

HI @yongzhang,

I have relabeled your post as Software Support and reorganized it according to the appropriate post template. In the future please submit software questions under this post category. Please edit your post to include the BIDS validation report.

Best,
Steven

Try upgrading to most recent version 0.17.0

Best,
Steven

Thank you for your reply。

  1. Try upgrading to most recent version 0.17.0
    I started with 0.17.0, but when I use --distortion-group-merge average, it reports missed 1 required positional arguement ‘omp_nthreads’.I think it might be a bug in 0.17.0.

  2. change --distortion-group-merge average to --distortion-group-merge concat
    I also tried this ,but it still reports a FOV error

Best
yongzhang

I just opened a PR to fix this Update distortion_group_merge.py by smeisler · Pull Request #555 · PennLINC/qsiprep · GitHub.

Best,
Steven

Whether I use --distortion-group-merge average or --distortion-group-merge concat, an error is reported (Field of view of image #1 is different from reference FOV.like related log output (up to 20 lines) :).

I use --separate_all_dwis, then average pa, ap, and join dir107 and dir99 together, will this work?

Dear Steven,

I followed the FIX you provided and manually modified the contents of the docker images and generated a new images to not report the missing “omp_nthreads”.
Later I found out that there might be a slight difference in bvec in the dwi image.Probably, this data can’t be used for analysis.

sub-1009_acq-dir99AP_space-T1w_desc-preproc_dwi.b

0.52095276 -0.71706105 0.46306768 5
0.52089550 -0.71735931 0.46266996 5
0.97552358 -0.17755992 -0.12971594 1500
0.28062523 0.78377350 -0.55402940 2990
0.61402912 0.66985686 0.41744464 1500
-0.49742072 0.67758098 0.54171638 3000
0.44022211 0.78634983 -0.43342639 1495
-0.91034294 -0.39708128 -0.11662838 2995
0.46529032 -0.24510091 -0.85054715 1490
-0.58079977 0.26853989 -0.76847769 2985
-0.70323715 0.23804039 -0.66992110 1490
-0.47958672 -0.41110233 0.77523639 3005
0.27620916 -0.95969084 -0.05198059 1500
-0.46980957 -0.66224785 -0.58370092 2990
-0.88808901 -0.06442007 0.45513512 1500
0.91061601 -0.31684139 -0.26531117 2995
-0.35459434 -0.05040005 -0.93366091 1490
0.52130910 -0.71710151 0.46260377 5
-0.55706419 0.82509436 -0.09433336 2995
-0.44697438 -0.88930474 0.09670051 1500
0.16822368 -0.00330000 -0.98574332 2985
-0.31898856 0.66605700 0.67425097 1500
0.88544417 0.08657982 0.45660986 3000
-0.16125794 -0.08905997 0.98288565 1505
0.61297754 0.76585443 -0.19423059 2990
0.76325474 -0.64606571 0.00642606 1500
0.15089271 -0.71262337 -0.68512724 2990
0.75950435 0.15015967 0.63293382 1505
-0.18387285 0.71123555 -0.67847975 2985
-0.23237892 0.58931727 -0.77376042 1490
-0.86615451 -0.20804060 0.45441772 3000
-0.30212004 -0.54684008 -0.78082611 1495
-0.40811293 -0.23688054 -0.88166402 2985
0.52026468 -0.71858371 0.46147818 5
-0.95707035 -0.28626130 -0.04550621 1495
-0.22247907 -0.97376467 0.04780623 3000
-0.57506335 0.73905146 0.35086334 1500
-0.82167109 0.48157830 -0.30485892 2990
0.70821057 0.52049601 -0.47699234 1495
-0.42384120 0.34295935 0.83829441 3005
0.48915056 -0.73214384 0.47402228 1505
-0.67870751 -0.43708097 -0.59018331 2990
-0.05723599 0.35267997 0.93399191 1505
0.16795454 -0.98281254 0.07662098 3000
0.07170383 0.98702945 -0.14363646 1490
0.14247861 0.36495950 -0.92005674 2980
0.78540413 -0.39664006 -0.47520208 1490
0.77906740 -0.24974045 -0.57505103 2990
-0.33112618 -0.49990027 0.80028443 1505
0.52117046 -0.71864615 0.46035754 5
0.62309967 0.75953960 0.18667190 2995
-0.94223332 0.26544037 -0.20429829 1495
-0.19550403 -0.03500001 -0.98007815 2980
0.71474405 0.65519822 0.24465533 1500
-0.45196113 0.82069479 0.34955858 3000
0.02204807 -0.88446282 -0.46608948 1495
-0.98521625 -0.16960004 0.02418201 3000
-0.73616814 -0.10714002 0.66826453 1500
-0.19864217 0.89139181 -0.40738426 2985
0.01496203 -0.73934141 0.67316448 1505
0.20988981 0.81728006 0.53665592 3000
0.75324878 -0.56410508 0.33823325 1505
-0.59462410 0.66645339 -0.44973554 2985
-0.57009708 -0.52666100 -0.63056920 1495
0.57572407 0.15197949 -0.80339531 2985
0.52423229 -0.71610039 0.46084785 5
-0.43024017 0.21390009 -0.87700635 1490
-0.42662671 -0.62378396 0.65489176 3000
-0.80365055 -0.58590186 0.10423433 1500
-0.06353572 0.48427790 0.87260422 3010
0.37406194 0.02268001 -0.92712636 1490
-0.69342419 0.05412001 -0.71849420 2990
0.44883752 -0.88847211 0.09571931 1500
0.72424574 -0.64222509 -0.25102799 2990
0.21390903 0.93990693 0.26611630 1500
-0.86416175 -0.49385986 0.09657597 3000
-0.89691011 0.38566005 0.21637603 1500
0.20191137 0.90105003 -0.38384975 2995
0.23513304 0.82459102 -0.51455039 1495
0.98490429 -0.11785980 0.12677778 3000
0.56708160 -0.40728258 -0.71591854 1490
0.52475321 -0.71680712 0.45915316 5
-0.21524734 0.37753884 -0.90062923 2985
-0.92672163 -0.05888010 -0.37110665 1495
-0.24936813 -0.94314050 -0.21977612 2995
0.02957801 -0.24818007 0.96826226 1510
-0.16016891 0.94211357 0.29456399 3000
-0.16308340 -0.72990626 -0.66380769 1495
-0.81254239 -0.51978281 -0.26381943 2990
-0.91673014 -0.22420052 0.33066597 1500
-0.72228477 -0.47100311 0.50641957 3000
0.58464686 0.14507972 0.79821045 1505
0.84557418 -0.52172135 0.11318629 2995
0.33062104 -0.89975847 -0.28482351 1495
0.06775149 0.68500096 -0.72538502 2985
0.18516347 -0.90616036 0.38024715 1505
0.48518528 -0.54496144 -0.68382181 2985
-0.15487811 0.54746037 0.82237456 1505
-0.57336620 -0.28548110 -0.76795295 2985
-0.54216510 -0.80226163 0.24986651 1500

sub-1009_acq-dir99PA_space-T1w_desc-preproc_dwi.b

0.52494469 -0.73012374 0.43743844 5
0.52476322 -0.73012448 0.43765489 5
0.97616808 -0.16954001 -0.13546981 1500
0.27905678 0.80470503 -0.52400108 2990
0.61219629 0.65529817 0.44249296 1500
-0.50114929 0.65464429 0.56594191 3000
0.43801290 0.80322678 -0.40369721 1495
-0.90877943 -0.39561975 -0.13268372 2995
0.46684753 -0.21095979 -0.85880694 1490
-0.58087540 0.29500071 -0.75865562 2985
-0.70401952 0.25892056 -0.66129922 1490
-0.47859064 -0.44251874 0.75837205 3005
0.27929425 -0.95607285 -0.08899113 1500
-0.46705344 -0.64080198 -0.60928968 2990
-0.88779037 -0.08566004 0.45220639 1500
0.91115180 -0.30393993 -0.27824974 2995
-0.35438379 -0.01575999 -0.93496725 1490
0.52488296 -0.73189576 0.43454168 5
-0.56091396 0.82550289 -0.06261402 2995
-0.44374268 -0.89410541 0.06056357 1500
0.16869923 0.03547996 -0.98502880 2985
-0.32151726 0.63787852 0.69981258 1500
0.88555571 0.07159998 0.45898205 3000
-0.16025798 -0.12775998 0.97877207 1505
0.61112437 0.77404300 -0.16548244 2990
0.76512249 -0.64359705 -0.01924591 1500
0.15370338 -0.68522168 -0.71193154 2990
0.75900752 0.12789992 0.63839580 1505
-0.18701713 0.73567656 -0.65100276 2985
-0.23582260 0.61642156 -0.75127370 1490
-0.86529249 -0.22986013 0.44545845 3000
-0.29818632 -0.51870055 -0.80127065 1495
-0.40608304 -0.20519952 -0.89049970 2985
0.52501004 -0.73223448 0.43381693 5
-0.95545940 -0.28957921 -0.05693165 1495
-0.21790804 -0.97594018 0.00754020 3000
-0.58101607 0.72054009 0.37847365 1500
-0.82401818 0.48775892 -0.28824516 2990
0.70635997 0.54070304 -0.45683237 1495
-0.42556480 0.30924058 0.85044980 3005
0.49135950 -0.74879619 0.44482594 1505
-0.67679867 -0.41682041 -0.60679840 2990
-0.05868813 0.31658071 0.94674831 1505
0.17013915 -0.98475855 0.03610075 3000
0.06808677 0.99194543 -0.10681038 1490
0.14205036 0.39957988 -0.90562554 2980
0.78608142 -0.37671972 -0.49005944 1490
0.77959898 -0.22532028 -0.58434254 2990
-0.32971277 -0.53050123 0.78093401 1505
0.52427953 -0.73255934 0.43415181 5
0.62292204 0.75239763 0.21416333 2995
-0.94323594 0.26956056 -0.19401820 1495
-0.19487401 0.00092000 -0.98082785 2980
0.71452860 0.64629693 0.26786033 1500
-0.45406902 0.80659471 0.37845252 3000
0.02301390 -0.86677637 -0.49816572 1495
-0.98495257 -0.17208010 0.01602741 3000
-0.73690992 -0.13221998 0.66293412 1500
-0.20025778 0.90430802 -0.37699314 2985
0.01464594 -0.76177705 0.64767370 1505
0.20754560 0.79913844 0.56418310 3000
0.75249100 -0.57570230 0.31988148 1505
-0.59490872 0.67967854 -0.42909288 2985
-0.56773102 -0.50626091 -0.64913896 1495
0.57749685 0.18015964 -0.79626622 2985
0.52135157 -0.73305658 0.43683016 5
-0.42668894 0.24570054 -0.87038371 1490
-0.42959181 -0.64849670 0.62841300 3000
-0.80398310 -0.58937934 0.07901371 1500
-0.06627437 0.45226249 0.88941911 3010
0.37759672 0.05700002 -0.92421410 1490
-0.69077664 0.08022007 -0.71860446 2990
0.44684963 -0.89228006 0.06451120 1500
0.72445132 -0.63309591 -0.27269004 2990
0.21398017 0.92953294 0.30030152 1500
-0.86474769 -0.49669982 0.07416677 3000
-0.89772233 0.37765930 0.22686578 1500
0.20452636 0.91351982 -0.35163973 2995
0.23817597 0.84171778 -0.48454452 1495
0.98430908 -0.12441988 0.12512128 3000
0.56881683 -0.38311921 -0.72778230 1490
0.52143043 -0.73314342 0.43659024 5
-0.21052028 0.41004055 -0.88743899 2985
-0.92484033 -0.04522002 -0.37765793 1495
-0.24920621 -0.93368080 -0.25717002 2995
0.02494400 -0.28238002 0.95897827 1510
-0.16109942 0.93119667 0.32698583 3000
-0.16069434 -0.70516150 -0.69059727 1495
-0.81185740 -0.50791837 -0.28793488 2990
-0.91838028 -0.23552059 0.31797439 1500
-0.72503497 -0.48924065 0.48473485 3000
0.58197484 0.11422016 0.80514536 1505
0.84373556 -0.52823847 0.09525972 2995
0.32924978 -0.88981724 -0.31594282 1495
0.07192782 0.71004016 -0.70047795 2985
0.18128093 -0.92015865 0.34705229 1505
0.48649834 -0.52032251 -0.70184318 2985
-0.15759440 0.51816133 0.84063835 1505
-0.57003304 -0.25715957 -0.78034049 2985
-0.54457802 -0.81000300 0.21755441 1500

Best,

yongzhang

@yongzhang you should expect to see differences in the bvecs after preprocessing. They are rotated as part of head motion correction. The “average” strategy combines them based on their original bvecs even though they are different after motion correction.

@mattcieslak This is how I understand that different bevc in ap and pa can cause fov error. but when I use--separate_all_dwis, even if it can execute successfully, I don’t know how it executes topup, after all b0(bvalue = 5) image has different bvec.

Hi,I found the same bvec and bval also report fov error. I would like to ask what is the cause of this error.I still use the above modified version of qsiprep

Node: qsiprep_wf.single_subject_4069_wf.dwi_preproc_wf.pre_hmc_wf.raw_rpe_concat
Working directory: /tmp/work/qsiprep_wf/single_subject_4069_wf/dwi_preproc_wf/pre_hmc_wf/raw_rpe_concat

Node inputs:

compress = True
dtype = f4
header_source = <undefined>
in_files = <undefined>
is_dwi = True

Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command
    raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node raw_rpe_concat.

Traceback:
	Traceback (most recent call last):
	  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 398, in run
	    runtime = self._run_interface(runtime)
	  File "/usr/local/miniconda/lib/python3.8/site-packages/qsiprep/interfaces/nilearn.py", line 134, in _run_interface
	    new_nii = concat_imgs(self.inputs.in_files, dtype=self.inputs.dtype)
	  File "/usr/local/miniconda/lib/python3.8/site-packages/nilearn/_utils/niimg_conversions.py", line 487, in concat_niimgs
	    for index, (size, niimg) in enumerate(zip(lengths, _iter_check_niimg(
	  File "/usr/local/miniconda/lib/python3.8/site-packages/nilearn/_utils/niimg_conversions.py", line 160, in _iter_check_niimg
	    raise ValueError(
	ValueError: Field of view of image #1 is different from reference FOV.
	Reference affine:
	array([[-1.49869120e+00, -4.97166775e-02,  3.81188020e-02,
	         1.06409637e+02],
	       [-6.02812544e-02,  1.39290857e+00, -5.53327799e-01,
	        -5.03080902e+01],
	       [ 1.70575883e-02,  5.54376960e-01,  1.39369118e+00,
	        -9.53015900e+01],
	       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
	         1.00000000e+00]])
	Image affine:
	array([[-1.49869120e+00, -4.97166775e-02,  3.81188020e-02,
	         1.06539520e+02],
	       [-6.02812544e-02,  1.39290857e+00, -5.53327799e-01,
	        -5.38477631e+01],
	       [ 1.70575883e-02,  5.54376960e-01,  1.39369118e+00,
	        -9.63844452e+01],
	       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
	         1.00000000e+00]])
	Reference shape:
	(140, 140, 92)
	Image shape:
	(140, 140, 92, 208)
clear

clc

ap_bval_99 = load("sub-4069_acq-dir99AP_dwi.bval");

pa_bval_99 = load("sub-4069_acq-dir99PA_dwi.bval");

isequal(ap_bval_99,pa_bval_99)

ap_bval_107 = load("sub-4069_acq-dir107AP_dwi.bval");

pa_bval_107 = load("sub-4069_acq-dir107PA_dwi.bval");

isequal(ap_bval_107,pa_bval_107)

ap_bvec_99 = load("sub-4069_acq-dir99AP_dwi.bvec");

pa_bvec_99 = load("sub-4069_acq-dir99PA_dwi.bvec");

isequal(ap_bvec_99,pa_bvec_99)

ap_bvec_107 = load("sub-4069_acq-dir107AP_dwi.bvec");

pa_bvec_107 = load("sub-4069_acq-dir107PA_dwi.bvec");

isequal(ap_bvec_107,pa_bvec_107)


output:ans =

  logical

   1


ans =

  logical

   1


ans =

  logical

   1


ans =

  logical

   1