Need CLI script to download all images with a given tagID
Posted: Thu Feb 08, 2018 5:25 pm
What is the best approach?
Thanks!
j
Thanks!
j
The OME community
https://www.openmicroscopy.org/community/
https://www.openmicroscopy.org/community/viewtopic.php?f=6&t=8449
[jamoore@ome-c6100-1 dist]$ bin/omero -q hql "select a.id, count(i.id) from ImageAnnotationLink l join l.child a join l.parent i where a.class = ome.model.annotations.TagAnnotation group by a.id"
# | Col1 | Col2
---+-------+------
0 | 12786 | 1
1 | 12901 | 3
2 | 20259 | 2
3 | 12907 | 1
4 | 20260 | 1
5 | 12908 | 1
6 | 20253 | 1
7 | 20257 | 3
8 | 20258 | 3
(9 rows)
[jamoore@ome-c6100-1 dist]$ bin/omero -q hql "select i.id, i.name, p.sizeX, p.sizeY from ImageAnnotationLink l join l.child a join l.parent i join i.pixels p where a.id = 12901"
# | Col1 | Col2 | Col3 | Col4
---+-------+---------------------------+-------+-------
0 | 21905 | UMD001_ORO.svs [Series 3] | 1280 | 501
1 | 21904 | UMD001_ORO.svs [Series 2] | 416 | 482
2 | 21903 | UMD001_ORO.svs [Series 1] | 17317 | 11041
(3 rows)
[jamoore@ome-c6100-1 dist]$ for x in $(bin/omero -q hql "select i.id, i.name, p.sizeX, p.sizeY from ImageAnnotationLink l join l.child a join l.parent i join i.pixels p where a.id = 12901" --style=plain | head -n 2 | cut -f2 -d,); do bin/omero -q export Image:$x -f- >/dev/null ; done
jstitlow wrote:Thanks Josh!
That works.
Using the script that exports the original file, how do you name the output file with the original filename?
for x in $(/opt/OMERO.server-5.4.5-ice35-b83/bin/omero -q hql "select i.id, i.name, p.sizeX, p.sizeY from ImageAnnotationLink l join l.child a join l.parent i join i.pixels p where a.id = 2113196" --style=plain | head -n 2 | cut -f2 -d,); do /opt/OMERO.server-5.4.5-ice35-b83/bin/omero -q export Image:$x -f- >$x.ome.tiff ; done
for x in $(/opt/OMERO.server-5.4.5-ice35-b83/bin/omero -q hql "select i.id, i.name, p.sizeX, p.sizeY from ImageAnnotationLink l join l.child a join l.parent i join i.pixels p where a.id = 2113196" --style=plain | head -n 2 | cut -f2 -d,); do /opt/OMERO.server-5.4.5-ice35-b83/bin/omero fs ls Fileset:$FILESET_ID>$x ; done
usage: /opt/OMERO.server fs ls [-h] fileset
/opt/OMERO.server fs ls: error: argument fileset: invalid proxy value: 'Fileset:'
for i in $1; do
/opt/OMERO.server-5.4.5-ice35-b83/bin/omero import ${i} -T Dataset:+name:$2\
--group 'davisgroup'
done
jstitlow wrote:Do you have a simple Python script to import data into OMERO? Would be helpful for naive users like me to have import/export Python scripts where we can just plugin a path/datasetID and upload/download.
from omero.cli import cli_login
with cli_login() as cli:
cli.invoke("import --help")
The export script you reference above is perfect, would be handy to have something similar for import.
We have a nice BASH script for batch importing all files in a given directory:
- Code: Select all
for i in $1; do
/opt/OMERO.server-5.4.5-ice35-b83/bin/omero import ${i} -T Dataset:+name:$2\
--group 'davisgroup'
done
.. which can be called with command line arguments for 1=local directory where the data are located; and 2=OMERO dataset name.