New to fMRIprep

Hi @Allen_Roy,

Your file script.sh can’t be in the BIDS root directory, it should live in a folder called code in the root directory.

Best,
Steven

Hi @Steven,
Thanks a lot, the script issue was solved. However, it looks like the sample dataset that im trying to work with has some issues. Can you direct me to some datasets that’s a bit easier to play around for beginners?

Thanks

You can look at OpenNeuro for BIDS-valid datasets.

Im using this dataset, however, when im trying to run, its throwing this error.

Hi, are you passing in the root directory of the BIDS dataset? Such that inside it, you see the sub-xx folders?

It would help to see your command for fMRIPrep.

Hey Steven,

I think i was doing a lot of things wrong. I want to start over and crosscheck if I did everything correctly. Is there a manual or tutorial where i can get step by step guidance right from the installation?

Thanks

You can try looking at steps here: fmriprep - Behavioral Neuroimaging Core User Manual and here: fMRIPrep Demonstration — Andy's Brain Book 1.0 documentation but some of the information may be outdated or specific to certain use cases. The fmriprep website I linked earlier also has lots of helpful information.
Without you explaining what you have tried and all the errors you are getting, it is difficult to assist with your specific problems.

Best,
Steven


The script and the error. I don’t know whats wrong. Could it be because I’m running it on WSL?

Are you sure that’s your full command, it ends after the --fs-license-file argument before the working directory is mentioned. It is easier if you copy and paste the code here, using the </> button to format the text as code.

That being said, it appears that your variable named $nprocs has not been defined.


subject=$1
nprocs=$4
mem=4 # 400

#Convert virtual memory from gb to mb
mem=`echo "${mem//[!0-9]/}"`
mem_mb=`echo $(((mem*1000)-5000))`

docker run -ti --rm \
  -v $rdd:/data:ro \
  -v $odd:/out \
  -v $wkd:/work \
  -v $licd:/licensedir \
  nipreps/fmriprep:latest \
  --participant-label "$subject" \
  --output-spaces T1w func \
  --nprocs "$nprocs" --mem "$mem_mb" \
  --stop-on-first-crash \
  --fs-license-file /licensedir/license.txt \
  -w $HOME

this is the entire code

Hi @Allen_Roy,

It looks like subject and nrpocs are positional arguments in your overall script, so how are you submitting this script? Maybe you can add a echo $nprocs before the fmriprep command to make sure the value you expect is being passed in correctly.

Also,

This makes your mem_mb -1000! So you probably want to change that too.

Best,
Steven

Hey,

Can you help me rewrite this script? Like how would you write it?

It’s written fine, just change mem to 40. Again, how are you submitting this script?

Im trying to run it like other bash scripts. Is that not how you do it?

The reason I ask is that subject and nprocs are the first and fourth positional argument in your script, respectively (as indicated by the $1 and $4). So I want to make sure that your input arguments are ordered properly when you submit the script, as your error was due to to nprocs being undefined.

I would also use your predefined work directory ($wkd or /work as you rename it in the container) instead of $HOME as your work directory (-w argument).

Are these variables ($rdd, $odd, $wkd, $licd) defined somewhere?

Best,
Steven

Hey @Steven,

Thanks for the suggestion, i’ve changed the script. The nprocs error is gone, however, when i try to run the script it throws this error “fmriprep: error: Path does not exist: </home//fmriprepdemo>.” I cant figure whats wrong with it.

#!/usr/bin/env bash

subject=1
nprocs=4
mem=6 # 400
rdd=$HOME/fmriprepdemo_lang-prod
odd=$HOME/fmriprepdemo_lang-prod/sub-01/output
wkd=$HOME/wkdir
licd=$HOME/FREESURFER
docker run -ti --rm \
  --memory="$mem""g" \
  -v $wkd:/work \
  -v $licd:/licensedir \
  nipreps/fmriprep:latest $rdd $odd \
participant \
  --participant-label $subject \
  --output-spaces T1w func \
  --nprocs $nprocs \
  --fs-no-reconall \
  --mem $mem \
  --low-mem \
  --stop-on-first-crash \
  --fs-license-file /licensedir/license.txt \
  -w $HOME

Is it possible to use fmriprep-docker in your environment? It was designed to avoid tedious wrangling of docker command lines.

Hi @Allen_Roy,

This would mean that you have a subject named sub-1 in your BIDS directory, and want to limit fMRIPrep to 4 CPUs. Just making sure that that is is the case?

--mem in the fMRIPrep command line is defined in megabytes, and I imagine you wanted this to be 6 gigabytes instead of megabytes. So, you can re-add the mem_mb variable similar to what you had before so you have a gigabytes number for the docker memory argument, and a megabytes number for the fmriprep argument.

Again, you should use $wkd for the -w argument instead of $HOME.

This flag is not recommended (see here)

fMRIPrep will make its own subject specific folders in the output directory. By convention, most people will define the output directory as $BIDS/derivatives/, which in your case is $HOME/fmriprepdemo_lang-prod/derivatives/.

Best,
Steven

Yes, My hardware is limited to those specs. This is the data:

In that case you will have to change your subject variable = "01"