Short Description
This script allow you to export all pixels values which are contained in ROI(s) into a excel file. Process is done so channel are separated in different sheet and pixels are grouped per ROI.Versions
-
Version 2 • Released on: 2017-11-21 15:54:15DownloadDescription:
Fixed a small bug
importClass(Packages.icy.gui.dialog.MessageDialog) importClass(Packages.icy.gui.frame.progress.ProgressFrame) importClass(Packages.icy.file.FileUtil) importClass(Packages.plugins.tprovoost.scripteditor.uitools.filedialogs.FileDialog) importClass(Packages.icy.util.XLSUtil) importClass(Packages.icy.util.XMLUtil) importClass(Packages.icy.util.ShapeUtil) importClass(Packages.icy.roi.ROIUtil) importClass(Packages.icy.sequence.SequenceDataIterator) // get active sequence s = getSequence() if (s == null) { MessageDialog.showDialog("You should open an image first") exit } // get sequence ROIs rois = s.getROIs() if (rois.size() > 0) { // request path to save XLS result file = FileDialog.open() if (file != null) { // display progress frame p = new ProgressFrame("exporting...") // set XLS extension path = FileUtil.setExtension(file.getAbsolutePath(), ".xls") //create a new excel document wb = XLSUtil.createWorkbook(path) for(c = 0; c < s.getSizeC(); c++) { sh = XLSUtil.createNewPage(wb, "Pixels - " + s.getChannelName(c)) line = 0 for(i = 0; i < rois.size(); i++) { // get current roi r = rois.get(i) // create an iterator through the given sequence and ROI it = new SequenceDataIterator(s, r, false, -1, -1, c) XLSUtil.setCellString(sh, 0, line, r.getName()) XLSUtil.setCellNumber(sh, 1, line, i) XLSUtil.setCellString(sh, 3, line, "Number of pixel =") XLSUtil.setCellNumber(sh, 4, line, Math.floor(r.getNumberOfPoints())) line += 2 // set column titles XLSUtil.setCellString(sh, 0, line, "X") XLSUtil.setCellString(sh, 1, line, "Y") XLSUtil.setCellString(sh, 2, line, "Z") XLSUtil.setCellString(sh, 3, line, "T") XLSUtil.setCellString(sh, 4, line, "Value") line++ while(!it.done()) { // set position information XLSUtil.setCellNumber(sh, 0, line, it.getPositionX()) XLSUtil.setCellNumber(sh, 1, line, it.getPositionY()) XLSUtil.setCellNumber(sh, 2, line, it.getPositionZ()) XLSUtil.setCellNumber(sh, 3, line, it.getPositionT()) // set value XLSUtil.setCellNumber(sh, 4, line, it.get()) // pass to next value it.next() line++ } line++ } } // save and close excel document XLSUtil.saveAndClose(wb) // done p.close() } } else MessageDialog.showDialog("You should have at least 1 ROI in your image")
-
Version 1 • Released on: 2014-06-10 10:46:52DownloadDescription:
initial version
importClass(Packages.icy.gui.dialog.MessageDialog) importClass(Packages.icy.gui.frame.progress.ProgressFrame) importClass(Packages.icy.file.FileUtil) importClass(Packages.plugins.tprovoost.scripteditor.uitools.filedialogs.FileDialog) importClass(Packages.icy.util.XLSUtil) importClass(Packages.icy.util.XMLUtil) importClass(Packages.icy.util.ShapeUtil) importClass(Packages.icy.roi.ROIUtil) importClass(Packages.icy.sequence.SequenceDataIterator) // get active sequence s = getSequence() if (s == null) { MessageDialog.showDialog("You should open an image first") exit } // get sequence ROIs rois = s.getROIs() if (rois.size() > 0) { // request path to save XLS result path = FileDialog.open() if (path != null) { // display progress frame p = new ProgressFrame("exporting...") // set XLS extension path = FileUtil.setExtension(path, ".xls") //create a new excel document wb = XLSUtil.createWorkbook(path) for(c = 0; c < s.getSizeC(); c++) { sh = XLSUtil.createNewPage(wb, "Pixels - " + s.getChannelName(c)) line = 0 for(i = 0; i < rois.size(); i++) { // get current roi r = rois.get(i) // create an iterator through the given sequence and ROI it = new SequenceDataIterator(s, r, false, -1, -1, c) XLSUtil.setCellString(sh, 0, line, r.getName()) XLSUtil.setCellNumber(sh, 1, line, i) XLSUtil.setCellString(sh, 3, line, "Number of pixel =") XLSUtil.setCellNumber(sh, 4, line, Math.floor(r.getNumberOfPoints())) line += 2 // set column titles XLSUtil.setCellString(sh, 0, line, "X") XLSUtil.setCellString(sh, 1, line, "Y") XLSUtil.setCellString(sh, 2, line, "Z") XLSUtil.setCellString(sh, 3, line, "T") XLSUtil.setCellString(sh, 4, line, "Value") line++ while(!it.done()) { // set position information XLSUtil.setCellNumber(sh, 0, line, it.getPositionX()) XLSUtil.setCellNumber(sh, 1, line, it.getPositionY()) XLSUtil.setCellNumber(sh, 2, line, it.getPositionZ()) XLSUtil.setCellNumber(sh, 3, line, it.getPositionT()) // set value XLSUtil.setCellNumber(sh, 4, line, it.get()) // pass to next value it.next() line++ } line++ } } // save and close excel document XLSUtil.saveAndClose(wb) // done p.close() } } else MessageDialog.showDialog("You should have at least 1 ROI in your image")