[RESOLVED] Trouble running dwi_legacy

Dear Jure and QuNex Experts:

I have been trying to run dwi_legacy but was not able to. I unfortunately couldn’t figure out what was the problem at all.

Below is the exact command I ran:

qunex_container dwi_legacy \
  --sessionsfolder="${WORK_DIR}/${STUDY_NAME}/sessions" \
  --sessions="${SESSIONS}" \
  --function='dwi_legacy' \
  --PEdir='1' \
  --echospacing='0.69' \
  --TE='2.46'\
  --unwarpdir='x-' \
  --diffdatasuffix='DWI_dir98_99_AP' \
  --usefieldmap='no' \
  --scanner='siemens' \
  --overwrite='yes' \
  --container="${QUNEX_CONTAINER}" \
  --nv;

And below is the error messages that I got:

--> QuNex will run the command over 1 sessions. It will utilize:

    Scheduled jobs: 1
    Maximum sessions run in parallel for a job: 1.
    Maximum elements run in parallel for a session: 1.
    Up to 1 processes will be utilized for a job.

    Job #1 will run sessions: 010A
/home/ehui/tmpxg4uy14t
singularity exec --cleanenv  --nv /hdd/qunex/qunexcontainer/qunex_suite-0.93.6.sif bash /home/ehui/tmpxg4uy14t
ehui@ehui:~/qunex$ --> unsetting the following environment variables: PATH MATLABPATH PYTHONPATH QUNEXVer TOOLS QUNEXREPO QUNEXPATH QUNEXLIBRARY QUNEXLIBRARYETC TemplateFolder FSL_FIXDIR FREESURFERDIR FREESURFER_HOME FREESURFER_SCHEDULER FreeSurferSchedulerDIR WORKBENCHDIR DCMNIIDIR DICMNIIDIR MATLABDIR MATLABBINDIR OCTAVEDIR OCTAVEPKGDIR OCTAVEBINDIR RDIR HCPWBDIR AFNIDIR PYLIBDIR FSLDIR FSLGPUDIR PALMDIR QUNEXMCOMMAND HCPPIPEDIR CARET7DIR GRADUNWARPDIR HCPPIPEDIR_Templates HCPPIPEDIR_Bin HCPPIPEDIR_Config HCPPIPEDIR_PreFS HCPPIPEDIR_FS HCPPIPEDIR_PostFS HCPPIPEDIR_fMRISurf HCPPIPEDIR_fMRIVol HCPPIPEDIR_tfMRI HCPPIPEDIR_dMRI HCPPIPEDIR_dMRITract HCPPIPEDIR_Global HCPPIPEDIR_tfMRIAnalysis HCPCIFTIRWDIR MSMBin HCPPIPEDIR_dMRITractFull HCPPIPEDIR_dMRILegacy AutoPtxFolder FSLGPUScripts FSLGPUBinary EDDYCUDADIR USEOCTAVE QUNEXENV CONDADIR MSMBINDIR MSMCONFIGDIR R_LIBS FSL_FIX_CIFTIRW FSFAST_HOME SUBJECTS_DIR MINC_BIN_DIR MNI_DIR MINC_LIB_DIR MNI_DATAPATH FSF_OUTPUT_FORMAT

Generated by QuNex
------------------------------------------------------------------------
Version: 0.93.6
User: ehui
System: ehui
OS: RedHat Linux #141~18.04.1-Ubuntu SMP Thu Aug 11 20:15:56 UTC 2022
------------------------------------------------------------------------

        ██████\                  ║      ██\   ██\
       ██  __██\                 ║      ███\  ██ |
       ██ /  ██ |██\   ██\       ║      ████\ ██ | ██████\ ██\   ██\
       ██ |  ██ |██ |  ██ |      ║      ██ ██\██ |██  __██\\██\ ██  |
       ██ |  ██ |██ |  ██ |      ║      ██ \████ |████████ |\████  /
       ██ ██\██ |██ |  ██ |      ║      ██ |\███ |██   ____|██  ██\
       \██████ / \██████  |      ║      ██ | \██ |\███████\██  /\██\
        \___███\  \______/       ║      \__|  \__| \_______\__/  \__|
            \___|                ║


                       DEVELOPED & MAINTAINED BY:

                    Anticevic Lab, Yale University
               Mind & Brain Lab, University of Ljubljana
                     Murray Lab, Yale University

                      COPYRIGHT & LICENSE NOTICE:

Use of this software is subject to the terms and conditions defined in
'LICENSE.md' which is a part of the QuNex Suite source code package:
https://bitbucket.org/oriadev/qunex/src/master/LICENSE.md

 ---> Setting up Octave


 ........................ Running QuNex v0.93.6 ........................


NOTE: Processing without FieldMap (TE option not needed)

Running dwi_legacy with the following parameters:
--------------------------------------------------------------
   Study Folder: /home/ehui/qunex/cimt
   Sessions Folder: /home/ehui/qunex/cimt/sessions
   Sessions: 010A
   Study Log Folder:
   Scanner: siemens
   Using FieldMap: no
   Echo Spacing: 0.69
   Phase Encoding Direction: 1
   TE value for Fieldmap: 2.46
   EPI Unwarp Direction: x-
   Diffusion Data Suffix Name: DWI_dir98_99_AP
   Overwrite prior run: yes


--- Full QuNex call for command: dwi_legacy

/opt/qunex/bash/qx_utilities/dwi_legacy.sh     --sessionsfolder=/home/ehui/qunex/cimt/sessions     --session=010A     --scanner=siemens     --usefieldmap=no     --PEdir=1     --echospacing=0.69     --TE=2.46     --unwarpdir=x-     --diffdatasuffix=DWI_dir98_99_AP     --overwrite=yes

--------------------------------------------------------------




--------------------------------------------------------------

   Running dwi_legacy locally on ehui
   Command log:     /home/ehui/qunex/cimt/processing/logs/runlogs/Log-dwi_legacy_2022-10-07_09.18.50.162679.log
   Command output: /home/ehui/qunex/cimt/processing/logs/comlogs/tmp_dwi_legacy_010A_2022-10-07_09.18.50.162679.log

--------------------------------------------------------------


This function runs the DWI preprocessing using the FUGUE method for legacy data
that are not TOPUP compatible.

It explicitly assumes the the Human Connectome Project folder structure for
preprocessing.

DWI data needs to be in the following folder::

 <study_folder>/<session>/hcp/<session>/T1w/Diffusion

T1w data needs to be in the following folder::

 <study_folder>/<case>/hcp/<case>/T1w

Note:

- If PreFreeSurfer component of the HCP Pipelines was run the function will
  make use of the T1w data [Results will be better due to superior brain
  stripping].
- If PreFreeSurfer component of the HCP Pipelines was NOT run the function will
  start from raw T1w data [Results may be less optimal].
- If you are this function interactively you need to be on a GPU-enabled node
  or send it to a GPU-enabled queue.

INPUTS
======

--sessionsfolder    Path to study data folder
--sessions          Comma separated list of sessions to run
--scanner           Name of scanner manufacturer (siemens or ge supported)
--echospacing       EPI Echo Spacing for data [in msec]; e.g. 0.69
--PEdir             Use 1 for Left-Right Phase Encoding, 2 for
                    Anterior-Posterior
--unwarpdir         Direction for EPI image unwarping; e.g. x or x- for LR/RL,
                    y or y- for AP/PA; may been to try out both -/+ combinations
--usefieldmap       Whether to use the standard field map (yes / no). If set
                    to <yes> then the parameter --TE becomes mandatory
--diffdatasuffix    Name of the DWI image; e.g. if the data is called
                    <SessionID>_DWI_dir91_LR.nii.gz - you would enter
                    DWI_dir91_LR
--overwrite         Delete prior run for a given session (yes / no)

FIELDMAP-SPECFIC INPUT
----------------------

--TE                This is the echo time difference of the fieldmap sequence
                    - find this out form the operator - defaults are *usually*
                    2.46ms on SIEMENS


EXAMPLE USE
===========

Examples using Siemens FieldMap (needs GPU-enabled node).

Run directly via::

 /opt/qunex/bash/qx_utilities/DWIPreprocPipelineLegacy.sh \
 --<parameter1> --<parameter2> --<parameter3> ... --<parameterN>

 NOTE: --scheduler is not available via direct script call.

Run via::

 qunex dwi_legacy --<parameter1> --<parameter2> ... --<parameterN>

 NOTE: scheduler is available via qunex call.

--scheduler       A string for the cluster scheduler (e.g. LSF, PBS or SLURM)
                  followed by relevant options

For SLURM scheduler the string would look like this via the qunex call::

 --scheduler='SLURM,jobname=<name_of_job>,time=<job_duration>,ntasks=<number_of_tasks>,cpus-per-task=<cpu_number>,mem-per-cpu=<memory>,partition=<queue_to_send_job_to>'

::

 qunex dwi_legacy \
 --sessionsfolder='<folder_with_sessions>' \
 --sessions='<comma_separarated_list_of_cases>' \
 --function='dwi_legacy' \
 --PEdir='1' \
 --echospacing='0.69' \
 --TE='2.46' \
 --unwarpdir='x-' \
 --diffdatasuffix='DWI_dir91_LR' \
 --usefieldmap='yes' \
 --scanner='siemens' \
 --overwrite='yes'

Example with flagged parameters for submission to the scheduler using Siemens
FieldMap (needs GPU-enabled queue)::

 qunex dwi_legacy \
 --sessionsfolder='<folder_with_sessions>' \
 --sessions='<comma_separarated_list_of_cases>' \
 --function='dwi_legacy' \
 --PEdir='1' \
 --echospacing='0.69' \
 --TE='2.46' \
 --unwarpdir='x-' \
 --diffdatasuffix='DWI_dir91_LR' \
 --scheduler='<name_of_scheduler_and_options>' \
 --usefieldmap='yes' \
 --scanner='siemens' \
 --overwrite='yes' \

Example with flagged parameters for submission to the scheduler using GE data
without FieldMap (needs GPU-enabled queue)::

 qunex dwi_legacy \
 --sessionsfolder='<folder_with_sessions>' \
 --sessions='<comma_separarated_list_of_cases>' \
 --diffdatasuffix='DWI_dir91_LR' \
 --scheduler='<name_of_scheduler_and_options>' \
 --usefieldmap='no' \
 --PEdir='1' \
 --echospacing='0.69' \
 --unwarpdir='x-' \
 --scanner='ge' \
 --overwrite='yes' \


 ===> ERROR during dwi_legacy. Check final QuNex error log output:

    /home/ehui/qunex/cimt/processing/logs/comlogs/error_dwi_legacy_010A_2022-10-07_09.18.50.162679.log


 ▄▄▄▄▄▄▄         ||  ▄▄   ▄▄
 ▓▓    ▓         ||  ▓▓▓▄ ▓▓                ▓▓▓▓▓ ▄▓▓▓▓  ▓ ▄▓    ▄▓▓▓ ▓▓▓▄
 ▓▓  ▓ ▓  ▓   ▓  ||  ▓▓ ▐▓▓▓ ▄▄▄▄ ▀▓▓ ▓▓▀   ▓▓    ▓  ▓▓ ▓▓ ▓▓   ▄▓▓▄  ▓  ▓▓
 ▓▓▄▄▓▄▓  ▓▓  ▓  ||  ▓▓   ▓▓ ▓▄▄▓    ▓▄     ▓▓▀▀  ▓▓▓▓▓ ▓▌ ▓▓   ▀▓▓   ▓  ▓▓
     ▓▄▄  ▓▓▄▄▓  ||  ▓▓    ▓ ▓▄▄  ▄▓▓ ▓▓▄   ▓     ▓▀ ▓  ▓  ▓▓▓▀▀ ▓▓▓▓ ▓▓▓▀
                 ||

I did put the data under ${sessionsfolder}/${sessions}/hcp/${sessions}/T1w/Diffusion like so:

010A_DWI_dir98_99_AP.nii.gz  
QC  
bvals 
bvecs  
eddylogs

Your help would be greatly appreciated. Thank you very much!

Best,
Ed

Ed,

  1. I suggest you use the latest version of QuNex (0.94.14) over the last couple of patches we made a number of changes related to dwi_legacy_gpu. The most notable one is that its outputs now seamlessly plug into the remaining commands of the DWI pipelines. Previously some manual operations had to be performed.

  2. The DWI data needs to be in the following folder:

    <study_folder>/<session>/hcp/<session>/unprocessed/Diffusion

T1w data needs to be in the following folder:

    <study_folder>/<session>/hcp/<session>/T1w

This info can be also found by using inline help qunex dwi_legacy_gpu --help.

Hope this will resolve your issues. As always, if it does not, let me know and we will dig deeper.

Hi Jure:

Perhaps I may try the new release later;)

For the 0.93.60 release, I did actually put the data in the exact locations you mentioned. May I ask what else could be causing the error?

Many thanks as always!
Ed

Not sure, I would need to see the contents of

/home/ehui/qunex/cimt/processing/logs/comlogs/error_dwi_legacy_010A_2022-10-07_09.18.50.162679.log

Above is just the general error log.

Hi Jure:

Looks like I will need to try the new release instead as the log file you mentioned didnt say anything except the actual command being called.

Many thanks!
Ed

Hi Jure:

I have just tried using the 0.94.14 release. Below is the command input I specified:

qunex_container dwi_legacy_gpu \
  --sessionsfolder="${WORK_DIR}/${STUDY_NAME}/sessions" \
  --sessions="${SESSIONS}" \
  --echospacing="0.69" \
  --pedir="2" \
  --TE="2.46"\
  --unwarpdir="y" \
  --diffdatasuffix="DWI_dir98_99_AP" \
  --usefieldmap="no" \
  --scanner="siemens" \
  --overwrite="yes" \
  --container="${QUNEX_CONTAINER}" \
  --nv

Although I have already specified the pedir flag, the error (it complained I didn’t specify the phase encoding direction even though I already did) still appeared:

--------------------------------------------------------------

   Running dwi_legacy_gpu locally on ehui
   Command log:     /home/ehui/qunex/cimt/processing/logs/runlogs/Log-dwi_legacy_gpu_2022-10-07_22.58.01.777281.log
   Command output: /home/ehui/qunex/cimt/processing/logs/comlogs/tmp_dwi_legacy_gpu_010A_2022-10-07_22.58.01.777281.log

--------------------------------------------------------------

ERROR: <phase-encoding-dir> not specified

 ===> ERROR during dwi_legacy_gpu. Check final QuNex error log output:

    /home/ehui/qunex/cimt/processing/logs/comlogs/error_dwi_legacy_gpu_010A_2022-10-07_22.58.01.777281.log

Your help would be greatly appreciated as always!

Thank you very much,
Ed

Can you try using --PEdir instead of --pedir. I think we might have a bug here that only --PEdir gets accepted.

Hi Jure: I can finally run dwi_legacy but I ran into errors when I ran dwi_pre_tractography:

# Generated by QuNex 0.93.6 on 2022-10-08_14.47.42.544973
#
--> Running make_trajectory_space.sh
Image Exception : #63 :: No image files match: /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/T1w_acpc_dc_restore_1.49
Image Exception : #22 :: Failed to read volume /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/T1w_acpc_dc_restore_1.49
Error : No image files match: /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/T1w_acpc_dc_restore_1.49
terminate called after throwing an instance of 'std::runtime_error'
  what():  Failed to read volume /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/T1w_acpc_dc_restore_1.49
Error : No image files match: /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/T1w_acpc_dc_restore_1.49
/opt/qunex/bash/qx_utilities/diffusion_tractography_dense/pre_tractography/make_trajectory_space.sh: line 69: 29948 Aborted                 (core dumped) ${FSLDIR}/bin/applywarp --rel --interp=nn -i "$T1wFolder"/wmparc.nii.gz -r "$T1wFolder"/"$T1wImage"_"$DiffusionResolution" --premat=$FSLDIR/etc/flirtsch/ident.mat -o "$T1wFolder"/"$wmparc"_"$DiffusionResolution"

I am guessing this is caused by the dwi_legacy script didn’t create additional images with the resolution of the diffusion? Many thanks as always! Edward

Try using 0.94.14, this bug was fixed in that version.

Jure

Hi Jure:

I was trying to build the singularity for this 0.93.14 release. May I ask what are the commands I need to specify in order to do so?

I tried the following but didn’t work:

export APPTAINER_DOCKER_USERNAME=ehui
singularity build --docker-login qunexcontainer-0.93.14.sif docker://gitlab.qunex.yale.edu:5002/qunex/qunexcontainer:0.93.14

The same commands work for 0.94.14 release though.

Many thank as always!
Ed

Oh, sorry. My bad, the correct version is 0.94.14, that is the one that should work. Your error logs above are saying you are using 0.93.6:

# Generated by QuNex 0.93.6 on 2022-10-08_14.47.42.544973

Hi Jure:

I have just run dwi_legacy_gpu and dwi_pre_tractography using 0.94.14 release. However, I got the following error:

# Generated by QuNex 0.94.14 on 2022-10-10_23.56.02.647778
#
--> Running make_trajectory_space.sh

WARNING: name collision in input name 'CTX-LH-UNKNOWN', changing one to 'CTX-LH-UNKNOWN_1'


WARNING: name collision in input name 'CTX-RH-UNKNOWN', changing one to 'CTX-RH-UNKNOWN_1'


WARNING: name collision in input name 'WM-LH-UNKNOWN', changing one to 'WM-LH-UNKNOWN_1'


WARNING: name collision in input name 'WM-RH-UNKNOWN', changing one to 'WM-RH-UNKNOWN_1'


WARNING: name collision in input name 'CTX-LH-UNKNOWN', changing one to 'CTX-LH-UNKNOWN_1'


WARNING: name collision in input name 'CTX-RH-UNKNOWN', changing one to 'CTX-RH-UNKNOWN_1'


WARNING: name collision in input name 'WM-LH-UNKNOWN', changing one to 'WM-LH-UNKNOWN_1'


WARNING: name collision in input name 'WM-RH-UNKNOWN', changing one to 'WM-RH-UNKNOWN_1'

--> Running make_workbench_uodfs.sh
Creating Fibre File for Connectome Workbench

While running:
/opt/workbench/workbench-1.5.0/bin_rh_linux64/../exe_rh_linux64/wb_command -estimate-fiber-binghams /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Diffusion.bedpostX/merged_f1samples.nii.gz /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Diffusion.bedpostX/merged_th1samples.nii.gz /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Diffusion.bedpostX/merged_ph1samples.nii.gz /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Diffusion.bedpostX/merged_f2samples.nii.gz /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Diffusion.bedpostX/merged_th2samples.nii.gz /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Diffusion.bedpostX/merged_ph2samples.nii.gz /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Diffusion.bedpostX/merged_f3samples.nii.gz /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Diffusion.bedpostX/merged_th3samples.nii.gz /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Diffusion.bedpostX/merged_ph3samples.nii.gz /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Whole_Brain_Trajectory_1.49.nii.gz /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Diffusion.bedpostX/Whole_Brain_Trajectory_1.49.fiberTEMP.nii

ERROR: all inputs must be in the same volume space
While running:
/opt/workbench/workbench-1.5.0/bin_rh_linux64/../exe_rh_linux64/wb_command -add-to-spec-file /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Native/010A.native.wb.spec INVALID /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Diffusion.bedpostX/Whole_Brain_Trajectory_1.49.fiberTEMP.nii

ERROR: data file not found


While running:
/opt/workbench/workbench-1.5.0/bin_rh_linux64/../exe_rh_linux64/wb_command -add-to-spec-file /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/fsaverage_LR32k/010A.32k_fs_LR.wb.spec INVALID /home/ehui/qunex/cimt/sessions/010A/hcp//010A/T1w/Diffusion.bedpostX/Whole_Brain_Trajectory_1.49.fiberTEMP.nii

ERROR: data file not found

Can you be so kind to tell me what went wrong?

Many thanks!
Ed

It seems like a mismatch in some of the data/inputs. This will be hard to debug without me taking a look at the data. Could you maybe send me the DWI data so I can try running on my end?

Thanks!

Hi Jure:

I just recalled that, except the diffusion data (which was processed by 0.94.14 release), everything else were preprocessed using the 0.93.6 release.

So I am still waiting for the entire pipeline on all the data (using the 0.94.14 release) to finish, and to see if this problem still persists. If the problem still persists, I certainly would be more than happy to update you again and give you the data for testing.

Thanks so much!
Ed

Hi Jure:

Looks like the culprit is in the manually combined dMRI data (because I have acquired DWI_dir98_AP, and DWI_dir99_AP).

The codes ran fine if I only used one of the dMRI data for the dwi_pre_tractography. But when I ran the script on the manually combined data, the error (ERROR: all inputs must be in the same volume space) appeared.

May I ask what is the right way of manually combining two sets of DWI data together?

Many thanks as always.
Ed

Hi Ed,

I just reminded my colleague that you are still waiting for guidance about how to combine DWIs.

Unfortunately I have never done this myself. Next week, I am meeting DWI experts that also contribute to FSL, one of the items on the agenda is to implement a QuNex command that would do this DWI merging for users. I cannot give an eta about this as I am not yet sure how complex this will be to implement.

Jure

Hi Jure:

Thanks so much for your help indeed! I look forward to hearing from your colleague on the advices on how to combine DWIs.

Best,
Ed