#!/bin/tcsh -f
if ("$1" == '' || "$1" == "-help" || "$1" == "-h") then
   echo "Usage 1: A script to parse an AFNI name"
   echo ""
   echo "   `basename $0` <name>"
   echo ""
   echo "Outputs the path, prefix, view and sub-brick selection string."
   echo ""
   echo "If view is missing (nifti file), and sub-brick selection"
   echo "is used, view is set to '----'"
   echo ""
   goto END
endif

set anat_in = `echo "$1" | cut -d \[ -f1`
set bling = `echo "$1" | cut -d \[ -f2 | cut -d \] -f1`
if ("$bling" == "$1") then
    set bling = ""
endif

set anat_path = "$anat_in:h"
if ( "$anat_path" == "${anat_in}" ) then
    set anat_path = "."
endif

set ana_pref = `@GetAfniPrefix "${anat_in}"`
set ana_view = `@GetAfniView "${anat_in}"`
if ("$ana_view" == '' && "$bling" != '') then
    set ana_view = "----"
endif
echo "$anat_path $ana_pref $ana_view $bling"

END:
