[RESOLVED] An error occurred while executing preprocess_bold

Hi, Jure

I encountered the following error while executing the preprocess_bold command. The logs file and the command used are shown below. Both the qunex_suite-1.3.1.sif and qunex_suite-1.2.2.sif container versions will encounter the following error.

qunex_container preprocess_bold \
    --sessionsfolder="/.../SMC/Group9_out/sessions" \
    --batchfile="/.../SMC/Group9_out/processing/batch.txt" \
    --image_target="nifti" \
    --nifti_tail="_hp0_clean" \
    --hcp_cifti_tail="_Atlas_hp0_clean" \
    --bold_actions="m,s,h,r,c,l" \
    --bold_nuisance="m,V,WM,1d" \
    --hipass_filter="0.01" \
    --lopass_filter="0.1" \
    --mov_bad='udvarsme' \
    --boldname="bold" \
    --bolds="all" \
    --overwrite="yes" \
    --pignore="hipass=linear|regress=ignore|lopass=linear" \
    --container="${QUNEX_CONTAINER}" \
    --scheduler='SLURM,jobname=preprocess,cpus-per-task=3,time=20:30:00'
ERROR img_readimage: File does not exist [/opt/qunex/library/data/atlases/MNITemplates/MNI152_T1_2mm_brain_mask.nii.gz]!

error_preprocess_bold_B1_114_S_5234_2018-01-23_2025-09-05_10.58.47.874492.log (3.8 KB)

It seems like you have a dated path in the batch file (MNITemplates is a legacy folder name that hase been renamed quite a long time ago). Open the batch file and look for dilate_mask. Instead of

/opt/qunex/library/data/atlases/MNITemplates/MNI152_T1_2mm_brain_mask.nii.gz

It should be

 /opt/qunex/library/data/atlases/mni_templates/MNI152_T1_2mm_brain_mask.nii.gz

In other words, whatever you have there. Replace MNITemplates with mni_templates.

Best, Jure

Hi, Jure

I followed your advice and modified batch.txt, then executed setup_hcp. The current parameter is _dilate_mask : ${TOOLS}/${QUNEXREPO}/library/data/atlases/mni_templates/MNI152_T1_2mm_brain_mask.nii.gz .

但我仍然出现上述报错

ERROR img_readimage: File does not exist [/opt/qunex/library/data/atlases/mni_templates/MNI152_T1_2mm_brain_mask.nii.gz]!

error_preprocess_bold_B1_114_S_5234_2018-01-23_2025-09-05_18.04.27.027273.log (3.8 KB)

Best, Olivier

Your batch is super old as there is one more legacy thing in there I did not catch before :slight_smile: .

The full path should be:

/opt/qunex/qx_library/data/atlases/mni_templates/MNI152_T1_2mm_brain_mask.nii.gz

Best, Jure

I’ve modified the parameters again. The current setting is: _dilate_mask : /opt/qunex/qx_library/data/atlases/mni_templates/MNI152_T1_2mm_brain_mask.nii.gz

Execution error! Processing failed! 
Please check arguments and/or try running the command in Matlab or Octave directly.

The exact error reported:
-----------------------------------------

Error identifier: 
   Error message: reshape: SIZE is not divisible by the product of known dimensions (= 179776)
     Error stack: /opt/qunex/matlab/qx_mri/img/@nimage/nimage.m -> image2D [line: 718]
                  /opt/qunex/matlab/qx_mri/img/@nimage/img_embed_stats.m -> img_embed_stats [line: 36]
                  /opt/qunex/matlab/qx_mri/img/@nimage/img_save_nifti.m -> img_save_nifti [line: 36]
                  /opt/qunex/matlab/qx_mri/img/@nimage/nimage.m -> img_saveimage [line: 542]
                  /opt/qunex/matlab/qx_mri/fc/fc_preprocess.m -> fc_preprocess [line: 1037]

=========================================

The contents of batch.txt and comlogs are as follows. I’m not sure if there are any other outdated parameter settings hidden within the batch file.
error_preprocess_bold_B1_114_S_5234_2019-02-06_2025-09-05_21.09.23.348975.log (5.5 KB)
batch.txt (6.1 KB)

Best, Olivier

I do not think this is parameter related. Seems like some kind of a data missmatch. Let me ask my colleagues who used this command more often to see if they have an idea.

Best, Jure

1 Like

Hm, is the 2mm template the correct one?

Can you maybe upload the BOLD that you want to preprocess somewhere so I can try reproducing this on my end.

Best, Jure

Hi, Jure

I believe the 2mm template should be fine. After adjusting the _dilate_mask parameter as you suggested, the error logs no longer mention any issues with the template.

I’ve uploaded a completed ICAFIX bold dataset to Google Drive. I hope you can test it using preprocess_bold.

Best, Olivier

Hi,

Can you try running the default setup on a single session. So just:

# best to provide full absolute path
STUDY_FOLDER="/XYZ/SMC/Group9_out"

qunex_container preprocess_bold \
  --sessionsfolder="${STUDY_FOLDER}/sessions" \
  --batchfile="${STUDY_FOLDER}/processing/batch.txt" \
  --session="PICK_ONE_SESSION" \
  --overwrite="yes" \
  --container="${QUNEX_CONTAINER}" \
  --scheduler='SLURM,jobname=preprocess,cpus-per-task=2,walltime=3:00:00'

I am unable to test this on our end since I also need a bunch of support things. If the above does not work, can you zip the whole

$STUDY/$SESSION/images

For one of the problematic sessions and share that.

Best, Jure

1 Like

Hi, Jure

I don’t believe the default settings can be applied to a single session. Even though I provided only one session ID, it still executed the command on all sessions. Therefore, I’ve uploaded the images folder from one of the sessions. I hope this proves useful to you. The session ID is 114_S_5234_2019-02-06.

Best, Olivier

You can always subset the sessions you want to run over. I made a mistake, session should be sessions. So:

# best to provide full absolute path
STUDY_FOLDER="/XYZ/SMC/Group9_out"

qunex_container preprocess_bold \
  --sessionsfolder="${STUDY_FOLDER}/sessions" \
  --batchfile="${STUDY_FOLDER}/processing/batch.txt" \
  --sessions="PICK_ONE_SESSION" \
  --overwrite="yes" \
  --container="${QUNEX_CONTAINER}" \
  --scheduler='SLURM,jobname=preprocess,cpus-per-task=2,walltime=3:00:00'

Hi, Jure

You’re right, it is indeed possible to process individual sessions. I executed the preprocess_bold command for each subject, and the output logs showed no differences.

=========================================
Execution error! Processing failed! 
Please check arguments and/or try running the command in Matlab or Octave directly.

The exact error reported:
-----------------------------------------

Error identifier: 
   Error message: reshape: SIZE is not divisible by the product of known dimensions (= 179776)
     Error stack: /opt/qunex/matlab/qx_mri/img/@nimage/nimage.m -> image2D [line: 718]
                  /opt/qunex/matlab/qx_mri/img/@nimage/img_embed_stats.m -> img_embed_stats [line: 36]
                  /opt/qunex/matlab/qx_mri/img/@nimage/img_save_nifti.m -> img_save_nifti [line: 36]
                  /opt/qunex/matlab/qx_mri/img/@nimage/nimage.m -> img_saveimage [line: 542]
                  /opt/qunex/matlab/qx_mri/fc/fc_preprocess.m -> fc_preprocess [line: 1037]

=========================================

Hi,

I was unable to reproduce this using the latest 1.3.3 container and your imaging data. The command below worked fine:

qunex_container preprocess_bold \
  --sessionsfolder="/data/jdemsar/studies/bold_test/sessions" \
  --batchfile="/data/jdemsar/studies/bold_test/processing/batch.txt" \
  --nifti_tail="_hp0_clean" \
  --hcp_cifti_tail="_Atlas_hp0_clean" \
  --bolds="1" \
  --overwrite="yes" \
  --container="$QX_CONTAINERS/qunex_suite-1.3.3.sif"

Best, Jure

Hi, Jure

I downloaded the latest 1.3.3 container and executed the following two commands separately.

qunex_container preprocess_bold \
    --sessionsfolder="/.../SMC/Group9_out/sessions" \
    --batchfile=".../SMC/Group9_out/processing/batch.txt" \
    --nifti_tail="_hp0_clean" \
    --hcp_cifti_tail="_Atlas_hp0_clean" \
    --bolds="1" \
    --overwrite="yes" \
    --container="${QUNEX_CONTAINER}" \
    --scheduler='SLURM,jobname=preprocess,cpus-per-task=3,time=5:30:00'
qunex_container preprocess_bold \
    --sessionsfolder="/.../SMC/Group9_out/sessions" \
    --batchfile="/.../SMC/Group9_out/processing/batch.txt" \
    --image_target="nifti" \
    --nifti_tail="_hp0_clean" \
    --hcp_cifti_tail="_Atlas_hp0_clean" \
    --bold_actions="m,s,h,r,c,l" \
    --bold_nuisance="m,V,WM,1d" \
    --hipass_filter="0.01" \
    --lopass_filter="0.1" \
    --mov_bad='udvarsme' \
    --boldname="bold" \
    --bolds="all" \
    --overwrite="yes" \
    --pignore="hipass=linear|regress=ignore|lopass=linear" \
    --container="${QUNEX_CONTAINER}" \
    --scheduler='SLURM,jobname=preprocess,cpus-per-task=3,time=5:30:00'

The results show that both the 1.2.2 and 1.3.3 containers can run correctly using the first command, but neither can run correctly using the second command (and both report the same error). It appears there is an issue with the command parameters.

Best, Olivier

It seems like the configuration causes some kind of a data missmatch. Not sure why this is the case. Most parameters are redundant as you are setting what the default value is…

What is different between the 2 calls is:

  • --bold_actions="m,s,h,r,c,l", here the default is s,h,r,c,l,
  • --hipass_filter="0.01", here the default is 0.008,
  • --lopass_filter="0.1", here the default is 0.09,
  • --bold_nuisance="m,V,WM,1d", here the default is m,m1d,mSq,m1dSq,V,WM,WB,1d,
  • --pignore I think the default is to drop bad frames.

I am extremely swamped right now and the person who wrote most of this code is on vacation, so this might take some time. If you can figure out exactly which parameter is problematic it would help us out a lot.

Also, is there a particular reason that you are deviating from sensible defaults which seem to work here? In other words, are the results obtained by defaults not OK?

Also, the first call is using only bold1, while the second one uses all bolds. It could be that bold1 is ok but others have some issues?

Best, Jure

1 Like

Did you maybe have any time to figure out which parameter is problematic here?

Thanks, Jure

Sorry, Jure. I need to prepare materials for a project soon. I should be able to test these parameter combinations next week to see if I can identify the faulty parameter.

No worries, let me know if you figure something out before we find the bandwidth to test this on our end. Thanks!

Best, Jure

Hi Olivier,

Did you maybe get a chance to investigate this on your end. If not, no worries, we will try to figure this out on our end.

Best, Jure

Hi, Jure

I should be able to test the command parameters soon. If I find any problematic parameters, I’ll let you know right away.

Best, Olivier