[RESOLVED] Nu_correct error in hcp_freesurfer pipeline

Dear all,

I am currently running the HCP preprocessing pipeline with a singularity container. After creating the data structure I ran:

qunex_container run_turnkey \
	--container="${con}" \
	--bind="${qdir}:${qdir}" \
	--dataformat="BIDS" \
	--bidsname="${bidsdir}" \
	--paramfile="${dir_paramfile}" \
	--mappingfile="${dir_mappingfile}" \
	--workingdir="${qdir}" \
	--projectname="${projectname}" \
	--path="${qdir}/${projectname}" \
	--sessions="sub1_2A" \
	--sessionids="sub1_2A" \
	--sessionsfoldername="sessions" \
	--turnkeytype="local" \
	--overwrite="yes" \
    --turnkeysteps="create_session_info,create_batch,setup_hcp,hcp_pre_freesurfer,hcp_freesurfer,hcp_post_freesurfer,hcp_fmri_volume,hcp_fmri_surface" \
	--scheduler="SLURM,jobname=qunex_turnkey,time=48:00:00,cpus-per-task=4,mem-per-cpu=32000"

However I am repeatedly getting the following error during the hcp_freesurfer pipeline:

(...)
running: /opt/freesurfer/freesurfer/mni/bin/nu_estimate_np_and_em -parzen -log -sharpen 0.15 0.01 -iterations 1000 -stop 0.001 -shrink 4 -auto_mask -nonotify -b_spline 1.0e-7 -distance 50 -quiet -execute -clobber -nokeeptmp -tmpdir ./tmp.mri_nu_correct.mni.2862674/0/ ./tmp.mri_nu_correct.mni.2862674/nu0.mnc ./tmp.mri_nu_correct.mni.2862674/nu1.imp

Assertion failed at line 742 in file templates/CachedArray.cc
nu_estimate_np_and_em: crashed while running volume_stats (termination status=256)
nu_correct: crashed while running nu_estimate_np_and_em (termination status=256)
ERROR: nu_correct
Linux dccn-c084.dccn.nl 4.18.0-553.8.1.el8_10.x86_64 #1 SMP Tue Jul 2 07:26:33 EDT 2024 x86_64 GNU/Linux

recon-all -s EC2129_2A exited with ERRORS at Thu Jul 25 22:52:24 CEST 2024
(...)

I thought this might be an issue of a faulty configuration of the container environment (despite --cleanenv being called by default) so I tried deleting all paths to Freesurfer, FSL etc from my local environment. Also, tried the reverse: binding my local software to the containers’ environment with e.g.:

--bash_post="FREESURFERDIR=/opt/freesurfer/7.3.2/bin/freesurfer".

Would anyone now what is going wrong here? Or where to look for the solution?

I attached files with the container environment and the (anonymized) error log file.

Thank you!

Best regards,

Thomas

error_log.txt (24.9 KB)
qunex_environment.txt (7.7 KB)

Hi,

Unfortunately, we have never seen this and the error logs you sent along are not very informative.

Perhaps you could try with an older version, say 0.99.2d that one has a different operating system.

Also, binding in FreeSurfer 7+ will not work as HCP Pipelines support FreeSurfer 6, so try with that maybe.

Best, Jure

Dear jure,

Thank you for the quick reply! I tried both options and some more things, but it all does not seem to work.
I thought it might help to re-install qunex from source. However the Clone: git clone https://gitlab.qunex.yale.edu/qunex/qunex.git does not work anymore. Would you now a way to install qunex from source?

Thanks again for the effort!

Best regards,

Thomas

Hi Thomas,

What error do you get when you run

git clone https://gitlab.qunex.yale.edu/qunex/qunex.git

The alternative is to clone with ssh, but for this to work, you need to add your public ssh key to QuNex Gitlab (here: Sign in · GitLab)

git clone git@gitlab.qunex.yale.edu:qunex/qunex.git

Best, Jure

Maybe this can help?

Do you happen to have the TMPDIR environment variable set somewhere in you bash profile / bashrc? We are starting the container with cleanenv flag but bashrc is still loaded by singularity. The reason I’m asking is that I tracked the assertion failure down to these internal functions.

Dear Jure and liningpan,

Thank you for the effort!

First about the installation from source:
I have tried both options to install from source but I get the following error without ssh key:

fatal: repository 'https://gitlab.qunex.yale.edu/qunex/qunex.git/' not found

And with the ssh key:

Permanently added 'gitlab.qunex.yale.edu,54.82.210.93' (ECDSA) to the list of known hosts.
remote: 
remote: ========================================================================
remote: 
remote: The project you were looking for could not be found or you don't have permission to view it.
remote: 
remote: ========================================================================
remote: 
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Would you know what is going on there?

Also, about the nu_correct error:

Looking at the fmriprep post, I cannot find a clear environmental variable that has been set incorrectly. Also I do not set the TMPDIR in my bashsrc.
My bashrc looks like:

# Change to homedir
cd -L

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

I even tried to run it from a shell session with only the $HOME and the singularity directories in the environment. That still gave the same error. So if you have any more ideas I would be glad to hear it!

Thank you again!

Best,

Thomas

Can you try git clone on your local machine? It seems like the server you are on is somehow blocking your access to our GitLab server. I tested both commands (https and ssh) on a couple of systems and they always worked …

For the second part, you could try this:

qunex_container run_turnkey \
	--container="${con}" \
	--bind="${qdir}:${qdir}" \
	--dataformat="BIDS" \
	--bidsname="${bidsdir}" \
	--paramfile="${dir_paramfile}" \
	--mappingfile="${dir_mappingfile}" \
	--workingdir="${qdir}" \
	--projectname="${projectname}" \
	--path="${qdir}/${projectname}" \
	--sessions="sub1_2A" \
	--sessionids="sub1_2A" \
	--sessionsfoldername="sessions" \
	--turnkeytype="local" \
	--overwrite="yes" \
    --turnkeysteps="create_session_info,create_batch,setup_hcp,hcp_pre_freesurfer,hcp_freesurfer,hcp_post_freesurfer,hcp_fmri_volume,hcp_fmri_surface" \
    --bash_post="unset TMPDIR" \
	--scheduler="SLURM,jobname=qunex_turnkey,time=48:00:00,cpus-per-task=4,mem-per-cpu=32000"

This could work if TMPDIR is indeed the problem. Do you maybe have some things in your .bash_profile or .profile?

Best, Jure

Hi Thomas,

Any updates regarding the issue you were having?

Best, Jure

Dear Jure,

I am sorry for not replying sooner!
This week I picked up the project again, and I think I found a solution.
Adding container_command += "--writable-tmpfs " to the “qunex_container” script did the trick eventually and the container is now running smoothly.

Thank you for all the advice!

Best regards,

Thomas