#!/bin/bash

fun_name="a5_segmentation_raw_data"

mkdir ./logs

rootpath="$(pwd)/../.."
rootpath=$(builtin cd $rootpath; pwd)

for subj in $(seq 1 33); do
	# if not been performed yet
	if [ ! -f ${rootpath}/data/outputs/eeg/sub-$(printf "%03d" ${subj})*_seg.mat ]; then
		echo "step not performed yet for this subject"
		echo "#!/bin/bash"                    			> job.slurm
		echo "#SBATCH --job-name eegmp_seg_${subj}" 	>> job.slurm
		echo "#SBATCH --cpus-per-task 4"				>> job.slurm
		echo "#SBATCH --mem 8gb" 						>> job.slurm
		echo "#SBATCH --time 01:00:00" 					>> job.slurm
		echo "#SBATCH --output ./logs/eegmp_prep_${subj}.out"			>> job.slurm
		echo "#SBATCH --workdir ." 										>> job.slurm
		echo "./${fun_name}_run.sh /opt/matlab/R2016b ${subj} ${rootpath}" 	>> job.slurm
		sbatch job.slurm
		rm -f job.slurm
	fi
done