Transition from toroidal to slab temperature gradient driven modes