Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot open Img as CellImg if underlying type is ND2 #373

Open
bnorthan opened this issue Jul 13, 2018 · 0 comments
Open

Cannot open Img as CellImg if underlying type is ND2 #373

bnorthan opened this issue Jul 13, 2018 · 0 comments
Milestone

Comments

@bnorthan
Copy link

bnorthan commented Jul 13, 2018

Hi all

I'm having an issue reading an ND2 file as a CellImg. I have plugins that take an ImagePlus as input and re-opens it as a CellImg. This is done, instead of just converting it to an Img becasue the underlyhing ImagePlus can be very large, and is often a virtual image. Up until very recently this process was working fine. However now it fails with ND2 images, but not with .tifs. Below is the error that occurs and a Command that can be used to repeat the problem. An example image is in dropbox here

at net.imglib2.cache.util.CacheAsUncheckedCacheAdapter.get(CacheAsUncheckedCacheAdapter.java:32)
at net.imglib2.img.cell.LazyCellImg$LazyCells.get(LazyCellImg.java:104)
at net.imglib2.img.list.AbstractLongListImg$LongListCursor.get(AbstractLongListImg.java:98)
at net.imglib2.img.cell.CellCursor.getCell(CellCursor.java:94)
at net.imglib2.img.cell.CellCursor.moveToNextCell(CellCursor.java:182)
at net.imglib2.img.cell.CellCursor.reset(CellCursor.java:152)
at net.imglib2.img.cell.CellCursor.(CellCursor.java:88)
at net.imglib2.img.cell.AbstractCellImg.cursor(AbstractCellImg.java:92)
at net.imglib2.img.cell.AbstractCellImg.cursor(AbstractCellImg.java:51)
at net.imglib2.img.AbstractImg.firstElement(AbstractImg.java:81)
at net.imagej.ImgPlus.firstElement(ImgPlus.java:276)
at net.imagej.DefaultDataset.getType(DefaultDataset.java:220)
at net.imagej.DefaultDataset.isSigned(DefaultDataset.java:225)
at net.imagej.DefaultDataset.mergedColorCompatible(DefaultDataset.java:704)
at net.imagej.DefaultDataset.(DefaultDataset.java:101)
at net.imagej.DefaultDatasetService.create(DefaultDatasetService.java:200)
at io.scif.services.DefaultDatasetIOService.open(DefaultDatasetIOService.java:128)
at com.doublehelixoptics.testcommands.TestImgOpenerCommandSimple.run(TestImgOpenerCommandSimple.java:51)
at org.scijava.command.CommandModule.run(CommandModule.java:199)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
at org.scijava.thread.DefaultThreadService$3.call(DefaultThreadService.java:238)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

import java.io.File;
import java.io.IOException;

import org.scijava.command.Command;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

import ij.ImagePlus;
import io.scif.config.SCIFIOConfig;
import io.scif.config.SCIFIOConfig.ImgMode;
import io.scif.services.DatasetIOService;
import net.imagej.Dataset;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;

@Plugin(type = Command.class, headless = true, menuPath = "Plugins>Test Cell Image Opener Simple")
public class TestImgOpenerCommandSimple<T extends RealType<T> & NativeType<T>> implements Command {

	@Parameter
	DatasetIOService io;

	@Parameter
	ImagePlus image;

	public void run() {

		// create the SCIFIOConfig. This gives us configuration control over
		// how the ImgOpener will open its datasets.
		final SCIFIOConfig config = new SCIFIOConfig();

		// Use CellImg mode to load the image. CellImgs dynamically load
		// image regions
		// and are useful when an image won't fit in memory
		config.imgOpenerSetImgModes(ImgMode.CELL);

		File imageFile = new File(image.getOriginalFileInfo().directory + image.getOriginalFileInfo().fileName);
		Dataset data = null;
		try {
			// open with DatasetIOService
			data = io.open(imageFile.getAbsolutePath(), config);

			for (int d = 0; d < data.numDimensions(); d++) {
				System.out.println(data.axis(d).type());
			}

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
BobHanson added a commit to BobHanson/scifio-SwingJS that referenced this issue Dec 31, 2019
BobHanson added a commit to BobHanson/scifio-SwingJS that referenced this issue Jan 1, 2020
better exists() method for FileLocation
@hinerm hinerm added this to the m1 milestone Oct 14, 2021
@hinerm hinerm added this to Triage in Intro to SCIFIO Oct 14, 2021
@hinerm hinerm modified the milestones: m1, m3 Oct 15, 2021
@hinerm hinerm removed this from Triage in Intro to SCIFIO Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants