Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions srun_fastsurfer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ subject_list_awk_code_sid="\$1"
subject_list_awk_code_args="\$2"
subject_list_delim="="
jobarray=""
timelimit_seg=10
timelimit_seg=15
# 1mm can take 1h per hemi plus 1h extra on a single core (depending on cpu speed)
timelimit_surf=$((4 * 60))
# the memory required for the surface and the segmentation pipeline depends on the
Expand Down Expand Up @@ -419,23 +419,23 @@ fi
wait # for directories to be made

# step one: copy singularity image to hpc
all_cases_file="/$hpc_work/scripts/subject_list"
all_cases_file="$hpc_work/scripts/subject_list"

log "cp \"$singularity_image\" \"$hpc_work/images/fastsurfer.sif\""
script_dir="$(dirname "$THIS_SCRIPT")"
log "cp \"$script_dir/brun_fastsurfer.sh\" \"$script_dir/stools.sh\" \"$hpc_work/scripts\""
log "cp \"$fs_license\" \"$hpc_work/scripts/.fs_license\""
log "Create Status/Success file at $hpc_work/scripts/subject_success"

tofile="cat"
tofile=("cat")
if [[ "$submit_jobs" == "true" ]]
then
cp "$singularity_image" "$hpc_work/images/fastsurfer.sif" &
cp "$script_dir/brun_fastsurfer.sh" "$script_dir/stools.sh" "$hpc_work/scripts" &
cp "$fs_license" "$hpc_work/scripts/.fs_license" &
log "#Status/Success file of srun_fastsurfer-run $(date)" > "$hpc_work/scripts/subject_success" &

tofile="tee $all_cases_file"
tofile=("tee" "$all_cases_file")
fi

# step two: copy input data to hpc
Expand All @@ -451,9 +451,9 @@ then
log ""
fi

cases=$(translate_cases "$in_dir" "$subject_list" "/source" "${subject_list_delim}" "${subject_list_awk_code_sid}" "${subject_list_awk_code_args}" | $tofile)
cases=$(translate_cases "$in_dir" "$subject_list" "/source" "${subject_list_delim}" "${subject_list_awk_code_sid}" "${subject_list_awk_code_args}" | "${tofile[@]}")
else
cases=$(read_cases "$in_dir" "$pattern" "/source" | $tofile)
cases=$(read_cases "$in_dir" "$pattern" "/source" | "${tofile[@]}")
fi
num_cases=$(echo "$cases" | wc -l)

Expand Down Expand Up @@ -548,6 +548,7 @@ then
seg_cmd_filename=$hpc_work/scripts/slurm_cmd_seg.sh
if [[ "$submit_jobs" == "true" ]] ; then seg_cmd_file=$seg_cmd_filename ; else seg_cmd_file=$(mktemp) ; fi

IFS=" "
slurm_part_=$(first_non_empty_arg "$partition_seg" "$partition")
if [[ -z "$slurm_part_" ]] ; then slurm_partition=() ; else slurm_partition=(-p "$slurm_part_") ; fi
{
Expand All @@ -573,16 +574,12 @@ then
fi
# note that there can be a decent startup cost for each run, running multiple cases
# per task significantly reduces this
seg_slurm_sched=("--mem=${mem_seg}G" "--cpus-per-task=$num_cpus_per_task"
seg_slurm_sched=("--mem=${mem_seg}G" "--cpus-per-task=$num_cpus_per_task" -J "FastSurfer-Seg-$USER"
--time=$((timelimit_seg * real_num_cases_per_task + 5))
"${slurm_partition[@]}" "${slurm_email[@]}"
"${jobarray_option[@]}" -J "FastSurfer-Seg-$USER"
"${slurm_partition[@]}" "${slurm_email[@]}" "${jobarray_option[@]}"
-o "$hpc_work/logs/seg_%A_%a.log" "$seg_cmd_filename")
if [[ "$cpu_only" == "true" ]]
then
debug "Schedule SLURM job without gpu"
else
seg_slurm_sched=(--gpus=1 "${seg_slurm_sched[@]}")
if [[ "$cpu_only" == "true" ]] ; then debug "Schedule SLURM job without gpu"
else seg_slurm_sched+=(--gpus-per-task=1)
fi
log "chmod +x $seg_cmd_filename"
chmod +x "$seg_cmd_file"
Expand Down Expand Up @@ -630,13 +627,9 @@ then
"${fastsurfer_surf_options[@]}"
"${POSITIONAL_FASTSURFER[@]}")
surf_cmd_filename=$hpc_work/scripts/slurm_cmd_surf.sh
if [[ "$submit_jobs" == "true" ]]; then surf_cmd_file=$surf_cmd_filename
else surf_cmd_file=$(mktemp)
fi
if [[ "$submit_jobs" == "true" ]]; then surf_cmd_file=$surf_cmd_filename ; else surf_cmd_file=$(mktemp) ; fi
mem_per_core=$((mem_surf / num_cpus_surf))
if [[ "$mem_surf" -gt "$((mem_per_core * num_cpus_surf))" ]]; then
mem_per_core=$((mem_per_core+1))
fi
if [[ "$mem_surf" -gt "$((mem_per_core * num_cpus_surf))" ]]; then mem_per_core=$((mem_per_core+1)) ; fi
slurm_part_=$(first_non_empty_arg "$partition_surf" "$partition")
if [[ -z "$slurm_part_" ]] ; then slurm_partition=() ; else slurm_partition=(-p "$slurm_part_") ; fi
{
Expand Down
3 changes: 2 additions & 1 deletion stools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ function check_subject_images ()
missing_subject_imgs=""
symlink_subject_imgs=""
data_dir="$1"
#remove training /
while [[ "${data_dir:$((${#data_dir} - 1))}" == "/" ]] ; do data_dir=${data_dir:0:$((${#data_dir} - 1))} ; done
OLD_IFS=$IFS
IFS=$'\n'
for subject in $2
Expand All @@ -196,7 +198,6 @@ function check_subject_images ()
arg0="${arg:0:${#data_dir}}"
if [[ "$real_data" != "$(realpath "$arg0")" ]] || [[ "${real_arg:${#real_data}}" != "${arg:${#data_dir}}" ]] # this is a symlink
then
echo ":$(realpath "$arg"):=?=:$arg:"
if [[ $first_img == 1 ]]; then missing_subject_ids+=", $subject_id" ; first_img=0 ; fi
symlink_subject_imgs+=", $arg => $(realpath "$arg")"
fi
Expand Down