-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/resources/script_templates/OMERO/Macro_Extensions/Read_key-value_pairs.ijm
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// @String(label="Username") USERNAME | ||
// @String(label="Password", style='password', persist=false) PASSWORD | ||
// @String(label="Host", value='wss://workshop.openmicroscopy.org/omero-ws') HOST | ||
// @Integer(label="Port", value=443) PORT | ||
// @Integer(label="Dataset ID", value=2331) dataset_id | ||
|
||
run("OMERO Extensions"); | ||
|
||
connected = Ext.connectToOMERO(HOST, PORT, USERNAME, PASSWORD); | ||
|
||
if(connected == "true") { | ||
// Read all key value pairs from a dataset | ||
kvs_dataset = Ext.getKeyValuePairs("dataset", dataset_id); | ||
|
||
// Default separator is a TAB | ||
kvs_dataset = split(kvs_dataset, "\t"); | ||
// ! If some cells are empty, split will ignore the double separators | ||
// -> add a space between them first with replace(kvs_dataset, "\t\t", "\t \t"); | ||
|
||
for(j=0; j<kvs_dataset.length; j=j+2){ | ||
// Every even index is the key, every odd index is the value | ||
print(kvs_dataset[j] + ": " + kvs_dataset[j+1]); | ||
} | ||
|
||
images = Ext.list("images", "dataset", dataset_id); | ||
image_ids = split(images, ","); | ||
for(i=0; i<image_ids.length; i++) { | ||
// Read from each image the value associated to the "condition" key | ||
condition_image = Ext.getValue("image", image_ids[i], "condition"); | ||
print(condition_image); | ||
} | ||
} | ||
|
||
Ext.disconnect(); | ||
print("processing done"); |