Bash not giving an output

Summary of what happened:

After succesfully installing Docker and fMRIPrep on a Windows 11 Pro computer I attempted to run bash fmriprep_singleSubj.sh through Ubuntu 22.04.3 LTS. However, I got no output at all.

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

I used the command bash fmriprep_singleSubj.sh to run the following script:

#!/bin/bash
#Template provided by Daniel Levitas of Indiana University
#Edits by Andrew Jahn, University of Michigan, 07.22.2020

#User inputs:
bids_root_dir=$HOME/Desktop/Flanker
subj=08
nthreads=4
mem=20 #gb
container=docker #docker or singularity

#Begin:

#Convert virtual memory from gb to mb
mem=`echo "${mem//[!0-9]/}"` #remove gb at end
mem_mb=`echo $(((mem*1000)-5000))` #reduce some memory for buffer space during pre-processing

#export TEMPLATEFLOW_HOME=$HOME/.cache/templateflow
export FS_LICENSE=$HOME/Desktop/Flanker/derivatives/license.txt

#Run fmriprep
if [ $container == singularity ]; then
  unset PYTHONPATH; singularity run -B $HOME/.cache/templateflow:/opt/templateflow $HOME/fmriprep.simg \
    $bids_root_dir $bids_root_dir/derivatives \
    participant \
    --participant-label $subj \
    --skip-bids-validation \
    --md-only-boilerplate \
    --fs-license-file $HOME/Desktop/Flanker/derivatives/license.txt \
    --fs-no-reconall \
    --output-spaces MNI152NLin2009cAsym:res-2 \
    --nthreads $nthreads \
    --stop-on-first-crash \
    --mem_mb $mem_mb \
else
  fmriprep-docker $bids_root_dir $bids_root_dir/derivatives \
    participant \
    --participant-label $subj \
    --skip-bids-validation \
    --md-only-boilerplate \
    --fs-license-file $HOME/Desktop/Flanker/derivatives/license.txt \
    --fs-no-reconall \
    --output-spaces MNI152NLin2009cAsym:res-2 \
    --nthreads $nthreads \
    --stop-on-first-crash \
    --mem_mb $mem_mb
fi

Version:

Docker version 24.0.6, build ed223bc and fMRIPrep version v23.1.4.

Environment (Docker, Singularity, custom installation):

I am running through Docker Desktop.

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

I dont think fMRIPrep has its own validator but I do know it uses the BIDS standard.

Relevant log outputs (up to 20 lines):

clara@LAPTOP-15KUVJH2:/mnt/c/Users/clara/Downloads/code$ docker --version
Docker version 24.0.6, build ed223bc
clara@LAPTOP-15KUVJH2:/mnt/c/Users/clara/Downloads/code$ fmriprep --version
fMRIPrep v23.1.4
clara@LAPTOP-15KUVJH2:/mnt/c/Users/clara/Downloads/code$ ls
fmriprep_singleSubj.sh
clara@LAPTOP-15KUVJH2:/mnt/c/Users/clara/Downloads/code$ bash fmriprep_singleSubj.sh
clara@LAPTOP-15KUVJH2:/mnt/c/Users/clara/Downloads/code$

Screenshots / relevant information:

My operating system is Windows 11 Pro but when I first bought the computer (it’s really new so a few weeks ago) it was Windows 11 S. I run commands via Ubuntu on Terminal, and I access the terminal from the file explorer when I want to go to a specific folder.

Hi @connectomeclara, and welcome to neurostars!

Try this, I simplified it a bit. Also do you have fmriprep-docker installed, which is the docker wrapper around fmriprep? Have you tried putting echo statments throughout the script to see if it begins at all? Are you sure your BIDS root is in $HOME/Desktop? Also, I would specify a working directory with the -w argument.

#!/bin/bash
#Template provided by Daniel Levitas of Indiana University
#Edits by Andrew Jahn, University of Michigan, 07.22.2020

#User inputs:
bids_root_dir=$HOME/Desktop/Flanker
work_dir="/path/to/tmp" # Do NOT put within bids_root_dir
subj=08
nthreads=4
mem=20 #gb
container="docker" #docker or singularity

#Begin:

#Convert virtual memory from gb to mb
mem=`echo "${mem//[!0-9]/}"` #remove gb at end
mem_mb=`echo $(((mem*1000)-5000))` #reduce some memory for buffer space during pre-processing

#export TEMPLATEFLOW_HOME=$HOME/.cache/templateflow
export FS_LICENSE=$HOME/Desktop/Flanker/derivatives/license.txt

echo "TEST, AT LEAST WE KNOW THE SCRIPT MADE IT THIS FAR"

#Run fmriprep
fmriprep-docker $bids_root_dir $bids_root_dir/derivatives \
    participant \
    -w $work_dir \
    --participant-label $subj \
    --md-only-boilerplate \
    --fs-license-file $HOME/Desktop/Flanker/derivatives/license.txt \
    --output-spaces MNI152NLin2009cAsym:res-2 \
    --nthreads $nthreads \
    --stop-on-first-crash \
    --mem_mb $mem_mb

Best,
Steven

Thank you! I do have fmriprep-docker installed as when I type the pip install --user --upgrade fmriprep-docker command it gives the following:

Requirement already satisfied: fmriprep-docker in ./.local/lib/python3.10/site-packages (23.1.4)

I have not tried putting echo statements throughout the script. Are there certain places I would need to put them?

I am unsure as to what the BIDS root is. Thus, I dont think I have it. Where could I get it?

As for using the -w argument, I have ran docker run -w /path/to/dir/ -i -t ubuntu pwd
and got this as an output: path/to/dir

I will update the script and return to this forum. Thanks again!


I updated the script and ran but I received this output. Do you have any recommendations?

The BIDS root is the root directory of the BIDS-valid dataset you are analyzing.

You should change the working path to a place on your filesystem.

Those echo statements can go anywhere, it just lets you know that the code was able to execute up to that point.

Do not execute the .swp file, execute the .sh file.

Thank you I will execute your suggestions and retry!
Should the corrected line look like this?
export FS_LICENSE=$HOME/Desktop/Flanker/derivatives/license.txt >$HOME/Desktop/Flanker

I am sorry, but that looks the same as what you have above to me, what did you change?

Hello! Before the code was
export FS_LICENSE=$HOME/Desktop/Flanker/derivatives/license.txt
but now it is
export FS_LICENSE=$HOME/Desktop/Flanker/derivatives/license.txt >$HOME/Desktop/Flanker
I did not code to move it to a different location because I am unsure as to where I would move it.
I added the >$HOME/Desktop/Flanker`

You should point the FS_LICENSE variable to wherever you put the freesurfer license on your filesystem.

Good evening! When I ran the bash command with the new script:

#!/bin/bash

# Template provided by Daniel Levitas of Indiana University
# Edits by Andrew Jahn, University of Michigan, 07.22.2020

# User inputs:
bids_root_dir=$HOME/Desktop/Flanker
work_dir="/tmp"  # Set to /tmp for the temporary directory
subj=08
nthreads=4
mem=20 # gb
container="docker" # docker or singularity

# Begin:

# Convert virtual memory from gb to mb
mem=`echo "${mem//[!0-9]/}"` # remove gb at end
mem_mb=`echo $(((mem*1000)-5000))` # reduce some memory for buffer space during pre-processing

# export TEMPLATEFLOW_HOME=$HOME/.cache/templateflow
export FS_LICENSE="$HOME/Desktop/Flanker/derivatives/license.txt"
touch "$HOME/Desktop/Flanker/output.txt"

echo "TEST, AT LEAST WE KNOW THE SCRIPT MADE IT THIS FAR"

# Run fmriprep with Docker
docker run --rm \
    -v $bids_root_dir:/data:ro \
    -v $bids_root_dir/derivatives:/out \
    -v $work_dir:/work \
    poldracklab/fmriprep \
    /data /out participant \
    --participant-label $subj \
    --md-only-boilerplate \
    --fs-license-file /work/license.txt \
    --output-spaces MNI152NLin2009cAsym:res-2 \
    --nthreads $nthreads \
    --stop-on-first-crash \
    --mem_mb $mem_mb

It gave me the following output:

bash fmriprep_singleSubj.sh.save.save.save.save.save
TEST, AT LEAST WE KNOW THE SCRIPT MADE IT THIS FAR
/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/validation.py:46: UserWarning: The ability to pass arguments to BIDSLayout that control indexing is likely to be removed in future; possibly as early as PyBIDS 0.14. This includes the `config_filename`, `ignore`, `force_index`, and `index_metadata` arguments. The recommended usage pattern is to initialize a new BIDSLayoutIndexer with these arguments, and pass it to the BIDSLayout via the `indexer` argument.
  warnings.warn("The ability to pass arguments to BIDSLayout that control "
You are using fMRIPrep-20.2.0, and a newer version of fMRIPrep is available: 23.1.4.
Please check out our documentation about how and when to upgrade:
https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading
WARNING: Version 20.2.0 of fMRIPrep (current) has been FLAGGED
(reason: Functional outputs in standard space can be wrong depending on the original data's orientation headers - see https://github.com/nipreps/fmriprep/issues/2307).
That means some severe flaw was found in it and we strongly
discourage its usage.
usage: fmriprep [-h] [--version] [--skip_bids_validation]
                [--participant-label PARTICIPANT_LABEL [PARTICIPANT_LABEL ...]]
                [-t TASK_ID] [--echo-idx ECHO_IDX] [--bids-filter-file FILE]
                [--anat-derivatives PATH] [--bids-database-dir PATH]
                [--nprocs NPROCS] [--omp-nthreads OMP_NTHREADS]
                [--mem MEMORY_GB] [--low-mem] [--use-plugin FILE]
                [--anat-only] [--boilerplate_only] [--md-only-boilerplate]
                [--error-on-aroma-warnings] [-v]
                [--ignore {fieldmaps,slicetiming,sbref,t2w,flair} [{fieldmaps,slicetiming,sbref,t2w,flair} ...]]
                [--longitudinal]
                [--output-spaces [OUTPUT_SPACES [OUTPUT_SPACES ...]]]
                [--bold2t1w-init {register,header}] [--bold2t1w-dof {6,9,12}]
                [--force-bbr] [--force-no-bbr] [--medial-surface-nan]
                [--dummy-scans DUMMY_SCANS] [--random-seed _RANDOM_SEED]
                [--use-aroma]
                [--aroma-melodic-dimensionality AROMA_MELODIC_DIM]
                [--return-all-components]
                [--fd-spike-threshold REGRESSORS_FD_TH]
                [--dvars-spike-threshold REGRESSORS_DVARS_TH]
                [--skull-strip-template SKULL_STRIP_TEMPLATE]
                [--skull-strip-fixed-seed]
                [--skull-strip-t1w {auto,skip,force}] [--fmap-bspline]
                [--fmap-no-demean] [--use-syn-sdc] [--force-syn]
                [--fs-license-file FILE] [--fs-subjects-dir PATH]
                [--no-submm-recon] [--cifti-output [{91k,170k}] |
                --fs-no-reconall] [-w WORK_DIR] [--clean-workdir]
                [--resource-monitor] [--reports-only] [--config-file FILE]
                [--write-graph] [--stop-on-first-crash] [--notrack]
                [--debug {compcor,all} [{compcor,all} ...]] [--sloppy]
                bids_dir output_dir {participant}
fmriprep: error: Path does not exist: </work/license.txt>

I found it strange because I have the most updated version but it tells me I dont. Also I dont see the word “work” anywhere as a path.

Hi @connectomeclara,

Do not use poldracklab/fmriprep, use nipreps/fmriprep/

You set your work_dir as /tmp, and your license is in export FS_LICENSE="$HOME/Desktop/Flanker/derivatives/license.txt" according to what you have. However, in your fMRIPrep command you said

These two statements are inconsistent, leading to the error.

You mounted work_dir as /work in the docker container when you said -v $work_dir:/work.

Best,
Steven

Thank you! Does this seem right?

 #!/bin/bash

# Template provided by Daniel Levitas of Indiana University
# Edits by Andrew Jahn, University of Michigan, 07.22.2020

# User inputs:
bids_root_dir=$HOME/Desktop/Flanker
work_dir="/tmp"  # Set to /tmp for the temporary directory
subj=08
nthreads=4
mem=20 # gb
container="docker" # docker or singularity

# Begin:

# Convert virtual memory from gb to mb
mem=`echo "${mem//[!0-9]/}"` # remove gb at end
mem_mb=`echo $(((mem*1000)-5000))` # reduce some memory for buffer space during pre-processing

# export TEMPLATEFLOW_HOME=$HOME/.cache/templateflow

echo "TEST, AT LEAST WE KNOW THE SCRIPT MADE IT THIS FAR"

# Run fmriprep with Docker
docker run --rm \
    -v $bids_root_dir:/data:ro \
    -v $bids_root_dir/derivatives:/out \
    -v $work_dir:/work \
    nipreps/fmriprep/ \
    /data /out participant \
    --participant-label $subj \
    --md-only-boilerplate \
    --fs-license-file /work/license.txt \
    --output-spaces MNI152NLin2009cAsym:res-2 \
    --nthreads $nthreads \
   --stop-on-first-crash \
    --mem_mb $mem_mb

Hi @connectomeclara

Is your FreeSurfer license file located at /tmp/license.txt?

Nope it is located at "C:\Users\clara\Desktop\Flanker\derivatives\license.txt"

In that case you should change the —fs-license-file argument such that it matches where you put the file.

I would edit this line correct? --fs-license-file /work/license.txt \

Yes, that is the line

Just to confirm, the correct line would be --fs-license-file /Desktop/Flanker/derivatives/license.txt \

Since you mount that derivatives directory as /out in your docker command, it would be /out/license.txt

Thank you I will update it and retry!