Z03-heuristics/convert_one.sh
Michał Szczepanik cacad47f1b Place the log file in the right place
The log file (where we save all the inconsistencies) needs to go into
the subject directory, i.e. under the public, not private, ID.
2024-10-11 18:52:04 +02:00

35 lines
895 B
Shell
Executable file

#! /bin/bash
# we rely on the following
# - PWD is NIfTI dataset
# - heuristic is in $PWD/code/heuristic.py
# - postprocessing is in $PWD/code/add_intended_for
# - dicom dataset has code/map_id.py
# allow ** globs
shopt -s globstar
# give names to inputs
public_id=$1
dicom_dataset=$2
# find out the private id
priv_id=$(python ${dicom_dataset}/code/map_id.py ${public_id})
# the log location to be used by the (custom) heuristic
export BIDS_LOG_FILE="sub-${public_id}/.conversion.log"
# run heudiconv
# alt. --files ${dicom_dataset}/${priv_id}/icf/${priv_id}_dicom.tar
heudiconv \
--files ${dicom_dataset}/${priv_id}/*_${priv_id}/incoming/**/*.dcm \
--subjects ${public_id} \
--outdir $PWD \
--heuristic code/heuristic.py \
-c dcm2niix \
--bids \
--minmeta \
--overwrite
# postprocess heudiconv's ouptputs
python code/add_intended_for.py $PWD $public_id