use of qupath.lib.images.writers.ome.OMEPyramidWriterCommand in project qupath by qupath.
the class BioFormatsOptionsExtension method installExtension.
@Override
public void installExtension(QuPathGUI qupath) {
// Request Bio-Formats version - if null, Bio-Formats is missing & we can't install the extension
bfVersion = BioFormatsServerBuilder.getBioFormatsVersion();
if (bfVersion == null) {
Dialogs.showErrorMessage("Bio-Formats extension", "The Bio-Formats extension is installed, but 'bioformats_package.jar' is missing!\n\n" + "Please make sure both .jar files are copied to the QuPath extensions folder.");
return;
} else {
logger.info("Bio-Formats version {}", bfVersion);
}
var actionWriter = ActionTools.createAction(new OMEPyramidWriterCommand(qupath), "OME TIFF");
actionWriter.setLongText("Write regions as OME-TIFF images. This supports writing image pyramids.");
actionWriter.disabledProperty().bind(qupath.imageDataProperty().isNull());
MenuTools.addMenuItems(qupath.getMenu("File>Export images...", true), actionWriter);
BioFormatsServerOptions options = BioFormatsServerOptions.getInstance();
// Create persistent properties
BooleanProperty enableBioformats = PathPrefs.createPersistentPreference("bfEnableBioformats", options.bioformatsEnabled());
BooleanProperty filesOnly = PathPrefs.createPersistentPreference("bfFilesOnly", options.getFilesOnly());
BooleanProperty useParallelization = PathPrefs.createPersistentPreference("bfUseParallelization", options.requestParallelization());
IntegerProperty memoizationTimeMillis = PathPrefs.createPersistentPreference("bfMemoizationTimeMS", options.getMemoizationTimeMillis());
// BooleanProperty parallelizeMultichannel = PathPrefs.createPersistentPreference("bfParallelizeMultichannel", options.requestParallelizeMultichannel());
// BooleanProperty requestChannelZCorrectionVSI = PathPrefs.createPersistentPreference("bfChannelZCorrectionVSI", options.requestChannelZCorrectionVSI());
StringProperty pathMemoization = PathPrefs.createPersistentPreference("bfPathMemoization", options.getPathMemoization());
StringProperty useExtensions = PathPrefs.createPersistentPreference("bfUseAlwaysExtensions", String.join(" ", options.getUseAlwaysExtensions()));
StringProperty skipExtensions = PathPrefs.createPersistentPreference("bfSkipAlwaysExtensions", String.join(" ", options.getSkipAlwaysExtensions()));
// Set options using any values previously stored
options.setFilesOnly(filesOnly.get());
options.setPathMemoization(pathMemoization.get());
options.setBioformatsEnabled(enableBioformats.get());
options.setRequestParallelization(useParallelization.get());
options.setMemoizationTimeMillis(memoizationTimeMillis.get());
// options.setRequestParallelizeMultichannel(parallelizeMultichannel.get());
// options.setRequestChannelZCorrectionVSI(requestChannelZCorrectionVSI.get());
fillCollectionWithTokens(useExtensions.get(), options.getUseAlwaysExtensions());
fillCollectionWithTokens(skipExtensions.get(), options.getSkipAlwaysExtensions());
// Listen for property changes
enableBioformats.addListener((v, o, n) -> options.setBioformatsEnabled(n));
filesOnly.addListener((v, o, n) -> options.setFilesOnly(n));
useParallelization.addListener((v, o, n) -> options.setRequestParallelization(n));
memoizationTimeMillis.addListener((v, o, n) -> options.setMemoizationTimeMillis(n.intValue()));
// parallelizeMultichannel.addListener((v, o, n) -> options.setRequestParallelizeMultichannel(n));
// requestChannelZCorrectionVSI.addListener((v, o, n) -> options.setRequestChannelZCorrectionVSI(n));
pathMemoization.addListener((v, o, n) -> options.setPathMemoization(n));
useExtensions.addListener((v, o, n) -> fillCollectionWithTokens(n, options.getUseAlwaysExtensions()));
skipExtensions.addListener((v, o, n) -> fillCollectionWithTokens(n, options.getSkipAlwaysExtensions()));
// Add preferences to QuPath GUI
PreferencePane prefs = QuPathGUI.getInstance().getPreferencePane();
prefs.addPropertyPreference(enableBioformats, Boolean.class, "Enable Bio-Formats", "Bio-Formats", "Allow QuPath to use Bio-Formats for image reading");
prefs.addPropertyPreference(filesOnly, Boolean.class, "Local files only", "Bio-Formats", "Limit Bio-Formats to only opening local files, not other URLs.\n" + "Allowing Bio-Formats to open URLs can cause performance issues if this results in attempting to open URLs intended to be read using other image servers.");
prefs.addPropertyPreference(useParallelization, Boolean.class, "Enable Bio-Formats tile parallelization", "Bio-Formats", "Enable reading image tiles in parallel when using Bio-Formats");
// prefs.addPropertyPreference(parallelizeMultichannel, Boolean.class, "Enable Bio-Formats channel parallelization (experimental)", "Bio-Formats", "Request multiple image channels in parallel, even if parallelization of tiles is turned off - "
// + "only relevant for multichannel images, and may fail for some image formats");
prefs.addPropertyPreference(memoizationTimeMillis, Integer.class, "Bio-Formats memoization time (ms)", "Bio-Formats", "Specify how long a file requires to open before Bio-Formats will create a .bfmemo file to improve performance (set < 0 to never use memoization)");
prefs.addDirectoryPropertyPreference(pathMemoization, "Bio-Formats memoization directory", "Bio-Formats", "Choose directory where Bio-Formats should write cache files for memoization; by default the directory where the image is stored will be used");
prefs.addPropertyPreference(useExtensions, String.class, "Always use Bio-Formats for specified image extensions", "Bio-Formats", "Request that Bio-Formats is always the file reader used for images with specific extensions; enter as a list with spaces between each entry");
prefs.addPropertyPreference(skipExtensions, String.class, "Never use Bio-Formats for specified image extensions", "Bio-Formats", "Request that Bio-Formats is never the file reader used for images with specific extensions; enter as a list with spaces between each entry");
// prefs.addPropertyPreference(requestChannelZCorrectionVSI, Boolean.class, "Correct VSI channel/z-stack confusion", "Bio-Formats", "Attempt to fix a bug that means some VSI files have different channels wrongly displayed as different z-slices");
}
Aggregations