#!/usr/bin/tcsh -f

#
# mksubjdirs
#
#
#
# Copyright © 2021 The General Hospital Corporation (Boston, MA) "MGH"
#
# Terms and conditions for use, reproduction, distribution and contribution
# are found in the 'FreeSurfer Software License Agreement' contained
# in the file 'LICENSE' found in the FreeSurfer distribution, and here:
#
# https://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferSoftwareLicense
#
# Reporting: freesurfer@nmr.mgh.harvard.edu
#
#



if ($#argv != 1) then
  echo "usage: mksubjdirs <subj_name>"
  exit
endif

if(-e $1) then
  echo "ERROR: $1 already exists"
  exit 1;
endif

mkdir $1
if($status) then
  echo "ERROR: creating directory $1"
  exit 1;
endif


chmod g+rws $1
cd $1
#bem rgb
mkdir -p  mri scripts surf tmp label morph mpg tiff touch stats
mkdir -p mri/transforms mri/orig
chmod -R g+rw .

echo " "
echo "REMEMBER to do a 'chgrp -R r_group' for the right group if needed."
echo "    All directories where just created as group writable."
echo "    Use the 'id' command to get a list of your groups."
echo " "


set um=`umask`
if ($um != 2) then
  echo " "
  echo "WARNING: your umask is not 002! New files will not be group writable."
  echo "This is a warning only, it is not an error."
  echo " "
endif

echo "Creation of subject directory complete."
echo "See recon-all -help for more info on how to proceed."
echo " "


exit 0;
