DECLARE struct $fstr
DECLARE string $path
CECHO ${$fstr=$root.func.strings}

CECHO ${$path=$root.vol[current].path}

{ img ${$fstr.right($path,4)==".img"}
	CECHO ${$path=$fstr.strip($path,-4)}
} img 0 0

{ MTT ${$fstr.right($path,4)=="-MTT"}
        CECHO ${$path=$fstr.strip($path,-3)}
} MTT 0 0

{ Tmax ${$fstr.right($path,5)=="-Tmax"}
        CECHO ${$path=$fstr.strip($path,-4)}
} Tmax 0 0

{ rCBF ${$fstr.right($path,5)=="-rCBF"}
        CECHO ${$path=$fstr.strip($path,-4)}
} rCBF 0 0

{ rCBV ${$fstr.right($path,5)=="-rCBV"}
        CECHO ${$path=$fstr.strip($path,-4)}
} rCBV 0 0

# Now $path holds the path with the suffix removed.

SAVECLASS /tmp/angleplot_allplots.class.gz

# Now load them all in order

LOAD ${$fstr.quote($path+"MTT.img")}
MERGECLASS /tmp/angleplot_allplots.class.gz
! angiotux2d/user/angleplot_MTT

LOAD ${$fstr.quote($path+"Tmax.img")}
MERGECLASS /tmp/angleplot_allplots.class.gz
! angiotux2d/user/angleplot_Tmax

LOAD ${$fstr.quote($path+"rCBF.img")}
MERGECLASS /tmp/angleplot_allplots.class.gz
! angiotux2d/user/angleplot_rCBF

LOAD ${$fstr.quote($path+"rCBV.img")}
MERGECLASS /tmp/angleplot_allplots.class.gz
! angiotux2d/user/angleplot_rCBV

# Make the other plots

SPAWNPROCESS ${$root.global.dir.scripts}/angiotux2d/makeplot4 "${$root.vol[current].path}"
SPAWNPROCESS ${$root.global.dir.scripts}/angiotux2d/maketimeplot "${$root.vol[current].path}"
