package cquest.utils; import java.io.*; /** class MrsiTxtReader. * to read/ write the selection of voxel to a text file. * @author Michael Sdika */ public class MrsiTxtReader { /** exception when the text file has not the good format. */ public static class WrongFormatException extends Exception { public WrongFormatException(String message) { super(message); } } /** read the next meaningful line. */ private static String nextLine(BufferedReader reader)throws IOException { String line; do { line = reader.readLine(); } while ( line!=null && ( line.trim().length()==0 || line.charAt(0)=='#') ); return(line); } /** read the text file that contains the selected voxels. */ public static boolean[][] read(File file) throws FileNotFoundException, IOException, WrongFormatException { BufferedReader reader = new BufferedReader(new FileReader(file)); boolean[][] mrsiSel; try { String line = nextLine(reader); String[] dims = line.split("\\s"); int d0 = Integer.valueOf(dims[0]).intValue(); int d1 = Integer.valueOf(dims[1]).intValue(); mrsiSel = new boolean[d1][d0]; for (int i=0;i