@Override public void setId(String id) throws FormatException, IOException { if (getCurrentFile() != null && new Location(id).getAbsolutePath().equals(getCurrentFile())) { // already initialized this file return; } close(); initFile(id); }
@Override public String[] getSeriesUsedFiles() { return getUsedFiles(); }
@Override public int[] getZCTModuloCoords(int index) { FormatTools.assertId(getCurrentFile(), true, 2); return noStitch ? reader.getZCTModuloCoords(index) : FormatTools.getZCTCoords(core.get(getCoreIndex()).dimensionOrder, getSizeZ(), getEffectiveSizeC(), getSizeT(), getModuloZ().length(), getModuloC().length(), getModuloT().length(), getImageCount(), index); }
/** Gets the file pattern object used to build the list of files. */ public FilePattern getFilePattern() { FormatTools.assertId(getCurrentFile(), true, 2); return noStitch ? findPattern(getCurrentFile()) : externals[getExternalSeries()].getFilePattern(); }
@Override public int[] getZCTCoords(int index) { FormatTools.assertId(getCurrentFile(), true, 2); return noStitch ? reader.getZCTCoords(index) : FormatTools.getZCTCoords(core.get(getCoreIndex()).dimensionOrder, getSizeZ(), getEffectiveSizeC(), getSizeT(), getImageCount(), index); }
private static void check(String pattern, String[] filenames, Integer[] dims) throws IOException, FormatException { FileStitcher fs = new FileStitcher(); fs.setId(pattern); assertEquals(fs.getFilePattern().getPattern(), pattern); assertEquals(fs.getImageCount(), SIZE_Z * SIZE_T * SIZE_C); assertEquals(fs.getSizeX(), SIZE_X); assertEquals(fs.getSizeY(), SIZE_Y); assertEquals(fs.getSizeZ(), SIZE_Z); assertEquals(fs.getSizeT(), SIZE_T); assertEquals(fs.getSizeC(), SIZE_C); assertEquals(fs.getPixelType(), PIXEL_TYPE); assertEqualsNoOrder(mkBasenames(fs.getUsedFiles()), filenames); checkPlanes(fs, dims); fs.close(); }
@Test public void testUnderlyingReaders() throws IOException, FormatException { FakeReader reader = new FakeReader(); FileStitcher fs = new FileStitcher(reader); assertNotNull(fs.getUnderlyingReaders()); fs.setId("test_z<0-2>.fake"); assertNotNull(fs.getUnderlyingReaders()); fs.close(); }
r = fileStitcher = new FileStitcher(baseReader); fileStitcher.setId(id); fileStitcher.setUsingPatternIds(true); fileStitcher.setCanChangePattern(false); options.setId(fileStitcher.getFilePattern().getPattern());
/** Constructs a cache source that draws from the given file. */ public CacheSource(String id) throws CacheException { this(new FileStitcher()); try { reader.setId(id); } catch (FormatException exc) { throw new CacheException(exc); } catch (IOException exc) { throw new CacheException(exc); } }
FileStitcher reader = new FileStitcher(); Set<String> failingIds = new LinkedHashSet<String>(); while (!fileSet.isEmpty()) { String file = fileSet.iterator().next(); try { reader.setId(file); } catch (Exception e) { LOGGER.error("setId(\"{}\") failed", file, e); String[] usedFiles = reader.getUsedFiles(); Set<String> auxFiles = new LinkedHashSet<String>(); for (String s: usedFiles) { String masterFile = reader.getCurrentFile(); auxFiles.remove(masterFile); minimalFiles.removeAll(auxFiles); fileSet.remove(file); try { reader.close();
@Override protected void initFile(String id) throws FormatException, IOException { // read the pattern from the file // the file should just contain a single line with the relative or // absolute file pattern currentId = new Location(id).getAbsolutePath(); String pattern = DataTools.readFile(id).trim(); String dir = new Location(id).getAbsoluteFile().getParent(); if (new Location(pattern).getParent() == null) { pattern = dir + File.separator + pattern; } helper.setUsingPatternIds(true); helper.setCanChangePattern(false); helper.setId(pattern); core = helper.getCoreMetadataList(); }
setCanChangePattern(false); String[] patterns = findPatterns(id); if (patterns.length == 0) patterns = new String[] {id}; int oldSeries = getCoreIndex(); for (int i=0; i<seriesCount; i++) { IFormatReader rr = getReader(i, 0); CoreMetadata ms = new CoreMetadata(); core.add(ms); ExternalSeries external = externals[getExternalSeries(i)]; ms.imageCount = rr.getImageCount() * external.getFiles().length; ms.thumbSizeX = rr.getThumbSizeX(); setCoreIndex(i); AxisGuesser ag = externals[getExternalSeries()].getAxisGuesser(); core.get(i).dimensionOrder = ag.getAdjustedOrder(); core.get(i).orderCertain = ag.isCertain(); computeAxisLengths(); setCoreIndex(oldSeries); if (reader.getCoreMetadataList().size() == 1 && getSeriesCount() > 1) { for (int i=0; i<getSeriesCount(); i++) { int index = getExternalSeries(i); String pattern = externals[index].getFilePattern().getPattern(); pattern = pattern.substring(pattern.lastIndexOf(File.separator) + 1);
@Override public int getThumbSizeX() { FormatTools.assertId(getCurrentFile(), true, 2); return noStitch ? reader.getThumbSizeX() : getReader(getCoreIndex(), 0).getThumbSizeX(); }
final IFormatReader reader = filesArePatterns ? new FileStitcher( true ) : new ImageReader(); if (filesArePatterns) ( (FileStitcher) reader ).setCanChangePattern( false ); ( (FileStitcher) reader).setAxisTypes( new int[] {AxisGuesser.Z_AXIS} );
@Override public boolean isThumbnailSeries() { FormatTools.assertId(getCurrentFile(), true, 2); return noStitch ? reader.isThumbnailSeries() : core.get(getCoreIndex()).thumbnail; }
if (zGrouped) final FileStitcher fs = new FileStitcher(true); fs.setCanChangePattern( false ); reader = new Memoizer( fs , Memoizer.DEFAULT_MINIMUM_ELAPSED, tempDir);
reader = new FileStitcher(reader, true); Location f = new Location(id); String pat = null; if (!f.exists()) { ((FileStitcher) reader).setUsingPatternIds(true); pat = id;
@Override public byte[] openThumbBytes(int no) throws FormatException, IOException { FormatTools.assertId(getCurrentFile(), true, 2); IFormatReader r = getReader(no); int ino = getAdjustedIndex(no); if (ino < r.getImageCount()) return r.openThumbBytes(ino); // return a blank image to cover for the fact that // this file does not contain enough image planes return externals[getExternalSeries()].getBlankThumbBytes(); }
@Override public int getResolution() { FormatTools.assertId(getCurrentFile(), true, 2); int n = reader.getCoreMetadataList().size(); if (n > 1 || noStitch) return reader.getResolution(); if (hasFlattenedResolutions()) { return 0; } return getCoreIndex() - coreIndexToSeries(getCoreIndex()); }
@Override public FileInfo[] getAdvancedUsedFiles(boolean noPixels) { if (noStitch) return reader.getAdvancedUsedFiles(noPixels); String[] files = getUsedFiles(noPixels); if (files == null) return null; FileInfo[] infos = new FileInfo[files.length]; for (int i=0; i<infos.length; i++) { infos[i] = new FileInfo(); infos[i].filename = files[i]; try { infos[i].reader = ((DimensionSwapper) reader).unwrap().getClass(); } catch (FormatException e) { LOGGER.debug("", e); } catch (IOException e) { LOGGER.debug("", e); } infos[i].usedToInitialize = files[i].endsWith(getCurrentFile()); } return infos; }