diff --git a/BIOP_VSI_reader.ijm b/BIOP_VSI_reader.ijm index 570e740..c00b609 100644 --- a/BIOP_VSI_reader.ijm +++ b/BIOP_VSI_reader.ijm @@ -1,1241 +1,1243 @@ // Action Bar description file : BIOP_VSI_reader // By Olivier Burri & Romain Guiet // EPFL BIOP 2014 /* * DESCRIPTION: Simple Action Bar to open and make sense of the Olympus OlyVIA Slide Scanner * The macro works as follows * Uses Jerome Mutterer's Action Bar Plugin as the interface. * Takes advantage of the print "Update" Function as of IJ 1.38m to keep data in memory. * Uses LOCI BioFormats to read and parse the data from the VSI reader * * MOTIVATION: Images produced by the OlyVIA Scanner are extremely large (>48'000px) * The inherent limitation of Java (or IJ) for images is about 48'000px * Because the .vsi files have preview thumbnails, we want to use those in order to * navigate the data and open only the part of the image we're interested in. * A Simple navigator is provided for convenience. * * DISCLAIMER: This is a work in progress and some bugs are bound to pop up, don't hesitate to contact us in case you have problems * at olivier.burri at epfl.ch */ // Action Bar settings sep = File.separator; // Install the BIOP Library call("BIOP_LibInstaller.installLibrary", "BIOP"+sep+"BIOPLib.ijm"); - -run("Action Bar", "jar:file:BIOP/BIOP_VSI_reader.jar!/BIOP_VSI_reader.ijm"); - ////////////////////////////////////////////////////////////////////////////////////////////// // The line below is for debugging. Place this VSI file in the ActionBar folder within Plugins ////////////////////////////////////////////////////////////////////////////////////////////// //run("Action Bar", "/plugins/ActionBar/BIOP_VSI_reader.ijm"); +// This is the default run behaviour +run("Action Bar", "jar:file:BIOP/BIOP_VSI_reader.jar!/BIOP_VSI_reader.ijm"); + + + exit(); //Start of ActionBar function toolName() { return "VSI Reader"; } function isVSI(filename) { if(endsWith(filename, ".vsi")) { return true; } return false; } /* * openLociStack opens the stack at the given index. This index is the raw index of the image as interpreted by LOCI * It starts at 1 and should be used in conjuction with the "getSeriesIndex... series of functions to ensure it works properly * Based on an example by Wayne Rasband on the LOCI Website */ function openLociStack(name, index) { run("Bio-Formats Macro Extensions"); id = getID(); Ext.setId(id); // Place yourself at the desired series Index (starts at 0); Ext.setSeries(index); // Get ther dimensions Ext.getSizeC(sizeC); Ext.getSizeZ(sizeZ); Ext.getSizeT(sizeT); Ext.getSizeX(sizeX); Ext.getSizeY(sizeY); Ext.getImageCount(n); print(index); //Start opening the series setBatchMode(true); for (i=0; i1) { Stack.setDimensions(sizeC, sizeZ, sizeT); if (sizeC>1) { if (sizeC==3&&sizeC==nSlices) mode = "Composite"; else mode = "Color"; run("Make Composite", "display="+mode); } setOption("OpenAsHyperStack", true); } setBatchMode(false); run("Select None"); } /* * Same as above, but opens a sub-region of the image */ function openLociSubStack(name, index, posX, posY, w, h) { run("Bio-Formats Macro Extensions"); id = getID(); Ext.setId(id); Ext.setSeries(index); Ext.getSizeC(sizeC); Ext.getSizeZ(sizeZ); Ext.getSizeT(sizeT); Ext.getImageCount(n); setBatchMode(true); for (i=0; i1) { cMode = getData("Camera Mode"); Stack.setDimensions(sizeC, sizeZ, sizeT); if (sizeC>1) { if (sizeC==3&&sizeC==nSlices) mode = "Composite"; else mode = "Color"; run("Make Composite", "display="+mode); } setOption("OpenAsHyperStack", true); if (cMode == "Brightfield") { for (i=0; i=0; i--) { Ext.setSeries(i); Ext.getSizeX(sizeX); Ext.getSizeY(sizeY); if(sizeX < 100 && sizeY < 100) oldSeries++; } return oldSeries; } function getRawSeriesPos(series) { serN = parseInt(getData("totSeries")); nextSer = 0; nSer=1; //print("Searching for Series ", series); for (i=0; i sizeX) { neworiW = sizeX - oriX; print("Size of image exceeds image dimensions, cropping:"); print("Original Width: "+oriW+" , New Width: "+neworiW); oriW = neworiW; } if (oriY + oriH > sizeY) { neworiH = sizeY - oriY; print("Size of image exceeds image dimensions, cropping:"); print("Original Height: "+oriH+" , New Height: "+neworiH); oriH = neworiH; } // Append rescaling factor to image name if (rescaling != 1) { rescaleText = " Scaling "+rescaling; } else { rescaleText = ""; } // Make sure that the chosen size is not larger than what imageJ can handle if( oriW > 42000 || oriH > 42000) { showMessage("Your selection is too large ("+oriX+", "+oriY+")\n Please select a smaller area"); } else if(matches(name,".*Thumbnail.*")) { openLociSubStack("Series #"+serInd+" at ("+oriX+", "+oriY+")"+rescaleText, (serPos), oriX, oriY, oriW , oriH); } else { showMessage("Please Select a Thumbnail Image!"); } } else { showMessage("Please make a selection"); } } function measureCurrentImageWithMacro(){ macroToMeasure = getData("Macro Image Processing and Measurement Path"); runMacro(macroToMeasure); } function createMaskFromROIs(measureStatus){ Stack.getDimensions(widthOri, heightOri, channelsOri, slicesOri, framesOri) n = roiManager("Count"); // get thu total number of ROI to process currentCat = "*none*"; // set current categorie name to 'none' // Here, the macro will create a new channel for each category // and will fill all ROI with a random grey value for (i=0; i