pnlbwh / pnlNipype

PNL pipeline for NIFTI images
Other
10 stars 15 forks source link

fsl_topup_epi_eddy local variable 'bvals2' referenced before assignment #44

Closed njhunsak closed 4 years ago

njhunsak commented 4 years ago

I have some AP and PA scans so I tried to run the topup eddy epi command:

(base) bash-4.2$ ~/build/pnlNipype/exec/fsl_topup_epi_eddy \
> --acqp acqparams.txt \
> --numb0 1 \
> --whichVol 1,2 \
> --bvals dwi_acq-AP_xc.bval,dwi_acq-PA_xc.bval \
> --bvecs dwi_acq-AP_xc.bvec,dwi_acq-PA_xc.bvec \
> --config /fslhome/intj5/build/pnlNipype/scripts/eddy_config.txt \
> --imain dwi_acq-AP_bse.nii.gz,dwi_acq-PA_bse.nii.gz \
> --mask dwi_acq-AP_mask.nii.gz,dwi_acq-PA_mask.nii.gz \
> --out dwi_epi
2019-12-10 18:16:17,232 /fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy INFO  Masking the volumes
2019-12-10 18:16:17,232 /fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy DEBUG  Running ['/fslhome/intj5/apps/fsl/bin/fslmaths', '/lustre/scratch/usr/intj5/data/tmp/sub-02C1049_ses-1/dwi_acq-AP_bse.nii.gz', '-mas', '/lustre/scratch/usr/intj5/data/tmp/sub-02C1049_ses-1/dwi_acq-AP_mask.nii.gz', '/fslhome/intj5/compute/tmp/tmpjsnoo8lr/primaryMasked.nii.gz']
2019-12-10 18:16:17,386 /fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy DEBUG  Running ['/fslhome/intj5/apps/fsl/bin/fslmaths', '/lustre/scratch/usr/intj5/data/tmp/sub-02C1049_ses-1/dwi_acq-PA_bse.nii.gz', '-mas', '/lustre/scratch/usr/intj5/data/tmp/sub-02C1049_ses-1/dwi_acq-PA_mask.nii.gz', '/fslhome/intj5/compute/tmp/tmpjsnoo8lr/secondaryMasked.nii.gz']
2019-12-10 18:16:17,487 /fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy INFO  Extracting B0 from masked volumes
2019-12-10 18:16:17,993 /fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy INFO  Writing acqparams.txt for topup
2019-12-10 18:16:18,000 /fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy INFO  Merging B0_PA and BO_AP
2019-12-10 18:16:18,000 /fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy DEBUG  Running ['/fslhome/intj5/apps/fsl/bin/fslmerge', '-t', '/fslhome/intj5/compute/tmp/tmpjsnoo8lr/B0_PA_AP_merged.nii.gz', '/fslhome/intj5/compute/tmp/tmpjsnoo8lr/B0_PA.nii.gz', '/fslhome/intj5/compute/tmp/tmpjsnoo8lr/secondaryMasked.nii.gz']
2019-12-10 18:16:18,180 /fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy INFO  Running topup
2019-12-10 18:16:18,180 /fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy DEBUG  Running ['/fslhome/intj5/apps/fsl/bin/topup', '--imain=/fslhome/intj5/compute/tmp/tmpjsnoo8lr/B0_PA_AP_merged.nii.gz', '--datain=/fslhome/intj5/compute/tmp/tmpjsnoo8lr/acqp_topup.txt', '--out=/fslhome/intj5/compute/tmp/tmpjsnoo8lr/topup_results', '--verbose']
SSD = 2529.07   n = 603288  Reg = 0 Cost = 2529.07
2019-12-10 18:18:04,254 /fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy INFO  Running applytopup
2019-12-10 18:18:04,254 /fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy DEBUG  Running ['/fslhome/intj5/apps/fsl/bin/applytopup', '--imain=/lustre/scratch/usr/intj5/data/tmp/sub-02C1049_ses-1/dwi_acq-AP_mask.nii.gz,/lustre/scratch/usr/intj5/data/tmp/sub-02C1049_ses-1/dwi_acq-PA_mask.nii.gz', '--datain=/lustre/scratch/usr/intj5/data/tmp/sub-02C1049_ses-1/acqparams.txt', '--inindex=1,2', '--topup=/fslhome/intj5/compute/tmp/tmpjsnoo8lr/topup_results', '--out=/fslhome/intj5/compute/tmp/tmpjsnoo8lr/topup_mask.nii.gz', '--verbose']
2019-12-10 18:18:30,553 /fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy INFO  Writing index.txt for topup
Traceback (most recent call last):
  File "/fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy", line 390, in <module>
    TopupEddyEpi.run()
  File "/fslhome/intj5/miniconda3/lib/python3.7/site-packages/plumbum/cli/application.py", line 572, in run
    retcode = inst.main(*tailargs)
  File "/fslhome/intj5/build/pnlNipype/exec/fsl_topup_epi_eddy", line 348, in main
    write_bvals(combinedBvals, bvals1+bvals2)
UnboundLocalError: local variable 'bvals2' referenced before assignment
tashrifbillah commented 4 years ago

--imain dwi_acq-AP_bse.nii.gz,dwi_acq-PA_bse.nii.gz

See ./fsl_topup_epi_eddy.py --help message and this section, the first volume should be 4D. It appears that you provided a 3D bse instead.

On the other hand, perhaps our people didn't check all combination of --imain so the reported error wasn't discovered earlier. I corrected one typo. You can affect my changes as follows:

cd pnlNipype
mv scripts/fs2dwi.py .
git checkout -- scripts/fs2dwi.py
git pull origin master
mv fs2dwi.py scripts/
njhunsak commented 4 years ago

I've confirmed that this update works.