Last active
April 18, 2022 17:39
-
-
Save mikrkilk/1409f64bf33d631112e61ed558ac9453 to your computer and use it in GitHub Desktop.
Omero utility scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ | |
let infotab = document.getElementById('infoTab').children[0].children[2]; | |
let channels = infotab.children[0].children[1].children[0].lastElementChild.textContent.trim().split(', '); | |
let channelsliders = document.getElementById('channel_sliders').children[0]; | |
for(i=0;i<channels.length;i++) { | |
let p = document.createTextNode(channels[i]); | |
let br = document.createElement('br'); | |
channelsliders.children[i].insertBefore(br,channelsliders.children[i].firstChild); | |
channelsliders.children[i].insertBefore(p,channelsliders.children[i].firstChild); | |
} | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ | |
let ic = Object.keys(angular.element(document.getElementsByClassName('channel-group-headers')).scope().model.indexedChannels).length; | |
for(i=0;i<ic/4;i++) { | |
angular.element(document.getElementsByClassName('btn-add-channel-group')).click(); | |
angular.element(document.getElementsByClassName('channel-group-headers')).scope().model.channelGroups[i].name= 'Cycle '+i; | |
angular.element(document.getElementsByClassName('channel-group-headers')).scope().model.channelGroups[i].channels = [4*i,4*i+1,4*i+2,4*i+3]; | |
angular.element(document.getElementsByClassName('channel-group-headers')).scope().model.channels[4*i].color="#0000FF"; | |
angular.element(document.getElementsByClassName('channel-group-headers')).scope().model.channels[4*i+1].color="#00FF00"; | |
angular.element(document.getElementsByClassName('channel-group-headers')).scope().model.channels[4*i+2].color="#FFFFFF"; | |
angular.element(document.getElementsByClassName('channel-group-headers')).scope().model.channels[4*i+3].color="#FF0000"; | |
} | |
angular.element(document.getElementsByClassName('channel-group-headers')).scope().model.channelGroups[ic/4].channels = []; | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ | |
var imgId = parseInt(document.getElementById('info').children[0].children[3].children[0].children[0].textContent.split(': ')[1]); | |
var headers = ['Name', 'X', 'Y', 'RadiusX', 'RadiusY', 'Width', 'Height']; | |
var url = `https://omero.hms.harvard.edu/api/v0/m/images/${imgId}/`; | |
var urlRoi = `https://omero.hms.harvard.edu/api/v0/m/rois/?image=${imgId}`; | |
var imgName; | |
fetch(url) | |
.then(res => res.json()) | |
.then(resJson => | |
imgName = resJson.data.Name | |
) | |
.then(() => fetch(urlRoi) | |
.then(res => res.json()) | |
.then(resJson => | |
resJson.data | |
.map(data => { | |
data.shapes[0].Name = data.Name || 'undefined'; | |
return data.shapes | |
}) | |
.reduce((acc, val) => acc.concat(val), []) | |
.map(shape => headers.map(header => shape[header] || -1)) | |
) | |
.then(rois => rois.map(e => e.join(",")).join("\n")) | |
.then(roisStr => | |
"data:text/csv;charset=utf-8," + | |
headers.join(',') + '\n' + | |
roisStr) | |
.then(fullStr => encodeURI(fullStr)) | |
.then(uri => { | |
let link = document.createElement("a"); | |
link.setAttribute("href", uri); | |
link.setAttribute("download", `${imgName}-${imgId}-rois.csv`); | |
document.body.appendChild(link); | |
link.click(); | |
}) | |
) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Omero ROI extraction works in Omero.iviewer. The script is only slightly modified to work as a bookmarklet. Original creator is @Yu-AnChen