Skip to content
33 changes: 17 additions & 16 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
rm -rf anat
rm -rf anat_mask
rm -rf bold_img
rm -rf anat
rm -rf anat_mask
rm -rf bold_img
rm -rf bold_mask
rm -f fmap.json
rm -f fmri.json
rm -rf fmripinput
rm -rf out
rm -rf workdir
rm -f license.txt
rm -f multi_proc.yml
rm -f nohup.out
rm -f fmap.json
rm -f fmri.json
rm -rf fmripinput
rm -rf out
rm -rf workdir
rm -f license.txt
rm -f multi_proc.yml
rm -f nohup.out
rm -rf output_report
rm -f product.json
rm -rf regress
rm -f t1w.json
rm -f t2w.json
rm -rf templateflow
rm -f product.json
rm -rf regress
rm -rf aroma
rm -f t1w.json
rm -f t2w.json
rm -rf templateflow
rm -rf bids
29 changes: 22 additions & 7 deletions fmriprep2bl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ product=""

# get basename for fmri output
sub=$(jq -r '._inputs[] | select(.id == "fmri") | .meta.subject' config.json)
oDir=$outdir/fmriprep/sub-$sub
# oDir=$outdir/fmriprep/sub-$sub
oDir=$outdir/sub-$sub
ses=$(jq -r '._inputs[] | select(.id == "fmri") | .meta.session' config.json)
[ "$ses" != "null" ] && oDir=$oDir/ses-$ses

Expand All @@ -22,6 +23,12 @@ regressors_tsv=$(find $oDir/func -name "*_desc-confounds_timeseries.tsv")
regressors_json=$(find $oDir/func -name "*_desc-confounds_timeseries.json")
[[ -f $regressors_json ]] && cp $regressors_json regress/regressors.json

# ADDITION vvvv
mkdir -p aroma
aroma_csv=$(find $oDir/func -name "*AROMAnoiseICs.csv")
[[ -f $aroma_csv ]] && cp $aroma_csv aroma/aroma.csv
# ADDITION ^^^^

# need to check if we have surface or volume output,
# this will match for fsaverage, fsaverage5, ...
space=$(jq -r .space config.json)
Expand All @@ -47,14 +54,20 @@ if [[ $space =~ 'fsaverage' ]] || [[ $space == 'fsnative' ]] ; then

else # else its a volume(bold) output

bold_json=$(find $oDir/func -name "*_desc-preproc_bold.json")
# CHANGE HERE vvvv
# bold_json=$(find $oDir/func -name "*_desc-preproc_bold.json")
bold_json=$(find $oDir/func -name "*_desc-smoothAROMAnonaggr_bold.json")
# CHANGE HERE ^^^^
time singularity exec -e docker://brainlife/python:2.7.16 python ./merge_json.py -f1 config.json -f2 $bold_json -id_in fmri -out tmp.json
product="\"bold_img\": {\"meta\": $(cat tmp.json), \"space\": \"$space\", \"tags\": [ \"space-$space\" ]}, $product"

# get the preproc fmri vol
mkdir -p bold_img
#sub-A00008326_ses-DS2_task-rest_acq-645_space-MNI152NLin6Asym_res-2_desc-preproc_bold.nii.gz
ln -sf ../$(find $oDir/func -name "*_space-${space}_*desc-preproc_bold.nii.gz") bold_img/bold.nii.gz

# CHANGE HERE vvvv
# ln -sf ../$(find $oDir/func -name "*_space-${space}_*desc-preproc_bold.nii.gz") bold_img/bold.nii.gz
ln -sf ../$(find $oDir/func -name "*_space-${space}_*desc-smoothAROMAnonaggr_bold.nii.gz") bold_img/bold.nii.gz
# CHANGE HERE ^^^^

# get the preproc fmri volmask
mkdir -p bold_mask
Expand All @@ -66,7 +79,8 @@ fi
# TODO - should we output all output spaces?
mkdir -p anat anat_mask
sub=$(jq -r '._inputs[] | select(.id == "t1w") | .meta.subject' config.json)
oDir=$outdir/fmriprep/sub-$sub
# oDir=$outdir/fmriprep/sub-$sub
oDir=$outdir/sub-$sub
ses=$(jq -r '._inputs[] | select(.id == "t1w") | .meta.session' config.json)
[ "$ses" != "null" ] && oDir=$oDir/ses-$ses
#anat
Expand All @@ -91,11 +105,12 @@ for dir in $(cd $outdir && find ./ -name "figures"); do
cp -r $outdir/$dir output_report/$(dirname $dir)
done
#rename the parent directory to confirm to brainlife html output
mv output_report/fmriprep output_report/html
# mv output_report/fmriprep output_report/html # this line is throwing error - e.b.
# mv output_report output_report/html

### aparcaseg parcellation datatype
mkdir -p parcellation
labelsTsv=$outdir/fmriprep/desc-aparcaseg_dseg.tsv
labelsTsv=$outdir/desc-aparcaseg_dseg.tsv
cp ${labelsTsv} ./labels.tsv
#oDir=$outdir/fmriprep/sub-$sub
ln -sf ../$(find $oDir/anat -name "*_desc-aparcaseg_dseg.nii.gz" -not -name "*space*") parcellation/parc.nii.gz
Expand Down
2 changes: 1 addition & 1 deletion main
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fi

outdir=out

#we should avoid using lustre filesystem as workdir on Expsnse@SDSC,
#we should avoid using lustre filesystem as workdir on Expsnse@SDSC,
#admin told me that it's causing high IOP
WORKDIRNAME=work
if [ -d "/scratch/$USER/job_$SLURM_JOB_ID" ]; then
Expand Down