Confinement and deconfinement of quarks in nuclear matter